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);
}
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();
}
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();
}
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;
}
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();
}
Aggregations