use of org.apache.tinkerpop.gremlin.driver.Cluster in project janusgraph by JanusGraph.
the class AbstractJanusGraphAssemblyIT method runTraversalAgainstServer.
protected void runTraversalAgainstServer(MessageSerializer serializer) {
Cluster cluster = Cluster.build("localhost").port(8182).serializer(serializer).create();
GraphTraversalSource g = AnonymousTraversalSource.traversal().withRemote(DriverRemoteConnection.using(cluster, "g"));
testServerUsingTraversalSource(g);
}
use of org.apache.tinkerpop.gremlin.driver.Cluster in project janusgraph by JanusGraph.
the class JanusGraphChannelizerTest method bindingShouldExistAfterGraphIsCreated.
@Test
public void bindingShouldExistAfterGraphIsCreated() throws Exception {
final Cluster cluster = TestClientFactory.open();
final Client client = cluster.connect();
try {
// assert server is running correctly
assertEquals(2, client.submit("1+1").all().get().get(0).getInt());
// assert ConfigurationManagementGraph is bound
assertEquals(0, client.submit("ConfigurationManagementGraph.vertices().size()").all().get().get(0).getInt());
// assert new graph is not bound
thrown.expect(ExecutionException.class);
thrown.expectMessage(equalTo("org.apache.tinkerpop.gremlin.driver.exception.ResponseException: No such property: " + "newGraph for class: Script3"));
client.submit("newGraph").all().get();
// create newGraph
client.submit("Map<String, Object> map = new HashMap<String, Object>(); map.put(\"storage.backend\", \"inmemory\"); " + "org.janusgraph.core.ConfiguredGraphFactory.createTemplateConfiguration(new MapConfiguration(map));" + "org.janusgraph.core.ConfiguredGraphFactory.create(\"newGraph\")");
// assert newGraph is indeed bound
assertEquals(0, client.submit("newGraph.vertices().size()").all().get().get(0).getInt());
// assert newGraph_traversal is bound and the graphs are equivalent
assertEquals("newGraph", client.submit("newGraph_traversal.getGraph().getGraphName()").all().get().get(0).getString());
} finally {
cluster.close();
}
}
use of org.apache.tinkerpop.gremlin.driver.Cluster in project cypher-for-gremlin by opencypher.
the class GremlinNeo4jDriverTest method multipleRows.
@Test
public void multipleRows() {
Cluster cluster = Cluster.build().addContactPoints("localhost").port(server.getPort()).create();
Driver driver = GremlinDatabase.driver(cluster);
try (Session session = driver.session()) {
StatementResult result = session.run("MATCH (p:person) RETURN p.name, p.age");
List<String> rows = result.list(r -> r.get("p.name").asString() + r.get("p.age").asInt());
assertThat(rows).containsExactly("marko29", "vadas27", "josh32", "peter35");
}
}
use of org.apache.tinkerpop.gremlin.driver.Cluster in project cypher-for-gremlin by opencypher.
the class CypherGremlinServerClient method translating.
@Test
public void translating() {
BaseConfiguration configuration = new BaseConfiguration();
configuration.setProperty("port", gremlinServer.getPort());
configuration.setProperty("hosts", Arrays.asList("localhost"));
Cluster cluster = Cluster.open(configuration);
Client gremlinClient = cluster.connect();
// freshReadmeSnippet: translating
CypherGremlinClient cypherGremlinClient = CypherGremlinClient.translating(gremlinClient);
// freshReadmeSnippet: translating
List<Map<String, Object>> results = cypherGremlinClient.submit("MATCH (p:person) WHERE p.age > 25 RETURN p.name").all();
assertThat(results).extracting("p.name").containsExactly("marko", "vadas", "josh", "peter");
}
use of org.apache.tinkerpop.gremlin.driver.Cluster in project DataX by alibaba.
the class AbstractGdbGraph method initClient.
protected void initClient(final Configuration config, final boolean session) {
this.updateMode = Key.UpdateMode.valueOf(config.getString(Key.UPDATE_MODE, "INSERT"));
log.info("init graphdb client");
final String host = config.getString(Key.HOST);
final int port = config.getInt(Key.PORT);
final String username = config.getString(Key.USERNAME);
final String password = config.getString(Key.PASSWORD);
int maxDepthPerConnection = config.getInt(Key.MAX_IN_PROCESS_PER_CONNECTION, GdbWriterConfig.DEFAULT_MAX_IN_PROCESS_PER_CONNECTION);
int maxConnectionPoolSize = config.getInt(Key.MAX_CONNECTION_POOL_SIZE, GdbWriterConfig.DEFAULT_MAX_CONNECTION_POOL_SIZE);
int maxSimultaneousUsagePerConnection = config.getInt(Key.MAX_SIMULTANEOUS_USAGE_PER_CONNECTION, GdbWriterConfig.DEFAULT_MAX_SIMULTANEOUS_USAGE_PER_CONNECTION);
this.session = session;
if (this.session) {
maxConnectionPoolSize = GdbWriterConfig.DEFAULT_MAX_CONNECTION_POOL_SIZE;
maxDepthPerConnection = GdbWriterConfig.DEFAULT_MAX_IN_PROCESS_PER_CONNECTION;
maxSimultaneousUsagePerConnection = GdbWriterConfig.DEFAULT_MAX_SIMULTANEOUS_USAGE_PER_CONNECTION;
}
try {
final Cluster cluster = Cluster.build(host).port(port).credentials(username, password).serializer(Serializers.GRAPHBINARY_V1D0).maxContentLength(1048576).maxInProcessPerConnection(maxDepthPerConnection).minInProcessPerConnection(0).maxConnectionPoolSize(maxConnectionPoolSize).minConnectionPoolSize(maxConnectionPoolSize).maxSimultaneousUsagePerConnection(maxSimultaneousUsagePerConnection).resultIterationBatchSize(64).create();
this.client = session ? cluster.connect(UUID.randomUUID().toString()).init() : cluster.connect().init();
warmClient(maxConnectionPoolSize * maxDepthPerConnection);
} catch (final RuntimeException e) {
log.error("Failed to connect to GDB {}:{}, due to {}", host, port, e);
throw e;
}
this.propertiesBatchNum = config.getInt(Key.MAX_PROPERTIES_BATCH_NUM, DEFAULT_BATCH_PROPERTY_NUM);
this.maxRequestLength = config.getInt(Key.MAX_GDB_REQUEST_LENGTH, MAX_REQUEST_LENGTH);
}
Aggregations