Search in sources :

Example 6 with DataCallback

use of org.apache.zookeeper.AsyncCallback.DataCallback in project bookkeeper by apache.

the class MockZooKeeperTestCase method mockZkGetData.

protected void mockZkGetData(String expectedLedgerPath, boolean expectedWatcher, int retCode, byte[] retData, Stat retStat) throws Exception {
    doAnswer(invocationOnMock -> {
        String path = invocationOnMock.getArgument(0);
        Watcher watcher = invocationOnMock.getArgument(1);
        DataCallback callback = invocationOnMock.getArgument(2);
        Object ctx = invocationOnMock.getArgument(3);
        if (Code.OK == retCode) {
            addWatcher(path, watcher);
        }
        callback.processResult(retCode, path, ctx, retData, retStat);
        return null;
    }).when(mockZk).getData(eq(expectedLedgerPath), expectedWatcher ? any(Watcher.class) : eq(null), any(DataCallback.class), any());
}
Also used : Watcher(org.apache.zookeeper.Watcher) DataCallback(org.apache.zookeeper.AsyncCallback.DataCallback)

Aggregations

DataCallback (org.apache.zookeeper.AsyncCallback.DataCallback)6 Stat (org.apache.zookeeper.data.Stat)5 Watcher (org.apache.zookeeper.Watcher)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 StatCallback (org.apache.zookeeper.AsyncCallback.StatCallback)2 ZooKeeper (org.apache.zookeeper.ZooKeeper)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 LedgerMetadata (org.apache.bookkeeper.client.LedgerMetadata)1 LongVersion (org.apache.bookkeeper.versioning.LongVersion)1 Children2Callback (org.apache.zookeeper.AsyncCallback.Children2Callback)1 Create2Callback (org.apache.zookeeper.AsyncCallback.Create2Callback)1 StringCallback (org.apache.zookeeper.AsyncCallback.StringCallback)1 VoidCallback (org.apache.zookeeper.AsyncCallback.VoidCallback)1