* @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
*/
public interface FlowNodeReconciliation extends ReconciliationNotificationListener, AutoCloseable {
+
ListenableFuture<Boolean> reconcileConfiguration(InstanceIdentifier<FlowCapableNode> connectedNode);
void flowNodeDisconnected(InstanceIdentifier<FlowCapableNode> disconnectedNode);
*/
package org.opendaylight.openflowplugin.applications.frm;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.binding.api.ReadTransaction;
import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationListener;
import org.opendaylight.openflowplugin.applications.frm.impl.DevicesGroupRegistry;
*/
NodeConfigurator getNodeConfigurator();
+ /**
+ * Return the {@link FlowNodeReconciliation} associated with this manager.
+ *
+ * @return the FlowNodeReconciliation
+ */
+ @NonNull FlowNodeReconciliation getFlowNodeReconciliation();
+
/**
* Method for register RecoverableListener.
*
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.frm.reconciliation.service.rev180227.FrmReconciliationService;
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.frm.reconciliation.service.rev180227.ReconcileNode;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
import org.slf4j.Logger;
private final InstanceIdentifier<FlowCapableNode> fcnIID;
private final KeyedInstanceIdentifier<Node, NodeKey> path;
- private ObjectRegistration<@NonNull FrmReconciliationService> reg;
+ private Registration reg;
public DeviceMastership(final NodeId nodeId) {
this.nodeId = nodeId;
- this.identifier = ServiceGroupIdentifier.create(nodeId.getValue());
+ identifier = ServiceGroupIdentifier.create(nodeId.getValue());
fcnIID = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(nodeId))
.augmentation(FlowCapableNode.class);
path = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(nodeId));
deviceMastered.set(true);
}
- public void registerReconciliationRpc(final RpcProviderService rpcProviderService,
- final FrmReconciliationService reconcliationService) {
+ public void registerReconcileNode(final RpcProviderService rpcProviderService, final ReconcileNode reconcileNode) {
if (reg == null) {
LOG.debug("The path is registered : {}", path);
- reg = rpcProviderService.registerRpcImplementation(FrmReconciliationService.class, reconcliationService,
- ImmutableSet.of(path));
+ reg = rpcProviderService.registerRpcImplementation(reconcileNode, ImmutableSet.of(path));
} else {
LOG.debug("The path is already registered : {}", path);
}
}
- public void deregisterReconciliationRpc() {
+ public void deregisterReconcileNode() {
if (reg != null) {
reg.close();
reg = null;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Iterables;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.MoreExecutors;
+import com.google.common.util.concurrent.SettableFuture;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Collection;
import java.util.Set;
import org.opendaylight.mdsal.binding.api.DataTreeModification;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeRegistration;
import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeService;
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.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.frm.reconciliation.service.rev180227.FrmReconciliationService;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.frm.reconciliation.service.rev180227.ReconcileNodeInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.frm.reconciliation.service.rev180227.ReconcileNodeOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.frm.reconciliation.service.rev180227.ReconcileNodeOutputBuilder;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.ErrorType;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final InstanceIdentifier<FlowCapableNode> II_TO_FLOW_CAPABLE_NODE = InstanceIdentifier
.builder(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class).build();
- private final ClusterSingletonServiceProvider clusterSingletonService;
- private final FlowNodeReconciliation reconcliationAgent;
private final ConcurrentHashMap<NodeId, DeviceMastership> deviceMasterships = new ConcurrentHashMap<>();
private final Set<InstanceIdentifier<FlowCapableNode>> activeNodes = ConcurrentHashMap.newKeySet();
private final ReentrantLock lock = new ReentrantLock();
+ private final FlowNodeReconciliation reconcliationAgent;
private final RpcProviderService rpcProviderService;
- private final FrmReconciliationService reconcliationService;
- private ListenerRegistration<DeviceMastershipManager> listenerRegistration;
+ private Registration listenerRegistration;
private MastershipChangeRegistration mastershipChangeServiceRegistration;
@SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR", justification = "Non-final for mocking")
- public DeviceMastershipManager(final ClusterSingletonServiceProvider clusterSingletonService,
- final FlowNodeReconciliation reconcliationAgent,
+ public DeviceMastershipManager(final FlowNodeReconciliation reconcliationAgent,
final DataBroker dataBroker,
final MastershipChangeServiceManager mastershipChangeServiceManager,
- final RpcProviderService rpcProviderService,
- final FrmReconciliationService reconciliationService) {
- this.clusterSingletonService = clusterSingletonService;
+ final RpcProviderService rpcProviderService) {
this.reconcliationAgent = reconcliationAgent;
this.rpcProviderService = rpcProviderService;
- reconcliationService = reconciliationService;
listenerRegistration = dataBroker.registerDataTreeChangeListener(
DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class)), this);
final var membership = deviceMasterships.computeIfAbsent(deviceInfo.getNodeId(),
device -> new DeviceMastership(deviceInfo.getNodeId()));
membership.reconcile();
- membership.registerReconciliationRpc(rpcProviderService, reconcliationService);
+ membership.registerReconcileNode(rpcProviderService, this::reconcileNode);
+ }
+
+ private ListenableFuture<RpcResult<ReconcileNodeOutput>> reconcileNode(final ReconcileNodeInput input) {
+ final var nodeId = input.requireNodeId();
+ LOG.debug("Triggering reconciliation for node: {}", nodeId);
+
+ final var nodeDpn = new NodeBuilder().setId(new NodeId("openflow:" + nodeId)).build();
+ final var connectedNode = InstanceIdentifier.builder(Nodes.class)
+ .child(Node.class, nodeDpn.key()).augmentation(FlowCapableNode.class)
+ .build();
+ final var rpcResult = SettableFuture.<RpcResult<ReconcileNodeOutput>>create();
+ Futures.addCallback(reconcliationAgent.reconcileConfiguration(connectedNode), new FutureCallback<>() {
+ @Override
+ public void onSuccess(final Boolean result) {
+ rpcResult.set(result
+ ? RpcResultBuilder.success(new ReconcileNodeOutputBuilder().setResult(result).build()).build()
+ : RpcResultBuilder.<ReconcileNodeOutput>failed()
+ .withError(ErrorType.APPLICATION, "Error while triggering reconciliation")
+ .build());
+ }
+
+ @Override
+ public void onFailure(final Throwable error) {
+ LOG.error("initReconciliation failed", error);
+ rpcResult.set(RpcResultBuilder.<ReconcileNodeOutput>failed()
+ .withError(ErrorType.RPC, "Error while calling RPC").build());
+ }
+ }, MoreExecutors.directExecutor());
+
+ LOG.debug("Completing reconciliation for node: {}", nodeId);
+ return rpcResult;
}
@Override
public void onLoseOwnership(@NonNull final DeviceInfo deviceInfo) {
final var mastership = deviceMasterships.remove(deviceInfo.getNodeId());
if (mastership != null) {
- mastership.deregisterReconciliationRpc();
+ mastership.deregisterReconcileNode();
mastership.close();
LOG.debug("Unregistered deviceMastership for device : {}", deviceInfo.getNodeId());
}
* @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
*/
public class FlowNodeReconciliationImpl implements FlowNodeReconciliation {
-
private static final Logger LOG = LoggerFactory.getLogger(FlowNodeReconciliationImpl.class);
private static final Logger OF_EVENT_LOG = LoggerFactory.getLogger("OfEventLog");
private ForwardingRulesCommiter<Group> groupListener;
private ForwardingRulesCommiter<Meter> meterListener;
private ForwardingRulesCommiter<TableFeatures> tableListener;
- private FlowNodeReconciliation nodeListener;
+ private FlowNodeReconciliationImpl flowNodeReconciliation;
private NotificationRegistration reconciliationNotificationRegistration;
private DeviceMastershipManager deviceMastershipManager;
private boolean disableReconciliation;
requireNonNull(rpcRegistry.getRpcService(ArbitratorReconcileService.class),
"ArbitratorReconciliationManager can not be null!");
- nodeListener = new FlowNodeReconciliationImpl(this, dataService, SERVICE_NAME, FRM_RECONCILIATION_PRIORITY,
- ResultState.DONOTHING, flowGroupCacheManager);
+ flowNodeReconciliation = new FlowNodeReconciliationImpl(this, dataService, SERVICE_NAME,
+ FRM_RECONCILIATION_PRIORITY, ResultState.DONOTHING, flowGroupCacheManager);
if (isReconciliationDisabled()) {
LOG.debug("Reconciliation is disabled by user");
} else {
- reconciliationNotificationRegistration = reconciliationManager.registerService(nodeListener);
+ reconciliationNotificationRegistration = reconciliationManager.registerService(flowNodeReconciliation);
LOG.debug("Reconciliation is enabled by user and successfully registered to the reconciliation framework");
}
- deviceMastershipManager = new DeviceMastershipManager(clusterSingletonServiceProvider, nodeListener,
- dataService, mastershipChangeServiceManager, rpcProviderService,
- new FrmReconciliationServiceImpl(this));
+ deviceMastershipManager = new DeviceMastershipManager(flowNodeReconciliation, dataService,
+ mastershipChangeServiceManager, rpcProviderService);
flowNodeConnectorInventoryTranslatorImpl = new FlowNodeConnectorInventoryTranslatorImpl(dataService);
bundleFlowListener = new BundleFlowForwarder(this);
tableListener.close();
tableListener = null;
}
- if (nodeListener != null) {
- nodeListener.close();
- nodeListener = null;
+ if (flowNodeReconciliation != null) {
+ flowNodeReconciliation.close();
+ flowNodeReconciliation = null;
}
if (deviceMastershipManager != null) {
deviceMastershipManager.close();
return nodeConfigurator;
}
- public FlowNodeReconciliation getNodeListener() {
- return nodeListener;
+ @Override
+ public FlowNodeReconciliation getFlowNodeReconciliation() {
+ return flowNodeReconciliation;
}
@Override
+++ /dev/null
-/*
- * Copyright (c) 2018 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;
-
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.MoreExecutors;
-import com.google.common.util.concurrent.SettableFuture;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-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.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.frm.reconciliation.service.rev180227.FrmReconciliationService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.frm.reconciliation.service.rev180227.ReconcileNodeInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.frm.reconciliation.service.rev180227.ReconcileNodeOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.frm.reconciliation.service.rev180227.ReconcileNodeOutputBuilder;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.ErrorType;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Singleton
-public class FrmReconciliationServiceImpl implements FrmReconciliationService {
-
- private static final Logger LOG = LoggerFactory.getLogger(FrmReconciliationServiceImpl.class);
-
- private final ForwardingRulesManagerImpl forwardingRulesManagerImpl;
-
- @Inject
- public FrmReconciliationServiceImpl(ForwardingRulesManagerImpl forwardingRulesManagerImpl) {
- this.forwardingRulesManagerImpl = forwardingRulesManagerImpl;
- }
-
- private static Node buildNode(long nodeIid) {
- NodeId nodeId = new NodeId("openflow:" + nodeIid);
- Node nodeDpn = new NodeBuilder().setId(nodeId).withKey(new NodeKey(nodeId)).build();
- return nodeDpn;
- }
-
- @Override
- public ListenableFuture<RpcResult<ReconcileNodeOutput>> reconcileNode(ReconcileNodeInput input) {
- LOG.debug("Triggering reconciliation for node: {}", input.getNodeId());
- Node nodeDpn = buildNode(input.getNodeId().longValue());
- InstanceIdentifier<FlowCapableNode> connectedNode = InstanceIdentifier.builder(Nodes.class)
- .child(Node.class, nodeDpn.key()).augmentation(FlowCapableNode.class).build();
- SettableFuture<RpcResult<ReconcileNodeOutput>> rpcResult = SettableFuture.create();
- ListenableFuture<Boolean> futureResult = forwardingRulesManagerImpl
- .getNodeListener().reconcileConfiguration(connectedNode);
- Futures.addCallback(futureResult, new ResultCallBack(futureResult, rpcResult),
- MoreExecutors.directExecutor());
- LOG.debug("Completing reconciliation for node: {}", input.getNodeId());
- return rpcResult;
- }
-
- private static class ResultCallBack implements FutureCallback<Boolean> {
- private final SettableFuture<RpcResult<ReconcileNodeOutput>> futureResult;
-
- ResultCallBack(ListenableFuture<Boolean> rpcResult,
- SettableFuture<RpcResult<ReconcileNodeOutput>> futureResult) {
- this.futureResult = futureResult;
- }
-
- @Override
- public void onSuccess(Boolean result) {
- if (result) {
- ReconcileNodeOutput output = new ReconcileNodeOutputBuilder().setResult(result).build();
- futureResult.set(RpcResultBuilder.success(output).build());
- } else {
- futureResult.set(RpcResultBuilder.<ReconcileNodeOutput>failed()
- .withError(ErrorType.APPLICATION, "Error while triggering reconciliation").build());
- }
-
- }
-
- @Override
- public void onFailure(Throwable error) {
- LOG.error("initReconciliation failed", error);
- futureResult.set(RpcResultBuilder.<ReconcileNodeOutput>failed()
- .withError(ErrorType.RPC, "Error while calling RPC").build());
- }
- }
-}
<?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"
+<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">
- <bean id="frmReconciliationServiceImpl"
- class="org.opendaylight.openflowplugin.applications.frm.impl.FrmReconciliationServiceImpl">
- <argument ref="forwardingRulesManagerImpl"/>
- </bean>
- <service ref="frmReconciliationServiceImpl"
- interface="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.frm.reconciliation.service.rev180227.FrmReconciliationService"/>
-
- <bean id="forwardingRulesManagerImpl"
- class="org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerImpl"
- destroy-method="close">
- <argument ref="dataBroker"/>
- <argument ref="rpcConsumerRegistry"/>
- <argument ref="rpcProviderService"/>
- <argument ref="forwardingRulesManagerConfig"/>
- <argument ref="mastershipChangeServiceManager"/>
- <argument ref="clusterSingletonServiceProvider"/>
- <argument ref="configurationService"/>
- <argument ref="reconciliationManager"/>
- <argument ref="openflowServiceRecoveryHandler"/>
- <argument ref="serviceRecoveryRegistry"/>
- <argument ref="flowGroupCacheManager"/>
- <argument ref="listenerRegistrationHelper"/>
- </bean>
-
- <odl:clustered-app-config id="forwardingRulesManagerConfig"
- binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.forwardingrules.manager.config.rev160511.ForwardingRulesManagerConfig"/>
-
<reference id="flowGroupCacheManager"
interface="org.opendaylight.openflowplugin.api.openflow.FlowGroupCacheManager"/>
<reference id="dataBroker"
interface="org.opendaylight.openflowplugin.applications.frm.impl.ListenerRegistrationHelper"/>
<reference id="openflowServiceRecoveryHandler"
interface="org.opendaylight.openflowplugin.applications.frm.recovery.OpenflowServiceRecoveryHandler"/>
+
+ <odl:clustered-app-config id="forwardingRulesManagerConfig"
+ binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.forwardingrules.manager.config.rev160511.ForwardingRulesManagerConfig"/>
+
+ <bean id="forwardingRulesManagerImpl"
+ class="org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerImpl"
+ destroy-method="close">
+ <argument ref="dataBroker"/>
+ <argument ref="rpcConsumerRegistry"/>
+ <argument ref="rpcProviderService"/>
+ <argument ref="forwardingRulesManagerConfig"/>
+ <argument ref="mastershipChangeServiceManager"/>
+ <argument ref="clusterSingletonServiceProvider"/>
+ <argument ref="configurationService"/>
+ <argument ref="reconciliationManager"/>
+ <argument ref="openflowServiceRecoveryHandler"/>
+ <argument ref="serviceRecoveryRegistry"/>
+ <argument ref="flowGroupCacheManager"/>
+ <argument ref="listenerRegistrationHelper"/>
+ </bean>
+
+ <service ref="forwardingRulesManagerImpl"
+ interface="org.opendaylight.openflowplugin.applications.frm.ForwardingRulesManager"/>
</blueprint>
import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeServiceManager;
import org.opendaylight.openflowplugin.applications.frm.FlowNodeReconciliation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.frm.reconciliation.service.rev180227.FrmReconciliationService;
/**
* Test for {@link DeviceMastershipManager}.
private NodeId nodeId;
@Mock
private RpcProviderService rpcProviderService;
- @Mock
- private FrmReconciliationService reconciliationService;
@Before
public void setUp() {
- deviceMastershipManager = new DeviceMastershipManager(clusterSingletonService, reconciliationAgent, dataBroker,
- mastershipChangeServiceManager, rpcProviderService, reconciliationService);
+ deviceMastershipManager = new DeviceMastershipManager(reconciliationAgent, dataBroker,
+ mastershipChangeServiceManager, rpcProviderService);
Mockito.lenient().when(clusterSingletonService
.registerClusterSingletonService(ArgumentMatchers.any()))
.thenReturn(registration);
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
import java.util.stream.Collectors;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.openflowplugin.api.openflow.FlowGroupCacheManager;
import org.opendaylight.openflowplugin.api.openflow.ReconciliationState;
+import org.opendaylight.openflowplugin.applications.frm.FlowNodeReconciliation;
+import org.opendaylight.openflowplugin.applications.frm.ForwardingRulesManager;
import org.opendaylight.openflowplugin.applications.southboundcli.alarm.AlarmAgent;
import org.opendaylight.openflowplugin.applications.southboundcli.util.OFNode;
import org.opendaylight.openflowplugin.applications.southboundcli.util.ShellUtil;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.frm.reconciliation.service.rev180227.FrmReconciliationService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.frm.reconciliation.service.rev180227.ReconcileNodeInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.frm.reconciliation.service.rev180227.ReconcileNodeInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.frm.reconciliation.service.rev180227.ReconcileNodeOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.reconciliation.service.rev180227.ReconcileInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.reconciliation.service.rev180227.ReconcileOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.reconciliation.service.rev180227.ReconcileOutputBuilder;
private static final Logger LOG = LoggerFactory.getLogger(ReconciliationServiceImpl.class);
private final DataBroker broker;
- private final FrmReconciliationService frmReconciliationService;
+ private final FlowNodeReconciliation flowNodeReconciliation;
private final AlarmAgent alarmAgent;
private final NodeListener nodeListener;
private final Map<String, ReconciliationState> reconciliationStates;
private ExecutorService executor = Executors.newWorkStealingPool(10);
- public ReconciliationServiceImpl(final DataBroker broker, final FrmReconciliationService frmReconciliationService,
- final AlarmAgent alarmAgent, final NodeListener nodeListener,
- final FlowGroupCacheManager flowGroupCacheManager) {
- this.broker = broker;
- this.frmReconciliationService = frmReconciliationService;
- this.alarmAgent = alarmAgent;
- this.nodeListener = requireNonNull(nodeListener, "NodeListener cannot be null!");
+ public ReconciliationServiceImpl(final DataBroker broker, final ForwardingRulesManager frm,
+ final AlarmAgent alarmAgent, final NodeListener nodeListener,
+ final FlowGroupCacheManager flowGroupCacheManager) {
+ this.broker = requireNonNull(broker);
+ flowNodeReconciliation = frm.getFlowNodeReconciliation();
+ this.alarmAgent = requireNonNull(alarmAgent);
+ this.nodeListener = requireNonNull(nodeListener);
reconciliationStates = flowGroupCacheManager.getReconciliationStates();
}
@Override
public void run() {
- ReconcileNodeInput reconInput = new ReconcileNodeInputBuilder()
- .setNodeId(nodeId).setNode(new NodeRef(InstanceIdentifier.builder(Nodes.class)
- .child(Node.class, nodeKey).build())).build();
updateReconciliationState(STARTED);
- Future<RpcResult<ReconcileNodeOutput>> reconOutput = frmReconciliationService
- .reconcileNode(reconInput);
+ final var reconOutput = flowNodeReconciliation.reconcileConfiguration(
+ InstanceIdentifier.create(Nodes.class)
+ .child(Node.class, nodeKey)
+ .augmentation(FlowCapableNode.class));
try {
- RpcResult<ReconcileNodeOutput> rpcResult = reconOutput.get();
- if (rpcResult.isSuccessful()) {
- increaseReconcileCount(true);
+ final boolean rpcResult = reconOutput.get();
+ increaseReconcileCount(rpcResult);
+ if (rpcResult) {
updateReconciliationState(COMPLETED);
LOG.info("Reconciliation successfully completed for node {}", nodeId);
} else {
- increaseReconcileCount(false);
updateReconciliationState(FAILED);
- LOG.error("Reconciliation failed for node {} with error {}", nodeId, rpcResult.getErrors());
+ LOG.error("Reconciliation failed for node {}", nodeId);
}
} catch (ExecutionException | InterruptedException e) {
increaseReconcileCount(false);
<reference id="dataBroker"
interface="org.opendaylight.mdsal.binding.api.DataBroker"/>
- <reference id="flowCacheManager" interface="org.opendaylight.openflowplugin.api.openflow.FlowGroupCacheManager"/>
+ <reference id="flowCacheManager"
+ interface="org.opendaylight.openflowplugin.api.openflow.FlowGroupCacheManager"/>
+ <reference id="frm"
+ interface="org.opendaylight.openflowplugin.applications.frm.ForwardingRulesManager"/>
- <odl:rpc-service id="frmReconciliationService"
- interface="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.frm.reconciliation.service.rev180227.FrmReconciliationService"/>
<bean id="alarmAgent"
class="org.opendaylight.openflowplugin.applications.southboundcli.alarm.AlarmAgent" init-method="start">
</bean>
class="org.opendaylight.openflowplugin.applications.southboundcli.ReconciliationServiceImpl"
destroy-method="close">
<argument ref="dataBroker"/>
- <argument ref="frmReconciliationService"/>
+ <argument ref="frm"/>
<argument ref="alarmAgent"/>
<argument ref="nodeListener"/>
<argument ref="flowCacheManager"/>