本文整理汇总了Java中org.apache.tinkerpop.gremlin.driver.Client类的典型用法代码示例。如果您正苦于以下问题:Java Client类的具体用法?Java Client怎么用?Java Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Client类属于org.apache.tinkerpop.gremlin.driver包,在下文中一共展示了Client类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: DriverRemoteConnection
import org.apache.tinkerpop.gremlin.driver.Client; //导入依赖的package包/类
public DriverRemoteConnection(final Configuration conf) {
if (conf.containsKey(GREMLIN_REMOTE_GRAPH_DRIVER_CLUSTERFILE) && conf.containsKey("clusterConfiguration"))
throw new IllegalStateException(String.format("A configuration should not contain both '%s' and 'clusterConfiguration'", GREMLIN_REMOTE_GRAPH_DRIVER_CLUSTERFILE));
connectionGraphName = conf.getString(GREMLIN_REMOTE_GRAPH_DRIVER_GRAPHNAME, DEFAULT_GRAPH);
try {
final Cluster cluster;
if (!conf.containsKey(GREMLIN_REMOTE_GRAPH_DRIVER_CLUSTERFILE) && !conf.containsKey("clusterConfiguration"))
cluster = Cluster.open();
else
cluster = conf.containsKey(GREMLIN_REMOTE_GRAPH_DRIVER_CLUSTERFILE) ?
Cluster.open(conf.getString(GREMLIN_REMOTE_GRAPH_DRIVER_CLUSTERFILE)) : Cluster.open(conf.subset("clusterConfiguration"));
client = cluster.connect(Client.Settings.build().unrollTraversers(false).create()).alias(connectionGraphName);
} catch (Exception ex) {
throw new IllegalStateException(ex);
}
tryCloseCluster = true;
this.conf = Optional.of(conf);
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:23,代码来源:DriverRemoteConnection.java
示例2: shouldFailIfSslEnabledOnServerButNotClient
import org.apache.tinkerpop.gremlin.driver.Client; //导入依赖的package包/类
@Test
public void shouldFailIfSslEnabledOnServerButNotClient() throws Exception {
final Cluster cluster = Cluster.build().create();
final Client client = cluster.connect();
try {
client.submit("1+1").all().get();
fail("This should not succeed as the client did not enable SSL");
} catch(Exception ex) {
final Throwable root = ExceptionUtils.getRootCause(ex);
assertEquals(TimeoutException.class, root.getClass());
assertThat(root.getMessage(), startsWith("Timed out while waiting for an available host"));
} finally {
cluster.close();
}
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:17,代码来源:GremlinServerAuthOldIntegrateTest.java
示例3: shouldFailAuthenticateWithPlainTextNoCredentials
import org.apache.tinkerpop.gremlin.driver.Client; //导入依赖的package包/类
@Test
public void shouldFailAuthenticateWithPlainTextNoCredentials() throws Exception {
final Cluster cluster = Cluster.build().create();
final Client client = cluster.connect();
try {
client.submit("1+1").all().get();
fail("This should not succeed as the client did not provide credentials");
} catch(Exception ex) {
final Throwable root = ExceptionUtils.getRootCause(ex);
assertEquals(GSSException.class, root.getClass());
// removed this assert as the text of the message changes based on kerberos config - stupid kerberos
// assertThat(root.getMessage(), startsWith("Invalid name provided"));
} finally {
cluster.close();
}
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:19,代码来源:GremlinServerAuthOldIntegrateTest.java
示例4: shouldFailAuthenticateWithPlainTextBadPassword
import org.apache.tinkerpop.gremlin.driver.Client; //导入依赖的package包/类
@Test
public void shouldFailAuthenticateWithPlainTextBadPassword() throws Exception {
final Cluster cluster = Cluster.build().credentials("stephen", "bad").create();
final Client client = cluster.connect();
try {
client.submit("1+1").all().get();
fail("This should not succeed as the client did not provide valid credentials");
} catch(Exception ex) {
final Throwable root = ExceptionUtils.getRootCause(ex);
assertEquals(ResponseException.class, root.getClass());
assertEquals("Username and/or password are incorrect", root.getMessage());
} finally {
cluster.close();
}
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:17,代码来源:GremlinServerAuthOldIntegrateTest.java
示例5: shouldAuthenticateAndWorkWithVariablesOverJsonSerialization
import org.apache.tinkerpop.gremlin.driver.Client; //导入依赖的package包/类
@Test
public void shouldAuthenticateAndWorkWithVariablesOverJsonSerialization() throws Exception {
final Cluster cluster = Cluster.build().serializer(Serializers.GRAPHSON).credentials("stephen", "password").create();
final Client client = cluster.connect(name.getMethodName());
try {
Map vertex = (Map) client.submit("v=graph.addVertex(\"name\", \"stephen\")").all().get().get(0).getObject();
Map<String, List<Map>> properties = (Map) vertex.get("properties");
assertEquals("stephen", properties.get("name").get(0).get("value"));
final Map vpName = (Map)client.submit("v.property('name')").all().get().get(0).getObject();
assertEquals("stephen", vpName.get("value"));
} finally {
cluster.close();
}
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:17,代码来源:GremlinServerAuthOldIntegrateTest.java
示例6: shouldAuthenticateAndWorkWithVariablesOverGraphSONSerialization
import org.apache.tinkerpop.gremlin.driver.Client; //导入依赖的package包/类
@Test
public void shouldAuthenticateAndWorkWithVariablesOverGraphSONSerialization() throws Exception {
final Cluster cluster = Cluster.build().serializer(Serializers.GRAPHSON_V1D0).credentials("stephen", "password").create();
final Client client = cluster.connect(name.getMethodName());
try {
Map vertex = (Map) client.submit("v=graph.addVertex('name', 'stephen')").all().get().get(0).getObject();
Map<String, List<Map>> properties = (Map) vertex.get("properties");
assertEquals("stephen", properties.get("name").get(0).get("value"));
final Map vpName = (Map)client.submit("v.property('name')").all().get().get(0).getObject();
assertEquals("stephen", vpName.get("value"));
} finally {
cluster.close();
}
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:17,代码来源:GremlinServerAuthOldIntegrateTest.java
示例7: shouldRollbackOnEvalExceptionForManagedTransaction
import org.apache.tinkerpop.gremlin.driver.Client; //导入依赖的package包/类
@Test
public void shouldRollbackOnEvalExceptionForManagedTransaction() throws Exception {
assumeNeo4jIsPresent();
final Cluster cluster = Cluster.build().create();
final Client client = cluster.connect(name.getMethodName(), true);
try {
client.submit("graph.addVertex(); throw new Exception('no worky')").all().get();
fail("Should have tossed the manually generated exception");
} catch (Exception ex) {
final Throwable root = ExceptionUtils.getRootCause(ex);
ex.printStackTrace();
assertEquals("no worky", root.getMessage());
// just force a commit here of "something" in case there is something lingering
client.submit("graph.addVertex(); graph.tx().commit()").all().get();
}
// the transaction is managed so a rollback should have executed
assertEquals(1, client.submit("g.V().count()").all().get().get(0).getInt());
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:23,代码来源:GremlinServerSessionIntegrateTest.java
示例8: shouldEventuallySucceedAfterChannelLevelError
import org.apache.tinkerpop.gremlin.driver.Client; //导入依赖的package包/类
@Test
public void shouldEventuallySucceedAfterChannelLevelError() throws Exception {
final Cluster cluster = Cluster.build().addContactPoint("localhost")
.reconnectIntialDelay(500)
.reconnectInterval(500)
.maxContentLength(1024).create();
final Client client = cluster.connect();
try {
client.submit("def x = '';(0..<1024).each{x = x + '$it'};x").all().get();
fail("Request should have failed because it exceeded the max content length allowed");
} catch (Exception ex) {
final Throwable root = ExceptionUtils.getRootCause(ex);
assertThat(root.getMessage(), containsString("Max frame length of 1024 has been exceeded."));
}
assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
cluster.close();
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:21,代码来源:GremlinDriverIntegrateTest.java
示例9: shouldEventuallySucceedAfterMuchFailure
import org.apache.tinkerpop.gremlin.driver.Client; //导入依赖的package包/类
@Test
public void shouldEventuallySucceedAfterMuchFailure() throws Exception {
final Cluster cluster = Cluster.build().addContactPoint("localhost").create();
final Client client = cluster.connect();
// tested independently to 10000 iterations but for speed, bumped back to 1000
IntStream.range(0,1000).forEach(i -> {
try {
client.submit("1 + 9 9").all().join().get(0).getInt();
fail("Should not have gone through due to syntax error");
} catch (Exception ex) {
final Throwable root = ExceptionUtils.getRootCause(ex);
assertThat(root, instanceOf(ResponseException.class));
}
});
assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
cluster.close();
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:21,代码来源:GremlinDriverIntegrateTest.java
示例10: shouldEventuallySucceedOnSameServer
import org.apache.tinkerpop.gremlin.driver.Client; //导入依赖的package包/类
@Test
public void shouldEventuallySucceedOnSameServer() throws Exception {
stopServer();
final Cluster cluster = Cluster.build().addContactPoint("localhost").create();
final Client client = cluster.connect();
try {
client.submit("1+1").all().join().get(0).getInt();
fail("Should not have gone through because the server is not running");
} catch (Exception i) {
final Throwable root = ExceptionUtils.getRootCause(i);
assertThat(root, instanceOf(TimeoutException.class));
}
startServer();
// default reconnect time is 1 second so wait some extra time to be sure it has time to try to bring it
// back to life
TimeUnit.SECONDS.sleep(3);
assertEquals(2, client.submit("1+1").all().join().get(0).getInt());
cluster.close();
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:25,代码来源:GremlinDriverIntegrateTest.java
示例11: shouldFailWithBadClientSideSerialization
import org.apache.tinkerpop.gremlin.driver.Client; //导入依赖的package包/类
@Test
public void shouldFailWithBadClientSideSerialization() throws Exception {
final Cluster cluster = Cluster.open();
final Client client = cluster.connect();
final ResultSet results = client.submit("java.awt.Color.RED");
try {
results.all().join();
fail("Should have thrown exception over bad serialization");
} catch (Exception ex) {
final Throwable inner = ExceptionUtils.getRootCause(ex);
assertTrue(inner instanceof RuntimeException);
assertThat(inner.getMessage(), startsWith("Encountered unregistered class ID:"));
}
// should not die completely just because we had a bad serialization error. that kind of stuff happens
// from time to time, especially in the console if you're just exploring.
assertEquals(2, client.submit("1+1").all().get().get(0).getInt());
cluster.close();
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:23,代码来源:GremlinDriverIntegrateTest.java
示例12: shouldFailWithScriptExecutionException
import org.apache.tinkerpop.gremlin.driver.Client; //导入依赖的package包/类
@Test
public void shouldFailWithScriptExecutionException() throws Exception {
final Cluster cluster = Cluster.open();
final Client client = cluster.connect();
final ResultSet results = client.submit("1/0");
try {
results.all().join();
fail("Should have thrown exception over bad serialization");
} catch (Exception ex) {
final Throwable inner = ExceptionUtils.getRootCause(ex);
assertTrue(inner instanceof ResponseException);
assertThat(inner.getMessage(), endsWith("Division by zero"));
}
// should not die completely just because we had a bad serialization error. that kind of stuff happens
// from time to time, especially in the console if you're just exploring.
assertEquals(2, client.submit("1+1").all().get().get(0).getInt());
cluster.close();
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:23,代码来源:GremlinDriverIntegrateTest.java
示例13: shouldProcessRequestsOutOfOrder
import org.apache.tinkerpop.gremlin.driver.Client; //导入依赖的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));
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:23,代码来源:GremlinDriverIntegrateTest.java
示例14: shouldProcessSessionRequestsInOrder
import org.apache.tinkerpop.gremlin.driver.Client; //导入依赖的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());
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:26,代码来源:GremlinDriverIntegrateTest.java
示例15: shouldWaitForAllResultsToArrive
import org.apache.tinkerpop.gremlin.driver.Client; //导入依赖的package包/类
@Test
public void shouldWaitForAllResultsToArrive() throws Exception {
final Cluster cluster = Cluster.open();
final Client client = cluster.connect();
final AtomicInteger checked = new AtomicInteger(0);
final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
while (!results.allItemsAvailable()) {
assertTrue(results.getAvailableItemCount() < 10);
checked.incrementAndGet();
Thread.sleep(100);
}
assertTrue(checked.get() > 0);
assertEquals(9, results.getAvailableItemCount());
cluster.close();
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:18,代码来源:GremlinDriverIntegrateTest.java
示例16: shouldWorkOverNioTransport
import org.apache.tinkerpop.gremlin.driver.Client; //导入依赖的package包/类
@Test
public void shouldWorkOverNioTransport() throws Exception {
final Cluster cluster = Cluster.build().channelizer(Channelizer.NioChannelizer.class.getName()).create();
final Client client = cluster.connect();
final AtomicInteger checked = new AtomicInteger(0);
final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
while (!results.allItemsAvailable()) {
assertTrue(results.getAvailableItemCount() < 10);
checked.incrementAndGet();
Thread.sleep(100);
}
assertTrue(checked.get() > 0);
assertEquals(9, results.getAvailableItemCount());
cluster.close();
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:18,代码来源:GremlinDriverIntegrateTest.java
示例17: shouldStream
import org.apache.tinkerpop.gremlin.driver.Client; //导入依赖的package包/类
@Test
public void shouldStream() throws Exception {
final Cluster cluster = Cluster.open();
final Client client = cluster.connect();
final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
final AtomicInteger counter = new AtomicInteger(0);
results.stream().map(i -> i.get(Integer.class) * 2).forEach(i -> assertEquals(counter.incrementAndGet() * 2, Integer.parseInt(i.toString())));
assertEquals(9, counter.get());
assertThat(results.allItemsAvailable(), is(true));
// cant stream it again
assertThat(results.stream().iterator().hasNext(), is(false));
cluster.close();
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:17,代码来源:GremlinDriverIntegrateTest.java
示例18: shouldIterate
import org.apache.tinkerpop.gremlin.driver.Client; //导入依赖的package包/类
@Test
public void shouldIterate() throws Exception {
final Cluster cluster = Cluster.open();
final Client client = cluster.connect();
final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
final Iterator<Result> itty = results.iterator();
final AtomicInteger counter = new AtomicInteger(0);
while (itty.hasNext()) {
counter.incrementAndGet();
assertEquals(counter.get(), itty.next().getInt());
}
assertEquals(9, counter.get());
assertThat(results.allItemsAvailable(), is(true));
// can't stream it again
assertThat(results.iterator().hasNext(), is(false));
cluster.close();
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:22,代码来源:GremlinDriverIntegrateTest.java
示例19: shouldFailWithBadServerSideSerialization
import org.apache.tinkerpop.gremlin.driver.Client; //导入依赖的package包/类
@Test
public void shouldFailWithBadServerSideSerialization() throws Exception {
final Cluster cluster = Cluster.open();
final Client client = cluster.connect();
final ResultSet results = client.submit("TinkerGraph.open().variables()");
try {
results.all().join();
fail();
} catch (Exception ex) {
final Throwable inner = ExceptionUtils.getRootCause(ex);
assertTrue(inner instanceof ResponseException);
assertEquals(ResponseStatusCode.SERVER_ERROR_SERIALIZATION, ((ResponseException) inner).getResponseStatusCode());
}
// should not die completely just because we had a bad serialization error. that kind of stuff happens
// from time to time, especially in the console if you're just exploring.
assertEquals(2, client.submit("1+1").all().get().get(0).getInt());
cluster.close();
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:23,代码来源:GremlinDriverIntegrateTest.java
示例20: shouldSerializeToStringWhenRequested
import org.apache.tinkerpop.gremlin.driver.Client; //导入依赖的package包/类
@Test
public void shouldSerializeToStringWhenRequested() throws Exception {
final Map<String, Object> m = new HashMap<>();
m.put("serializeResultToString", true);
final GryoMessageSerializerV1d0 serializer = new GryoMessageSerializerV1d0();
serializer.configure(m, null);
final Cluster cluster = Cluster.build().serializer(serializer).create();
final Client client = cluster.connect();
final ResultSet resultSet = client.submit("TinkerFactory.createClassic()");
final List<Result> results = resultSet.all().join();
assertEquals(1, results.size());
assertEquals("tinkergraph[vertices:6 edges:6]", results.get(0).getString());
cluster.close();
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:18,代码来源:GremlinDriverIntegrateTest.java
注:本文中的org.apache.tinkerpop.gremlin.driver.Client类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论