Search in sources :

Example 1 with DataNode

use of org.apache.zookeeper.server.DataNode in project zookeeper by apache.

the class LoadFromLogTest method testTxnFailure.

/**
     * For ZOOKEEPER-1046. Verify if cversion and pzxid if incremented
     * after create/delete failure during restore.
     */
@Test
public void testTxnFailure() throws Exception {
    long count = 1;
    File tmpDir = ClientBase.createTmpDir();
    FileTxnSnapLog logFile = new FileTxnSnapLog(tmpDir, tmpDir);
    DataTree dt = new DataTree();
    dt.createNode("/test", new byte[0], null, 0, -1, 1, 1);
    for (count = 1; count <= 3; count++) {
        dt.createNode("/test/" + count, new byte[0], null, 0, -1, count, Time.currentElapsedTime());
    }
    DataNode zk = dt.getNode("/test");
    // Make create to fail, then verify cversion.
    LOG.info("Attempting to create " + "/test/" + (count - 1));
    doOp(logFile, OpCode.create, "/test/" + (count - 1), dt, zk, -1);
    LOG.info("Attempting to create " + "/test/" + (count - 1));
    doOp(logFile, OpCode.create, "/test/" + (count - 1), dt, zk, zk.stat.getCversion() + 1);
    LOG.info("Attempting to create " + "/test/" + (count - 1));
    doOp(logFile, OpCode.multi, "/test/" + (count - 1), dt, zk, zk.stat.getCversion() + 1);
    LOG.info("Attempting to create " + "/test/" + (count - 1));
    doOp(logFile, OpCode.multi, "/test/" + (count - 1), dt, zk, -1);
// Make delete fo fail, then verify cversion.
// this doesn't happen anymore, we only set the cversion on create
// LOG.info("Attempting to delete " + "/test/" + (count + 1));
// doOp(logFile, OpCode.delete, "/test/" + (count + 1), dt, zk);
}
Also used : DataTree(org.apache.zookeeper.server.DataTree) DataNode(org.apache.zookeeper.server.DataNode) File(java.io.File) FileTxnSnapLog(org.apache.zookeeper.server.persistence.FileTxnSnapLog) Test(org.junit.Test)

Aggregations

File (java.io.File)1 DataNode (org.apache.zookeeper.server.DataNode)1 DataTree (org.apache.zookeeper.server.DataTree)1 FileTxnSnapLog (org.apache.zookeeper.server.persistence.FileTxnSnapLog)1 Test (org.junit.Test)1