diff options
author | 2017-09-23 00:03:28 +0000 | |
---|---|---|
committer | 2017-09-23 00:03:28 +0000 | |
commit | 2569e1680700bc46fbe6557679447b64481bfa9c (patch) | |
tree | f07c7802e41f3c221a22c44c70ddbd418bcc0d57 /src/main/java/com/att/nsa/mr/dme/client | |
parent | 08f6ff1defe178f51753f50e2195109a01a69910 (diff) | |
parent | 3af66448e6107f51ff30acfd440f8331515f1792 (diff) |
Merge "Fix for Sonar major issues"
Diffstat (limited to 'src/main/java/com/att/nsa/mr/dme/client')
-rw-r--r-- | src/main/java/com/att/nsa/mr/dme/client/SimpleExampleConsumer.java | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/main/java/com/att/nsa/mr/dme/client/SimpleExampleConsumer.java b/src/main/java/com/att/nsa/mr/dme/client/SimpleExampleConsumer.java index bc54a01..bdd15d4 100644 --- a/src/main/java/com/att/nsa/mr/dme/client/SimpleExampleConsumer.java +++ b/src/main/java/com/att/nsa/mr/dme/client/SimpleExampleConsumer.java @@ -32,14 +32,20 @@ import javax.ws.rs.core.MultivaluedMap; import com.att.nsa.mr.client.MRClientFactory; import com.att.nsa.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(); @@ -48,22 +54,23 @@ public class SimpleExampleConsumer { final MRConsumer cc = MRClientFactory.createConsumer("D:\\SG\\consumer.properties"); while (true) { for (String msg : cc.fetch()) { - - System.out.println("Message Received: " + msg); + logger.debug("Message Received: " + msg); } // Header for DME2 Call. MultivaluedMap<String, Object> headersMap = MRClientFactory.HTTPHeadersMap; - for (String key : headersMap.keySet()) { - System.out.println("Header Key " + key); - System.out.println("Header Value " + headersMap.get(key)); + 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(String key - : dme2headersMap.keySet()) { System.out.println("Header Key " - + key); System.out.println("Header Value " + - dme2headersMap.get(key)); } + 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; @@ -72,12 +79,11 @@ public class SimpleExampleConsumer { final long elapsedMs = endMs - startMs; final double elapsedSec = elapsedMs / 1000.0; final double eps = count / elapsedSec; - System.out.println("Consumed " + count + " in " + elapsedSec + "; " + eps + " eps"); + logger.error("Consumed " + count + " in " + elapsedSec + "; " + eps + " eps"); } } } catch (Exception x) { - System.err.println(x.getClass().getName() + ": " + x.getMessage()); - logger.error("exception: ", x); + logger.error(x.getClass().getName() + ": " + x.getMessage()); } } } |