use of org.apache.bookkeeper.zookeeper.ZooKeeperWatcherBase in project pulsar by yahoo.
the class ZkBookieRackAffinityMappingTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
localZkS = new ZookeeperServerTest(LOCAL_ZOOKEEPER_PORT);
localZkS.start();
ZooKeeperWatcherBase zkWatcherBase = new ZooKeeperWatcherBase(10000);
localZkc = ZkUtils.createConnectedZookeeperClient("127.0.0.1" + ":" + LOCAL_ZOOKEEPER_PORT, zkWatcherBase);
BOOKIE1 = new BookieSocketAddress("127.0.0.1:3181");
BOOKIE2 = new BookieSocketAddress("127.0.0.2:3181");
BOOKIE3 = new BookieSocketAddress("127.0.0.3:3181");
}
use of org.apache.bookkeeper.zookeeper.ZooKeeperWatcherBase in project bookkeeper by apache.
the class BookKeeperClientZKSessionExpiry method testSessionLossWhileWriting.
@Test
public void testSessionLossWhileWriting() throws Exception {
Thread expiryThread = new Thread() {
@Override
public void run() {
try {
while (true) {
Thread.sleep(5000);
long sessionId = bkc.getZkHandle().getSessionId();
byte[] sessionPasswd = bkc.getZkHandle().getSessionPasswd();
try {
ZooKeeperWatcherBase watcher = new ZooKeeperWatcherBase(10000);
ZooKeeper zk = new ZooKeeper(zkUtil.getZooKeeperConnectString(), 10000, watcher, sessionId, sessionPasswd);
zk.close();
} catch (Exception e) {
LOG.info("Error killing session", e);
}
}
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
return;
}
}
};
expiryThread.start();
for (int i = 0; i < 3; i++) {
LedgerHandle lh = bkc.createLedger(3, 3, 2, BookKeeper.DigestType.MAC, "foobar".getBytes());
for (int j = 0; j < 100; j++) {
lh.asyncAddEntry("foobar".getBytes(), new AddCallbackFuture(j), null);
}
startNewBookie();
killBookie(0);
lh.addEntry("lastEntry".getBytes());
lh.close();
}
}
Aggregations