/**
* create the old snapshot database
* apply logs to it and create the final
* database
* @throws IOException
*/
private void loadThisSnapShot() throws IOException {
// pick the most recent snapshot
File snapshot = findMostRecentSnapshot();
if (snapshot == null) {
throw new IOException("Invalid snapshots " +
"or not snapshots in " + snapShotDir);
}
InputStream inputstream = new BufferedInputStream(
new FileInputStream(snapshot));
InputArchive ia = BinaryInputArchive.getArchive(inputstream);
deserializeSnapshot(oldDataTree, ia, sessionsWithTimeouts);
//ok done with the snapshot
// now apply the logs
long snapshotZxid = oldDataTree.lastProcessedZxid;
File[] files = FileTxnLog.getLogFiles(
dataDir.listFiles(), snapshotZxid);
long zxid = processLogFiles(oldDataTree, files);
//check for this zxid to be sane
if (zxid != oldDataTree.lastProcessedZxid) {
LOG.error("Zxids not equal " + " log zxid " +
zxid + " datatree processed " + oldDataTree.lastProcessedZxid);
}
}
java类org.apache.zookeeper.server.persistence.FileTxnLog的实例源码
UpgradeSnapShotV1.java 文件源码
项目:fuck_zookeeper
阅读 30
收藏 0
点赞 0
评论 0
ZooKeeperServerTest.java 文件源码
项目:fuck_zookeeper
阅读 44
收藏 0
点赞 0
评论 0
@Test
public void testGetLogFiles() {
File[] files = new File[5];
files[0] = new File("log.10027c6de");
files[1] = new File("log.10027c6df");
files[2] = new File("snapshot.10027c6dd");
files[3] = new File("log.10027c6dc");
files[4] = new File("log.20027c6dc");
File[] orig = files.clone();
File[] filelist =
FileTxnLog.getLogFiles(files,
Long.parseLong("10027c6de", 16));
Assert.assertEquals(3, filelist.length);
Assert.assertEquals(orig[0], filelist[0]);
Assert.assertEquals(orig[1], filelist[1]);
Assert.assertEquals(orig[4], filelist[2]);
}
LoadFromLogTest.java 文件源码
项目:fuck_zookeeper
阅读 38
收藏 0
点赞 0
评论 0
/**
* Simulates ZOOKEEPER-1069 and verifies that flush() before padLogFile
* fixes it.
*/
@Test
public void testPad() throws Exception {
File tmpDir = ClientBase.createTmpDir();
FileTxnLog txnLog = new FileTxnLog(tmpDir);
TxnHeader txnHeader = new TxnHeader(0xabcd, 0x123, 0x123,
System.currentTimeMillis(), OpCode.create);
Record txn = new CreateTxn("/Test", new byte[0], null, false, 1);
txnLog.append(txnHeader, txn);
FileInputStream in = new FileInputStream(tmpDir.getPath() + "/log." +
Long.toHexString(txnHeader.getZxid()));
BinaryInputArchive ia = BinaryInputArchive.getArchive(in);
FileHeader header = new FileHeader();
header.deserialize(ia, "fileheader");
LOG.info("Received magic : " + header.getMagic() +
" Expected : " + FileTxnLog.TXNLOG_MAGIC);
Assert.assertTrue("Missing magic number ",
header.getMagic() == FileTxnLog.TXNLOG_MAGIC);
}
ZooKeeperServerTest.java 文件源码
项目:https-github.com-apache-zookeeper
阅读 27
收藏 0
点赞 0
评论 0
@Test
public void testGetLogFiles() {
File[] files = new File[5];
files[0] = new File("log.10027c6de");
files[1] = new File("log.10027c6df");
files[2] = new File("snapshot.10027c6dd");
files[3] = new File("log.10027c6dc");
files[4] = new File("log.20027c6dc");
File[] orig = files.clone();
File[] filelist =
FileTxnLog.getLogFiles(files,
Long.parseLong("10027c6de", 16));
Assert.assertEquals(3, filelist.length);
Assert.assertEquals(orig[0], filelist[0]);
Assert.assertEquals(orig[1], filelist[1]);
Assert.assertEquals(orig[4], filelist[2]);
}
LoadFromLogTest.java 文件源码
项目:https-github.com-apache-zookeeper
阅读 29
收藏 0
点赞 0
评论 0
/**
* Simulates ZOOKEEPER-1069 and verifies that flush() before padLogFile
* fixes it.
*/
@Test
public void testPad() throws Exception {
File tmpDir = ClientBase.createTmpDir();
FileTxnLog txnLog = new FileTxnLog(tmpDir);
TxnHeader txnHeader = new TxnHeader(0xabcd, 0x123, 0x123,
Time.currentElapsedTime(), OpCode.create);
Record txn = new CreateTxn("/Test", new byte[0], null, false, 1);
txnLog.append(txnHeader, txn);
FileInputStream in = new FileInputStream(tmpDir.getPath() + "/log." +
Long.toHexString(txnHeader.getZxid()));
BinaryInputArchive ia = BinaryInputArchive.getArchive(in);
FileHeader header = new FileHeader();
header.deserialize(ia, "fileheader");
LOG.info("Received magic : " + header.getMagic() +
" Expected : " + FileTxnLog.TXNLOG_MAGIC);
Assert.assertTrue("Missing magic number ",
header.getMagic() == FileTxnLog.TXNLOG_MAGIC);
}
UpgradeSnapShotV1.java 文件源码
项目:ZooKeeper
阅读 31
收藏 0
点赞 0
评论 0
/**
* create the old snapshot database
* apply logs to it and create the final
* database
* @throws IOException
*/
private void loadThisSnapShot() throws IOException {
// pick the most recent snapshot
File snapshot = findMostRecentSnapshot();
if (snapshot == null) {
throw new IOException("Invalid snapshots " +
"or not snapshots in " + snapShotDir);
}
InputStream inputstream = new BufferedInputStream(
new FileInputStream(snapshot));
InputArchive ia = BinaryInputArchive.getArchive(inputstream);
deserializeSnapshot(oldDataTree, ia, sessionsWithTimeouts);
//ok done with the snapshot
// now apply the logs
long snapshotZxid = oldDataTree.lastProcessedZxid;
File[] files = FileTxnLog.getLogFiles(
dataDir.listFiles(), snapshotZxid);
long zxid = processLogFiles(oldDataTree, files);
//check for this zxid to be sane
if (zxid != oldDataTree.lastProcessedZxid) {
LOG.error("Zxids not equal " + " log zxid " +
zxid + " datatree processed " + oldDataTree.lastProcessedZxid);
}
}
ZooKeeperServerTest.java 文件源码
项目:ZooKeeper
阅读 45
收藏 0
点赞 0
评论 0
@Test
public void testGetLogFiles() {
File[] files = new File[5];
files[0] = new File("log.10027c6de");
files[1] = new File("log.10027c6df");
files[2] = new File("snapshot.10027c6dd");
files[3] = new File("log.10027c6dc");
files[4] = new File("log.20027c6dc");
File[] orig = files.clone();
File[] filelist =
FileTxnLog.getLogFiles(files,
Long.parseLong("10027c6de", 16));
Assert.assertEquals(3, filelist.length);
Assert.assertEquals(orig[0], filelist[0]);
Assert.assertEquals(orig[1], filelist[1]);
Assert.assertEquals(orig[4], filelist[2]);
}
LoadFromLogTest.java 文件源码
项目:ZooKeeper
阅读 29
收藏 0
点赞 0
评论 0
/**
* Simulates ZOOKEEPER-1069 and verifies that flush() before padLogFile
* fixes it.
*/
@Test
public void testPad() throws Exception {
File tmpDir = ClientBase.createTmpDir();
FileTxnLog txnLog = new FileTxnLog(tmpDir);
TxnHeader txnHeader = new TxnHeader(0xabcd, 0x123, 0x123,
System.currentTimeMillis(), OpCode.create);
Record txn = new CreateTxn("/Test", new byte[0], null, false, 1);
txnLog.append(txnHeader, txn);
FileInputStream in = new FileInputStream(tmpDir.getPath() + "/log." +
Long.toHexString(txnHeader.getZxid()));
BinaryInputArchive ia = BinaryInputArchive.getArchive(in);
FileHeader header = new FileHeader();
header.deserialize(ia, "fileheader");
LOG.info("Received magic : " + header.getMagic() +
" Expected : " + FileTxnLog.TXNLOG_MAGIC);
Assert.assertTrue("Missing magic number ",
header.getMagic() == FileTxnLog.TXNLOG_MAGIC);
}
UpgradeSnapShotV1.java 文件源码
项目:StreamProcessingInfrastructure
阅读 31
收藏 0
点赞 0
评论 0
/**
* create the old snapshot database
* apply logs to it and create the final
* database
* @throws IOException
*/
private void loadThisSnapShot() throws IOException {
// pick the most recent snapshot
File snapshot = findMostRecentSnapshot();
if (snapshot == null) {
throw new IOException("Invalid snapshots " +
"or not snapshots in " + snapShotDir);
}
InputStream inputstream = new BufferedInputStream(
new FileInputStream(snapshot));
InputArchive ia = BinaryInputArchive.getArchive(inputstream);
deserializeSnapshot(oldDataTree, ia, sessionsWithTimeouts);
//ok done with the snapshot
// now apply the logs
long snapshotZxid = oldDataTree.lastProcessedZxid;
File[] files = FileTxnLog.getLogFiles(
dataDir.listFiles(), snapshotZxid);
long zxid = processLogFiles(oldDataTree, files);
//check for this zxid to be sane
if (zxid != oldDataTree.lastProcessedZxid) {
LOG.error("Zxids not equal " + " log zxid " +
zxid + " datatree processed " + oldDataTree.lastProcessedZxid);
}
}
ZooKeeperServerTest.java 文件源码
项目:StreamProcessingInfrastructure
阅读 31
收藏 0
点赞 0
评论 0
@Test
public void testGetLogFiles() {
File[] files = new File[5];
files[0] = new File("log.10027c6de");
files[1] = new File("log.10027c6df");
files[2] = new File("snapshot.10027c6dd");
files[3] = new File("log.10027c6dc");
files[4] = new File("log.20027c6dc");
File[] orig = files.clone();
File[] filelist =
FileTxnLog.getLogFiles(files,
Long.parseLong("10027c6de", 16));
Assert.assertEquals(3, filelist.length);
Assert.assertEquals(orig[0], filelist[0]);
Assert.assertEquals(orig[1], filelist[1]);
Assert.assertEquals(orig[4], filelist[2]);
}
LoadFromLogTest.java 文件源码
项目:StreamProcessingInfrastructure
阅读 32
收藏 0
点赞 0
评论 0
/**
* Simulates ZOOKEEPER-1069 and verifies that flush() before padLogFile
* fixes it.
*/
@Test
public void testPad() throws Exception {
File tmpDir = ClientBase.createTmpDir();
FileTxnLog txnLog = new FileTxnLog(tmpDir);
TxnHeader txnHeader = new TxnHeader(0xabcd, 0x123, 0x123,
System.currentTimeMillis(), OpCode.create);
Record txn = new CreateTxn("/Test", new byte[0], null, false, 1);
txnLog.append(txnHeader, txn);
FileInputStream in = new FileInputStream(tmpDir.getPath() + "/log." +
Long.toHexString(txnHeader.getZxid()));
BinaryInputArchive ia = BinaryInputArchive.getArchive(in);
FileHeader header = new FileHeader();
header.deserialize(ia, "fileheader");
LOG.info("Received magic : " + header.getMagic() +
" Expected : " + FileTxnLog.TXNLOG_MAGIC);
Assert.assertTrue("Missing magic number ",
header.getMagic() == FileTxnLog.TXNLOG_MAGIC);
}
UpgradeSnapShotV1.java 文件源码
项目:bigstreams
阅读 31
收藏 0
点赞 0
评论 0
/**
* create the old snapshot database
* apply logs to it and create the final
* database
* @throws IOException
*/
private void loadThisSnapShot() throws IOException {
// pick the most recent snapshot
File snapshot = findMostRecentSnapshot();
if (snapshot == null) {
throw new IOException("Invalid snapshots " +
"or not snapshots in " + snapShotDir);
}
InputStream inputstream = new BufferedInputStream(
new FileInputStream(snapshot));
InputArchive ia = BinaryInputArchive.getArchive(inputstream);
deserializeSnapshot(oldDataTree, ia, sessionsWithTimeouts);
//ok done with the snapshot
// now apply the logs
long snapshotZxid = oldDataTree.lastProcessedZxid;
File[] files = FileTxnLog.getLogFiles(
dataDir.listFiles(), snapshotZxid);
long zxid = processLogFiles(oldDataTree, files);
//check for this zxid to be sane
if (zxid != oldDataTree.lastProcessedZxid) {
LOG.error("Zxids not equal " + " log zxid " +
zxid + " datatree processed " + oldDataTree.lastProcessedZxid);
}
}
ZooKeeperServerTest.java 文件源码
项目:bigstreams
阅读 40
收藏 0
点赞 0
评论 0
@Test
public void testGetLogFiles() {
File[] files = new File[5];
files[0] = new File("log.10027c6de");
files[1] = new File("log.10027c6df");
files[2] = new File("snapshot.10027c6dd");
files[3] = new File("log.10027c6dc");
files[4] = new File("log.20027c6dc");
File[] orig = files.clone();
File[] filelist =
FileTxnLog.getLogFiles(files,
Long.parseLong("10027c6de", 16));
Assert.assertEquals(3, filelist.length);
Assert.assertEquals(orig[0], filelist[0]);
Assert.assertEquals(orig[1], filelist[1]);
Assert.assertEquals(orig[4], filelist[2]);
}
LoadFromLogTest.java 文件源码
项目:bigstreams
阅读 46
收藏 0
点赞 0
评论 0
/**
* Simulates ZOOKEEPER-1069 and verifies that flush() before padLogFile
* fixes it.
*/
@Test
public void testPad() throws Exception {
File tmpDir = ClientBase.createTmpDir();
FileTxnLog txnLog = new FileTxnLog(tmpDir);
TxnHeader txnHeader = new TxnHeader(0xabcd, 0x123, 0x123,
System.currentTimeMillis(), OpCode.create);
Record txn = new CreateTxn("/Test", new byte[0], null, false, 1);
txnLog.append(txnHeader, txn);
FileInputStream in = new FileInputStream(tmpDir.getPath() + "/log." +
Long.toHexString(txnHeader.getZxid()));
BinaryInputArchive ia = BinaryInputArchive.getArchive(in);
FileHeader header = new FileHeader();
header.deserialize(ia, "fileheader");
LOG.info("Received magic : " + header.getMagic() +
" Expected : " + FileTxnLog.TXNLOG_MAGIC);
Assert.assertTrue("Missing magic number ",
header.getMagic() == FileTxnLog.TXNLOG_MAGIC);
}
UpgradeSnapShotV1.java 文件源码
项目:bigstreams
阅读 43
收藏 0
点赞 0
评论 0
/**
* create the old snapshot database
* apply logs to it and create the final
* database
* @throws IOException
*/
private void loadThisSnapShot() throws IOException {
// pick the most recent snapshot
File snapshot = findMostRecentSnapshot();
if (snapshot == null) {
throw new IOException("Invalid snapshots " +
"or not snapshots in " + snapShotDir);
}
InputStream inputstream = new BufferedInputStream(
new FileInputStream(snapshot));
InputArchive ia = BinaryInputArchive.getArchive(inputstream);
deserializeSnapshot(oldDataTree, ia, sessionsWithTimeouts);
//ok done with the snapshot
// now apply the logs
long snapshotZxid = oldDataTree.lastProcessedZxid;
File[] files = FileTxnLog.getLogFiles(
dataDir.listFiles(), snapshotZxid);
long zxid = processLogFiles(oldDataTree, files);
//check for this zxid to be sane
if (zxid != oldDataTree.lastProcessedZxid) {
LOG.error("Zxids not equal " + " log zxid " +
zxid + " datatree processed " + oldDataTree.lastProcessedZxid);
}
}
ZooKeeperServerTest.java 文件源码
项目:bigstreams
阅读 33
收藏 0
点赞 0
评论 0
@Test
public void testGetLogFiles() {
File[] files = new File[5];
files[0] = new File("log.10027c6de");
files[1] = new File("log.10027c6df");
files[2] = new File("snapshot.10027c6dd");
files[3] = new File("log.10027c6dc");
files[4] = new File("log.20027c6dc");
File[] orig = files.clone();
File[] filelist =
FileTxnLog.getLogFiles(files,
Long.parseLong("10027c6de", 16));
Assert.assertEquals(3, filelist.length);
Assert.assertEquals(orig[0], filelist[0]);
Assert.assertEquals(orig[1], filelist[1]);
Assert.assertEquals(orig[4], filelist[2]);
}
LoadFromLogTest.java 文件源码
项目:bigstreams
阅读 39
收藏 0
点赞 0
评论 0
/**
* Simulates ZOOKEEPER-1069 and verifies that flush() before padLogFile
* fixes it.
*/
@Test
public void testPad() throws Exception {
File tmpDir = ClientBase.createTmpDir();
FileTxnLog txnLog = new FileTxnLog(tmpDir);
TxnHeader txnHeader = new TxnHeader(0xabcd, 0x123, 0x123,
System.currentTimeMillis(), OpCode.create);
Record txn = new CreateTxn("/Test", new byte[0], null, false, 1);
txnLog.append(txnHeader, txn);
FileInputStream in = new FileInputStream(tmpDir.getPath() + "/log." +
Long.toHexString(txnHeader.getZxid()));
BinaryInputArchive ia = BinaryInputArchive.getArchive(in);
FileHeader header = new FileHeader();
header.deserialize(ia, "fileheader");
LOG.info("Expected header :" + header.getMagic() +
" Received : " + FileTxnLog.TXNLOG_MAGIC);
Assert.assertTrue("Missing magic number ",
header.getMagic() == FileTxnLog.TXNLOG_MAGIC);
}
UpgradeSnapShotV1.java 文件源码
项目:zookeeper-src-learning
阅读 29
收藏 0
点赞 0
评论 0
/**
* create the old snapshot database
* apply logs to it and create the final
* database
* @throws IOException
*/
private void loadThisSnapShot() throws IOException {
// pick the most recent snapshot
File snapshot = findMostRecentSnapshot();
if (snapshot == null) {
throw new IOException("Invalid snapshots " +
"or not snapshots in " + snapShotDir);
}
InputStream inputstream = new BufferedInputStream(
new FileInputStream(snapshot));
InputArchive ia = BinaryInputArchive.getArchive(inputstream);
deserializeSnapshot(oldDataTree, ia, sessionsWithTimeouts);
//ok done with the snapshot
// now apply the logs
long snapshotZxid = oldDataTree.lastProcessedZxid;
File[] files = FileTxnLog.getLogFiles(
dataDir.listFiles(), snapshotZxid);
long zxid = processLogFiles(oldDataTree, files);
//check for this zxid to be sane
if (zxid != oldDataTree.lastProcessedZxid) {
LOG.error("Zxids not equal " + " log zxid " +
zxid + " datatree processed " + oldDataTree.lastProcessedZxid);
}
}
UpgradeSnapShotV1.java 文件源码
项目:zookeeper
阅读 32
收藏 0
点赞 0
评论 0
/**
* create the old snapshot database
* apply logs to it and create the final
* database
* @throws IOException
*/
private void loadThisSnapShot() throws IOException {
// pick the most recent snapshot
File snapshot = findMostRecentSnapshot();
if (snapshot == null) {
throw new IOException("Invalid snapshots " +
"or not snapshots in " + snapShotDir);
}
InputStream inputstream = new BufferedInputStream(
new FileInputStream(snapshot));
InputArchive ia = BinaryInputArchive.getArchive(inputstream);
deserializeSnapshot(oldDataTree, ia, sessionsWithTimeouts);
//ok done with the snapshot
// now apply the logs
long snapshotZxid = oldDataTree.lastProcessedZxid;
File[] files = FileTxnLog.getLogFiles(
dataDir.listFiles(), snapshotZxid);
long zxid = processLogFiles(oldDataTree, files);
//check for this zxid to be sane
if (zxid != oldDataTree.lastProcessedZxid) {
LOG.error("Zxids not equal " + " log zxid " +
zxid + " datatree processed " + oldDataTree.lastProcessedZxid);
}
}
ZooKeeperServerTest.java 文件源码
项目:zookeeper
阅读 27
收藏 0
点赞 0
评论 0
@Test
public void testGetLogFiles() {
File[] files = new File[5];
files[0] = new File("log.10027c6de");
files[1] = new File("log.10027c6df");
files[2] = new File("snapshot.10027c6dd");
files[3] = new File("log.10027c6dc");
files[4] = new File("log.20027c6dc");
File[] orig = files.clone();
File[] filelist =
FileTxnLog.getLogFiles(files,
Long.parseLong("10027c6de", 16));
Assert.assertEquals(3, filelist.length);
Assert.assertEquals(orig[0], filelist[0]);
Assert.assertEquals(orig[1], filelist[1]);
Assert.assertEquals(orig[4], filelist[2]);
}
LoadFromLogTest.java 文件源码
项目:zookeeper
阅读 28
收藏 0
点赞 0
评论 0
/**
* Simulates ZOOKEEPER-1069 and verifies that flush() before padLogFile
* fixes it.
*/
@Test
public void testPad() throws Exception {
File tmpDir = ClientBase.createTmpDir();
FileTxnLog txnLog = new FileTxnLog(tmpDir);
TxnHeader txnHeader = new TxnHeader(0xabcd, 0x123, 0x123,
System.currentTimeMillis(), OpCode.create);
Record txn = new CreateTxn("/Test", new byte[0], null, false, 1);
txnLog.append(txnHeader, txn);
FileInputStream in = new FileInputStream(tmpDir.getPath() + "/log." +
Long.toHexString(txnHeader.getZxid()));
BinaryInputArchive ia = BinaryInputArchive.getArchive(in);
FileHeader header = new FileHeader();
header.deserialize(ia, "fileheader");
LOG.info("Received magic : " + header.getMagic() +
" Expected : " + FileTxnLog.TXNLOG_MAGIC);
Assert.assertTrue("Missing magic number ",
header.getMagic() == FileTxnLog.TXNLOG_MAGIC);
}
ZooKeeperServerTest.java 文件源码
项目:SecureKeeper
阅读 60
收藏 0
点赞 0
评论 0
@Test
public void testGetLogFiles() {
File[] files = new File[5];
files[0] = new File("log.10027c6de");
files[1] = new File("log.10027c6df");
files[2] = new File("snapshot.10027c6dd");
files[3] = new File("log.10027c6dc");
files[4] = new File("log.20027c6dc");
File[] orig = files.clone();
File[] filelist =
FileTxnLog.getLogFiles(files,
Long.parseLong("10027c6de", 16));
Assert.assertEquals(3, filelist.length);
Assert.assertEquals(orig[0], filelist[0]);
Assert.assertEquals(orig[1], filelist[1]);
Assert.assertEquals(orig[4], filelist[2]);
}
LoadFromLogTest.java 文件源码
项目:SecureKeeper
阅读 40
收藏 0
点赞 0
评论 0
/**
* Simulates ZOOKEEPER-1069 and verifies that flush() before padLogFile
* fixes it.
*/
@Test
public void testPad() throws Exception {
File tmpDir = ClientBase.createTmpDir();
FileTxnLog txnLog = new FileTxnLog(tmpDir);
TxnHeader txnHeader = new TxnHeader(0xabcd, 0x123, 0x123,
Time.currentElapsedTime(), OpCode.create);
Record txn = new CreateTxn("/Test", new byte[0], null, false, 1);
txnLog.append(txnHeader, txn);
FileInputStream in = new FileInputStream(tmpDir.getPath() + "/log." +
Long.toHexString(txnHeader.getZxid()));
BinaryInputArchive ia = BinaryInputArchive.getArchive(in);
FileHeader header = new FileHeader();
header.deserialize(ia, "fileheader");
LOG.info("Received magic : " + header.getMagic() +
" Expected : " + FileTxnLog.TXNLOG_MAGIC);
Assert.assertTrue("Missing magic number ",
header.getMagic() == FileTxnLog.TXNLOG_MAGIC);
}
ZooKeeperServerTest.java 文件源码
项目:SecureKeeper
阅读 31
收藏 0
点赞 0
评论 0
@Test
public void testGetLogFiles() {
File[] files = new File[5];
files[0] = new File("log.10027c6de");
files[1] = new File("log.10027c6df");
files[2] = new File("snapshot.10027c6dd");
files[3] = new File("log.10027c6dc");
files[4] = new File("log.20027c6dc");
File[] orig = files.clone();
File[] filelist =
FileTxnLog.getLogFiles(files,
Long.parseLong("10027c6de", 16));
Assert.assertEquals(3, filelist.length);
Assert.assertEquals(orig[0], filelist[0]);
Assert.assertEquals(orig[1], filelist[1]);
Assert.assertEquals(orig[4], filelist[2]);
}
LoadFromLogTest.java 文件源码
项目:SecureKeeper
阅读 41
收藏 0
点赞 0
评论 0
/**
* Simulates ZOOKEEPER-1069 and verifies that flush() before padLogFile
* fixes it.
*/
@Test
public void testPad() throws Exception {
File tmpDir = ClientBase.createTmpDir();
FileTxnLog txnLog = new FileTxnLog(tmpDir);
TxnHeader txnHeader = new TxnHeader(0xabcd, 0x123, 0x123,
Time.currentElapsedTime(), OpCode.create);
Record txn = new CreateTxn("/Test", new byte[0], null, false, 1);
txnLog.append(txnHeader, txn);
FileInputStream in = new FileInputStream(tmpDir.getPath() + "/log." +
Long.toHexString(txnHeader.getZxid()));
BinaryInputArchive ia = BinaryInputArchive.getArchive(in);
FileHeader header = new FileHeader();
header.deserialize(ia, "fileheader");
LOG.info("Received magic : " + header.getMagic() +
" Expected : " + FileTxnLog.TXNLOG_MAGIC);
Assert.assertTrue("Missing magic number ",
header.getMagic() == FileTxnLog.TXNLOG_MAGIC);
}
ZooKeeperLogParser.java 文件源码
项目:exhibitor
阅读 20
收藏 0
点赞 0
评论 0
public ZooKeeperLogParser(InputStream log)
{
logStream = BinaryInputArchive.getArchive(log);
boolean localValidHeader = false;
try
{
FileHeader fhdr = new FileHeader();
fhdr.deserialize(logStream, "fileheader");
localValidHeader = (fhdr.getMagic() == FileTxnLog.TXNLOG_MAGIC);
}
catch ( IOException e )
{
// ignore
}
validHeader = localValidHeader;
}
UpgradeSnapShotV1.java 文件源码
项目:StreamBench
阅读 31
收藏 0
点赞 0
评论 0
/**
* create the old snapshot database
* apply logs to it and create the final
* database
* @throws IOException
*/
private void loadThisSnapShot() throws IOException {
// pick the most recent snapshot
File snapshot = findMostRecentSnapshot();
if (snapshot == null) {
throw new IOException("Invalid snapshots " +
"or not snapshots in " + snapShotDir);
}
InputStream inputstream = new BufferedInputStream(
new FileInputStream(snapshot));
InputArchive ia = BinaryInputArchive.getArchive(inputstream);
deserializeSnapshot(oldDataTree, ia, sessionsWithTimeouts);
//ok done with the snapshot
// now apply the logs
long snapshotZxid = oldDataTree.lastProcessedZxid;
File[] files = FileTxnLog.getLogFiles(
dataDir.listFiles(), snapshotZxid);
long zxid = processLogFiles(oldDataTree, files);
//check for this zxid to be sane
if (zxid != oldDataTree.lastProcessedZxid) {
LOG.error("Zxids not equal " + " log zxid " +
zxid + " datatree processed " + oldDataTree.lastProcessedZxid);
}
}
ZooKeeperServerTest.java 文件源码
项目:StreamBench
阅读 31
收藏 0
点赞 0
评论 0
@Test
public void testGetLogFiles() {
File[] files = new File[5];
files[0] = new File("log.10027c6de");
files[1] = new File("log.10027c6df");
files[2] = new File("snapshot.10027c6dd");
files[3] = new File("log.10027c6dc");
files[4] = new File("log.20027c6dc");
File[] orig = files.clone();
File[] filelist =
FileTxnLog.getLogFiles(files,
Long.parseLong("10027c6de", 16));
Assert.assertEquals(3, filelist.length);
Assert.assertEquals(orig[0], filelist[0]);
Assert.assertEquals(orig[1], filelist[1]);
Assert.assertEquals(orig[4], filelist[2]);
}
LoadFromLogTest.java 文件源码
项目:StreamBench
阅读 41
收藏 0
点赞 0
评论 0
/**
* Simulates ZOOKEEPER-1069 and verifies that flush() before padLogFile
* fixes it.
*/
@Test
public void testPad() throws Exception {
File tmpDir = ClientBase.createTmpDir();
FileTxnLog txnLog = new FileTxnLog(tmpDir);
TxnHeader txnHeader = new TxnHeader(0xabcd, 0x123, 0x123,
System.currentTimeMillis(), OpCode.create);
Record txn = new CreateTxn("/Test", new byte[0], null, false, 1);
txnLog.append(txnHeader, txn);
FileInputStream in = new FileInputStream(tmpDir.getPath() + "/log." +
Long.toHexString(txnHeader.getZxid()));
BinaryInputArchive ia = BinaryInputArchive.getArchive(in);
FileHeader header = new FileHeader();
header.deserialize(ia, "fileheader");
LOG.info("Received magic : " + header.getMagic() +
" Expected : " + FileTxnLog.TXNLOG_MAGIC);
Assert.assertTrue("Missing magic number ",
header.getMagic() == FileTxnLog.TXNLOG_MAGIC);
}
UpgradeSnapShotV1.java 文件源码
项目:ACaZoo
阅读 28
收藏 0
点赞 0
评论 0
/**
* create the old snapshot database
* apply logs to it and create the final
* database
* @throws IOException
*/
private void loadThisSnapShot() throws IOException {
// pick the most recent snapshot
File snapshot = findMostRecentSnapshot();
if (snapshot == null) {
throw new IOException("Invalid snapshots " +
"or not snapshots in " + snapShotDir);
}
InputStream inputstream = new BufferedInputStream(
new FileInputStream(snapshot));
InputArchive ia = BinaryInputArchive.getArchive(inputstream);
deserializeSnapshot(oldDataTree, ia, sessionsWithTimeouts);
//ok done with the snapshot
// now apply the logs
long snapshotZxid = oldDataTree.lastProcessedZxid;
File[] files = FileTxnLog.getLogFiles(
dataDir.listFiles(), snapshotZxid);
long zxid = processLogFiles(oldDataTree, files);
//check for this zxid to be sane
if (zxid != oldDataTree.lastProcessedZxid) {
LOG.error("Zxids not equal " + " log zxid " +
zxid + " datatree processed " + oldDataTree.lastProcessedZxid);
}
}