Search in sources :

Example 1 with SpringCypherRestGraphDatabase

use of org.springframework.data.neo4j.rest.SpringCypherRestGraphDatabase in project elasticsearch-river-neo4j by sksamuel.

the class Neo4jRiverIntTest method setupElasticAndNeo4jClient.

@Before
public void setupElasticAndNeo4jClient() throws Exception {
    Settings globalSettings = settingsBuilder().loadFromClasspath("settings.yml").build();
    String json = copyToStringFromClasspath("/neo4j-inttest-river.json");
    Settings riverSettings = settingsBuilder().loadFromSource(json).build();
    index = riverSettings.get("index.name");
    type = riverSettings.get("index.type");
    String uri = riverSettings.get("neo4j.uri");
    logger.debug("Connecting to neo4j @ {}", uri);
    db = new SpringCypherRestGraphDatabase(uri);
    logger.debug("Starting local elastic...");
    Tuple<Settings, Environment> initialSettings = InternalSettingsPerparer.prepareSettings(globalSettings, true);
    if (!initialSettings.v2().configFile().exists()) {
        FileSystemUtils.mkdirs(initialSettings.v2().configFile());
    }
    if (!initialSettings.v2().logsFile().exists()) {
        FileSystemUtils.mkdirs(initialSettings.v2().logsFile());
    }
    node = nodeBuilder().local(true).settings(globalSettings).node();
    logger.info("Create river [{}]", river);
    node.client().prepareIndex("_river", river, "_meta").setSource(json).execute().actionGet();
    logger.debug("Running Cluster Health");
    ClusterHealthResponse clusterHealth = node.client().admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet();
    logger.info("Done Cluster Health, status " + clusterHealth.getStatus());
    GetResponse response = node.client().prepareGet("_river", river, "_meta").execute().actionGet();
    assertTrue(response.isExists());
    logger.debug("...elasticized ok");
}
Also used : ClusterHealthResponse(org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse) SpringCypherRestGraphDatabase(org.springframework.data.neo4j.rest.SpringCypherRestGraphDatabase) Environment(org.elasticsearch.env.Environment) QueryBuilders.queryString(org.elasticsearch.index.query.QueryBuilders.queryString) GetResponse(org.elasticsearch.action.get.GetResponse) Settings(org.elasticsearch.common.settings.Settings) Before(org.junit.Before)

Example 2 with SpringCypherRestGraphDatabase

use of org.springframework.data.neo4j.rest.SpringCypherRestGraphDatabase in project elasticsearch-river-neo4j by sksamuel.

the class Neo4jDriver method start.

@Override
public void start() {
    logger.info("Starting neo4j river");
    ElasticOperationWorker worker = new ElasticOperationWorker(client);
    SpringCypherRestGraphDatabase db = new SpringCypherRestGraphDatabase(uri);
    Neo4jIndexer indexer = new Neo4jIndexer(db, worker, indexingStrategy, deletingStategy, index, type, labels);
    Neo4jPoller poller = new Neo4jPoller(indexer, interval);
    executor = Executors.newFixedThreadPool(2);
    executor.submit(worker);
    executor.submit(poller);
    logger.debug("Neo4j river started");
}
Also used : SpringCypherRestGraphDatabase(org.springframework.data.neo4j.rest.SpringCypherRestGraphDatabase)

Aggregations

SpringCypherRestGraphDatabase (org.springframework.data.neo4j.rest.SpringCypherRestGraphDatabase)2 ClusterHealthResponse (org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse)1 GetResponse (org.elasticsearch.action.get.GetResponse)1 Settings (org.elasticsearch.common.settings.Settings)1 Environment (org.elasticsearch.env.Environment)1 QueryBuilders.queryString (org.elasticsearch.index.query.QueryBuilders.queryString)1 Before (org.junit.Before)1