package org.opendaylight.openflowplugin.api.openflow.device;
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-
import io.netty.util.Timeout;
import java.math.BigInteger;
import java.util.Map;
import org.opendaylight.controller.md.sal.binding.api.ReadTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
import org.opendaylight.openflowplugin.api.openflow.OpenflowPluginTimer;
import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceReplyProcessor;
* <p>
* Created by Martin Bobak <mbobak@cisco.com> on 25.2.2015.
*/
-public interface DeviceContext extends AutoCloseable,OpenflowPluginTimer, MessageHandler, TranslatorLibrarian, OutstandingMessageExtractor, DeviceReplyProcessor {
+public interface DeviceContext extends AutoCloseable, OpenflowPluginTimer, MessageHandler, TranslatorLibrarian, OutstandingMessageExtractor, DeviceReplyProcessor {
/**
/**
* Method generates unique XID value.
+ *
* @return
*/
Xid getNextXid();
/**
* Method returns registered {@link org.opendaylight.openflowplugin.api.openflow.device.listener.OpenflowMessageListenerFacade}
+ *
* @return
*/
OpenflowMessageListenerFacade getOpenflowMessageListenerFacade();
/**
* Method exposes flow registry used for storing flow ids identified by calculated flow hash.
+ *
* @return
*/
DeviceFlowRegistry getDeviceFlowRegistry();
+
/**
* Method exposes device group registry used for storing group ids.
+ *
* @return
*/
DeviceGroupRegistry getDeviceGroupRegistry();
+
/**
* Method exposes device meter registry used for storing meter ids.
+ *
* @return
*/
DeviceMeterRegistry getDeviceMeterRegistry();
-
/**
* store cancellable timeout handler of currently running barrier task
*/
/**
* Sets notification service
+ *
* @param notificationService
*/
void setNotificationService(NotificationProviderService notificationService);
import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry;
import org.opendaylight.openflowplugin.api.openflow.registry.group.DeviceGroupRegistry;
import org.opendaylight.openflowplugin.api.openflow.registry.meter.DeviceMeterRegistry;
+import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
import org.opendaylight.openflowplugin.impl.common.NodeStaticReplyTranslatorUtil;
import org.opendaylight.openflowplugin.impl.registry.flow.DeviceFlowRegistryImpl;
import org.opendaylight.openflowplugin.impl.registry.group.DeviceGroupRegistryImpl;
private final DeviceMeterRegistry deviceMeterRegistry;
private Timeout barrierTaskTimeout;
private NotificationProviderService notificationService;
+ private final MessageSpy messageSpy;
+
@VisibleForTesting
DeviceContextImpl(@Nonnull final ConnectionContext primaryConnectionContext,
- @Nonnull final DeviceState deviceState, @Nonnull final DataBroker dataBroker,
- @Nonnull final HashedWheelTimer hashedWheelTimer) {
+ @Nonnull final DeviceState deviceState,
+ @Nonnull final DataBroker dataBroker,
+ @Nonnull final HashedWheelTimer hashedWheelTimer,
+ @Nonnull final MessageSpy _messageSpy) {
this.primaryConnectionContext = Preconditions.checkNotNull(primaryConnectionContext);
this.deviceState = Preconditions.checkNotNull(deviceState);
this.dataBroker = Preconditions.checkNotNull(dataBroker);
deviceFlowRegistry = new DeviceFlowRegistryImpl();
deviceGroupRegistry = new DeviceGroupRegistryImpl();
deviceMeterRegistry = new DeviceMeterRegistryImpl();
+ messageSpy = _messageSpy;
}
/**
import org.opendaylight.openflowplugin.impl.device.listener.OpenflowProtocolListenerFullImpl;
import org.opendaylight.openflowplugin.impl.rpc.RequestContextImpl;
import org.opendaylight.openflowplugin.impl.services.OFJResult2RequestCtxFuture;
+import org.opendaylight.openflowplugin.impl.statistics.ofpspecific.MessageIntelligenceAgencyImpl;
import org.opendaylight.openflowplugin.impl.util.DeviceStateUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder;
private NotificationProviderService notificationService;
private final List<DeviceContext> synchronizedDeviceContextsList = Collections
.<DeviceContext>synchronizedList(new ArrayList<DeviceContext>());
+ private final MessageIntelligenceAgency messageIntelligenceAgency = new MessageIntelligenceAgencyImpl();
public DeviceManagerImpl(@Nonnull final DataBroker dataBroker) {
this.dataBroker = Preconditions.checkNotNull(dataBroker);
final DeviceState deviceState = new DeviceStateImpl(connectionContext.getFeatures(), connectionContext.getNodeId());
- final DeviceContextImpl deviceContext = new DeviceContextImpl(connectionContext, deviceState, dataBroker, hashedWheelTimer);
+ final DeviceContextImpl deviceContext = new DeviceContextImpl(connectionContext, deviceState, dataBroker, hashedWheelTimer, messageIntelligenceAgency);
deviceContext.setNotificationService(notificationService);
deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, deviceState.getNodeInstanceIdentifier(), new NodeBuilder().setId(deviceState.getNodeId()).build());
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
+
import com.google.common.util.concurrent.SettableFuture;
import io.netty.util.HashedWheelTimer;
import java.util.ArrayList;
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.statistics.ofpspecific.MessageIntelligenceAgency;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder;
BindingTransactionChain txChainFactory;
@Mock
HashedWheelTimer timer;
+ @Mock
+ MessageIntelligenceAgency messageIntelligenceAgency;
@Before
public void setUp() {
Mockito.when(txChainFactory.newWriteOnlyTransaction()).thenReturn(wTx);
Mockito.when(dataBroker.newReadOnlyTransaction()).thenReturn(rTx);
- deviceContext = new DeviceContextImpl(connectionContext, deviceState, dataBroker, timer);
+ deviceContext = new DeviceContextImpl(connectionContext, deviceState, dataBroker, timer, messageIntelligenceAgency);
xid = deviceContext.getNextXid();
xidMulti = deviceContext.getNextXid();
}
@Test(expected = NullPointerException.class)
public void testDeviceContextImplConstructorNullConnectionContext() {
- new DeviceContextImpl(null, deviceState, dataBroker, timer);
+ new DeviceContextImpl(null, deviceState, dataBroker, timer, messageIntelligenceAgency);
}
@Test(expected = NullPointerException.class)
public void testDeviceContextImplConstructorNullDataBroker() {
- new DeviceContextImpl(connectionContext, deviceState, null, timer);
+ new DeviceContextImpl(connectionContext, deviceState, null, timer, messageIntelligenceAgency);
}
@Test(expected = NullPointerException.class)
public void testDeviceContextImplConstructorNullDeviceState() {
- new DeviceContextImpl(connectionContext, null, dataBroker, timer);
+ new DeviceContextImpl(connectionContext, null, dataBroker, timer, messageIntelligenceAgency);
}
@Test(expected = NullPointerException.class)
public void testDeviceContextImplConstructorNullTimer() {
- new DeviceContextImpl(null, deviceState, dataBroker, null);
+ new DeviceContextImpl(null, deviceState, dataBroker, null, messageIntelligenceAgency);
}
@Test
private static GetAsyncOutput createAsyncOutput(final Xid xid) {
final GetAsyncOutputBuilder asyncOutputBuilder = new GetAsyncOutputBuilder();
- asyncOutputBuilder.setFlowRemovedMask(Collections.<FlowRemovedMask> emptyList());
- asyncOutputBuilder.setPacketInMask(Collections.<PacketInMask> emptyList());
- asyncOutputBuilder.setPortStatusMask(Collections.<PortStatusMask> emptyList());
+ asyncOutputBuilder.setFlowRemovedMask(Collections.<FlowRemovedMask>emptyList());
+ asyncOutputBuilder.setPacketInMask(Collections.<PacketInMask>emptyList());
+ asyncOutputBuilder.setPortStatusMask(Collections.<PortStatusMask>emptyList());
asyncOutputBuilder.setVersion(OFConstants.OFP_VERSION_1_3);
asyncOutputBuilder.setXid(xid.getValue());
return asyncOutputBuilder.build();
private static List<MultipartReply> createMultipartReplyList(final Xid xid) {
final MultipartReplyDesc descValue = new MultipartReplyDescBuilder().setHwDesc("hw-test-value").build();
final MultipartReplyDescCase replyBody = new MultipartReplyDescCaseBuilder()
- .setMultipartReplyDesc(descValue).build();
+ .setMultipartReplyDesc(descValue).build();
final List<MultipartReply> multipartReplies = new ArrayList<>();
multipartReplies.add(new MultipartReplyMessageBuilder()
.setMultipartReplyBody(replyBody)
LOG.info("Checking RequestContext.future");
try {
- final Object object = requestContext.getFuture().get(1L, TimeUnit.SECONDS);
- final RpcResult<OfHeader> rpcResult = (RpcResult<OfHeader>) object;
- Assert.assertFalse(rpcResult.isSuccessful());
- final List<RpcError> errors = (List<RpcError>) rpcResult.getErrors();
- Assert.assertTrue(errors.get(0).getCause() instanceof DeviceDataException);
- final DeviceDataException cause = (DeviceDataException) errors.get(0).getCause();
- Assert.assertTrue(cause.getCause() instanceof NullPointerException);
+ final Object object = requestContext.getFuture().get(1L, TimeUnit.SECONDS);
+ final RpcResult<OfHeader> rpcResult = (RpcResult<OfHeader>) object;
+ Assert.assertFalse(rpcResult.isSuccessful());
+ final List<RpcError> errors = (List<RpcError>) rpcResult.getErrors();
+ Assert.assertTrue(errors.get(0).getCause() instanceof DeviceDataException);
+ final DeviceDataException cause = (DeviceDataException) errors.get(0).getCause();
+ Assert.assertTrue(cause.getCause() instanceof NullPointerException);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
LOG.error("Test failed when checking RequestContext.future", e);
fail("fail");