Search in sources :

Example 11 with MetaStoreException

use of org.apache.bookkeeper.mledger.ManagedLedgerException.MetaStoreException in project pulsar by yahoo.

the class MetaStoreImplZookeeperTest method readMalformedML.

@Test(timeOut = 20000)
void readMalformedML() throws Exception {
    MetaStore store = new MetaStoreImplZookeeper(zkc, executor);
    zkc.create("/managed-ledgers/my_test", "non-valid".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
    final CountDownLatch latch = new CountDownLatch(1);
    store.getManagedLedgerInfo("my_test", new MetaStoreCallback<MLDataFormats.ManagedLedgerInfo>() {

        public void operationFailed(MetaStoreException e) {
            // Ok
            latch.countDown();
        }

        public void operationComplete(ManagedLedgerInfo result, Stat version) {
            fail("Operation should have failed");
        }
    });
    latch.await();
}
Also used : MetaStoreException(org.apache.bookkeeper.mledger.ManagedLedgerException.MetaStoreException) Stat(org.apache.bookkeeper.mledger.impl.MetaStore.Stat) CountDownLatch(java.util.concurrent.CountDownLatch) ManagedLedgerInfo(org.apache.bookkeeper.mledger.proto.MLDataFormats.ManagedLedgerInfo) Test(org.testng.annotations.Test)

Example 12 with MetaStoreException

use of org.apache.bookkeeper.mledger.ManagedLedgerException.MetaStoreException in project pulsar by yahoo.

the class MetaStoreImplZookeeperTest method failInCreatingMLnode.

@Test(timeOut = 20000)
void failInCreatingMLnode() throws Exception {
    MetaStore store = new MetaStoreImplZookeeper(zkc, executor);
    final CountDownLatch latch = new CountDownLatch(1);
    zkc.failAfter(1, Code.CONNECTIONLOSS);
    store.getManagedLedgerInfo("my_test", new MetaStoreCallback<MLDataFormats.ManagedLedgerInfo>() {

        public void operationFailed(MetaStoreException e) {
            // Ok
            latch.countDown();
        }

        public void operationComplete(ManagedLedgerInfo result, Stat version) {
            fail("Operation should have failed");
        }
    });
    latch.await();
}
Also used : MetaStoreException(org.apache.bookkeeper.mledger.ManagedLedgerException.MetaStoreException) Stat(org.apache.bookkeeper.mledger.impl.MetaStore.Stat) CountDownLatch(java.util.concurrent.CountDownLatch) ManagedLedgerInfo(org.apache.bookkeeper.mledger.proto.MLDataFormats.ManagedLedgerInfo) Test(org.testng.annotations.Test)

Example 13 with MetaStoreException

use of org.apache.bookkeeper.mledger.ManagedLedgerException.MetaStoreException in project pulsar by yahoo.

the class MetaStoreImplZookeeperTest method updatingCursorNode.

@Test(timeOut = 20000)
void updatingCursorNode() throws Exception {
    final MetaStore store = new MetaStoreImplZookeeper(zkc, executor);
    zkc.create("/managed-ledgers/my_test", "".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
    final CountDownLatch latch = new CountDownLatch(1);
    ManagedCursorInfo info = ManagedCursorInfo.newBuilder().setCursorsLedgerId(1).build();
    store.asyncUpdateCursorInfo("my_test", "c1", info, null, new MetaStoreCallback<Void>() {

        public void operationFailed(MetaStoreException e) {
            fail("should have succeeded");
        }

        public void operationComplete(Void result, Stat version) {
            // Update again using the version
            zkc.failNow(Code.CONNECTIONLOSS);
            ManagedCursorInfo info = ManagedCursorInfo.newBuilder().setCursorsLedgerId(2).build();
            store.asyncUpdateCursorInfo("my_test", "c1", info, version, new MetaStoreCallback<Void>() {

                public void operationFailed(MetaStoreException e) {
                    // ok
                    latch.countDown();
                }

                @Override
                public void operationComplete(Void result, Stat version) {
                    fail("should have failed");
                }
            });
        }
    });
    latch.await();
}
Also used : MetaStoreException(org.apache.bookkeeper.mledger.ManagedLedgerException.MetaStoreException) Stat(org.apache.bookkeeper.mledger.impl.MetaStore.Stat) ManagedCursorInfo(org.apache.bookkeeper.mledger.proto.MLDataFormats.ManagedCursorInfo) MetaStoreCallback(org.apache.bookkeeper.mledger.impl.MetaStore.MetaStoreCallback) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.testng.annotations.Test)

Example 14 with MetaStoreException

use of org.apache.bookkeeper.mledger.ManagedLedgerException.MetaStoreException in project pulsar by yahoo.

the class MetaStoreImplZookeeperTest method deleteNonExistingML.

@Test
void deleteNonExistingML() throws Exception {
    MetaStore store = new MetaStoreImplZookeeper(zkc, executor);
    AtomicReference<MetaStoreException> exception = new AtomicReference<>();
    CountDownLatch counter = new CountDownLatch(1);
    store.removeManagedLedger("non-existing", new MetaStoreCallback<Void>() {

        @Override
        public void operationComplete(Void result, Stat version) {
            counter.countDown();
        }

        @Override
        public void operationFailed(MetaStoreException e) {
            exception.set(e);
            counter.countDown();
        }
    });
    counter.await();
    assertNotNull(exception.get());
}
Also used : MetaStoreException(org.apache.bookkeeper.mledger.ManagedLedgerException.MetaStoreException) Stat(org.apache.bookkeeper.mledger.impl.MetaStore.Stat) AtomicReference(java.util.concurrent.atomic.AtomicReference) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.testng.annotations.Test)

Example 15 with MetaStoreException

use of org.apache.bookkeeper.mledger.ManagedLedgerException.MetaStoreException in project pulsar by yahoo.

the class MetaStoreImplZookeeperTest method readMalformedCursorNode.

@Test(timeOut = 20000)
void readMalformedCursorNode() throws Exception {
    MetaStore store = new MetaStoreImplZookeeper(zkc, executor);
    zkc.create("/managed-ledgers/my_test", "".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
    zkc.create("/managed-ledgers/my_test/c1", "non-valid".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
    final CountDownLatch latch = new CountDownLatch(1);
    store.asyncGetCursorInfo("my_test", "c1", new MetaStoreCallback<MLDataFormats.ManagedCursorInfo>() {

        public void operationFailed(MetaStoreException e) {
            // Ok
            latch.countDown();
        }

        public void operationComplete(ManagedCursorInfo result, Stat version) {
            fail("Operation should have failed");
        }
    });
    latch.await();
}
Also used : MetaStoreException(org.apache.bookkeeper.mledger.ManagedLedgerException.MetaStoreException) Stat(org.apache.bookkeeper.mledger.impl.MetaStore.Stat) ManagedCursorInfo(org.apache.bookkeeper.mledger.proto.MLDataFormats.ManagedCursorInfo) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.testng.annotations.Test)

Aggregations

MetaStoreException (org.apache.bookkeeper.mledger.ManagedLedgerException.MetaStoreException)19 Stat (org.apache.bookkeeper.mledger.impl.MetaStore.Stat)13 CountDownLatch (java.util.concurrent.CountDownLatch)9 ManagedLedgerInfo (org.apache.bookkeeper.mledger.proto.MLDataFormats.ManagedLedgerInfo)9 Test (org.testng.annotations.Test)8 MetaStoreCallback (org.apache.bookkeeper.mledger.impl.MetaStore.MetaStoreCallback)6 ManagedLedgerException (org.apache.bookkeeper.mledger.ManagedLedgerException)5 LedgerInfo (org.apache.bookkeeper.mledger.proto.MLDataFormats.ManagedLedgerInfo.LedgerInfo)5 BadVersionException (org.apache.bookkeeper.mledger.ManagedLedgerException.BadVersionException)4 ManagedCursorInfo (org.apache.bookkeeper.mledger.proto.MLDataFormats.ManagedCursorInfo)3 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)2 ParseException (com.google.protobuf.TextFormat.ParseException)2 OpenCallback (org.apache.bookkeeper.client.AsyncCallback.OpenCallback)2 ManagedLedger (org.apache.bookkeeper.mledger.ManagedLedger)2 ManagedLedgerConfig (org.apache.bookkeeper.mledger.ManagedLedgerConfig)2 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 BoundType (com.google.common.collect.BoundType)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 Queues (com.google.common.collect.Queues)1