Search in sources :

Example 1 with StatisticsContext

use of org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext 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 StatisticsContext

use of org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext in project openflowplugin by opendaylight.

the class StatisticsManagerImplTest method testChangeStatisticsWorkMode2.

/**
 * Switching to {@link StatisticsWorkMode#FULLYDISABLED}; with pollTimeout and lifecycleRegistry.
 */
@Test
public void testChangeStatisticsWorkMode2() throws Exception {
    final StatisticsContext statisticContext = Mockito.mock(StatisticsContext.class);
    getContextsMap(statisticsManager).put(deviceInfo, statisticContext);
    final ChangeStatisticsWorkModeInputBuilder changeStatisticsWorkModeInputBld = new ChangeStatisticsWorkModeInputBuilder().setMode(StatisticsWorkMode.FULLYDISABLED);
    Future<RpcResult<Void>> workMode = statisticsManager.changeStatisticsWorkMode(changeStatisticsWorkModeInputBld.build());
    checkWorkModeChangeOutcome(workMode);
    verify(statisticContext).disableGathering();
}
Also used : ChangeStatisticsWorkModeInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.ChangeStatisticsWorkModeInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) StatisticsContext(org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext) Test(org.junit.Test)

Example 3 with StatisticsContext

use of org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext in project openflowplugin by opendaylight.

the class StatisticsManagerImplTest method testChangeStatisticsWorkMode3.

/**
 * Tests switching to {@link StatisticsWorkMode#FULLYDISABLED} and back
 * to {@link StatisticsWorkMode#COLLECTALL}; with lifecycleRegistry and pollTimeout.
 */
@Test
public void testChangeStatisticsWorkMode3() throws Exception {
    final StatisticsContext statisticContext = Mockito.mock(StatisticsContext.class);
    getContextsMap(statisticsManager).put(deviceInfo, statisticContext);
    final ChangeStatisticsWorkModeInputBuilder changeStatisticsWorkModeInputBld = new ChangeStatisticsWorkModeInputBuilder().setMode(StatisticsWorkMode.FULLYDISABLED);
    Future<RpcResult<Void>> workMode;
    workMode = statisticsManager.changeStatisticsWorkMode(changeStatisticsWorkModeInputBld.build());
    checkWorkModeChangeOutcome(workMode);
    verify(statisticContext).disableGathering();
    changeStatisticsWorkModeInputBld.setMode(StatisticsWorkMode.COLLECTALL);
    workMode = statisticsManager.changeStatisticsWorkMode(changeStatisticsWorkModeInputBld.build());
    checkWorkModeChangeOutcome(workMode);
    verify(statisticContext).enableGathering();
}
Also used : ChangeStatisticsWorkModeInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.ChangeStatisticsWorkModeInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) StatisticsContext(org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext) Test(org.junit.Test)

Example 4 with StatisticsContext

use of org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext in project openflowplugin by opendaylight.

the class StatisticsManagerImpl method createContext.

@Override
public StatisticsContext createContext(@Nonnull final DeviceContext deviceContext, final boolean useReconciliationFramework) {
    final MultipartWriterProvider statisticsWriterProvider = MultipartWriterProviderFactory.createDefaultProvider(deviceContext);
    final StatisticsContext statisticsContext = new StatisticsContextImpl<>(deviceContext, converterExecutor, statisticsWriterProvider, executorService, config, !isStatisticsFullyDisabled && config.isIsStatisticsPollingOn(), useReconciliationFramework);
    contexts.put(deviceContext.getDeviceInfo(), statisticsContext);
    return statisticsContext;
}
Also used : MultipartWriterProvider(org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProvider) StatisticsContext(org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext)

Example 5 with StatisticsContext

use of org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext in project openflowplugin by opendaylight.

the class StatisticsManagerImplTest method testChangeStatisticsWorkMode1.

/**
 * switching to {@link StatisticsWorkMode#FULLYDISABLED}; no pollTimeout and no lifecycleRegistry.
 */
@Test
public void testChangeStatisticsWorkMode1() throws Exception {
    final StatisticsContext statisticContext = Mockito.mock(StatisticsContext.class);
    getContextsMap(statisticsManager).put(deviceInfo, statisticContext);
    final ChangeStatisticsWorkModeInputBuilder changeStatisticsWorkModeInputBld = new ChangeStatisticsWorkModeInputBuilder().setMode(StatisticsWorkMode.FULLYDISABLED);
    final Future<RpcResult<Void>> workMode = statisticsManager.changeStatisticsWorkMode(changeStatisticsWorkModeInputBld.build());
    checkWorkModeChangeOutcome(workMode);
    verify(statisticContext).disableGathering();
}
Also used : ChangeStatisticsWorkModeInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.ChangeStatisticsWorkModeInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) StatisticsContext(org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext) Test(org.junit.Test)

Aggregations

StatisticsContext (org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext)6 Test (org.junit.Test)3 ChangeStatisticsWorkModeInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.ChangeStatisticsWorkModeInputBuilder)3 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)3 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 RpcContext (org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext)1 MultipartWriterProvider (org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProvider)1