本文整理汇总了Java中org.apache.tinkerpop.gremlin.driver.ResultSet.all方法的典型用法代码示例。如果您正苦于以下问题:Java ResultSet.all方法的具体用法?Java ResultSet.all怎么用?Java ResultSet.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tinkerpop.gremlin.driver.ResultSet
的用法示例。
在下文中一共展示了ResultSet.all方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldProcessRequestsOutOfOrder
import org.apache.tinkerpop.gremlin.driver.ResultSet; //导入方法依赖的package包/类
@Test
public void shouldProcessRequestsOutOfOrder() throws Exception {
final Cluster cluster = Cluster.open();
final Client client = cluster.connect();
final ResultSet rsFive = client.submit("Thread.sleep(5000);'five'");
final ResultSet rsZero = client.submit("'zero'");
final CompletableFuture<List<Result>> futureFive = rsFive.all();
final CompletableFuture<List<Result>> futureZero = rsZero.all();
final long start = System.nanoTime();
assertFalse(futureFive.isDone());
assertEquals("zero", futureZero.get().get(0).getString());
logger.info("Eval of 'zero' complete: " + TimeUtil.millisSince(start));
assertFalse(futureFive.isDone());
assertEquals("five", futureFive.get(10, TimeUnit.SECONDS).get(0).getString());
logger.info("Eval of 'five' complete: " + TimeUtil.millisSince(start));
}
示例2: shouldProcessSessionRequestsInOrder
import org.apache.tinkerpop.gremlin.driver.ResultSet; //导入方法依赖的package包/类
@Test
public void shouldProcessSessionRequestsInOrder() throws Exception {
final Cluster cluster = Cluster.open();
final Client client = cluster.connect(name.getMethodName());
final ResultSet rsFive = client.submit("Thread.sleep(5000);'five'");
final ResultSet rsZero = client.submit("'zero'");
final CompletableFuture<List<Result>> futureFive = rsFive.all();
final CompletableFuture<List<Result>> futureZero = rsZero.all();
final AtomicBoolean hit = new AtomicBoolean(false);
while (!futureFive.isDone()) {
// futureZero can't finish before futureFive - racy business here?
assertThat(futureZero.isDone(), is(false));
hit.set(true);
}
// should have entered the loop at least once and thus proven that futureZero didn't return ahead of
// futureFive
assertThat(hit.get(), is(true));
assertEquals("zero", futureZero.get().get(0).getString());
assertEquals("five", futureFive.get(10, TimeUnit.SECONDS).get(0).getString());
}
示例3: shouldProcessRequestsOutOfOrder
import org.apache.tinkerpop.gremlin.driver.ResultSet; //导入方法依赖的package包/类
@Test
public void shouldProcessRequestsOutOfOrder() throws Exception {
final Cluster cluster = TestClientFactory.open();
final Client client = cluster.connect();
final ResultSet rsFive = client.submit("Thread.sleep(5000);'five'");
final ResultSet rsZero = client.submit("'zero'");
final CompletableFuture<List<Result>> futureFive = rsFive.all();
final CompletableFuture<List<Result>> futureZero = rsZero.all();
final long start = System.nanoTime();
assertFalse(futureFive.isDone());
assertEquals("zero", futureZero.get().get(0).getString());
logger.info("Eval of 'zero' complete: " + TimeUtil.millisSince(start));
assertFalse(futureFive.isDone());
assertEquals("five", futureFive.get(10, TimeUnit.SECONDS).get(0).getString());
logger.info("Eval of 'five' complete: " + TimeUtil.millisSince(start));
}
示例4: shouldProcessSessionRequestsInOrder
import org.apache.tinkerpop.gremlin.driver.ResultSet; //导入方法依赖的package包/类
@Test
public void shouldProcessSessionRequestsInOrder() throws Exception {
final Cluster cluster = TestClientFactory.open();
final Client client = cluster.connect(name.getMethodName());
final ResultSet rsFive = client.submit("Thread.sleep(5000);'five'");
final ResultSet rsZero = client.submit("'zero'");
final CompletableFuture<List<Result>> futureFive = rsFive.all();
final CompletableFuture<List<Result>> futureZero = rsZero.all();
final CountDownLatch latch = new CountDownLatch(2);
final List<String> order = new ArrayList<>();
final ExecutorService executor = Executors.newSingleThreadExecutor();
futureFive.thenAcceptAsync(r -> {
order.add(r.get(0).getString());
latch.countDown();
}, executor);
futureZero.thenAcceptAsync(r -> {
order.add(r.get(0).getString());
latch.countDown();
}, executor);
// wait for both results
latch.await(30000, TimeUnit.MILLISECONDS);
// should be two results
assertEquals(2, order.size());
// ensure that "five" is first then "zero"
assertThat(order, contains("five", "zero"));
}