use of ai.grakn.engine.GraknConfig in project grakn by graknlabs.
the class EngineContext method createTestConfig.
/**
* Create a configuration for use in tests, using random ports.
*/
public static GraknConfig createTestConfig() {
GraknConfig config = GraknConfig.create();
config.setConfigProperty(GraknConfigKey.SERVER_PORT, 0);
return config;
}
use of ai.grakn.engine.GraknConfig in project grakn by graknlabs.
the class BackgroundTaskRunnerTest method configureMocks.
@BeforeClass
public static void configureMocks() {
GraknConfig config = mock(GraknConfig.class);
when(config.getProperty(GraknConfigKey.NUM_BACKGROUND_THREADS)).thenReturn(1);
taskRunner = new BackgroundTaskRunner(config);
}
use of ai.grakn.engine.GraknConfig in project grakn by graknlabs.
the class GraqlShellIT method runShell.
private ShellResponse runShell(String input, String... args) throws Exception {
args = addKeyspaceAndUriParams(args);
InputStream in = new ByteArrayInputStream(input.getBytes());
OutputStream bout = new ByteArrayOutputStream();
OutputStream berr = new ByteArrayOutputStream();
OutputStream tout = bout;
OutputStream terr = berr;
if (showStdOutAndErr) {
// Intercept stdout and stderr, but make sure it is still printed using the TeeOutputStream
tout = new TeeOutputStream(bout, System.out);
terr = new TeeOutputStream(berr, System.err);
}
PrintStream out = new PrintStream(tout);
PrintStream err = new PrintStream(terr);
Boolean success = null;
GraknConfig config = GraknConfig.create();
try {
System.setIn(in);
GraqlShellOptions options = GraqlShellOptions.create(args);
success = GraqlConsole.start(options, new GraknSessionProvider(config), historyFile, out, err);
} catch (Exception e) {
e.printStackTrace();
err.flush();
fail(berr.toString());
} finally {
resetIO();
}
out.flush();
err.flush();
assertNotNull(success);
return ShellResponse.of(bout.toString(), berr.toString(), success);
}
use of ai.grakn.engine.GraknConfig 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.engine.GraknConfig in project grakn by graknlabs.
the class ConfigProcessor method updateStorageConfig.
public static void updateStorageConfig() {
GraknConfig graknConfig = Configs.graknConfig();
String updatedStorageConfigString = Configs.storageConfig().updateFromConfig(graknConfig).toConfigString();
saveConfigStringToFile(updatedStorageConfigString, Configs.storageConfigPath());
}
Aggregations