本文整理了Java中io.vertx.ext.unit.Async.count()
方法的一些代码示例,展示了Async.count()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Async.count()
方法的具体详情如下:
包路径:io.vertx.ext.unit.Async
类名称:Async
方法名:count
暂无
代码示例来源:origin: io.vertx/vertx-rx-java
/**
* @return the current count
*/
public int count() {
int ret = delegate.count();
return ret;
}
代码示例来源:origin: org.openehealth.ipf.oht.atna/ipf-oht-atna-test
@Override
public void start() throws Exception {
NetServer netServer = vertx.createNetServer(nsOptions);
netServer.connectHandler(netSocket -> netSocket.handler(buffer -> {
log.debug("================= Received content on " + port + ":" + async.count() +
" =================== \n" + buffer.toString());
async.countDown();
})).listen(port);
}
}
代码示例来源:origin: org.openehealth.ipf.commons/ipf-commons-audit
@Override
public void start() {
NetServer netServer = vertx.createNetServer(nsOptions);
netServer.connectHandler(netSocket -> netSocket.handler(buffer -> {
LOG.debug("Received content on port {} ({}) : {}", port, async.count(), buffer.toString());
async.countDown();
})).listen(port);
}
}
代码示例来源:origin: vert-x3/vertx-rx
/**
* @return the current count
*/
public int count() {
int ret = delegate.count();
return ret;
}
代码示例来源:origin: reactiverse/reactive-pg-client
@Test
public void testCloseWithErrorInProgress(TestContext ctx) {
Async async = ctx.async(2);
connector.accept(ctx.asyncAssertSuccess(conn -> {
conn.query("SELECT whatever from DOES_NOT_EXIST", ctx.asyncAssertFailure(err -> {
ctx.assertEquals(2, async.count());
async.countDown();
}));
conn.closeHandler(v -> {
ctx.assertEquals(1, async.count());
async.countDown();
});
conn.close();
}));
}
代码示例来源:origin: org.openehealth.ipf.commons/ipf-commons-audit
@Test
public void testUDP(TestContext testContext) throws Exception {
auditContext.setAuditRepositoryTransport("UDP");
int count = 10;
Async async = testContext.async(count + 1);
deploy(testContext, createUDPServer(LOCALHOST, port, async));
while (async.count() > count) {
Thread.sleep(10);
}
for (int i = 0; i < count; i++) sendAudit();
async.awaitSuccess(WAIT_TIME);
}
代码示例来源:origin: reactiverse/reactive-pg-client
@Test
public void testQueueQueries(TestContext ctx) {
int num = 1000;
Async async = ctx.async(num + 1);
connector.accept(ctx.asyncAssertSuccess(conn -> {
for (int i = 0;i < num;i++) {
conn.query("SELECT id, randomnumber from WORLD", ar -> {
if (ar.succeeded()) {
PgResult result = ar.result();
ctx.assertEquals(10000, result.size());
} else {
ctx.assertEquals("closed", ar.cause().getMessage());
}
async.countDown();
});
}
conn.closeHandler(v -> {
ctx.assertEquals(1, async.count());
async.countDown();
});
conn.close();
}));
}
代码示例来源:origin: io.vertx/vertx-unit
Future<Void> fut = Future.future();
async.resolve(fut);
assertEquals(3, async.count());
countDownAsync.accept(async);
assertFalse(fut.isComplete());
assertEquals(2, async.count());
completeAsync.accept(async);
assertTrue(fut.isComplete());
assertEquals(0, async.count());
countDownAsync.accept(async);
assertEquals(0, async.count());
reporter.await();
assertTrue(reporter.completed());
代码示例来源:origin: reactiverse/reactive-pg-client
@Test
public void testCloseWithQueryInProgress(TestContext ctx) {
Async async = ctx.async(2);
connector.accept(ctx.asyncAssertSuccess(conn -> {
conn.query("SELECT id, randomnumber from WORLD", ctx.asyncAssertSuccess(result -> {
ctx.assertEquals(2, async.count());
ctx.assertEquals(10000, result.size());
async.countDown();
}));
conn.closeHandler(v -> {
ctx.assertEquals(1, async.count());
async.countDown();
});
conn.close();
}));
}
代码示例来源:origin: weld/weld-vertx
@Test
public void testWorkerInject(TestContext context) throws InterruptedException, ExecutionException {
BlockingFoo.reset();
Async async = context.async();
Hello hello = weld.select(Hello.class).get();
hello.hello().thenAccept((m) -> {
context.assertEquals("Hello ping!", m);
async.complete();
});
context.assertEquals(1, async.count());
BlockingFoo.complete("ping");
}
代码示例来源:origin: reactiverse/reactive-pg-client
@Test
public void testCancelRequest(TestContext ctx) {
Async async = ctx.async(2);
connector.accept(ctx.asyncAssertSuccess(conn -> {
conn.query("SELECT pg_sleep(10)", ctx.asyncAssertFailure(error -> {
ctx.assertEquals("canceling statement due to user request", error.getMessage());
async.countDown();
}));
conn.cancelRequest(ctx.asyncAssertSuccess());
conn.closeHandler(v -> {
ctx.assertEquals(1, async.count());
async.countDown();
});
conn.close();
}));
}
}
代码示例来源:origin: weld/weld-vertx
@Test
public void testWorker(TestContext context) throws InterruptedException, ExecutionException {
BlockingFoo.reset();
Async async = context.async();
BlockingFoo foo = weld.select(BlockingFoo.class).get();
AsyncWorker.from(vertx).performBlocking(foo::getMessage).thenAccept(m -> {
context.assertEquals("ping", m);
async.complete();
});
context.assertEquals(1, async.count());
BlockingFoo.complete("ping");
}
代码示例来源:origin: io.vertx/vertx-consul-client
private void testSessionsBlocking(TestContext tc, BiConsumer<BlockingQueryOptions, Handler<AsyncResult<SessionList>>> request) {
ctx.writeClient().createSession(tc.asyncAssertSuccess(id1 -> {
ctx.readClient().listSessions(tc.asyncAssertSuccess(list1 -> {
Async async = tc.async();
request.accept(new BlockingQueryOptions().setIndex(list1.getIndex()), h -> {
List<String> ids = h.result().getList().stream().map(Session::getId).collect(Collectors.toList());
assertTrue(ids.contains(id1));
async.countDown();
});
vertx.setTimer(1000, l -> {
assertEquals(async.count(), 1);
ctx.writeClient().createSession(tc.asyncAssertSuccess(id2 -> {
async.handler(a -> {
ctx.writeClient().destroySession(id1, tc.asyncAssertSuccess(d1 -> {
ctx.writeClient().destroySession(id2, tc.asyncAssertSuccess());
}));
});
}));
});
}));
}));
}
代码示例来源:origin: weld/weld-vertx
@Test
public void testAsyncReferenceWorkerCombo(TestContext context) throws InterruptedException, ExecutionException {
BlockingAlpha.reset();
Async async = context.async();
HelloCombo hello = weld.select(HelloCombo.class).get();
hello.hello().thenAccept((m) -> {
context.assertEquals("Hello ping!", m);
async.complete();
});
BlockingAlpha.completeInit();
context.assertEquals(1, async.count());
BlockingAlpha.completeOperation("ping");
}
代码示例来源:origin: io.vertx/vertx-grpc
ctx.assertEquals("Hello Julien", ar.result().getMessage());
async.countDown();
if (async.count() == 0) {
ctx.assertEquals(2, threads.size());
代码示例来源:origin: io.vertx/vertx-rabbitmq-client
@Test
public void pauseAndResumeShouldWork(TestContext ctx) throws Exception {
int count = 1;
Set<String> messages = createMessages(count);
String q = setupQueue(ctx, messages);
Async paused = ctx.async();
Async resumed = ctx.async();
Async messageReceived = ctx.async();
client.basicConsumer(q, new QueueOptions(), ctx.asyncAssertSuccess(consumer -> {
consumer.pause();
consumer.handler(msg -> {
ctx.assertNotNull(msg);
// if not resumed, test should fail
if (resumed.count() == 1) {
ctx.fail();
} else {
messageReceived.complete();
}
});
paused.complete();
// wait for resume command
resumed.await();
consumer.resume();
}));
paused.awaitSuccess(15000);
// wait some time to ensure that handler will not receive any messages when it is paused
vertx.setTimer(1000, t -> resumed.complete());
}
代码示例来源:origin: io.vertx/vertx-consul-client
tc.assertEquals(async1.count(), 1);
vertx.<ConsulAgent>executeBlocking(b1 -> b1.complete(ctx.attachAgent("attached_node")), tc.asyncAssertSuccess(attached -> {
System.out.println(">>>>>>> new node attached");
代码示例来源:origin: vert-x3/vertx-rabbitmq-client
@Test
public void pauseAndResumeShouldWork(TestContext ctx) throws Exception {
int count = 1;
Set<String> messages = createMessages(count);
String q = setupQueue(ctx, messages);
Async paused = ctx.async();
Async resumed = ctx.async();
Async messageReceived = ctx.async();
client.basicConsumer(q, new QueueOptions(), ctx.asyncAssertSuccess(consumer -> {
consumer.pause();
consumer.handler(msg -> {
ctx.assertNotNull(msg);
// if not resumed, test should fail
if (resumed.count() == 1) {
ctx.fail();
} else {
messageReceived.complete();
}
});
paused.complete();
// wait for resume command
resumed.await();
consumer.resume();
}));
paused.awaitSuccess(15000);
// wait some time to ensure that handler will not receive any messages when it is paused
vertx.setTimer(1000, t -> resumed.complete());
}
代码示例来源:origin: engagingspaces/vertx-graphql-service-discovery
@Test
public void should_Manage_Service_Discovery_Creation_And_Invoke_Close_Handler(TestContext context) {
Async async = context.async(2);
vertx.runOnContext(ctx ->
{
ServiceDiscovery serviceDiscoveryDefault = abstractRegistrar
.getOrCreateDiscovery(new ServiceDiscoveryOptions(), null);
context.assertNotNull(serviceDiscoveryDefault);
ServiceDiscovery serviceDiscovery1 = abstractRegistrar.getOrCreateDiscovery(options, () -> {
abstractRegistrar.closeServiceDiscovery(options.getName());
async.countDown();
return null;
});
context.assertTrue(serviceDiscovery1 instanceof ManagedServiceDiscovery);
context.assertEquals(1, abstractRegistrar.serviceDiscoveryNames().size());
serviceDiscoveryDefault.close();
context.assertEquals(1, abstractRegistrar.serviceDiscoveryNames().size());
ServiceDiscovery serviceDiscovery2 = abstractRegistrar.getOrCreateDiscovery(options, null);
context.assertEquals(serviceDiscovery1, serviceDiscovery2);
serviceDiscovery1.close();
context.assertEquals(1, async.count());
context.assertEquals(0, abstractRegistrar.serviceDiscoveryNames().size());
async.countDown();
});
async.awaitSuccess();
}
代码示例来源:origin: io.vertx/vertx-consul-client
@Test
public void sessionInfoBlocking(TestContext tc) {
ctx.writeClient().createSession(tc.asyncAssertSuccess(id -> {
ctx.readClient().infoSession(id, tc.asyncAssertSuccess(s1 -> {
Async async = tc.async();
ctx.readClient().infoSessionWithOptions(id, new BlockingQueryOptions().setIndex(s1.getIndex()), h -> async.countDown());
vertx.setTimer(1000, l -> {
assertEquals(async.count(), 1);
ctx.writeClient().destroySession(id, tc.asyncAssertSuccess());
});
}));
}));
}
内容来源于网络,如有侵权,请联系作者删除!