Replaced use of logger abstraction COPSDebug.java to having this class log directly... 81/18481/1
authorSteven Pisarski <s.pisarski@cablelabs.com>
Thu, 16 Apr 2015 20:02:55 +0000 (14:02 -0600)
committerSteven Pisarski <s.pisarski@cablelabs.com>
Thu, 16 Apr 2015 20:02:55 +0000 (14:02 -0600)
Change-Id: I80861f13e32a05861efd01ad187d6cde20080582
Signed-off-by: Steven Pisarski <s.pisarski@cablelabs.com>
packetcable-driver/src/main/java/org/pcmm/PCMMPepAgent.java

index 394bdf13fdfec45faa3834d02063a2edddd5ccf8..263a8db9aeeddd8655683bc5f121a2c774c37747 100644 (file)
@@ -4,27 +4,16 @@
 
 package org.pcmm;
 
-import java.io.IOException;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.UnknownHostException;
-
-import org.umu.cops.common.COPSDebug;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.umu.cops.prpep.COPSPepAgent;
 import org.umu.cops.prpep.COPSPepConnection;
 import org.umu.cops.prpep.COPSPepException;
-import org.umu.cops.stack.COPSAcctTimer;
-import org.umu.cops.stack.COPSClientAcceptMsg;
-import org.umu.cops.stack.COPSClientCloseMsg;
-import org.umu.cops.stack.COPSClientOpenMsg;
-import org.umu.cops.stack.COPSData;
-import org.umu.cops.stack.COPSError;
-import org.umu.cops.stack.COPSException;
-import org.umu.cops.stack.COPSHeader;
-import org.umu.cops.stack.COPSKATimer;
-import org.umu.cops.stack.COPSMsg;
-import org.umu.cops.stack.COPSPepId;
-import org.umu.cops.stack.COPSTransceiver;
+import org.umu.cops.stack.*;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
 
 /**
  * This is a provisioning COPS PEP. Responsible for making connection to the PDP
@@ -32,6 +21,8 @@ import org.umu.cops.stack.COPSTransceiver;
  */
 public class PCMMPepAgent extends COPSPepAgent implements Runnable {
 
+    public final static Logger logger = LoggerFactory.getLogger(PCMMPepAgent.class);
+
     /** Well-known port for COPS */
     public static final int WELL_KNOWN_CMTS_PORT = 3918;
 
@@ -80,8 +71,7 @@ public class PCMMPepAgent extends COPSPepAgent implements Runnable {
     public void run() {
         try {
 
-            COPSDebug.err(getClass().getName(), "Create Server Socket on Port "
-                          + serverPort);
+            logger.info("Create Server Socket on Port " + serverPort);
 
             serverSocket = new ServerSocket(serverPort);
             // Loop through for Incoming messages
@@ -92,8 +82,7 @@ public class PCMMPepAgent extends COPSPepAgent implements Runnable {
                 // Wait for an incoming connection from a PEP
                 Socket socket = serverSocket.accept();
 
-                COPSDebug.err(getClass().getName(), "New connection accepted "
-                              + socket.getInetAddress() + ":" + socket.getPort());
+                logger.info("New connection accepted " + socket.getInetAddress() + ":" + socket.getPort());
 
                 processConnection(socket);
                 /**
@@ -104,12 +93,8 @@ public class PCMMPepAgent extends COPSPepAgent implements Runnable {
                  */
 
             }
-        } catch (IOException e) {
-            COPSDebug.err(getClass().getName(), COPSDebug.ERROR_SOCKET, e);
-        } catch (COPSException e) {
-            COPSDebug.err(getClass().getName(), COPSDebug.ERROR_SOCKET, e);
-        } catch (COPSPepException e) {
-            COPSDebug.err(getClass().getName(), COPSDebug.ERROR_SOCKET, e);
+        } catch (Exception e) {
+            logger.error("Error while processing the socket connection", e);
         }
     }
 
@@ -130,15 +115,12 @@ public class PCMMPepAgent extends COPSPepAgent implements Runnable {
      *
      * Not send [<PDPRedirAddr>], [<Integrity>]
      *
-     * @throws UnknownHostException
      * @throws IOException
      * @throws COPSException
      * @throws COPSPepException
      *
      */
-    private COPSPepConnection processConnection(Socket socket)
-    throws UnknownHostException, IOException, COPSException,
-                COPSPepException {
+    private COPSPepConnection processConnection(Socket socket) throws IOException, COPSException, COPSPepException {
         // Build OPN
         COPSHeader hdr = new COPSHeader(COPSHeader.COPS_OP_OPN, getClientType());
 
@@ -155,15 +137,15 @@ public class PCMMPepAgent extends COPSPepAgent implements Runnable {
          * InetAddress addr = InetAddress.getByName(psHost); Socket socket = new
          * Socket(addr,psPort);
          */
-        COPSDebug.err(getClass().getName(), "Send COPSClientOpenMsg to PDP");
+        logger.info("Send COPSClientOpenMsg to PDP");
         msg.writeData(socket);
 
         // Receive the response
-        COPSDebug.err(getClass().getName(), "Receive the resposne from PDP");
+        logger.info("Receive the resposne from PDP");
         COPSMsg recvmsg = COPSTransceiver.receiveMsg(socket);
 
         if (recvmsg.getHeader().isAClientAccept()) {
-            COPSDebug.err(getClass().getName(), "isAClientAccept from PDP");
+            logger.info("isAClientAccept from PDP");
             COPSClientAcceptMsg cMsg = (COPSClientAcceptMsg) recvmsg;
 
             // Support
@@ -189,12 +171,12 @@ public class PCMMPepAgent extends COPSPepAgent implements Runnable {
                     socket);
             conn.setKaTimer(_kaTimeVal);
             conn.setAcctTimer(_acctTimer);
-            COPSDebug.err(getClass().getName(), "Thread(conn).start");
+            logger.info("Thread(conn).start");
             new Thread(conn).start();
 
             return conn;
         } else if (recvmsg.getHeader().isAClientClose()) {
-            COPSDebug.err(getClass().getName(), "isAClientClose from PDP");
+            logger.info("isAClientClose from PDP");
             COPSClientCloseMsg cMsg = (COPSClientCloseMsg) recvmsg;
             error = cMsg.getError();
             socket.close();