+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowplugin.api.openflow.device.exception;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error;
-
-/**
- * @deprecated FIXME: TO BE REMOVED: migrate to org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException.
- */
-@Deprecated
-public class DeviceDataException extends Exception {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private Error error;
-
- public DeviceDataException(final String message) {
- super(message);
- }
-
- public DeviceDataException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
- public DeviceDataException(final String message, final Error error) {
- super(message);
- this.error= error;
- }
-
- public Error getError() {
- return error;
- }
-}
package org.opendaylight.openflowplugin.api.openflow.device.handlers;
import java.util.List;
-
+import org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.device.exception.DeviceDataException;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;
/**
- *
* @author tkubas
- *
*/
public interface DeviceReplyProcessor {
/**
* Method that set future to context in Map
+ *
* @param ofHeader
*/
public void processReply(OfHeader ofHeader);
/**
* Method that set future to context in Map
+ *
* @param xid,
* @param ofHeaderList
*/
/**
* Method that set exception to the future
+ *
* @param xid,
- * @param deviceDataException
+ * @param deviceRequestFailedException
*/
- public void processException(Xid xid, DeviceDataException deviceDataException);
+ public void processException(Xid xid, DeviceRequestFailedException deviceRequestFailedException);
/**
* Method process async flow removed from device
+ *
* @param flowRemoved
*/
public void processFlowRemovedMessage(FlowRemoved flowRemoved);
/**
* Method process async port status from device
+ *
* @param portStatus
*/
public void processPortStatusMessage(PortStatusMessage portStatus);
/**
* Method process async packet in from device
+ *
* @param packetInMessage
*/
public void processPacketInMessage(PacketInMessage packetInMessage);
import org.opendaylight.controller.md.sal.binding.api.ReadTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
+import org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException;
import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandlerRegistration;
import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
import org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.device.exception.DeviceDataException;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceContextClosedHandler;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceDisconnectedHandler;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
}
@Override
- public Long getReservedXid() {
+ public Long getReservedXid() {
return outboundQueueProvider.reserveEntry();
}
}
@Override
- public void processException(final Xid xid, final DeviceDataException deviceDataException) {
- messageSpy.spyMessage(deviceDataException.getClass(), MessageSpy.STATISTIC_GROUP.FROM_SWITCH_PUBLISHED_FAILURE);
+ public void processException(final Xid xid, final DeviceRequestFailedException deviceRequestFailedException) {
+ messageSpy.spyMessage(deviceRequestFailedException.getClass(), MessageSpy.STATISTIC_GROUP.FROM_SWITCH_PUBLISHED_FAILURE);
}
@Override
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
+import org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.device.exception.DeviceDataException;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceReplyProcessor;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
/**
* <p>
- * openflowplugin-api
- * org.opendaylight.openflowplugin.impl.openflow.device
- *
+
* Implementation for {@link MultiMsgCollector} interface
*
* @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
if (cachedRef == null) {
MultipartType multipartType = reply.getType();
LOG.trace("Orphaned multipart msg with XID : {} of type {}", xid, multipartType);
+
deviceReplyProcessor.processException(new Xid(xid),
- new DeviceDataException("unknown xid received for multipart of type " + multipartType));
+ new DeviceRequestFailedException("unknown xid received for multipart of type " + multipartType, getErrorMessageWithXid(xid)));
return;
}
cachedRef.publishCollection(xid); // settable future has now whole collection
cache.invalidate(xid); // we don't need a reference anymore - remove explicitly
}
- } catch (DeviceDataException e) {
+ } catch (DeviceRequestFailedException e) {
deviceReplyProcessor.processException(new Xid(xid), e);
}
}
+ private ErrorMessage getErrorMessageWithXid(final long xid) {
+ final ErrorMessageBuilder errorMessageBuilder = new ErrorMessageBuilder();
+ errorMessageBuilder.setXid(xid);
+ return errorMessageBuilder.build();
+ }
+
@Override
public void setDeviceReplyProcessor(final DeviceReplyProcessor deviceReplyProcessor) {
this.deviceReplyProcessor = deviceReplyProcessor;
@Override
public void invalidateRequestContext(final RequestContext<List<MultipartReply>> requestContext) {
- MultiCollectorObject multiCollectorObject = cache.getIfPresent(requestContext);
- if (null != multiCollectorObject){
+ MultiCollectorObject multiCollectorObject = cache.getIfPresent(requestContext);
+ if (null != multiCollectorObject) {
multiCollectorObject.invalidateFutureByTimeout(requestContext.getXid().getValue());
}
}
this.requestContext = Preconditions.checkNotNull(requestContext);
}
- void add(final MultipartReply reply) throws DeviceDataException {
+ void add(final MultipartReply reply) throws DeviceRequestFailedException {
/* Rise possible exception if it possible */
msgTypeValidation(reply.getType(), reply.getXid());
replyCollection.add(reply);
void invalidateFutureByTimeout(final long key) {
final String msg = "MultiMsgCollector can not wait for last multipart any more";
- DeviceDataException deviceDataException = new DeviceDataException(msg);
+
+ DeviceRequestFailedException deviceDataException = new DeviceRequestFailedException(msg, getErrorMessageWithXid(key));
final RpcResult<List<MultipartReply>> rpcResult = RpcResultBuilder
.<List<MultipartReply>>failed()
.withError(RpcError.ErrorType.APPLICATION, String.format("Message processing failed : %s", deviceDataException.getError()), deviceDataException)
}
- private void msgTypeValidation(final MultipartType type, final long key) throws DeviceDataException {
+ private void msgTypeValidation(final MultipartType type, final long key) throws DeviceRequestFailedException {
if (msgType == null) {
msgType = type;
return;
final String msg = "MultiMsgCollector get incorrect multipart msg with type {}"
+ " but expected type is {}";
LOG.trace(msg, type, msgType);
- throw new DeviceDataException("multipart message type mismatch");
+ throw new DeviceRequestFailedException("multipart message type mismatch", getErrorMessageWithXid(key));
}
}
}
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
+import org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.device.exception.DeviceDataException;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceReplyProcessor;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
import org.opendaylight.openflowplugin.impl.connection.testutil.MsgGeneratorTestUtils;
@Mock
DeviceReplyProcessor deviceProcessor;
@Captor
- ArgumentCaptor<DeviceDataException> ddeCaptor;
+ ArgumentCaptor<DeviceRequestFailedException> ddeCaptor;
@Captor
ArgumentCaptor<Xid> xidCaptor;
@Captor