--- /dev/null
+/**
+ * ============LICENSE_START==========================================
+ * org.onap.aai
+ * ===================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 Amdocs
+ * ===================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ */
+package org.onap.aai.champcore;
+
+import com.att.eelf.i18n.EELFResourceManager;
+import org.onap.aai.cl.eelf.LogMessageEnum;
+
+public enum ChampCoreMsgs implements LogMessageEnum {
+
+ CHAMPCORE_ABSTRACT_LOGGING_CHAMP_GRAPH_INFO,
+ CHAMPCORE_ABSTRACT_LOGGING_CHAMP_GRAPH_ERROR,
+ CHAMPCORE_ABSTRACT_LOGGING_CHAMP_GRAPH_WARN,
+
+ CHAMPCORE_ABSTRACT_TINKERPOP_CHAMP_GRAPH_INFO,
+ CHAMPCORE_ABSTRACT_TINKERPOP_CHAMP_GRAPH_ERROR,
+ CHAMPCORE_ABSTRACT_TINKERPOP_CHAMP_GRAPH_WARN,
+
+ CHAMPCORE_CHAMP_API_IMPL_INFO,
+ CHAMPCORE_CHAMP_API_IMPL_ERROR,
+ CHAMPCORE_CHAMP_API_IMPL_WARN,
+
+ CHAMPCORE_TINKERPOP_TRANSACTION_INFO,
+ CHAMPCORE_TINKERPOP_TRANSACTION_ERROR,
+ CHAMPCORE_TINKERPOP_TRANSACTION_WARN,
+
+ CHAMPCORE_GRAPH_ML_IMPORTER_EXPORTER_INFO,
+ CHAMPCORE_GRAPH_ML_IMPORTER_EXPORTER_ERROR,
+ CHAMPCORE_GRAPH_ML_IMPORTER_EXPORTER_WARN,
+
+ CHAMPCORE_FORMATTER_INFO,
+ CHAMPCORE_FORMATTER_ERROR,
+ CHAMPCORE_FORMATTER_WARN;
+
+
+
+ /**
+ * Static initializer to ensure the resource bundles for this class are loaded...
+ */
+ static {
+ EELFResourceManager.loadMessageBundle("logging/ChampCoreMsgs");
+ }
+}
import java.util.Optional;
import java.util.stream.Stream;
+import org.onap.aai.champcore.ie.GraphMLImporterExporter;
+import org.onap.aai.cl.api.Logger;
+import org.onap.aai.cl.eelf.LoggerFactory;
+
public class Formatter {
- private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(Formatter.class);
+ private static final Logger LOGGER = LoggerFactory.getInstance().getLogger(Formatter.class);
protected JsonParser parser = new JsonParser();
protected final FormatMapper format;
try {
return Optional.of(this.format.formatObject(v));
} catch (Exception var3) {
- LOGGER.warn("Failed to format vertex, returning a partial list", var3);
+ LOGGER.warn(ChampCoreMsgs.CHAMPCORE_FORMATTER_WARN,
+ "Failed to format vertex, returning a partial list " + var3);
return Optional.empty();
}
}).forEach((obj) -> {
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Stream;
+
import org.onap.aai.champcore.ChampCapabilities;
+import org.onap.aai.champcore.ChampCoreMsgs;
import org.onap.aai.champcore.ChampGraph;
import org.onap.aai.champcore.ChampTransaction;
import org.onap.aai.champcore.event.ChampEvent.ChampOperation;
import org.onap.aai.champcore.model.ChampRelationshipConstraint;
import org.onap.aai.champcore.model.ChampRelationshipIndex;
import org.onap.aai.champcore.model.ChampSchema;
+import org.onap.aai.cl.api.Logger;
+import org.onap.aai.cl.eelf.LoggerFactory;
import org.onap.aai.event.api.EventPublisher;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
/** Number of event publisher worker threads. */
private Integer eventStreamPublisherPoolSize;
- private static final Logger logger = LoggerFactory.getLogger(AbstractLoggingChampGraph.class);
+ private static final Logger logger = LoggerFactory.getInstance().getLogger(AbstractLoggingChampGraph.class);
/**
// Make sure we were passed an event producer as one of our properties, otherwise
// there is really nothing more we can do...
if(producer == null) {
- logger.error("No event stream producer was supplied.");
- logger.error("NOTE!! Champ events will NOT be published to the event stream!");
+ logger.error(ChampCoreMsgs.CHAMPCORE_ABSTRACT_LOGGING_CHAMP_GRAPH_ERROR,
+ "No event stream producer was supplied.");
+ logger.error(ChampCoreMsgs.CHAMPCORE_ABSTRACT_LOGGING_CHAMP_GRAPH_ERROR,
+ "NOTE!! Champ events will NOT be published to the event stream!");
return;
}
} catch (Exception e) {
- logger.error("Failed to instantiate event stream producer thread due to: '" + e.getMessage() + "'");
- logger.error("NOTE!! Champ events may NOT be published to the event stream!");
+ logger.error(ChampCoreMsgs.CHAMPCORE_ABSTRACT_LOGGING_CHAMP_GRAPH_ERROR,
+ "Failed to instantiate event stream producer thread due to: '" + e.getMessage() + "'");
+ logger.error(ChampCoreMsgs.CHAMPCORE_ABSTRACT_LOGGING_CHAMP_GRAPH_ERROR,
+ "NOTE!! Champ events may NOT be published to the event stream!");
return;
}
}
try {
publisherPool.awaitTermination(1000, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
- logger.warn("Termination interrupted");
+ logger.warn(ChampCoreMsgs.CHAMPCORE_ABSTRACT_LOGGING_CHAMP_GRAPH_WARN,
+ "Termination interrupted");
Thread.currentThread().interrupt();
}
}
producer.close();
} catch (Exception e) {
- logger.error("Failed to stop event stream producer: " + e.getMessage());
+ logger.error(ChampCoreMsgs.CHAMPCORE_ABSTRACT_LOGGING_CHAMP_GRAPH_ERROR,
+ "Failed to stop event stream producer: " + e.getMessage());
}
}
}
} catch (ChampTransactionException e) {
- logger.warn("Events associated with transaction " + transaction.id() + " not generated due to transaction commit failure.");
+ logger.warn(ChampCoreMsgs.CHAMPCORE_ABSTRACT_LOGGING_CHAMP_GRAPH_WARN,
+ "Events associated with transaction " + transaction.id() + " not generated due to transaction commit failure.");
List<ChampEvent> enqueuedEvents = transaction.getEnqueuedEvents();
for(ChampEvent event : enqueuedEvents) {
objectToDelete = retrieveObject(key, transaction);
} catch (ChampUnmarshallingException e) {
- logger.error("Unable to generate delete object log: " + e.getMessage());
+ logger.error(ChampCoreMsgs.CHAMPCORE_ABSTRACT_LOGGING_CHAMP_GRAPH_ERROR,
+ "Unable to generate delete object log: " + e.getMessage());
}
executeDeleteObject(key, transaction);
return;
}
- logger.info("Log champcore event with transaction id: " + anEvent.getTransactionId() + " to event bus");
+ logger.info(ChampCoreMsgs.CHAMPCORE_ABSTRACT_LOGGING_CHAMP_GRAPH_INFO,
+ "Log champcore event with transaction id: " + anEvent.getTransactionId() + " to event bus");
if(logger.isDebugEnabled()) {
logger.debug("Event payload: " + anEvent.toString());
}
// Try to submit the event to be published to the event bus.
if(!eventQueue.offer(anEvent)) {
- logger.error("Event could not be published to the event bus due to: Internal buffer capacity exceeded.");
+ logger.error(ChampCoreMsgs.CHAMPCORE_ABSTRACT_LOGGING_CHAMP_GRAPH_ERROR,
+ "Event could not be published to the event bus due to: Internal buffer capacity exceeded.");
}
}
} catch (Exception e) {
- logger.error("Failed to publish event to event bus: " + e.getMessage());
+ logger.error(ChampCoreMsgs.CHAMPCORE_ABSTRACT_LOGGING_CHAMP_GRAPH_ERROR,
+ "Failed to publish event to event bus: " + e.getMessage());
}
}
}
import java.util.Set;
import java.util.Spliterator;
import java.util.Spliterators;
-import java.util.Vector;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import org.apache.tinkerpop.gremlin.structure.Property;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.onap.aai.champcore.ChampCoreMsgs;
import org.onap.aai.champcore.ChampTransaction;
-import org.onap.aai.champcore.NoOpTinkerPopTransaction;
import org.onap.aai.champcore.exceptions.ChampMarshallingException;
import org.onap.aai.champcore.exceptions.ChampObjectNotExistsException;
import org.onap.aai.champcore.exceptions.ChampRelationshipNotExistsException;
import org.onap.aai.champcore.model.ChampSchema;
import org.onap.aai.champcore.model.fluent.partition.CreateChampPartitionable;
import org.onap.aai.champcore.transform.TinkerpopChampformer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.onap.aai.cl.api.Logger;
+import org.onap.aai.cl.eelf.LoggerFactory;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
public abstract class AbstractTinkerpopChampGraph extends AbstractValidatingChampGraph {
- private static final Logger LOGGER = LoggerFactory.getLogger(AbstractTinkerpopChampGraph.class);
+ private static final Logger LOGGER = LoggerFactory.getInstance().getLogger(AbstractTinkerpopChampGraph.class);
private static final TinkerpopChampformer TINKERPOP_CHAMPFORMER = new TinkerpopChampformer();
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
return Stream.empty();
}
} catch (ChampUnmarshallingException e) {
- LOGGER.warn("Failed to unmarshall object", e);
+ LOGGER.warn(ChampCoreMsgs.CHAMPCORE_ABSTRACT_TINKERPOP_CHAMP_GRAPH_WARN,
+ "Failed to unmarshall object. " + e.getMessage());
return Stream.empty();
}
}
next = getChampformer().unmarshallObject(query.next());
return true;
} catch (ChampUnmarshallingException e) {
- LOGGER.warn("Failed to unmarshall tinkerpop vertex during query, returning partial results", e);
+ LOGGER.warn(ChampCoreMsgs.CHAMPCORE_ABSTRACT_TINKERPOP_CHAMP_GRAPH_WARN,
+ "Failed to unmarshall tinkerpop vertex during query, returning partial results" + e.getMessage());
}
}
tx.commit(); //Danger ahead if this iterator is not completely consumed
//then the transaction cache will hold stale values
} catch (ChampTransactionException e) {
- LOGGER.warn("Failed transaction commit due to: " + e.getMessage());
+ LOGGER.warn(ChampCoreMsgs.CHAMPCORE_ABSTRACT_TINKERPOP_CHAMP_GRAPH_WARN,
+ "Failed transaction commit due to: " + e.getMessage());
}
}
next = getChampformer().unmarshallRelationship(edges.next());
return true;
} catch (ChampUnmarshallingException e) {
- LOGGER.warn("Failed to unmarshall tinkerpop edge during query, returning partial results", e);
+ LOGGER.warn(ChampCoreMsgs.CHAMPCORE_ABSTRACT_TINKERPOP_CHAMP_GRAPH_WARN,
+ "Failed to unmarshall tinkerpop edge during query, returning partial results" + e.getMessage());
}
}
//consumed, then the transaction cache will be stale
} catch (ChampTransactionException e) {
- LOGGER.warn("Failed transaction commit due to: " + e.getMessage());
+ LOGGER.warn(ChampCoreMsgs.CHAMPCORE_ABSTRACT_TINKERPOP_CHAMP_GRAPH_WARN,
+ "Failed transaction commit due to: " + e.getMessage());
}
}
}
} catch (ChampUnmarshallingException e) {
- LOGGER.warn("Failed to unmarshall relationship", e);
+ LOGGER.warn(ChampCoreMsgs.CHAMPCORE_ABSTRACT_TINKERPOP_CHAMP_GRAPH_WARN,
+ "Failed to unmarshall relationship" + e.getMessage());
return Stream.empty();
}
}
next = getChampformer().unmarshallRelationship(query.next());
return true;
} catch (ChampUnmarshallingException e) {
- LOGGER.warn("Failed to unmarshall tinkerpop vertex during query, returning partial results", e);
+ LOGGER.warn(ChampCoreMsgs.CHAMPCORE_ABSTRACT_TINKERPOP_CHAMP_GRAPH_WARN,
+ "Failed to unmarshall tinkerpop vertex during query, returning partial results" + e.getMessage());
}
}
//consumed, then the transaction cache will be stale
} catch (ChampTransactionException e) {
- LOGGER.warn("Failed transaction commit due to " + e.getMessage());
+ LOGGER.warn(ChampCoreMsgs.CHAMPCORE_ABSTRACT_TINKERPOP_CHAMP_GRAPH_WARN,
+ "Failed transaction commit due to " + e.getMessage());
}
}
try {
getGraph().close();
} catch (Throwable t) {
- LOGGER.error("Exception while shutting down graph", t);
+ LOGGER.error(ChampCoreMsgs.CHAMPCORE_ABSTRACT_TINKERPOP_CHAMP_GRAPH_ERROR,
+ "Exception while shutting down graph" + t.getMessage());
}
} else {
throw new IllegalStateException("Cannot call shutdown() after shutdown() was already initiated");
import java.util.concurrent.atomic.AtomicBoolean;
import org.onap.aai.champcore.ChampAPI;
+import org.onap.aai.champcore.ChampCoreMsgs;
import org.onap.aai.champcore.ChampGraph;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.onap.aai.cl.api.Logger;
+import org.onap.aai.cl.eelf.LoggerFactory;
+
public class ChampAPIImpl implements ChampAPI {
- private static final Logger LOGGER = LoggerFactory.getLogger(ChampAPIImpl.class);
+ private static final Logger LOGGER = LoggerFactory.getInstance().getLogger(ChampAPIImpl.class);
private final AtomicBoolean shutdown;
private final String type;
public void shutdown() {
if (shutdown.compareAndSet(false, true)) {
for (Entry<String, ChampGraph> graphEntry : graphs.entrySet()) {
- LOGGER.info("Shutting down graph {}", graphEntry.getKey());
+ LOGGER.info(ChampCoreMsgs.CHAMPCORE_CHAMP_API_IMPL_INFO,
+ String.format("Shutting down graph %s", graphEntry.getKey()));
try {
graphEntry.getValue().shutdown();
- LOGGER.info("Graph {} shutdown successfully", graphEntry.getKey());
+ LOGGER.info(ChampCoreMsgs.CHAMPCORE_CHAMP_API_IMPL_INFO,
+ String.format("Graph %s shutdown successfully", graphEntry.getKey()));
} catch (Throwable t) {
- LOGGER.warn("Caught exception while shutting down graph " + graphEntry.getKey(), t);
+ LOGGER.warn(ChampCoreMsgs.CHAMPCORE_CHAMP_API_IMPL_WARN,
+ String.format("Caught exception while shutting down graph %s: %s", graphEntry.getKey(), t.getMessage()));
}
}
}
* ============LICENSE_START==========================================
* org.onap.aai
* ===================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 Amdocs
+ * Modifications Copyright (C) 2019 IBM
* ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
super(builder.graphConfiguration);
this.graph = TinkerGraph.open();
- this.objectIndices = new ConcurrentHashMap<String, ChampObjectIndex> ();
- this.relationshipIndices = new ConcurrentHashMap<String, ChampRelationshipIndex> ();
+ this.objectIndices = new ConcurrentHashMap<>();
+ this.relationshipIndices = new ConcurrentHashMap<>();
this.schemaEnforcer = builder.schemaEnforcer;
}
package org.onap.aai.champcore.graph.impl;
import java.security.SecureRandom;
+
import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.onap.aai.champcore.ChampCoreMsgs;
import org.onap.aai.champcore.ChampTransaction;
import org.onap.aai.champcore.exceptions.ChampTransactionException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.onap.aai.cl.api.Logger;
+import org.onap.aai.cl.eelf.LoggerFactory;
public class TinkerpopTransaction extends ChampTransaction {
protected Graph threadedTransaction;
- private static final Logger LOGGER = LoggerFactory.getLogger(TinkerpopTransaction.class);
+ private static final Logger LOGGER = LoggerFactory.getInstance().getLogger(TinkerpopTransaction.class);
protected TinkerpopTransaction() { }
// Request a threaded transaction object from the graph.
this.threadedTransaction = aGraphInstance.tx().createThreadedTx();
- LOGGER.info("Open transaction - id: " + id);
+ LOGGER.info(ChampCoreMsgs.CHAMPCORE_TINKERPOP_TRANSACTION_INFO,
+ "Open transaction - id: " + id);
}
@Override
// Do the commit.
threadedTransaction.tx().commit();
- LOGGER.info("Committed transaction - id: " + id);
+ LOGGER.info(ChampCoreMsgs.CHAMPCORE_TINKERPOP_TRANSACTION_INFO,
+ "Committed transaction - id: " + id);
return;
} catch (Throwable e) {
// Have we used up all of our retries?
if (i == COMMIT_RETRY_COUNT - 1) {
- LOGGER.error("Maxed out commit attempt retries, client must handle exception and retry", e);
+ LOGGER.error(ChampCoreMsgs.CHAMPCORE_TINKERPOP_TRANSACTION_ERROR,
+ "Maxed out commit attempt retries, client must handle exception and retry. " + e.getMessage());
threadedTransaction.tx().rollback();
throw new ChampTransactionException(e);
}
// Calculate how long we will wait before retrying...
final long backoff = (long) Math.pow(2, i) * initialBackoff;
- LOGGER.warn("Caught exception while retrying transaction commit, retrying in " + backoff + " ms");
+ LOGGER.warn(ChampCoreMsgs.CHAMPCORE_TINKERPOP_TRANSACTION_WARN,
+ "Caught exception while retrying transaction commit, retrying in " + backoff + " ms");
// ...and sleep before trying the commit again.
try {
} catch (InterruptedException ie) {
- LOGGER.info("Interrupted while backing off on transaction commit");
+ LOGGER.info(ChampCoreMsgs.CHAMPCORE_TINKERPOP_TRANSACTION_INFO,
+ "Interrupted while backing off on transaction commit");
Thread.currentThread().interrupt();
return;
}
try {
threadedTransaction.tx().rollback();
- LOGGER.info("Rolled back transaction - id: " + id);
+ LOGGER.info(ChampCoreMsgs.CHAMPCORE_TINKERPOP_TRANSACTION_INFO,
+ "Rolled back transaction - id: " + id);
return;
} catch (Throwable e) {
// Have we used up all of our retries?
if (i == COMMIT_RETRY_COUNT - 1) {
- LOGGER.error("Maxed out rollback attempt retries, client must handle exception and retry", e);
+ LOGGER.error(ChampCoreMsgs.CHAMPCORE_TINKERPOP_TRANSACTION_ERROR,
+ "Maxed out rollback attempt retries, client must handle exception and retry. " + e.getMessage());
throw new ChampTransactionException(e);
}
// Calculate how long we will wait before retrying...
final long backoff = (long) Math.pow(2, i) * initialBackoff;
- LOGGER.warn("Caught exception while retrying transaction roll back, retrying in " + backoff + " ms");
+ LOGGER.warn(ChampCoreMsgs.CHAMPCORE_TINKERPOP_TRANSACTION_WARN,
+ "Caught exception while retrying transaction roll back, retrying in " + backoff + " ms");
// ...and sleep before trying the commit again.
try {
} catch (InterruptedException ie) {
- LOGGER.info("Interrupted while backing off on transaction rollback");
+ LOGGER.info(ChampCoreMsgs.CHAMPCORE_TINKERPOP_TRANSACTION_INFO,
+ "Interrupted while backing off on transaction rollback");
Thread.currentThread().interrupt();
return;
}
import javax.xml.stream.XMLStreamWriter;
import org.onap.aai.champcore.ChampAPI;
+import org.onap.aai.champcore.ChampCoreMsgs;
import org.onap.aai.champcore.ChampGraph;
-import org.onap.aai.champcore.ChampTransaction;
import org.onap.aai.champcore.exceptions.ChampMarshallingException;
import org.onap.aai.champcore.exceptions.ChampObjectNotExistsException;
import org.onap.aai.champcore.exceptions.ChampRelationshipNotExistsException;
import org.onap.aai.champcore.model.ChampObject;
import org.onap.aai.champcore.model.ChampObjectIndex;
import org.onap.aai.champcore.model.ChampRelationship;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.onap.aai.cl.api.Logger;
+import org.onap.aai.cl.eelf.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
public class GraphMLImporterExporter implements Importer, Exporter {
- private static final Logger LOGGER = LoggerFactory.getLogger(GraphMLImporterExporter.class);
+ private static final Logger LOGGER = LoggerFactory.getInstance().getLogger(GraphMLImporterExporter.class);
private static class GraphMLKey {
private final String id;
} else if (elementType.equals("edge")) {
edgePropertyDefinitions.put(id, propertyDefinitions);
} else {
- LOGGER.warn("Unknown element type {}, skipping", elementType);
+ LOGGER.warn(ChampCoreMsgs.CHAMPCORE_GRAPH_ML_IMPORTER_EXPORTER_WARN,
+ String.format("Unknown element type %s, skipping", elementType));
}
}
} else if (nodeOrEdge.getNodeName().equals("edge")) {
writeEdge(api.getGraph(graphName), nodeOrEdge, edgePropertyDefinitions, edgeDefaults);
} else {
- LOGGER.warn("Unknown object {} found in graphML, skipping", nodeOrEdge.getNodeName());
+ LOGGER.warn(ChampCoreMsgs.CHAMPCORE_GRAPH_ML_IMPORTER_EXPORTER_WARN,
+ String.format("Unknown object %s found in graphML, skipping", nodeOrEdge.getNodeName()));
}
}
}
} else targetObject = target.get();
} catch (ChampMarshallingException e) {
- LOGGER.error("Failed to marshall object to backend type, skipping this edge", e);
+ LOGGER.error(ChampCoreMsgs.CHAMPCORE_GRAPH_ML_IMPORTER_EXPORTER_ERROR,
+ "Failed to marshall object to backend type, skipping this edge. " + e.getMessage());
return;
} catch (ChampSchemaViolationException e) {
- LOGGER.error("Source/target object violates schema constraint(s)", e);
+ LOGGER.error(ChampCoreMsgs.CHAMPCORE_GRAPH_ML_IMPORTER_EXPORTER_ERROR,
+ "Source/target object violates schema constraint(s). " + e.getMessage());
return;
} catch (ChampObjectNotExistsException e) {
- LOGGER.error("Failed to update existing source/target ChampObject", e);
+ LOGGER.error(ChampCoreMsgs.CHAMPCORE_GRAPH_ML_IMPORTER_EXPORTER_ERROR,
+ "Failed to update existing source/target ChampObject. " + e.getMessage());
return;
} catch (ChampTransactionException e) {
- LOGGER.error("Failed to commit or rollback transaction", e);
+ LOGGER.error(ChampCoreMsgs.CHAMPCORE_GRAPH_ML_IMPORTER_EXPORTER_ERROR,
+ "Failed to commit or rollback transaction. " + e.getMessage());
}
final ChampRelationship.Builder champRelBuilder = new ChampRelationship.Builder(sourceObject, targetObject, "undefined");
try {
graph.storeRelationship(relToStore, Optional.empty());
} catch (ChampMarshallingException e) {
- LOGGER.warn("Failed to marshall ChampObject to backend type", e);
+ LOGGER.warn(ChampCoreMsgs.CHAMPCORE_GRAPH_ML_IMPORTER_EXPORTER_WARN,
+ "Failed to marshall ChampObject to backend type. " + e.getMessage());
} catch (ChampSchemaViolationException e) {
- LOGGER.error("Failed to store object (schema violated): " + relToStore, e);
+ LOGGER.error(ChampCoreMsgs.CHAMPCORE_GRAPH_ML_IMPORTER_EXPORTER_ERROR,
+ "Failed to store object (schema violated): " + relToStore + " " + e.getMessage());
} catch (ChampRelationshipNotExistsException e) {
- LOGGER.error("Failed to update existing ChampRelationship", e);
+ LOGGER.error(ChampCoreMsgs.CHAMPCORE_GRAPH_ML_IMPORTER_EXPORTER_ERROR,
+ "Failed to update existing ChampRelationship. " + e.getMessage());
} catch (ChampObjectNotExistsException e) {
- LOGGER.error("Objects bound to relationship do not exist (should never happen)");
+ LOGGER.error(ChampCoreMsgs.CHAMPCORE_GRAPH_ML_IMPORTER_EXPORTER_ERROR,
+ "Objects bound to relationship do not exist (should never happen)");
} catch (ChampUnmarshallingException e) {
- LOGGER.error("Failed to unmarshall ChampObject to backend type");
+ LOGGER.error(ChampCoreMsgs.CHAMPCORE_GRAPH_ML_IMPORTER_EXPORTER_ERROR,
+ "Failed to unmarshall ChampObject to backend type");
} catch (ChampTransactionException e) {
- LOGGER.error("Failed to commit or rollback transaction");
+ LOGGER.error(ChampCoreMsgs.CHAMPCORE_GRAPH_ML_IMPORTER_EXPORTER_ERROR,
+ "Failed to commit or rollback transaction");
}
}
try {
graph.storeObject(objectToStore, Optional.empty());
} catch (ChampMarshallingException e) {
- LOGGER.warn("Failed to marshall ChampObject to backend type", e);
+ LOGGER.warn(ChampCoreMsgs.CHAMPCORE_GRAPH_ML_IMPORTER_EXPORTER_WARN,
+ "Failed to marshall ChampObject to backend type. " + e.getMessage());
} catch (ChampSchemaViolationException e) {
- LOGGER.error("Failed to store object (schema violated): " + objectToStore, e);
+ LOGGER.error(ChampCoreMsgs.CHAMPCORE_GRAPH_ML_IMPORTER_EXPORTER_ERROR,
+ "Failed to store object (schema violated): " + objectToStore + " " + e.getMessage());
} catch (ChampObjectNotExistsException e) {
- LOGGER.error("Failed to update existing ChampObject", e);
+ LOGGER.error(ChampCoreMsgs.CHAMPCORE_GRAPH_ML_IMPORTER_EXPORTER_ERROR,
+ "Failed to update existing ChampObject. " + e.getMessage());
} catch (ChampTransactionException e) {
- LOGGER.error("Failed to commit or rollback transaction");
+ LOGGER.error(ChampCoreMsgs.CHAMPCORE_GRAPH_ML_IMPORTER_EXPORTER_ERROR,
+ "Failed to commit or rollback transaction");
}
}
--- /dev/null
+#Resource key=Error Code|Message text|Resolution text |Description text
+#######
+#Newlines can be utilized to add some clarity ensuring continuing line
+#has atleast one leading space
+#ResourceKey=\
+# ERR0000E\
+# Sample error msg txt\
+# Sample resolution msg\
+# Sample description txt
+#
+######
+#Error code classification category
+#000 Info/Debug
+#100 Permission errors
+#200 Availability errors/Timeouts
+#300 Data errors
+#400 Schema Interface type/validation errors
+#500 Business process errors
+#900 Unknown errors
+#
+########################################################################
+
+CHAMPCORE_ABSTRACT_LOGGING_CHAMP_GRAPH_INFO=\
+ CCE0011I|\
+ AbstractLoggingChampGraph: {0}
+CHAMPCORE_ABSTRACT_LOGGING_CHAMP_GRAPH_ERROR=\
+ CCE0511E|\
+ AbstractLoggingChampGraph Error: {0}
+CHAMPCORE_ABSTRACT_LOGGING_CHAMP_GRAPH_WARN=\
+ CCE0512E|\
+ AbstractLoggingChampGraph Warning: {0}
+
+
+CHAMPCORE_ABSTRACT_TINKERPOP_CHAMP_GRAPH_INFO=\
+ CCG0012I|\
+ AbstractTinkerpopChampGraph: {0}
+CHAMPCORE_ABSTRACT_TINKERPOP_CHAMP_GRAPH_ERROR=\
+ CCG0513E|\
+ AbstractTinkerpopChampGraph Error: {0}
+CHAMPCORE_ABSTRACT_TINKERPOP_CHAMP_GRAPH_WARN=\
+ CCG0514E|\
+ AbstractTinkerpopChampGraph Warning: {0}
+
+
+CHAMPCORE_CHAMP_API_IMPL_INFO=\
+ CCG0013I|\
+ ChampAPIImpl: {0}
+CHAMPCORE_CHAMP_API_IMPL_ERROR=\
+ CCG0515E|\
+ ChampAPIImpl Error: {0}
+CHAMPCORE_CHAMP_API_IMPL_WARN=\
+ CCG0516E|\
+ ChampAPIImpl Warning: {0}
+
+
+CHAMPCORE_TINKERPOP_TRANSACTION_INFO=\
+ CCG0014I|\
+ TinkerpopTransaction: {0}
+CHAMPCORE_TINKERPOP_TRANSACTION_ERROR=\
+ CCG0517E|\
+ TinkerpopTransaction Error: {0}
+CHAMPCORE_TINKERPOP_TRANSACTION_WARN=\
+ CCG0518E|\
+ TinkerpopTransaction Warning: {0}
+
+
+CHAMPCORE_GRAPH_ML_IMPORTER_EXPORTER_INFO=\
+ CCIE0015I|\
+ GraphMLImporterExporter: {0}
+CHAMPCORE_GRAPH_ML_IMPORTER_EXPORTER_ERROR=\
+ CCIE0519E|\
+ GraphMLImporterExporter Error: {0}
+CHAMPCORE_GRAPH_ML_IMPORTER_EXPORTER_WARN=\
+ CCIE0520E|\
+ GraphMLImporterExporter Warning: {0}
+
+
+CHAMPCORE_FORMATTER_INFO=\
+ CCIE0015I|\
+ Formatter: {0}
+CHAMPCORE_FORMATTER_ERROR=\
+ CCIE0519E|\
+ Formatter Error: {0}
+CHAMPCORE_FORMATTER_WARN=\
+ CCIE0520E|\
+ Formatter Warning: {0}
+
+
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
+
+import org.junit.Assert;
import org.junit.Test;
import org.onap.aai.champcore.event.ChampEvent;
import org.onap.aai.champcore.model.ChampObject;
import org.skyscreamer.jsonassert.JSONAssert;
import org.skyscreamer.jsonassert.JSONCompareMode;
import org.skyscreamer.jsonassert.comparator.CustomComparator;
+
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
new Customization("body.timestamp", (o1, o2) -> true),
new Customization("body.transaction-id", (o1, o2) -> true)));
}
+
+ @Test
+ public void testChampEventHeader() {
+ String link = "link1";
+ String requestId = "request-id1";
+ String entityType = "entity-type1";
+ String topEntityType = "top-entity-type1";
+
+ ChampEventHeader header1 = new ChampEventHeader.Builder(ChampEventHeader.EventType.UPDATE_NOTIFICATION)
+ .entityLink(link)
+ .requestId(requestId)
+ .validationEntityType(entityType)
+ .validationTopEntityType(topEntityType)
+ .build();
+
+ Assert.assertEquals(link, header1.getEntityLink());
+ Assert.assertEquals(requestId, header1.getRequestId());
+ Assert.assertEquals(entityType, header1.getValidationEntityType());
+ Assert.assertEquals(topEntityType, header1.getValidationTopEntityType());
+
+ ChampEventHeader header2 = new ChampEventHeader.Builder(ChampEventHeader.EventType.UPDATE_RESULT)
+ .entityLink("link2")
+ .requestId("request-id2")
+ .validationEntityType("entity-type2")
+ .validationTopEntityType("top-entity-type2")
+ .build();
+
+ Assert.assertNotEquals(header1, header2);
+
+
+ header2.setEntityLink(link);
+ header2.setRequestId(requestId);
+ header2.setValidationEntityType(entityType);
+ header2.setValidationTopEntityType(topEntityType);
+ header2.setEventType(header1.getEventType());
+ header2.setTimestamp(header1.getTimestamp());
+
+ Assert.assertEquals(header1, header2);
+
+ }
}
api.shutdown();
}
+
+ @Test
+ public void testUndefinedEdgeSourceAndTarget() throws ChampTransactionException, AssertionError {
+
+ final GraphMLImporterExporter importer = new GraphMLImporterExporter();
+ final ChampAPI api = ChampAPI.Factory.newInstance("IN_MEMORY");
+
+ importer.importData(api, getClass().getClassLoader().getResourceAsStream("import-test2.graphml"));
+
+ final ChampGraph graph = api.getGraph(GRAPH_NAME);
+
+ graph.queryObjects(Collections.emptyMap(), Optional.empty()).forEach(object -> {
+ final Optional<String> nameOpt = object.getProperty("name");
+ assertTrue(!nameOpt.isPresent());
+ });
+
+ api.shutdown();
+ }
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
+ <key id="d0" for="node" attr.name="student" attr.type="boolean"/>
+ <key id="d1" for="node" attr.name="worth" attr.type="long"/>
+ <key id="d2" for="node" attr.name="age" attr.type="int"/>
+ <key id="d3" for="node" attr.name="height" attr.type="float"/>
+ <key id="d4" for="node" attr.name="weight" attr.type="double"/>
+ <key id="d5" for="node" attr.name="favoriteColor" attr.type="string">
+ <default>green</default>
+ </key>
+ <key id="d6" for="node" attr.name="name" attr.type="string"/>
+ <key id="d7" for="edge" attr.name="at" attr.type="long"/>
+ <key id="d8" for="node" attr.name="type" attr.type="string"/>
+ <key id="d9" for="edge" attr.name="type" attr.type="string"/>
+ <key id="d10" for="test" attr.name="name" attr.type="string">
+ <default>abc</default>
+ </key>
+ <key id="d11" for="edge" attr.name="favoriteColor" attr.type="string">
+ <default>green</default>
+ </key>
+ <graph id="unit-test" edgedefault="directed">
+ <edge id="e0" source="n0" target="n2">
+ <data key="d7">12348234</data>
+ <data key="d9">Dog</data>
+ </edge>
+ <test id="test" />
+ </graph>
+</graphml>
\ No newline at end of file
--- /dev/null
+/**
+ * ============LICENSE_START==========================================
+ * org.onap.aai
+ * ===================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 Amdocs
+ * ===================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ */
+package org.onap.aai.champjanus.graph.impl;
+
+import com.att.eelf.i18n.EELFResourceManager;
+import org.onap.aai.cl.eelf.LogMessageEnum;
+
+public enum ChampJanusMsgs implements LogMessageEnum {
+
+ JANUS_CHAMP_GRAPH_IMPL_INFO,
+ JANUS_CHAMP_GRAPH_IMPL_ERROR,
+ JANUS_CHAMP_GRAPH_IMPL_WARN;
+
+
+
+ /**
+ * Static initializer to ensure the resource bundles for this class are loaded...
+ */
+ static {
+ EELFResourceManager.loadMessageBundle("logging/ChampJanusMsgs");
+ }
+}
* ===================================================================
* Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
* Copyright © 2017-2018 Amdocs
+ * Modifications Copyright (C) 2019 IBM
* ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
package org.onap.aai.champjanus.graph.impl;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-// import com.thinkaurelius.titan.graphdb.tinkerpop.TitanIoRegistry;
-import org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONWriter;
+import org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry;
import org.onap.aai.champcore.FormatMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
public class GraphSON implements FormatMapper {
+ private static final Logger LOGGER = LoggerFactory.getLogger(GraphSON.class);
private final GraphSONMapper mapper;
private final GraphSONWriter writer;
protected JsonParser parser;
public GraphSON() {
- this.mapper = GraphSONMapper.build().addRegistry(JanusGraphIoRegistry.getInstance ()).create();
+ this.mapper = GraphSONMapper.build().addRegistry(JanusGraphIoRegistry.getInstance()).create();
this.writer = GraphSONWriter.build().mapper(this.mapper).create();
this.parser = new JsonParser();
}
String result = "";
try {
- this.writer.writeVertex(os, (Vertex)v, Direction.BOTH);
+ this.writer.writeVertex(os, (Vertex) v, Direction.BOTH);
result = os.toString();
} catch (IOException var5) {
- var5.printStackTrace();
+ LOGGER.debug("Exception occured while formatting object : " + var5.getMessage());
}
return this.parser.parse(result).getAsJsonObject();
*/
package org.onap.aai.champjanus.graph.impl;
+import java.security.SecureRandom;
+import java.time.temporal.ChronoUnit;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Optional;
+import java.util.Spliterator;
+import java.util.Spliterators;
+import java.util.concurrent.ExecutionException;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
+
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.janusgraph.core.*;
+import org.janusgraph.core.Cardinality;
+import org.janusgraph.core.EdgeLabel;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphEdge;
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraphVertex;
+import org.janusgraph.core.PropertyKey;
+import org.janusgraph.core.SchemaViolationException;
import org.janusgraph.core.schema.JanusGraphIndex;
import org.janusgraph.core.schema.JanusGraphManagement;
import org.janusgraph.core.schema.JanusGraphManagement.IndexBuilder;
import org.onap.aai.champcore.exceptions.ChampIndexNotExistsException;
import org.onap.aai.champcore.exceptions.ChampSchemaViolationException;
import org.onap.aai.champcore.graph.impl.AbstractTinkerpopChampGraph;
-import org.onap.aai.champcore.model.*;
+import org.onap.aai.champcore.model.ChampCardinality;
+import org.onap.aai.champcore.model.ChampField;
+import org.onap.aai.champcore.model.ChampObject;
+import org.onap.aai.champcore.model.ChampObjectConstraint;
+import org.onap.aai.champcore.model.ChampObjectIndex;
+import org.onap.aai.champcore.model.ChampPropertyConstraint;
+import org.onap.aai.champcore.model.ChampRelationship;
+import org.onap.aai.champcore.model.ChampRelationshipConstraint;
+import org.onap.aai.champcore.model.ChampRelationshipIndex;
+import org.onap.aai.champcore.model.ChampSchema;
import org.onap.aai.champcore.schema.ChampSchemaEnforcer;
import org.onap.aai.champcore.schema.DefaultChampSchemaEnforcer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.security.SecureRandom;
-import java.time.temporal.ChronoUnit;
-import java.util.*;
-import java.util.concurrent.ExecutionException;
-import java.util.stream.Stream;
-import java.util.stream.StreamSupport;
+import org.onap.aai.cl.api.Logger;
+import org.onap.aai.cl.eelf.LoggerFactory;
public final class JanusChampGraphImpl extends AbstractTinkerpopChampGraph {
- private static final Logger LOGGER = LoggerFactory.getLogger(JanusChampGraphImpl.class);
+ private static final Logger LOGGER = LoggerFactory.getInstance().getLogger(JanusChampGraphImpl.class);
private static final String JANUS_CASSANDRA_KEYSPACE = "storage.cassandra.keyspace";
private static final String JANUS_CQL_KEYSPACE = "storage.cql.keyspace";
private static final String JANUS_HBASE_TABLE = "storage.hbase.table";
}
catch (Exception ex) {
// Swallow exception. Cassandra may not be reachable. Will retry next time we need to use the graph.
- LOGGER.error("Error opening graph: " + ex.getMessage());
+ LOGGER.error(ChampJanusMsgs.JANUS_CHAMP_GRAPH_IMPL_ERROR,
+ "Error opening graph: " + ex.getMessage());
return;
}
- LOGGER.info("Instantiated data access layer for Janus graph data store with backend: " + storageBackend);
+ LOGGER.info(ChampJanusMsgs.JANUS_CHAMP_GRAPH_IMPL_INFO,
+ "Instantiated data access layer for Janus graph data store with backend: " + storageBackend);
}
public static class Builder {
if (createIndexMgmt.getGraphIndex(index.getName()) != null) {
createIndexMgmt.rollback();
- LOGGER.info("Index " + index.getName() + " already exists");
+ LOGGER.info(ChampJanusMsgs.JANUS_CHAMP_GRAPH_IMPL_INFO,
+ "Index " + index.getName() + " already exists");
return; //Ignore, index already exists
}
- LOGGER.info("Create index " + index.getName());
+ LOGGER.info(ChampJanusMsgs.JANUS_CHAMP_GRAPH_IMPL_INFO,
+ "Create index " + index.getName());
IndexBuilder ib = createIndexMgmt.buildIndex(index.getName(), Vertex.class);
for (ChampField field : index.getFields()) {
PropertyKey pk = createIndexMgmt.getOrCreatePropertyKey(field.getName());
return; //Ignore, index already exists
}
- LOGGER.info("Create edge index " + index.getName());
+ LOGGER.info(ChampJanusMsgs.JANUS_CHAMP_GRAPH_IMPL_INFO,
+ "Create edge index " + index.getName());
createIndexMgmt.buildIndex(index.getName(), Edge.class).addKey(pk).buildCompositeIndex();
createIndexMgmt.commit();
.timeout(REGISTER_OBJECT_INDEX_TIMEOUT_SECS, ChronoUnit.SECONDS)
.call()
.getSucceeded()) {
- LOGGER.warn("Object index was created, but timed out while waiting for it to be registered");
+ LOGGER.warn(ChampJanusMsgs.JANUS_CHAMP_GRAPH_IMPL_WARN,
+ "Object index was created, but timed out while waiting for it to be registered");
return;
}
} catch (InterruptedException e) {
- LOGGER.warn("Interrupted while waiting for object index creation status");
+ LOGGER.warn(ChampJanusMsgs.JANUS_CHAMP_GRAPH_IMPL_WARN,
+ "Interrupted while waiting for object index creation status");
Thread.currentThread().interrupt();
return;
}
updateIndexMgmt.updateIndex(updateIndexMgmt.getGraphIndex(indexName), SchemaAction.REINDEX).get();
updateIndexMgmt.commit();
} catch (InterruptedException e) {
- LOGGER.warn("Interrupted while reindexing for object index");
+ LOGGER.warn(ChampJanusMsgs.JANUS_CHAMP_GRAPH_IMPL_WARN,
+ "Interrupted while reindexing for object index");
Thread.currentThread().interrupt();
return;
} catch (ExecutionException e) {
- LOGGER.warn("Exception occurred during reindexing procedure for creating object index " + indexName, e);
+ LOGGER.warn(ChampJanusMsgs.JANUS_CHAMP_GRAPH_IMPL_WARN,
+ "Exception occurred during reindexing procedure for creating object index " + indexName + ". " + e.getMessage());
}
try {
.timeout(2, ChronoUnit.MINUTES)
.call();
} catch (InterruptedException e) {
- LOGGER.warn("Interrupted while waiting for index to transition to ENABLED state");
+ LOGGER.warn(ChampJanusMsgs.JANUS_CHAMP_GRAPH_IMPL_WARN,
+ "Interrupted while waiting for index to transition to ENABLED state");
Thread.currentThread().interrupt();
return;
}
PropertyKey pk = createIndexMgmt.getOrCreatePropertyKey(KEY_PROPERTY_NAME);
if (!vertexIndexExists) {
- LOGGER.info("Create Index " + KEY_PROPERTY_NAME);
+ LOGGER.info(ChampJanusMsgs.JANUS_CHAMP_GRAPH_IMPL_INFO,
+ "Create Index " + KEY_PROPERTY_NAME);
createIndexMgmt.buildIndex(KEY_PROPERTY_NAME, Vertex.class).addKey(pk).buildCompositeIndex();
}
if (!edgeIndexExists) {
- LOGGER.info("Create Index " + EDGE_IX_NAME);
+ LOGGER.info(ChampJanusMsgs.JANUS_CHAMP_GRAPH_IMPL_INFO,
+ "Create Index " + EDGE_IX_NAME);
createIndexMgmt.buildIndex(EDGE_IX_NAME, Edge.class).addKey(pk).buildCompositeIndex();
}
createIndexMgmt.commit();
}
else {
createIndexMgmt.rollback();
- LOGGER.info("Index " + KEY_PROPERTY_NAME + " and " + EDGE_IX_NAME + " already exist");
+ LOGGER.info(ChampJanusMsgs.JANUS_CHAMP_GRAPH_IMPL_INFO,
+ "Index " + KEY_PROPERTY_NAME + " and " + EDGE_IX_NAME + " already exist");
}
if (!nodeTypeIndexExists) {
- LOGGER.info("Create Index " + NODE_TYPE_PROPERTY_NAME);
+ LOGGER.info(ChampJanusMsgs.JANUS_CHAMP_GRAPH_IMPL_INFO,
+ "Create Index " + NODE_TYPE_PROPERTY_NAME);
createIndexMgmt = graph.openManagement();
PropertyKey pk = createIndexMgmt.getOrCreatePropertyKey(NODE_TYPE_PROPERTY_NAME);
createIndexMgmt.buildIndex(NODE_TYPE_PROPERTY_NAME, Vertex.class).addKey(pk).buildCompositeIndex();
--- /dev/null
+#Resource key=Error Code|Message text|Resolution text |Description text
+#######
+#Newlines can be utilized to add some clarity ensuring continuing line
+#has atleast one leading space
+#ResourceKey=\
+# ERR0000E\
+# Sample error msg txt\
+# Sample resolution msg\
+# Sample description txt
+#
+######
+#Error code classification category
+#000 Info/Debug
+#100 Permission errors
+#200 Availability errors/Timeouts
+#300 Data errors
+#400 Schema Interface type/validation errors
+#500 Business process errors
+#900 Unknown errors
+#
+########################################################################
+
+JANUS_CHAMP_GRAPH_IMPL_INFO=\
+ CJ0011I|\
+ JanusChampGraphImpl: {0}
+JANUS_CHAMP_GRAPH_IMPL_ERROR=\
+ CJ0511E|\
+ JanusChampGraphImpl Error: {0}
+JANUS_CHAMP_GRAPH_IMPL_WARN=\
+ CJ0512E|\
+ JanusChampGraphImpl Warning: {0}
--- /dev/null
+/**
+ * ============LICENSE_START==========================================
+ * org.onap.aai
+ * ===================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 Amdocs
+ * ===================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ */
+package org.onap.aai.champtitan.graph.impl;
+
+import com.att.eelf.i18n.EELFResourceManager;
+import org.onap.aai.cl.eelf.LogMessageEnum;
+
+public enum ChampTitanMsgs implements LogMessageEnum {
+
+ TITAN_CHAMP_GRAPH_IMPL_INFO,
+ TITAN_CHAMP_GRAPH_IMPL_ERROR,
+ TITAN_CHAMP_GRAPH_IMPL_WARN;
+
+
+
+ /**
+ * Static initializer to ensure the resource bundles for this class are loaded...
+ */
+ static {
+ EELFResourceManager.loadMessageBundle("logging/ChampTitanMsgs");
+ }
+}
import java.security.SecureRandom;
import java.time.temporal.ChronoUnit;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import java.util.Map.Entry;
+import java.util.NoSuchElementException;
+import java.util.Optional;
+import java.util.Spliterator;
+import java.util.Spliterators;
import java.util.concurrent.ExecutionException;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import org.onap.aai.champcore.model.ChampSchema;
import org.onap.aai.champcore.schema.ChampSchemaEnforcer;
import org.onap.aai.champcore.schema.DefaultChampSchemaEnforcer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.onap.aai.cl.api.Logger;
+import org.onap.aai.cl.eelf.LoggerFactory;
import com.thinkaurelius.titan.core.Cardinality;
import com.thinkaurelius.titan.core.EdgeLabel;
public final class TitanChampGraphImpl extends AbstractTinkerpopChampGraph {
- private static final Logger LOGGER = LoggerFactory.getLogger(TitanChampGraphImpl.class);
+ private static final Logger LOGGER = LoggerFactory.getInstance().getLogger(TitanChampGraphImpl.class);
private static final String TITAN_UNIQUE_SUFFIX = "graph.unique-instance-id-suffix";
private static final String TITAN_CASSANDRA_KEYSPACE = "storage.cassandra.keyspace";
private static final String TITAN_HBASE_TABLE = "storage.hbase.table";
throw new RuntimeException("Unknown storage.backend=" + storageBackend);
}
- LOGGER.info("Instantiated data access layer for Titan graph data store with backend: " + storageBackend);
+ LOGGER.info(ChampTitanMsgs.TITAN_CHAMP_GRAPH_IMPL_INFO,
+ "Instantiated data access layer for Titan graph data store with backend: " + storageBackend);
this.graph = titanGraphBuilder.open();
}
.timeout(REGISTER_OBJECT_INDEX_TIMEOUT_SECS, ChronoUnit.SECONDS)
.call()
.getSucceeded()) {
- LOGGER.warn("Object index was created, but timed out while waiting for it to be registered");
+ LOGGER.warn(ChampTitanMsgs.TITAN_CHAMP_GRAPH_IMPL_WARN,
+ "Object index was created, but timed out while waiting for it to be registered");
return;
}
} catch (InterruptedException e) {
- LOGGER.warn("Interrupted while waiting for object index creation status");
+ LOGGER.warn(ChampTitanMsgs.TITAN_CHAMP_GRAPH_IMPL_WARN,
+ "Interrupted while waiting for object index creation status");
Thread.currentThread().interrupt();
return;
}
updateIndexMgmt.updateIndex(updateIndexMgmt.getGraphIndex(indexName),SchemaAction.REINDEX).get();
updateIndexMgmt.commit();
} catch (InterruptedException e) {
- LOGGER.warn("Interrupted while reindexing for object index");
+ LOGGER.warn(ChampTitanMsgs.TITAN_CHAMP_GRAPH_IMPL_WARN,
+ "Interrupted while reindexing for object index");
Thread.currentThread().interrupt();
return;
} catch (ExecutionException e) {
- LOGGER.warn("Exception occurred during reindexing procedure for creating object index " + indexName, e);
+ LOGGER.warn(ChampTitanMsgs.TITAN_CHAMP_GRAPH_IMPL_WARN,
+ "Exception occurred during reindexing procedure for creating object index " + indexName + ". " + e.getMessage());
}
try {
.timeout(10, ChronoUnit.MINUTES)
.call();
} catch (InterruptedException e) {
- LOGGER.warn("Interrupted while waiting for index to transition to ENABLED state");
+ LOGGER.warn(ChampTitanMsgs.TITAN_CHAMP_GRAPH_IMPL_WARN,
+ "Interrupted while waiting for index to transition to ENABLED state");
Thread.currentThread().interrupt();
return;
}
@Override
public void createDefaultIndexes() {
- LOGGER.error("No default indexes being created");
+ LOGGER.error(ChampTitanMsgs.TITAN_CHAMP_GRAPH_IMPL_ERROR,
+ "No default indexes being created");
}
}
--- /dev/null
+#Resource key=Error Code|Message text|Resolution text |Description text
+#######
+#Newlines can be utilized to add some clarity ensuring continuing line
+#has atleast one leading space
+#ResourceKey=\
+# ERR0000E\
+# Sample error msg txt\
+# Sample resolution msg\
+# Sample description txt
+#
+######
+#Error code classification category
+#000 Info/Debug
+#100 Permission errors
+#200 Availability errors/Timeouts
+#300 Data errors
+#400 Schema Interface type/validation errors
+#500 Business process errors
+#900 Unknown errors
+#
+########################################################################
+
+TITAN_CHAMP_GRAPH_IMPL_INFO=\
+ CT0011I|\
+ TitanChampGraphImpl: {0}
+TITAN_CHAMP_GRAPH_IMPL_ERROR=\
+ CT0511E|\
+ TitanChampGraphImpl Error: {0}
+TITAN_CHAMP_GRAPH_IMPL_WARN=\
+ CT0512E|\
+ TitanChampGraphImpl Warning: {0}
import java.util.HashMap;
import java.util.Map;
+
import javax.annotation.PostConstruct;
+
import org.eclipse.jetty.util.security.Password;
+import org.onap.champ.service.logging.LoggingUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
private Environment env;
public static void main(String[] args) {
+ LoggingUtil.initMdcContext();
+
String keyStorePassword = System.getProperty("KEY_STORE_PASSWORD");
if (keyStorePassword == null || keyStorePassword.isEmpty()) {
throw new RuntimeException("Environment property KEY_STORE_PASSWORD not set");
* Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
* Copyright © 2017-2018 Amdocs
* ================================================================================
+ * Modifications Copyright (C) 2019 IBM.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
public class ChampBulkPayload {
- public static String ADD_OP = "add";
- public static String UPDATE_OP = "modify";
- public static String DELETE_OP = "delete";
- public static String PATCH_OP = "patch";
+ public static final String ADD_OP = "add";
+ public static final String UPDATE_OP = "modify";
+ public static final String DELETE_OP = "delete";
+ public static final String PATCH_OP = "patch";
private List<ChampBulkOp> edgeDeleteOps = new ArrayList<ChampBulkOp>();
private List<ChampBulkOp> vertexDeleteOps = new ArrayList<ChampBulkOp>();
* Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
* Copyright © 2017-2018 Amdocs
* ===================================================================
+ * Modifications Copyright (C) 2019 IBM.
+ * ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
graphImpl.rollbackTransaction((ChampTransaction) notification.getValue());
logger.info(ChampMsgs.CHAMP_TX_CACHE, "Transaction rolledback successfully :" + notification.getKey());
} catch (ChampTransactionException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ logger.error(ChampMsgs.CHAMP_DATA_SERVICE_ERROR, e, "Transaction rolledback failed :");
}
}
}
MdcContext.initialize(transId, "ChampService", "", fromAppId, fromIp);
}
+
+ public static void initMdcContext() {
+ MdcContext.initialize("", "ChampService", "", "", "");
+ }
/**
* Logs the rest request.
* Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
* Copyright © 2017-2018 Amdocs
* ===================================================================
+ * Modifications Copyright (C) 2019 IBM.
+ * ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
+import org.onap.aai.cl.api.Logger;
+import org.onap.aai.cl.eelf.LoggerFactory;
+import org.onap.champ.service.logging.ChampMsgs;
public class ChampProperties {
+
+ private static Logger logger = LoggerFactory.getInstance().getLogger(ChampProperties.class.getName());
private static Properties properties;
) {
properties.load(fileInputStream);
} catch (IOException e) {
- e.printStackTrace();
+ logger.error(ChampMsgs.CHAMP_DATA_SERVICE_ERROR, "Error while loading properties ", e.getMessage());
Runtime.getRuntime().halt(1);
}
}
) {
properties.store(fileOut, "Added property: " + key);
} catch (Exception e) {
- e.printStackTrace();
+ logger.error(ChampMsgs.CHAMP_DATA_SERVICE_ERROR, "Error while setting properties ", e.getMessage());
}
}