Merge "DeviceState changes"
[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.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
17 import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProvider;
18 import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProviderFactory;
19 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
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, DataBroker dataBroker,
34             RpcProviderRegistry rpcRegistry, NotificationService notificationService,
35             NotificationPublishService notificationPublishService,
36             EntityOwnershipService entityOwnershipService,
37             List<SwitchConnectionProvider> switchConnectionProviders) {
38
39         LOG.info("Initializing new OFP southbound.");
40
41         OpenflowPortsUtil.init();
42         OpenFlowPluginProvider openflowPluginProvider = new OpenFlowPluginProviderImpl(providerConfig.getRpcRequestsQuota(),
43                 providerConfig.getGlobalNotificationQuota());
44
45         openflowPluginProvider.setSwitchConnectionProviders(switchConnectionProviders);
46         openflowPluginProvider.setDataBroker(dataBroker);
47         openflowPluginProvider.setRpcProviderRegistry(rpcRegistry);
48         openflowPluginProvider.setNotificationProviderService(notificationService);
49         openflowPluginProvider.setNotificationPublishService(notificationPublishService);
50         openflowPluginProvider.setEntityOwnershipService(entityOwnershipService);
51         openflowPluginProvider.setSwitchFeaturesMandatory(providerConfig.isSwitchFeaturesMandatory());
52         openflowPluginProvider.setIsStatisticsPollingOff(providerConfig.isIsStatisticsPollingOff());
53         openflowPluginProvider.setIsStatisticsRpcEnabled(providerConfig.isIsStatisticsRpcEnabled());
54         openflowPluginProvider.setBarrierCountLimit(providerConfig.getBarrierCountLimit().getValue());
55         openflowPluginProvider.setBarrierInterval(providerConfig.getBarrierIntervalTimeoutLimit().getValue());
56         openflowPluginProvider.setEchoReplyTimeout(providerConfig.getEchoReplyTimeout().getValue());
57
58         openflowPluginProvider.initialize();
59
60         LOG.info("Configured values, StatisticsPollingOff:{}, SwitchFeaturesMandatory:{}, BarrierCountLimit:{}, BarrierTimeoutLimit:{}, EchoReplyTimeout:{}",
61                 providerConfig.isIsStatisticsPollingOff(), providerConfig.isSwitchFeaturesMandatory(),
62                 providerConfig.getBarrierCountLimit().getValue(),
63                 providerConfig.getBarrierIntervalTimeoutLimit().getValue(), providerConfig.getEchoReplyTimeout().getValue());
64
65         return openflowPluginProvider;
66     }
67 }