aboutsummaryrefslogtreecommitdiffstats
path: root/champ-lib/champ-core/src/main/java/org/onap/aai/champcore
diff options
context:
space:
mode:
Diffstat (limited to 'champ-lib/champ-core/src/main/java/org/onap/aai/champcore')
-rw-r--r--champ-lib/champ-core/src/main/java/org/onap/aai/champcore/ChampCoreMsgs.java60
-rw-r--r--champ-lib/champ-core/src/main/java/org/onap/aai/champcore/Formatter.java9
-rw-r--r--champ-lib/champ-core/src/main/java/org/onap/aai/champcore/event/AbstractLoggingChampGraph.java42
-rw-r--r--champ-lib/champ-core/src/main/java/org/onap/aai/champcore/graph/impl/AbstractTinkerpopChampGraph.java36
-rw-r--r--champ-lib/champ-core/src/main/java/org/onap/aai/champcore/graph/impl/ChampAPIImpl.java17
-rw-r--r--champ-lib/champ-core/src/main/java/org/onap/aai/champcore/graph/impl/TinkerpopTransaction.java35
-rw-r--r--champ-lib/champ-core/src/main/java/org/onap/aai/champcore/ie/GraphMLImporterExporter.java56
7 files changed, 187 insertions, 68 deletions
diff --git a/champ-lib/champ-core/src/main/java/org/onap/aai/champcore/ChampCoreMsgs.java b/champ-lib/champ-core/src/main/java/org/onap/aai/champcore/ChampCoreMsgs.java
new file mode 100644
index 0000000..3e9bd71
--- /dev/null
+++ b/champ-lib/champ-core/src/main/java/org/onap/aai/champcore/ChampCoreMsgs.java
@@ -0,0 +1,60 @@
+/**
+ * ============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");
+ }
+}
diff --git a/champ-lib/champ-core/src/main/java/org/onap/aai/champcore/Formatter.java b/champ-lib/champ-core/src/main/java/org/onap/aai/champcore/Formatter.java
index e85b672..dfb6143 100644
--- a/champ-lib/champ-core/src/main/java/org/onap/aai/champcore/Formatter.java
+++ b/champ-lib/champ-core/src/main/java/org/onap/aai/champcore/Formatter.java
@@ -30,9 +30,13 @@ import java.util.List;
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;
@@ -55,7 +59,8 @@ public class Formatter {
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) -> {
diff --git a/champ-lib/champ-core/src/main/java/org/onap/aai/champcore/event/AbstractLoggingChampGraph.java b/champ-lib/champ-core/src/main/java/org/onap/aai/champcore/event/AbstractLoggingChampGraph.java
index 6530b98..1ecf71b 100644
--- a/champ-lib/champ-core/src/main/java/org/onap/aai/champcore/event/AbstractLoggingChampGraph.java
+++ b/champ-lib/champ-core/src/main/java/org/onap/aai/champcore/event/AbstractLoggingChampGraph.java
@@ -32,7 +32,9 @@ import java.util.concurrent.ThreadPoolExecutor;
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;
@@ -52,9 +54,10 @@ 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.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;
+
@@ -89,7 +92,7 @@ public abstract class AbstractLoggingChampGraph implements ChampGraph {
/** 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);
/**
@@ -105,8 +108,10 @@ public abstract class AbstractLoggingChampGraph implements ChampGraph {
// 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;
}
@@ -128,8 +133,10 @@ public abstract class AbstractLoggingChampGraph implements ChampGraph {
} 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;
}
}
@@ -395,7 +402,8 @@ public abstract class AbstractLoggingChampGraph implements ChampGraph {
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();
}
}
@@ -406,7 +414,8 @@ public abstract class AbstractLoggingChampGraph implements ChampGraph {
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());
}
}
}
@@ -421,7 +430,8 @@ public abstract class AbstractLoggingChampGraph implements ChampGraph {
} 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) {
@@ -509,7 +519,8 @@ public abstract class AbstractLoggingChampGraph implements ChampGraph {
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);
@@ -731,14 +742,16 @@ public abstract class AbstractLoggingChampGraph implements ChampGraph {
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.");
}
}
@@ -783,7 +796,8 @@ public abstract class AbstractLoggingChampGraph implements ChampGraph {
} 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());
}
}
}
diff --git a/champ-lib/champ-core/src/main/java/org/onap/aai/champcore/graph/impl/AbstractTinkerpopChampGraph.java b/champ-lib/champ-core/src/main/java/org/onap/aai/champcore/graph/impl/AbstractTinkerpopChampGraph.java
index f910b3c..3fbfd3d 100644
--- a/champ-lib/champ-core/src/main/java/org/onap/aai/champcore/graph/impl/AbstractTinkerpopChampGraph.java
+++ b/champ-lib/champ-core/src/main/java/org/onap/aai/champcore/graph/impl/AbstractTinkerpopChampGraph.java
@@ -31,7 +31,6 @@ import java.util.Optional;
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;
@@ -43,8 +42,8 @@ import org.apache.tinkerpop.gremlin.structure.Graph;
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;
@@ -57,15 +56,15 @@ import org.onap.aai.champcore.model.ChampRelationship;
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();
@@ -282,7 +281,8 @@ public abstract class AbstractTinkerpopChampGraph extends AbstractValidatingCham
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();
}
}
@@ -313,7 +313,8 @@ public abstract class AbstractTinkerpopChampGraph extends AbstractValidatingCham
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());
}
}
@@ -324,7 +325,8 @@ public abstract class AbstractTinkerpopChampGraph extends AbstractValidatingCham
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());
}
}
@@ -433,7 +435,8 @@ public abstract class AbstractTinkerpopChampGraph extends AbstractValidatingCham
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());
}
}
@@ -445,7 +448,8 @@ public abstract class AbstractTinkerpopChampGraph extends AbstractValidatingCham
//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());
}
}
@@ -698,7 +702,8 @@ public abstract class AbstractTinkerpopChampGraph extends AbstractValidatingCham
}
} 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();
}
}
@@ -728,7 +733,8 @@ public abstract class AbstractTinkerpopChampGraph extends AbstractValidatingCham
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());
}
}
@@ -740,7 +746,8 @@ public abstract class AbstractTinkerpopChampGraph extends AbstractValidatingCham
//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());
}
}
@@ -996,7 +1003,8 @@ public abstract class AbstractTinkerpopChampGraph extends AbstractValidatingCham
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");
diff --git a/champ-lib/champ-core/src/main/java/org/onap/aai/champcore/graph/impl/ChampAPIImpl.java b/champ-lib/champ-core/src/main/java/org/onap/aai/champcore/graph/impl/ChampAPIImpl.java
index 5a8b79e..2350d00 100644
--- a/champ-lib/champ-core/src/main/java/org/onap/aai/champcore/graph/impl/ChampAPIImpl.java
+++ b/champ-lib/champ-core/src/main/java/org/onap/aai/champcore/graph/impl/ChampAPIImpl.java
@@ -25,13 +25,15 @@ import java.util.concurrent.ConcurrentHashMap;
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;
@@ -67,13 +69,16 @@ public class ChampAPIImpl implements ChampAPI {
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()));
}
}
}
diff --git a/champ-lib/champ-core/src/main/java/org/onap/aai/champcore/graph/impl/TinkerpopTransaction.java b/champ-lib/champ-core/src/main/java/org/onap/aai/champcore/graph/impl/TinkerpopTransaction.java
index bd970dc..19c6f7c 100644
--- a/champ-lib/champ-core/src/main/java/org/onap/aai/champcore/graph/impl/TinkerpopTransaction.java
+++ b/champ-lib/champ-core/src/main/java/org/onap/aai/champcore/graph/impl/TinkerpopTransaction.java
@@ -21,11 +21,13 @@
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 {
@@ -35,7 +37,7 @@ 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() { }
@@ -55,7 +57,8 @@ public class TinkerpopTransaction extends ChampTransaction {
// 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
@@ -82,7 +85,8 @@ public class TinkerpopTransaction extends ChampTransaction {
// 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) {
@@ -92,14 +96,16 @@ public class TinkerpopTransaction extends ChampTransaction {
// 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 {
@@ -107,7 +113,8 @@ public class TinkerpopTransaction extends ChampTransaction {
} 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;
}
@@ -128,7 +135,8 @@ public class TinkerpopTransaction extends ChampTransaction {
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) {
@@ -138,13 +146,15 @@ public class TinkerpopTransaction extends ChampTransaction {
// 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 {
@@ -152,7 +162,8 @@ public class TinkerpopTransaction extends ChampTransaction {
} 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;
}
diff --git a/champ-lib/champ-core/src/main/java/org/onap/aai/champcore/ie/GraphMLImporterExporter.java b/champ-lib/champ-core/src/main/java/org/onap/aai/champcore/ie/GraphMLImporterExporter.java
index 36a3da0..c73b973 100644
--- a/champ-lib/champ-core/src/main/java/org/onap/aai/champcore/ie/GraphMLImporterExporter.java
+++ b/champ-lib/champ-core/src/main/java/org/onap/aai/champcore/ie/GraphMLImporterExporter.java
@@ -43,8 +43,8 @@ import javax.xml.stream.XMLStreamException;
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;
@@ -54,8 +54,8 @@ import org.onap.aai.champcore.exceptions.ChampUnmarshallingException;
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;
@@ -65,7 +65,7 @@ import org.xml.sax.SAXException;
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;
@@ -141,7 +141,8 @@ public class GraphMLImporterExporter implements Importer, Exporter {
} 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));
}
}
@@ -170,7 +171,8 @@ public class GraphMLImporterExporter implements Importer, Exporter {
} 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()));
}
}
}
@@ -212,16 +214,20 @@ public class GraphMLImporterExporter implements Importer, Exporter {
} 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");
@@ -267,17 +273,23 @@ public class GraphMLImporterExporter implements Importer, Exporter {
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");
}
}
@@ -338,13 +350,17 @@ public class GraphMLImporterExporter implements Importer, Exporter {
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");
}
}