Search in sources :

Example 11 with LongVersion

use of org.apache.bookkeeper.versioning.LongVersion in project bookkeeper by apache.

the class TestZKLogStreamMetadataStoreUtils 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 LongVersion(1));
    Versioned<byte[]> logSegmentsData = new Versioned<byte[]>(DLUtils.serializeLogSegmentSequenceNumber(1L), new LongVersion(1));
    List<Versioned<byte[]>> metadatas = Lists.newArrayList(new Versioned<byte[]>(null, null), new Versioned<byte[]>(null, null), maxTxnIdData, new Versioned<byte[]>(intToBytes(LogMetadata.LAYOUT_VERSION), null), new Versioned<byte[]>(new byte[0], new LongVersion(1)), new Versioned<byte[]>(new byte[0], new LongVersion(1)), logSegmentsData);
    LogMetadataForWriter metadata = 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) LongVersion(org.apache.bookkeeper.versioning.LongVersion) URI(java.net.URI) LogMetadataForWriter(org.apache.distributedlog.metadata.LogMetadataForWriter) Test(org.junit.Test)

Example 12 with LongVersion

use of org.apache.bookkeeper.versioning.LongVersion in project bookkeeper by apache.

the class TestZKLogStreamMetadataStoreUtils method testProcessLogMetadatasMissingReadLockPath.

@SuppressWarnings("unchecked")
@Test(timeout = 60000, expected = UnexpectedException.class)
public void testProcessLogMetadatasMissingReadLockPath() 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 LongVersion(1)), new Versioned<byte[]>(intToBytes(LogMetadata.LAYOUT_VERSION), null), new Versioned<byte[]>(new byte[0], new LongVersion(1)), new Versioned<byte[]>(null, null));
    processLogMetadatas(uri, logName, logIdentifier, metadatas, false);
}
Also used : Versioned(org.apache.bookkeeper.versioning.Versioned) LongVersion(org.apache.bookkeeper.versioning.LongVersion) URI(java.net.URI) Test(org.junit.Test)

Example 13 with LongVersion

use of org.apache.bookkeeper.versioning.LongVersion in project bookkeeper by apache.

the class TestZKLogStreamMetadataStoreUtils method testProcessLogMetadatasMissingVersion.

@SuppressWarnings("unchecked")
@Test(timeout = 60000, expected = UnexpectedException.class)
public void testProcessLogMetadatasMissingVersion() 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 LongVersion(1)), new Versioned<byte[]>(null, null));
    processLogMetadatas(uri, logName, logIdentifier, metadatas, false);
}
Also used : Versioned(org.apache.bookkeeper.versioning.Versioned) LongVersion(org.apache.bookkeeper.versioning.LongVersion) URI(java.net.URI) Test(org.junit.Test)

Example 14 with LongVersion

use of org.apache.bookkeeper.versioning.LongVersion in project bookkeeper by apache.

the class TestZKLogStreamMetadataStoreUtils 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 LongVersion(1));
    Versioned<byte[]> logSegmentsData = new Versioned<byte[]>(DLUtils.serializeLogSegmentSequenceNumber(1L), new LongVersion(1));
    Versioned<byte[]> allocationData = new Versioned<byte[]>(DLUtils.logSegmentId2Bytes(1L), new LongVersion(1));
    List<Versioned<byte[]>> metadatas = Lists.newArrayList(new Versioned<byte[]>(null, null), new Versioned<byte[]>(null, null), maxTxnIdData, new Versioned<byte[]>(intToBytes(LogMetadata.LAYOUT_VERSION), null), new Versioned<byte[]>(new byte[0], new LongVersion(1)), new Versioned<byte[]>(new byte[0], new LongVersion(1)), logSegmentsData, allocationData);
    LogMetadataForWriter metadata = 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) LongVersion(org.apache.bookkeeper.versioning.LongVersion) URI(java.net.URI) LogMetadataForWriter(org.apache.distributedlog.metadata.LogMetadataForWriter) Test(org.junit.Test)

Example 15 with LongVersion

use of org.apache.bookkeeper.versioning.LongVersion in project bookkeeper by apache.

the class TestZKLogStreamMetadataStoreUtils 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 LongVersion(1)), new Versioned<byte[]>(intToBytes(LogMetadata.LAYOUT_VERSION), null), new Versioned<byte[]>(new byte[0], new LongVersion(1)), new Versioned<byte[]>(new byte[0], new LongVersion(1)), new Versioned<byte[]>(null, null));
    processLogMetadatas(uri, logName, logIdentifier, metadatas, false);
}
Also used : Versioned(org.apache.bookkeeper.versioning.Versioned) LongVersion(org.apache.bookkeeper.versioning.LongVersion) URI(java.net.URI) Test(org.junit.Test)

Aggregations

LongVersion (org.apache.bookkeeper.versioning.LongVersion)56 Test (org.junit.Test)37 Versioned (org.apache.bookkeeper.versioning.Versioned)29 Stat (org.apache.zookeeper.data.Stat)25 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)21 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)20 Version (org.apache.bookkeeper.versioning.Version)18 GenericCallbackFuture (org.apache.bookkeeper.test.TestCallbacks.GenericCallbackFuture)16 BKException (org.apache.bookkeeper.client.BKException)12 VoidCallback (org.apache.zookeeper.AsyncCallback.VoidCallback)12 Set (java.util.Set)11 LedgerMetadata (org.apache.bookkeeper.client.LedgerMetadata)10 StatCallback (org.apache.zookeeper.AsyncCallback.StatCallback)10 DataCallback (org.apache.zookeeper.AsyncCallback.DataCallback)9 Before (org.junit.Before)9 URI (java.net.URI)8 ZKException (org.apache.distributedlog.exceptions.ZKException)8 KeeperException (org.apache.zookeeper.KeeperException)8 Assert.assertEquals (org.junit.Assert.assertEquals)8 Assert.fail (org.junit.Assert.fail)8