Java Code Examples for org.janusgraph.core.JanusGraph#close()

The following examples show how to use org.janusgraph.core.JanusGraph#close() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SchemaLoader.java    From janusgraph-utils with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {

        if (null == args || args.length < 2) {
            System.err.println("Usage: SchemaLoader <janusgraph-config-file> <schema-file>");
            System.exit(1);
        }

        String configFile = args[0];
        String schemaFile = args[1];

        // use custom or default config file to get JanusGraph
        JanusGraph g = JanusGraphFactory.open(configFile);

        try {
            new SchemaLoader().loadSchema(g, schemaFile);
        } catch (Exception e) {
            System.out.println("Failed to import schema due to " + e.getMessage());
        } finally {
            g.close();
        }

    }
 
Example 2
Source File: LoadData.java    From janusgraph-visualization with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
    ClassPathResource classPathResource = new ClassPathResource("janusgraph.properties");
    File file = classPathResource.getFile();
    String path = file.getPath();
    JanusGraph graph = JanusGraphFactory.open(path);
    GraphTraversalSource g = graph.traversal();
    g.V().drop().iterate();
    g.tx().commit();
    graph.tx().commit();
    GraphOfTheGodsFactory.load(graph);
    graph.close();
}
 
Example 3
Source File: BatchImport.java    From janusgraph-utils with Apache License 2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {

        if (null == args || args.length < 4) {
            System.err.println(
                    "Usage: BatchImport <janusgraph-config-file> <data-files-directory> <schema.json> <data-mapping.json> [skipSchema]");
            System.exit(1);
        }

        JanusGraph graph = JanusGraphFactory.open(args[0]);
        if (!(args.length > 4 && args[4].equals("skipSchema")))
            new SchemaLoader().loadSchema(graph, args[2]);
        new DataLoader(graph).loadVertex(args[1], args[3]);
        new DataLoader(graph).loadEdges(args[1], args[3]);
        graph.close();
    }
 
Example 4
Source File: AtlasJanusGraph.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Override
public void clear() {
    JanusGraph graph = getGraph();

    if (graph.isOpen()) {
        // only a shut down graph can be cleared
        graph.close();
    }

    try {
        JanusGraphFactory.drop(graph);
    } catch (BackendException ignoreEx) {
    }
}
 
Example 5
Source File: NewTimeline.java    From janusgraph_tutorial with Apache License 2.0 5 votes vote down vote up
public static void main(String argv[]) throws Exception {
  JanusGraph graph = JanusGraphFactory.open(Schema.CONFIG_FILE);
  HadoopQueryRunner q = new HadoopQueryRunner(graph.traversal(), "testUser1");
  int runs = 10;

  for(int i =0; i < runs; i++) {
    LOGGER.info("New timeline (run {} of {})", i+1, runs);
    q.printTimeline(q.getTimeline3(10));
  }
  q.close();
  graph.close();
}
 
Example 6
Source File: OldTimeline.java    From janusgraph_tutorial with Apache License 2.0 5 votes vote down vote up
public static void main(String argv[]) throws Exception {
  JanusGraph graph = JanusGraphFactory.open(Schema.CONFIG_FILE);
  HadoopQueryRunner q = new HadoopQueryRunner(graph.traversal(), "testUser1");
  int runs = 10;

  for(int i =0; i < runs; i++) {
    LOGGER.info("Previous timeline (run {} of {})", i+1, runs);
    q.printTimeline(q.getTimeline2(10));
  }
  q.close();
  graph.close();
}
 
Example 7
Source File: BuiltinQueries.java    From janusgraph_tutorial with Apache License 2.0 4 votes vote down vote up
/**
 * Run every example query, outputting results via @LOGGER
 *
 * @param argv
 * @throws Exception
 */
public static void main(String[] argv) throws Exception {
  JanusGraph graph = JanusGraphFactory.open(Schema.CONFIG_FILE);
  GraphTraversalSource graphTraversalSource = graph.traversal();

  QueryRunner queryRunner = new QueryRunner(graphTraversalSource, "testUser0");

  LOGGER.info("Initialized the builtin query executor");

  queryRunner.runQueries();

  queryRunner.close();

  graph.close();

  System.exit(0);
}