{tip} ~This page has been generated by [maven-confluence-plugin|https://github.com/bsorrentino/maven-confluence-plugin/]~ {tip}
----
\\
h1.Table Of Content
{toc:minLevel=2}
h2.Use JanusGraph Embedded
Below the necessary steps to setup JanusGraph embedded and accessing it through a spring application
h3.Declare Maven dependencies
*Access to Cassandra using open source driver*
{code:xml}
<dependency>
<groupId>com.wba.configurationmanager-library</groupId>
<artifactId>cfgmgr-janus-spring</artifactId>
<version>3.2-SNAPSHOT</version>
</dependency>
<!-- THIS ENABLE ACCESS TO CASSANDRA -->
<dependency>
<groupId>org.janusgraph</groupId>
<artifactId>janusgraph-cql</artifactId>
<version>0.3.0-20180813</version>
<scope>runtime</scope>
</dependency>
{code}
*Access to Cassandra using DSE Driver enabling LDAP access*
{code:xml}
<dependency>
<groupId>com.wba.configurationmanager-library</groupId>
<artifactId>cfgmgr-janus-spring</artifactId>
<version>3.2-SNAPSHOT</version>
</dependency>
<!-- THIS ENABLE ACCESS TO CASSANDRA -->
<dependency>
<groupId>org.janusgraph</groupId>
<artifactId>janusgraph-cql</artifactId>
<version>0.3.0-20180813-</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.datastax.dse</groupId>
<artifactId>dse-java-driver-core</artifactId>
<version>[1.4.1,)</version>
</dependency>
{code}
h3.Use in Spring
*Create an instance of JANUSGraphLocalSession*
{code:java}
@SpringBootApplication
public class JanusLocalPocApplication {
private static final Logger LOGGER = LoggerFactory.getLogger(JanusLocalPocApplication.class);
@Autowired()
JANUSGraphLocalSession session;
public static void main(String[] args) {
SpringApplication.run(JanusLocalPocApplication.class, args);
}
@PostConstruct
void init() {
// Use graph traversal
LOGGER.debug( "number of vertex(s): {}", session.G().V().count().next() );
}
}
{code}
*Configure spring application*
In the application properties we have to set the URL of Janus configuration file
{noformat}janus.config.url=classpath:janus-cql.properties
{noformat}
*Janus Graph configuration for accessing to Cassandra*
{noformat}
#
# file: janus-cql.properties
#
gremlin.graph=org.janusgraph.core.JanusGraphFactory
storage.backend=cql
# storage.backend=inmemory // useful for test
storage.cql.keyspace=_keyspace_
storage.cql.read-consistency-level=LOCAL_QUORUM
storage.cql.write-consistency-level=LOCAL_QUORUM
storage.hostname=_cassandra_host_
storage.username=_username_
storage.password=_password_
{noformat}
----
\\
h1.Table Of Content
{toc:minLevel=2}
h2.Use JanusGraph Embedded
Below the necessary steps to setup JanusGraph embedded and accessing it through a spring application
h3.Declare Maven dependencies
*Access to Cassandra using open source driver*
{code:xml}
<dependency>
<groupId>com.wba.configurationmanager-library</groupId>
<artifactId>cfgmgr-janus-spring</artifactId>
<version>3.2-SNAPSHOT</version>
</dependency>
<!-- THIS ENABLE ACCESS TO CASSANDRA -->
<dependency>
<groupId>org.janusgraph</groupId>
<artifactId>janusgraph-cql</artifactId>
<version>0.3.0-20180813</version>
<scope>runtime</scope>
</dependency>
{code}
*Access to Cassandra using DSE Driver enabling LDAP access*
{code:xml}
<dependency>
<groupId>com.wba.configurationmanager-library</groupId>
<artifactId>cfgmgr-janus-spring</artifactId>
<version>3.2-SNAPSHOT</version>
</dependency>
<!-- THIS ENABLE ACCESS TO CASSANDRA -->
<dependency>
<groupId>org.janusgraph</groupId>
<artifactId>janusgraph-cql</artifactId>
<version>0.3.0-20180813-</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.datastax.dse</groupId>
<artifactId>dse-java-driver-core</artifactId>
<version>[1.4.1,)</version>
</dependency>
{code}
h3.Use in Spring
*Create an instance of JANUSGraphLocalSession*
{code:java}
@SpringBootApplication
public class JanusLocalPocApplication {
private static final Logger LOGGER = LoggerFactory.getLogger(JanusLocalPocApplication.class);
@Autowired()
JANUSGraphLocalSession session;
public static void main(String[] args) {
SpringApplication.run(JanusLocalPocApplication.class, args);
}
@PostConstruct
void init() {
// Use graph traversal
LOGGER.debug( "number of vertex(s): {}", session.G().V().count().next() );
}
}
{code}
*Configure spring application*
In the application properties we have to set the URL of Janus configuration file
{noformat}janus.config.url=classpath:janus-cql.properties
{noformat}
*Janus Graph configuration for accessing to Cassandra*
{noformat}
#
# file: janus-cql.properties
#
gremlin.graph=org.janusgraph.core.JanusGraphFactory
storage.backend=cql
# storage.backend=inmemory // useful for test
storage.cql.keyspace=_keyspace_
storage.cql.read-consistency-level=LOCAL_QUORUM
storage.cql.write-consistency-level=LOCAL_QUORUM
storage.hostname=_cassandra_host_
storage.username=_username_
storage.password=_password_
{noformat}