This program and the accompanying materials are made available under the
terms of the Eclipse Public License v1.0 which accompanies this distribution,
and is available at http://www.eclipse.org/legal/epl-v10.html
+
+ NOTE: This file is deprecated as wiring is now done via blueprint. This file is kept for
+ backwards compatibility. Runtime modifications are not honored.
-->
<snapshot>
<configuration>
<groupId>org.opendaylight.controller</groupId>
<artifactId>config-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-common-util</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
package org.opendaylight.openflowplugin.applications.config.yang.forwardingrules_manager;
-import org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerConfig;
-import org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerImpl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.opendaylight.controller.sal.common.util.NoopAutoCloseable;
-public class ForwardingRulesManagerModule extends org.opendaylight.openflowplugin.applications.config.yang.forwardingrules_manager.AbstractForwardingRulesManagerModule {
-
- private static final Logger LOG = LoggerFactory.getLogger(ForwardingRulesManagerModule.class);
- private static final boolean ENABLE_FGM_STALE_MARKING = false;
- private static final int RECONCILIATION_RETRY_COUNT = 5;
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class ForwardingRulesManagerModule extends AbstractForwardingRulesManagerModule {
public ForwardingRulesManagerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
super(identifier, dependencyResolver);
}
@Override
- public void customValidation() {
- // add custom validation form module attributes here.
- }
-
- @Override
- public java.lang.AutoCloseable createInstance() {
- LOG.info("FRM module initialization.");
- final ForwardingRulesManagerConfig config = readConfig();
- final ForwardingRulesManagerImpl forwardingrulessManagerProvider =
- new ForwardingRulesManagerImpl(getDataBrokerDependency(), getRpcRegistryDependency(), config, getEntityOwnershipServiceDependency());
- forwardingrulessManagerProvider.start();
- LOG.info("FRM module started successfully.");
- return new AutoCloseable() {
- @Override
- public void close() throws Exception {
- try {
- forwardingrulessManagerProvider.close();
- } catch (final Exception e) {
- LOG.warn("Unexpected error by stopping FRM", e);
- }
- LOG.info("FRM module stopped.");
- }
- };
- }
-
- private ForwardingRulesManagerConfig readConfig(){
-
- final ForwardingRulesManagerConfig.ForwardingRulesManagerConfigBuilder fwdRulesMgrCfgBuilder = ForwardingRulesManagerConfig.builder();
-
- if (getForwardingManagerSettings() != null && getForwardingManagerSettings().getStaleMarkingEnabled() != null){
- fwdRulesMgrCfgBuilder.setStaleMarkingEnabled(getForwardingManagerSettings().getStaleMarkingEnabled());
- }
- else{
- LOG.warn("Could not load XML configuration file via ConfigSubsystem! Fallback to default config value(s)");
- fwdRulesMgrCfgBuilder.setStaleMarkingEnabled(ENABLE_FGM_STALE_MARKING);
- }
-
- if(getForwardingManagerSettings() != null && getForwardingManagerSettings().getReconciliationRetryCount()>0){
- fwdRulesMgrCfgBuilder.setReconciliationRetryCount(getForwardingManagerSettings().getReconciliationRetryCount());
- }
- else{
- LOG.warn("Could not load XML configuration file via ConfigSubsystem for reconciliation retry! " +
- "Fallback to default config value(s)");
- fwdRulesMgrCfgBuilder.setReconciliationRetryCount(RECONCILIATION_RETRY_COUNT);
- }
-
-
-
- return fwdRulesMgrCfgBuilder.build();
-
+ public AutoCloseable createInstance() {
+ // FRM instance is created via blueprint so this in a no-op.
+ return NoopAutoCloseable.INSTANCE;
}
-
}
* Do not modify this file unless it is present under src/main directory
*/
package org.opendaylight.openflowplugin.applications.config.yang.forwardingrules_manager;
-public class ForwardingRulesManagerModuleFactory extends org.opendaylight.openflowplugin.applications.config.yang.forwardingrules_manager.AbstractForwardingRulesManagerModuleFactory {
+
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class ForwardingRulesManagerModuleFactory extends AbstractForwardingRulesManagerModuleFactory {
}
package org.opendaylight.openflowplugin.applications.frm;
-import org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerConfig;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
-
-import org.opendaylight.openflowplugin.applications.frm.impl.FlowNodeConnectorInventoryTranslatorImpl;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.openflowplugin.applications.frm.impl.FlowNodeConnectorInventoryTranslatorImpl;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.forwardingrules.manager.config.rev160511.ForwardingRulesManagerConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
/**
* @return True if owner, else false
*/
public boolean isNodeOwner(InstanceIdentifier<FlowCapableNode> ident);
-
+
/**
* Content definition method and prevent code duplicity
* @return FlowNodeConnectorInventoryTranslatorImpl
+++ /dev/null
-/**
- * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowplugin.applications.frm.impl;
-
-/**
- * Created by efiijjp on 10/14/2015.
- */
-public class ForwardingRulesManagerConfig {
-
- private final boolean m_staleMarkingEnabled;
- private final int m_reconciliationRetryCount;
-
- private ForwardingRulesManagerConfig(ForwardingRulesManagerConfigBuilder builder){
- m_staleMarkingEnabled = builder.isStaleMarkingEnabled();
- m_reconciliationRetryCount = builder.getReconciliationRetryCount();
- }
-
- public boolean isStaleMarkingEnabled(){
- return m_staleMarkingEnabled;
- }
-
- public int getReconciliationRetryCount() {
- return m_reconciliationRetryCount;
- }
-
-
- public static ForwardingRulesManagerConfigBuilder builder(){
- return new ForwardingRulesManagerConfigBuilder();
- }
-
-
-
- public static class ForwardingRulesManagerConfigBuilder {
- private boolean staleMarkingEnabled ;
- private int reconciliationRetryCount ;
-
- public boolean isStaleMarkingEnabled(){
- return staleMarkingEnabled;
- }
- public int getReconciliationRetryCount() {return reconciliationRetryCount;}
-
- public void setStaleMarkingEnabled(boolean staleMarkingEnabledFlag){
- staleMarkingEnabled = staleMarkingEnabledFlag;
- }
-
- public void setReconciliationRetryCount(int retryCount ){
- reconciliationRetryCount = retryCount;
- }
-
- public ForwardingRulesManagerConfig build(){
- return new ForwardingRulesManagerConfig(this);
- }
- }
-
-}
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.collect.Sets;
+import com.google.common.util.concurrent.CheckedFuture;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
-
-import com.google.common.util.concurrent.CheckedFuture;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.forwardingrules.manager.config.rev160511.ForwardingRulesManagerConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
this.tableListener = new TableForwarder(this, dataService);
this.nodeListener = new FlowNodeReconciliationImpl(this, dataService);
- flowNodeConnectorInventoryTranslatorImpl =
+ flowNodeConnectorInventoryTranslatorImpl =
new FlowNodeConnectorInventoryTranslatorImpl(this,dataService);
LOG.info("ForwardingRulesManager has started successfully.");
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+ odl:use-default-for-reference-types="true">
+
+ <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"/>
+ <reference id="rpcRegistry" interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"/>
+ <reference id="entityOwnershipService" interface="org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService"/>
+
+ <odl:clustered-app-config id="frmConfig"
+ binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.forwardingrules.manager.config.rev160511.ForwardingRulesManagerConfig"/>
+
+ <bean id="frmManager" class="org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerImpl"
+ init-method="start" destroy-method="close">
+ <argument ref="dataBroker"/>
+ <argument ref="rpcRegistry"/>
+ <argument ref="frmConfig"/>
+ <argument ref="entityOwnershipService"/>
+ </bean>
+</blueprint>
\ No newline at end of file
identity forwardingrules-manager {
base config:module-type;
config:java-name-prefix ForwardingRulesManager;
+ status deprecated;
}
augment "/config:modules/config:module/config:configuration" {
--- /dev/null
+module forwarding-rules-manager-config {
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:openflowplugin:app:forwardingrules-manager:config";
+ prefix "frm";
+
+ description
+ "Configuration for Forwarding Rules Manager application..";
+
+ revision "2016-05-11" {
+ description
+ "Initial revision.";
+ }
+
+ container forwarding-rules-manager-config {
+ leaf stale-marking-enabled {
+ type boolean;
+ default false;
+ }
+
+ leaf reconciliation-retry-count {
+ type uint16;
+ default 5;
+ }
+ }
+}
\ No newline at end of file
*/
package test.mock;
+import static org.junit.Assert.assertEquals;
+import java.util.Collections;
+import java.util.List;
import org.junit.Test;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerConfig;
import org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerImpl;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlowKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
import test.mock.util.EntityOwnershipServiceMock;
import test.mock.util.FRMTest;
import test.mock.util.RpcProviderRegistryMock;
import test.mock.util.SalFlowServiceMock;
-import java.util.Collections;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
public class FlowListenerTest extends FRMTest {
RpcProviderRegistry rpcProviderRegistryMock = new RpcProviderRegistryMock();
EntityOwnershipService eos = new EntityOwnershipServiceMock();
package test.mock.util;
-import org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerConfig;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
import java.util.Collections;
import java.util.concurrent.ExecutionException;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.forwardingrules.manager.config.rev160511.ForwardingRulesManagerConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.forwardingrules.manager.config.rev160511.ForwardingRulesManagerConfigBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public abstract class FRMTest extends AbstractDataBrokerTest {
}
public ForwardingRulesManagerConfig getConfig(){
- ForwardingRulesManagerConfig.ForwardingRulesManagerConfigBuilder cfgBuilder =
- new ForwardingRulesManagerConfig.ForwardingRulesManagerConfigBuilder();
+ ForwardingRulesManagerConfigBuilder cfgBuilder = new ForwardingRulesManagerConfigBuilder();
cfgBuilder.setStaleMarkingEnabled(false);
+ cfgBuilder.setReconciliationRetryCount(0);
return cfgBuilder.build();
}
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v1.0 which accompanies this distribution,
and is available at http://www.eclipse.org/legal/epl-v10.html
+
+NOTE: This file is deprecated as wiring is now done via blueprint. This file is kept for
+ backwards compatibility. Runtime modifications are not honored.
-->
<snapshot>
<required-capabilities>
*/
package org.opendaylight.openflowplugin.applications.topology.lldp;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.NotificationListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class LLDPActivator implements BindingAwareProvider, AutoCloseable {
+public class LLDPActivator implements AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(LLDPActivator.class);
- private static LLDPDiscoveryProvider provider = new LLDPDiscoveryProvider();
+
private static String lldpSecureKey;
- public LLDPActivator(String secureKey) {
+ private final ListenerRegistration<NotificationListener> lldpNotificationRegistration;
+
+ public LLDPActivator(NotificationProviderService notificationService, LLDPDiscoveryListener lldpDiscoveryListener,
+ String secureKey) {
lldpSecureKey = secureKey;
- }
- public void onSessionInitiated(final ProviderContext session) {
- DataProviderService dataService = session.<DataProviderService>getSALService(DataProviderService.class);
- provider.setDataService(dataService);
- NotificationProviderService notificationService = session.<NotificationProviderService>getSALService(NotificationProviderService.class);
- provider.setNotificationService(notificationService);
- provider.start();
+ LOG.info("Starting LLDPActivator with lldpSecureKey: {}", lldpSecureKey);
+
+ lldpNotificationRegistration = notificationService.registerNotificationListener(lldpDiscoveryListener);
+
+ LOG.info("LLDPDiscoveryListener started.");
}
@Override
- public void close() throws Exception {
- if(provider != null) {
- try {
- provider.close();
- } catch (Exception e) {
- LOG.warn("Exception when closing down topology-lldp-discovery",e);
- }
- }
+ public void close() {
+ lldpNotificationRegistration.close();
+
+ LOG.info("LLDPDiscoveryListener stopped.");
}
public static String getLldpSecureKey() {
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-class LLDPDiscoveryListener implements PacketProcessingListener {
+public class LLDPDiscoveryListener implements PacketProcessingListener {
private static final Logger LOG = LoggerFactory.getLogger(LLDPDiscoveryListener.class);
- private LLDPLinkAger lldpLinkAger;
- private NotificationProviderService notificationService;
+ private final LLDPLinkAger lldpLinkAger;
+ private final NotificationProviderService notificationService;
- LLDPDiscoveryListener(NotificationProviderService notificationService) {
+ public LLDPDiscoveryListener(NotificationProviderService notificationService, LLDPLinkAger lldpLinkAger) {
this.notificationService = notificationService;
+ this.lldpLinkAger = lldpLinkAger;
}
+ @Override
public void onPacketReceived(PacketReceived lldp) {
NodeConnectorRef src = LLDPDiscoveryUtils.lldpToNodeConnectorRef(lldp.getPayload(), true);
if(src != null) {
lldpLinkAger.put(ld);
}
}
-
- public void setLldpLinkAger(LLDPLinkAger lldpLinkAger) {
- this.lldpLinkAger = lldpLinkAger;
- }
-}
+}
\ No newline at end of file
+++ /dev/null
-/**
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.applications.topology.lldp;
-
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
-import org.opendaylight.openflowplugin.applications.topology.lldp.utils.LLDPDiscoveryUtils;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.NotificationListener;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class LLDPDiscoveryProvider implements AutoCloseable {
- private static final Logger LOG = LoggerFactory.getLogger(LLDPDiscoveryProvider.class);
- private DataProviderService dataService;
- private NotificationProviderService notificationService;
-
- private ListenerRegistration<NotificationListener> listenerRegistration;
- private LLDPLinkAger lldpLinkAger;
-
- public DataProviderService getDataService() {
- return this.dataService;
- }
-
- public void setDataService(final DataProviderService dataService) {
- this.dataService = dataService;
- }
-
- public NotificationProviderService getNotificationService() {
- return this.notificationService;
- }
-
- public void setNotificationService(final NotificationProviderService notificationService) {
- this.notificationService = notificationService;
- }
-
- public void start() {
- lldpLinkAger = new LLDPLinkAger(LLDPDiscoveryUtils.LLDP_INTERVAL, LLDPDiscoveryUtils.LLDP_EXPIRATION_TIME);
- lldpLinkAger.setNotificationService(notificationService);
-
- LLDPDiscoveryListener committer = new LLDPDiscoveryListener(notificationService);
- committer.setLldpLinkAger(lldpLinkAger);
-
- ListenerRegistration<NotificationListener> registerNotificationListener =
- notificationService.registerNotificationListener(committer);
- this.listenerRegistration = registerNotificationListener;
- LOG.info("LLDPDiscoveryListener Started.");
- }
-
- public void close() {
- try {
- LOG.info("LLDPDiscoveryListener stopped.");
- if (this.listenerRegistration!=null) {
- this.listenerRegistration.close();
- }
- lldpLinkAger.close();
- } catch (Exception e) {
- throw new Error(e);
- }
- }
-}
public class LLDPLinkAger implements AutoCloseable {
private final long linkExpirationTime;
- private Map<LinkDiscovered, Date> linkToDate;
- private Timer timer;
- private NotificationProviderService notificationService;
+ private final Map<LinkDiscovered, Date> linkToDate;
+ private final Timer timer;
+ private final NotificationProviderService notificationService;
/**
* default ctor - start timer
*/
- public LLDPLinkAger(final long lldpInterval, final long linkExpirationTime) {
+ public LLDPLinkAger(final long lldpInterval, final long linkExpirationTime,
+ final NotificationProviderService notificationService) {
this.linkExpirationTime = linkExpirationTime;
+ this.notificationService = notificationService;
linkToDate = new ConcurrentHashMap<>();
timer = new Timer();
timer.schedule(new LLDPAgingTask(), 0, lldpInterval);
linkToDate.clear();
}
- public void setNotificationService(NotificationProviderService notificationService) {
- this.notificationService = notificationService;
- }
-
private class LLDPAgingTask extends TimerTask {
@Override
*/
package org.opendaylight.openflowplugin.applications.topology.lldp.utils;
-import org.apache.commons.lang3.ArrayUtils;
-import java.nio.charset.Charset;
import com.google.common.hash.HashCode;
+import com.google.common.hash.HashFunction;
+import com.google.common.hash.Hasher;
+import com.google.common.hash.Hashing;
+import java.lang.management.ManagementFactory;
+import java.nio.charset.Charset;
+import java.security.NoSuchAlgorithmException;
+import java.util.Arrays;
+import org.apache.commons.lang3.ArrayUtils;
+import org.opendaylight.controller.liblldp.BitBufferHelper;
+import org.opendaylight.controller.liblldp.CustomTLVKey;
import org.opendaylight.controller.liblldp.Ethernet;
import org.opendaylight.controller.liblldp.LLDP;
-import org.opendaylight.controller.liblldp.BitBufferHelper;
import org.opendaylight.controller.liblldp.LLDPTLV;
import org.opendaylight.controller.liblldp.NetUtils;
-import com.google.common.hash.Hasher;
-import com.google.common.hash.Hashing;
-import com.google.common.hash.HashFunction;
import org.opendaylight.openflowplugin.applications.topology.lldp.LLDPActivator;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
-import java.util.Arrays;
-import java.security.NoSuchAlgorithmException;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
-import java.lang.management.ManagementFactory;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.controller.liblldp.CustomTLVKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class LLDPDiscoveryUtils {
private static final Logger LOG = LoggerFactory.getLogger(LLDPDiscoveryUtils.class);
- // Send LLDP every five seconds
- public static final Long LLDP_INTERVAL = (long) (1000*5);
-
- // Let up to three intervals pass before we decide we are expired.
- public static final Long LLDP_EXPIRATION_TIME = LLDP_INTERVAL*3;
-
public static String macToString(byte[] mac) {
StringBuilder b = new StringBuilder();
for (int i = 0; i < mac.length; i++) {
package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.lldp.discovery.impl.rev150530;
-import org.opendaylight.openflowplugin.applications.topology.lldp.LLDPActivator;
+import org.opendaylight.controller.sal.common.util.NoopAutoCloseable;
-public class TopologyLldpDiscoveryImplModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.lldp.discovery.impl.rev150530.AbstractTopologyLldpDiscoveryImplModule {
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class TopologyLldpDiscoveryImplModule extends AbstractTopologyLldpDiscoveryImplModule {
public TopologyLldpDiscoveryImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
super(identifier, dependencyResolver);
}
}
@Override
- public void customValidation() {
- // add custom validation form module attributes here.
+ public AutoCloseable createInstance() {
+ // LLDPActivator instance is created via blueprint so this in a no-op.
+ return NoopAutoCloseable.INSTANCE;
}
-
- @Override
- public java.lang.AutoCloseable createInstance() {
- LLDPActivator provider = new LLDPActivator(getLldpSecureKey());
- getBrokerDependency().registerProvider(provider);
- return provider;
- }
-
}
* Do not modify this file unless it is present under src/main directory
*/
package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.lldp.discovery.impl.rev150530;
-public class TopologyLldpDiscoveryImplModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.lldp.discovery.impl.rev150530.AbstractTopologyLldpDiscoveryImplModuleFactory {
+
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class TopologyLldpDiscoveryImplModuleFactory extends AbstractTopologyLldpDiscoveryImplModuleFactory {
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+ odl:use-default-for-reference-types="true">
+
+ <reference id="notificationService" interface="org.opendaylight.controller.sal.binding.api.NotificationProviderService"/>
+
+ <odl:clustered-app-config id="topologyLLDPConfig"
+ binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.lldp.discovery.config.rev160511.TopologyLldpDiscoveryConfig">
+ <odl:default-config><![CDATA[
+ <topology-lldp-discovery-config xmlns="urn:opendaylight:params:xml:ns:yang:topology-lldp-discovery:config">
+ <lldp-secure-key>aa9251f8-c7c0-4322-b8d6-c3a84593bda3</lldp-secure-key>
+ </topology-lldp-discovery-config>
+ ]]></odl:default-config>
+ </odl:clustered-app-config>
+
+ <bean id="lldpLinkAger" class="org.opendaylight.openflowplugin.applications.topology.lldp.LLDPLinkAger"
+ destroy-method="close">
+ <!-- Interval to send LLDP (five seconds) -->
+ <argument value="5000"/>
+ <!-- Expiration interval for aging out links (3 * the interval) -->
+ <argument value="15000"/>
+ <argument ref="notificationService"/>
+ </bean>
+
+ <bean id="lldpDiscoveryListener" class="org.opendaylight.openflowplugin.applications.topology.lldp.LLDPDiscoveryListener">
+ <argument ref="notificationService"/>
+ <argument ref="lldpLinkAger"/>
+ </bean>
+
+ <bean id="LLDPActivator" class="org.opendaylight.openflowplugin.applications.topology.lldp.LLDPActivator"
+ destroy-method="close">
+ <argument ref="notificationService"/>
+ <argument ref="lldpDiscoveryListener"/>
+ <argument>
+ <bean factory-ref="topologyLLDPConfig" factory-method="getLldpSecureKey"/>
+ </argument>
+ </bean>
+</blueprint>
\ No newline at end of file
--- /dev/null
+module topology-lldp-discovery-config {
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:topology-lldp-discovery:config";
+ prefix "topology-lldp-discovery-config";
+
+ description
+ "Configuration for Topology LLDP discovery application.";
+
+ revision "2016-05-11" {
+ description
+ "Initial revision.";
+ }
+
+ container topology-lldp-discovery-config {
+ leaf lldp-secure-key {
+ description "Provided key will be used to generate LLDP custom security hash";
+ type string;
+ mandatory true;
+ }
+ }
+}
\ No newline at end of file
identity topology-lldp-discovery-impl {
base config:module-type;
config:java-name-prefix TopologyLldpDiscoveryImpl;
+ status deprecated;
}
augment "/config:modules/config:module/config:configuration" {
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v1.0 which accompanies this distribution,
and is available at http://www.eclipse.org/legal/epl-v10.html
+
+NOTE: This file is deprecated as wiring is now done via blueprint. This file is kept for
+ backwards compatibility. Runtime modifications are not honored.
-->
<snapshot>
<required-capabilities>
*/
package org.opendaylight.openflowplugin.applications.topology.manager;
-import java.util.concurrent.ExecutionException;
-
import com.google.common.base.Optional;
+import java.util.concurrent.ExecutionException;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadTransaction;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class FlowCapableTopologyProvider implements BindingAwareProvider, AutoCloseable {
+public class FlowCapableTopologyProvider implements AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(FlowCapableTopologyProvider.class);
- private ListenerRegistration<NotificationListener> listenerRegistration;
- private Thread thread;
- private TerminationPointChangeListenerImpl terminationPointChangeListener;
- private NodeChangeListenerImpl nodeChangeListener;
static final String TOPOLOGY_ID = "flow:1";
+ private final DataBroker dataBroker;
+ private final NotificationProviderService notificationService;
+ private final OperationProcessor processor;
+ private ListenerRegistration<NotificationListener> listenerRegistration;
+
+ public FlowCapableTopologyProvider(DataBroker dataBroker, NotificationProviderService notificationService,
+ OperationProcessor processor) {
+ this.dataBroker = dataBroker;
+ this.notificationService = notificationService;
+ this.processor = processor;
+ }
+
/**
* Gets called on start of a bundle.
- *
- * @param session
*/
- @Override
- public synchronized void onSessionInitiated(final ProviderContext session) {
- final DataBroker dataBroker = session.getSALService(DataBroker.class);
- final NotificationProviderService notificationService = session.getSALService(NotificationProviderService.class);
-
+ public void start() {
final TopologyKey key = new TopologyKey(new TopologyId(TOPOLOGY_ID));
final InstanceIdentifier<Topology> path = InstanceIdentifier
.create(NetworkTopology.class)
.child(Topology.class, key);
- final OperationProcessor processor = new OperationProcessor(dataBroker);
final FlowCapableTopologyExporter listener = new FlowCapableTopologyExporter(processor, path);
this.listenerRegistration = notificationService.registerNotificationListener(listener);
- this.terminationPointChangeListener = new TerminationPointChangeListenerImpl(dataBroker, processor);
- nodeChangeListener = new NodeChangeListenerImpl(dataBroker, processor);
if(!isFlowTopologyExist(dataBroker, path)){
final ReadWriteTransaction tx = dataBroker.newReadWriteTransaction();
}
}
- thread = new Thread(processor);
- thread.setDaemon(true);
- thread.setName("FlowCapableTopologyExporter-" + TOPOLOGY_ID);
- thread.start();
+ LOG.info("FlowCapableTopologyProvider started");
}
@Override
- public synchronized void close() throws InterruptedException {
+ public void close() {
LOG.info("FlowCapableTopologyProvider stopped.");
if (this.listenerRegistration != null) {
try {
}
listenerRegistration = null;
}
- unregisterListener(terminationPointChangeListener);
- unregisterListener(nodeChangeListener);
- if (thread != null) {
- thread.interrupt();
- thread.join();
- thread = null;
- }
- }
-
- private static void unregisterListener(final AutoCloseable listenerToClose) {
- if (listenerToClose != null) {
- try {
- listenerToClose.close();
- } catch (Exception e) {
- LOG.warn("Failed to close listener registration: {}", e.getMessage());
- LOG.debug("Failed to close listener registration.. ", e);
- }
- }
}
private boolean isFlowTopologyExist(final DataBroker dataBroker,
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-final class OperationProcessor implements AutoCloseable, Runnable, TransactionChainListener {
+public final class OperationProcessor implements AutoCloseable, Runnable, TransactionChainListener {
private static final Logger LOG = LoggerFactory.getLogger(OperationProcessor.class);
private static final int MAX_TRANSACTION_OPERATIONS = 100;
private static final int OPERATION_QUEUE_DEPTH = 500;
private final BlockingQueue<TopologyOperation> queue = new LinkedBlockingQueue<>(OPERATION_QUEUE_DEPTH);
private final DataBroker dataBroker;
+ private final Thread thread;
private BindingTransactionChain transactionChain;
private volatile boolean finishing = false;
- OperationProcessor(final DataBroker dataBroker) {
+ public OperationProcessor(final DataBroker dataBroker) {
this.dataBroker = Preconditions.checkNotNull(dataBroker);
transactionChain = this.dataBroker.createTransactionChain(this);
+
+ thread = new Thread(this);
+ thread.setDaemon(true);
+ thread.setName("FlowCapableTopologyExporter-" + FlowCapableTopologyProvider.TOPOLOGY_ID);
}
void enqueueOperation(final TopologyOperation task) {
}
}
+ public void start() {
+ thread.start();
+ }
+
@Override
public void run() {
while (!finishing) {
transactionChain = dataBroker.createTransactionChain(this);
cleanDataStoreOperQueue();
} catch (final InterruptedException e) {
- LOG.warn("Stat Manager DS Operation thread interupted!", e);
+ // This should mean we're shutting down.
+ LOG.debug("Stat Manager DS Operation thread interupted!", e);
finishing = true;
} catch (final Exception e) {
LOG.warn("Stat DataStore Operation executor fail!", e);
}
@Override
- public void close() throws Exception {
+ public void close() {
+ thread.interrupt();
+ try {
+ thread.join();
+ } catch(InterruptedException e) {
+ LOG.debug("Join of thread {} was interrupted", thread.getName(), e);
+ }
+
if (transactionChain != null) {
transactionChain.close();
}
+ LOG.debug("OperationProcessor closed");
}
}
package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.manager.impl.rev150530;
-import org.opendaylight.openflowplugin.applications.topology.manager.FlowCapableTopologyProvider;
+import org.opendaylight.controller.sal.common.util.NoopAutoCloseable;
-public class TopologyLldpDiscoveryImplModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.manager.impl.rev150530.AbstractTopologyLldpDiscoveryImplModule {
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class TopologyLldpDiscoveryImplModule extends AbstractTopologyLldpDiscoveryImplModule {
public TopologyLldpDiscoveryImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
super(identifier, dependencyResolver);
}
super(identifier, dependencyResolver, oldModule, oldInstance);
}
- @Override
- public void customValidation() {
- // add custom validation form module attributes here.
- }
-
@Override
public java.lang.AutoCloseable createInstance() {
- FlowCapableTopologyProvider provider = new FlowCapableTopologyProvider();
- getBrokerDependency().registerProvider(provider);
- return provider;
+ // FlowCapableTopologyProvider instance is created via blueprint so this in a no-op.
+ return NoopAutoCloseable.INSTANCE;
}
-
}
* Do not modify this file unless it is present under src/main directory
*/
package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.manager.impl.rev150530;
-public class TopologyLldpDiscoveryImplModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.manager.impl.rev150530.AbstractTopologyLldpDiscoveryImplModuleFactory {
+
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class TopologyLldpDiscoveryImplModuleFactory extends AbstractTopologyLldpDiscoveryImplModuleFactory {
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+ odl:use-default-for-reference-types="true">
+
+ <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"/>
+ <reference id="notificationService" interface="org.opendaylight.controller.sal.binding.api.NotificationProviderService"/>
+
+ <bean id="operationProcessor" class="org.opendaylight.openflowplugin.applications.topology.manager.OperationProcessor"
+ init-method="start" destroy-method="close">
+ <argument ref="dataBroker"/>
+ </bean>
+
+ <bean id="termPointChangeListener" class="org.opendaylight.openflowplugin.applications.topology.manager.TerminationPointChangeListenerImpl"
+ destroy-method="close">
+ <argument ref="dataBroker"/>
+ <argument ref="operationProcessor"/>
+ </bean>
+
+ <bean id="nodeChangeListener" class="org.opendaylight.openflowplugin.applications.topology.manager.NodeChangeListenerImpl"
+ destroy-method="close">
+ <argument ref="dataBroker"/>
+ <argument ref="operationProcessor"/>
+ </bean>
+
+ <bean id="topologyProvider" class="org.opendaylight.openflowplugin.applications.topology.manager.FlowCapableTopologyProvider"
+ init-method="start" destroy-method="close">
+ <argument ref="dataBroker"/>
+ <argument ref="notificationService"/>
+ <argument ref="operationProcessor"/>
+ </bean>
+</blueprint>
\ No newline at end of file
identity topology-manager-impl {
base config:module-type;
config:java-name-prefix TopologyLldpDiscoveryImpl;
+ status deprecated;
}
augment "/config:modules/config:module/config:configuration" {