Search in sources :

Example 6 with DeviceContext

use of org.opendaylight.openflowplugin.api.openflow.device.DeviceContext in project openflowplugin by opendaylight.

the class MultipartReplyTranslatorTest method testTranslateFlow.

@Test
public void testTranslateFlow() {
    DeviceContext mockedDeviceContext = mock(DeviceContext.class);
    MultipartReplyMessage multipartReplyMessage = prepareMocks(mockedDeviceContext, prepareMultipartReplyFlow(), MultipartType.OFPMPFLOW);
    DataContainer result = MultipartReplyTranslatorUtil.translate(multipartReplyMessage, mockedDeviceContext.getDeviceInfo(), CONVERTOR_MANAGER, mockedDeviceContext.oook()).get();
    DataContainer dataObject = validateOutput(result);
    assertTrue(dataObject instanceof FlowAndStatisticsMapList);
}
Also used : DeviceContext(org.opendaylight.openflowplugin.api.openflow.device.DeviceContext) MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) DataContainer(org.opendaylight.yangtools.yang.binding.DataContainer) FlowAndStatisticsMapList(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowAndStatisticsMapList) Test(org.junit.Test)

Example 7 with DeviceContext

use of org.opendaylight.openflowplugin.api.openflow.device.DeviceContext in project openflowplugin by opendaylight.

the class MultipartReplyTranslatorTest method testTranslatePortStats.

@Test
public void testTranslatePortStats() {
    DeviceContext mockedDeviceContext = mock(DeviceContext.class);
    MultipartReplyMessage multipartReplyMessage = prepareMocks(mockedDeviceContext, prepareMultipartReplyPortStats(), MultipartType.OFPMPPORTSTATS);
    DataContainer result = MultipartReplyTranslatorUtil.translate(multipartReplyMessage, mockedDeviceContext.getDeviceInfo(), CONVERTOR_MANAGER, mockedDeviceContext.oook()).get();
    DataContainer dataObject = validateOutput(result);
    assertTrue(dataObject instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsAndPortNumberMap);
    org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsAndPortNumberMap nodeConnectorStatisticsUpdate = (org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsAndPortNumberMap) dataObject;
    List<NodeConnectorStatisticsAndPortNumberMap> nodeConnectorStatisticsAndPortNumberMaps = nodeConnectorStatisticsUpdate.getNodeConnectorStatisticsAndPortNumberMap();
    assertEquals(1, nodeConnectorStatisticsAndPortNumberMaps.size());
    NodeConnectorStatisticsAndPortNumberMap nodeConnectorStatisticsAndPortNumberMap = nodeConnectorStatisticsAndPortNumberMaps.get(0);
    assertEquals("openflow:" + DUMMY_DATAPATH_ID + ":" + DUMMY_PORT_NO, nodeConnectorStatisticsAndPortNumberMap.getNodeConnectorId().getValue());
    assertEquals(DUMMY_RX_BYTES, nodeConnectorStatisticsAndPortNumberMap.getBytes().getReceived());
    assertEquals(DUMMY_TX_BYTES, nodeConnectorStatisticsAndPortNumberMap.getBytes().getTransmitted());
    assertEquals(DUMMY_RX_PACKETS, nodeConnectorStatisticsAndPortNumberMap.getPackets().getReceived());
    assertEquals(DUMMY_TX_PACKETS, nodeConnectorStatisticsAndPortNumberMap.getPackets().getTransmitted());
    assertEquals(DUMMY_COLLISIONS, nodeConnectorStatisticsAndPortNumberMap.getCollisionCount());
    assertEquals(DUMMY_RX_CRC_ERR, nodeConnectorStatisticsAndPortNumberMap.getReceiveCrcError());
    assertEquals(DUMMY_RX_DROPPED, nodeConnectorStatisticsAndPortNumberMap.getReceiveDrops());
    assertEquals(DUMMY_RX_ERRORS, nodeConnectorStatisticsAndPortNumberMap.getReceiveErrors());
    assertEquals(DUMMY_RX_FRAME_ERR, nodeConnectorStatisticsAndPortNumberMap.getReceiveFrameError());
    assertEquals(DUMMY_OVER_ERR, nodeConnectorStatisticsAndPortNumberMap.getReceiveOverRunError());
    assertEquals(DUMMY_TX_DROPPED, nodeConnectorStatisticsAndPortNumberMap.getTransmitDrops());
    assertEquals(DUMMY_TX_ERRORS, nodeConnectorStatisticsAndPortNumberMap.getTransmitErrors());
}
Also used : MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) DeviceContext(org.opendaylight.openflowplugin.api.openflow.device.DeviceContext) DataContainer(org.opendaylight.yangtools.yang.binding.DataContainer) NodeConnectorStatisticsAndPortNumberMap(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap) Test(org.junit.Test)

Example 8 with DeviceContext

use of org.opendaylight.openflowplugin.api.openflow.device.DeviceContext in project openflowplugin by opendaylight.

the class DeviceManagerImpl method createContext.

@Override
public DeviceContext createContext(@Nonnull final ConnectionContext connectionContext) {
    LOG.info("ConnectionEvent: Device connected to controller, Device:{}, NodeId:{}", connectionContext.getConnectionAdapter().getRemoteAddress(), connectionContext.getDeviceInfo().getNodeId());
    connectionContext.getConnectionAdapter().setPacketInFiltering(true);
    final OutboundQueueProvider outboundQueueProvider = new OutboundQueueProviderImpl(connectionContext.getDeviceInfo().getVersion());
    connectionContext.setOutboundQueueProvider(outboundQueueProvider);
    final OutboundQueueHandlerRegistration<OutboundQueueProvider> outboundQueueHandlerRegistration = connectionContext.getConnectionAdapter().registerOutboundQueueHandler(outboundQueueProvider, config.getBarrierCountLimit().getValue(), TimeUnit.MILLISECONDS.toNanos(config.getBarrierIntervalTimeoutLimit().getValue()));
    connectionContext.setOutboundQueueHandleRegistration(outboundQueueHandlerRegistration);
    final DeviceContext deviceContext = new DeviceContextImpl(connectionContext, dataBroker, messageSpy, translatorLibrary, convertorExecutor, config.isSkipTableFeatures(), hashedWheelTimer, config.isUseSingleLayerSerialization(), deviceInitializerProvider, config.isEnableFlowRemovedNotification(), config.isSwitchFeaturesMandatory(), contextChainHolder);
    ((ExtensionConverterProviderKeeper) deviceContext).setExtensionConverterProvider(extensionConverterProvider);
    deviceContext.setNotificationPublishService(notificationPublishService);
    deviceContexts.put(connectionContext.getDeviceInfo(), deviceContext);
    updatePacketInRateLimiters();
    final OpenflowProtocolListenerFullImpl messageListener = new OpenflowProtocolListenerFullImpl(connectionContext.getConnectionAdapter(), deviceContext);
    connectionContext.getConnectionAdapter().setMessageListener(messageListener);
    connectionContext.getConnectionAdapter().setAlienMessageListener(messageListener);
    return deviceContext;
}
Also used : OutboundQueueProvider(org.opendaylight.openflowplugin.api.openflow.connection.OutboundQueueProvider) DeviceContext(org.opendaylight.openflowplugin.api.openflow.device.DeviceContext) OpenflowProtocolListenerFullImpl(org.opendaylight.openflowplugin.impl.device.listener.OpenflowProtocolListenerFullImpl) OutboundQueueProviderImpl(org.opendaylight.openflowplugin.impl.connection.OutboundQueueProviderImpl) ExtensionConverterProviderKeeper(org.opendaylight.openflowplugin.extension.api.ExtensionConverterProviderKeeper)

Example 9 with DeviceContext

use of org.opendaylight.openflowplugin.api.openflow.device.DeviceContext in project openflowplugin by opendaylight.

the class DeviceManagerImplTest method close.

@Test
public void close() throws Exception {
    final DeviceContext deviceContext = mock(DeviceContext.class);
    final ConcurrentHashMap<DeviceInfo, DeviceContext> deviceContexts = getContextsCollection(deviceManager);
    deviceContexts.put(deviceInfo, deviceContext);
    Assert.assertEquals(1, deviceContexts.size());
    deviceManager.close();
    verify(deviceContext).close();
}
Also used : DeviceContext(org.opendaylight.openflowplugin.api.openflow.device.DeviceContext) DeviceInfo(org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo) Test(org.junit.Test)

Example 10 with DeviceContext

use of org.opendaylight.openflowplugin.api.openflow.device.DeviceContext in project openflowplugin by opendaylight.

the class DeviceManagerImplTest method createContext.

@Test
public void createContext() throws Exception {
    final DeviceContext context = deviceManager.createContext(mockConnectionContext);
    assertEquals(deviceInfo, context.getDeviceInfo());
}
Also used : DeviceContext(org.opendaylight.openflowplugin.api.openflow.device.DeviceContext) Test(org.junit.Test)

Aggregations

DeviceContext (org.opendaylight.openflowplugin.api.openflow.device.DeviceContext)10 Test (org.junit.Test)7 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)5 DataContainer (org.opendaylight.yangtools.yang.binding.DataContainer)5 DeviceInfo (org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Function (com.google.common.base.Function)1 Preconditions (com.google.common.base.Preconditions)1 AsyncFunction (com.google.common.util.concurrent.AsyncFunction)1 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 Futures (com.google.common.util.concurrent.Futures)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Future (java.util.concurrent.Future)1 Collectors (java.util.stream.Collectors)1 Nonnull (javax.annotation.Nonnull)1