Bug 6110: Fixed bugs in statistics manager due to race condition.
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / OpenFlowPluginProviderFactoryImpl.java
1 /*
2  * Copyright (c) 2016 Brocade Communications Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.openflowplugin.impl;
9
10 import java.util.List;
11 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
12 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
13 import org.opendaylight.controller.md.sal.binding.api.NotificationService;
14 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
15 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
16 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
17 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
18 import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProvider;
19 import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProviderFactory;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
23
24 /**
25  * Implementation of OpenFlowPluginProviderFactory.
26  *
27  * @author Thomas Pantelis
28  */
29 public class OpenFlowPluginProviderFactoryImpl implements OpenFlowPluginProviderFactory {
30     private static final Logger LOG = LoggerFactory.getLogger(OpenFlowPluginProviderFactoryImpl.class);
31
32     @Override
33     public OpenFlowPluginProvider newInstance(OpenflowProviderConfig providerConfig,
34                                               DataBroker dataBroker,
35                                               RpcProviderRegistry rpcRegistry,
36                                               NotificationService notificationService,
37                                               NotificationPublishService notificationPublishService,
38                                               EntityOwnershipService entityOwnershipService,
39                                               List<SwitchConnectionProvider> switchConnectionProviders,
40                                               ClusterSingletonServiceProvider singletonServiceProvider) {
41
42         LOG.info("Initializing new OFP southbound.");
43
44         OpenFlowPluginProvider openflowPluginProvider = new OpenFlowPluginProviderImpl(
45                 providerConfig.getRpcRequestsQuota(),
46                 providerConfig.getGlobalNotificationQuota(),
47                 providerConfig.getThreadPoolMinThreads(),
48                 providerConfig.getThreadPoolMaxThreads().getValue(),
49                 providerConfig.getThreadPoolTimeout());
50
51         openflowPluginProvider.setSwitchConnectionProviders(switchConnectionProviders);
52         openflowPluginProvider.setDataBroker(dataBroker);
53         openflowPluginProvider.setRpcProviderRegistry(rpcRegistry);
54         openflowPluginProvider.setNotificationProviderService(notificationService);
55         openflowPluginProvider.setNotificationPublishService(notificationPublishService);
56         openflowPluginProvider.setSwitchFeaturesMandatory(providerConfig.isSwitchFeaturesMandatory());
57         openflowPluginProvider.setFlowRemovedNotification(providerConfig.isEnableFlowRemovedNotification());
58         openflowPluginProvider.setIsStatisticsRpcEnabled(providerConfig.isIsStatisticsRpcEnabled());
59         openflowPluginProvider.setBarrierCountLimit(providerConfig.getBarrierCountLimit().getValue());
60         openflowPluginProvider.setBarrierInterval(providerConfig.getBarrierIntervalTimeoutLimit().getValue());
61         openflowPluginProvider.setEchoReplyTimeout(providerConfig.getEchoReplyTimeout().getValue());
62         openflowPluginProvider.setStatisticsPollingOn(providerConfig.isIsStatisticsPollingOn());
63         openflowPluginProvider.setClusteringSingletonServicesProvider(singletonServiceProvider);
64         openflowPluginProvider.setSkipTableFeatures(providerConfig.isSkipTableFeatures());
65         openflowPluginProvider.setBasicTimerDelay(providerConfig.getBasicTimerDelay().getValue());
66         openflowPluginProvider.setMaximumTimerDelay(providerConfig.getMaximumTimerDelay().getValue());
67
68         openflowPluginProvider.initialize();
69
70         LOG.info("Configured values, " +
71                 "StatisticsPollingOn:{}, " +
72                 "SwitchFeaturesMandatory:{}, " +
73                 "BarrierCountLimit:{}, " +
74                 "BarrierTimeoutLimit:{}, " +
75                 "EchoReplyTimeout:{}, " +
76                 "ThreadPoolMinThreads:{}, " +
77                 "ThreadPoolMaxThreads:{}, " +
78                 "ThreadPoolTimeout:{}, " +
79                 "NotificationFlowRemovedOff:{}, " +
80                 "BasicTimerDelay:{}, "+
81                 "MaximumTimerDelay:{} ",
82                 providerConfig.isIsStatisticsPollingOn(),
83                 providerConfig.isSwitchFeaturesMandatory(),
84                 providerConfig.getBarrierCountLimit().getValue(),
85                 providerConfig.getBarrierIntervalTimeoutLimit().getValue(),
86                 providerConfig.getEchoReplyTimeout().getValue(),
87                 providerConfig.getThreadPoolMinThreads(),
88                 providerConfig.getThreadPoolMaxThreads().getValue(),
89                 providerConfig.getThreadPoolTimeout(),
90                 providerConfig.isEnableFlowRemovedNotification(),
91                 providerConfig.getBasicTimerDelay().getValue(),
92                 providerConfig.getMaximumTimerDelay().getValue());
93
94         return openflowPluginProvider;
95     }
96 }