Maintaining code - Move buildRpcError method into AbstractRpcListener 14/12314/2
authorMarian Adamjak <marian.adamjak@pantheon.sk>
Wed, 29 Oct 2014 12:06:57 +0000 (13:06 +0100)
committerMarian Adamjak <marian.adamjak@pantheon.sk>
Wed, 29 Oct 2014 12:37:05 +0000 (13:37 +0100)
                 - remove unused method from ConnectionAdapterImpl

Change-Id: I4d25b566fafd28a307345ebdffadcd14e844f2ee
Signed-off-by: Marian Adamjak <marian.adamjak@pantheon.sk>
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/AbstractRpcListener.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/connection/ConnectionAdapterImpl.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/connection/ResponseExpectedRpcListenerTest.java

index 42f8c66e80fb5ac5f2f14b60f95efd8212012a67..891dc17b162ccc9da1c85eb080bdd01fa1d2f076 100644 (file)
@@ -12,9 +12,11 @@ import io.netty.util.concurrent.GenericFutureListener;
 
 import java.util.Collections;
 
+import org.opendaylight.controller.sal.common.util.RpcErrors;
 import org.opendaylight.controller.sal.common.util.Rpcs;
 import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity;
+import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -30,10 +32,27 @@ import com.google.common.util.concurrent.SettableFuture;
  */
 abstract class AbstractRpcListener<T> implements GenericFutureListener<Future<Void>>, ChannelOutboundQueue.MessageHolder<Object> {
     private static final Logger LOG = LoggerFactory.getLogger(AbstractRpcListener.class);
+    private static final String APPLICATION_TAG = "OPENFLOW_LIBRARY";
+    private static final String TAG = "OPENFLOW";
     private final SettableFuture<RpcResult<T>> result = SettableFuture.create();
     private final String failureInfo;
     private Object message;
 
+    /**
+     * Create RcpError object
+     * @param info
+     * @param severity - error severity
+     * @param message
+     * @param cause - details of reason
+     * @return
+     */
+    static RpcError buildRpcError(final String info, final ErrorSeverity severity, final String message,
+            final Throwable cause) {
+        RpcError error = RpcErrors.getRpcError(APPLICATION_TAG, TAG, info, severity, message,
+                ErrorType.RPC, cause);
+        return error;
+    }
+
     AbstractRpcListener(final Object message, final String failureInfo) {
         this.failureInfo = Preconditions.checkNotNull(failureInfo);
         this.message = Preconditions.checkNotNull(message);
@@ -70,7 +89,7 @@ abstract class AbstractRpcListener<T> implements GenericFutureListener<Future<Vo
     protected abstract void operationSuccessful();
 
     protected final void failedRpc(final Throwable cause) {
-        final RpcError rpcError = ConnectionAdapterImpl.buildRpcError(
+        final RpcError rpcError = buildRpcError(
                 failureInfo, ErrorSeverity.ERROR, "check switch connection", cause);
         result.set(Rpcs.getRpcResult(
                 false,
index c24899fd1c975c7f0c746725f725b5edfa0d1cd4..5ebffd8fc931fc08ce2f6eca66162c96d42bd33b 100644 (file)
@@ -18,7 +18,6 @@ import java.util.concurrent.Future;
 import java.util.concurrent.RejectedExecutionException;
 import java.util.concurrent.TimeUnit;
 
-import org.opendaylight.controller.sal.common.util.RpcErrors;
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput;
@@ -61,9 +60,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.S
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SystemNotificationsListener;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.Notification;
-import org.opendaylight.yangtools.yang.common.RpcError;
-import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity;
-import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -395,28 +391,6 @@ public class ConnectionAdapterImpl implements ConnectionFacade {
         return transportResult;
     }
 
-    /**
-     * @param cause
-     * @return
-     */
-    static RpcError buildRpcError(final String info, final ErrorSeverity severity, final String message,
-            final Throwable cause) {
-        RpcError error = RpcErrors.getRpcError(APPLICATION_TAG, TAG, info, severity, message,
-                ErrorType.RPC, cause);
-        return error;
-    }
-
-    /**
-     * @param cause
-     * @return
-     */
-    protected static RpcError buildTransportError(final String info, final ErrorSeverity severity, final String message,
-            final Throwable cause) {
-        RpcError error = RpcErrors.getRpcError(APPLICATION_TAG, TAG, info, severity, message,
-                ErrorType.TRANSPORT, cause);
-        return error;
-    }
-
     /**
      * @param message
      * @return
index a535c0851b59066018e5f1f5ccecb2a5363bb9e4..aa33498f02a9dce150563535bfd7c20b15db188e 100644 (file)
@@ -66,7 +66,6 @@ public class ResponseExpectedRpcListenerTest {
      */\r
     @Test(expected=NullPointerException.class)\r
     public void testCreation2() {\r
-        RpcResponseKey key = new RpcResponseKey(12345L, BarrierOutput.class.getName());\r
         new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", responseCache, null);\r
     }\r
 \r
@@ -79,7 +78,7 @@ public class ResponseExpectedRpcListenerTest {
         ResponseExpectedRpcListener<OfHeader> listener =\r
                 new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", responseCache, key);\r
         listener.discard();\r
-        RpcError rpcError = ConnectionAdapterImpl.buildRpcError("Failed to send message",\r
+        RpcError rpcError = AbstractRpcListener.buildRpcError("Failed to send message",\r
                 ErrorSeverity.ERROR, "check switch connection", new TimeoutException("Request timed out"));\r
         SettableFuture<RpcResult<?>> result = SettableFuture.create();\r
         result.set(Rpcs.getRpcResult(false, null, Collections.singletonList(rpcError)));\r