import javax.inject.Inject;
import javax.inject.Singleton;
import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
import org.opendaylight.openflowplugin.applications.reconciliation.NotificationRegistration;
@Inject
@Activate
public ArbitratorReconciliationManagerImpl(@Reference final ReconciliationManager reconciliationManager,
- @Reference final RpcProviderService rpcProviderService, @Reference final RpcConsumerRegistry rpcService,
+ @Reference final RpcProviderService rpcProviderService, @Reference final RpcService rpcService,
@Reference final UpgradeState upgradeState) {
this.rpcProviderService = requireNonNull(rpcProviderService);
this.upgradeState = requireNonNull(upgradeState);
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.Transaction;
import org.opendaylight.mdsal.binding.api.TransactionChain;
-import org.opendaylight.mdsal.binding.api.TransactionChainListener;
import org.opendaylight.mdsal.binding.api.WriteTransaction;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Empty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private final AtomicInteger countDpnWriteCompletion = new AtomicInteger();
private final AtomicLong taskCompletionTime = new AtomicLong();
- public FlowWriterTxChain(final DataBroker dataBroker, ExecutorService flowPusher) {
+ public FlowWriterTxChain(final DataBroker dataBroker, final ExecutorService flowPusher) {
this.dataBroker = dataBroker;
this.flowPusher = flowPusher;
LOG.info("Using Ping Pong Flow Tester Impl");
}
- public void addFlows(Integer dpnCount, Integer flowsPerDPN, int batchSize, int sleepMillis, int sleepAfter,
- short startTableId, short endTableId, boolean isCreateParents) {
+ public void addFlows(final Integer dpnCount, final Integer flowsPerDPN, final int batchSize, final int sleepMillis,
+ final int sleepAfter, final short startTableId, final short endTableId, final boolean isCreateParents) {
LOG.info("Using Transaction Chain Flow Writer Impl");
countDpnWriteCompletion.set(dpnCount);
startTime = System.nanoTime();
}
}
- public void deleteFlows(Integer dpnCount, Integer flowsPerDPN, int batchSize, short startTableId,
- short endTableId) {
+ public void deleteFlows(final Integer dpnCount, final Integer flowsPerDPN, final int batchSize,
+ final short startTableId, final short endTableId) {
LOG.info("Using Transaction Chain Flow Writer Impl");
countDpnWriteCompletion.set(dpnCount);
for (int i = 1; i <= dpnCount; i++) {
return taskCompletionTime.get();
}
- private class FlowHandlerTask implements Runnable, TransactionChainListener {
+ private class FlowHandlerTask implements Runnable, FutureCallback<Empty> {
private final String dpId;
private final boolean add;
private final int flowsPerDpn;
private final boolean isCreateParents;
private final AtomicInteger remainingTxReturn = new AtomicInteger(0);
- private TransactionChain txChain;
+ private TransactionChain txChain = null;
FlowHandlerTask(final String dpId,
final int flowsPerDpn,
int newBatchSize = batchSize;
LOG.info("Number of Txn for dpId: {} is: {}", dpId, numSubmits);
- txChain = dataBroker.createMergingTransactionChain(this);
+ txChain = dataBroker.createMergingTransactionChain();
+ txChain.addCallback(this);
LOG.info("Creating new txChain: {} for dpid: {}", txChain, dpId);
for (int i = 1; i <= numSubmits; i++) {
}
@Override
- public void onTransactionChainFailed(TransactionChain transactionChain,
- Transaction asyncTransaction, Throwable throwable) {
- LOG.error("Transaction chain: {} FAILED at asyncTransaction: {} due to: ", transactionChain,
- asyncTransaction.getIdentifier(), throwable);
- transactionChain.close();
+ public void onFailure(final Throwable throwable) {
+ LOG.error("Transaction chain: {} FAILED due to: ", txChain, throwable);
+ txChain.close();
}
@Override
- public void onTransactionChainSuccessful(TransactionChain transactionChain) {
- LOG.info("Transaction chain: {} closed successfully.", transactionChain);
+ public void onSuccess(final Empty result) {
+ LOG.info("Transaction chain: {} closed successfully.", txChain);
}
- private void writeTxToDs(WriteTransaction writeTransaction, String flowId, InstanceIdentifier<Flow> flowIid,
- Flow flow, Integer sourceIp, Short tableId) {
+ private void writeTxToDs(final WriteTransaction writeTransaction, final String flowId,
+ final InstanceIdentifier<Flow> flowIid, final Flow flow, final Integer sourceIp, final Short tableId) {
if (add) {
LOG.trace("Adding flow for flowId: {}, flowIid: {}", flowId, flowIid);
if (isCreateParents) {
private final short beginTableId;
private final TransactionChain txChain;
- DsCallBack(String dpId, short beginTableId, short endTableId, int sourceIp,
- TransactionChain txChain) {
+ DsCallBack(final String dpId, final short beginTableId, final short endTableId, final int sourceIp,
+ final TransactionChain txChain) {
this.dpId = dpId;
this.sourceIp = sourceIp;
this.endTableId = endTableId;
}
@Override
- public void onSuccess(Object notUsed) {
+ public void onSuccess(final Object notUsed) {
if (remainingTxReturn.decrementAndGet() <= 0) {
long dur = System.nanoTime() - startTime;
LOG.info("Completed all flows installation for: dpid: {} in {}ns", dpId, dur);
}
@Override
- public void onFailure(Throwable error) {
+ public void onFailure(final Throwable error) {
if (remainingTxReturn.decrementAndGet() <= 0) {
long dur = System.nanoTime() - startTime;
LOG.info("Completed all flows installation for: dpid: {} in {}ns", dpId, dur);
import javax.management.ObjectName;
import org.opendaylight.infrautils.utils.concurrent.LoggingFutures;
import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.mdsal.binding.api.WriteTransaction;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsDs;
@Inject
@Activate
- public SalBulkFlowRpcs(@Reference final DataBroker dataBroker, @Reference final RpcConsumerRegistry rpcService,
+ public SalBulkFlowRpcs(@Reference final DataBroker dataBroker, @Reference final RpcService rpcService,
@Reference final RpcProviderService rpcProviderService) {
this.dataBroker = requireNonNull(dataBroker);
addFlow = rpcService.getRpc(AddFlow.class);
final TransactionChain mockedTxChain = mock(TransactionChain.class);
when(mockedTxChain.newWriteOnlyTransaction()).thenReturn(writeTransaction);
- doReturn(mockedTxChain).when(mockDataBroker)
- .createMergingTransactionChain(ArgumentMatchers.any());
+ doReturn(mockedTxChain).when(mockDataBroker).createMergingTransactionChain();
doReturn(CommitInfo.emptyFluentFuture()).when(writeTransaction).commit();
import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.ReadTransaction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.mdsal.binding.api.WriteTransaction;
import org.opendaylight.mdsal.common.api.CommitInfo;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
@Mock
private DataBroker mockDataBroker;
@Mock
- private RpcConsumerRegistry mockRpcService;
+ private RpcService mockRpcService;
@Mock
private RpcProviderService mockRpcProviderService;
@Mock
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Singleton;
-import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipChange;
import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipListener;
import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService;
import org.opendaylight.mdsal.eos.common.api.EntityOwnershipState;
+import org.opendaylight.mdsal.eos.common.api.EntityOwnershipStateChange;
import org.opendaylight.openflowplugin.applications.deviceownershipservice.DeviceOwnershipService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.core.general.entity.rev150930.Entity;
import org.opendaylight.yangtools.concepts.Registration;
}
@Override
- public void ownershipChanged(final EntityOwnershipChange ownershipChange) {
- final String entityName = ownershipChange.getEntity().getIdentifier().firstKeyOf(Entity.class).getName();
+ public void ownershipChanged(final org.opendaylight.mdsal.eos.binding.api.Entity entity,
+ final EntityOwnershipStateChange change, final boolean inJeopardy) {
+ final String entityName = entity.getIdentifier().firstKeyOf(Entity.class).getName();
if (entityName != null && isOpenFlowEntity(entityName)) {
- LOG.info("Entity ownership change received for node : {} : {}", entityName, ownershipChange);
- if (!ownershipChange.getState().isOwner() && !ownershipChange.getState().hasOwner()
- && !ownershipChange.inJeopardy()) {
+ LOG.info("Entity ownership change received for node : {} : {}", entityName, change);
+ if (!change.isOwner() && !change.hasOwner() && !inJeopardy) {
LOG.debug("Entity for node {} is unregistered.", entityName);
ownershipStateCache.remove(entityName);
- } else if (!ownershipChange.getState().isOwner() && ownershipChange.getState().hasOwner()) {
+ } else if (!change.isOwner() && change.hasOwner()) {
ownershipStateCache.put(entityName, EntityOwnershipState.OWNED_BY_OTHER);
- } else if (ownershipChange.getState().isOwner()) {
+ } else if (change.isOwner()) {
LOG.trace("Entity for node : {} is registered", entityName);
ownershipStateCache.put(entityName, EntityOwnershipState.IS_OWNER);
}
<packaging>bundle</packaging>
<dependencies>
+ <dependency>
+ <groupId>com.github.spotbugs</groupId>
+ <artifactId>spotbugs-annotations</artifactId>
+ <optional>true</optional>
+ </dependency>
<dependency>
<groupId>com.guicedee.services</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-singleton-common-api</artifactId>
+ <artifactId>mdsal-singleton-api</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.openflowplugin</groupId>
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.MoreExecutors;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.util.Collection;
+import java.util.List;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.DataObjectModification;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.openflowplugin.applications.frm.NodeConfigurator;
import org.opendaylight.serviceutils.srm.RecoverableListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
- public void onDataTreeChanged(final Collection<DataTreeModification<T>> changes) {
+ public void onDataTreeChanged(final List<DataTreeModification<T>> changes) {
LOG.trace("Received data changes :{}", requireNonNull(changes, "Changes may not be null!"));
for (DataTreeModification<T> change : changes) {
@Override
public final void registerListener() {
Futures.addCallback(registrationHelper.checkedRegisterListener(
- DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, getWildCardPath()), this),
- new FutureCallback<>() {
+ DataTreeIdentifier.of(LogicalDatastoreType.CONFIGURATION, getWildCardPath()), this),
+ new FutureCallback<Registration>() {
@Override
- public void onSuccess(final ObjectRegistration<?> flowListenerRegistration) {
- LOG.info("{} registered successfully", flowListenerRegistration.getInstance());
+ public void onSuccess(final Registration flowListenerRegistration) {
+ LOG.info("{} registered successfully", this);
listenerRegistration = flowListenerRegistration;
}
import static java.util.Objects.requireNonNull;
-import java.util.Collection;
+import java.util.List;
import org.opendaylight.mdsal.binding.api.DataObjectModification;
import org.opendaylight.mdsal.binding.api.DataTreeModification;
import org.opendaylight.openflowplugin.applications.frm.FlowCapableNodeConnectorCommitter;
implements FlowCapableNodeConnectorCommitter<T> {
@Override
- public void onDataTreeChanged(final Collection<DataTreeModification<T>> changes) {
+ public void onDataTreeChanged(final List<DataTreeModification<T>> changes) {
requireNonNull(changes, "Changes may not be null!");
for (DataTreeModification<T> change : changes) {
import com.google.common.util.concurrent.ListenableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
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.mdsal.singleton.api.ClusterSingletonService;
+import org.opendaylight.mdsal.singleton.api.ServiceGroupIdentifier;
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;
public DeviceMastership(final NodeId nodeId) {
this.nodeId = nodeId;
- identifier = ServiceGroupIdentifier.create(nodeId.getValue());
+ identifier = new ServiceGroupIdentifier(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));
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.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantLock;
}
@Override
- public void onDataTreeChanged(@NonNull final Collection<DataTreeModification<FlowCapableNode>> changes) {
+ public void onDataTreeChanged(final List<DataTreeModification<FlowCapableNode>> changes) {
for (DataTreeModification<FlowCapableNode> change : changes) {
final InstanceIdentifier<FlowCapableNode> key = change.getRootPath().getRootIdentifier();
final DataObjectModification<FlowCapableNode> mod = change.getRootNode();
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.ReadTransaction;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.openflowplugin.api.openflow.FlowGroupCacheManager;
import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService;
@Inject
public ForwardingRulesManagerImpl(final DataBroker dataBroker,
- final RpcConsumerRegistry rpcRegistry,
+ final RpcService rpcRegistry,
final RpcProviderService rpcProviderService,
final ForwardingRulesManagerConfig config,
final MastershipChangeServiceManager mastershipChangeServiceManager,
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.DataObject;
// Needed only for BluePrint coexistence
public interface ListenerRegistrationHelper {
- <T extends DataObject> @NonNull ListenableFuture<ObjectRegistration<?>> checkedRegisterListener(
- DataTreeIdentifier<T> treeId, ClusteredDataTreeChangeListener<T> listener);
+ <T extends DataObject> @NonNull ListenableFuture<Registration> checkedRegisterListener(DataTreeIdentifier<T> treeId,
+ ClusteredDataTreeChangeListener<T> listener);
}
\ No newline at end of file
import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
}
@Override
- public <T extends DataObject> ListenableFuture<ObjectRegistration<?>> checkedRegisterListener(
+ public <T extends DataObject> ListenableFuture<Registration> checkedRegisterListener(
final DataTreeIdentifier<T> treeId, final ClusteredDataTreeChangeListener<T> listener) {
return Futures.submit(() -> {
while (!getInventoryConfigDataStoreStatus().equals("OPERATIONAL")) {
<reference id="dataBroker"
interface="org.opendaylight.mdsal.binding.api.DataBroker"/>
<reference id="rpcConsumerRegistry"
- interface="org.opendaylight.mdsal.binding.api.RpcConsumerRegistry"/>
+ interface="org.opendaylight.mdsal.binding.api.RpcService"/>
<reference id="rpcProviderService"
interface="org.opendaylight.mdsal.binding.api.RpcProviderService"/>
<reference id="mastershipChangeServiceManager"
import static org.mockito.Mockito.when;
import org.mockito.Mock;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.mdsal.binding.api.WriteTransaction;
import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTest;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
private ForwardingRulesManagerImpl forwardingRulesManager;
@Mock
- private RpcConsumerRegistry rpcConsumerRegistry;
+ private RpcService rpcConsumerRegistry;
@Mock
private RpcProviderService rpcProviderService;
@Mock
import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
+import org.opendaylight.mdsal.singleton.api.ClusterSingletonServiceProvider;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
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.yangtools.concepts.Registration;
/**
* Test for {@link DeviceMastershipManager}.
public class DeviceMastershipManagerTest {
private DeviceMastershipManager deviceMastershipManager;
@Mock
- private ClusterSingletonServiceRegistration registration;
+ private Registration registration;
@Mock
private ClusterSingletonServiceProvider clusterSingletonService;
@Mock
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-singleton-common-api</artifactId>
+ <artifactId>mdsal-singleton-api</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.openflowplugin.model</groupId>
package org.opendaylight.openflowplugin.applications.frsync.impl;
import com.google.common.util.concurrent.ListenableFuture;
-import java.util.Collection;
+import java.util.List;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
private static final Logger LOG = LoggerFactory.getLogger(AbstractFrmSyncListener.class);
@Override
- public void onDataTreeChanged(final Collection<DataTreeModification<T>> modifications) {
+ public void onDataTreeChanged(final List<DataTreeModification<T>> modifications) {
for (DataTreeModification<T> modification : modifications) {
final NodeId nodeId = PathUtil.digNodeId(modification.getRootPath().getRootIdentifier());
if (LOG.isTraceEnabled()) {
import javax.inject.Singleton;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
+import org.opendaylight.mdsal.singleton.api.ClusterSingletonServiceProvider;
import org.opendaylight.openflowplugin.applications.frsync.NodeListener;
import org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeCachedDao;
import org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeOdlDao;
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.table.service.rev131026.UpdateTable;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
private final DataTreeIdentifier<FlowCapableNode> nodeConfigDataTreePath;
private final DataTreeIdentifier<Node> nodeOperationalDataTreePath;
- private ListenerRegistration<?> dataTreeConfigChangeListener;
- private ListenerRegistration<?> dataTreeOperationalChangeListener;
+ private Registration dataTreeConfigChangeListener;
+ private Registration dataTreeOperationalChangeListener;
private final ExecutorService syncThreadPool;
@Inject
@Activate
public ForwardingRulesSyncProvider(@Reference final DataBroker dataBroker,
- @Reference final RpcConsumerRegistry rpcRegistry,
+ @Reference final RpcService rpcRegistry,
@Reference final ClusterSingletonServiceProvider clusterSingletonService) {
- requireNonNull(rpcRegistry, "RpcConsumerRegistry can not be null!");
+ requireNonNull(rpcRegistry, "RpcService can not be null!");
dataService = requireNonNull(dataBroker, "DataBroker can not be null!");
this.clusterSingletonService = requireNonNull(clusterSingletonService,
"ClusterSingletonServiceProvider can not be null!");
package org.opendaylight.openflowplugin.applications.frsync.impl;
import com.google.common.util.concurrent.ListenableFuture;
-import java.util.Collection;
+import java.util.List;
import java.util.Optional;
import org.opendaylight.mdsal.binding.api.DataObjectModification;
import org.opendaylight.mdsal.binding.api.DataTreeModification;
}
@Override
- public void onDataTreeChanged(final Collection<DataTreeModification<FlowCapableNode>> modifications) {
+ public void onDataTreeChanged(final List<DataTreeModification<FlowCapableNode>> modifications) {
super.onDataTreeChanged(modifications);
}
import com.google.common.util.concurrent.ListenableFuture;
import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.Collection;
import java.util.Date;
+import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.opendaylight.mdsal.binding.api.DataObjectModification;
}
@Override
- public void onDataTreeChanged(final Collection<DataTreeModification<Node>> modifications) {
+ public void onDataTreeChanged(final List<DataTreeModification<Node>> modifications) {
super.onDataTreeChanged(modifications);
}
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
-import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
+import org.opendaylight.mdsal.singleton.api.ClusterSingletonService;
+import org.opendaylight.mdsal.singleton.api.ClusterSingletonServiceProvider;
+import org.opendaylight.mdsal.singleton.api.ServiceGroupIdentifier;
import org.opendaylight.openflowplugin.applications.frsync.util.ReconciliationRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yangtools.concepts.Registration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private final NodeId nodeId;
private final ServiceGroupIdentifier identifier;
private final ReconciliationRegistry reconciliationRegistry;
- private final ClusterSingletonServiceRegistration clusterSingletonServiceRegistration;
+ private final Registration clusterSingletonServiceRegistration;
private boolean deviceMastered;
public DeviceMastership(final NodeId nodeId,
final ReconciliationRegistry reconciliationRegistry,
final ClusterSingletonServiceProvider clusterSingletonService) {
this.nodeId = nodeId;
- identifier = ServiceGroupIdentifier.create(nodeId.getValue());
+ identifier = new ServiceGroupIdentifier(nodeId.getValue());
this.reconciliationRegistry = reconciliationRegistry;
deviceMastered = false;
clusterSingletonServiceRegistration = clusterSingletonService.registerClusterSingletonService(this);
import com.google.common.annotations.VisibleForTesting;
import java.util.concurrent.ConcurrentHashMap;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
+import org.opendaylight.mdsal.singleton.api.ClusterSingletonServiceProvider;
import org.opendaylight.openflowplugin.applications.frsync.util.ReconciliationRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.slf4j.Logger;
package org.opendaylight.openflowplugin.applications.frsync.impl.strategy;
import com.google.common.util.concurrent.ListenableFuture;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.openflowplugin.applications.frsync.ForwardingRulesCommitter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroup;
private final UpdateGroup updateGroupRpc;
private final RemoveGroup removeGroupRpc;
- public GroupForwarder(final RpcConsumerRegistry rpcConsumerRegistry) {
+ public GroupForwarder(final RpcService rpcConsumerRegistry) {
addGroupRpc = rpcConsumerRegistry.getRpc(AddGroup.class);
updateGroupRpc = rpcConsumerRegistry.getRpc(UpdateGroup.class);
removeGroupRpc = rpcConsumerRegistry.getRpc(RemoveGroup.class);
package org.opendaylight.openflowplugin.applications.frsync.impl.strategy;
import com.google.common.util.concurrent.ListenableFuture;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.openflowplugin.applications.frsync.ForwardingRulesCommitter;
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;
private final AddMeter addMeter;
private final UpdateMeter updateMeter;
- public MeterForwarder(final RpcConsumerRegistry rpcConsumerRegistry) {
+ public MeterForwarder(final RpcService rpcConsumerRegistry) {
addMeter = rpcConsumerRegistry.getRpc(AddMeter.class);
removeMeter = rpcConsumerRegistry.getRpc(RemoveMeter.class);
updateMeter = rpcConsumerRegistry.getRpc(UpdateMeter.class);
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
+import org.opendaylight.mdsal.binding.api.RpcService;
+import org.opendaylight.mdsal.singleton.api.ClusterSingletonServiceProvider;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatch;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTable;
@Mock
private DataBroker dataBroker;
@Mock
- private RpcConsumerRegistry rpcRegistry;
+ private RpcService rpcRegistry;
@Mock
private ClusterSingletonServiceProvider clusterSingletonService;
package org.opendaylight.openflowplugin.applications.frsync.impl;
import com.google.common.util.concurrent.Futures;
-import java.util.Collections;
+import java.util.List;
import java.util.Optional;
import org.junit.Assert;
import org.junit.Before;
final SyncupEntry syncupEntry =
loadOperationalDSAndPrepareSyncupEntry(dataAfter, confgDS, dataBefore, operationalDS);
- nodeListenerConfig.onDataTreeChanged(Collections.singleton(dataTreeModification));
+ nodeListenerConfig.onDataTreeChanged(List.of(dataTreeModification));
Mockito.verify(reactor).syncup(fcNodePath, syncupEntry);
Mockito.verifyNoMoreInteractions(reactor);
Mockito.when(configModification.getDataAfter()).thenReturn(dataAfter);
final SyncupEntry syncupEntry = loadOperationalDSAndPrepareSyncupEntry(dataAfter, confgDS, dataBefore, confgDS);
- nodeListenerConfig.onDataTreeChanged(Collections.singleton(dataTreeModification));
+ nodeListenerConfig.onDataTreeChanged(List.of(dataTreeModification));
Mockito.verify(reactor).syncup(fcNodePath, syncupEntry);
Mockito.verifyNoMoreInteractions(reactor);
Mockito.when(configModification.getDataAfter()).thenReturn(null);
final SyncupEntry syncupEntry = loadOperationalDSAndPrepareSyncupEntry(null, confgDS, dataBefore, confgDS);
- nodeListenerConfig.onDataTreeChanged(Collections.singleton(dataTreeModification));
+ nodeListenerConfig.onDataTreeChanged(List.of(dataTreeModification));
Mockito.verify(reactor).syncup(fcNodePath, syncupEntry);
Mockito.verifyNoMoreInteractions(reactor);
Mockito.doReturn(FluentFutures.immediateFluentFuture(Optional.empty())).when(roTx)
.read(LogicalDatastoreType.OPERATIONAL, fcNodePath);
- nodeListenerConfig.onDataTreeChanged(Collections.singleton(dataTreeModification));
+ nodeListenerConfig.onDataTreeChanged(List.of(dataTreeModification));
Mockito.verifyNoMoreInteractions(reactor);
Mockito.verify(roTx).close();
import com.google.common.util.concurrent.Futures;
import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.Collections;
+import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.junit.Assert;
@Test
public void testOnDataTreeChangedAddPhysical() {
operationalAdd();
- nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
+ nodeListenerOperational.onDataTreeChanged(List.of(dataTreeModification));
Mockito.verify(deviceMastershipManager).onDeviceConnected(NODE_ID);
Mockito.verifyNoMoreInteractions(reactor);
}
Mockito.when(operationalModification.getDataBefore()).thenReturn(operationalNode);
Mockito.when(operationalModification.getDataAfter()).thenReturn(null);
- nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
+ nodeListenerOperational.onDataTreeChanged(List.of(dataTreeModification));
Mockito.verify(deviceMastershipManager).onDeviceDisconnected(NODE_ID);
Mockito.verifyNoMoreInteractions(reactor);
Mockito.when(operationalModification.getDataAfter()).thenReturn(operationalNodeEmpty);
Mockito.when(operationalNodeEmpty.getNodeConnector()).thenReturn(null);
- nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
+ nodeListenerOperational.onDataTreeChanged(List.of(dataTreeModification));
Mockito.verify(deviceMastershipManager).onDeviceDisconnected(NODE_ID);
Mockito.verifyNoMoreInteractions(reactor);
Mockito.when(reconciliationRegistry.isRegistered(NODE_ID)).thenReturn(false);
operationalUpdate();
- nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
+ nodeListenerOperational.onDataTreeChanged(List.of(dataTreeModification));
Mockito.verifyNoMoreInteractions(reactor);
}
operationalUpdate();
Mockito.when(operationalNode.augmentation(FlowCapableStatisticsGatheringStatus.class)).thenReturn(null);
- nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
+ nodeListenerOperational.onDataTreeChanged(List.of(dataTreeModification));
Mockito.verifyNoMoreInteractions(reactor);
}
.thenReturn(statisticsGatheringStatus);
Mockito.when(statisticsGatheringStatus.getSnapshotGatheringStatusEnd()).thenReturn(null);
- nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
+ nodeListenerOperational.onDataTreeChanged(List.of(dataTreeModification));
Mockito.verifyNoMoreInteractions(reactor);
}
Mockito.when(statisticsGatheringStatus.getSnapshotGatheringStatusEnd()).thenReturn(snapshotGatheringStatusEnd);
Mockito.when(snapshotGatheringStatusEnd.getSucceeded()).thenReturn(false);
- nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
+ nodeListenerOperational.onDataTreeChanged(List.of(dataTreeModification));
Mockito.verifyNoMoreInteractions(reactor);
}
operationalUpdate();
prepareFreshOperational(false);
- nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
+ nodeListenerOperational.onDataTreeChanged(List.of(dataTreeModification));
Mockito.verifyNoMoreInteractions(reactor);
}
final SyncupEntry syncupEntry = loadConfigDSAndPrepareSyncupEntry(
configNode, configDS, fcOperationalNode, operationalDS);
- nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
+ nodeListenerOperational.onDataTreeChanged(List.of(dataTreeModification));
Mockito.verify(reactor).syncup(fcNodePath, syncupEntry);
Mockito.verify(roTx).close();
final SyncupEntry syncupEntry = loadConfigDSAndPrepareSyncupEntry(
configNode, configDS, fcOperationalNode, operationalDS);
- nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
+ nodeListenerOperational.onDataTreeChanged(List.of(dataTreeModification));
Mockito.verify(reactor).syncup(fcNodePath, syncupEntry);
Mockito.verify(roTx).close();
Mockito.doReturn(FluentFutures.immediateFluentFuture(Optional.empty())).when(roTx)
.read(LogicalDatastoreType.CONFIGURATION, fcNodePath);
- nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
+ nodeListenerOperational.onDataTreeChanged(List.of(dataTreeModification));
Mockito.verify(reconciliationRegistry).unregisterIfRegistered(NODE_ID);
Mockito.verifyNoMoreInteractions(reactor);
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
+import org.opendaylight.mdsal.singleton.api.ClusterSingletonServiceProvider;
import org.opendaylight.openflowplugin.applications.frsync.util.ReconciliationRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yangtools.concepts.Registration;
/**
* Test for {@link DeviceMastershipManager}.
private static final NodeId NODE_ID = new NodeId("testNode");
private DeviceMastershipManager deviceMastershipManager;
@Mock
- private ClusterSingletonServiceRegistration registration;
+ private Registration registration;
@Mock
private ClusterSingletonServiceProvider clusterSingletonService;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
+import org.opendaylight.mdsal.singleton.api.ClusterSingletonServiceProvider;
import org.opendaylight.openflowplugin.applications.frsync.util.ReconciliationRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroup;
private final InstanceIdentifier<Group> groupPath = flowCapableNodePath.child(Group.class, groupKey);
@Mock
- private RpcConsumerRegistry rpcConsumerRegistry;
+ private RpcService rpcConsumerRegistry;
@Mock
private AddGroup addGroup;
@Mock
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
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.meters.MeterBuilder;
private final InstanceIdentifier<Meter> meterPath = flowCapableNodePath.child(Meter.class, meterKey);
@Mock
- private RpcConsumerRegistry rpcRegistry;
+ private RpcService rpcRegistry;
@Mock
private AddMeter addMeter;
@Mock
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.openflowplugin.applications.deviceownershipservice.DeviceOwnershipService;
import org.opendaylight.openflowplugin.libraries.liblldp.PacketException;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
private volatile OperStatus operationalStatus = OperStatus.RUN;
- public LLDPSpeaker(final DeviceOwnershipService deviceOwnershipService, final RpcConsumerRegistry rpcService,
+ public LLDPSpeaker(final DeviceOwnershipService deviceOwnershipService, final RpcService rpcService,
final RpcProviderService rpcProviderService, final LldpSpeakerConfig config) {
this(Executors.newSingleThreadScheduledExecutor(THREAD_FACTORY), deviceOwnershipService, rpcService,
rpcProviderService, config.getAddressDestination());
@VisibleForTesting
LLDPSpeaker(final ScheduledExecutorService scheduledExecutorService,
- final DeviceOwnershipService deviceOwnershipService, final RpcConsumerRegistry rpcService,
+ final DeviceOwnershipService deviceOwnershipService, final RpcService rpcService,
final RpcProviderService rpcProviderService, final MacAddress addressDestination) {
this.scheduledExecutorService = requireNonNull(scheduledExecutorService);
this.deviceOwnershipService = requireNonNull(deviceOwnershipService);
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
-import java.util.Collection;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.mdsal.binding.api.DataTreeModification;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
* and update LLDPSpeaker and topology.
*/
public final class NodeConnectorInventoryEventTranslator<T extends DataObject>
- implements ClusteredDataTreeChangeListener<T>, AutoCloseable {
+ implements DataTreeChangeListener<T>, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(NodeConnectorInventoryEventTranslator.class);
private static final InstanceIdentifier<FlowCapableNodeConnector> II_TO_FLOW_CAPABLE_NODE_CONNECTOR =
InstanceIdentifier.builder(Nodes.class)
final NodeConnectorEventsObserver... observers) {
this.observers = ImmutableSet.copyOf(observers);
- final DataTreeIdentifier dtiToNodeConnector = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
+ final DataTreeIdentifier dtiToNodeConnector = DataTreeIdentifier.of(LogicalDatastoreType.OPERATIONAL,
II_TO_FLOW_CAPABLE_NODE_CONNECTOR);
- final DataTreeIdentifier dtiToNodeConnectorState = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
+ final DataTreeIdentifier dtiToNodeConnectorState = DataTreeIdentifier.of(LogicalDatastoreType.OPERATIONAL,
II_TO_STATE);
- listenerOnPortRegistration = dataBroker.registerDataTreeChangeListener(dtiToNodeConnector, this);
- listenerOnPortStateRegistration = dataBroker.registerDataTreeChangeListener(dtiToNodeConnectorState, this);
+ listenerOnPortRegistration = dataBroker.registerTreeChangeListener(dtiToNodeConnector, this);
+ listenerOnPortStateRegistration = dataBroker.registerTreeChangeListener(dtiToNodeConnectorState, this);
LOG.info("NodeConnectorInventoryEventTranslator has started.");
}
}
@Override
- public void onDataTreeChanged(@NonNull final Collection<DataTreeModification<T>> modifications) {
- for (DataTreeModification modification : modifications) {
- LOG.trace("Node connectors in inventory changed -> {}", modification.getRootNode().getModificationType());
- switch (modification.getRootNode().getModificationType()) {
+ public void onDataTreeChanged(@NonNull final List<DataTreeModification<T>> modifications) {
+ for (var modification : modifications) {
+ LOG.trace("Node connectors in inventory changed -> {}", modification.getRootNode().modificationType());
+ switch (modification.getRootNode().modificationType()) {
case WRITE:
processAddedConnector(modification);
break;
break;
default:
throw new IllegalArgumentException(
- "Unhandled modification type: {}" + modification.getRootNode().getModificationType());
+ "Unhandled modification type: " + modification.getRootNode().modificationType());
}
}
}
private void processAddedConnector(final DataTreeModification<T> modification) {
- final InstanceIdentifier<T> identifier = modification.getRootPath().getRootIdentifier();
+ final InstanceIdentifier<T> identifier = modification.getRootPath().path();
InstanceIdentifier<NodeConnector> nodeConnectorInstanceId = identifier.firstIdentifierOf(NodeConnector.class);
if (compareIITail(identifier, II_TO_FLOW_CAPABLE_NODE_CONNECTOR)) {
FlowCapableNodeConnector flowConnector = (FlowCapableNodeConnector) modification.getRootNode()
- .getDataAfter();
+ .dataAfter();
if (!isPortDown(flowConnector)) {
notifyNodeConnectorAppeared(nodeConnectorInstanceId, flowConnector);
} else {
}
private void processUpdatedConnector(final DataTreeModification<T> modification) {
- final InstanceIdentifier<T> identifier = modification.getRootPath().getRootIdentifier();
+ final InstanceIdentifier<T> identifier = modification.getRootPath().path();
InstanceIdentifier<NodeConnector> nodeConnectorInstanceId = identifier.firstIdentifierOf(NodeConnector.class);
if (compareIITail(identifier, II_TO_FLOW_CAPABLE_NODE_CONNECTOR)) {
FlowCapableNodeConnector flowConnector = (FlowCapableNodeConnector) modification.getRootNode()
- .getDataAfter();
+ .dataAfter();
if (isPortDown(flowConnector)) {
notifyNodeConnectorDisappeared(nodeConnectorInstanceId);
} else {
} else if (compareIITail(identifier, II_TO_STATE)) {
FlowCapableNodeConnector flowNodeConnector = iiToDownFlowCapableNodeConnectors.get(nodeConnectorInstanceId);
if (flowNodeConnector != null) {
- State state = (State) modification.getRootNode().getDataAfter();
+ State state = (State) modification.getRootNode().dataAfter();
if (!state.getLinkDown()) {
FlowCapableNodeConnectorBuilder flowCapableNodeConnectorBuilder
= new FlowCapableNodeConnectorBuilder(flowNodeConnector);
}
private void processRemovedConnector(final DataTreeModification<T> modification) {
- final InstanceIdentifier<T> identifier = modification.getRootPath().getRootIdentifier();
+ final InstanceIdentifier<T> identifier = modification.getRootPath().path();
if (compareIITail(identifier, II_TO_FLOW_CAPABLE_NODE_CONNECTOR)) {
InstanceIdentifier<NodeConnector> nodeConnectorInstanceId = identifier
.firstIdentifierOf(NodeConnector.class);
odl:use-default-for-reference-types="true">
<reference id="dataBroker" interface="org.opendaylight.mdsal.binding.api.DataBroker"/>
- <reference id="rpcService" interface="org.opendaylight.mdsal.binding.api.RpcConsumerRegistry"/>
+ <reference id="rpcService" interface="org.opendaylight.mdsal.binding.api.RpcService"/>
<reference id="rpcProviderService" interface="org.opendaylight.mdsal.binding.api.RpcProviderService"/>
<reference id="deviceOwnershipService" interface="org.opendaylight.openflowplugin.applications.deviceownershipservice.DeviceOwnershipService"/>
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.openflowplugin.applications.deviceownershipservice.DeviceOwnershipService;
import org.opendaylight.openflowplugin.libraries.liblldp.PacketException;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
@Mock
private DeviceOwnershipService deviceOwnershipService;
@Mock
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Mock
private RpcProviderService rpcProviderService;
final InstanceIdentifier<T> ii, final FlowCapableNodeConnector connector) {
final DataTreeModification dataTreeModification = mock(DataTreeModification.class);
when(dataTreeModification.getRootNode()).thenReturn(mock(DataObjectModification.class));
- DataTreeIdentifier<T> identifier = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, ii);
- when(dataTreeModification.getRootNode().getModificationType()).thenReturn(type);
+ DataTreeIdentifier<T> identifier = DataTreeIdentifier.of(LogicalDatastoreType.OPERATIONAL, ii);
+ when(dataTreeModification.getRootNode().modificationType()).thenReturn(type);
when(dataTreeModification.getRootPath()).thenReturn(identifier);
- when(dataTreeModification.getRootNode().getDataAfter()).thenReturn(connector);
+ when(dataTreeModification.getRootNode().dataAfter()).thenReturn(connector);
return dataTreeModification;
}
}
import static java.util.Objects.requireNonNull;
-import java.util.Collection;
+import java.util.List;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.opendaylight.infrautils.utils.concurrent.LoggingFutures;
-import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType;
+import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.mdsal.binding.api.DataTreeModification;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.applications.deviceownershipservice.DeviceOwnershipService;
@Singleton
@Component(service = { })
-public final class DefaultConfigPusher implements AutoCloseable, ClusteredDataTreeChangeListener<FlowCapableNode> {
+public final class DefaultConfigPusher implements AutoCloseable, DataTreeChangeListener<FlowCapableNode> {
private static final Logger LOG = LoggerFactory.getLogger(DefaultConfigPusher.class);
private final DeviceOwnershipService deviceOwnershipService;
@Inject
@Activate
- public DefaultConfigPusher(@Reference final DataBroker dataBroker, @Reference final RpcConsumerRegistry rpcService,
+ public DefaultConfigPusher(@Reference final DataBroker dataBroker, @Reference final RpcService rpcService,
@Reference final DeviceOwnershipService deviceOwnershipService) {
this.deviceOwnershipService = requireNonNull(deviceOwnershipService);
setConfig = rpcService.getRpc(SetConfig.class);
- reg = dataBroker.registerDataTreeChangeListener(
- DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
+ reg = dataBroker.registerTreeChangeListener(
+ DataTreeIdentifier.of(LogicalDatastoreType.OPERATIONAL,
InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class)), this);
LOG.info("DefaultConfigPusher has started.");
}
}
@Override
- public void onDataTreeChanged(final Collection<DataTreeModification<FlowCapableNode>> modifications) {
+ public void onDataTreeChanged(final List<DataTreeModification<FlowCapableNode>> modifications) {
for (var modification : modifications) {
- if (modification.getRootNode().getModificationType() == ModificationType.WRITE) {
- final var nodeId = modification.getRootPath().getRootIdentifier().firstKeyOf(Node.class)
- .getId().getValue();
+ if (modification.getRootNode().modificationType() == ModificationType.WRITE) {
+ final var nodeId = modification.getRootPath().path().firstKeyOf(Node.class).getId().getValue();
if (deviceOwnershipService.isEntityOwned(nodeId)) {
LoggingFutures.addErrorLogging(setConfig.invoke(new SetConfigInputBuilder()
.setFlag(SwitchConfigFlag.FRAGNORMAL.toString())
.setMissSearchLength(OFConstants.OFPCML_NO_BUFFER)
- .setNode(new NodeRef(
- modification.getRootPath().getRootIdentifier().firstIdentifierOf(Node.class)))
+ .setNode(new NodeRef(modification.getRootPath().path().firstIdentifierOf(Node.class)))
.build()), LOG, "addFlow");
} else {
LOG.debug("Node {} is not owned by this controller, so skip setting config", nodeId);
import org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.mdsal.binding.api.DataTreeModification;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.applications.deviceownershipservice.DeviceOwnershipService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.SetConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.SetConfigInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
@Mock
private DataBroker dataBroker;
@Mock
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Mock
private SetConfig setConfig;
@Mock
@Mock
private DeviceOwnershipService deviceOwnershipService;
@Mock
- private ListenerRegistration<?> reg;
+ private Registration reg;
@Captor
private ArgumentCaptor<SetConfigInput> setConfigInputCaptor;
@Before
public void setUp() {
doReturn(RpcResultBuilder.success().buildFuture()).when(setConfig).invoke(any());
- doReturn(reg).when(dataBroker).registerDataTreeChangeListener(any(), any());
+ doReturn(reg).when(dataBroker).registerTreeChangeListener(any(), any());
doReturn(setConfig).when(rpcService).getRpc(any());
defaultConfigPusher = new DefaultConfigPusher(dataBroker, rpcService, deviceOwnershipService);
- final var identifier = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
+ final var identifier = DataTreeIdentifier.of(LogicalDatastoreType.OPERATIONAL,
NODE_IID.augmentation(FlowCapableNode.class));
when(dataTreeModification.getRootPath()).thenReturn(identifier);
when(dataTreeModification.getRootNode()).thenReturn(dataObjectModification);
- when(dataTreeModification.getRootNode().getModificationType()).thenReturn(ModificationType.WRITE);
+ when(dataTreeModification.getRootNode().modificationType()).thenReturn(ModificationType.WRITE);
when(deviceOwnershipService.isEntityOwned(any())).thenReturn(true);
}
package org.opendaylight.openflowplugin.applications.southboundcli;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Singleton;
-import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.mdsal.binding.api.DataTreeModification;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
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.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
@Singleton
@Component(service = DpnTracker.class)
-public final class DefaultDpnTracker
- implements DpnTracker, ClusteredDataTreeChangeListener<FlowCapableNode>, AutoCloseable {
+public final class DefaultDpnTracker implements DpnTracker, DataTreeChangeListener<FlowCapableNode>, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(DefaultDpnTracker.class);
public static final String DEFAULT_DPN_NAME = "UNKNOWN";
public static final String SEPARATOR = ":";
private final Map<Long, String> dpnIdToNameCache = new HashMap<>();
- private final ListenerRegistration<?> listenerReg;
+ private final Registration listenerReg;
@Inject
@Activate
public DefaultDpnTracker(@Reference final DataBroker dataBroker) {
- listenerReg = dataBroker.registerDataTreeChangeListener(
- DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
+ listenerReg = dataBroker.registerTreeChangeListener(
+ DataTreeIdentifier.of(LogicalDatastoreType.OPERATIONAL,
InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class)), this);
}
}
@Override
- public synchronized void onDataTreeChanged(final Collection<DataTreeModification<FlowCapableNode>> changes) {
+ public synchronized void onDataTreeChanged(final List<DataTreeModification<FlowCapableNode>> changes) {
for (var change : changes) {
- final var key = change.getRootPath().getRootIdentifier();
+ final var key = change.getRootPath().path();
final var mod = change.getRootNode();
final var nodeIdent = key.firstIdentifierOf(FlowCapableNode.class);
- switch (mod.getModificationType()) {
+ switch (mod.modificationType()) {
case DELETE:
- remove(nodeIdent, mod.getDataBefore());
+ remove(nodeIdent, mod.dataBefore());
break;
case SUBTREE_MODIFIED:
- update(nodeIdent, mod.getDataBefore(), mod.getDataAfter());
+ update(nodeIdent, mod.dataBefore(), mod.dataAfter());
break;
case WRITE:
if (mod.getDataBefore() == null) {
- add(nodeIdent, mod.getDataAfter());
+ add(nodeIdent, mod.dataAfter());
} else {
- update(nodeIdent, mod.getDataBefore(), mod.getDataAfter());
+ update(nodeIdent, mod.dataBefore(), mod.dataAfter());
}
break;
default:
- throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
+ throw new IllegalArgumentException("Unhandled modification type " + mod.modificationType());
}
}
}
import static java.util.Objects.requireNonNull;
-import java.util.Collection;
+import java.util.List;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.mdsal.binding.api.DataTreeModification;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.applications.deviceownershipservice.DeviceOwnershipService;
@Activate
public LLDPPacketPuntEnforcer(@Reference final DataBroker dataBroker,
@Reference final DeviceOwnershipService deviceOwnershipService,
- @Reference final RpcConsumerRegistry rpcService) {
+ @Reference final RpcService rpcService) {
this.deviceOwnershipService = requireNonNull(deviceOwnershipService);
addFlow = rpcService.getRpc(AddFlow.class);
listenerRegistration = dataBroker.registerDataTreeChangeListener(
}
@Override
- public void onDataTreeChanged(final Collection<DataTreeModification<FlowCapableNode>> modifications) {
+ public void onDataTreeChanged(final List<DataTreeModification<FlowCapableNode>> modifications) {
for (var modification : modifications) {
- if (modification.getRootNode().getModificationType() == ModificationType.WRITE) {
- final var nodeId = modification.getRootPath().getRootIdentifier()
- .firstKeyOf(Node.class).getId().getValue();
+ if (modification.getRootNode().modificationType() == ModificationType.WRITE) {
+ final var nodeId = modification.getRootPath().path().firstKeyOf(Node.class).getId().getValue();
if (deviceOwnershipService.isEntityOwned(nodeId)) {
LoggingFutures.addErrorLogging(addFlow.invoke(new AddFlowInputBuilder(createFlow())
- .setNode(new NodeRef(modification.getRootPath()
- .getRootIdentifier().firstIdentifierOf(Node.class)))
+ .setNode(new NodeRef(modification.getRootPath().path().firstIdentifierOf(Node.class)))
.build()), LOG, "addFlow");
} else {
LOG.debug("Node {} is not owned by this controller, so skip adding LLDP table miss flow", nodeId);
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import java.util.Collections;
+import java.util.List;
import java.util.Map;
import org.junit.After;
import org.junit.Before;
import org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.mdsal.binding.api.DataTreeModification;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.openflowplugin.applications.deviceownershipservice.DeviceOwnershipService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
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.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.opendaylight.yangtools.yang.common.Uint16;
@Mock
private DataBroker dataBroker;
@Mock
- private ListenerRegistration<?> reg;
+ private Registration reg;
@Mock
- private RpcConsumerRegistry rpcService;
+ private RpcService rpcService;
@Mock
private AddFlow addFlow;
@Mock
LogicalDatastoreType.OPERATIONAL, NODE_IID.augmentation(FlowCapableNode.class));
when(dataTreeModification.getRootPath()).thenReturn(identifier);
when(dataTreeModification.getRootNode()).thenReturn(mock(DataObjectModification.class));
- when(dataTreeModification.getRootNode().getModificationType()).thenReturn(ModificationType.WRITE);
+ when(dataTreeModification.getRootNode().modificationType()).thenReturn(ModificationType.WRITE);
when(deviceOwnershipService.isEntityOwned(any())).thenReturn(true);
}
@Test
public void testOnDataTreeChanged() {
- lldpPacketPuntEnforcer.onDataTreeChanged(Collections.singleton(dataTreeModification));
+ lldpPacketPuntEnforcer.onDataTreeChanged(List.of(dataTreeModification));
verify(addFlow).invoke(addFlowInputCaptor.capture());
AddFlowInput captured = addFlowInputCaptor.getValue();
assertEquals(NODE_IID, captured.getNode().getValue());
<packaging>bundle</packaging>
<dependencies>
+ <dependency>
+ <groupId>com.github.spotbugs</groupId>
+ <artifactId>spotbugs-annotations</artifactId>
+ <optional>true</optional>
+ </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
package org.opendaylight.openflowplugin.applications.topology.lldp;
import com.google.common.annotations.VisibleForTesting;
-import java.util.Collection;
import java.util.Date;
+import java.util.List;
import java.util.Map.Entry;
import java.util.Timer;
import java.util.TimerTask;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private final NotificationPublishService notificationService;
private final AutoCloseable configurationServiceRegistration;
private final EntityOwnershipService eos;
- private ListenerRegistration<?> listenerRegistration;
+ private Registration listenerRegistration;
/**
* default ctor - start timer.
this.notificationService = notificationService;
configurationServiceRegistration = configurationService.registerListener(this);
eos = entityOwnershipService;
- final DataTreeIdentifier<Link> dtiToNodeConnector = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
+ final DataTreeIdentifier<Link> dtiToNodeConnector = DataTreeIdentifier.of(LogicalDatastoreType.OPERATIONAL,
II_TO_LINK);
try {
listenerRegistration = dataBroker.registerDataTreeChangeListener(dtiToNodeConnector, LLDPLinkAger.this);
topologyLldpDiscoveryConfig.getTopologyLldpInterval().getValue().toJava());
}
- public void put(LinkDiscovered link) {
+ public void put(final LinkDiscovered link) {
Date expires = new Date();
expires.setTime(expires.getTime() + linkExpirationTime);
linkToDate.put(link, expires);
}
@Override
- public void onDataTreeChanged(@NonNull Collection<DataTreeModification<Link>> changes) {
+ public void onDataTreeChanged(final List<DataTreeModification<Link>> changes) {
for (DataTreeModification<Link> modification : changes) {
- switch (modification.getRootNode().getModificationType()) {
+ switch (modification.getRootNode().modificationType()) {
case WRITE:
break;
case SUBTREE_MODIFIED:
processLinkDeleted(modification.getRootNode());
break;
default:
- LOG.error("Unhandled modification type: {}", modification.getRootNode().getModificationType());
+ LOG.error("Unhandled modification type: {}", modification.getRootNode().modificationType());
}
}
}
return linkToDate.containsKey(linkDiscovered);
}
- private void processLinkDeleted(DataObjectModification<Link> rootNode) {
+ private void processLinkDeleted(final DataObjectModification<Link> rootNode) {
Link link = rootNode.getDataBefore();
LOG.trace("Removing link {} from linkToDate cache", link);
LinkDiscovered linkDiscovered = LLDPDiscoveryUtils.toLLDPLinkDiscovered(link);
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-singleton-common-api</artifactId>
+ <artifactId>mdsal-singleton-api</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.openflowplugin.model</groupId>
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
static final InstanceIdentifier<Topology> II_TO_TOPOLOGY = InstanceIdentifier.create(NetworkTopology.class)
.child(Topology.class, new TopologyKey(new TopologyId(FlowCapableTopologyProvider.TOPOLOGY_ID)));
- protected final ListenerRegistration<?> listenerRegistration;
+ protected final Registration listenerRegistration;
protected OperationProcessor operationProcessor;
@SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR",
final InstanceIdentifier<T> ii) {
this.operationProcessor = requireNonNull(operationProcessor);
listenerRegistration = dataBroker.registerDataTreeChangeListener(
- DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, ii), this);
+ DataTreeIdentifier.of(LogicalDatastoreType.OPERATIONAL, ii), this);
}
@Override
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.NotificationService;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
-import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
+import org.opendaylight.mdsal.singleton.api.ClusterSingletonService;
+import org.opendaylight.mdsal.singleton.api.ClusterSingletonServiceProvider;
+import org.opendaylight.mdsal.singleton.api.ServiceGroupIdentifier;
import org.opendaylight.openflowplugin.common.txchain.TransactionChainManager;
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;
private final OperationProcessor processor;
private Registration listenerRegistration;
- private ClusterSingletonServiceRegistration singletonServiceRegistration;
+ private Registration singletonServiceRegistration;
@Inject
@Activate
@Override
public ServiceGroupIdentifier getIdentifier() {
- return ServiceGroupIdentifier.create(TOPOLOGY_PROVIDER);
+ return new ServiceGroupIdentifier(TOPOLOGY_PROVIDER);
}
private boolean isFlowTopologyExist(final InstanceIdentifier<Topology> path) {
*/
package org.opendaylight.openflowplugin.applications.topology.manager;
-import java.util.Collection;
+import java.util.List;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Singleton;
}
@Override
- public void onDataTreeChanged(final Collection<DataTreeModification<FlowCapableNode>> modifications) {
+ public void onDataTreeChanged(final List<DataTreeModification<FlowCapableNode>> modifications) {
for (DataTreeModification<FlowCapableNode> modification : modifications) {
- switch (modification.getRootNode().getModificationType()) {
+ switch (modification.getRootNode().modificationType()) {
case WRITE:
processAddedNode(modification);
break;
break;
default:
throw new IllegalArgumentException(
- "Unhandled modification type: {}" + modification.getRootNode().getModificationType());
+ "Unhandled modification type: {}" + modification.getRootNode().modificationType());
}
}
}
}
private void processRemovedNode(final DataTreeModification<FlowCapableNode> modification) {
- final var iiToNodeInInventory = modification.getRootPath().getRootIdentifier();
+ final var iiToNodeInInventory = modification.getRootPath().path();
final var nodeId = provideTopologyNodeId(iiToNodeInInventory);
final var iiToTopologyRemovedNode = provideIIToTopologyNode(nodeId);
if (iiToTopologyRemovedNode != null) {
}
private void processAddedNode(final DataTreeModification<FlowCapableNode> modification) {
- final InstanceIdentifier<FlowCapableNode> iiToNodeInInventory = modification.getRootPath().getRootIdentifier();
+ final InstanceIdentifier<FlowCapableNode> iiToNodeInInventory = modification.getRootPath().path();
final NodeId nodeIdInTopology = provideTopologyNodeId(iiToNodeInInventory);
if (nodeIdInTopology != null) {
final InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology
*/
package org.opendaylight.openflowplugin.applications.topology.manager;
-import java.util.Collection;
+import java.util.List;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import javax.annotation.PreDestroy;
}
@Override
- public void onDataTreeChanged(final Collection<DataTreeModification<FlowCapableNodeConnector>> modifications) {
+ public void onDataTreeChanged(final List<DataTreeModification<FlowCapableNodeConnector>> modifications) {
for (DataTreeModification<FlowCapableNodeConnector> modification : modifications) {
- switch (modification.getRootNode().getModificationType()) {
+ switch (modification.getRootNode().modificationType()) {
case WRITE:
processAddedTerminationPoints(modification);
break;
break;
default:
throw new IllegalArgumentException(
- "Unhandled modification type: {}" + modification.getRootNode().getModificationType());
+ "Unhandled modification type: {}" + modification.getRootNode().modificationType());
}
}
}
}
private void processRemovedTerminationPoints(final DataTreeModification<FlowCapableNodeConnector> modification) {
- final InstanceIdentifier<FlowCapableNodeConnector> removedNode = modification.getRootPath().getRootIdentifier();
+ final InstanceIdentifier<FlowCapableNodeConnector> removedNode = modification.getRootPath().path();
final TpId terminationPointId = provideTopologyTerminationPointId(removedNode);
final InstanceIdentifier<TerminationPoint> iiToTopologyTerminationPoint = provideIIToTopologyTerminationPoint(
terminationPointId, removedNode);
}
private void processAddedTerminationPoints(final DataTreeModification<FlowCapableNodeConnector> modification) {
- final InstanceIdentifier<FlowCapableNodeConnector> iiToNodeInInventory = modification.getRootPath()
- .getRootIdentifier();
+ final InstanceIdentifier<FlowCapableNodeConnector> iiToNodeInInventory = modification.getRootPath().path();
TpId terminationPointIdInTopology = provideTopologyTerminationPointId(iiToNodeInInventory);
if (terminationPointIdInTopology != null) {
InstanceIdentifier<TerminationPoint> iiToTopologyTerminationPoint = provideIIToTopologyTerminationPoint(
terminationPointIdInTopology, iiToNodeInInventory);
TerminationPoint point = prepareTopologyTerminationPoint(terminationPointIdInTopology, iiToNodeInInventory);
sendToTransactionChain(point, iiToTopologyTerminationPoint);
- removeLinks(modification.getRootNode().getDataAfter(), point);
+ removeLinks(modification.getRootNode().dataAfter(), point);
} else {
LOG.debug("Inventory node connector key is null. Data can't be written to topology termination point");
}
*/
package org.opendaylight.openflowplugin.applications.topology.manager;
-import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.mdsal.binding.api.DataTreeModification;
import org.opendaylight.mdsal.binding.api.TransactionChain;
-import org.opendaylight.mdsal.binding.api.TransactionChainListener;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder;
@Before
public void setUp() {
- doReturn(mockTxChain).when(mockDataBroker).createTransactionChain(any(TransactionChainListener.class));
+ doReturn(mockTxChain).when(mockDataBroker).createTransactionChain();
processor = new OperationProcessor(mockDataBroker);
final InstanceIdentifier<T> ii,
final boolean getDataAfter) {
final DataTreeModification dataTreeModification = mock(DataTreeModification.class);
- final DataTreeIdentifier<T> identifier = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, ii);
+ final DataTreeIdentifier<T> identifier = DataTreeIdentifier.of(LogicalDatastoreType.OPERATIONAL, ii);
when(dataTreeModification.getRootNode()).thenReturn(mock(DataObjectModification.class));
- when(dataTreeModification.getRootNode().getModificationType()).thenReturn(type);
+ when(dataTreeModification.getRootNode().modificationType()).thenReturn(type);
when(dataTreeModification.getRootPath()).thenReturn(identifier);
if (getDataAfter) {
- when(dataTreeModification.getRootNode().getDataAfter()).thenReturn(mock(FlowCapableNodeConnector.class));
+ when(dataTreeModification.getRootNode().dataAfter()).thenReturn(mock(FlowCapableNodeConnector.class));
}
return dataTreeModification;
}
package org.opendaylight.openflowplugin.applications.topology.manager;
import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
import org.opendaylight.mdsal.binding.api.TransactionChain;
-import org.opendaylight.mdsal.binding.api.TransactionChainListener;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkDiscoveredBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.topology.discovery.rev130819.LinkRemovedBuilder;
@Before
public void setUp() {
- doReturn(mockTxChain).when(mockDataBroker)
- .createTransactionChain(any(TransactionChainListener.class));
+ doReturn(mockTxChain).when(mockDataBroker).createTransactionChain();
processor = new OperationProcessor(mockDataBroker);
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.SettableFuture;
import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CountDownLatch;
int expDeleteCalls = expDeletedIIDs.length;
CountDownLatch deleteLatch = new CountDownLatch(expDeleteCalls);
- ArgumentCaptor<InstanceIdentifier> deletedLinkIDs =
- ArgumentCaptor.forClass(InstanceIdentifier.class);
+ ArgumentCaptor<InstanceIdentifier> deletedLinkIDs = ArgumentCaptor.forClass(InstanceIdentifier.class);
setupStubbedDeletes(mockTx1, deletedLinkIDs, deleteLatch);
doReturn(mockTx1).when(mockTxChain).newReadWriteTransaction();
DataTreeModification dataTreeModification = setupDataTreeChange(DELETE, invNodeID, false);
- nodeChangeListener.onDataTreeChanged(Collections.singleton(dataTreeModification));
+ nodeChangeListener.onDataTreeChanged(List.of(dataTreeModification));
waitForSubmit(submitLatch1);
doReturn(mockTx).when(mockTxChain).newReadWriteTransaction();
DataTreeModification dataTreeModification = setupDataTreeChange(DELETE, invNodeID, false);
- nodeChangeListener.onDataTreeChanged(Collections.singleton(dataTreeModification));
+ nodeChangeListener.onDataTreeChanged(List.of(dataTreeModification));
waitForSubmit(submitLatch);
doReturn(mockTx).when(mockTxChain).newReadWriteTransaction();
DataTreeModification dataTreeModification = setupDataTreeChange(WRITE, invNodeID, false);
- nodeChangeListener.onDataTreeChanged(Collections.singleton(dataTreeModification));
+ nodeChangeListener.onDataTreeChanged(List.of(dataTreeModification));
waitForSubmit(submitLatch);
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.SettableFuture;
import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CountDownLatch;
doReturn(mockTx1).when(mockTxChain).newReadWriteTransaction();
DataTreeModification dataTreeModification = setupDataTreeChange(DELETE, invNodeConnID, false);
- terminationPointListener.onDataTreeChanged(Collections.singleton(dataTreeModification));
+ terminationPointListener.onDataTreeChanged(List.of(dataTreeModification));
waitForSubmit(submitLatch1);
doReturn(mockTx).when(mockTxChain).newReadWriteTransaction();
DataTreeModification dataTreeModification = setupDataTreeChange(DELETE, invNodeConnID, false);
- terminationPointListener.onDataTreeChanged(Collections.singleton(dataTreeModification));
+ terminationPointListener.onDataTreeChanged(List.of(dataTreeModification));
waitForSubmit(submitLatch);
doReturn(mockTx).when(mockTxChain).newReadWriteTransaction();
DataTreeModification dataTreeModification = setupDataTreeChange(WRITE, invNodeConnID, true);
- terminationPointListener.onDataTreeChanged(Collections.singleton(dataTreeModification));
+ terminationPointListener.onDataTreeChanged(List.of(dataTreeModification));
waitForSubmit(submitLatch);
doReturn(mockTx).when(mockTxChain).newReadWriteTransaction();
DataTreeModification dataTreeModification = setupDataTreeChange(WRITE, invNodeConnID, false);
- when(dataTreeModification.getRootNode().getDataAfter())
+ when(dataTreeModification.getRootNode().dataAfter())
.thenReturn(provideFlowCapableNodeConnector(true, false));
- terminationPointListener.onDataTreeChanged(Collections.singleton(dataTreeModification));
+ terminationPointListener.onDataTreeChanged(List.of(dataTreeModification));
waitForDeletes(1, deleteLatch);
doReturn(mockTx).when(mockTxChain).newReadWriteTransaction();
DataTreeModification dataTreeModification = setupDataTreeChange(WRITE, invNodeConnID, false);
- when(dataTreeModification.getRootNode().getDataAfter())
+ when(dataTreeModification.getRootNode().dataAfter())
.thenReturn(provideFlowCapableNodeConnector(false, true));
- terminationPointListener.onDataTreeChanged(Collections.singleton(dataTreeModification));
+ terminationPointListener.onDataTreeChanged(List.of(dataTreeModification));
waitForDeletes(1, deleteLatch);
<dependencies>
<dependency>
- <groupId>${project.groupId}.openflowjava</groupId>
+ <groupId>com.github.spotbugs</groupId>
+ <artifactId>spotbugs-annotations</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-buffer</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.openflowplugin.openflowjava</groupId>
<artifactId>openflow-protocol-api</artifactId>
</dependency>
<dependency>
- <groupId>${project.groupId}.openflowjava</groupId>
+ <groupId>org.opendaylight.openflowplugin.openflowjava</groupId>
<artifactId>openflow-protocol-spi</artifactId>
</dependency>
<dependency>
- <groupId>${project.groupId}.openflowjava</groupId>
+ <groupId>org.opendaylight.openflowplugin.openflowjava</groupId>
<artifactId>openflowjava-util</artifactId>
</dependency>
<dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>org.opendaylight.openflowplugin</groupId>
<artifactId>openflowjava-extension-nicira-api</artifactId>
</dependency>
- <dependency>
- <groupId>io.netty</groupId>
- <artifactId>netty-buffer</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-common-netty</artifactId>
</dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
import javax.inject.Inject;
import javax.inject.Singleton;
import org.opendaylight.infrautils.utils.concurrent.LoggingFutures;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
@Inject
@Activate
- public Test(@Reference final RpcConsumerRegistry rpcService,
- @Reference final RpcProviderService rpcProviderService) {
+ public Test(@Reference final RpcService rpcService, @Reference final RpcProviderService rpcProviderService) {
addFlow = rpcService.getRpc(AddFlow.class);
reg = rpcProviderService.registerRpcImplementation(this);
}
<dependency>
<groupId>org.opendaylight.netconf</groupId>
<artifactId>netconf-artifacts</artifactId>
- <version>6.0.6</version>
+ <version>7.0.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-openflowplugin-flow-services-rest">
<feature name="odl-openflowplugin-flow-services-rest">
- <feature version="[6,7)">odl-restconf</feature>
+ <feature version="[7,8)">odl-restconf</feature>
</feature>
</features>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-artifacts</artifactId>
- <version>12.0.4</version>
+ <version>13.0.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>controller-artifacts</artifactId>
- <version>8.0.4</version>
+ <version>9.0.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<?xml version="1.0" encoding="UTF-8"?>
<features name="odl-openflowplugin-nsf-model-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0">
<feature name="odl-openflowplugin-nsf-model" version="${project.version}">
- <feature version="[12,13)">odl-mdsal-model-draft-clemm-netmod-yang-network-topo-01-minimal</feature>
- <feature version="[12,13)">odl-mdsal-model-odl-l2-types</feature>
+ <feature version="[13,14)">odl-mdsal-model-draft-clemm-netmod-yang-network-topo-01-minimal</feature>
+ <feature version="[13,14)">odl-mdsal-model-odl-l2-types</feature>
</feature>
</features>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>controller-artifacts</artifactId>
- <version>8.0.4</version>
+ <version>9.0.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<features name="openflowplugin-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0">
<feature name="odl-openflowplugin-southbound" version="${project.version}">
<configfile finalname="etc/org.opendaylight.openflowplugin.cfg">mvn:org.opendaylight.openflowplugin/openflowplugin-blueprint-config/${project.version}/cfg/config</configfile>
- <feature version="[8,9)">odl-mdsal-broker</feature>
+ <feature version="[9,10)">odl-mdsal-broker</feature>
<feature version="[6,7)">odl-infrautils-diagstatus</feature>
</feature>
</features>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-artifacts</artifactId>
- <version>11.0.5</version>
+ <version>13.0.1</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-artifacts</artifactId>
- <version>12.0.4</version>
+ <version>13.0.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<feature name='odl-openflowjava-protocol' version='${project.version}'>
<configfile finalname="etc/opendaylight/datastore/initial/config/default-openflow-connection-config.xml">mvn:org.opendaylight.openflowplugin.openflowjava/openflowjava-blueprint-config/${project.version}/xml/config</configfile>
<configfile finalname="etc/opendaylight/datastore/initial/config/legacy-openflow-connection-config.xml">mvn:org.opendaylight.openflowplugin.openflowjava/openflowjava-blueprint-config/${project.version}/xml/legacyConfig</configfile>
- <feature version="[11,12)">odl-yangtools-netty</feature>
- <feature version="[12,13)">odl-mdsal-model-rfc6991</feature>
+ <feature version="[13,14)">odl-yangtools-netty</feature>
+ <feature version="[13,14)">odl-mdsal-model-rfc6991</feature>
<feature version="[6,7)">odl-infrautils-diagstatus</feature>
</feature>
</features>
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-singleton-common-api</artifactId>
+ <artifactId>mdsal-singleton-api</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
package org.opendaylight.openflowplugin.api.openflow;
import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
+import org.opendaylight.mdsal.singleton.api.ClusterSingletonService;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
import org.opendaylight.openflowplugin.api.openflow.lifecycle.ContextChainMastershipWatcher;
@Override
void close();
-}
\ No newline at end of file
+}
package org.opendaylight.openflowplugin.api.openflow.device;
import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
+import org.opendaylight.mdsal.singleton.api.ServiceGroupIdentifier;
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.inventory.rev130819.nodes.NodeKey;
package org.opendaylight.openflowplugin.api.openflow.lifecycle;
import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
+import org.opendaylight.mdsal.singleton.api.ClusterSingletonService;
+import org.opendaylight.mdsal.singleton.api.ClusterSingletonServiceProvider;
import org.opendaylight.openflowplugin.api.openflow.OFPContext;
import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceRemovedHandler;
* @param deviceRemovedHandler device removed handler
*/
void registerDeviceRemovedHandler(@NonNull DeviceRemovedHandler deviceRemovedHandler);
-}
\ No newline at end of file
+}
import static java.util.Objects.requireNonNull;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.FutureCallback;
import org.checkerframework.checker.lock.qual.Holding;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
-import org.opendaylight.mdsal.binding.api.Transaction;
import org.opendaylight.mdsal.binding.api.TransactionChain;
import org.opendaylight.mdsal.binding.api.TransactionChainClosedException;
-import org.opendaylight.mdsal.binding.api.TransactionChainListener;
import org.opendaylight.mdsal.binding.api.WriteTransaction;
import org.opendaylight.mdsal.common.api.CommitInfo;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Empty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The openflowplugin-impl.org.opendaylight.openflowplugin.impl.device
- * package protected class for controlling {@link WriteTransaction} life cycle. It is
- * a {@link TransactionChainListener} and provide package protected methods for writeToTransaction
+ * package protected class for controlling {@link WriteTransaction} life cycle. It listens on chains and provides
+ * package-protected methods for writeToTransaction
* method (wrapped {@link WriteTransaction#put(LogicalDatastoreType, InstanceIdentifier, DataObject)})
* and submitTransaction method (wrapped {@link WriteTransaction#commit()}).
*/
-public class TransactionChainManager implements TransactionChainListener, AutoCloseable {
-
+public class TransactionChainManager implements AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(TransactionChainManager.class);
private static final String CANNOT_WRITE_INTO_TRANSACTION = "Cannot write into transaction.";
@Holding("txLock")
private void createTxChain() {
- TransactionChain txChainFactoryTemp = transactionChain;
- transactionChain = dataBroker.createTransactionChain(TransactionChainManager.this);
- if (txChainFactoryTemp != null) {
- txChainFactoryTemp.close();
+ final var prev = transactionChain;
+ final var next = dataBroker.createTransactionChain();
+ transactionChain = next;
+ if (prev != null) {
+ prev.close();
}
+ next.addCallback(new FutureCallback<Empty>() {
+ @Override
+ public void onSuccess(final Empty result) {
+ // No-op
+ }
+
+ @Override
+ public void onFailure(final Throwable cause) {
+ onTransactionChainFailed(next, cause);
+ }
+ });
}
public boolean initialSubmitWriteTransaction() {
}
/**
- * Method change status for TxChainManager to WORKING and it has to make
- * registration for this class instance as {@link TransactionChainListener} to provide possibility a make DS
- * transactions. Call this method for MASTER role only.
+ * Method change status for TxChainManager to WORKING and it has to make registration for this instance as
+ * a {@link TransactionChain} callback to provide possibility a make DS transactions. Call this method for MASTER
+ * role only.
*/
public void activateTransactionManager() {
- if (LOG.isDebugEnabled()) {
- LOG.debug("activateTransactionManager for node {} transaction submit is set to {}",
- nodeId, submitIsEnabled);
- }
+ LOG.debug("activateTransactionManager for node {} transaction submit is set to {}", nodeId, submitIsEnabled);
synchronized (txLock) {
if (TransactionChainManagerStatus.SLEEPING == transactionChainManagerStatus) {
- Preconditions.checkState(transactionChain == null,
- "TxChainFactory survive last close.");
- Preconditions.checkState(writeTx == null,
- "We have some unexpected WriteTransaction.");
+ Preconditions.checkState(transactionChain == null, "TxChainFactory survive last close.");
+ Preconditions.checkState(writeTx == null, "We have some unexpected WriteTransaction.");
transactionChainManagerStatus = TransactionChainManagerStatus.WORKING;
submitIsEnabled = false;
initCommit = true;
}
/**
- * Method change status for TxChainManger to SLEEPING and it unregisters
- * this class instance as {@link TransactionChainListener} so it broke a possibility to write something to DS.
- * Call this method for SLAVE only.
- * @return Future
+ * Method change status for TxChainManger to SLEEPING and it unregisters this instance so it broke a possibility to
+ * write something to DS. Call this method for SLAVE only.
+ *
+ * @return Future competing when deactivation completes
*/
public FluentFuture<?> deactivateTransactionManager() {
- if (LOG.isDebugEnabled()) {
- LOG.debug("deactivateTransactionManager for node {}", nodeId);
- }
+ LOG.debug("deactivateTransactionManager for node {}", nodeId);
final FluentFuture<? extends CommitInfo> future;
synchronized (txLock) {
if (TransactionChainManagerStatus.WORKING == transactionChainManagerStatus) {
transactionChainManagerStatus = TransactionChainManagerStatus.SLEEPING;
- future = txChainShuttingDown();
- Preconditions.checkState(writeTx == null,
- "We have some unexpected WriteTransaction.");
+ future = txChainShuttingDown();
+ Preconditions.checkState(writeTx == null, "We have some unexpected WriteTransaction.");
future.addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
}
}
- @Override
- public void onTransactionChainFailed(final TransactionChain chain,
- final Transaction transaction, final Throwable cause) {
+ @VisibleForTesting
+ void onTransactionChainFailed(final TransactionChain chain, final Throwable cause) {
synchronized (txLock) {
if (TransactionChainManagerStatus.WORKING == transactionChainManagerStatus
&& chain.equals(transactionChain)) {
}
}
- @Override
- public void onTransactionChainSuccessful(final TransactionChain chain) {
- // NOOP
- }
-
@Holding("txLock")
private void ensureTransaction() {
if (writeTx == null && TransactionChainManagerStatus.WORKING == transactionChainManagerStatus
*/
package org.opendaylight.openflowplugin.common.txchain;
-import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import java.util.concurrent.ExecutionException;
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.ReadTransaction;
import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
-import org.opendaylight.mdsal.binding.api.Transaction;
import org.opendaylight.mdsal.binding.api.TransactionChain;
-import org.opendaylight.mdsal.binding.api.TransactionChainListener;
import org.opendaylight.mdsal.common.api.CommitInfo;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-@RunWith(MockitoJUnitRunner.class)
+@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class TransactionChainManagerTest {
-
@Mock
private DataBroker dataBroker;
@Mock
@Before
public void setUp() {
- final ReadTransaction readOnlyTx = Mockito.mock(ReadTransaction.class);
- Mockito.when(dataBroker.createTransactionChain(any(TransactionChainListener.class)))
- .thenReturn(txChain);
+ final ReadTransaction readOnlyTx = mock(ReadTransaction.class);
+ when(dataBroker.createTransactionChain()).thenReturn(txChain);
nodeId = new NodeId("h2g2:42");
nodeKeyIdent = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(nodeId));
txChainManager = new TransactionChainManager(dataBroker, nodeId.getValue());
- Mockito.when(txChain.newReadWriteTransaction()).thenReturn(writeTx);
+ when(txChain.newReadWriteTransaction()).thenReturn(writeTx);
path = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(nodeId));
- Mockito.doReturn(CommitInfo.emptyFluentFuture()).when(writeTx).commit();
+ doReturn(CommitInfo.emptyFluentFuture()).when(writeTx).commit();
txChainManager.activateTransactionManager();
}
- @After
- public void tearDown() {
- Mockito.verifyNoMoreInteractions(txChain, writeTx);
- }
-
@Test
public void testWriteToTransaction() {
final Node data = new NodeBuilder().setId(nodeId).build();
txChainManager.writeToTransaction(LogicalDatastoreType.CONFIGURATION, path, data, false);
- Mockito.verify(txChain).newReadWriteTransaction();
- Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data);
+ verify(txChain).newReadWriteTransaction();
+ verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data);
}
/**
txChainManager.writeToTransaction(LogicalDatastoreType.CONFIGURATION, path, data, false);
txChainManager.submitTransaction();
- Mockito.verify(txChain).newReadWriteTransaction();
- Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data);
- Mockito.verify(writeTx).commit();
+ verify(txChain).newReadWriteTransaction();
+ verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data);
+ verify(writeTx).commit();
}
/**
txChainManager.writeToTransaction(LogicalDatastoreType.CONFIGURATION, path, data, false);
txChainManager.submitTransaction();
- Mockito.verify(txChain).newReadWriteTransaction();
- Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data);
- Mockito.verify(writeTx, Mockito.never()).commit();
+ verify(txChain).newReadWriteTransaction();
+ verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data);
+ verify(writeTx, never()).commit();
}
@Test
public void testSubmitTransactionFailed() {
- Mockito.doReturn(FluentFutures.immediateFailedFluentFuture(new ExecutionException(new Throwable("mock"))))
+ doReturn(FluentFutures.immediateFailedFluentFuture(new ExecutionException(new Throwable("mock"))))
.when(writeTx).commit();
final Node data = new NodeBuilder().setId(nodeId).build();
txChainManager.initialSubmitWriteTransaction();
txChainManager.writeToTransaction(LogicalDatastoreType.CONFIGURATION, path, data, false);
txChainManager.submitTransaction();
- Mockito.verify(txChain).newReadWriteTransaction();
- Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data);
- Mockito.verify(writeTx).commit();
+ verify(txChain).newReadWriteTransaction();
+ verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data);
+ verify(writeTx).commit();
}
/**
txChainManager.writeToTransaction(LogicalDatastoreType.CONFIGURATION, path, data, false);
txChainManager.writeToTransaction(LogicalDatastoreType.CONFIGURATION, path, data, false);
- Mockito.verify(txChain).newReadWriteTransaction();
- Mockito.verify(writeTx, Mockito.times(2)).put(LogicalDatastoreType.CONFIGURATION, path, data);
- Mockito.verify(writeTx, Mockito.never()).commit();
+ verify(txChain).newReadWriteTransaction();
+ verify(writeTx, times(2)).put(LogicalDatastoreType.CONFIGURATION, path, data);
+ verify(writeTx, never()).commit();
}
@Test
public void testOnTransactionChainFailed() {
- txChainManager.onTransactionChainFailed(txChain, Mockito.mock(Transaction.class),
- Mockito.mock(Throwable.class));
- Mockito.verify(txChain).close();
- Mockito.verify(dataBroker, Mockito.times(2)).createTransactionChain(txChainManager);
- }
-
- @Test
- public void testOnTransactionChainSuccessful() {
- txChainManager.onTransactionChainSuccessful(transactionChain);
- // NOOP
- Mockito.verifyNoInteractions(transactionChain);
+ txChainManager.onTransactionChainFailed(txChain, mock(Throwable.class));
+ verify(txChain).close();
+ verify(dataBroker, times(2)).createTransactionChain();
}
@Test
public void testAddDeleteOperationTotTxChain() {
txChainManager.addDeleteOperationToTxChain(LogicalDatastoreType.CONFIGURATION, path);
- Mockito.verify(txChain).newReadWriteTransaction();
- Mockito.verify(writeTx).delete(LogicalDatastoreType.CONFIGURATION, path);
+ verify(txChain).newReadWriteTransaction();
+ verify(writeTx).delete(LogicalDatastoreType.CONFIGURATION, path);
}
@Test
public void testDeactivateTransactionChainManager() {
txChainManager.deactivateTransactionManager();
- Mockito.verify(txChain).close();
+ verify(txChain).close();
}
@Test
txChainManager.deactivateTransactionManager();
- Mockito.verify(txChain).newReadWriteTransaction();
- Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data);
- Mockito.verify(writeTx, Mockito.never()).commit();
- Mockito.verify(writeTx).cancel();
- Mockito.verify(txChain).close();
+ verify(txChain).newReadWriteTransaction();
+ verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data);
+ verify(writeTx, never()).commit();
+ verify(writeTx).cancel();
+ verify(txChain).close();
}
@Test
txChainManager.writeToTransaction(LogicalDatastoreType.CONFIGURATION, path, data, false);
txChainManager.shuttingDown();
- Mockito.verify(txChain).newReadWriteTransaction();
- Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data);
- Mockito.verify(writeTx).commit();
+ verify(txChain).newReadWriteTransaction();
+ verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data);
+ verify(writeTx).commit();
}
@Test
public void testClose() {
txChainManager.shuttingDown();
txChainManager.close();
- Mockito.verify(txChain).close();
+ verify(txChain).close();
}
}
*/
package org.opendaylight.openflowplugin.impl;
+import static java.util.Objects.requireNonNull;
+
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.TransactionChain;
-import org.opendaylight.mdsal.binding.api.TransactionChainListener;
import org.opendaylight.mdsal.binding.spi.ForwardingDataBroker;
/**
*/
// FIXME: this should not be necessary
public class ForwardingPingPongDataBroker extends ForwardingDataBroker implements PingPongDataBroker {
+ private final @NonNull DataBroker delegate;
- private final DataBroker delegate;
-
- public ForwardingPingPongDataBroker(DataBroker delegate) {
- this.delegate = delegate;
+ public ForwardingPingPongDataBroker(final DataBroker delegate) {
+ this.delegate = requireNonNull(delegate);
}
@Override
}
@Override
- public TransactionChain createTransactionChain(final TransactionChainListener listener) {
- return delegate().createMergingTransactionChain(listener);
+ public TransactionChain createTransactionChain() {
+ return delegate().createMergingTransactionChain();
}
}
import org.opendaylight.mdsal.binding.api.NotificationPublishService;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
+import org.opendaylight.mdsal.singleton.api.ClusterSingletonServiceProvider;
import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProviderList;
import org.opendaylight.openflowplugin.api.openflow.FlowGroupInfoHistories;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
+import org.opendaylight.mdsal.singleton.api.ServiceGroupIdentifier;
import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandlerRegistration;
this.version = requireNonNull(version);
this.datapathId = datapathId;
this.outboundQueueProvider = outboundQueueProvider;
- serviceGroupIdentifier = ServiceGroupIdentifier.create(this.nodeId.getValue());
+ serviceGroupIdentifier = new ServiceGroupIdentifier(this.nodeId.getValue());
}
@Override
import java.math.BigInteger;
import java.net.InetAddress;
import java.time.LocalDateTime;
-import java.util.Collection;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.DataObjectModification;
+import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.mdsal.binding.api.DataTreeModification;
import org.opendaylight.mdsal.binding.api.NotificationPublishService;
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.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
}
- class DeviceConnectionStatusProviderImpl implements DeviceConnectionStatusProvider,
- ClusteredDataTreeChangeListener<Node> {
+ class DeviceConnectionStatusProviderImpl implements DeviceConnectionStatusProvider, DataTreeChangeListener<Node> {
private final Map<BigInteger, LocalDateTime> deviceConnectionMap = new ConcurrentHashMap<>();
- private ListenerRegistration<DeviceConnectionStatusProviderImpl> listenerRegistration;
+ private Registration listenerRegistration;
@Override
@SuppressWarnings({"checkstyle:IllegalCatch"})
public void init() {
- DataTreeIdentifier<Node> treeId = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
- getWildCardPath());
+ final var treeId = DataTreeIdentifier.of(LogicalDatastoreType.OPERATIONAL, getWildCardPath());
try {
- listenerRegistration = dataBroker.registerDataTreeChangeListener(treeId, this);
+ listenerRegistration = dataBroker.registerTreeChangeListener(treeId, this);
} catch (Exception e) {
LOG.error("DeviceConnectionStatusProvider listener registration failed", e);
}
}
@Override
- public void onDataTreeChanged(@NonNull final Collection<DataTreeModification<Node>> changes) {
+ public void onDataTreeChanged(final List<DataTreeModification<Node>> changes) {
requireNonNull(changes, "Changes must not be null!");
for (DataTreeModification<Node> change : changes) {
final DataObjectModification<Node> mod = change.getRootNode();
import org.opendaylight.mdsal.binding.api.NotificationPublishService;
import org.opendaylight.mdsal.binding.api.ReadTransaction;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
+import org.opendaylight.mdsal.singleton.api.ServiceGroupIdentifier;
import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
import org.opendaylight.openflowplugin.api.OFConstants;
import com.google.common.annotations.VisibleForTesting;
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.ThreadFactoryBuilder;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.stream.Collectors;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipChange;
-import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipListenerRegistration;
import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService;
import org.opendaylight.mdsal.eos.common.api.EntityOwnershipState;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
+import org.opendaylight.mdsal.eos.common.api.EntityOwnershipStateChange;
+import org.opendaylight.mdsal.singleton.api.ClusterSingletonServiceProvider;
import org.opendaylight.openflowplugin.api.openflow.OFPManager;
import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionStatus;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.core.general.entity.rev150930.Entity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.rf.state.rev170713.ResultState;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
import org.opendaylight.yangtools.yang.common.Uint8;
import org.slf4j.Logger;
private static final String SEPARATOR = ":";
private final ConcurrentMap<DeviceInfo, ContextChain> contextChainMap = new ConcurrentHashMap<>();
private final ConcurrentMap<DeviceInfo, ? super ConnectionContext> connectingDevices = new ConcurrentHashMap<>();
- private final EntityOwnershipListenerRegistration eosListenerRegistration;
+ private final Registration eosListenerRegistration;
private final ClusterSingletonServiceProvider singletonServiceProvider;
private final Executor executor;
private final OwnershipChangeListener ownershipChangeListener;
@Override
@SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
- public void ownershipChanged(final EntityOwnershipChange entityOwnershipChange) {
- LOG.info("Entity ownership change received for node : {}", entityOwnershipChange);
- if (entityOwnershipChange.inJeopardy()) {
- LOG.warn("Controller is in Jeopardy, ignore ownership change notification. {}", entityOwnershipChange);
+ public void ownershipChanged(final org.opendaylight.mdsal.eos.binding.api.Entity entity,
+ final EntityOwnershipStateChange change, final boolean inJeopardy) {
+ LOG.info("Entity ownership change received for node : {}", change);
+ if (inJeopardy) {
+ LOG.warn("Controller is in Jeopardy, ignore ownership change notification. {}", change);
return;
}
- if (entityOwnershipChange.getState().hasOwner()) {
+ if (change.hasOwner()) {
return;
}
// Findbugs flags a false violation for "Unchecked/unconfirmed cast" from GenericEntity to Entity hence the
// suppression above. The suppression is temporary until EntityOwnershipChange is modified to eliminate the
// violation.
- final String entityName = entityOwnershipChange
- .getEntity()
- .getIdentifier()
- .firstKeyOf(Entity.class)
- .getName();
+ final String entityName = entity.getIdentifier().firstKeyOf(Entity.class).getName();
if (entityName != null && entityName.startsWith("openflow:")) {
if (nodeCleanerExecutor.isShutdown()) {
DeviceStateUtil.createNodeInstanceIdentifier(new NodeId(entityName));
deviceManager.sendNodeRemovedNotification(nodeInstanceIdentifier);
LOG.info("Try to remove device {} from operational DS", entityName);
- ListenableFuture<?> future =
- deviceManager.removeDeviceFromOperationalDS(nodeInstanceIdentifier);
+ final var future = deviceManager.removeDeviceFromOperationalDS(nodeInstanceIdentifier);
Futures.addCallback(future, new FutureCallback<Object>() {
@Override
public void onSuccess(final Object result) {
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
-import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
+import org.opendaylight.mdsal.singleton.api.ClusterSingletonServiceProvider;
+import org.opendaylight.mdsal.singleton.api.ServiceGroupIdentifier;
import org.opendaylight.openflowplugin.api.openflow.OFPContext;
import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
import com.google.common.util.concurrent.Service;
import java.util.function.Function;
import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
+import org.opendaylight.mdsal.singleton.api.ServiceGroupIdentifier;
import org.opendaylight.openflowplugin.api.openflow.OFPContext;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
import org.opendaylight.openflowplugin.api.openflow.lifecycle.ContextChainMastershipWatcher;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
+import org.opendaylight.mdsal.singleton.api.ServiceGroupIdentifier;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
return deviceInfo;
}
+ @Override
public void setRoleRpc(final SetRole setRole) {
setRoleRpc = setRole;
}
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.binding.api.NotificationPublishService;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
-import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
+import org.opendaylight.mdsal.singleton.api.ServiceGroupIdentifier;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.binding.api.TransactionChainClosedException;
-import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
+import org.opendaylight.mdsal.singleton.api.ServiceGroupIdentifier;
import org.opendaylight.openflowplugin.api.ConnectionException;
import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
final boolean isStatisticsPollingOn,
final boolean isUsingReconciliationFramework) {
this.deviceContext = deviceContext;
- this.devState = requireNonNull(deviceContext.getDeviceState());
+ devState = requireNonNull(deviceContext.getDeviceState());
this.executorService = executorService;
this.isStatisticsPollingOn = isStatisticsPollingOn;
this.config = config;
this.convertorExecutor = convertorExecutor;
- this.deviceInfo = deviceContext.getDeviceInfo();
- this.statisticsPollingInterval = config.getBasicTimerDelay().getValue().toJava();
- this.maximumPollingDelay = config.getMaximumTimerDelay().getValue().toJava();
+ deviceInfo = deviceContext.getDeviceInfo();
+ statisticsPollingInterval = config.getBasicTimerDelay().getValue().toJava();
+ maximumPollingDelay = config.getMaximumTimerDelay().getValue().toJava();
this.statisticsWriterProvider = statisticsWriterProvider;
this.isUsingReconciliationFramework = isUsingReconciliationFramework;
@Override
public DeviceInfo getDeviceInfo() {
- return this.deviceInfo;
+ return deviceInfo;
}
@NonNull
@Override
public void registerMastershipWatcher(@NonNull final ContextChainMastershipWatcher newWatcher) {
- this.contextChainMastershipWatcher = newWatcher;
+ contextChainMastershipWatcher = newWatcher;
}
@Override
@Override
public void enableGathering() {
- this.schedulingEnabled.set(true);
+ schedulingEnabled.set(true);
}
@Override
public void disableGathering() {
- this.schedulingEnabled.set(false);
+ schedulingEnabled.set(false);
}
@Override
return Futures.immediateFuture(Boolean.TRUE);
}
- return this.lastDataGatheringRef.updateAndGet(future -> {
+ return lastDataGatheringRef.updateAndGet(future -> {
// write start timestamp to state snapshot container
StatisticsGatheringUtils.markDeviceStateSnapshotStart(deviceInfo, deviceContext);
schedulingEnabled.set(true);
statisticsPollingService.startAsync();
- this.statisticsPollingServiceRef.set(statisticsPollingService);
+ statisticsPollingServiceRef.set(statisticsPollingService);
}
private ListenableFuture<Void> stopGatheringData() {
import com.google.common.util.concurrent.MoreExecutors;
import org.apache.commons.lang3.tuple.MutablePair;
import org.apache.commons.lang3.tuple.Pair;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.FlowCapableTransactionService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrier;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierInputBuilder;
* Creates barrier input.
*
* @param nodeRef rpc routing context
- * @return input for {@link FlowCapableTransactionService#sendBarrier(SendBarrierInput)}
+ * @return input for {@link SendBarrier#invoke(SendBarrierInput)}
*/
@VisibleForTesting
static SendBarrierInput createSendBarrierInput(final NodeRef nodeRef) {
<reference id="notificationPublishService"
interface="org.opendaylight.mdsal.binding.api.NotificationPublishService"/>
<reference id="clusterSingletonServiceProvider"
- interface="org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider"/>
+ interface="org.opendaylight.mdsal.singleton.api.ClusterSingletonServiceProvider"/>
<reference id="entityOwnershipService"
interface="org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService"/>
<reference id="diagStatusProvider"
interface="org.opendaylight.infrautils.ready.SystemReadyMonitor"/>
<reference id="mastershipChangeServiceManager"
interface="org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeServiceManager"/>
-
- <odl:action-provider interface="org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService"/>
</blueprint>
import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.mdsal.binding.api.WriteTransaction;
import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipListenerRegistration;
import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
+import org.opendaylight.mdsal.singleton.api.ClusterSingletonServiceProvider;
import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProviderList;
import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationProperty;
import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService;
import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeServiceManager;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.common.Uint16;
import org.opendaylight.yangtools.yang.common.Uint32;
EntityOwnershipService entityOwnershipService;
@Mock
- EntityOwnershipListenerRegistration entityOwnershipListenerRegistration;
+ Registration entityOwnershipListenerRegistration;
@Mock
SwitchConnectionProvider switchConnectionProvider;
import org.opendaylight.openflowplugin.api.openflow.registry.group.DeviceGroupRegistry;
import org.opendaylight.openflowplugin.api.openflow.registry.meter.DeviceMeterRegistry;
import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
-import org.opendaylight.openflowplugin.common.txchain.TransactionChainManager;
import org.opendaylight.openflowplugin.extension.api.ConvertorMessageFromOFJava;
import org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider;
import org.opendaylight.openflowplugin.impl.device.initialization.AbstractDeviceInitializer;
Mockito.lenient().when(readTx.read(LogicalDatastoreType.OPERATIONAL, nodeKeyIdent))
.thenReturn(noExistNodeFuture);
Mockito.when(dataBroker.newReadOnlyTransaction()).thenReturn(readTx);
- Mockito.when(dataBroker.createTransactionChain(any(TransactionChainManager.class)))
- .thenReturn(txChainFactory);
+ Mockito.when(dataBroker.createTransactionChain()).thenReturn(txChainFactory);
Mockito.when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodeKeyIdent);
Mockito.when(deviceInfo.getNodeId()).thenReturn(nodeId);
Mockito.when(deviceInfo.getDatapathId()).thenReturn(Uint64.ONE);
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.mdsal.eos.binding.api.Entity;
-import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipChange;
-import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipListenerRegistration;
import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService;
-import org.opendaylight.mdsal.eos.common.api.EntityOwnershipChangeState;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
+import org.opendaylight.mdsal.eos.common.api.EntityOwnershipStateChange;
+import org.opendaylight.mdsal.singleton.api.ClusterSingletonServiceProvider;
import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionStatus;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.rf.state.rev170713.ResultState;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.common.Uint8;
@Mock
private ExecutorService executorService;
@Mock
- private ClusterSingletonServiceRegistration clusterSingletonServiceRegistration;
+ private Registration clusterSingletonServiceRegistration;
@Mock
private EntityOwnershipService entityOwnershipService;
@Mock
- private EntityOwnershipListenerRegistration entityOwnershipListenerRegistration;
+ private Registration entityOwnershipListenerRegistration;
@Mock
private ReconciliationFrameworkEvent reconciliationFrameworkEvent;
@Mock
contextChainHolder.onMasterRoleAcquired(deviceInfo, ContextChainMastershipState.RPC_REGISTRATION);
contextChainHolder.onMasterRoleAcquired(deviceInfo, ContextChainMastershipState.MASTER_ON_DEVICE);
contextChainHolder.onMasterRoleAcquired(deviceInfo, ContextChainMastershipState.INITIAL_SUBMIT);
- EntityOwnershipChange ownershipChange = new EntityOwnershipChange(
- new Entity(ENTITY_TEST, OPENFLOW_TEST),
- EntityOwnershipChangeState.LOCAL_OWNERSHIP_LOST_NO_OWNER
- );
- contextChainHolder.ownershipChanged(ownershipChange);
+ contextChainHolder.ownershipChanged(new Entity(ENTITY_TEST, OPENFLOW_TEST),
+ EntityOwnershipStateChange.LOCAL_OWNERSHIP_LOST_NO_OWNER, false);
Mockito.verify(deviceManager, Mockito.timeout(1000)).removeDeviceFromOperationalDS(Mockito.any());
}
contextChainHolder.onMasterRoleAcquired(deviceInfo, ContextChainMastershipState.RPC_REGISTRATION);
contextChainHolder.onMasterRoleAcquired(deviceInfo, ContextChainMastershipState.MASTER_ON_DEVICE);
contextChainHolder.onMasterRoleAcquired(deviceInfo, ContextChainMastershipState.INITIAL_SUBMIT);
- EntityOwnershipChange ownershipChange = new EntityOwnershipChange(
- new Entity(ENTITY_TEST, OPENFLOW_TEST),
- EntityOwnershipChangeState.LOCAL_OWNERSHIP_LOST_NEW_OWNER
- );
- contextChainHolder.ownershipChanged(ownershipChange);
+ contextChainHolder.ownershipChanged(new Entity(ENTITY_TEST, OPENFLOW_TEST),
+ EntityOwnershipStateChange.LOCAL_OWNERSHIP_LOST_NEW_OWNER, false);
Mockito.verify(deviceManager,Mockito.never()).removeDeviceFromOperationalDS(Mockito.any());
}
}
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
-import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
+import org.opendaylight.mdsal.singleton.api.ClusterSingletonServiceProvider;
+import org.opendaylight.mdsal.singleton.api.ServiceGroupIdentifier;
import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
import org.opendaylight.openflowplugin.api.openflow.lifecycle.ContextChainMastershipWatcher;
import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext;
import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext;
+import org.opendaylight.yangtools.concepts.Registration;
@RunWith(MockitoJUnitRunner.class)
public class ContextChainImplTest {
-
private static final String TEST_NODE = "test node";
- private static final ServiceGroupIdentifier SERVICE_GROUP_IDENTIFIER = ServiceGroupIdentifier.create(TEST_NODE);
+ private static final ServiceGroupIdentifier SERVICE_GROUP_IDENTIFIER = new ServiceGroupIdentifier(TEST_NODE);
@Mock
private StatisticsContext statisticsContext;
@Mock
private ClusterSingletonServiceProvider clusterSingletonServiceProvider;
@Mock
- private ClusterSingletonServiceRegistration clusterSingletonServiceRegistration;
+ private Registration clusterSingletonServiceRegistration;
@Mock
private ContextChainMastershipWatcher contextChainMastershipWatcher;
@Mock
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.yangtools.concepts.ObjectRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.Rpc;
-import org.opendaylight.yangtools.yang.binding.RpcService;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.common.Uint8;
@Mock
private ConnectionContext connectionContext;
@Mock
- private ObjectRegistration<RpcService> registration;
+ private Registration registration;
@Mock
private NotificationPublishService notificationPublishService;
@Mock
*/
package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
-import static com.google.common.base.Preconditions.checkArgument;
-
import com.google.common.collect.Iterables;
import java.util.Collection;
import java.util.Collections;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableItem;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
+import org.opendaylight.yangtools.yang.binding.DataObjectStep;
+import org.opendaylight.yangtools.yang.binding.KeyStep;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.common.Uint8;
import org.slf4j.Logger;
* @return default empty meter mod input builder
*/
public static PacketOutInput defaultResult(final Uint8 version) {
- return new PacketOutInputBuilder()
- .setVersion(version)
- .build();
+ return new PacketOutInputBuilder().setVersion(version).build();
}
- private static PortNumber getPortNumber(final PathArgument pathArgument, final Uint8 ofVersion) {
- checkArgument(pathArgument instanceof IdentifiableItem, "Unexpected path argument %s", pathArgument);
+ private static PortNumber getPortNumber(final DataObjectStep<?> step, final Uint8 ofVersion) {
+ if (!(step instanceof KeyStep<?, ?> keyStep)) {
+ throw new IllegalArgumentException("Unexpected path argument " + step);
+ }
// FIXME VD P! find InstanceIdentifier helper
- final Object key = ((IdentifiableItem<?, ?>) pathArgument).getKey();
- checkArgument(key instanceof NodeConnectorKey, "Unexpected key %s", key);
-
- return new PortNumber(InventoryDataServiceUtil.portNumberfromNodeConnectorId(OpenflowVersion.get(ofVersion),
- ((NodeConnectorKey) key).getId()));
+ final var key = keyStep.key();
+ if (key instanceof NodeConnectorKey nodeConnectorKey) {
+ return new PortNumber(InventoryDataServiceUtil.portNumberfromNodeConnectorId(
+ OpenflowVersion.ofVersion(ofVersion), nodeConnectorKey.getId()));
+ }
+ throw new IllegalArgumentException("Unexpected key " + key);
}
@Override
// Build Port ID from TransmitPacketInput.Ingress
PortNumber inPortNr;
Uint32 bufferId = OFConstants.OFP_NO_BUFFER;
- Iterable<PathArgument> inArgs = null;
+ Iterable<DataObjectStep<?>> inArgs = null;
if (source.getIngress() != null) {
inArgs = source.getIngress().getValue().getPathArguments();
}
final PortNumber outPort;
- final Iterable<PathArgument> outArgs = source.getEgress().getValue().getPathArguments();
+ final var outArgs = source.getEgress().getValue().getPathArguments();
if (Iterables.size(outArgs) >= 3) {
outPort = getPortNumber(Iterables.get(outArgs, 2), data.getVersion());
} else {
<parent>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>binding-parent</artifactId>
- <version>12.0.4</version>
+ <version>13.0.0</version>
<relativePath/>
</parent>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>controller-artifacts</artifactId>
- <version>8.0.4</version>
+ <version>9.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
package org.opendaylight.openflowplugin.learningswitch;
import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
/**
* Holder for {@link DataTreeChangeListener} registration.
*/
public interface DataTreeChangeListenerRegistrationHolder {
-
/**
* Returns the DataTreeChangeListenerRegistration.
*/
- ListenerRegistration<DataTreeChangeListener> getDataTreeChangeListenerRegistration();
-
+ Registration getDataTreeChangeListenerRegistration();
}
package org.opendaylight.openflowplugin.learningswitch;
import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.mdsal.binding.api.NotificationService;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
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.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived;
import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacket;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
public final class LearningSwitchManagerSimpleImpl implements DataTreeChangeListenerRegistrationHolder, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(LearningSwitchManagerSimpleImpl.class);
- private final ListenerRegistration<DataTreeChangeListener> dataTreeChangeListenerRegistration;
+ private final Registration dataTreeChangeListenerRegistration;
private final Registration packetInRegistration;
public LearningSwitchManagerSimpleImpl(final DataBroker dataBroker, final NotificationService notificationService,
- final RpcConsumerRegistry rpcService) {
+ final RpcService rpcService) {
LOG.debug("start() -->");
final var dataStoreAccessor = new FlowCommitWrapperImpl(dataBroker);
rpcService.getRpc(TransmitPacket.class), this);
packetInRegistration = notificationService.registerListener(PacketReceived.class, learningSwitchHandler);
- dataTreeChangeListenerRegistration = dataBroker.registerDataTreeChangeListener(DataTreeIdentifier.create(
+ dataTreeChangeListenerRegistration = dataBroker.registerDataTreeChangeListener(DataTreeIdentifier.of(
LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class)
.child(Node.class)
.augmentation(FlowCapableNode.class)
}
@Override
- public ListenerRegistration<DataTreeChangeListener> getDataTreeChangeListenerRegistration() {
+ public Registration getDataTreeChangeListenerRegistration() {
return dataTreeChangeListenerRegistration;
}
}
import static java.util.Objects.requireNonNull;
-import java.util.Collection;
+import java.util.List;
import org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType;
import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.DataTreeModification;
}
@Override
- public void onDataTreeChanged(final Collection<DataTreeModification<Table>> modifications) {
+ public void onDataTreeChanged(final List<DataTreeModification<Table>> modifications) {
Uint8 requiredTableId = Uint8.ZERO;
// TODO add flow
for (var modification : modifications) {
- if (modification.getRootNode().getModificationType() == ModificationType.SUBTREE_MODIFIED) {
- var table = modification.getRootNode().getDataAfter();
+ if (modification.getRootNode().modificationType() == ModificationType.SUBTREE_MODIFIED) {
+ var table = modification.getRootNode().dataAfter();
if (table != null) {
LOG.trace("table: {}", table);
if (requiredTableId.equals(table.getId())) {
- learningSwitchHandler.onSwitchAppeared(modification.getRootPath().getRootIdentifier());
+ learningSwitchHandler.onSwitchAppeared(modification.getRootPath().path());
}
}
}
import javax.inject.Inject;
import javax.inject.Singleton;
import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.mdsal.binding.api.NotificationService;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.openflowplugin.learningswitch.DataTreeChangeListenerRegistrationHolder;
import org.opendaylight.openflowplugin.learningswitch.FlowCommitWrapperImpl;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived;
import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacket;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.osgi.service.component.annotations.Activate;
public final class LearningSwitchManagerMultiImpl implements DataTreeChangeListenerRegistrationHolder, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(LearningSwitchManagerMultiImpl.class);
- private final ListenerRegistration<DataTreeChangeListener> dataTreeChangeListenerRegistration;
+ private final Registration dataTreeChangeListenerRegistration;
private final Registration packetInRegistration;
@Inject
@Activate
public LearningSwitchManagerMultiImpl(@Reference final DataBroker dataBroker,
- @Reference final NotificationService notificationService, @Reference final RpcConsumerRegistry rpcService) {
+ @Reference final NotificationService notificationService, @Reference final RpcService rpcService) {
LOG.debug("start() -->");
final var dataStoreAccessor = new FlowCommitWrapperImpl(dataBroker);
packetInRegistration = notificationService.registerListener(PacketReceived.class, packetInDispatcher);
dataTreeChangeListenerRegistration = dataBroker.registerDataTreeChangeListener(
- DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class)
+ DataTreeIdentifier.of(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class)
.child(Node.class)
.augmentation(FlowCapableNode.class)
.child(Table.class)),
LOG.debug("stop() <--");
}
-
+ // FIXME: why?
@Override
- public ListenerRegistration<DataTreeChangeListener> getDataTreeChangeListenerRegistration() {
+ public Registration getDataTreeChangeListenerRegistration() {
return dataTreeChangeListenerRegistration;
}
}
*/
package org.opendaylight.openflowplugin.samples.sample.bundles;
-import java.util.Collection;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.mdsal.binding.api.DataTreeModification;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleControlType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleFlags;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleId;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.util.BindingMap;
import org.opendaylight.yangtools.yang.common.Uint16;
private final ControlBundle controlBundle;
private final AddBundleMessages addBundleMessages;
- private final ListenerRegistration<?> listenerReg;
+ private final Registration listenerReg;
@Inject
@Activate
public SampleFlowCapableNodeListener(@Reference final DataBroker dataBroker,
- @Reference final RpcConsumerRegistry rpcService) {
+ @Reference final RpcService rpcService) {
controlBundle = rpcService.getRpc(ControlBundle.class);
addBundleMessages = rpcService.getRpc(AddBundleMessages.class);
LOG.debug("inSessionInitialized() passing");
}
@Override
- public void onDataTreeChanged(final Collection<DataTreeModification<FlowCapableNode>> modifications) {
+ public void onDataTreeChanged(final List<DataTreeModification<FlowCapableNode>> modifications) {
for (var modification : modifications) {
if (modification.getRootNode().getModificationType() == ModificationType.WRITE) {
LOG.info("Node connected: {}",
import java.util.concurrent.TimeoutException;
import javax.inject.Inject;
import javax.inject.Singleton;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
import org.osgi.service.component.annotations.Activate;
@Inject
@Activate
- public SimpleDropFirewall(@Reference final RpcConsumerRegistry rpcService) {
+ public SimpleDropFirewall(@Reference final RpcService rpcService) {
addFlow = rpcService.getRpc(AddFlow.class);
}
import javax.inject.Inject;
import javax.inject.Singleton;
import org.opendaylight.mdsal.binding.api.NotificationService;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.mdsal.binding.api.RpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput;
@Inject
@Activate
public DropTestRpcSender(@Reference final NotificationService notificationService,
- @Reference final RpcConsumerRegistry rpcService) {
+ @Reference final RpcService rpcService) {
this.notificationService = requireNonNull(notificationService);
addFlow = rpcService.getRpc(AddFlow.class);
}