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;
*/
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);
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,
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;
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;
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
*/\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
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