Search in sources :

Example 11 with ZkVersion

use of org.apache.bookkeeper.meta.ZkVersion in project distributedlog by twitter.

the class TestZKLogMetadataForWriterUtilFunctions method testProcessLogMetadatasWrongVersion.

@SuppressWarnings("unchecked")
@Test(timeout = 60000, expected = UnexpectedException.class)
public void testProcessLogMetadatasWrongVersion() throws Exception {
    String rootPath = "/test-missing-version";
    URI uri = DLMTestUtil.createDLMURI(2181, rootPath);
    String logName = "test-log";
    String logIdentifier = "<default>";
    List<Versioned<byte[]>> metadatas = Lists.newArrayList(new Versioned<byte[]>(null, null), new Versioned<byte[]>(null, null), new Versioned<byte[]>(DLUtils.serializeTransactionId(1L), new ZkVersion(1)), new Versioned<byte[]>(ZKLogMetadataForWriter.intToBytes(9999), null));
    ZKLogMetadataForWriter.processLogMetadatas(uri, logName, logIdentifier, metadatas, false);
}
Also used : Versioned(org.apache.bookkeeper.versioning.Versioned) URI(java.net.URI) ZkVersion(org.apache.bookkeeper.meta.ZkVersion) Test(org.junit.Test)

Example 12 with ZkVersion

use of org.apache.bookkeeper.meta.ZkVersion in project distributedlog by twitter.

the class TestZKLogMetadataForWriterUtilFunctions method testProcessLogMetadatasMissingAllocatorPath.

@SuppressWarnings("unchecked")
@Test(timeout = 60000, expected = UnexpectedException.class)
public void testProcessLogMetadatasMissingAllocatorPath() throws Exception {
    String rootPath = "/test-missing-version";
    URI uri = DLMTestUtil.createDLMURI(2181, rootPath);
    String logName = "test-log";
    String logIdentifier = "<default>";
    List<Versioned<byte[]>> metadatas = Lists.newArrayList(new Versioned<byte[]>(null, null), new Versioned<byte[]>(null, null), new Versioned<byte[]>(DLUtils.serializeTransactionId(1L), new ZkVersion(1)), new Versioned<byte[]>(ZKLogMetadataForWriter.intToBytes(ZKLogMetadata.LAYOUT_VERSION), null), new Versioned<byte[]>(new byte[0], new ZkVersion(1)), new Versioned<byte[]>(new byte[0], new ZkVersion(1)), new Versioned<byte[]>(DLUtils.serializeLogSegmentSequenceNumber(1L), new ZkVersion(1)), new Versioned<byte[]>(null, null));
    ZKLogMetadataForWriter.processLogMetadatas(uri, logName, logIdentifier, metadatas, true);
}
Also used : Versioned(org.apache.bookkeeper.versioning.Versioned) URI(java.net.URI) ZkVersion(org.apache.bookkeeper.meta.ZkVersion) Test(org.junit.Test)

Example 13 with ZkVersion

use of org.apache.bookkeeper.meta.ZkVersion in project distributedlog by twitter.

the class TestZKLogMetadataForWriterUtilFunctions method testProcessLogMetadatasMissingLogSegmentsPath.

@SuppressWarnings("unchecked")
@Test(timeout = 60000, expected = UnexpectedException.class)
public void testProcessLogMetadatasMissingLogSegmentsPath() throws Exception {
    String rootPath = "/test-missing-version";
    URI uri = DLMTestUtil.createDLMURI(2181, rootPath);
    String logName = "test-log";
    String logIdentifier = "<default>";
    List<Versioned<byte[]>> metadatas = Lists.newArrayList(new Versioned<byte[]>(null, null), new Versioned<byte[]>(null, null), new Versioned<byte[]>(DLUtils.serializeTransactionId(1L), new ZkVersion(1)), new Versioned<byte[]>(ZKLogMetadataForWriter.intToBytes(ZKLogMetadata.LAYOUT_VERSION), null), new Versioned<byte[]>(new byte[0], new ZkVersion(1)), new Versioned<byte[]>(new byte[0], new ZkVersion(1)), new Versioned<byte[]>(null, null));
    ZKLogMetadataForWriter.processLogMetadatas(uri, logName, logIdentifier, metadatas, false);
}
Also used : Versioned(org.apache.bookkeeper.versioning.Versioned) URI(java.net.URI) ZkVersion(org.apache.bookkeeper.meta.ZkVersion) Test(org.junit.Test)

Example 14 with ZkVersion

use of org.apache.bookkeeper.meta.ZkVersion in project distributedlog by twitter.

the class TestZKLogMetadataForWriterUtilFunctions method testProcessLogMetadatasAllocatorPath.

@SuppressWarnings("unchecked")
@Test(timeout = 60000)
public void testProcessLogMetadatasAllocatorPath() throws Exception {
    String rootPath = "/test-missing-version";
    URI uri = DLMTestUtil.createDLMURI(2181, rootPath);
    String logName = "test-log";
    String logIdentifier = "<default>";
    Versioned<byte[]> maxTxnIdData = new Versioned<byte[]>(DLUtils.serializeTransactionId(1L), new ZkVersion(1));
    Versioned<byte[]> logSegmentsData = new Versioned<byte[]>(DLUtils.serializeLogSegmentSequenceNumber(1L), new ZkVersion(1));
    Versioned<byte[]> allocationData = new Versioned<byte[]>(DLUtils.ledgerId2Bytes(1L), new ZkVersion(1));
    List<Versioned<byte[]>> metadatas = Lists.newArrayList(new Versioned<byte[]>(null, null), new Versioned<byte[]>(null, null), maxTxnIdData, new Versioned<byte[]>(ZKLogMetadataForWriter.intToBytes(ZKLogMetadata.LAYOUT_VERSION), null), new Versioned<byte[]>(new byte[0], new ZkVersion(1)), new Versioned<byte[]>(new byte[0], new ZkVersion(1)), logSegmentsData, allocationData);
    ZKLogMetadataForWriter metadata = ZKLogMetadataForWriter.processLogMetadatas(uri, logName, logIdentifier, metadatas, true);
    assertTrue(maxTxnIdData == metadata.getMaxTxIdData());
    assertTrue(logSegmentsData == metadata.getMaxLSSNData());
    assertTrue(allocationData == metadata.getAllocationData());
}
Also used : Versioned(org.apache.bookkeeper.versioning.Versioned) URI(java.net.URI) ZkVersion(org.apache.bookkeeper.meta.ZkVersion) Test(org.junit.Test)

Example 15 with ZkVersion

use of org.apache.bookkeeper.meta.ZkVersion in project distributedlog by twitter.

the class TestZKLogMetadataForWriterUtilFunctions method testProcessLogMetadatasNoAllocatorPath.

@SuppressWarnings("unchecked")
@Test(timeout = 60000)
public void testProcessLogMetadatasNoAllocatorPath() throws Exception {
    String rootPath = "/test-missing-version";
    URI uri = DLMTestUtil.createDLMURI(2181, rootPath);
    String logName = "test-log";
    String logIdentifier = "<default>";
    Versioned<byte[]> maxTxnIdData = new Versioned<byte[]>(DLUtils.serializeTransactionId(1L), new ZkVersion(1));
    Versioned<byte[]> logSegmentsData = new Versioned<byte[]>(DLUtils.serializeLogSegmentSequenceNumber(1L), new ZkVersion(1));
    List<Versioned<byte[]>> metadatas = Lists.newArrayList(new Versioned<byte[]>(null, null), new Versioned<byte[]>(null, null), maxTxnIdData, new Versioned<byte[]>(ZKLogMetadataForWriter.intToBytes(ZKLogMetadata.LAYOUT_VERSION), null), new Versioned<byte[]>(new byte[0], new ZkVersion(1)), new Versioned<byte[]>(new byte[0], new ZkVersion(1)), logSegmentsData);
    ZKLogMetadataForWriter metadata = ZKLogMetadataForWriter.processLogMetadatas(uri, logName, logIdentifier, metadatas, false);
    assertTrue(maxTxnIdData == metadata.getMaxTxIdData());
    assertTrue(logSegmentsData == metadata.getMaxLSSNData());
    assertNull(metadata.getAllocationData().getValue());
    assertNull(metadata.getAllocationData().getVersion());
}
Also used : Versioned(org.apache.bookkeeper.versioning.Versioned) URI(java.net.URI) ZkVersion(org.apache.bookkeeper.meta.ZkVersion) Test(org.junit.Test)

Aggregations

ZkVersion (org.apache.bookkeeper.meta.ZkVersion)26 Versioned (org.apache.bookkeeper.versioning.Versioned)21 Test (org.junit.Test)16 Stat (org.apache.zookeeper.data.Stat)11 Promise (com.twitter.util.Promise)9 Version (org.apache.bookkeeper.versioning.Version)9 URI (java.net.URI)8 ZKException (com.twitter.distributedlog.exceptions.ZKException)7 Transaction (com.twitter.distributedlog.util.Transaction)6 AsyncCallback (org.apache.zookeeper.AsyncCallback)4 KeeperException (org.apache.zookeeper.KeeperException)4 Op (org.apache.zookeeper.Op)4 ZKOp (com.twitter.distributedlog.zk.ZKOp)3 ZKVersionedSetOp (com.twitter.distributedlog.zk.ZKVersionedSetOp)3 DefaultZKOp (com.twitter.distributedlog.zk.DefaultZKOp)2 ZKTransaction (com.twitter.distributedlog.zk.ZKTransaction)2 LedgerEntry (org.apache.bookkeeper.client.LedgerEntry)2 LedgerHandle (org.apache.bookkeeper.client.LedgerHandle)2 OpResult (org.apache.zookeeper.OpResult)2 ZooKeeperClient (com.twitter.distributedlog.ZooKeeperClient)1