From 6b344b02f99bb57cd962762dd62914c07a288a00 Mon Sep 17 00:00:00 2001 From: Evan Zeller Date: Fri, 23 Feb 2018 16:05:34 -0800 Subject: [PATCH] OPNFLWPLUG-981: per-capability configuration for stats polling Implemented granular config knobs to enable or disable statistics polling for each of the OpenFlow capabilities. Only if supported by device and enabled by this configuration will the plugin poll the statistics. By default all are enabled. Change-Id: Ic0bc81f1f2efc51f96dc6ccd94e803b70ad14174 Signed-off-by: Evan Zeller --- .../configuration/ConfigurationProperty.java | 24 +++++++++++ .../main/yang/openflow-provider-config.yang | 42 +++++++++++++++++++ .../main/resources/initial/openflowplugin.cfg | 10 +++++ .../ConfigurationServiceFactoryImpl.java | 12 ++++++ .../OpenFlowProviderConfigImpl.java | 31 ++++++++++++++ .../statistics/StatisticsContextImpl.java | 26 +++++++----- .../statistics/StatisticsManagerImpl.java | 7 ++-- .../ConfigurationServiceFactoryImplTest.java | 9 +++- .../StatisticsContextImplParamTest.java | 24 ++++++++++- .../statistics/StatisticsContextImplTest.java | 39 ++++++++++++----- 10 files changed, 196 insertions(+), 28 deletions(-) diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/configuration/ConfigurationProperty.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/configuration/ConfigurationProperty.java index 26d680e6d5..79d4e7c8b5 100644 --- a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/configuration/ConfigurationProperty.java +++ b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/configuration/ConfigurationProperty.java @@ -23,6 +23,30 @@ public enum ConfigurationProperty { * Is statistics polling on property type. */ IS_STATISTICS_POLLING_ON, + /** + * Is table statistics polling on property type. + */ + IS_TABLE_STATISTICS_POLLING_ON, + /** + * Is flow statistics polling on property type. + */ + IS_FLOW_STATISTICS_POLLING_ON, + /** + * Is group statistics polling on property type. + */ + IS_GROUP_STATISTICS_POLLING_ON, + /** + * Is meter statistics polling on property type. + */ + IS_METER_STATISTICS_POLLING_ON, + /** + * Is port statistics polling on property type. + */ + IS_PORT_STATISTICS_POLLING_ON, + /** + * Is queue statistics polling on property type. + */ + IS_QUEUE_STATISTICS_POLLING_ON, /** * Barrier count limit property type. */ diff --git a/openflowplugin-api/src/main/yang/openflow-provider-config.yang b/openflowplugin-api/src/main/yang/openflow-provider-config.yang index 87fe5c2a6e..8be0d43b7d 100644 --- a/openflowplugin-api/src/main/yang/openflow-provider-config.yang +++ b/openflowplugin-api/src/main/yang/openflow-provider-config.yang @@ -47,6 +47,48 @@ module openflow-provider-config { leaf is-statistics-polling-on { description "If enabled, periodic statistics gathering will be + turned on. If false takes precedence over the per-capability configuration."; + type boolean; + default "true"; + } + + leaf is-table-statistics-polling-on { + description "If enabled, periodic table statistics gathering will be + turned on"; + type boolean; + default "true"; + } + + leaf is-flow-statistics-polling-on { + description "If enabled, periodic flow statistics gathering will be + turned on"; + type boolean; + default "true"; + } + + leaf is-group-statistics-polling-on { + description "If enabled, periodic group statistics gathering will be + turned on"; + type boolean; + default "true"; + } + + leaf is-meter-statistics-polling-on { + description "If enabled, periodic meter statistics gathering will be + turned on"; + type boolean; + default "true"; + } + + leaf is-port-statistics-polling-on { + description "If enabled, periodic port statistics gathering will be + turned on"; + type boolean; + default "true"; + } + + leaf is-queue-statistics-polling-on { + description "If enabled, periodic queue statistics gathering will be turned on"; type boolean; default "true"; diff --git a/openflowplugin-blueprint-config/src/main/resources/initial/openflowplugin.cfg b/openflowplugin-blueprint-config/src/main/resources/initial/openflowplugin.cfg index f62fd85b73..ed72352a71 100644 --- a/openflowplugin-blueprint-config/src/main/resources/initial/openflowplugin.cfg +++ b/openflowplugin-blueprint-config/src/main/resources/initial/openflowplugin.cfg @@ -30,6 +30,16 @@ # # is-statistics-polling-on=true +# +# If enabled, periodic statistics gathering will be turned on for the given capability +# +# is-table-statistics-polling-on=true +# is-flow-statistics-polling-on=true +# is-group-statistics-polling-on=true +# is-meter-statistics-polling-on=true +# is-port-statistics-polling-on=true +# is-queue-statistics-polling-on=true + # # Expose backward compatible statistics RPCs providing result in form of # asynchronous notification. This is deprecated, use direct statistics instead. diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/configuration/ConfigurationServiceFactoryImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/configuration/ConfigurationServiceFactoryImpl.java index afae1caba1..15ef52d694 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/configuration/ConfigurationServiceFactoryImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/configuration/ConfigurationServiceFactoryImpl.java @@ -68,6 +68,18 @@ public class ConfigurationServiceFactoryImpl implements ConfigurationServiceFact providerConfig.getEchoReplyTimeout().getValue().toString()) .put(ConfigurationProperty.IS_STATISTICS_POLLING_ON.toString(), providerConfig.isIsStatisticsPollingOn().toString()) + .put(ConfigurationProperty.IS_TABLE_STATISTICS_POLLING_ON.toString(), + providerConfig.isIsTableStatisticsPollingOn().toString()) + .put(ConfigurationProperty.IS_FLOW_STATISTICS_POLLING_ON.toString(), + providerConfig.isIsFlowStatisticsPollingOn().toString()) + .put(ConfigurationProperty.IS_GROUP_STATISTICS_POLLING_ON.toString(), + providerConfig.isIsGroupStatisticsPollingOn().toString()) + .put(ConfigurationProperty.IS_METER_STATISTICS_POLLING_ON.toString(), + providerConfig.isIsMeterStatisticsPollingOn().toString()) + .put(ConfigurationProperty.IS_PORT_STATISTICS_POLLING_ON.toString(), + providerConfig.isIsPortStatisticsPollingOn().toString()) + .put(ConfigurationProperty.IS_QUEUE_STATISTICS_POLLING_ON.toString(), + providerConfig.isIsQueueStatisticsPollingOn().toString()) .put(ConfigurationProperty.SKIP_TABLE_FEATURES.toString(), providerConfig.isSkipTableFeatures().toString()) .put(ConfigurationProperty.BASIC_TIMER_DELAY.toString(), diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/configuration/OpenFlowProviderConfigImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/configuration/OpenFlowProviderConfigImpl.java index e91cef4059..955bcec6db 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/configuration/OpenFlowProviderConfigImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/configuration/OpenFlowProviderConfigImpl.java @@ -47,6 +47,37 @@ public class OpenFlowProviderConfigImpl implements OpenflowProviderConfig { return service.getProperty(ConfigurationProperty.IS_STATISTICS_POLLING_ON.toString(), Boolean::valueOf); } + @Override + public Boolean isIsTableStatisticsPollingOn() { + return service.getProperty(ConfigurationProperty.IS_TABLE_STATISTICS_POLLING_ON.toString(), Boolean::valueOf); + } + + @Override + public Boolean isIsFlowStatisticsPollingOn() { + return service.getProperty(ConfigurationProperty.IS_FLOW_STATISTICS_POLLING_ON.toString(), Boolean::valueOf); + } + + @Override + public Boolean isIsGroupStatisticsPollingOn() { + return service.getProperty(ConfigurationProperty.IS_GROUP_STATISTICS_POLLING_ON.toString(), Boolean::valueOf); + } + + @Override + public Boolean isIsMeterStatisticsPollingOn() { + return service.getProperty(ConfigurationProperty.IS_METER_STATISTICS_POLLING_ON.toString(), Boolean::valueOf); + } + + @Override + public Boolean isIsQueueStatisticsPollingOn() { + return service.getProperty(ConfigurationProperty.IS_QUEUE_STATISTICS_POLLING_ON.toString(), Boolean::valueOf); + } + + @Override + public Boolean isIsPortStatisticsPollingOn() { + return service.getProperty(ConfigurationProperty.IS_PORT_STATISTICS_POLLING_ON.toString(), Boolean::valueOf); + } + + @Override public Boolean isIsStatisticsRpcEnabled() { return service.getProperty(ConfigurationProperty.IS_STATISTICS_RPC_ENABLED.toString(), Boolean::valueOf); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpl.java index 84807763f9..f2246d01fd 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpl.java @@ -45,6 +45,7 @@ import org.opendaylight.openflowplugin.impl.statistics.services.dedicated.Statis import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -62,6 +63,7 @@ class StatisticsContextImpl implements StatisticsContext { private final MultipartWriterProvider statisticsWriterProvider; private final DeviceInfo deviceInfo; private final TimeCounter timeCounter = new TimeCounter(); + private final OpenflowProviderConfig config; private final long statisticsPollingInterval; private final long maximumPollingDelay; private final boolean isUsingReconciliationFramework; @@ -76,17 +78,19 @@ class StatisticsContextImpl implements StatisticsContext { StatisticsContextImpl(@Nonnull final DeviceContext deviceContext, @Nonnull final ConvertorExecutor convertorExecutor, @Nonnull final MultipartWriterProvider statisticsWriterProvider, - @Nonnull final ListeningExecutorService executorService, boolean isStatisticsPollingOn, - boolean isUsingReconciliationFramework, long statisticsPollingInterval, - long maximumPollingDelay) { + @Nonnull final ListeningExecutorService executorService, + @Nonnull final OpenflowProviderConfig config, + boolean isStatisticsPollingOn, + boolean isUsingReconciliationFramework) { this.deviceContext = deviceContext; this.devState = Preconditions.checkNotNull(deviceContext.getDeviceState()); this.executorService = executorService; this.isStatisticsPollingOn = isStatisticsPollingOn; + this.config = config; this.convertorExecutor = convertorExecutor; this.deviceInfo = deviceContext.getDeviceInfo(); - this.statisticsPollingInterval = statisticsPollingInterval; - this.maximumPollingDelay = maximumPollingDelay; + this.statisticsPollingInterval = config.getBasicTimerDelay().getValue(); + this.maximumPollingDelay = config.getMaximumTimerDelay().getValue(); this.statisticsWriterProvider = statisticsWriterProvider; this.isUsingReconciliationFramework = isUsingReconciliationFramework; @@ -151,29 +155,29 @@ class StatisticsContextImpl implements StatisticsContext { public void instantiateServiceInstance() { final List statListForCollecting = new ArrayList<>(); - if (devState.isTableStatisticsAvailable()) { + if (devState.isTableStatisticsAvailable() && config.isIsTableStatisticsPollingOn()) { statListForCollecting.add(MultipartType.OFPMPTABLE); } - if (devState.isGroupAvailable()) { + if (devState.isGroupAvailable() && config.isIsGroupStatisticsPollingOn()) { statListForCollecting.add(MultipartType.OFPMPGROUPDESC); statListForCollecting.add(MultipartType.OFPMPGROUP); } - if (devState.isMetersAvailable()) { + if (devState.isMetersAvailable() && config.isIsMeterStatisticsPollingOn()) { statListForCollecting.add(MultipartType.OFPMPMETERCONFIG); statListForCollecting.add(MultipartType.OFPMPMETER); } - if (devState.isFlowStatisticsAvailable()) { + if (devState.isFlowStatisticsAvailable() && config.isIsFlowStatisticsPollingOn()) { statListForCollecting.add(MultipartType.OFPMPFLOW); } - if (devState.isPortStatisticsAvailable()) { + if (devState.isPortStatisticsAvailable() && config.isIsPortStatisticsPollingOn()) { statListForCollecting.add(MultipartType.OFPMPPORTSTATS); } - if (devState.isQueueStatisticsAvailable()) { + if (devState.isQueueStatisticsAvailable() && config.isIsQueueStatisticsPollingOn()) { statListForCollecting.add(MultipartType.OFPMPQUEUE); } diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImpl.java index 1a1801520f..2a38430845 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImpl.java @@ -77,7 +77,7 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag switch (targetWorkMode) { case COLLECTALL: context.enableGathering(); - // FIXME: is it a genuine fall through or an error? + break; case FULLYDISABLED: context.disableGathering(); break; @@ -107,10 +107,9 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag converterExecutor, statisticsWriterProvider, executorService, + config, !isStatisticsFullyDisabled && config.isIsStatisticsPollingOn(), - useReconciliationFramework, - config.getBasicTimerDelay().getValue(), - config.getMaximumTimerDelay().getValue()); + useReconciliationFramework); contexts.put(deviceContext.getDeviceInfo(), statisticsContext); return statisticsContext; diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/configuration/ConfigurationServiceFactoryImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/configuration/ConfigurationServiceFactoryImplTest.java index 46cdece6b7..a18da729a0 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/configuration/ConfigurationServiceFactoryImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/configuration/ConfigurationServiceFactoryImplTest.java @@ -37,7 +37,7 @@ import org.osgi.service.cm.ConfigurationAdmin; @RunWith(MockitoJUnitRunner.class) public class ConfigurationServiceFactoryImplTest { - private static final int CONFIG_PROP_COUNT = 16; + private static final int CONFIG_PROP_COUNT = 22; private static final boolean IS_STATISTICS_POLLING_ON = true; private static final int BARRIER_COUNT_LIMIT = 2000; private static final long BARRIER_INTERVAL_TIMEOUT_LIMIT = 3000; @@ -79,6 +79,13 @@ public class ConfigurationServiceFactoryImplTest { @Before public void setUp() throws Exception { when(config.isIsStatisticsPollingOn()).thenReturn(IS_STATISTICS_POLLING_ON); + when(config.isIsFlowStatisticsPollingOn()).thenReturn(IS_STATISTICS_POLLING_ON); + when(config.isIsTableStatisticsPollingOn()).thenReturn(IS_STATISTICS_POLLING_ON); + when(config.isIsFlowStatisticsPollingOn()).thenReturn(IS_STATISTICS_POLLING_ON); + when(config.isIsGroupStatisticsPollingOn()).thenReturn(IS_STATISTICS_POLLING_ON); + when(config.isIsMeterStatisticsPollingOn()).thenReturn(IS_STATISTICS_POLLING_ON); + when(config.isIsQueueStatisticsPollingOn()).thenReturn(IS_STATISTICS_POLLING_ON); + when(config.isIsPortStatisticsPollingOn()).thenReturn(IS_STATISTICS_POLLING_ON); when(config.getBarrierCountLimit()).thenReturn(new NonZeroUint16Type(BARRIER_COUNT_LIMIT)); when(config.getBarrierIntervalTimeoutLimit()).thenReturn(new NonZeroUint32Type(BARRIER_INTERVAL_TIMEOUT_LIMIT)); when(config.getEchoReplyTimeout()).thenReturn(new NonZeroUint32Type(ECHO_REPLY_TIMEOUT)); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplParamTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplParamTest.java index 6cc5acfb6d..d46dad3eee 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplParamTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplParamTest.java @@ -10,6 +10,7 @@ package org.opendaylight.openflowplugin.impl.statistics; import static com.google.common.util.concurrent.Futures.immediateFuture; import static org.mockito.Matchers.any; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -19,22 +20,29 @@ import com.google.common.util.concurrent.MoreExecutors; import java.util.Arrays; import java.util.Collections; import java.util.List; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier; import org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProviderFactory; import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager; import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.NonZeroUint32Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; @RunWith(Parameterized.class) public class StatisticsContextImplParamTest extends StatisticsContextImpMockInitiation { + @Mock + private OpenflowProviderConfig config = mock(OpenflowProviderConfig.class); public StatisticsContextImplParamTest(final boolean isTable, final boolean isFlow, final boolean isGroup, final boolean isMeter, @@ -60,6 +68,18 @@ public class StatisticsContextImplParamTest extends StatisticsContextImpMockInit }); } + @Before + public void setUp() { + Mockito.when(config.isIsTableStatisticsPollingOn()).thenReturn(true); + Mockito.when(config.isIsFlowStatisticsPollingOn()).thenReturn(true); + Mockito.when(config.isIsGroupStatisticsPollingOn()).thenReturn(true); + Mockito.when(config.isIsMeterStatisticsPollingOn()).thenReturn(true); + Mockito.when(config.isIsPortStatisticsPollingOn()).thenReturn(true); + Mockito.when(config.isIsQueueStatisticsPollingOn()).thenReturn(true); + Mockito.when(config.getBasicTimerDelay()).thenReturn(new NonZeroUint32Type(3000L)); + Mockito.when(config.getMaximumTimerDelay()).thenReturn(new NonZeroUint32Type(50000L)); + } + @Test public void gatherDynamicDataTest() throws InterruptedException { @@ -76,7 +96,9 @@ public class StatisticsContextImplParamTest extends StatisticsContextImpMockInit mockedDeviceContext, convertorManager, MultipartWriterProviderFactory.createDefaultProvider(mockedDeviceContext), MoreExecutors.newDirectExecutorService(), - true, false, 3000, 50000); + config, + true, + false); final ListenableFuture>> rpcResult = immediateFuture(RpcResultBuilder .success(Collections.emptyList()).build()); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplTest.java index 5e0b46f567..509f5ad7b1 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplTest.java @@ -22,6 +22,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Matchers; +import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.runners.MockitoJUnitRunner; import org.opendaylight.openflowplugin.api.openflow.device.RequestContext; @@ -31,6 +32,8 @@ import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorM import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.NonZeroUint32Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; @@ -44,21 +47,35 @@ public class StatisticsContextImplTest extends StatisticsContextImpMockInitiatio private static final Long TEST_XID = 55L; private StatisticsContextImpl statisticsContext; private ConvertorManager convertorManager; + @Mock + private OpenflowProviderConfig config = + Mockito.mock(OpenflowProviderConfig.class); @Before public void setUp() throws Exception { convertorManager = ConvertorManagerFactory.createDefaultManager(); when(mockedDeviceInfo.reserveXidForDeviceMessage()).thenReturn(TEST_XID); Mockito.when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState); + Mockito.when(config.isIsTableStatisticsPollingOn()).thenReturn(true); + Mockito.when(config.isIsFlowStatisticsPollingOn()).thenReturn(true); + Mockito.when(config.isIsGroupStatisticsPollingOn()).thenReturn(true); + Mockito.when(config.isIsMeterStatisticsPollingOn()).thenReturn(true); + Mockito.when(config.isIsPortStatisticsPollingOn()).thenReturn(true); + Mockito.when(config.isIsQueueStatisticsPollingOn()).thenReturn(true); + Mockito.when(config.getBasicTimerDelay()).thenReturn(new NonZeroUint32Type(3000L)); + Mockito.when(config.getMaximumTimerDelay()).thenReturn(new NonZeroUint32Type(50000L)); + initStatisticsContext(); } private void initStatisticsContext() { statisticsContext = new StatisticsContextImpl<>(mockedDeviceContext, convertorManager, - MultipartWriterProviderFactory - .createDefaultProvider(mockedDeviceContext), - MoreExecutors.newDirectExecutorService(), true, false, 3000, - 50000); + MultipartWriterProviderFactory + .createDefaultProvider(mockedDeviceContext), + MoreExecutors.newDirectExecutorService(), + config, + true, + false); statisticsContext.setStatisticsGatheringService(mockedStatisticsGatheringService); statisticsContext.setStatisticsGatheringOnTheFlyService(mockedStatisticsOnFlyGatheringService); @@ -80,13 +97,13 @@ public class StatisticsContextImplTest extends StatisticsContextImpMockInitiatio public void testClose() throws Exception { statisticsContext = new StatisticsContextImpl<>(mockedDeviceContext, - convertorManager, - MultipartWriterProviderFactory - .createDefaultProvider(mockedDeviceContext), - MoreExecutors.newDirectExecutorService(), - true, - false, - 3000,50000); + convertorManager, + MultipartWriterProviderFactory + .createDefaultProvider(mockedDeviceContext), + MoreExecutors.newDirectExecutorService(), + config, + true, + false); final RequestContext requestContext = statisticsContext.createRequestContext(); statisticsContext.close(); -- 2.36.6