aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorabatos <adrian.batos-parac@amdocs.com>2017-08-22 14:23:21 -0400
committerabatos <adrian.batos-parac@amdocs.com>2017-08-22 15:33:04 -0400
commitddc73b563fcd2b3e47b5d0f54139f20ed3cdcba1 (patch)
tree91bf9c18725f0a982468ad71f963ffe26f8c2d58
parent7e69be504213aa92893fd3354a767128b3a583f1 (diff)
Split out Titan specific dependencies from core
Remove the Titan specific references within the gizmo core and prepare for dependency on new champ core library. Change-Id: I29a4e7b6528e8357715b095d8db5456cd01eb636 Issue-ID: AAI-21 Signed-off-by: abatos <adrian.batos-parac@amdocs.com>
-rw-r--r--janus-deps-pom.xml90
-rw-r--r--pom.xml88
-rw-r--r--src/main/ajsc/crud-api_v1/crud-api/v1/routes/crud.route2
-rw-r--r--src/main/bin/start.sh18
-rw-r--r--src/main/docker/Dockerfile3
-rw-r--r--src/main/java/org/openecomp/crud/dao/champ/ChampDao.java174
-rw-r--r--src/main/java/org/openecomp/crud/logging/CrudServiceMsgs.java35
-rw-r--r--src/main/java/org/openecomp/crud/service/CrudGraphDataService.java37
-rw-r--r--src/main/resources/logging/CrudServiceMsgs.properties18
-rw-r--r--src/test/java/org/openecomp/crud/dao/champ/ChampDaoTest.java4
-rw-r--r--titan-deps-pom.xml89
11 files changed, 236 insertions, 322 deletions
diff --git a/janus-deps-pom.xml b/janus-deps-pom.xml
new file mode 100644
index 0000000..7a0cd77
--- /dev/null
+++ b/janus-deps-pom.xml
@@ -0,0 +1,90 @@
+<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>
+ <groupId>com.test</groupId>
+ <artifactId>myjanus</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.openecomp.aai</groupId>
+ <artifactId>champ-janus</artifactId>
+ <version>1.1.1-AMDOCS-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.janusgraph</groupId>
+ <artifactId>janusgraph-cassandra</artifactId>
+ <version>0.1.1</version>
+ <optional>true</optional>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>gremlin-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>gremlin-groovy</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.janusgraph</groupId>
+ <artifactId>janusgraph-hbase</artifactId>
+ <version>0.1.1</version>
+ <optional>true</optional>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>gremlin-groovy</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>gremlin-core</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>3.0.1</version>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.directory}/graph-deps/janus-deps</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>false</overWriteSnapshots>
+ <overWriteIfNewer>true</overWriteIfNewer>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project> \ No newline at end of file
diff --git a/pom.xml b/pom.xml
index d16e93c..99dd62b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -74,70 +74,6 @@
<version>2.6.2</version>
</dependency>
- <dependency>
- <groupId>com.thinkaurelius.titan</groupId>
- <artifactId>titan-cassandra</artifactId>
- <version>1.0.0</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.tinkerpop</groupId>
- <artifactId>gremlin-groovy</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </exclusion>
- <exclusion>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.tinkerpop</groupId>
- <artifactId>gremlin-core</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>com.thinkaurelius.titan</groupId>
- <artifactId>titan-hbase</artifactId>
- <version>1.0.0</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.tinkerpop</groupId>
- <artifactId>gremlin-groovy</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </exclusion>
- <exclusion>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.tinkerpop</groupId>
- <artifactId>gremlin-core</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.apache.hbase</groupId>
- <artifactId>hbase-client</artifactId>
- <version>1.0.2</version>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </exclusion>
- <exclusion>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
<!-- Common logging framework -->
<dependency>
<groupId>org.openecomp.aai.logging-service</groupId>
@@ -194,20 +130,30 @@
</exclusion>
</exclusions>
</dependency>
+
+ <!-- TEST Dependencies -->
+
+ <dependency>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>tinkergraph-gremlin</artifactId>
+ <version>3.2.3</version>
+ <scope>test</scope>
+ </dependency>
- <!-- Since for some reason the Champ library marks this artifact as an
- 'optional' dependency, we don't get it as a transitive dependency, even though
- we are guaranteed No-Clas-Def errors if we don't have it on the class path,
- so... we need to explicitly include it ourselves... -->
<dependency>
- <groupId>com.thinkaurelius.titan</groupId>
- <artifactId>titan-cassandra</artifactId>
- <version>1.0.0</version>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>gremlin-core</artifactId>
+ <version>3.2.3</version>
+ <scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ </exclusion>
</exclusions>
</dependency>
diff --git a/src/main/ajsc/crud-api_v1/crud-api/v1/routes/crud.route b/src/main/ajsc/crud-api_v1/crud-api/v1/routes/crud.route
index 185aa6a..65420a3 100644
--- a/src/main/ajsc/crud-api_v1/crud-api/v1/routes/crud.route
+++ b/src/main/ajsc/crud-api_v1/crud-api/v1/routes/crud.route
@@ -1,4 +1,4 @@
<route xmlns="http://camel.apache.org/schema/spring" trace="true">
<from uri="att-dme2-servlet:///inventory?matchOnUriPrefix=true" />
- <to uri="cxfbean:crudServices" />
+ <to uri="cxfbean:crudRestService" />
</route> \ No newline at end of file
diff --git a/src/main/bin/start.sh b/src/main/bin/start.sh
index 8a68460..003852f 100644
--- a/src/main/bin/start.sh
+++ b/src/main/bin/start.sh
@@ -39,6 +39,24 @@ fi
CLASSPATH="$AJSC_HOME/lib/*"
CLASSPATH="$CLASSPATH:$AJSC_HOME/extJars/"
CLASSPATH="$CLASSPATH:$AJSC_HOME/etc/"
+
+# Check to see if the provided implementation exists in the image and add it to the classpath
+for file in $( find ${BASEDIR}graph-deps/* -maxdepth 0 -type d ); do
+ CURRIMPL=$(echo $file | cut -d"/" -f6)
+ if [ "x$GRAPHIMPL" = "x$CURRIMPL" ]; then
+ CLASSPATH_GRAPHIMPL=$file
+ echo "Setting up graph implementation of $GRAPHIMPL"
+ else
+ SUPPORTED_GRAPHIMPL="$SUPPORTED_GRAPHIMPL $CURRIMPL"
+ fi
+done
+if [ -n "$CLASSPATH_GRAPHIMPL" ]; then
+ cp $CLASSPATH_GRAPHIMPL/* $AJSC_HOME/extJars/
+else
+ echo "Configured graph implementation '$GRAPHIMPL' is not supported. Acceptable implementations are one of: $SUPPORTED_GRAPHIMPL"
+ exit 1
+fi
+
PROPS="-DAJSC_HOME=$AJSC_HOME"
PROPS="$PROPS -DAJSC_CONF_HOME=$BASEDIR/bundleconfig/"
PROPS="$PROPS -Dlogback.configurationFile=$BASEDIR/bundleconfig/etc/logback.xml"
diff --git a/src/main/docker/Dockerfile b/src/main/docker/Dockerfile
index e4459d1..c342772 100644
--- a/src/main/docker/Dockerfile
+++ b/src/main/docker/Dockerfile
@@ -2,6 +2,7 @@ FROM ubuntu:14.04
ARG MICRO_HOME=/opt/app/crud-api
ARG BIN_HOME=$MICRO_HOME/bin
+ARG GRAPHLIB_HOME=$MICRO_HOME/graph-deps
RUN apt-get update
@@ -16,6 +17,8 @@ RUN export JAVA_HOME
# Build up the deployment folder structure
RUN mkdir -p $MICRO_HOME
ADD swm/package/nix/dist_files/appl/crud-api/* $MICRO_HOME/
+RUN mkdir -p $GRAPHLIB_HOME
+ADD graph-deps $GRAPHLIB_HOME
RUN mkdir -p $BIN_HOME
COPY *.sh $BIN_HOME
RUN chmod 755 $BIN_HOME/*
diff --git a/src/main/java/org/openecomp/crud/dao/champ/ChampDao.java b/src/main/java/org/openecomp/crud/dao/champ/ChampDao.java
index c8a68e7..5e9d10a 100644
--- a/src/main/java/org/openecomp/crud/dao/champ/ChampDao.java
+++ b/src/main/java/org/openecomp/crud/dao/champ/ChampDao.java
@@ -23,17 +23,16 @@
*/
package org.openecomp.crud.dao.champ;
-import org.openecomp.aai.champ.ChampAPI;
-import org.openecomp.aai.champ.ChampGraph;
-import org.openecomp.aai.champ.exceptions.ChampMarshallingException;
-import org.openecomp.aai.champ.exceptions.ChampObjectNotExistsException;
-import org.openecomp.aai.champ.exceptions.ChampRelationshipNotExistsException;
-import org.openecomp.aai.champ.exceptions.ChampSchemaViolationException;
-import org.openecomp.aai.champ.exceptions.ChampUnmarshallingException;
-import org.openecomp.aai.champ.graph.impl.TitanChampGraphImpl;
-import org.openecomp.aai.champ.model.ChampObject;
-import org.openecomp.aai.champ.model.ChampRelationship;
-import org.openecomp.aai.champ.model.fluent.object.ObjectBuildOrPropertiesStep;
+import org.openecomp.aai.champcore.ChampGraph;
+import org.openecomp.aai.champcore.exceptions.ChampMarshallingException;
+import org.openecomp.aai.champcore.exceptions.ChampObjectNotExistsException;
+import org.openecomp.aai.champcore.exceptions.ChampRelationshipNotExistsException;
+import org.openecomp.aai.champcore.exceptions.ChampSchemaViolationException;
+import org.openecomp.aai.champcore.exceptions.ChampTransactionException;
+import org.openecomp.aai.champcore.exceptions.ChampUnmarshallingException;
+import org.openecomp.aai.champcore.model.ChampObject;
+import org.openecomp.aai.champcore.model.ChampRelationship;
+import org.openecomp.aai.champcore.model.fluent.object.ObjectBuildOrPropertiesStep;
import org.openecomp.cl.api.Logger;
import org.openecomp.cl.eelf.LoggerFactory;
import org.openecomp.crud.dao.GraphDao;
@@ -47,8 +46,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
-import java.util.Properties;
-import java.util.Random;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -82,11 +79,6 @@ public class ChampDao implements GraphDao {
}
/**
- * Set of configuration properties for the DAI.
- */
- private Properties daoConfig;
-
- /**
* Instance of the API used for interacting with the Champ library.
*/
private ChampGraph champApi = null;
@@ -97,20 +89,12 @@ public class ChampDao implements GraphDao {
/**
* Creates a new instance of the ChampDao.
*
- * @param config - Set of configuration properties to be applied to this instance
- * of the DAO.
+ * @param champGraph - Concrete implementation of the graph dao layer
*/
- public ChampDao(Properties config) {
-
- // Store the configuration properties.
- daoConfig = config;
-
- // Apply the configuration to the DAO.
- configure();
-
+ public ChampDao(ChampGraph champGraph) {
+ this.champApi = champGraph;
}
-
@Override
public Vertex getVertex(String id, String type) throws CrudException {
@@ -635,112 +619,6 @@ public class ChampDao implements GraphDao {
return edgeBuilder.build();
}
-
- /**
- * Performs all one-time configuration operations which are required when creating
- * a new instance of the DAO.
- */
- private void configure() {
-
- // Instantiate the Champ library API.
- try {
-
- // Determine which back end we are using.
- switch (getBackendTypeFromConfig()) {
-
- case IN_MEMORY:
-
- logger.info(CrudServiceMsgs.INSTANTIATE_GRAPH_DAO,
- "In Memory",
- daoConfig.getProperty(CONFIG_GRAPH_NAME, DEFAULT_GRAPH_NAME),
- "Not applicable");
-
- champApi = ChampGraph.Factory.newInstance(ChampGraph.Type.IN_MEMORY,
- daoConfig.getProperty(CONFIG_GRAPH_NAME, DEFAULT_GRAPH_NAME));
-
- break;
-
- case TITAN:
- try {
- String db = daoConfig.getProperty(CONFIG_STORAGE_BACKEND_DB);
- Short graphIdSuffix = (short) new Random().nextInt(Short.MAX_VALUE);
- logger.info(CrudServiceMsgs.TITAN_GRAPH_INFO, GRAPH_UNQ_INSTANCE_ID_SUFFIX
- + ": = " + graphIdSuffix);
- if (db.equalsIgnoreCase(STORAGE_CASSANDRA_DB)) {
- logger.info(CrudServiceMsgs.INSTANTIATE_GRAPH_DAO, "Titan with cassandra backend",
- daoConfig.getProperty(CONFIG_GRAPH_NAME, DEFAULT_GRAPH_NAME),
- daoConfig.getProperty(CONFIG_STORAGE_HOSTNAMES));
-
- TitanChampGraphImpl.Builder champApiBuilder =
- new TitanChampGraphImpl.Builder(daoConfig.getProperty(CONFIG_GRAPH_NAME,
- DEFAULT_GRAPH_NAME))
- .property("storage.backend", "cassandrathrift")
- .property(GRAPH_UNQ_INSTANCE_ID_SUFFIX, graphIdSuffix)
- .property("storage.hostname", daoConfig.get(CONFIG_STORAGE_HOSTNAMES));
-
- if (daoConfig.containsKey(CONFIG_EVENT_STREAM_PUBLISHER)) {
- champApiBuilder.property("champ.event.stream.publisher",
- daoConfig.get(CONFIG_EVENT_STREAM_PUBLISHER));
- }
-
- if (daoConfig.containsKey(CONFIG_EVENT_STREAM_NUM_PUBLISHERS)) {
- champApiBuilder.property("champ.event.stream.publisher-pool-size",
- daoConfig.get(CONFIG_EVENT_STREAM_NUM_PUBLISHERS));
- }
-
- champApi = champApiBuilder.build();
-
- } else if (db.equalsIgnoreCase(STORAGE_HBASE_DB)) {
-
- logger.info(CrudServiceMsgs.INSTANTIATE_GRAPH_DAO, "Titan with Hbase backend",
- daoConfig.getProperty(CONFIG_GRAPH_NAME, DEFAULT_GRAPH_NAME),
- daoConfig.getProperty(CONFIG_STORAGE_HOSTNAMES));
- TitanChampGraphImpl.Builder champApiBuilder =
- new TitanChampGraphImpl.Builder(daoConfig
- .getProperty(CONFIG_GRAPH_NAME, DEFAULT_GRAPH_NAME))
- .property("storage.backend", "hbase")
- .property("storage.hbase.ext.zookeeper.znode.parent",
- daoConfig.get(CONFIG_HBASE_ZNODE_PARENT))
- .property("storage.port", daoConfig.get(CONFIG_STORAGE_PORT))
- .property(GRAPH_UNQ_INSTANCE_ID_SUFFIX, graphIdSuffix)
- .property("storage.hostname", daoConfig.get(CONFIG_STORAGE_HOSTNAMES));
-
- if (daoConfig.containsKey(CONFIG_EVENT_STREAM_PUBLISHER)) {
- champApiBuilder.property("champ.event.stream.publisher",
- daoConfig.get(CONFIG_EVENT_STREAM_PUBLISHER));
- }
-
- if (daoConfig.containsKey(CONFIG_EVENT_STREAM_NUM_PUBLISHERS)) {
- champApiBuilder.property("champ.event.stream.publisher-pool-size",
- daoConfig.get(CONFIG_EVENT_STREAM_NUM_PUBLISHERS));
- }
- champApi = champApiBuilder.build();
- } else {
- logger.error(CrudServiceMsgs.INVALID_GRAPH_BACKEND,
- daoConfig.getProperty(CONFIG_STORAGE_BACKEND_DB));
- }
-
- } catch (com.thinkaurelius.titan.core.TitanException e) {
-
- logger.error(CrudServiceMsgs.INSTANTIATE_GRAPH_BACKEND_ERR, "Titan", e.getMessage());
- }
-
-
- break;
-
- default:
- logger.error(CrudServiceMsgs.INVALID_GRAPH_BACKEND,
- daoConfig.getProperty(CONFIG_STORAGE_BACKEND));
- break;
- }
-
- } catch (CrudException e) {
- logger.error(CrudServiceMsgs.INSTANTIATE_GRAPH_BACKEND_ERR,
- daoConfig.getProperty(CONFIG_STORAGE_BACKEND), e.getMessage());
- }
- }
-
-
/**
* Performs any necessary shut down operations when the DAO is no longer needed.
*/
@@ -753,30 +631,4 @@ public class ChampDao implements GraphDao {
champApi.shutdown();
}
}
-
-
- /**
- * This helper function converts the 'graph back end type' config parameter into the
- * corresponding {@link ChampAPI.Type}.
- *
- * @return - A {@link ChampAPI.Type}
- * @throws CrudException
- */
- private GraphType getBackendTypeFromConfig() throws CrudException {
-
- // Get the back end type from the DAO's configuration properties.
- String backend = daoConfig.getProperty(CONFIG_STORAGE_BACKEND, "in-memory");
-
- // Now, find the appropriate ChampAPI type and return it.
- if (backend.equals("in-memory")) {
- return GraphType.IN_MEMORY;
- } else if (backend.equals("titan")) {
- return GraphType.TITAN;
- }
-
- // If we are here, then whatever was in the config properties didn't match to a supported
- // back end type, so just throw an exception and let the caller figure it out.
- throw new CrudException("Invalid graph backend type '" + backend + "' specified.",
- javax.ws.rs.core.Response.Status.BAD_REQUEST);
- }
}
diff --git a/src/main/java/org/openecomp/crud/logging/CrudServiceMsgs.java b/src/main/java/org/openecomp/crud/logging/CrudServiceMsgs.java
index 71fb14b..265f327 100644
--- a/src/main/java/org/openecomp/crud/logging/CrudServiceMsgs.java
+++ b/src/main/java/org/openecomp/crud/logging/CrudServiceMsgs.java
@@ -61,16 +61,6 @@ public enum CrudServiceMsgs implements LogMessageEnum {
OXM_LOAD_ERROR,
/**
- * Instantiate data access layer for graph data store type: {0} graph: {1} using hosts: {2}
- *
- * <p>Arguments:
- * {0} = Graph data store technology type
- * {1} = Graph name
- * {2} = Hosts list
- */
- INSTANTIATE_GRAPH_DAO,
-
- /**
* Stopping ChampDAO...
*
* <p>Arguments:
@@ -78,23 +68,6 @@ public enum CrudServiceMsgs implements LogMessageEnum {
STOPPING_CHAMP_DAO,
/**
- * Unsupported graph database {0} specified.
- *
- * <p>Arguments:
- * {0} = Graph database back end.
- */
- INVALID_GRAPH_BACKEND,
-
- /**
- * Failure instantiating {0} graph database backend. Cause: {1}
- *
- * <p>Arguments:
- * {0} - Graph database type.
- * {1} - Failure cause.
- */
- INSTANTIATE_GRAPH_BACKEND_ERR,
-
- /**
* Failure instantiating CRUD Rest Service. Cause: {0}
*
* <p>Arguments:
@@ -103,14 +76,6 @@ public enum CrudServiceMsgs implements LogMessageEnum {
INSTANTIATE_AUTH_ERR,
/**
- * Any info log related to titan graph
- *
- * <p>Arguments:
- * {0} - Info.
- */
- TITAN_GRAPH_INFO,
-
- /**
* Arguments:
* {0} Opertaion
* {1} URI
diff --git a/src/main/java/org/openecomp/crud/service/CrudGraphDataService.java b/src/main/java/org/openecomp/crud/service/CrudGraphDataService.java
index 8693505..e6d6748 100644
--- a/src/main/java/org/openecomp/crud/service/CrudGraphDataService.java
+++ b/src/main/java/org/openecomp/crud/service/CrudGraphDataService.java
@@ -23,16 +23,13 @@
*/
package org.openecomp.crud.service;
-import org.onap.aai.event.api.EventPublisher;
-
+import org.openecomp.aai.champcore.ChampGraph;
import org.openecomp.crud.dao.GraphDao;
import org.openecomp.crud.dao.champ.ChampDao;
import org.openecomp.crud.entity.Edge;
import org.openecomp.crud.entity.Vertex;
import org.openecomp.crud.exception.CrudException;
import org.openecomp.crud.parser.CrudResponseBuilder;
-import org.openecomp.crud.util.CrudProperties;
-import org.openecomp.crud.util.CrudServiceConstants;
import org.openecomp.schema.OxmModelLoader;
import org.openecomp.schema.OxmModelValidator;
import org.openecomp.schema.RelationshipSchemaLoader;
@@ -40,42 +37,14 @@ import org.openecomp.schema.RelationshipSchemaValidator;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
public class CrudGraphDataService {
private GraphDao dao;
- public CrudGraphDataService(EventPublisher champEventPublisher) throws CrudException {
-
- // Configure the GraphDao and wire it
- Properties champProperties = new Properties();
- champProperties.put(ChampDao.CONFIG_STORAGE_BACKEND, "titan");
- champProperties.put(ChampDao.CONFIG_STORAGE_BACKEND_DB,
- CrudProperties.get(CrudServiceConstants.CRD_STORAGE_BACKEND_DB, "hbase"));
- champProperties.put(ChampDao.CONFIG_STORAGE_HOSTNAMES,
- CrudProperties.get(CrudServiceConstants.CRD_GRAPH_HOST));
- champProperties.put(ChampDao.CONFIG_STORAGE_PORT,
- CrudProperties.get(CrudServiceConstants.CRD_GRAPH_PORT, "2181"));
- champProperties.put(ChampDao.CONFIG_HBASE_ZNODE_PARENT,
- CrudProperties.get(CrudServiceConstants.CRD_HBASE_ZNODE_PARENT, "/hbase-unsecure"));
-
- if (CrudProperties.get("crud.graph.name") != null) {
- champProperties.put(ChampDao.CONFIG_GRAPH_NAME, CrudProperties.get("crud.graph.name"));
- }
-
- if (champEventPublisher != null) {
- champProperties.put(ChampDao.CONFIG_EVENT_STREAM_PUBLISHER, champEventPublisher);
- }
-
- if (CrudProperties.get(ChampDao.CONFIG_EVENT_STREAM_NUM_PUBLISHERS) != null) {
- champProperties.put(ChampDao.CONFIG_EVENT_STREAM_NUM_PUBLISHERS,
- Integer.parseInt(CrudProperties.get(ChampDao.CONFIG_EVENT_STREAM_NUM_PUBLISHERS)));
- }
-
- ChampDao champDao = new ChampDao(champProperties);
+ public CrudGraphDataService(ChampGraph graphImpl) throws CrudException {
- this.dao = champDao;
+ this.dao = new ChampDao(graphImpl);
//load the schemas
OxmModelLoader.loadModels();
diff --git a/src/main/resources/logging/CrudServiceMsgs.properties b/src/main/resources/logging/CrudServiceMsgs.properties
index 850574f..13554e5 100644
--- a/src/main/resources/logging/CrudServiceMsgs.properties
+++ b/src/main/resources/logging/CrudServiceMsgs.properties
@@ -42,22 +42,10 @@ INVALID_OXM_DIR=\
CRD0005I|\
Invalid OXM dir: {0}\
-INSTANTIATE_GRAPH_DAO=\
- CRD0006I|\
- Instantiate data access layer for graph data store type: {0} graph: {1} using hosts: {2}
-
LOADED_OXM_FILE=\
CRD0007I|\
Successfully loaded schema: {0}
-INVALID_GRAPH_BACKEND=\
- CRD0301E|\
- Unsupported graph database {0} specified.
-
-INSTANTIATE_GRAPH_BACKEND_ERR=\
- CRD0302E|\
- Failure instantiating {0} graph database backend. Cause: {1}
-
EXCEPTION_DURING_METHOD_CALL=\
CRD0502E|\
Failed to {0} request for {1} due to: {2}|\
@@ -67,9 +55,3 @@ EXCEPTION_DURING_METHOD_CALL=\
OXM_LOAD_ERROR=\
CRD0503E|\
Unable to load OXM schema: {0}
-
-
-TITAN_GRAPH_INFO=\
- CRD0504I|\
- Titan Graph Info: {0}
- \ No newline at end of file
diff --git a/src/test/java/org/openecomp/crud/dao/champ/ChampDaoTest.java b/src/test/java/org/openecomp/crud/dao/champ/ChampDaoTest.java
index b11e274..a895066 100644
--- a/src/test/java/org/openecomp/crud/dao/champ/ChampDaoTest.java
+++ b/src/test/java/org/openecomp/crud/dao/champ/ChampDaoTest.java
@@ -35,10 +35,10 @@ public class ChampDaoTest {
// Create an instance of the Champ DAO, backed by the Champ library's in-memory back end
// for testing purposes.
- Properties champDaoProperties = new Properties();
+ Map<String, Object> champDaoProperties = new HashMap<String, Object>();
champDaoProperties.put(ChampDao.CONFIG_STORAGE_BACKEND, "in-memory");
champDaoProperties.put(ChampDao.CONFIG_GRAPH_NAME, GRAPH_NAME);
- champDao = new ChampDao(champDaoProperties);
+ champDao = new ChampDao(new InMemoryChampGraphImpl.Builder().properties(champDaoProperties).build());
}
diff --git a/titan-deps-pom.xml b/titan-deps-pom.xml
new file mode 100644
index 0000000..869c9a1
--- /dev/null
+++ b/titan-deps-pom.xml
@@ -0,0 +1,89 @@
+<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>
+ <groupId>com.test</groupId>
+ <artifactId>mytitan</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <dependencies>
+
+
+ <dependency>
+ <groupId>org.openecomp.aai</groupId>
+ <artifactId>champ-titan</artifactId>
+ <version>1.1.1-AMDOCS-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>com.thinkaurelius.titan</groupId>
+ <artifactId>titan-cassandra</artifactId>
+ <version>1.0.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>gremlin-groovy</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>gremlin-core</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>com.thinkaurelius.titan</groupId>
+ <artifactId>titan-hbase</artifactId>
+ <version>1.0.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>gremlin-groovy</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>gremlin-core</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>3.0.1</version>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.directory}/graph-deps/titan-deps</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>false</overWriteSnapshots>
+ <overWriteIfNewer>true</overWriteIfNewer>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project> \ No newline at end of file