summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/att/nsa/mr/client/impl/MRBaseClient.java2
-rw-r--r--src/main/java/com/att/nsa/mr/client/impl/MRClientVersionInfo.java5
-rw-r--r--src/main/java/com/att/nsa/mr/client/impl/MRConsumerImpl.java20
-rw-r--r--src/main/java/com/att/nsa/mr/client/impl/MRFormat.java3
-rw-r--r--src/main/java/com/att/nsa/mr/client/impl/MRMetaClient.java6
-rw-r--r--src/main/java/com/att/nsa/mr/client/impl/MRSimplerBatchPublisher.java8
-rw-r--r--src/main/java/com/att/nsa/mr/client/response/MRPublisherResponse.java1
-rw-r--r--src/main/java/com/att/nsa/mr/dme/client/DefaultLoggingFailoverFaultHandler.java4
-rw-r--r--src/main/java/com/att/nsa/mr/dme/client/PreferredRouteRequestHandler.java4
-rw-r--r--src/main/java/com/att/nsa/mr/dme/client/SimpleExampleConsumer.java36
-rw-r--r--src/main/java/com/att/nsa/mr/logging/MRAppender.java11
-rw-r--r--src/main/java/com/att/nsa/mr/test/clients/ConsolePublisher.java17
-rw-r--r--src/main/java/com/att/nsa/mr/test/clients/SampleConsumer.java17
-rw-r--r--src/main/java/com/att/nsa/mr/test/clients/SimpleExampleConsumer.java7
-rw-r--r--src/main/java/com/att/nsa/mr/test/clients/SimpleExampleConsumerWithReturnResponse.java5
-rw-r--r--src/main/java/com/att/nsa/mr/tools/ApiKeyCommand.java9
-rw-r--r--src/main/java/com/att/nsa/mr/tools/MessageCommand.java9
-rw-r--r--src/main/java/com/att/nsa/mr/tools/TopicCommand.java14
18 files changed, 134 insertions, 44 deletions
diff --git a/src/main/java/com/att/nsa/mr/client/impl/MRBaseClient.java b/src/main/java/com/att/nsa/mr/client/impl/MRBaseClient.java
index a9fd9bd..012e95e 100644
--- a/src/main/java/com/att/nsa/mr/client/impl/MRBaseClient.java
+++ b/src/main/java/com/att/nsa/mr/client/impl/MRBaseClient.java
@@ -59,6 +59,8 @@ public class MRBaseClient extends HttpClient implements MRClient
protected MRBaseClient ( Collection<String> hosts ) throws MalformedURLException
{
super ( ConnectionType.HTTP, hosts, MRConstants.kStdMRServicePort );
+
+ fLog = LoggerFactory.getLogger ( this.getClass().getName () );
}
protected MRBaseClient ( Collection<String> hosts, int stdSvcPort ) throws MalformedURLException {
diff --git a/src/main/java/com/att/nsa/mr/client/impl/MRClientVersionInfo.java b/src/main/java/com/att/nsa/mr/client/impl/MRClientVersionInfo.java
index fa9207d..bb6299d 100644
--- a/src/main/java/com/att/nsa/mr/client/impl/MRClientVersionInfo.java
+++ b/src/main/java/com/att/nsa/mr/client/impl/MRClientVersionInfo.java
@@ -25,8 +25,12 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
public class MRClientVersionInfo
{
+ private static final Logger logger = LoggerFactory.getLogger(MRClientVersionInfo.class);
public static String getVersion ()
{
return version;
@@ -48,6 +52,7 @@ public class MRClientVersionInfo
}
catch ( IOException e )
{
+ logger.error("exception: ", e);
}
version = use;
}
diff --git a/src/main/java/com/att/nsa/mr/client/impl/MRConsumerImpl.java b/src/main/java/com/att/nsa/mr/client/impl/MRConsumerImpl.java
index fdd1b89..eb7fd91 100644
--- a/src/main/java/com/att/nsa/mr/client/impl/MRConsumerImpl.java
+++ b/src/main/java/com/att/nsa/mr/client/impl/MRConsumerImpl.java
@@ -57,7 +57,7 @@ public class MRConsumerImpl extends MRBaseClient implements MRConsumer
private static final String SUCCESS_MESSAGE = "Success";
- private Logger fLog = LoggerFactory.getLogger ( this.getClass().getName () );
+ private Logger log = LoggerFactory.getLogger ( this.getClass().getName () );
public static List<String> stringToList ( String str )
{
final LinkedList<String> set = new LinkedList<String> ();
@@ -160,6 +160,7 @@ public class MRConsumerImpl extends MRBaseClient implements MRConsumer
{
// unexpected response
reportProblemWithResponse ();
+ log.error("exception: ", e);
}
catch ( HttpException e )
{
@@ -202,6 +203,7 @@ public class MRConsumerImpl extends MRBaseClient implements MRConsumer
{
// unexpected response
reportProblemWithResponse ();
+ log.error("exception: ", e);
}
catch ( HttpException e )
{
@@ -242,6 +244,7 @@ public class MRConsumerImpl extends MRBaseClient implements MRConsumer
{
// unexpected response
reportProblemWithResponse ();
+ log.error("exception: ", e);
}
catch ( HttpException e )
{
@@ -253,6 +256,7 @@ public class MRConsumerImpl extends MRBaseClient implements MRConsumer
} catch ( JSONException e ) {
// unexpected response
reportProblemWithResponse ();
+ log.error("exception: ", e);
} catch (HttpException e) {
throw new IOException(e);
} catch (Exception e ) {
@@ -267,7 +271,7 @@ public class MRConsumerImpl extends MRBaseClient implements MRConsumer
try {
- //fLog.info("DMAAP response status: " + response.getStatus());
+ //log.info("DMAAP response status: " + response.getStatus());
// final String responseData = response.readEntity(String.class);
JSONTokener jsonTokener = new JSONTokener(response);
@@ -284,7 +288,7 @@ public class MRConsumerImpl extends MRBaseClient implements MRConsumer
return jsonObject;
} catch (JSONException excp) {
- // fLog.error("DMAAP - Error reading response data.", excp);
+ // log.error("DMAAP - Error reading response data.", excp);
return null;
}
@@ -348,7 +352,7 @@ public class MRConsumerImpl extends MRBaseClient implements MRConsumer
private Properties props;
private HashMap<String, String> DMETimeOuts;
private String handlers;
- public static String routerFilePath;
+ public static final String routerFilePath = null;
public static String getRouterFilePath() {
return routerFilePath;
}
@@ -413,7 +417,7 @@ public class MRConsumerImpl extends MRBaseClient implements MRConsumer
url = protocol + "://"+serviceName+"?version="+version+"&envContext="+env+"&routeoffer="+routeOffer;
}
- //fLog.info("url :"+url);
+ //log.info("url :"+url);
if(timeoutMs != -1 )url=url+"&timeout="+timeoutMs;
if(limit != -1 )url=url+"&limit="+limit;
@@ -564,7 +568,7 @@ public class MRConsumerImpl extends MRBaseClient implements MRConsumer
MRClientFactory.prop.load(new FileReader(new File (MRClientFactory.routeFilePath)));
} catch (Exception ex) {
- fLog.error("Reply Router Error " + ex.toString() );
+ log.error("Reply Router Error " + ex.toString() );
}
String routeOffer = MRClientFactory.prop.getProperty(routeKey);
return routeOffer;
@@ -669,15 +673,19 @@ public class MRConsumerImpl extends MRBaseClient implements MRConsumer
} catch (JSONException e) {
mrConsumerResponse.setResponseMessage(String.valueOf(HttpStatus.SC_INTERNAL_SERVER_ERROR));
mrConsumerResponse.setResponseMessage(e.getMessage());
+ log.error("json exception: ", e);
} catch (HttpException e) {
mrConsumerResponse.setResponseMessage(String.valueOf(HttpStatus.SC_INTERNAL_SERVER_ERROR));
mrConsumerResponse.setResponseMessage(e.getMessage());
+ log.error("http exception: ", e);
}catch(DME2Exception e){
mrConsumerResponse.setResponseCode(e.getErrorCode());
mrConsumerResponse.setResponseMessage(e.getErrorMessage());
+ log.error("DME2 exception: ", e);
}catch (Exception e) {
mrConsumerResponse.setResponseMessage(String.valueOf(HttpStatus.SC_INTERNAL_SERVER_ERROR));
mrConsumerResponse.setResponseMessage(e.getMessage());
+ log.error("exception: ", e);
}
mrConsumerResponse.setActualMessages(msgs);
return mrConsumerResponse;
diff --git a/src/main/java/com/att/nsa/mr/client/impl/MRFormat.java b/src/main/java/com/att/nsa/mr/client/impl/MRFormat.java
index 09a317b..1028adf 100644
--- a/src/main/java/com/att/nsa/mr/client/impl/MRFormat.java
+++ b/src/main/java/com/att/nsa/mr/client/impl/MRFormat.java
@@ -28,6 +28,7 @@ enum MRFormat
*/
CAMBRIA
{
+ @Override
public String toString() { return "application/cambria"; }
},
@@ -36,6 +37,7 @@ enum MRFormat
*/
CAMBRIA_ZIP
{
+ @Override
public String toString() { return "application/cambria-zip"; }
},
@@ -44,6 +46,7 @@ enum MRFormat
*/
JSON
{
+ @Override
public String toString() { return "application/json"; }
}
}
diff --git a/src/main/java/com/att/nsa/mr/client/impl/MRMetaClient.java b/src/main/java/com/att/nsa/mr/client/impl/MRMetaClient.java
index d32a7ef..609540b 100644
--- a/src/main/java/com/att/nsa/mr/client/impl/MRMetaClient.java
+++ b/src/main/java/com/att/nsa/mr/client/impl/MRMetaClient.java
@@ -31,6 +31,9 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import com.att.nsa.apiClient.credentials.ApiCredential;
import com.att.nsa.apiClient.http.HttpException;
import com.att.nsa.apiClient.http.HttpObjectNotFoundException;
@@ -39,6 +42,7 @@ import com.att.nsa.mr.client.MRTopicManager;
public class MRMetaClient extends MRBaseClient implements MRTopicManager, MRIdentityManager
{
+ private static final Logger logger = LoggerFactory.getLogger(MRMetaClient.class);
public MRMetaClient ( Collection<String> baseUrls ) throws MalformedURLException
{
super ( baseUrls );
@@ -60,10 +64,12 @@ public class MRMetaClient extends MRBaseClient implements MRTopicManager, MRIden
catch ( HttpObjectNotFoundException e )
{
getLog().warn ( "No /topics endpoint on service." );
+ logger.error("HttpObjectNotFoundException: ", e);
}
catch ( JSONException e )
{
getLog().warn ( "Bad /topics result from service." );
+ logger.error("JSONException: ", e);
}
catch ( HttpException e )
{
diff --git a/src/main/java/com/att/nsa/mr/client/impl/MRSimplerBatchPublisher.java b/src/main/java/com/att/nsa/mr/client/impl/MRSimplerBatchPublisher.java
index ad925b1..398558d 100644
--- a/src/main/java/com/att/nsa/mr/client/impl/MRSimplerBatchPublisher.java
+++ b/src/main/java/com/att/nsa/mr/client/impl/MRSimplerBatchPublisher.java
@@ -40,6 +40,9 @@ import java.util.zip.GZIPOutputStream;
import javax.ws.rs.core.MultivaluedMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import org.apache.http.HttpException;
import org.apache.http.HttpStatus;
import org.json.JSONArray;
@@ -54,6 +57,8 @@ import com.att.nsa.mr.test.clients.ProtocolTypeConstants;
public class MRSimplerBatchPublisher extends MRBaseClient implements MRBatchingPublisher
{
+ private static final Logger logger = LoggerFactory.getLogger(MRSimplerBatchPublisher.class);
+
public static class Builder
{
public Builder ()
@@ -512,6 +517,7 @@ public class MRSimplerBatchPublisher extends MRBaseClient implements MRBatchingP
pubResponse.setResponseCode(String.valueOf(HttpStatus.SC_INTERNAL_SERVER_ERROR));
pubResponse.setResponseMessage(x.getMessage());
+ logger.error("exception: ", x);
}
@@ -684,7 +690,7 @@ private MRPublisherResponse createMRPublisherResponse(String reply, MRPublisherR
private String handlers;
private Properties props;
public static String routerFilePath;
- public static Map<String, String> headers=new HashMap<String, String>();
+ protected static final Map<String, String> headers=new HashMap<String, String>();
public static MultivaluedMap<String, Object> headersMap;
diff --git a/src/main/java/com/att/nsa/mr/client/response/MRPublisherResponse.java b/src/main/java/com/att/nsa/mr/client/response/MRPublisherResponse.java
index 4aebe23..96c39d6 100644
--- a/src/main/java/com/att/nsa/mr/client/response/MRPublisherResponse.java
+++ b/src/main/java/com/att/nsa/mr/client/response/MRPublisherResponse.java
@@ -57,6 +57,7 @@ public class MRPublisherResponse {
this.pendingMsgs = pendingMsgs;
}
+ @Override
public String toString() {
return "Response Code:" + this.responseCode + ","
+ "Response Message:" + this.responseMessage + "," + "Pending Messages Count"
diff --git a/src/main/java/com/att/nsa/mr/dme/client/DefaultLoggingFailoverFaultHandler.java b/src/main/java/com/att/nsa/mr/dme/client/DefaultLoggingFailoverFaultHandler.java
index 1d3b6be..813ad59 100644
--- a/src/main/java/com/att/nsa/mr/dme/client/DefaultLoggingFailoverFaultHandler.java
+++ b/src/main/java/com/att/nsa/mr/dme/client/DefaultLoggingFailoverFaultHandler.java
@@ -32,6 +32,7 @@ import java.util.logging.Logger;
//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. */
//private static Logger logger = DME2Constants.getLogger(DefaultLoggingFailoverFaultHandler.class.getName());
@@ -47,4 +48,5 @@ public class DefaultLoggingFailoverFaultHandler /*implements DME2FailoverFaultHa
// //noop
//
// }
-} \ No newline at end of file
+}
+
diff --git a/src/main/java/com/att/nsa/mr/dme/client/PreferredRouteRequestHandler.java b/src/main/java/com/att/nsa/mr/dme/client/PreferredRouteRequestHandler.java
index a65683b..85b6126 100644
--- a/src/main/java/com/att/nsa/mr/dme/client/PreferredRouteRequestHandler.java
+++ b/src/main/java/com/att/nsa/mr/dme/client/PreferredRouteRequestHandler.java
@@ -29,7 +29,7 @@ import com.att.aft.dme2.api.util.DME2ExchangeRequestHandler;
import com.att.nsa.mr.client.MRClientFactory;
public class PreferredRouteRequestHandler implements DME2ExchangeRequestHandler {
- private Logger fLog = LoggerFactory.getLogger(this.getClass().getName());
+ private Logger logger = LoggerFactory.getLogger(this.getClass().getName());
@Override
public void handleRequest(DME2ExchangeRequestContext requestData) {
@@ -47,7 +47,7 @@ public class PreferredRouteRequestHandler implements DME2ExchangeRequestHandler
MRClientFactory.prop.load(MRClientFactory.routeReader);
} catch (Exception ex) {
- fLog.error("Request Router Error " + ex.toString());
+ logger.error("Request Router Error " + ex.toString());
}
return MRClientFactory.prop.getProperty(routeKey);
}
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 4df9fcb..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
@@ -24,17 +24,28 @@ package com.att.nsa.mr.dme.client;
import java.util.Map;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
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();
@@ -43,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;
@@ -67,11 +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(x.getClass().getName() + ": " + x.getMessage());
}
}
}
diff --git a/src/main/java/com/att/nsa/mr/logging/MRAppender.java b/src/main/java/com/att/nsa/mr/logging/MRAppender.java
index 8faf0df..4bb3e71 100644
--- a/src/main/java/com/att/nsa/mr/logging/MRAppender.java
+++ b/src/main/java/com/att/nsa/mr/logging/MRAppender.java
@@ -26,8 +26,10 @@ package com.att.nsa.mr.logging;
import java.io.IOException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import org.apache.log4j.AppenderSkeleton;
-import org.apache.log4j.helpers.LogLog;
import org.apache.log4j.spi.LoggingEvent;
import com.att.nsa.mr.client.MRClientFactory;
@@ -39,6 +41,8 @@ import com.att.nsa.mr.client.MRPublisher;
*/
public class MRAppender extends AppenderSkeleton {
+ private Logger logger = LoggerFactory.getLogger(this.getClass().getName());
+
private MRPublisher fPublisher;
//Provided through log4j configuration
@@ -98,15 +102,16 @@ public class MRAppender extends AppenderSkeleton {
try {
fPublisher.send(partition, message);
} catch (IOException e) {
- e.printStackTrace();
+ logger.error("IOException: ", e);
}
}
+ @Override
public void activateOptions() {
if (hosts != null && topic != null && partition != null) {
fPublisher = MRClientFactory.createBatchingPublisher(hosts.split(","), topic, maxBatchSize, maxAgeMs, compress);
} else {
- LogLog.error("The Hosts, Topic, and Partition parameter are required to create a MR Log4J Appender");
+ logger.error("The Hosts, Topic, and Partition parameter are required to create a MR Log4J Appender");
}
}
public String getTopic() {
diff --git a/src/main/java/com/att/nsa/mr/test/clients/ConsolePublisher.java b/src/main/java/com/att/nsa/mr/test/clients/ConsolePublisher.java
index 2294d7b..61aa836 100644
--- a/src/main/java/com/att/nsa/mr/test/clients/ConsolePublisher.java
+++ b/src/main/java/com/att/nsa/mr/test/clients/ConsolePublisher.java
@@ -29,6 +29,9 @@ import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import com.att.nsa.mr.client.MRBatchingPublisher;
import com.att.nsa.mr.client.MRClientFactory;
import com.att.nsa.mr.client.MRPublisher.message;
@@ -39,16 +42,20 @@ import com.att.nsa.mr.client.MRPublisher.message;
*/
public class ConsolePublisher
{
+
+ private static final Logger logger = LoggerFactory.getLogger(ConsolePublisher.class);
+ private ConsolePublisher() {
+ }
public static void main ( String[] args ) throws IOException //throws IOException, InterruptedException
{
// read the hosts(s) from the command line
- final String hosts = ( args.length > 0 ? args[0] : "aaa.it.att.com,bbb.it.att.com,ccc.it.att.com" );
+ final String hosts = args.length > 0 ? args[0] : "aaa.it.att.com,bbb.it.att.com,ccc.it.att.com";
// read the topic name from the command line
- final String topic = ( args.length > 1 ? args[1] : "TEST-TOPIC" );
+ final String topic = args.length > 1 ? args[1] : "TEST-TOPIC";
// read the topic name from the command line
- final String partition = ( args.length > 2 ? args[2] : UUID.randomUUID ().toString () );
+ final String partition = args.length > 2 ? args[2] : UUID.randomUUID ().toString ();
// set up some batch limits and the compression flag
final int maxBatchSize = 100;
@@ -76,11 +83,11 @@ public class ConsolePublisher
}
catch ( InterruptedException e )
{
- System.err.println ( "Send on close interrupted." );
+ logger.error( "Send on close interrupted." );
}
for ( message m : leftovers )
{
- System.err.println ( "Unsent message: " + m.fMsg );
+ logger.error( "Unsent message: " + m.fMsg );
}
}
}
diff --git a/src/main/java/com/att/nsa/mr/test/clients/SampleConsumer.java b/src/main/java/com/att/nsa/mr/test/clients/SampleConsumer.java
index 8e1c0e0..eac8b7f 100644
--- a/src/main/java/com/att/nsa/mr/test/clients/SampleConsumer.java
+++ b/src/main/java/com/att/nsa/mr/test/clients/SampleConsumer.java
@@ -21,7 +21,6 @@
*******************************************************************************/
package com.att.nsa.mr.test.clients;
-import java.io.IOException;
import java.util.LinkedList;
import org.slf4j.Logger;
@@ -31,12 +30,14 @@ import com.att.nsa.mr.client.MRClientFactory;
import com.att.nsa.mr.client.MRConsumer;
public class SampleConsumer {
+ private SampleConsumer() {
+ }
public static void main ( String[] args )
{
- final Logger LOG = LoggerFactory.getLogger(SampleConsumer.class);
+ final Logger log = LoggerFactory.getLogger(SampleConsumer.class);
- LOG.info("Sample Consumer Class executing");
+ log.info("Sample Consumer Class executing");
final String topic = "com.att.app.dmaap.mr.testingTopic";
final String url = ( args.length > 1 ? args[1] : "localhost:8181" );
final String group = ( args.length > 2 ? args[2] :"grp" );
@@ -61,8 +62,7 @@ public class SampleConsumer {
{
for ( String msg : cc.fetch () )
{
- //System.out.println ( "" + (++count) + ": " + msg );
- LOG.info ( "" + (++count) + ": " + msg );
+ log.info ( "" + (++count) + ": " + msg );
}
if ( count > nextReport )
@@ -73,15 +73,14 @@ public class SampleConsumer {
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" );
- LOG.info ( "Consumed " + count + " in " + elapsedSec + "; " + eps + " eps" );
+ log.info ( "Consumed " + count + " in " + elapsedSec + "; " + eps + " eps" );
}
- LOG.info ( "" + (++count) + ": consumed message" );
+ log.info ( "" + (++count) + ": consumed message" );
}
}
catch ( Exception x )
{
- System.err.println ( x.getClass().getName () + ": " + x.getMessage () );
+ log.error( x.getClass().getName () + ": " + x.getMessage () );
}
}
}
diff --git a/src/main/java/com/att/nsa/mr/test/clients/SimpleExampleConsumer.java b/src/main/java/com/att/nsa/mr/test/clients/SimpleExampleConsumer.java
index 3a131a0..5ae36d2 100644
--- a/src/main/java/com/att/nsa/mr/test/clients/SimpleExampleConsumer.java
+++ b/src/main/java/com/att/nsa/mr/test/clients/SimpleExampleConsumer.java
@@ -22,13 +22,14 @@
package com.att.nsa.mr.test.clients;
-
-
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.Properties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import com.att.nsa.mr.client.MRClientFactory;
import com.att.nsa.mr.client.MRConsumer;
@@ -40,6 +41,7 @@ public class SimpleExampleConsumer
static FileReader routeReader=null;
public static void main ( String[] args )
{
+ final Logger LOG = LoggerFactory.getLogger(SimpleExampleConsumer.class);
long count = 0;
long nextReport = 5000;
@@ -81,6 +83,7 @@ public class SimpleExampleConsumer
catch ( Exception x )
{
System.err.println ( x.getClass().getName () + ": " + x.getMessage () );
+ LOG.error("exception: ", x);
}
}
}
diff --git a/src/main/java/com/att/nsa/mr/test/clients/SimpleExampleConsumerWithReturnResponse.java b/src/main/java/com/att/nsa/mr/test/clients/SimpleExampleConsumerWithReturnResponse.java
index b3c167b..433ab9f 100644
--- a/src/main/java/com/att/nsa/mr/test/clients/SimpleExampleConsumerWithReturnResponse.java
+++ b/src/main/java/com/att/nsa/mr/test/clients/SimpleExampleConsumerWithReturnResponse.java
@@ -26,12 +26,16 @@ import java.io.FileReader;
import java.io.FileWriter;
import java.util.Properties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import com.att.nsa.mr.client.MRClientFactory;
import com.att.nsa.mr.client.MRConsumer;
import com.att.nsa.mr.client.response.MRConsumerResponse;
public class SimpleExampleConsumerWithReturnResponse {
+ private static final Logger LOG = LoggerFactory.getLogger(SimpleExampleConsumerWithReturnResponse.class);
static FileWriter routeWriter= null;
static Properties props=null;
@@ -84,6 +88,7 @@ public class SimpleExampleConsumerWithReturnResponse {
catch ( Exception x )
{
System.err.println ( x.getClass().getName () + ": " + x.getMessage () );
+ LOG.error("exception: ", x);
}
}
diff --git a/src/main/java/com/att/nsa/mr/tools/ApiKeyCommand.java b/src/main/java/com/att/nsa/mr/tools/ApiKeyCommand.java
index 0faefe7..df28fc0 100644
--- a/src/main/java/com/att/nsa/mr/tools/ApiKeyCommand.java
+++ b/src/main/java/com/att/nsa/mr/tools/ApiKeyCommand.java
@@ -24,6 +24,9 @@ package com.att.nsa.mr.tools;
import java.io.IOException;
import java.io.PrintStream;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import com.att.nsa.apiClient.credentials.ApiCredential;
import com.att.nsa.apiClient.http.HttpException;
import com.att.nsa.apiClient.http.HttpObjectNotFoundException;
@@ -36,7 +39,7 @@ import com.att.nsa.mr.client.MRIdentityManager.ApiKey;
public class ApiKeyCommand implements Command<MRCommandContext>
{
-
+ final Logger log = LoggerFactory.getLogger(ApiKeyCommand.class);
@Override
public String[] getMatches ()
{
@@ -104,18 +107,22 @@ public class ApiKeyCommand implements Command<MRCommandContext>
catch ( HttpObjectNotFoundException e )
{
out.println ( "Object not found: " + e.getMessage () );
+ log.error("HttpObjectNotFoundException: ", e);
}
catch ( HttpException e )
{
out.println ( "HTTP exception: " + e.getMessage () );
+ log.error("HttpException: ", e);
}
catch ( MRApiException e )
{
out.println ( "API exception: " + e.getMessage () );
+ log.error("MRApiException: ", e);
}
catch ( IOException e )
{
out.println ( "IO exception: " + e.getMessage () );
+ log.error("IOException: ", e);
}
finally
{
diff --git a/src/main/java/com/att/nsa/mr/tools/MessageCommand.java b/src/main/java/com/att/nsa/mr/tools/MessageCommand.java
index 2c646bf..97216c4 100644
--- a/src/main/java/com/att/nsa/mr/tools/MessageCommand.java
+++ b/src/main/java/com/att/nsa/mr/tools/MessageCommand.java
@@ -26,6 +26,9 @@ import java.io.PrintStream;
import java.util.List;
import java.util.concurrent.TimeUnit;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import com.att.nsa.cmdtool.Command;
import com.att.nsa.cmdtool.CommandNotReadyException;
import com.att.nsa.mr.client.MRBatchingPublisher;
@@ -36,7 +39,7 @@ import com.att.nsa.mr.client.MRPublisher.message;
public class MessageCommand implements Command<MRCommandContext>
{
-
+ final Logger logger = LoggerFactory.getLogger(ApiKeyCommand.class);
@Override
public String[] getMatches ()
{
@@ -73,6 +76,7 @@ public class MessageCommand implements Command<MRCommandContext>
catch ( Exception e )
{
out.println ( "Problem fetching messages: " + e.getMessage() );
+ logger.error("Problem fetching messages: ", e);
}
finally
{
@@ -94,6 +98,7 @@ public class MessageCommand implements Command<MRCommandContext>
catch ( IOException e )
{
out.println ( "Problem sending message: " + e.getMessage() );
+ logger.error("Problem sending message: ", e);
}
finally
{
@@ -105,10 +110,12 @@ public class MessageCommand implements Command<MRCommandContext>
catch ( IOException e )
{
out.println ( "Problem sending message: " + e.getMessage() );
+ logger.error("Problem sending message: ", e);
}
catch ( InterruptedException e )
{
out.println ( "Problem sending message: " + e.getMessage() );
+ logger.error("Problem sending message: ", e);
}
if ( left != null && left.size () > 0 )
{
diff --git a/src/main/java/com/att/nsa/mr/tools/TopicCommand.java b/src/main/java/com/att/nsa/mr/tools/TopicCommand.java
index 8010a58..4b1151e 100644
--- a/src/main/java/com/att/nsa/mr/tools/TopicCommand.java
+++ b/src/main/java/com/att/nsa/mr/tools/TopicCommand.java
@@ -25,6 +25,9 @@ import java.io.IOException;
import java.io.PrintStream;
import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import com.att.nsa.apiClient.http.HttpException;
import com.att.nsa.apiClient.http.HttpObjectNotFoundException;
import com.att.nsa.cmdtool.Command;
@@ -35,7 +38,7 @@ import com.att.nsa.mr.client.MRTopicManager.TopicInfo;
public class TopicCommand implements Command<MRCommandContext>
{
-
+ final Logger logger = LoggerFactory.getLogger(ApiKeyCommand.class);
@Override
public String[] getMatches ()
{
@@ -117,10 +120,12 @@ public class TopicCommand implements Command<MRCommandContext>
catch ( IOException x )
{
out.println ( "Problem with request: " + x.getMessage () );
+ logger.error("IOException: ", x);
}
catch ( HttpObjectNotFoundException e )
{
out.println ( "Not found: " + e.getMessage () );
+ logger.error("HttpObjectNotFoundException: ", e);
}
}
else if ( parts[0].equals ( "create" ) )
@@ -135,14 +140,17 @@ public class TopicCommand implements Command<MRCommandContext>
catch ( HttpException e )
{
out.println ( "Problem with request: " + e.getMessage () );
+ logger.error("HttpException: ", e);
}
catch ( IOException e )
{
out.println ( "Problem with request: " + e.getMessage () );
+ logger.error("IOException: ", e);
}
catch ( NumberFormatException e )
{
out.println ( "Problem with request: " + e.getMessage () );
+ logger.error("NumberFormatException: ", e);
}
}
else if ( parts[0].equals ( "grant" ) )
@@ -161,10 +169,12 @@ public class TopicCommand implements Command<MRCommandContext>
catch ( HttpException e )
{
out.println ( "Problem with request: " + e.getMessage () );
+ logger.error("HttpException: ", e);
}
catch ( IOException e )
{
out.println ( "Problem with request: " + e.getMessage () );
+ logger.error("IOException: ", e);
}
}
else if ( parts[0].equals ( "revoke" ) )
@@ -183,10 +193,12 @@ public class TopicCommand implements Command<MRCommandContext>
catch ( HttpException e )
{
out.println ( "Problem with request: " + e.getMessage () );
+ logger.error("HttpException: ", e);
}
catch ( IOException e )
{
out.println ( "Problem with request: " + e.getMessage () );
+ logger.error("IOException: ", e);
}
}
}