本文整理了Java中org.apache.samza.zk.ZkUtils.close()
方法的一些代码示例,展示了ZkUtils.close()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkUtils.close()
方法的具体详情如下:
包路径:org.apache.samza.zk.ZkUtils
类名称:ZkUtils
方法名:close
暂无
代码示例来源:origin: apache/samza
public void close() {
try {
if (zkUtils != null)
zkUtils.close();
} catch (ZkInterruptedException ex) {
// Swallowing due to occurrence in the last stage of lifecycle(Not actionable).
LOG.error("Exception in close(): ", ex);
}
}
代码示例来源:origin: org.apache.samza/samza-core_2.12
public void close() {
try {
if (zkUtils != null)
zkUtils.close();
} catch (ZkInterruptedException ex) {
// Swallowing due to occurrence in the last stage of lifecycle(Not actionable).
LOG.error("Exception in close(): ", ex);
}
}
代码示例来源:origin: org.apache.samza/samza-core_2.11
public void close() {
try {
if (zkUtils != null)
zkUtils.close();
} catch (ZkInterruptedException ex) {
// Swallowing due to occurrence in the last stage of lifecycle(Not actionable).
LOG.error("Exception in close(): ", ex);
}
}
代码示例来源:origin: org.apache.samza/samza-core_2.10
public void close() {
try {
if (zkUtils != null)
zkUtils.close();
} catch (ZkInterruptedException ex) {
// Swallowing due to occurrence in the last stage of lifecycle(Not actionable).
LOG.error("Exception in close(): ", ex);
}
}
代码示例来源:origin: org.apache.samza/samza-core
public void close() {
try {
if (zkUtils != null)
zkUtils.close();
} catch (ZkInterruptedException ex) {
// Swallowing due to occurrence in the last stage of lifecycle(Not actionable).
LOG.error("Exception in close(): ", ex);
}
}
代码示例来源:origin: apache/samza
@After
public void testTearDown() {
zkUtils.close();
zkUtils1.close();
}
代码示例来源:origin: org.apache.samza/samza-core_2.10
zkUtils.close();
代码示例来源:origin: org.apache.samza/samza-core_2.12
zkUtils.close();
代码示例来源:origin: apache/samza
zkUtils.close();
代码示例来源:origin: apache/samza
@After
public void testTeardown() {
if (zkClient != null) {
try {
zkUtils.close();
} finally {
zkServer.teardown();
}
}
}
代码示例来源:origin: org.apache.samza/samza-core_2.11
zkUtils.close();
代码示例来源:origin: org.apache.samza/samza-core
zkUtils.close();
代码示例来源:origin: apache/samza
@Test
public void testCloseShouldRetryOnceOnInterruptedException() {
ZkClient zkClient = Mockito.mock(ZkClient.class);
ZkUtils zkUtils = new ZkUtils(KEY_BUILDER, zkClient, CONNECTION_TIMEOUT_MS, SESSION_TIMEOUT_MS, new NoOpMetricsRegistry());
Mockito.doThrow(new ZkInterruptedException(new InterruptedException()))
.doAnswer(invocation -> null)
.when(zkClient).close();
zkUtils.close();
Mockito.verify(zkClient, Mockito.times(2)).close();
}
代码示例来源:origin: apache/samza
@Test
public void testCloseShouldTearDownZkConnectionOnInterruptedException() throws Exception {
CountDownLatch latch = new CountDownLatch(1);
// Establish connection with the zookeeper server.
ZkClient zkClient = new ZkClient("127.0.0.1:" + zkServer.getPort());
ZkUtils zkUtils = new ZkUtils(KEY_BUILDER, zkClient, CONNECTION_TIMEOUT_MS, SESSION_TIMEOUT_MS, new NoOpMetricsRegistry());
Thread threadToInterrupt = new Thread(() -> {
try {
latch.await();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
zkUtils.close();
});
threadToInterrupt.start();
Field field = ZkClient.class.getDeclaredField("_closed");
field.setAccessible(true);
Assert.assertFalse(field.getBoolean(zkClient));
threadToInterrupt.interrupt();
threadToInterrupt.join();
Assert.assertTrue(field.getBoolean(zkClient));
}
}
代码示例来源:origin: apache/samza
@Override
public void run() {
ZkUtils zkUtils = getZkUtilsWithNewClient(participantId);
zkUtils.connect();
ZkProcessorLatch latch = new ZkProcessorLatch(
latchSize, latchId, participantId, zkUtils);
latch.countDown();
try {
latch.await(30, TimeUnit.SECONDS);
} catch (Exception e) {
Assert.fail(String.format("Threw an exception while waiting for latch completion in %s! %s",
participantId, e.getLocalizedMessage()));
} finally {
zkUtils.close();
}
}
};
代码示例来源:origin: apache/samza
@After
public void testTeardown() {
testZkUtils.getZkClient().deleteRecursive(KEY_BUILDER.getRootPath());
testZkUtils.close();
}
代码示例来源:origin: apache/samza
@After
public void testTeardown() {
testZkUtils.getZkClient().deleteRecursive(KEY_BUILDER.getRootPath());
testZkUtils.close();
}
代码示例来源:origin: apache/samza
Assert.fail(String.format("await timed out from %s - %s", participant1, e.getLocalizedMessage()));
} finally {
zkUtils.close();
代码示例来源:origin: apache/samza
zkUtils1.close();
zkUtils2.close();
zkUtils3.close();
代码示例来源:origin: apache/samza
@Test
public void testAmILeader() {
BooleanResult isLeader1 = new BooleanResult();
BooleanResult isLeader2 = new BooleanResult();
// Processor-1
ZkUtils zkUtils1 = getZkUtilsWithNewClient();
ZkLeaderElector leaderElector1 = new ZkLeaderElector("1", zkUtils1, null);
leaderElector1.setLeaderElectorListener(() -> isLeader1.res = true);
// Processor-2
ZkUtils zkUtils2 = getZkUtilsWithNewClient();
ZkLeaderElector leaderElector2 = new ZkLeaderElector("2", zkUtils2, null);
leaderElector2.setLeaderElectorListener(() -> isLeader2.res = true);
// Before Leader Election
Assert.assertFalse(leaderElector1.amILeader());
Assert.assertFalse(leaderElector2.amILeader());
leaderElector1.tryBecomeLeader();
leaderElector2.tryBecomeLeader();
// After Leader Election
Assert.assertTrue(leaderElector1.amILeader());
Assert.assertFalse(leaderElector2.amILeader());
zkUtils1.close();
zkUtils2.close();
}
内容来源于网络,如有侵权,请联系作者删除!