aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/dmaap/mr/dme
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/onap/dmaap/mr/dme')
-rw-r--r--src/main/java/org/onap/dmaap/mr/dme/client/DefaultLoggingFailoverFaultHandler.java52
-rw-r--r--src/main/java/org/onap/dmaap/mr/dme/client/HeaderReplyHandler.java59
-rw-r--r--src/main/java/org/onap/dmaap/mr/dme/client/PreferredRouteReplyHandler.java86
-rw-r--r--src/main/java/org/onap/dmaap/mr/dme/client/PreferredRouteRequestHandler.java50
-rw-r--r--src/main/java/org/onap/dmaap/mr/dme/client/SimpleExampleConsumer.java88
-rw-r--r--src/main/java/org/onap/dmaap/mr/dme/client/SimpleExamplePublisher.java128
6 files changed, 100 insertions, 363 deletions
diff --git a/src/main/java/org/onap/dmaap/mr/dme/client/DefaultLoggingFailoverFaultHandler.java b/src/main/java/org/onap/dmaap/mr/dme/client/DefaultLoggingFailoverFaultHandler.java
deleted file mode 100644
index a44d858..0000000
--- a/src/main/java/org/onap/dmaap/mr/dme/client/DefaultLoggingFailoverFaultHandler.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START=======================================================
- * org.onap.dmaap
- * ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *
- *******************************************************************************/
-package org.onap.dmaap.mr.dme.client;
-
-
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-
-//import com.att.aft.dme2.api.util.DME2Constants;
-//import com.att.aft.dme2.api.util.DME2ExchangeFaultContext;
-//import com.att.aft.dme2.api.util.LogMessage;
-//import com.att.aft.dme2.api.util.LogUtil;
-public class DefaultLoggingFailoverFaultHandler /*implements DME2FailoverFaultHandler*/ {
- //TODO: This code may be enable in the future when we implement DME2FailoverFaultHandler interface
- /** The logger. */
-
-
-// @Override
-
-// // LogUtil.INSTANCE.report(logger, Level.WARNING, LogMessage.SEP_FAILOVER, context.getService(),context.getRequestURL(),context.getRouteOffer(),context.getResponseCode(),context.getException());
-// }
-// @Override
-// /**
-// * The DME2Exchange already has a log message when the route offer is failed over. We dont need to log it again here.
-// */
-
-// //noop
-//
-
-}
-
diff --git a/src/main/java/org/onap/dmaap/mr/dme/client/HeaderReplyHandler.java b/src/main/java/org/onap/dmaap/mr/dme/client/HeaderReplyHandler.java
index 9197ca4..7d6c971 100644
--- a/src/main/java/org/onap/dmaap/mr/dme/client/HeaderReplyHandler.java
+++ b/src/main/java/org/onap/dmaap/mr/dme/client/HeaderReplyHandler.java
@@ -4,11 +4,13 @@
* ================================================================================
* Copyright © 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright © 2021 Orange.
+ * ================================================================================
* 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.
@@ -17,40 +19,41 @@
* ============LICENSE_END=========================================================
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *
+ *
*******************************************************************************/
-package org.onap.dmaap.mr.dme.client;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+package org.onap.dmaap.mr.dme.client;
import com.att.aft.dme2.api.util.DME2ExchangeFaultContext;
import com.att.aft.dme2.api.util.DME2ExchangeReplyHandler;
import com.att.aft.dme2.api.util.DME2ExchangeResponseContext;
import org.onap.dmaap.mr.client.MRClientFactory;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
public class HeaderReplyHandler implements DME2ExchangeReplyHandler {
-
- private Logger fLog = LoggerFactory.getLogger ( this.getClass().getName () );
-
-
- @Override public void handleFault(DME2ExchangeFaultContext responseData) {
- // TODO Auto-generated method stub
-
- }
- @Override public void handleEndpointFault(DME2ExchangeFaultContext responseData) {
- // TODO Auto-generated method stub
-
- }
-@Override public void handleReply(DME2ExchangeResponseContext responseData) {
-
- if(responseData != null) {
- MRClientFactory.DME2HeadersMap=responseData.getResponseHeaders();
- if (responseData.getResponseHeaders().get("transactionId")!=null)
- fLog.info("Transaction Id : " + responseData.getResponseHeaders().get("transactionId"));
-
- }
-}
+
+ private static final Logger logger = LoggerFactory.getLogger(HeaderReplyHandler.class);
+
+ @Override
+ public void handleFault(DME2ExchangeFaultContext responseData) {
+
+ }
+
+ @Override
+ public void handleEndpointFault(DME2ExchangeFaultContext responseData) {
+
+ }
+
+ @Override
+ public void handleReply(DME2ExchangeResponseContext responseData) {
+ if (responseData != null) {
+ MRClientFactory.DME2HeadersMap = responseData.getResponseHeaders();
+ if (responseData.getResponseHeaders().get("transactionId") != null) {
+ logger.info("Transaction Id : " + responseData.getResponseHeaders().get("transactionId"));
+ }
+
+ }
+ }
}
diff --git a/src/main/java/org/onap/dmaap/mr/dme/client/PreferredRouteReplyHandler.java b/src/main/java/org/onap/dmaap/mr/dme/client/PreferredRouteReplyHandler.java
index 70e0d1b..1b13c8e 100644
--- a/src/main/java/org/onap/dmaap/mr/dme/client/PreferredRouteReplyHandler.java
+++ b/src/main/java/org/onap/dmaap/mr/dme/client/PreferredRouteReplyHandler.java
@@ -4,11 +4,13 @@
* ================================================================================
* Copyright © 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright © 2021 Orange.
+ * ================================================================================
* 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.
@@ -17,55 +19,57 @@
* ============LICENSE_END=========================================================
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *
+ *
*******************************************************************************/
-package org.onap.dmaap.mr.dme.client;
-import java.io.File;
-import java.io.FileWriter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+package org.onap.dmaap.mr.dme.client;
import com.att.aft.dme2.api.util.DME2ExchangeFaultContext;
import com.att.aft.dme2.api.util.DME2ExchangeReplyHandler;
import com.att.aft.dme2.api.util.DME2ExchangeResponseContext;
+import java.io.File;
+import java.io.FileWriter;
import org.onap.dmaap.mr.client.MRClientFactory;
import org.onap.dmaap.mr.client.impl.MRSimplerBatchPublisher;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class PreferredRouteReplyHandler implements DME2ExchangeReplyHandler {
- private Logger fLog = LoggerFactory.getLogger ( this.getClass().getName () );
- @Override public void handleReply(DME2ExchangeResponseContext responseData) {
-
- if(responseData != null) {
- MRClientFactory.DME2HeadersMap=responseData.getResponseHeaders();
- if (responseData.getResponseHeaders().get("transactionId")!=null)
-
- fLog.info("Transaction_Id : " + responseData.getResponseHeaders().get("transactionId"));
-
- if(responseData.getRouteOffer() != null ){
- routeWriter("preferredRouteKey",responseData.getRouteOffer());
-
- }
- }
-}
-
- @Override public void handleFault(DME2ExchangeFaultContext responseData) {
- // TODO Auto-generated method stub
- //StaticCache.getInstance().setHandleFaultInvoked(true);
- }
- @Override public void handleEndpointFault(DME2ExchangeFaultContext responseData) {
- // TODO Auto-generated method stub
-
- }
- public void routeWriter(String routeKey, String routeValue){
- try(FileWriter routeWriter=new FileWriter(new File (MRSimplerBatchPublisher.routerFilePath))){
- routeWriter.write(routeKey+"="+routeValue);
- routeWriter.close();
-
- }catch(Exception ex){
- fLog.error("Reply Router Error " + ex);
- }
-
- }
+ private static final Logger logger = LoggerFactory.getLogger(PreferredRouteReplyHandler.class);
+
+ @Override
+ public void handleReply(DME2ExchangeResponseContext responseData) {
+
+ if (responseData != null) {
+ MRClientFactory.DME2HeadersMap = responseData.getResponseHeaders();
+ if (responseData.getResponseHeaders().get("transactionId") != null) {
+ logger.info("Transaction_Id : " + responseData.getResponseHeaders().get("transactionId"));
+ }
+
+ if (responseData.getRouteOffer() != null) {
+ routeWriter("preferredRouteKey", responseData.getRouteOffer());
+ }
+ }
+ }
+
+ @Override
+ public void handleFault(DME2ExchangeFaultContext responseData) {
+
+ }
+
+ @Override
+ public void handleEndpointFault(DME2ExchangeFaultContext responseData) {
+
+ }
+
+ public void routeWriter(String routeKey, String routeValue) {
+
+ try (FileWriter routeWriter = new FileWriter(new File(MRSimplerBatchPublisher.routerFilePath))) {
+ routeWriter.write(routeKey + "=" + routeValue);
+ } catch (Exception ex) {
+ logger.error("Reply Router Error " + ex);
+ }
+
+ }
}
diff --git a/src/main/java/org/onap/dmaap/mr/dme/client/PreferredRouteRequestHandler.java b/src/main/java/org/onap/dmaap/mr/dme/client/PreferredRouteRequestHandler.java
index dd0b286..bb5309f 100644
--- a/src/main/java/org/onap/dmaap/mr/dme/client/PreferredRouteRequestHandler.java
+++ b/src/main/java/org/onap/dmaap/mr/dme/client/PreferredRouteRequestHandler.java
@@ -4,11 +4,13 @@
* ================================================================================
* Copyright © 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright © 2021 Orange.
+ * ================================================================================
* 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.
@@ -17,38 +19,34 @@
* ============LICENSE_END=========================================================
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *
+ *
*******************************************************************************/
-package org.onap.dmaap.mr.dme.client;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+package org.onap.dmaap.mr.dme.client;
import com.att.aft.dme2.api.util.DME2ExchangeRequestContext;
import com.att.aft.dme2.api.util.DME2ExchangeRequestHandler;
import org.onap.dmaap.mr.client.MRClientFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class PreferredRouteRequestHandler implements DME2ExchangeRequestHandler {
- private Logger logger = LoggerFactory.getLogger(this.getClass().getName());
-
- @Override
- public void handleRequest(DME2ExchangeRequestContext requestData) {
-
- if (requestData != null) {
-
- requestData.setPreferredRouteOffer(readRoute("preferredRouteKey"));
- }
- }
-
- public String readRoute(String routeKey) {
-
- try {
-
- MRClientFactory.prop.load(MRClientFactory.routeReader);
- } catch (Exception ex) {
- logger.error("Request Router Error ", ex);
- }
- return MRClientFactory.prop.getProperty(routeKey);
- }
+ private static final Logger logger = LoggerFactory.getLogger(PreferredRouteRequestHandler.class);
+
+ @Override
+ public void handleRequest(DME2ExchangeRequestContext requestData) {
+ if (requestData != null) {
+ requestData.setPreferredRouteOffer(readRoute("preferredRouteKey"));
+ }
+ }
+
+ public String readRoute(String routeKey) {
+ try {
+ MRClientFactory.prop.load(MRClientFactory.routeReader);
+ } catch (Exception ex) {
+ logger.error("Request Router Error ", ex);
+ }
+ return MRClientFactory.prop.getProperty(routeKey);
+ }
}
diff --git a/src/main/java/org/onap/dmaap/mr/dme/client/SimpleExampleConsumer.java b/src/main/java/org/onap/dmaap/mr/dme/client/SimpleExampleConsumer.java
deleted file mode 100644
index 76abb7e..0000000
--- a/src/main/java/org/onap/dmaap/mr/dme/client/SimpleExampleConsumer.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START=======================================================
- * org.onap.dmaap
- * ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *
- *******************************************************************************/
-
-package org.onap.dmaap.mr.dme.client;
-
-import java.util.Map;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.ws.rs.core.MultivaluedMap;
-
-import org.onap.dmaap.mr.client.MRClientFactory;
-import org.onap.dmaap.mr.client.MRConsumer;
-
-import java.util.List;
-
-public class SimpleExampleConsumer {
-
- private static final Logger logger = LoggerFactory.getLogger(SimpleExampleConsumer.class);
-
- private SimpleExampleConsumer() {
- }
-
- public static void main(String[] args) {
-
- long count = 0;
- long nextReport = 5000;
- String key;
-
- final long startMs = System.currentTimeMillis();
-
- try {
-
- final MRConsumer cc = MRClientFactory.createConsumer("D:\\SG\\consumer.properties");
- while (true) {
- for (String msg : cc.fetch()) {
- logger.debug("Message Received: " + msg);
- }
- // Header for DME2 Call.
- MultivaluedMap<String, Object> headersMap = MRClientFactory.getHTTPHeadersMap();
- for (MultivaluedMap.Entry<String, List<Object>> entry : headersMap.entrySet()) {
- key = entry.getKey();
- logger.debug("Header Key " + key);
- logger.debug("Header Value " + headersMap.get(key));
- }
- // Header for HTTP Call.
-
- Map<String, String> dme2headersMap = MRClientFactory.DME2HeadersMap;
- for (Map.Entry<String, String> entry : dme2headersMap.entrySet()) {
- key = entry.getKey();
- logger.debug("Header Key " + key);
- logger.debug("Header Value " + dme2headersMap.get(key));
- }
-
- if (count > nextReport) {
- nextReport += 5000;
-
- final long endMs = System.currentTimeMillis();
- final long elapsedMs = endMs - startMs;
- final double elapsedSec = elapsedMs / 1000.0;
- final double eps = count / elapsedSec;
- }
- }
- } catch (Exception x) {
- logger.error("Exception in SimpleExampleConsumer", x);
- }
- }
-}
diff --git a/src/main/java/org/onap/dmaap/mr/dme/client/SimpleExamplePublisher.java b/src/main/java/org/onap/dmaap/mr/dme/client/SimpleExamplePublisher.java
deleted file mode 100644
index b5d83bb..0000000
--- a/src/main/java/org/onap/dmaap/mr/dme/client/SimpleExamplePublisher.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START=======================================================
- * org.onap.dmaap
- * ================================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- *
- *******************************************************************************/
-
-package org.onap.dmaap.mr.dme.client;
-
-
-import java.io.IOException;
-import java.util.Map;
-import javax.ws.rs.core.MultivaluedMap;
-import org.json.JSONObject;
-import org.onap.dmaap.mr.client.MRBatchingPublisher;
-import org.onap.dmaap.mr.client.MRClientFactory;
-
-/**
- * An example of how to use the Java publisher.
- *
- * @author author
- */
-public class SimpleExamplePublisher {
- static String content = null;
- static String messageSize = null;
- static String transport = null;
- static String messageCount = null;
-
- public void publishMessage(String producerFilePath) throws IOException, InterruptedException {
-
- // create our publisher
-
- // publish some messages
-
-
- StringBuilder sb = new StringBuilder();
- final MRBatchingPublisher pub = MRClientFactory.createBatchingPublisher(producerFilePath);
-
- if (content.equalsIgnoreCase("text/plain")) {
- for (int i = 0; i < Integer.parseInt(messageCount); i++) {
- for (int j = 0; j < Integer.parseInt(messageSize); j++) {
- sb.append("T");
- }
-
- pub.send(sb.toString());
- }
- } else if (content.equalsIgnoreCase("application/cambria")) {
- for (int i = 0; i < Integer.parseInt(messageCount); i++) {
- for (int j = 0; j < Integer.parseInt(messageSize); j++) {
- sb.append("C");
- }
-
- pub.send("Key", sb.toString());
- }
- } else if (content.equalsIgnoreCase("application/json")) {
- for (int i = 0; i < Integer.parseInt(messageCount); i++) {
-
- final JSONObject msg12 = new JSONObject();
- msg12.put("Name", "DMaaP Reference Client to Test jason Message");
-
- pub.send(msg12.toString());
-
- }
- }
-
- // ...
-
- // close the publisher to make sure everything's sent before exiting.
- // The batching
- // publisher interface allows the app to get the set of unsent messages.
- // It could
- // write them to disk, for example, to try to send them later.
- /* final List<message> stuck = pub.close(20, TimeUnit.SECONDS);
- if (stuck.size() > 0) {
- System.err.println(stuck.size() + " messages unsent");
- } else {
- System.out.println("Clean exit; all messages sent.");
- }*/
-
- if (transport.equalsIgnoreCase("HTTP")) {
- MultivaluedMap<String, Object> headersMap = MRClientFactory.getHTTPHeadersMap();
- for (String key : headersMap.keySet()) {
- System.out.println("Header Key " + key);
- System.out.println("Header Value " + headersMap.get(key));
- }
- } else {
- Map<String, String> dme2headersMap = MRClientFactory.DME2HeadersMap;
- for (String key : dme2headersMap.keySet()) {
- System.out.println("Header Key " + key);
- System.out.println("Header Value " + dme2headersMap.get(key));
- }
- }
-
- }
-
- public static void main(String[] args) throws InterruptedException, Exception {
-
- String producerFilePath = args[0];
- content = args[1];
- messageSize = args[2];
- transport = args[3];
- messageCount = args[4];
-
-
-
-
-
- SimpleExamplePublisher publisher = new SimpleExamplePublisher();
-
- publisher.publishMessage("D:\\SG\\producer.properties");
- }
-
-}