Search in sources :

Example 1 with RpcContext

use of org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext in project openflowplugin by opendaylight.

the class ContextChainHolderImpl method createContextChain.

@VisibleForTesting
void createContextChain(final ConnectionContext connectionContext) {
    final DeviceInfo deviceInfo = connectionContext.getDeviceInfo();
    final DeviceContext deviceContext = deviceManager.createContext(connectionContext);
    deviceContext.registerMastershipWatcher(this);
    LOG.debug("Device" + CONTEXT_CREATED_FOR_CONNECTION, deviceInfo);
    final RpcContext rpcContext = rpcManager.createContext(deviceContext);
    rpcContext.registerMastershipWatcher(this);
    LOG.debug("RPC" + CONTEXT_CREATED_FOR_CONNECTION, deviceInfo);
    final StatisticsContext statisticsContext = statisticsManager.createContext(deviceContext, ownershipChangeListener.isReconciliationFrameworkRegistered());
    statisticsContext.registerMastershipWatcher(this);
    LOG.debug("Statistics" + CONTEXT_CREATED_FOR_CONNECTION, deviceInfo);
    final RoleContext roleContext = roleManager.createContext(deviceContext);
    roleContext.registerMastershipWatcher(this);
    LOG.debug("Role" + CONTEXT_CREATED_FOR_CONNECTION, deviceInfo);
    final ContextChain contextChain = new ContextChainImpl(this, connectionContext, executorService);
    contextChain.registerDeviceRemovedHandler(deviceManager);
    contextChain.registerDeviceRemovedHandler(rpcManager);
    contextChain.registerDeviceRemovedHandler(statisticsManager);
    contextChain.registerDeviceRemovedHandler(roleManager);
    contextChain.registerDeviceRemovedHandler(this);
    contextChain.addContext(deviceContext);
    contextChain.addContext(rpcContext);
    contextChain.addContext(statisticsContext);
    contextChain.addContext(roleContext);
    contextChainMap.put(deviceInfo, contextChain);
    connectingDevices.remove(deviceInfo);
    LOG.debug("Context chain" + CONTEXT_CREATED_FOR_CONNECTION, deviceInfo);
    deviceContext.onPublished();
    contextChain.registerServices(singletonServiceProvider);
}
Also used : RpcContext(org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext) DeviceContext(org.opendaylight.openflowplugin.api.openflow.device.DeviceContext) RoleContext(org.opendaylight.openflowplugin.api.openflow.role.RoleContext) DeviceInfo(org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo) StatisticsContext(org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext) ContextChain(org.opendaylight.openflowplugin.api.openflow.lifecycle.ContextChain) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 2 with RpcContext

use of org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext in project openflowplugin by opendaylight.

the class RpcManagerImplTest method createContext.

@Test
public void createContext() throws Exception {
    final RpcContext context = rpcManager.createContext(deviceContext);
    assertEquals(deviceInfo, context.getDeviceInfo());
}
Also used : RpcContext(org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext) Test(org.junit.Test)

Example 3 with RpcContext

use of org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext in project openflowplugin by opendaylight.

the class RpcContextImplTest method testStoreOrFail.

@Test
public void testStoreOrFail() throws Exception {
    try (RpcContext rpcContext = new RpcContextImpl(rpcProviderRegistry, 100, deviceContext, extensionConverterProvider, convertorExecutor, notificationPublishService, true)) {
        final RequestContext<?> requestContext = rpcContext.createRequestContext();
        assertNotNull(requestContext);
    }
}
Also used : RpcContext(org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext) Test(org.junit.Test)

Example 4 with RpcContext

use of org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext in project openflowplugin by opendaylight.

the class RpcContextImplTest method testStoreOrFailThatFails.

@Test
public void testStoreOrFailThatFails() throws Exception {
    try (RpcContext rpcContext = new RpcContextImpl(rpcProviderRegistry, 0, deviceContext, extensionConverterProvider, convertorExecutor, notificationPublishService, true)) {
        final RequestContext<?> requestContext = rpcContext.createRequestContext();
        assertNull(requestContext);
    }
}
Also used : RpcContext(org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext) Test(org.junit.Test)

Example 5 with RpcContext

use of org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext in project openflowplugin by opendaylight.

the class RpcContextImplTest method testStoreAndCloseOrFail.

@Test
public void testStoreAndCloseOrFail() throws Exception {
    try (RpcContext rpcContext = new RpcContextImpl(rpcProviderRegistry, 100, deviceContext, extensionConverterProvider, convertorExecutor, notificationPublishService, true)) {
        final RequestContext<?> requestContext = rpcContext.createRequestContext();
        assertNotNull(requestContext);
        requestContext.close();
        verify(messageSpy).spyMessage(RpcContextImpl.class, MessageSpy.StatisticsGroup.REQUEST_STACK_FREED);
    }
}
Also used : RpcContext(org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext) Test(org.junit.Test)

Aggregations

RpcContext (org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext)5 Test (org.junit.Test)4 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 DeviceContext (org.opendaylight.openflowplugin.api.openflow.device.DeviceContext)1 DeviceInfo (org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo)1 ContextChain (org.opendaylight.openflowplugin.api.openflow.lifecycle.ContextChain)1 RoleContext (org.opendaylight.openflowplugin.api.openflow.role.RoleContext)1 StatisticsContext (org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext)1