当前位置: 首页>>代码示例>>Java>>正文


Java FileTxnLog类代码示例

本文整理汇总了Java中org.apache.zookeeper.server.persistence.FileTxnLog的典型用法代码示例。如果您正苦于以下问题:Java FileTxnLog类的具体用法?Java FileTxnLog怎么用?Java FileTxnLog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FileTxnLog类属于org.apache.zookeeper.server.persistence包,在下文中一共展示了FileTxnLog类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadThisSnapShot

import org.apache.zookeeper.server.persistence.FileTxnLog; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:30,代码来源:UpgradeSnapShotV1.java

示例2: testGetLogFiles

import org.apache.zookeeper.server.persistence.FileTxnLog; //导入依赖的package包/类
@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]);
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:22,代码来源:ZooKeeperServerTest.java

示例3: testPad

import org.apache.zookeeper.server.persistence.FileTxnLog; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:23,代码来源:LoadFromLogTest.java

示例4: testPad

import org.apache.zookeeper.server.persistence.FileTxnLog; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:23,代码来源:LoadFromLogTest.java

示例5: testPad

import org.apache.zookeeper.server.persistence.FileTxnLog; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:23,代码来源:LoadFromLogTest.java

示例6: ZooKeeperLogParser

import org.apache.zookeeper.server.persistence.FileTxnLog; //导入依赖的package包/类
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;
}
 
开发者ID:dcos,项目名称:exhibitor,代码行数:18,代码来源:ZooKeeperLogParser.java

示例7: testGetLogFiles

import org.apache.zookeeper.server.persistence.FileTxnLog; //导入依赖的package包/类
@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));

    assertEquals(3, filelist.length);
    assertEquals(orig[0], filelist[0]);
    assertEquals(orig[1], filelist[1]);
    assertEquals(orig[4], filelist[2]);
}
 
开发者ID:prodigeni,项目名称:zookeeper.dsc,代码行数:22,代码来源:ZooKeeperServerTest.java

示例8: testPad

import org.apache.zookeeper.server.persistence.FileTxnLog; //导入依赖的package包/类
/**
 * 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);
    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");
    Assert.assertTrue("Missing magic number ",
          header.getMagic() == FileTxnLog.TXNLOG_MAGIC);
}
 
开发者ID:prodigeni,项目名称:zookeeper.dsc,代码行数:21,代码来源:LoadFromLogTest.java


注:本文中的org.apache.zookeeper.server.persistence.FileTxnLog类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。