use of ai.grakn.util.SimpleURI in project grakn by graknlabs.
the class EngineProcess method graknCheckIfReady.
private boolean graknCheckIfReady(String host, int port, String path) {
try {
URL siteURL = UriBuilder.fromUri(new SimpleURI(host, port).toURI()).path(path).build().toURL();
HttpURLConnection connection = (HttpURLConnection) siteURL.openConnection();
connection.setRequestMethod("GET");
connection.connect();
int code = connection.getResponseCode();
return code == 200;
} catch (IOException e) {
return false;
}
}
use of ai.grakn.util.SimpleURI in project grakn by graknlabs.
the class GraqlShellIT method addKeyspaceAndUriParams.
// TODO: Remove this when we can clear graphs properly (TP #13745)
private String[] addKeyspaceAndUriParams(String[] args) {
List<String> argList = Lists.newArrayList(args);
int keyspaceIndex = argList.indexOf("-k") + 1;
if (keyspaceIndex == 0) {
argList.add("-k");
argList.add(GraqlShellOptions.DEFAULT_KEYSPACE.getValue());
keyspaceIndex = argList.size() - 1;
}
argList.set(keyspaceIndex, argList.get(keyspaceIndex) + keyspaceSuffix);
boolean uriSpecified = argList.contains("-r");
if (!uriSpecified) {
argList.add("-r");
boolean isBatchLoading = argList.contains("-b");
SimpleURI uri = isBatchLoading ? engine.uri() : engine.grpcUri();
argList.add(uri.toString());
}
return argList.toArray(new String[argList.size()]);
}
use of ai.grakn.util.SimpleURI in project grakn by graknlabs.
the class DistributionContext method newEngineProcess.
private Process newEngineProcess(Integer port, Integer redisPort) throws IOException {
// Set correct port & task manager
GraknConfig config = GraknConfig.create();
config.setConfigProperty(GraknConfigKey.SERVER_PORT, port);
config.setConfigProperty(GraknConfigKey.REDIS_HOST, ImmutableList.of(new SimpleURI("localhost", redisPort).toString()));
// To speed up tests of failure cases
config.setConfigProperty(GraknConfigKey.TASKS_RETRY_DELAY, 60);
// Write new properties to disk
File propertiesFile = new File("grakn-engine-" + port + ".properties");
propertiesFile.deleteOnExit();
config.write(propertiesFile);
// Java commands to start Engine process
String[] commands = { "java", "-cp", getClassPath(), "-Dgrakn.dir=" + EXTRACTED_DISTRIBUTION_DIRECTORY, "-Dgrakn.conf=" + propertiesFile.getAbsolutePath(), "-Dgrakn.pidfile=/tmp/grakn.pid", Grakn.class.getName(), "&" };
// Start process
ProcessBuilder processBuilder = new ProcessBuilder(commands);
if (inheritIO)
processBuilder.inheritIO();
return processBuilder.start();
}
use of ai.grakn.util.SimpleURI in project grakn by graknlabs.
the class RedisWrapperTest method whenBuildingSentinelNoMaster_Fails.
@Test(expected = IllegalStateException.class)
public void whenBuildingSentinelNoMaster_Fails() {
RedisServer server = inMemoryRedisContext.server();
RedisWrapper.builder().setUseSentinel(true).addURI(new SimpleURI(server.getHost(), server.getBindPort()).toString()).build();
}
use of ai.grakn.util.SimpleURI in project grakn by graknlabs.
the class GraknSessionProvider method getSession.
@Override
public GraknSession getSession(GraqlShellOptions options, ConsoleReader console) {
int defaultGrpcPort = config.getProperty(GraknConfigKey.GRPC_PORT);
SimpleURI defaultGrpcUri = new SimpleURI(Grakn.DEFAULT_URI.getHost(), defaultGrpcPort);
SimpleURI location = options.getUri();
SimpleURI uri = location != null ? location : defaultGrpcUri;
Keyspace keyspace = options.getKeyspace();
return RemoteGrakn.session(uri, keyspace);
}
Aggregations