/** * Close the client and release its resources */ public void close() { delegate.close(); }
/** * Close the client and release its resources */ public void close() { delegate.close(); }
@Override public void close() { consulClient.close(); } }
public void close() { client.close(); }
@Override public void close(Handler<Void> completionHandler) { client.close(); completionHandler.handle(null); }
@Override public synchronized void stop() { if (!started) { throw new IllegalStateException("An unstarted watch"); } if (stopped) { throw new IllegalStateException("Watch already stopped"); } stopped = true; vertx.runOnContext(v -> consulClient.close()); }
private void createMasterClient(ConsulTestNode node) { AtomicReference<ConsulTestNode> usedNode = new AtomicReference<>(node); masterClient = ConsulClient.create(vertx, new ConsulClientOptions().setAclToken(MASTER_TOKEN).setDc(TEST_DC).setHost(LOCALHOST).setPort(usedNode.get().httpPort()).setSsl(false)); vertx.setPeriodic(5000, l -> { if ((usedNode.get() == null || !usedNode.get().isRunning()) && masterClient != null) { masterClient.close(); masterClient = null; } }); } }
public static void TestClusterTestContext(ConsulTestEnv env, TestContext ctx) { ctx.assertTrue(env.nodeCount() == 5); ctx.assertTrue(env.nodes().stream().map(env::getNode).allMatch(ConsulTestNode::isRunning)); ctx.assertTrue(env.nodes().stream().map(env::getNode).filter(ConsulTestNode::isServer).count() == 3); ctx.assertTrue(env.nodes().stream().map(env::getNode).filter(a -> !a.isServer()).count() == 2); env.getServerNode().setHandler(ctx.asyncAssertSuccess(node -> { env.clientOptionsForNode(node, null).map(opt -> { ConsulClient client = ConsulClient.create(env.vertx(), opt); client.catalogNodes(nodes -> { if (nodes.failed()) { client.close(); } ctx.assertTrue(nodes.succeeded()); ctx.assertEquals(env.nodeCount(), nodes.result().getList().size(), "ConsulTestEnv node map and HTTP API result are inconsistent"); nodes.result().getList().stream().map(Node::getName).collect(Collectors.toList()).forEach(name -> ctx.assertTrue(env.nodes().contains(name))); }); return client; }).setHandler(client -> { ctx.assertTrue(client.succeeded()); client.result().close(); }); })); }
@After public void tearDown(TestContext tc) { retriever.close(); client.close(); vertx.close(tc.asyncAssertSuccess()); }
public static void TestClusterAssertAwait(ConsulTestEnv env) { Assert.assertTrue(env.nodeCount() == 5); Assert.assertTrue(env.nodes().stream().map(env::getNode).allMatch(ConsulTestNode::isRunning)); Assert.assertTrue(env.nodes().stream().map(env::getNode).filter(ConsulTestNode::isServer).count() == 3); Assert.assertTrue(env.nodes().stream().map(env::getNode).filter(a -> !a.isServer()).count() == 2); env.getServerNode().setHandler(node -> { Assert.assertTrue(node.succeeded()); env.clientOptionsForNode(node.result(), null).map(opt -> { ConsulClient client = ConsulClient.create(env.vertx(), opt); client.catalogNodes(nodes -> { if (nodes.failed()) { client.close(); } Assert.assertTrue(nodes.succeeded()); Assert.assertEquals("ConsulTestEnv node map and HTTP API result are inconsistent", env.nodeCount(), nodes.result().getList().size()); nodes.result().getList().stream().map(Node::getName).collect(Collectors.toList()).forEach(name -> Assert.assertTrue(env.nodes().contains(name))); }); return client; }).setHandler(client -> { Assert.assertTrue(client.succeeded()); client.result().close(); }); }); }
@After public void tearDown(TestContext tc) { retriever.close(); client.close(); vertx.close(tc.asyncAssertSuccess()); }