Search in sources :

Example 1 with GraknConfig

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;
}
Also used : GraknConfig(ai.grakn.engine.GraknConfig)

Example 2 with GraknConfig

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);
}
Also used : GraknConfig(ai.grakn.engine.GraknConfig) BeforeClass(org.junit.BeforeClass)

Example 3 with GraknConfig

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);
}
Also used : GraknSessionProvider(ai.grakn.graql.shell.GraknSessionProvider) PrintStream(java.io.PrintStream) TeeOutputStream(org.apache.commons.io.output.TeeOutputStream) GraknConfig(ai.grakn.engine.GraknConfig) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) GraqlShellOptions(ai.grakn.graql.shell.GraqlShellOptions) ByteArrayOutputStream(java.io.ByteArrayOutputStream) TeeOutputStream(org.apache.commons.io.output.TeeOutputStream) OutputStream(java.io.OutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 4 with GraknConfig

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();
}
Also used : GraknConfig(ai.grakn.engine.GraknConfig) Grakn(ai.grakn.bootup.graknengine.Grakn) SimpleURI(ai.grakn.util.SimpleURI) ZipFile(net.lingala.zip4j.core.ZipFile) File(java.io.File)

Example 5 with GraknConfig

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());
}
Also used : GraknConfig(ai.grakn.engine.GraknConfig)

Aggregations

GraknConfig (ai.grakn.engine.GraknConfig)8 SimpleURI (ai.grakn.util.SimpleURI)2 Grakn (ai.grakn.bootup.graknengine.Grakn)1 GraknSessionProvider (ai.grakn.graql.shell.GraknSessionProvider)1 GraqlShellOptions (ai.grakn.graql.shell.GraqlShellOptions)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 PrintStream (java.io.PrintStream)1 URI (java.net.URI)1 Properties (java.util.Properties)1 ZipFile (net.lingala.zip4j.core.ZipFile)1 TeeOutputStream (org.apache.commons.io.output.TeeOutputStream)1 BeforeClass (org.junit.BeforeClass)1