forked from JanusGraph/janusgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes JanusGraph#530 Signed-off-by: Jason Plurad <pluradj@us.ibm.com>
- Loading branch information
Showing
40 changed files
with
1,976 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# JanusGraph Examples | ||
|
||
The JanusGraph examples show the basics of how to configure and construct | ||
a graph application. It uses [Apache Maven](https://maven.apache.org) to | ||
manage the numerous dependencies required to build the application. The common | ||
application will: | ||
|
||
* Open and initialize the graph | ||
* Define the schema | ||
* Build the graph | ||
* Run traversal queries to get data from the graph | ||
* Make updates to the graph | ||
* Close the graph | ||
|
||
By using different graph configurations, the same example code can run against | ||
the various supported storage and indexing backends. | ||
|
||
## Prerequisites | ||
|
||
* Java 8 Developer Kit, update 40 or higher | ||
* Apache Maven, version 3.3 or higher | ||
|
||
## Building the Examples | ||
|
||
``` | ||
mvn clean install | ||
``` | ||
|
||
## Running the Examples | ||
|
||
Refer to the directions in each sub-directory. | ||
|
||
* [Common](example-common/README.md) | ||
* [BerkeleyJE](example-berkeleyje/README.md) | ||
* [Cassandra](example-cassandra/README.md) | ||
* [CQL](example-cql/README.md) | ||
* [HBase](example-hbase/README.md) | ||
* [RemoteGraph](example-remotegraph/README.md) | ||
* [TinkerGraph](example-tinkergraph/README.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
jgex/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# BerkeleyJE Storage, Lucene Index | ||
|
||
## About BerkeleyJE and Lucene | ||
|
||
[Oracle Berkeley DB Java Edition](http://www.oracle.com/technetwork/database/berkeleydb/overview/index-093405.html) | ||
is an embedded database, so it runs within your application rather than as | ||
a standalone server. By including the `janusgraph-berkeleyje` dependency, | ||
the required jar files are pulled in. The data is stored in a directory on | ||
the file system. | ||
|
||
[Apache Lucene](http://lucene.apache.org/) is an embedded index, so it runs | ||
within your application rather than as a standalone server. By including the | ||
`janusgraph-lucene` dependency, the required jar files are pulled in. The | ||
data is stored in a directory on the file system. | ||
|
||
## JanusGraph configuration | ||
|
||
[`jgex-berkeleyje.properties`](conf/jgex-berkeleyje.properties) contains | ||
the directory locations for BerkeleyJE and Lucene. | ||
|
||
Refer to the JanusGraph [configuration reference](http://docs.janusgraph.org/latest/config-ref.html) | ||
for additional properties. | ||
|
||
## Running the example | ||
|
||
Use [Apache Maven](http://maven.apache.org/) and the | ||
[exec-maven-plugin](http://www.mojohaus.org/exec-maven-plugin/java-mojo.html) | ||
to pull in the required jar files onto the runtime classpath. | ||
|
||
``` | ||
$ cd $JANUSGRAPH_HOME/janusgraph-examples/example-berkeleyje | ||
$ mvn exec:java -Dexec.mainClass="org.janusgraph.example.JanusGraphApp" -Dexec.args="conf/jgex-berkeleyje.properties" | ||
``` | ||
|
||
## Drop the graph | ||
|
||
Make sure to stop the application before dropping the graph. The configuration | ||
uses the application name `jgex` as the root directory for the BerkeleyJE | ||
and Lucene directories. | ||
|
||
``` | ||
$ cd $JANUSGRAPH_HOME/janusgraph-examples/example-berkeleyje | ||
$ mvn exec:java -Dexec.mainClass="org.janusgraph.example.JanusGraphApp" -Dexec.args="conf/jgex-berkeleyje.properties drop" | ||
$ rm -rf jgex/ | ||
``` |
7 changes: 7 additions & 0 deletions
7
janusgraph-examples/example-berkeleyje/conf/jgex-berkeleyje.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
gremlin.graph=org.janusgraph.core.JanusGraphFactory | ||
|
||
storage.backend=berkeleyje | ||
storage.directory=jgex/berkeleyje | ||
|
||
index.jgex.backend=lucene | ||
index.jgex.directory=jgex/lucene |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.janusgraph</groupId> | ||
<artifactId>janusgraph-examples</artifactId> | ||
<version>0.2.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<artifactId>example-berkeleyje</artifactId> | ||
<packaging>pom</packaging> | ||
<name>Example-BerkeleyJE: BerkeleyJE Storage, Lucene Index</name> | ||
<url>http://janusgraph.org</url> | ||
|
||
<dependencies> | ||
<!-- These are all runtime dependencies --> | ||
<dependency> | ||
<groupId>org.janusgraph</groupId> | ||
<artifactId>example-common</artifactId> | ||
<version>${project.version}</version> | ||
<scope>runtime</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.janusgraph</groupId> | ||
<artifactId>janusgraph-berkeleyje</artifactId> | ||
<version>${project.version}</version> | ||
<scope>runtime</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.janusgraph</groupId> | ||
<artifactId>janusgraph-lucene</artifactId> | ||
<version>${project.version}</version> | ||
<scope>runtime</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Cassandra Thrift Storage, Elasticsearch Index | ||
|
||
## About Cassandra and Elasticsearch | ||
|
||
[Apache Cassandra](http://cassandra.apache.org/) is a distributed database | ||
designed for scalability and high availability. Cassandra supports two | ||
protocols for communications, Thrift (legacy RPC protocol) and CQL (native | ||
protocol). Depending on the Cassandra version, Thrift may not be started by | ||
default. Make sure that [Thrift is started](http://docs.datastax.com/en/cassandra/2.1/cassandra/tools/toolsStatusThrift.html) | ||
when using this example. | ||
|
||
[Elasticsearch](https://www.elastic.co/products/elasticsearch) is a scalable, | ||
distributed search engine. | ||
|
||
> Check the JanusGraph [version compatibility](http://docs.janusgraph.org/latest/version-compat.html) | ||
to ensure you select versions of Cassandra and Elasticsearch compatible with | ||
this JanusGraph release. | ||
|
||
## JanusGraph configuration | ||
|
||
* [`jgex-cassandra.properties`](conf/jgex-cassandra.properties) contains the | ||
Cassandra and Elasticsearch server locations. By providing different values | ||
for `storage.cassandra.keyspace` and `index.jgex.index-name`, you can store | ||
multiple graphs on the same Cassandra and Elasticsearch servers. Refer to | ||
the JanusGraph [configuration reference](http://docs.janusgraph.org/latest/config-ref.html) | ||
for additional properties. | ||
|
||
* [`logback.xml`](conf/logback.xml) configures logging with [Logback](https://logback.qos.ch/), | ||
which is the logger used by Cassandra. The example configuration logs to the | ||
console and adjusts the logging level for some noisier packages. Refer to | ||
the Logback [manual](https://logback.qos.ch/manual/index.html) for additional | ||
details. | ||
|
||
## Run the example | ||
|
||
Use [Apache Maven](http://maven.apache.org/) and the [exec-maven-plugin](http://www.mojohaus.org/exec-maven-plugin/java-mojo.html) | ||
to pull in the required jar files onto the runtime classpath. | ||
|
||
``` | ||
$ cd $JANUSGRAPH_HOME/janusgraph-examples/example-cassandra | ||
$ mvn exec:java -Dexec.mainClass="org.janusgraph.example.JanusGraphApp" -Dlogback.configurationFile="conf/logback.xml" -Dexec.args="conf/jgex-cassandra.properties" | ||
``` | ||
|
||
## Drop the graph | ||
|
||
Make sure to stop the application before dropping the graph. | ||
|
||
``` | ||
$ cd $JANUSGRAPH_HOME/janusgraph-examples/example-cassandra | ||
$ mvn exec:java -Dexec.mainClass="org.janusgraph.example.JanusGraphApp" -Dlogback.configurationFile="conf/logback.xml" -Dexec.args="conf/jgex-cassandra.properties drop" | ||
``` |
9 changes: 9 additions & 0 deletions
9
janusgraph-examples/example-cassandra/conf/jgex-cassandra.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
gremlin.graph=org.janusgraph.core.JanusGraphFactory | ||
|
||
storage.backend=cassandra | ||
storage.cassandra.keyspace=jgex | ||
storage.hostname=127.0.0.1 | ||
|
||
index.jgex.backend=elasticsearch | ||
index.jgex.index-name=jgex | ||
index.jgex.hostname=127.0.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<configuration> | ||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> | ||
<!-- encoders are assigned the type | ||
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> | ||
<encoder> | ||
<pattern>%d{HH:mm:ss} %-5level %logger - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
<logger name="com.netflix.astyanax.connectionpool.impl" level="WARN"/> | ||
<root level="INFO"> | ||
<appender-ref ref="CONSOLE" /> | ||
</root> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.janusgraph</groupId> | ||
<artifactId>janusgraph-examples</artifactId> | ||
<version>0.2.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<artifactId>example-cassandra</artifactId> | ||
<packaging>pom</packaging> | ||
<name>Example-Cassandra: C* Thrift Storage, ES Index</name> | ||
<url>http://janusgraph.org</url> | ||
|
||
<dependencies> | ||
<!-- These are all runtime dependencies --> | ||
<dependency> | ||
<groupId>org.janusgraph</groupId> | ||
<artifactId>example-common</artifactId> | ||
<version>${project.version}</version> | ||
<scope>runtime</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.janusgraph</groupId> | ||
<artifactId>janusgraph-cassandra</artifactId> | ||
<version>${project.version}</version> | ||
<scope>runtime</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.janusgraph</groupId> | ||
<artifactId>janusgraph-es</artifactId> | ||
<version>${project.version}</version> | ||
<scope>runtime</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Common Example | ||
|
||
## About the common example | ||
|
||
`GraphApp` is an abstract class that defines a basic structure for a graph | ||
application. It contains methods for configuring a graph instance, defining | ||
a graph schema, creating a graph structure, and querying a graph. | ||
|
||
`JanusGraphApp` is a subclass of `GraphApp` using JanusGraph-specific methods | ||
to create the schema. | ||
|
||
## In-Memory configuration | ||
|
||
[`jgex-inmemory.properties`](conf/jgex-inmemory.properties) contains the | ||
settings for the JanusGraph [in-memory storage backend](http://docs.janusgraph.org/latest/inmemorystorage.html). | ||
This backend is primarily for testing purposes. | ||
|
||
## Running the example | ||
|
||
``` | ||
$ cd $JANUSGRAPH_HOME/janusgraph-examples/example-common | ||
$ mvn exec:java -Dexec.mainClass="org.janusgraph.example.JanusGraphApp" -Dexec.args="conf/jgex-inmemory.properties" | ||
``` |
3 changes: 3 additions & 0 deletions
3
janusgraph-examples/example-common/conf/jgex-inmemory.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
gremlin.graph=org.janusgraph.core.JanusGraphFactory | ||
|
||
storage.backend=inmemory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.janusgraph</groupId> | ||
<artifactId>janusgraph-examples</artifactId> | ||
<version>0.2.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<artifactId>example-common</artifactId> | ||
<name>Example-Common: Common Graph Code for Examples</name> | ||
<url>http://janusgraph.org</url> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.janusgraph</groupId> | ||
<artifactId>janusgraph-core</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
Oops, something went wrong.