Fix for Sonar major issues 33/13133/2
authorrama-huawei <rama.subba.reddy.s@huawei.com>
Mon, 18 Sep 2017 12:27:39 +0000 (17:57 +0530)
committerRama SubbaReddy <rama.subba.reddy.s@huawei.com>
Mon, 18 Sep 2017 12:31:35 +0000 (12:31 +0000)
DCAEGEN2-93

Change-Id: I0c1d6a75644b8e6f7e8f06dd2e2abcb185a94efb
Signed-off-by: rama-huawei <rama.subba.reddy.s@huawei.com>
src/main/java/com/att/nsa/mr/logging/MRAppender.java
src/main/java/com/att/nsa/mr/test/clients/ConsolePublisher.java

index 364f36d..4bb3e71 100644 (file)
@@ -106,6 +106,7 @@ public class MRAppender extends AppenderSkeleton {
                }
        }
 
+        @Override
        public void activateOptions() {
                if (hosts != null && topic != null && partition != null) {
                        fPublisher = MRClientFactory.createBatchingPublisher(hosts.split(","), topic, maxBatchSize, maxAgeMs, compress);
index 2294d7b..61aa836 100644 (file)
@@ -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 );
                        }
                }
        }