use of org.apache.bookkeeper.versioning.Versioned in project distributedlog by twitter.
the class TestLogSegmentsZK method getMaxLogSegmentSequenceNo.
private static MaxLogSegmentSequenceNo getMaxLogSegmentSequenceNo(ZooKeeperClient zkc, URI uri, String streamName, DistributedLogConfiguration conf) throws Exception {
Stat stat = new Stat();
String logSegmentsPath = ZKLogMetadata.getLogSegmentsPath(uri, streamName, conf.getUnpartitionedStreamName());
byte[] data = zkc.get().getData(logSegmentsPath, false, stat);
Versioned<byte[]> maxLSSNData = new Versioned<byte[]>(data, new ZkVersion(stat.getVersion()));
return new MaxLogSegmentSequenceNo(maxLSSNData);
}
use of org.apache.bookkeeper.versioning.Versioned 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);
}
use of org.apache.bookkeeper.versioning.Versioned 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);
}
use of org.apache.bookkeeper.versioning.Versioned 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);
}
use of org.apache.bookkeeper.versioning.Versioned 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());
}
Aggregations