Search in sources :

Example 1 with Grakn

use of ai.grakn.bootup.graknengine.Grakn in project grakn by graknlabs.

the class EngineProcess method getClassPathFrom.

protected String getClassPathFrom(Path home) {
    FilenameFilter jarFiles = (dir, name) -> name.toLowerCase().endsWith(".jar");
    // services/lib folder
    File folder = new File(home + File.separator + "services" + File.separator + "lib");
    File[] values = folder.listFiles(jarFiles);
    if (values == null) {
        throw new RuntimeException("No libraries found: cannot run " + COMPONENT_NAME);
    }
    Stream<File> jars = Stream.of(values);
    // /conf
    File conf = new File(home + File.separator + "conf" + File.separator);
    // services/grakn/server lib
    File graknLogback = new File(home + File.separator + "services" + File.separator + "grakn" + File.separator + "server" + File.separator);
    return ":" + Stream.concat(jars, Stream.of(conf, graknLogback)).filter(f -> !f.getName().contains("slf4j-log4j12")).map(File::getAbsolutePath).sorted().collect(Collectors.joining(":"));
}
Also used : HttpURLConnection(java.net.HttpURLConnection) FilenameFilter(java.io.FilenameFilter) Files(java.nio.file.Files) URL(java.net.URL) LocalDateTime(java.time.LocalDateTime) Grakn(ai.grakn.bootup.graknengine.Grakn) IOException(java.io.IOException) REST(ai.grakn.util.REST) Collectors(java.util.stream.Collectors) File(java.io.File) GraknConfig(ai.grakn.engine.GraknConfig) GraknConfigKey(ai.grakn.GraknConfigKey) Stream(java.util.stream.Stream) Paths(java.nio.file.Paths) Optional(java.util.Optional) UriBuilder(javax.ws.rs.core.UriBuilder) Comparator(java.util.Comparator) Path(java.nio.file.Path) SimpleURI(ai.grakn.util.SimpleURI) GraknSystemProperty(ai.grakn.GraknSystemProperty) FilenameFilter(java.io.FilenameFilter) File(java.io.File)

Example 2 with Grakn

use of ai.grakn.bootup.graknengine.Grakn in project grakn by graknlabs.

the class DistributionContext method getClassPath.

/**
 * Get the class path of all the jars in the /lib folder
 */
private String getClassPath() {
    Path servicesLibDir = Paths.get(EXTRACTED_DISTRIBUTION_DIRECTORY.toString(), "services", "lib");
    Path confDir = Paths.get(EXTRACTED_DISTRIBUTION_DIRECTORY.toString(), "conf");
    Path graknLogback = Paths.get(EXTRACTED_DISTRIBUTION_DIRECTORY.toString(), "services", "grakn", "server");
    FilenameFilter jarFiles = (dir, name) -> name.toLowerCase().endsWith(".jar");
    Stream<File> jars = Stream.of(servicesLibDir.toFile().listFiles(jarFiles));
    return Stream.concat(jars, Stream.of(confDir.toFile(), graknLogback.toFile())).filter(f -> !f.getName().contains("slf4j-log4j12")).map(File::getAbsolutePath).collect(joining(":"));
}
Also used : Path(java.nio.file.Path) FilenameFilter(java.io.FilenameFilter) System.currentTimeMillis(java.lang.System.currentTimeMillis) TestRule(org.junit.rules.TestRule) LoggerFactory(org.slf4j.LoggerFactory) GraknConfig(ai.grakn.engine.GraknConfig) Client(ai.grakn.client.Client) ImmutableList(com.google.common.collect.ImmutableList) Path(java.nio.file.Path) GraknSystemProperty(ai.grakn.GraknSystemProperty) ZipFile(net.lingala.zip4j.core.ZipFile) Logger(org.slf4j.Logger) Files(java.nio.file.Files) Grakn(ai.grakn.bootup.graknengine.Grakn) FileUtils(org.apache.commons.io.FileUtils) IOException(java.io.IOException) File(java.io.File) Collectors.joining(java.util.stream.Collectors.joining) ZipException(net.lingala.zip4j.exception.ZipException) GraknConfigKey(ai.grakn.GraknConfigKey) List(java.util.List) Stream(java.util.stream.Stream) Paths(java.nio.file.Paths) GraknVersion(ai.grakn.util.GraknVersion) RestAssured(com.jayway.restassured.RestAssured) Assert(org.junit.Assert) SimpleURI(ai.grakn.util.SimpleURI) FilenameFilter(java.io.FilenameFilter) ZipFile(net.lingala.zip4j.core.ZipFile) File(java.io.File)

Example 3 with Grakn

use of ai.grakn.bootup.graknengine.Grakn 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)

Aggregations

Grakn (ai.grakn.bootup.graknengine.Grakn)3 GraknConfig (ai.grakn.engine.GraknConfig)3 SimpleURI (ai.grakn.util.SimpleURI)3 File (java.io.File)3 GraknConfigKey (ai.grakn.GraknConfigKey)2 GraknSystemProperty (ai.grakn.GraknSystemProperty)2 FilenameFilter (java.io.FilenameFilter)2 IOException (java.io.IOException)2 Files (java.nio.file.Files)2 Path (java.nio.file.Path)2 Paths (java.nio.file.Paths)2 Stream (java.util.stream.Stream)2 ZipFile (net.lingala.zip4j.core.ZipFile)2 Client (ai.grakn.client.Client)1 GraknVersion (ai.grakn.util.GraknVersion)1 REST (ai.grakn.util.REST)1 ImmutableList (com.google.common.collect.ImmutableList)1 RestAssured (com.jayway.restassured.RestAssured)1 System.currentTimeMillis (java.lang.System.currentTimeMillis)1 HttpURLConnection (java.net.HttpURLConnection)1