package org.opendaylight.openflowplugin.applications.statistics.manager;
import java.util.List;
-
+import java.util.UUID;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.OpendaylightQueueStatisticsListener;
private NodeId nodeId;
private StatsManagerOperationType operationType = StatsManagerOperationType.DATA_COMMIT_OPER_DS;
+ private UUID nodeUUID;
public StatDataStoreOperation(final StatsManagerOperationType operType, final NodeId id){
if(operType != null){
operationType = operType;
}
nodeId = id;
+ nodeUUID = generatedUUIDForNode();
}
public final StatsManagerOperationType getType() {
return nodeId;
}
+ public UUID getNodeUUID() {
+ return nodeUUID;
+ }
+
/**
* Apply all read / write (put|merge) operation for DataStore
*
*/
public abstract void applyOperation(ReadWriteTransaction tx);
+ protected abstract UUID generatedUUIDForNode();
+
+ public InstanceIdentifier<Node> getNodeIdentifier() {
+ final InstanceIdentifier<Node> nodeIdent = InstanceIdentifier.create(Nodes.class)
+ .child(Node.class, new NodeKey(nodeId));
+ return nodeIdent;
+ }
+
+ }
+
+
+ class Pair<L,R> {
+
+ private final L left;
+ private final R right;
+
+ public Pair(L left, R right) {
+ this.left = left;
+ this.right = right;
+ }
+
+ public L getLeft() { return left; }
+ public R getRight() { return right; }
+
+ @Override
+ public int hashCode() { return left.hashCode() ^ right.hashCode(); }
+
+ @Override
+ public boolean equals(Object o) {
+ if (!(o instanceof Pair)) return false;
+ Pair pairo = (Pair) o;
+ return this.left.equals(pairo.getLeft()) &&
+ this.right.equals(pairo.getRight());
+ }
+
}
/**
StatisticsManagerConfig getConfiguration();
+ /**
+ * A unique UUID is generated with each node added by the statistics manager implementation in order to uniquely
+ * identify a session.
+ * @param nodeInstanceIdentifier
+ */
+ UUID getGeneratedUUIDForNode(InstanceIdentifier<Node> nodeInstanceIdentifier);
+
}
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
}
}
}
+
+ @Override
+ public UUID generatedUUIDForNode() {
+ return manager.getGeneratedUUIDForNode(getNodeIdentifier());
+ }
});
}
notifyToCollectNextStatistics(nodeIdent, transId);
}
+ @Override
+ public UUID generatedUUIDForNode() {
+ return manager.getGeneratedUUIDForNode(getNodeIdentifier());
+ }
+
});
}
import java.util.Collections;
import java.util.List;
+import java.util.UUID;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
/* Notification for continue collecting statistics */
notifyToCollectNextStatistics(nodeIdent, transId);
}
+
+ @Override
+ public UUID generatedUUIDForNode() {
+ return manager.getGeneratedUUIDForNode(getNodeIdentifier());
+ }
});
}
}
}
}
+
+ @Override
+ public UUID generatedUUIDForNode() {
+ return manager.getGeneratedUUIDForNode(getNodeIdentifier());
+ }
});
}
notifyToCollectNextStatistics(nodeIdent, transId);
}
}
+
+ public UUID generatedUUIDForNode() {
+ return manager.getGeneratedUUIDForNode(getNodeIdentifier());
+ }
});
}
import java.util.Collections;
import java.util.List;
+import java.util.UUID;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
/* Notification for continue collecting statistics */
notifyToCollectNextStatistics(nodeIdent, transId);
}
+
+ public UUID generatedUUIDForNode() {
+ return manager.getGeneratedUUIDForNode(getNodeIdentifier());
+ }
});
}
}
}
}
+
+ @Override
+ public UUID generatedUUIDForNode() {
+ return manager.getGeneratedUUIDForNode(getNodeIdentifier());
+ }
});
}
notifyToCollectNextStatistics(nodeIdent, transId);
}
}
+
+ @Override
+ public UUID generatedUUIDForNode() {
+ return manager.getGeneratedUUIDForNode(getNodeIdentifier());
+ }
});
}
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+
+import java.util.UUID;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
/* Notification for continue collecting statistics */
notifyToCollectNextStatistics(nodeIdent, transId);
}
+
+ @Override
+ public UUID generatedUUIDForNode() {
+ return manager.getGeneratedUUIDForNode(getNodeIdentifier());
+ }
});
}
package org.opendaylight.openflowplugin.applications.statistics.manager.impl;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
-
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
import org.opendaylight.openflowplugin.applications.statistics.manager.StatNodeRegistration;
-import org.opendaylight.openflowplugin.applications.statistics.manager.StatisticsManager;
import org.opendaylight.openflowplugin.applications.statistics.manager.StatPermCollector.StatCapabTypes;
-import org.opendaylight.openflowplugin.applications.statistics.manager.StatisticsManager.StatDataStoreOperation;
-import org.opendaylight.openflowplugin.applications.statistics.manager.StatisticsManager.StatDataStoreOperation.StatsManagerOperationType;
+import org.opendaylight.openflowplugin.applications.statistics.manager.StatisticsManager;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FeatureCapability;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeUpdated;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated;
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.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-
/**
* statistics-manager
* org.opendaylight.openflowplugin.applications.statistics.manager.impl
Preconditions.checkNotNull(data, "SwitchFeatures data for {} can not be null!", keyIdent);
Preconditions.checkArgument(( ! keyIdent.isWildcarded()), "InstanceIdentifier is WildCarded!");
- manager.enqueue(new StatDataStoreOperation(StatsManagerOperationType.NODE_UPDATE,nodeIdent.firstKeyOf(Node.class, NodeKey.class).getId()) {
-
- @Override
- public void applyOperation(final ReadWriteTransaction tx) {
-
- final List<StatCapabTypes> statCapabTypes = new ArrayList<>();
- Short maxCapTables = Short.valueOf("1");
-
- final List<Class<? extends FeatureCapability>> capabilities = data.getCapabilities() != null
- ? data.getCapabilities() : Collections.<Class<? extends FeatureCapability>> emptyList();
- for (final Class<? extends FeatureCapability> capability : capabilities) {
- if (FlowFeatureCapabilityTableStats.class.equals(capability)) {
- statCapabTypes.add(StatCapabTypes.TABLE_STATS);
- } else if (FlowFeatureCapabilityFlowStats.class.equals(capability)) {
- statCapabTypes.add(StatCapabTypes.FLOW_STATS);
- } else if (FlowFeatureCapabilityGroupStats.class.equals(capability)) {
- statCapabTypes.add(StatCapabTypes.GROUP_STATS);
- } else if (FlowFeatureCapabilityPortStats.class.equals(capability)) {
- statCapabTypes.add(StatCapabTypes.PORT_STATS);
- } else if (FlowFeatureCapabilityQueueStats.class.equals(capability)) {
- statCapabTypes.add(StatCapabTypes.QUEUE_STATS);
- }
- }
- maxCapTables = data.getMaxTables();
-
- final Optional<Short> maxTables = Optional.<Short> of(maxCapTables);
- manager.connectedNodeRegistration(nodeIdent,
- Collections.unmodifiableList(statCapabTypes), maxTables.get());
+ LOG.trace("STAT-MANAGER - connecting flow capable node {}", nodeIdent);
+ final List<StatCapabTypes> statCapabTypes = new ArrayList<>();
+ Short maxCapTables = Short.valueOf("1");
+
+ final List<Class<? extends FeatureCapability>> capabilities = data.getCapabilities() != null
+ ? data.getCapabilities() : Collections.<Class<? extends FeatureCapability>> emptyList();
+ for (final Class<? extends FeatureCapability> capability : capabilities) {
+ if (FlowFeatureCapabilityTableStats.class.equals(capability)) {
+ statCapabTypes.add(StatCapabTypes.TABLE_STATS);
+ } else if (FlowFeatureCapabilityFlowStats.class.equals(capability)) {
+ statCapabTypes.add(StatCapabTypes.FLOW_STATS);
+ } else if (FlowFeatureCapabilityGroupStats.class.equals(capability)) {
+ statCapabTypes.add(StatCapabTypes.GROUP_STATS);
+ } else if (FlowFeatureCapabilityPortStats.class.equals(capability)) {
+ statCapabTypes.add(StatCapabTypes.PORT_STATS);
+ } else if (FlowFeatureCapabilityQueueStats.class.equals(capability)) {
+ statCapabTypes.add(StatCapabTypes.QUEUE_STATS);
}
- });
+ }
+ maxCapTables = data.getMaxTables();
+
+ final Optional<Short> maxTables = Optional.<Short> of(maxCapTables);
+ manager.connectedNodeRegistration(nodeIdent, Collections.unmodifiableList(statCapabTypes), maxTables.get());
}
@Override
Preconditions.checkArgument(nodeIdent != null, "InstanceIdentifier can not be NULL!");
Preconditions.checkArgument(( ! nodeIdent.isWildcarded()),
"InstanceIdentifier {} is WildCarded!", nodeIdent);
- manager.enqueue(new StatDataStoreOperation(StatsManagerOperationType.NODE_REMOVAL,nodeIdent.firstKeyOf(Node.class, NodeKey.class).getId()) {
-
- @Override
- public void applyOperation(final ReadWriteTransaction tx) {
- manager.disconnectedNodeUnregistration(nodeIdent);
- }
- });
+ LOG.trace("STAT-MANAGER - disconnect flow capable node {}", nodeIdent);
+ manager.disconnectedNodeUnregistration(nodeIdent);
}
final InstanceIdentifier<Node> nodeIdent =
nodeRefIdent.firstIdentifierOf(Node.class);
if (nodeIdent != null) {
+ LOG.debug("Received onNodeRemoved for node:{} ", nodeIdent);
disconnectFlowCapableNode(nodeIdent);
}
}
import java.util.ArrayList;
import java.util.List;
+import java.util.UUID;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
* and they are small - don't need to wait for whole apply operation*/
notifyToCollectNextStatistics(nodeIdent, transId);
}
+
+ @Override
+ public UUID generatedUUIDForNode() {
+ return manager.getGeneratedUUIDForNode(getNodeIdentifier());
+ }
});
}
import java.util.ArrayList;
import java.util.List;
+import java.util.UUID;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
* and they are small - don't need to wait to whole apply operation */
notifyToCollectNextStatistics(nodeIdent, transId);
}
+
+ @Override
+ public UUID generatedUUIDForNode() {
+ return manager.getGeneratedUUIDForNode(getNodeIdentifier());
+ }
});
}
package org.opendaylight.openflowplugin.applications.statistics.manager.impl;
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
+import java.util.UUID;
import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadFactory;
-
+import java.util.concurrent.atomic.AtomicInteger;
import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.openflowplugin.applications.statistics.manager.StatPermCollector.StatCapabTypes;
import org.opendaylight.openflowplugin.applications.statistics.manager.StatRpcMsgManager;
import org.opendaylight.openflowplugin.applications.statistics.manager.StatisticsManager;
-import org.opendaylight.openflowplugin.applications.statistics.manager.StatisticsManager.StatDataStoreOperation.StatsManagerOperationType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-
/**
* statistics-manager
* org.opendaylight.openflowplugin.applications.statistics.manager.impl
private static final int MAX_BATCH = 100;
private final BlockingQueue<StatDataStoreOperation> dataStoreOperQueue = new LinkedBlockingDeque<>(QUEUE_DEPTH);
+ private final Map<InstanceIdentifier<Node>, Pair<StatPermCollector, UUID>> nodeCollectorMap = new ConcurrentHashMap<>();
+ private AtomicInteger numNodesBeingCollected = new AtomicInteger(0);
- private final DataBroker dataBroker;
+
+ private final DataBroker dataBroker;
private final ExecutorService statRpcMsgManagerExecutor;
private final ExecutorService statDataStoreOperationServ;
private StatRpcMsgManager rpcMsgManager;
int ops = 0;
do {
- op.applyOperation(tx);
+ Pair<StatPermCollector, UUID> statPermCollectorUUIDPair = nodeCollectorMap.get(op.getNodeIdentifier());
+ if (statPermCollectorUUIDPair != null && statPermCollectorUUIDPair.getRight().equals(op.getNodeUUID())) {
+ // dont apply operations for nodes which have been disconnected or if there uuids do not match
+ // this can happen if operations are queued and node is removed.
+ // if the uuids dont match, it means that the stat operation are stale and belong to the same node
+ // which got disconnected and connected again.
+ op.applyOperation(tx);
+ ops++;
+ } else {
+ LOG.debug("{} not found or UUID mismatch for statistics datastore operation", op.getNodeIdentifier());
+ }
- ops++;
if (ops < MAX_BATCH) {
op = dataStoreOperQueue.poll();
} else {
LOG.trace("Processed {} operations, submitting transaction {}", ops, tx.getIdentifier());
- tx.submit().checkedGet();
+ tx.submit().checkedGet();
} catch (final InterruptedException e) {
LOG.warn("Stat Manager DS Operation thread interupted!", e);
finishing = true;
private synchronized void cleanDataStoreOperQueue() {
// Drain all events, making sure any blocked threads are unblocked
while (! dataStoreOperQueue.isEmpty()) {
- StatDataStoreOperation op = dataStoreOperQueue.poll();
-
- // Execute the node removal clean up operation if queued in the
- // operational queue.
- if (op.getType() == StatsManagerOperationType.NODE_REMOVAL) {
- try {
- LOG.debug("Node {} disconnected. Cleaning internal data.",op.getNodeId());
- op.applyOperation(null);
- } catch (final Exception e) {
- LOG.warn("Unhandled exception while cleaning up internal data of node [{}]. "
- + "Exception {}",op.getNodeId(), e);
- }
- }
+ dataStoreOperQueue.poll();
}
}
}
}
- @Override
- public void connectedNodeRegistration(final InstanceIdentifier<Node> nodeIdent,
- final List<StatCapabTypes> statTypes, final Short nrOfSwitchTables) {
- for (final StatPermCollector collector : statCollectors) {
- if (collector.connectedNodeRegistration(nodeIdent, statTypes, nrOfSwitchTables)) {
- return;
- }
- }
- synchronized (statCollectorLock) {
- for (final StatPermCollector collector : statCollectors) {
- if (collector.connectedNodeRegistration(nodeIdent, statTypes, nrOfSwitchTables)) {
- return;
- }
- }
- final StatPermCollectorImpl newCollector = new StatPermCollectorImpl(this,
- statManagerConfig.getMinRequestNetMonitorInterval(), statCollectors.size() + 1,
- statManagerConfig.getMaxNodesForCollector());
- final List<StatPermCollector> statCollectorsNew = new ArrayList<>(statCollectors);
- newCollector.connectedNodeRegistration(nodeIdent, statTypes, nrOfSwitchTables);
- statCollectorsNew.add(newCollector);
- statCollectors = Collections.unmodifiableList(statCollectorsNew);
- }
- }
+ @Override
+ public void connectedNodeRegistration(final InstanceIdentifier<Node> nodeIdent,
+ final List<StatCapabTypes> statTypes, final Short nrOfSwitchTables) {
+
+
+ Pair<StatPermCollector, UUID> collectorUUIDPair = nodeCollectorMap.get(nodeIdent);
+ if (collectorUUIDPair == null) {
+ // no collector contains this node,
+ // check if one of the collectors can accommodate it
+ // if no then add a new collector
+
+ synchronized(statCollectorLock) {
+ for (int i = statCollectors.size() - 1; i >= 0; i--) {
+ // start from back of the list as most likely previous ones might be full
+ final StatPermCollector aCollector = statCollectors.get(i);
+ if (aCollector.connectedNodeRegistration(nodeIdent, statTypes, nrOfSwitchTables)) {
+ // if the collector returns true after adding node, then return
+ nodeCollectorMap.put(nodeIdent, new Pair(aCollector, UUID.randomUUID()));
+ LOG.debug("NodeAdded: Num Nodes Registered with StatisticsManager:{}",
+ numNodesBeingCollected.incrementAndGet());
+ return;
+ }
+ }
+ // no collector was able to add this node
+ LOG.info("No existing collector found for new node. Creating a new collector for {}", nodeIdent);
+ final StatPermCollectorImpl newCollector = new StatPermCollectorImpl(this,
+ statManagerConfig.getMinRequestNetMonitorInterval(), statCollectors.size() + 1,
+ statManagerConfig.getMaxNodesForCollector());
+
+ final List<StatPermCollector> statCollectorsNew = new ArrayList<>(statCollectors);
+ statCollectorsNew.add(newCollector);
+ statCollectors = Collections.unmodifiableList(statCollectorsNew);
+ nodeCollectorMap.put(nodeIdent, new Pair(newCollector, UUID.randomUUID()));
+ LOG.debug("NodeAdded: Num Nodes Registered with StatisticsManager:{}", numNodesBeingCollected.incrementAndGet());
+
+ newCollector.connectedNodeRegistration(nodeIdent, statTypes, nrOfSwitchTables);
+ }
+
+
+ } else {
+ // add to the collector, even if it rejects it.
+ collectorUUIDPair.getLeft().connectedNodeRegistration(nodeIdent, statTypes, nrOfSwitchTables);
+ }
+ }
- @Override
- public void disconnectedNodeUnregistration(final InstanceIdentifier<Node> nodeIdent) {
- flowListeningCommiter.cleanForDisconnect(nodeIdent);
- for (final StatPermCollector collector : statCollectors) {
- if (collector.disconnectedNodeUnregistration(nodeIdent)) {
- if ( ! collector.hasActiveNodes()) {
- synchronized (statCollectorLock) {
- if (collector.hasActiveNodes()) {
- return;
- }
- final List<StatPermCollector> newStatColl =
- new ArrayList<>(statCollectors);
- newStatColl.remove(collector);
- statCollectors = Collections.unmodifiableList(newStatColl);
- }
- }
- return;
- }
- }
- LOG.debug("Node {} has not been removed.", nodeIdent);
- }
+ @Override
+ public void disconnectedNodeUnregistration(final InstanceIdentifier<Node> nodeIdent) {
+ flowListeningCommiter.cleanForDisconnect(nodeIdent);
+
+ Pair<StatPermCollector, UUID> collectorUUIDPair = nodeCollectorMap.get(nodeIdent);
+ StatPermCollector collector = collectorUUIDPair.getLeft();
+ if (collector != null) {
+ nodeCollectorMap.remove(nodeIdent);
+ LOG.debug("NodeRemoved: Num Nodes Registered with StatisticsManager:{}", numNodesBeingCollected.decrementAndGet());
+
+ if (collector.disconnectedNodeUnregistration(nodeIdent)) {
+ if (!collector.hasActiveNodes()) {
+ synchronized (statCollectorLock) {
+ if (collector.hasActiveNodes()) {
+ return;
+ }
+ final List<StatPermCollector> newStatColl = new ArrayList<>(statCollectors);
+ newStatColl.remove(collector);
+ statCollectors = Collections.unmodifiableList(newStatColl);
+ }
+ }
+ LOG.info("Node:{} successfully removed by StatisticsManager ", nodeIdent);
+ } else {
+ LOG.error("Collector not disconnecting for node, no operations will be committed for this node:{}", nodeIdent);
+ }
+ } else {
+ LOG.error("Received node removed for {}, but unable to find it in nodeCollectorMap", nodeIdent);
+ }
+ }
@Override
public void registerAdditionalNodeFeature(final InstanceIdentifier<Node> nodeIdent,
public StatisticsManagerConfig getConfiguration() {
return statManagerConfig;
}
+
+ @Override
+ public UUID getGeneratedUUIDForNode(InstanceIdentifier<Node> nodeInstanceIdentifier) {
+ Pair<StatPermCollector, UUID> permCollectorUUIDPair = nodeCollectorMap.get(nodeInstanceIdentifier);
+ if (permCollectorUUIDPair != null) {
+ return permCollectorUUIDPair.getRight();
+ }
+ // we dont want to mark operations with null uuid and get NPEs later. So mark them with invalid ones
+ return UUID.fromString("invalid-uuid");
+ }
}
import org.opendaylight.openflowjava.nx.codec.match.Reg7Codec;
import org.opendaylight.openflowjava.nx.codec.match.TunIdCodec;
import org.opendaylight.openflowjava.nx.codec.match.TunIpv4SrcCodec;
+import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey;
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
import org.opendaylight.openflowplugin.extension.api.ConverterExtensionKey;
+import org.opendaylight.openflowplugin.extension.api.ConvertorActionFromOFJava;
import org.opendaylight.openflowplugin.extension.api.ConvertorActionToOFJava;
import org.opendaylight.openflowplugin.extension.api.ExtensionConverterRegistrator;
import org.opendaylight.openflowplugin.extension.api.TypeVersionKey;
+import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.action.MultipathConvertor;
import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.action.OutputRegConvertor;
import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.action.RegLoadConvertor;
import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match.TunIPv4SrcConvertor;
import org.opendaylight.openflowplugin.extension.vendor.nicira.convertor.match.TunIdConvertor;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionMultipath;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionOutputReg;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionRegLoad;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionRegMove;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionResubmit;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionSetNsi;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionSetNsp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.add.flow.input.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionMultipathRpcAddFlowApplyActionsCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.add.flow.input.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionOutputRegRpcAddFlowApplyActionsCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.add.flow.input.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegLoadRpcAddFlowApplyActionsCase;
registerAction13(NxActionSetNshc4RpcUpdateGroupOriginalCase.class, SET_NSC4_CONVERTOR);
registerAction13(NxActionSetNshc4RpcUpdateGroupUpdatedCase.class, SET_NSC4_CONVERTOR);
+
+ registerAction13(ActionRegLoad.class, REG_LOAD_CONVERTOR);
+ registerAction13(ActionRegMove.class, REG_MOVE_CONVERTOR);
+ registerAction13(ActionOutputReg.class, OUTPUT_REG_CONVERTOR);
+ registerAction13(ActionResubmit.class, RESUBMIT_CONVERTOR);
+ registerAction13(ActionMultipath.class, MULTIPATH_CONVERTOR);
+ registerAction13(ActionSetNsp.class, SET_NSP_CONVERTOR);
+ registerAction13(ActionSetNsi.class, SET_NSI_CONVERTOR);
+
registrations.add(extensionConverterRegistrator.registerActionConvertor(NiciraUtil.createOfJavaKeyFrom(RegLoadCodec.SERIALIZER_KEY), REG_LOAD_CONVERTOR));
registrations.add(extensionConverterRegistrator.registerActionConvertor(NiciraUtil.createOfJavaKeyFrom(RegMoveCodec.SERIALIZER_KEY), REG_MOVE_CONVERTOR));
registrations.add(extensionConverterRegistrator.registerActionConvertor(NiciraUtil.createOfJavaKeyFrom(OutputRegCodec.SERIALIZER_KEY), OUTPUT_REG_CONVERTOR));
TypeVersionKey<? extends Action> key = new TypeVersionKey<>(actionCaseType, EncodeConstants.OF13_VERSION_ID);
registrations.add(extensionConverterRegistrator.registerActionConvertor(key, actionConvertor));
}
+ /**
+ * @param actionCaseType
+ * @param actionConvertor
+ */
+ private void registerAction13(
+ Class<? extends ActionChoice> actionCaseType,
+ ConvertorActionFromOFJava<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action, ActionPath> actionConvertor) {
+ ActionSerializerKey<?> key = new ActionSerializerKey(EncodeConstants.OF13_VERSION_ID, actionCaseType, null);
+ registrations.add(extensionConverterRegistrator.registerActionConvertor(key, actionConvertor));
+ }
}
import static org.opendaylight.openflowplugin.legacy.sal.compatibility.ProtocolConstants.TCP;
import static org.opendaylight.openflowplugin.legacy.sal.compatibility.ProtocolConstants.UDP;
+import com.google.common.net.InetAddresses;
import java.math.BigInteger;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-
import org.junit.Test;
import org.opendaylight.controller.sal.action.Flood;
import org.opendaylight.controller.sal.action.FloodAll;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
-import com.google.common.net.InetAddresses;
-
public class TestToSalConversionsUtils {
// prefix:
// od|Od = Open Daylight
FlowAddedBuilder odNodeFlowBuilder = new FlowAddedBuilder();
odNodeFlowBuilder = prepareOdFlowCommon();
- Node node = new Node(NodeIDType.OPENFLOW,(long)1);
+ final Node node = new Node(NodeIDType.OPENFLOW,(long)1);
Flow salFlow = ToSalConversionsUtils.toFlow(prepareOdFlow(odNodeFlowBuilder, MtchType.other), node);
checkSalMatch(salFlow.getMatch(), MtchType.other);
*/
@Test
public void testFromNodeConnectorRef() throws ConstructionException {
- Node node = new Node(NodeIDType.OPENFLOW, 42L);
- NodeConnector nodeConnector = ToSalConversionsUtils.fromNodeConnectorRef(new Uri("1"), node);
+ final Node node = new Node(NodeIDType.OPENFLOW, 42L);
+ final NodeConnector nodeConnector = ToSalConversionsUtils.fromNodeConnectorRef(new Uri("1"), node);
assertEquals("OF|1@OF|00:00:00:00:00:00:00:2a", nodeConnector.toString());
}
@Test
public void testActionFrom() throws ConstructionException {
// Bug 2021: Convert AD-SAL notation into MD-SAL notation before calling NodeConnector
- Node node = new Node(NodeIDType.OPENFLOW, 42L);
- List<Action> odActions = new ArrayList<>();
+ final Node node = new Node(NodeIDType.OPENFLOW, 42L);
+ final List<Action> odActions = new ArrayList<>();
- OutputActionBuilder outputActionBuilder = new OutputActionBuilder();
+ final OutputActionBuilder outputActionBuilder = new OutputActionBuilder();
outputActionBuilder.setOutputNodeConnector(new Uri("openflow:42:CONTROLLER"));
- OutputActionCaseBuilder outputActionCaseBuilder = new OutputActionCaseBuilder();
+ final OutputActionCaseBuilder outputActionCaseBuilder = new OutputActionCaseBuilder();
outputActionCaseBuilder.setOutputAction(outputActionBuilder.build());
odActions.add(new ActionBuilder().setAction(outputActionCaseBuilder.build()).build());
- List<org.opendaylight.controller.sal.action.Action> targetAction =
+ final List<org.opendaylight.controller.sal.action.Action> targetAction =
ToSalConversionsUtils.actionFrom(odActions, node);
assertNotNull(targetAction);
assertTrue( Output.class.isInstance(targetAction.get(0)) );
- Output targetActionOutput = (Output) targetAction.get(0);
- NodeConnector port = targetActionOutput.getPort();
+ final Output targetActionOutput = (Output) targetAction.get(0);
+ final NodeConnector port = targetActionOutput.getPort();
assertNotNull(port);
assertEquals(port.getType(), NodeConnectorIDType.CONTROLLER);
assertEquals(port.getID(), org.opendaylight.controller.sal.core.NodeConnector.SPECIALNODECONNECTORID);
}
- private void checkSalMatch(org.opendaylight.controller.sal.match.Match match, MtchType mt) throws ConstructionException {
+ private void checkSalMatch(final org.opendaylight.controller.sal.match.Match match, final MtchType mt) throws ConstructionException {
switch (mt) {
case other:
/*assertNotNull("DL_DST isn't equal.", "3C:A9:F4:00:E0:C8",
assertEquals("DL_SRC isn't equal.", "24:77:03:7C:C5:F1",
new String((byte[]) match.getField(MatchType.DL_SRC).getValue()));
*/
- Node node = new Node(NodeIDType.OPENFLOW, 12L);
- NodeConnector port = new NodeConnector(NodeConnectorIDType.OPENFLOW, Short.valueOf((short)345), node);
+ final Node node = new Node(NodeIDType.OPENFLOW, 12L);
+ final NodeConnector port = new NodeConnector(NodeConnectorIDType.OPENFLOW, Short.valueOf((short)345), node);
assertEquals("IN_PORT isn't equal.", port, match.getField(MatchType.IN_PORT).getValue());
assertEquals("DL_TYPE isn't equal.", (short) 0xffff, (short) match.getField(MatchType.DL_TYPE).getValue());
assertEquals("NW_TOS isn't equal.", (byte) 0x33, (byte) match.getField(MatchType.NW_TOS).getValue());
}
- private void checkSalFlow(Flow salFlow) {
+ private void checkSalFlow(final Flow salFlow) {
assertTrue("Id value is incorrect.", salFlow.getId() == 9223372036854775807L);
assertTrue("Hard timeout is incorrect.", salFlow.getHardTimeout() == 32767);
assertTrue("Iddle timeout is incorrect.", salFlow.getIdleTimeout() == 32767);
checkSalActions(salFlow.getActions());
}
- private void checkSalActions(List<org.opendaylight.controller.sal.action.Action> actions) {
+ private void checkSalActions(final List<org.opendaylight.controller.sal.action.Action> actions) {
checkSalAction(actions, Flood.class, 1);
checkSalAction(actions, FloodAll.class, 1);
checkSalAction(actions, HwPath.class, 1);
checkSalAction(actions, SwPath.class, 1);
}
- private void checkSalAction(List<org.opendaylight.controller.sal.action.Action> actions, Class<?> cls,
- int numOfActions) {
+ private void checkSalAction(final List<org.opendaylight.controller.sal.action.Action> actions, final Class<?> cls,
+ final int numOfActions) {
checkSalAction(actions, cls, numOfActions, false);
}
- private void checkSalAction(List<org.opendaylight.controller.sal.action.Action> actions, Class<?> cls,
- int numOfActions, boolean additionalCheck) {
+ private void checkSalAction(final List<org.opendaylight.controller.sal.action.Action> actions, final Class<?> cls,
+ final int numOfActions, final boolean additionalCheck) {
int numOfEqualClass = 0;
- for (org.opendaylight.controller.sal.action.Action action : actions) {
+ for (final org.opendaylight.controller.sal.action.Action action : actions) {
if (action.getClass().equals(cls)) {
if (additionalCheck) {
additionalActionCheck(action);
}
// implement special checks
- private void additionalActionCheck(org.opendaylight.controller.sal.action.Action action) {
+ private void additionalActionCheck(final org.opendaylight.controller.sal.action.Action action) {
if (action instanceof Output) {
// ((Output)action).getPort() //TODO finish check when mapping will
// be defined
} else if (action instanceof SetDlType) {
assertEquals("Wrong value for action SetDlType for.", 513L, ((SetDlType) action).getDlType());
} else if (action instanceof SetNextHop) {
- InetAddress inetAddress = ((SetNextHop) action).getAddress();
+ final InetAddress inetAddress = ((SetNextHop) action).getAddress();
checkIpAddresses(inetAddress, "192.168.100.100", "2001:db8:85a3::8a2e:370:7334");
} else if (action instanceof SetNwDst) {
- InetAddress inetAddress = ((SetNwDst) action).getAddress();
+ final InetAddress inetAddress = ((SetNwDst) action).getAddress();
checkIpAddresses(inetAddress, "192.168.100.101", "2001:db8:85a3::8a2e:370:7335");
} else if (action instanceof SetNwSrc) {
- InetAddress inetAddress = ((SetNwSrc) action).getAddress();
+ final InetAddress inetAddress = ((SetNwSrc) action).getAddress();
checkIpAddresses(inetAddress, "192.168.100.102", "2001:db8:85a3::8a2e:370:7336");
} else if (action instanceof SetNwTos) {
assertEquals("Wrong value for action SetNwTos for tos.", 63, ((SetNwTos) action).getNwTos());
}
}
- private void checkIpAddresses(InetAddress inetAddress, String ipv4, String ipv6) {
+ private void checkIpAddresses(final InetAddress inetAddress, final String ipv4, final String ipv6) {
if (inetAddress instanceof Inet4Address) {
assertEquals("Wrong value for IP address.", ipv4, InetAddresses.toAddrString(inetAddress));
} else if (inetAddress instanceof Inet6Address) {
}
private FlowAddedBuilder prepareOdFlowCommon() {
- FlowAddedBuilder odNodeFlowBuilder = new FlowAddedBuilder();
+ final FlowAddedBuilder odNodeFlowBuilder = new FlowAddedBuilder();
odNodeFlowBuilder.setCookie(new FlowCookie(new BigInteger("9223372036854775807")));
odNodeFlowBuilder.setHardTimeout(32767);
return odNodeFlowBuilder;
}
- private NodeFlow prepareOdFlow(FlowAddedBuilder odNodeFlowBuilder, MtchType mt) {
+ private NodeFlow prepareOdFlow(final FlowAddedBuilder odNodeFlowBuilder, final MtchType mt) {
odNodeFlowBuilder.setMatch(prepOdMatch(mt));
return odNodeFlowBuilder.build();
}
private Instructions prepareOdActions() {
- List<Action> odActions = new ArrayList<>();
-
- ControllerActionCaseBuilder controllerActionBuilder = new ControllerActionCaseBuilder();
- DropActionCaseBuilder dropActionBuilder = new DropActionCaseBuilder();
- FloodActionCaseBuilder floodActionBuilder = new FloodActionCaseBuilder();
- FloodAllActionCaseBuilder floodAllActionBuilder = new FloodAllActionCaseBuilder();
- HwPathActionCaseBuilder hwPathActionBuilder = new HwPathActionCaseBuilder();
- LoopbackActionCaseBuilder loopbackActionBuilder = new LoopbackActionCaseBuilder();
- OutputActionCaseBuilder outputActionBuilder = new OutputActionCaseBuilder();
- PopMplsActionCaseBuilder popMplsActionBuilder = new PopMplsActionCaseBuilder();
- PopVlanActionCaseBuilder popVlanActionBuilder = new PopVlanActionCaseBuilder();
- PushMplsActionCaseBuilder pushMplsActionBuilder = new PushMplsActionCaseBuilder();
- PushPbbActionCaseBuilder pushPbbActionBuilder = new PushPbbActionCaseBuilder();
- PushVlanActionCaseBuilder pushVlanActionBuilder = new PushVlanActionCaseBuilder();
- SetDlDstActionCaseBuilder setDlDstActionBuilder = new SetDlDstActionCaseBuilder();
- SetDlSrcActionCaseBuilder setDlSrcActionBuilder = new SetDlSrcActionCaseBuilder();
- SetDlTypeActionCaseBuilder setDlTypeActionBuilder = new SetDlTypeActionCaseBuilder();
- SetMplsTtlActionCaseBuilder setMplsTtlActionBuilder = new SetMplsTtlActionCaseBuilder();
- SetNwTosActionCaseBuilder setNwTosActionBuilder = new SetNwTosActionCaseBuilder();
- SetNwTtlActionCaseBuilder setNwTtlActionBuilder = new SetNwTtlActionCaseBuilder();
- SetQueueActionCaseBuilder setQueueActionBuilder = new SetQueueActionCaseBuilder();
- SetTpDstActionCaseBuilder setTpDstActionBuilder = new SetTpDstActionCaseBuilder();
- SetTpSrcActionCaseBuilder setTpSrcActionBuilder = new SetTpSrcActionCaseBuilder();
- SetVlanCfiActionCaseBuilder setVlanCfiActionBuilder = new SetVlanCfiActionCaseBuilder();
- SetVlanIdActionCaseBuilder setVlanIdActionBuilder = new SetVlanIdActionCaseBuilder();
- SetVlanPcpActionCaseBuilder setVlanPcpActionBuilder = new SetVlanPcpActionCaseBuilder();
- SwPathActionCaseBuilder swPathActionBuilder = new SwPathActionCaseBuilder();
+ final List<Action> odActions = new ArrayList<>();
+
+ final ControllerActionCaseBuilder controllerActionBuilder = new ControllerActionCaseBuilder();
+ final DropActionCaseBuilder dropActionBuilder = new DropActionCaseBuilder();
+ final FloodActionCaseBuilder floodActionBuilder = new FloodActionCaseBuilder();
+ final FloodAllActionCaseBuilder floodAllActionBuilder = new FloodAllActionCaseBuilder();
+ final HwPathActionCaseBuilder hwPathActionBuilder = new HwPathActionCaseBuilder();
+ final LoopbackActionCaseBuilder loopbackActionBuilder = new LoopbackActionCaseBuilder();
+ final OutputActionCaseBuilder outputActionBuilder = new OutputActionCaseBuilder();
+ final PopMplsActionCaseBuilder popMplsActionBuilder = new PopMplsActionCaseBuilder();
+ final PopVlanActionCaseBuilder popVlanActionBuilder = new PopVlanActionCaseBuilder();
+ final PushMplsActionCaseBuilder pushMplsActionBuilder = new PushMplsActionCaseBuilder();
+ final PushPbbActionCaseBuilder pushPbbActionBuilder = new PushPbbActionCaseBuilder();
+ final PushVlanActionCaseBuilder pushVlanActionBuilder = new PushVlanActionCaseBuilder();
+ final SetDlDstActionCaseBuilder setDlDstActionBuilder = new SetDlDstActionCaseBuilder();
+ final SetDlSrcActionCaseBuilder setDlSrcActionBuilder = new SetDlSrcActionCaseBuilder();
+ final SetDlTypeActionCaseBuilder setDlTypeActionBuilder = new SetDlTypeActionCaseBuilder();
+ final SetMplsTtlActionCaseBuilder setMplsTtlActionBuilder = new SetMplsTtlActionCaseBuilder();
+ final SetNwTosActionCaseBuilder setNwTosActionBuilder = new SetNwTosActionCaseBuilder();
+ final SetNwTtlActionCaseBuilder setNwTtlActionBuilder = new SetNwTtlActionCaseBuilder();
+ final SetQueueActionCaseBuilder setQueueActionBuilder = new SetQueueActionCaseBuilder();
+ final SetTpDstActionCaseBuilder setTpDstActionBuilder = new SetTpDstActionCaseBuilder();
+ final SetTpSrcActionCaseBuilder setTpSrcActionBuilder = new SetTpSrcActionCaseBuilder();
+ final SetVlanCfiActionCaseBuilder setVlanCfiActionBuilder = new SetVlanCfiActionCaseBuilder();
+ final SetVlanIdActionCaseBuilder setVlanIdActionBuilder = new SetVlanIdActionCaseBuilder();
+ final SetVlanPcpActionCaseBuilder setVlanPcpActionBuilder = new SetVlanPcpActionCaseBuilder();
+ final SwPathActionCaseBuilder swPathActionBuilder = new SwPathActionCaseBuilder();
prepareActionOutput(outputActionBuilder);
prepareActionPushVlan(pushVlanActionBuilder);
odActions.add(new ActionBuilder().setAction(swPathActionBuilder.build()).build());
- ApplyActionsCase innerInst = new ApplyActionsCaseBuilder().setApplyActions(new ApplyActionsBuilder().setAction(odActions).build()).build();
- Instruction applyActions = new InstructionBuilder().setInstruction(innerInst).build();
- List<Instruction> instructions = Collections.singletonList(applyActions );
- InstructionsBuilder instBuilder = new InstructionsBuilder();
+ final ApplyActionsCase innerInst = new ApplyActionsCaseBuilder().setApplyActions(new ApplyActionsBuilder().setAction(odActions).build()).build();
+ final Instruction applyActions = new InstructionBuilder().setInstruction(innerInst).build();
+ final List<Instruction> instructions = Collections.singletonList(applyActions );
+ final InstructionsBuilder instBuilder = new InstructionsBuilder();
instBuilder.setInstruction(instructions);
return instBuilder.build();
}
- private void prepareActionSetVlanPcp(SetVlanPcpActionCaseBuilder wrapper) {
- SetVlanPcpActionBuilder setVlanPcpActionBuilder = new SetVlanPcpActionBuilder();
+ private void prepareActionSetVlanPcp(final SetVlanPcpActionCaseBuilder wrapper) {
+ final SetVlanPcpActionBuilder setVlanPcpActionBuilder = new SetVlanPcpActionBuilder();
setVlanPcpActionBuilder.setVlanPcp(new VlanPcp((short) 7));
wrapper.setSetVlanPcpAction(setVlanPcpActionBuilder.build());
}
- private void prepareActionSetVladId(SetVlanIdActionCaseBuilder wrapper) {
- SetVlanIdActionBuilder setVlanIdActionBuilder = new SetVlanIdActionBuilder();
+ private void prepareActionSetVladId(final SetVlanIdActionCaseBuilder wrapper) {
+ final SetVlanIdActionBuilder setVlanIdActionBuilder = new SetVlanIdActionBuilder();
setVlanIdActionBuilder.setVlanId(new VlanId(4095));
wrapper.setSetVlanIdAction(setVlanIdActionBuilder.build());
}
- private void prepareActionSetVlanCfi(SetVlanCfiActionCaseBuilder wrapper) {
- SetVlanCfiActionBuilder setVlanCfiActionBuilder = new SetVlanCfiActionBuilder();
+ private void prepareActionSetVlanCfi(final SetVlanCfiActionCaseBuilder wrapper) {
+ final SetVlanCfiActionBuilder setVlanCfiActionBuilder = new SetVlanCfiActionBuilder();
setVlanCfiActionBuilder.setVlanCfi(new VlanCfi(1));
wrapper.setSetVlanCfiAction(setVlanCfiActionBuilder.build());
}
- private void prepareActionSetTpDst(SetTpDstActionCaseBuilder wrapper) {
- SetTpDstActionBuilder setTpDstActionBuilder = new SetTpDstActionBuilder();
+ private void prepareActionSetTpDst(final SetTpDstActionCaseBuilder wrapper) {
+ final SetTpDstActionBuilder setTpDstActionBuilder = new SetTpDstActionBuilder();
setTpDstActionBuilder.setPort(new PortNumber(65535));
wrapper.setSetTpDstAction(setTpDstActionBuilder.build());
}
- private void prepareActionSetTpSrc(SetTpSrcActionCaseBuilder wrapper) {
- SetTpSrcActionBuilder setTpSrcActionBuilder = new SetTpSrcActionBuilder();
+ private void prepareActionSetTpSrc(final SetTpSrcActionCaseBuilder wrapper) {
+ final SetTpSrcActionBuilder setTpSrcActionBuilder = new SetTpSrcActionBuilder();
setTpSrcActionBuilder.setPort(new PortNumber(65535));
wrapper.setSetTpSrcAction(setTpSrcActionBuilder.build());
}
- private void prepareActionSetNwTos(SetNwTosActionCaseBuilder wrapper) {
- SetNwTosActionBuilder setNwTosActionBuilder = new SetNwTosActionBuilder();
+ private void prepareActionSetNwTos(final SetNwTosActionCaseBuilder wrapper) {
+ final SetNwTosActionBuilder setNwTosActionBuilder = new SetNwTosActionBuilder();
setNwTosActionBuilder.setTos(252);
wrapper.setSetNwTosAction(setNwTosActionBuilder.build());
}
- private void prepareActionSetNwSrc(List<Action> odActions) {
+ private void prepareActionSetNwSrc(final List<Action> odActions) {
// test case for IPv4
- SetNwSrcActionBuilder setNwSrcActionBuilderIpv4 = new SetNwSrcActionBuilder();
+ final SetNwSrcActionBuilder setNwSrcActionBuilderIpv4 = new SetNwSrcActionBuilder();
setNwSrcActionBuilderIpv4.setAddress(prapareIpv4Address("192.168.100.102"));
odActions.add(new ActionBuilder().setAction(new SetNwSrcActionCaseBuilder().setSetNwSrcAction(setNwSrcActionBuilderIpv4.build()).build()).build());
// test case for IPv6
- SetNwSrcActionBuilder setNwSrcActionBuilderIpv6 = new SetNwSrcActionBuilder();
- setNwSrcActionBuilderIpv6.setAddress(prapareIpv6Address("2001:0db8:85a3:0000:0000:8a2e:0370:7336"));
+ final SetNwSrcActionBuilder setNwSrcActionBuilderIpv6 = new SetNwSrcActionBuilder();
+ setNwSrcActionBuilderIpv6.setAddress(prapareIpv6Prefix("2001:0db8:85a3:0000:0000:8a2e:0370:7336/128"));
odActions.add(new ActionBuilder().setAction(new SetNwSrcActionCaseBuilder().setSetNwSrcAction(setNwSrcActionBuilderIpv6.build()).build()).build());
}
- private void prepareActionSetNwDst(List<Action> odActions) {
+ private void prepareActionSetNwDst(final List<Action> odActions) {
// test case for IPv4
- SetNwDstActionBuilder setNwDstActionBuilderIpv4 = new SetNwDstActionBuilder();
+ final SetNwDstActionBuilder setNwDstActionBuilderIpv4 = new SetNwDstActionBuilder();
setNwDstActionBuilderIpv4.setAddress(prapareIpv4Address("192.168.100.101"));
odActions.add(new ActionBuilder().setAction(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilderIpv4.build()).build()).build());
// test case for IPv6
- SetNwDstActionBuilder setNwDstActionBuilderIpv6 = new SetNwDstActionBuilder();
- setNwDstActionBuilderIpv6.setAddress(prapareIpv6Address("2001:0db8:85a3:0000:0000:8a2e:0370:7335"));
+ final SetNwDstActionBuilder setNwDstActionBuilderIpv6 = new SetNwDstActionBuilder();
+ setNwDstActionBuilderIpv6.setAddress(prapareIpv6Prefix("2001:0db8:85a3:0000:0000:8a2e:0370:7335/128"));
odActions.add(new ActionBuilder().setAction(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilderIpv6.build()).build()).build());
}
- private void prepareActionNextHop(List<Action> odActions) {
+ private void prepareActionNextHop(final List<Action> odActions) {
// test case for IPv4
- SetNextHopActionBuilder setNextHopActionBuilderIpv4 = new SetNextHopActionBuilder();
+ final SetNextHopActionBuilder setNextHopActionBuilderIpv4 = new SetNextHopActionBuilder();
setNextHopActionBuilderIpv4.setAddress(prapareIpv4Address("192.168.100.100"));
odActions.add(new ActionBuilder().setAction(new SetNextHopActionCaseBuilder().setSetNextHopAction(setNextHopActionBuilderIpv4.build()).build()).build());
// test case for IPv6
- SetNextHopActionBuilder setNextHopActionBuilderIpv6 = new SetNextHopActionBuilder();
- setNextHopActionBuilderIpv6.setAddress(prapareIpv6Address("2001:0db8:85a3:0000:0000:8a2e:0370:7334"));
+ final SetNextHopActionBuilder setNextHopActionBuilderIpv6 = new SetNextHopActionBuilder();
+ setNextHopActionBuilderIpv6.setAddress(prapareIpv6Prefix("2001:0db8:85a3:0000:0000:8a2e:0370:7334/128"));
odActions.add(new ActionBuilder().setAction(new SetNextHopActionCaseBuilder().setSetNextHopAction(setNextHopActionBuilderIpv6.build()).build()).build());
}
- private Address prapareIpv4Address(String ipv4Address) {
- Ipv4Builder ipv4Builder = new Ipv4Builder();
+ private Address prapareIpv4Address(final String ipv4Address) {
+ final Ipv4Builder ipv4Builder = new Ipv4Builder();
ipv4Builder.setIpv4Address(new Ipv4Prefix(ipv4Address + "/32"));
return ipv4Builder.build();
}
- private Address prapareIpv6Address(String ipv6Address) {
- Ipv6Builder ipv6Builder = new Ipv6Builder();
+ private Address prapareIpv6Prefix(final String ipv6Address) {
+ final Ipv6Builder ipv6Builder = new Ipv6Builder();
ipv6Builder.setIpv6Address(new Ipv6Prefix(ipv6Address));
return ipv6Builder.build();
}
- private void prepareActionSetDlType(SetDlTypeActionCaseBuilder wrapper) {
- SetDlTypeActionBuilder setDlTypeActionBuilder = new SetDlTypeActionBuilder();
+ private void prepareActionSetDlType(final SetDlTypeActionCaseBuilder wrapper) {
+ final SetDlTypeActionBuilder setDlTypeActionBuilder = new SetDlTypeActionBuilder();
setDlTypeActionBuilder.setDlType(new EtherType(513L));
wrapper.setSetDlTypeAction(setDlTypeActionBuilder.build());
}
- private void prepareActionSetDlSrc(SetDlSrcActionCaseBuilder wrapper) {
- SetDlSrcActionBuilder setDlSrcActionBuilder = new SetDlSrcActionBuilder();
+ private void prepareActionSetDlSrc(final SetDlSrcActionCaseBuilder wrapper) {
+ final SetDlSrcActionBuilder setDlSrcActionBuilder = new SetDlSrcActionBuilder();
setDlSrcActionBuilder.setAddress(new MacAddress("24:77:03:7C:C5:F1"));
wrapper.setSetDlSrcAction(setDlSrcActionBuilder.build());
}
- private void prepareActionSetDlDst(SetDlDstActionCaseBuilder wrapper) {
- SetDlDstActionBuilder setDlDstActionBuilder = new SetDlDstActionBuilder();
+ private void prepareActionSetDlDst(final SetDlDstActionCaseBuilder wrapper) {
+ final SetDlDstActionBuilder setDlDstActionBuilder = new SetDlDstActionBuilder();
setDlDstActionBuilder.setAddress(new MacAddress("3C:A9:F4:00:E0:C8"));
wrapper.setSetDlDstAction(setDlDstActionBuilder.build());
}
- private void prepareActionPushVlan(PushVlanActionCaseBuilder wrapper) {
- PushVlanActionBuilder pushVlanActionBuilder = new PushVlanActionBuilder();
+ private void prepareActionPushVlan(final PushVlanActionCaseBuilder wrapper) {
+ final PushVlanActionBuilder pushVlanActionBuilder = new PushVlanActionBuilder();
pushVlanActionBuilder.setTag(0x8100); // 12 bit
wrapper.setPushVlanAction(pushVlanActionBuilder.build());
}
- private void prepareActionOutput(OutputActionCaseBuilder wrapper) {
- OutputActionBuilder outputActionBuilder = new OutputActionBuilder();
+ private void prepareActionOutput(final OutputActionCaseBuilder wrapper) {
+ final OutputActionBuilder outputActionBuilder = new OutputActionBuilder();
outputActionBuilder.setOutputNodeConnector(new Uri("openflow:1:1"));
wrapper.setOutputAction(outputActionBuilder.build());
}
- private Match prepOdMatch(MtchType mt) {
- MatchBuilder odMatchBuilder = new MatchBuilder();
+ private Match prepOdMatch(final MtchType mt) {
+ final MatchBuilder odMatchBuilder = new MatchBuilder();
switch (mt) {
case other:
odMatchBuilder.setInPort(new NodeConnectorId("openflow:12:345"));
}
private Layer4Match prepLayer4MatchUdp() {
- UdpMatchBuilder udpMatchBuilder = new UdpMatchBuilder();
+ final UdpMatchBuilder udpMatchBuilder = new UdpMatchBuilder();
udpMatchBuilder.setUdpSourcePort(new PortNumber(11));
udpMatchBuilder.setUdpDestinationPort(new PortNumber(12));
}
private Layer4Match prepLayer4MatchTcp() {
- TcpMatchBuilder tcpMatchBuilder = new TcpMatchBuilder();
+ final TcpMatchBuilder tcpMatchBuilder = new TcpMatchBuilder();
tcpMatchBuilder.setTcpSourcePort(new PortNumber(21));
tcpMatchBuilder.setTcpDestinationPort(new PortNumber(22));
}
private Layer4Match prepLayer4MatchSctp() {
- SctpMatchBuilder sctpMatchBuilder = new SctpMatchBuilder();
+ final SctpMatchBuilder sctpMatchBuilder = new SctpMatchBuilder();
sctpMatchBuilder.setSctpSourcePort(new PortNumber(31));
sctpMatchBuilder.setSctpDestinationPort(new PortNumber(32));
}
private Layer3Match prepLayer3MatchIpv4() {
- Ipv4MatchBuilder ipv4MatchBuilder = new Ipv4MatchBuilder();
+ final Ipv4MatchBuilder ipv4MatchBuilder = new Ipv4MatchBuilder();
ipv4MatchBuilder.setIpv4Source(new Ipv4Prefix("192.168.1.104/32"));
ipv4MatchBuilder.setIpv4Destination(new Ipv4Prefix("192.168.1.105/32"));
return ipv4MatchBuilder.build();
}
private Layer3Match prepLayer3MatchIpv6() {
- Ipv6MatchBuilder ipv6MatchBuilder = new Ipv6MatchBuilder();
- ipv6MatchBuilder.setIpv6Source(new Ipv6Prefix("3001:0db8:85a3:0000:0000:8a2e:0370:7334"));
- ipv6MatchBuilder.setIpv6Destination(new Ipv6Prefix("3001:0db8:85a3:0000:0000:8a2e:0370:7335"));
+ final Ipv6MatchBuilder ipv6MatchBuilder = new Ipv6MatchBuilder();
+ ipv6MatchBuilder.setIpv6Source(new Ipv6Prefix("3001:0db8:85a3:0000:0000:8a2e:0370:7334/128"));
+ ipv6MatchBuilder.setIpv6Destination(new Ipv6Prefix("3001:0db8:85a3:0000:0000:8a2e:0370:7335/128"));
return ipv6MatchBuilder.build();
}
private Layer3Match prepLayer3MatchArp() {
- ArpMatchBuilder arpMatchBuilder = new ArpMatchBuilder();
+ final ArpMatchBuilder arpMatchBuilder = new ArpMatchBuilder();
arpMatchBuilder.setArpSourceTransportAddress(new Ipv4Prefix("192.168.1.101/32"));
arpMatchBuilder.setArpTargetTransportAddress(new Ipv4Prefix("192.168.1.102/32"));
- ArpSourceHardwareAddressBuilder arpSourAddressBuild = new ArpSourceHardwareAddressBuilder();
+ final ArpSourceHardwareAddressBuilder arpSourAddressBuild = new ArpSourceHardwareAddressBuilder();
arpSourAddressBuild.setAddress(new MacAddress("22:44:66:88:AA:CC"));
arpMatchBuilder.setArpSourceHardwareAddress(arpSourAddressBuild.build());
- ArpTargetHardwareAddressBuilder arpTarAddressBuild = new ArpTargetHardwareAddressBuilder();
+ final ArpTargetHardwareAddressBuilder arpTarAddressBuild = new ArpTargetHardwareAddressBuilder();
arpTarAddressBuild.setAddress(new MacAddress("11:33:55:77:BB:DD"));
arpMatchBuilder.setArpTargetHardwareAddress(arpTarAddressBuild.build());
return arpMatchBuilder.build();
}
private VlanMatch prepVlanMatch() {
- VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
+ final VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
- VlanIdBuilder vlanIdBuilder = new VlanIdBuilder().setVlanId(new VlanId(0xfff));
+ final VlanIdBuilder vlanIdBuilder = new VlanIdBuilder().setVlanId(new VlanId(0xfff));
vlanMatchBuilder.setVlanId(vlanIdBuilder.setVlanIdPresent(true).build());
vlanMatchBuilder.setVlanPcp(new VlanPcp((short) 0x7));
}
private VlanMatch prepVlanNoneMatch() {
- VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
+ final VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
- VlanIdBuilder vlanIdBuilder = new VlanIdBuilder().
+ final VlanIdBuilder vlanIdBuilder = new VlanIdBuilder().
setVlanIdPresent(false);
vlanMatchBuilder.setVlanId(vlanIdBuilder.build());
}
private IpMatch prepIpMatch() {
- IpMatchBuilder ipMatchBuilder = new IpMatchBuilder();
+ final IpMatchBuilder ipMatchBuilder = new IpMatchBuilder();
ipMatchBuilder.setIpDscp(new Dscp((short) 0x33));
ipMatchBuilder.setIpProtocol((short) 0x3f);
return ipMatchBuilder.build();
}
private EthernetMatch prepEthernetMatch() {
- EthernetMatchBuilder odEthernetMatchBuilder = new EthernetMatchBuilder();
+ final EthernetMatchBuilder odEthernetMatchBuilder = new EthernetMatchBuilder();
odEthernetMatchBuilder.setEthernetDestination(prepEthDest());
odEthernetMatchBuilder.setEthernetSource(prepEthSour());
odEthernetMatchBuilder.setEthernetType(prepEthType());
}
private EthernetType prepEthType() {
- EthernetTypeBuilder ethTypeBuild = new EthernetTypeBuilder();
+ final EthernetTypeBuilder ethTypeBuild = new EthernetTypeBuilder();
ethTypeBuild.setType(new EtherType(0xffffL));
return ethTypeBuild.build();
}
private EthernetSource prepEthSour() {
- EthernetSourceBuilder ethSourBuild = new EthernetSourceBuilder();
+ final EthernetSourceBuilder ethSourBuild = new EthernetSourceBuilder();
ethSourBuild.setAddress(new MacAddress("24:77:03:7C:C5:F1"));
return ethSourBuild.build();
}
private EthernetDestination prepEthDest() {
- EthernetDestinationBuilder ethDestBuild = new EthernetDestinationBuilder();
+ final EthernetDestinationBuilder ethDestBuild = new EthernetDestinationBuilder();
ethDestBuild.setAddress(new MacAddress("3C:A9:F4:00:E0:C8"));
return ethDestBuild.build();
}
import io.netty.util.Timeout;
import java.math.BigInteger;
+import java.util.List;
import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.controller.md.sal.binding.api.NotificationService;
import org.opendaylight.controller.md.sal.binding.api.ReadTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandlerRegistration;
import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginTimer;
import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
+import org.opendaylight.openflowplugin.api.openflow.connection.OutboundQueueProvider;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceContextClosedHandler;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceDisconnectedHandler;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceReplyProcessor;
import org.opendaylight.openflowplugin.api.openflow.registry.meter.DeviceMeterRegistry;
import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
import org.opendaylight.openflowplugin.api.openflow.translator.TranslatorLibrarian;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
*/
<T extends DataObject> void addDeleteToTxChain(final LogicalDatastoreType store, final InstanceIdentifier<T> path);
+ /**
+ * Method submits Transaction to DataStore.
+ * @return transaction is submitted successfully
+ */
+ boolean submitTransaction();
+
/**
* Method exposes transaction created for device
* represented by this context. This read only transaction has a fresh dataStore snapshot.
*/
void addDeviceContextClosedHandler(DeviceContextClosedHandler deviceContextClosedHandler);
- void startGatheringOperationsToOneTransaction();
-
- void commitOperationsGatheredInOneTransaction();
-
- MultiMsgCollector getMultiMsgCollector();
+ MultiMsgCollector getMultiMsgCollector(final RequestContext<List<MultipartReply>> requestContext);
Long getReservedXid();
/**
- * Method registers outbound queue handler that should be invalidated when device context is closed.s
- * @param outboundQueueHandlerRegistration
+ * Method registers outbound queue provider into current device context's primary connection adapter.
+ *
+ * @param outboundQueueProvider
+ * @param maxQueueDepth
+ * @param barrierNanos
*/
- void registerOutboundQueueHandler(OutboundQueueHandlerRegistration outboundQueueHandlerRegistration);
+ void registerOutboundQueueProvider(OutboundQueueProvider outboundQueueProvider, int maxQueueDepth, long barrierNanos);
+
}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowplugin.api.openflow.device.exception;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error;
-
-/**
- * @deprecated FIXME: TO BE REMOVED: migrate to org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException.
- */
-@Deprecated
-public class DeviceDataException extends Exception {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private Error error;
-
- public DeviceDataException(final String message) {
- super(message);
- }
-
- public DeviceDataException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
- public DeviceDataException(final String message, final Error error) {
- super(message);
- this.error= error;
- }
-
- public Error getError() {
- return error;
- }
-}
package org.opendaylight.openflowplugin.api.openflow.device.handlers;
import java.util.List;
-
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.device.exception.DeviceDataException;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;
/**
- *
* @author tkubas
- *
*/
public interface DeviceReplyProcessor {
/**
* Method that set future to context in Map
+ *
* @param ofHeader
*/
public void processReply(OfHeader ofHeader);
/**
* Method that set future to context in Map
+ *
* @param xid,
* @param ofHeaderList
*/
public void processReply(Xid xid, List<MultipartReply> ofHeaderList);
- /**
- * Method that set exception to the future
- * @param xid,
- * @param deviceDataException
- */
- public void processException(Xid xid, DeviceDataException deviceDataException);
-
/**
* Method process async flow removed from device
+ *
* @param flowRemoved
*/
public void processFlowRemovedMessage(FlowRemoved flowRemoved);
/**
* Method process async port status from device
+ *
* @param portStatus
*/
public void processPortStatusMessage(PortStatusMessage portStatus);
/**
* Method process async packet in from device
+ *
* @param packetInMessage
*/
public void processPacketInMessage(PacketInMessage packetInMessage);
package org.opendaylight.openflowplugin.api.openflow.device.handlers;
-import java.util.List;
import javax.annotation.Nonnull;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
/**
* Created: Mar 23, 2015
*/
public interface MultiMsgCollector {
-
- /**
- * Property used to know a max life time of Multipart collection in internal Cache
- */
- final int DEFAULT_TIME_OUT = 10;
-
- /**
- * Method registers a requst context to the Multipart messages collector
- * and returns Settable future with all MultipartReply. Method has to be called before
- * send a request to the device, otherwise there is a small possibility to miss a first msg.
- *
- * @param requestContext
- */
- void registerMultipartRequestContext(RequestContext<List<MultipartReply>> requestContext);
-
/**
* Method adds a reply multipart message to the collection and if the message has marker
* "I'M A LAST" method set whole Collection to Future object and remove from cache.
*/
void addMultipartMsg(@Nonnull MultipartReply reply);
-
- void setDeviceReplyProcessor(DeviceReplyProcessor deviceReplyProcessor);
-
- void invalidateRequestContext(RequestContext<List<MultipartReply>> requestContext);
+ /**
+ * Null response could be a valid end multipart collecting event for barrier response scenario.
+ * We are not able to resolve an issue (it is or it isn't barrier scenario) so we have to finish
+ * collecting multipart messages successfully.
+ */
+ void endCollecting();
}
*/
public interface DeviceFlowRegistry extends AutoCloseable {
- FlowDescriptor retrieveIdForFlow(FlowHash flowHash);
+ FlowDescriptor retrieveIdForFlow(FlowRegistryKey flowRegistryKey);
- void store(FlowHash flowHash, FlowDescriptor flowDescriptor);
+ void store(FlowRegistryKey flowRegistryKey, FlowDescriptor flowDescriptor);
- FlowId storeIfNecessary(FlowHash flowHash, short tableId);
+ FlowId storeIfNecessary(FlowRegistryKey flowRegistryKey, short tableId);
- void markToBeremoved(FlowHash flowHash);
+ void markToBeremoved(FlowRegistryKey flowRegistryKey);
void removeMarked();
- Map<FlowHash, FlowDescriptor> getAllFlowDescriptors();
+ Map<FlowRegistryKey, FlowDescriptor> getAllFlowDescriptors();
@Override
void close();
* Marker interface identifying flow stored in OFP local flow registry.
* Created by Martin Bobak <mbobak@cisco.com> on 8.4.2015.
*/
-public interface FlowHash {
-
- long getFlowHash();
+public interface FlowRegistryKey {
short getTableId();
BigInteger getCookie();
+
}
package org.opendaylight.openflowplugin.api.openflow.statistics;
import com.google.common.util.concurrent.ListenableFuture;
+import javax.annotation.CheckForNull;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
/**
* Created by Martin Bobak <mbobak@cisco.com> on 27.2.2015.
public interface StatisticsContext extends RequestContextStack, AutoCloseable {
public ListenableFuture<Boolean> gatherDynamicData();
+
+ ListenableFuture<Boolean> gatherDynamicData(@CheckForNull MultipartType multipartType);
+
}
public class OpenFlowPluginProviderImpl implements OpenFlowPluginProvider, OpenFlowPluginExtensionRegistratorProvider {
private static final Logger LOG = LoggerFactory.getLogger(OpenFlowPluginProviderImpl.class);
+ private static final MessageIntelligenceAgency messageIntelligenceAgency = new MessageIntelligenceAgencyImpl();
+ private final int rpcRequestsQuota;
private DeviceManager deviceManager;
private RpcManager rpcManager;
private RpcProviderRegistry rpcProviderRegistry;
private DataBroker dataBroker;
private OfpRole role;
private Collection<SwitchConnectionProvider> switchConnectionProviders;
- private final Long rpcRequestsQuota;
- private static final MessageIntelligenceAgency messageIntelligenceAgency = new MessageIntelligenceAgencyImpl();
-
- public OpenFlowPluginProviderImpl(final Long rpcRequestsQuota) {
- this.rpcRequestsQuota = rpcRequestsQuota;
+ public OpenFlowPluginProviderImpl(final long rpcRequestsQuota) {
+ Preconditions.checkArgument(rpcRequestsQuota > 0 && rpcRequestsQuota <= Integer.MAX_VALUE, "rpcRequestQuota has to be in range <1,%s>", Integer.MAX_VALUE);
+ this.rpcRequestsQuota = (int) rpcRequestsQuota;
}
return maker(xid, type, ofVersion, false, makeDefaultEmptyRequestBody(type, ofVersion));
}
- /**
- * Method validate input values and makes {@link MultipartRequestInput} from input values. Method set
- * a moreRequest marker to false.
- *
- * @param xid
- * @param type
- * @param ofVersion
- * @param body
- * @return
- */
- public static MultipartRequestInput makeMultipartRequestInput(final long xid, final short ofVersion,
- @Nonnull final MultipartType type, @Nonnull final MultipartRequestBody body) {
- Preconditions.checkArgument(validationOfMultipartTypeAndRequestBody(type, body));
- return maker(xid, type, ofVersion, false, body);
- }
-
- /**
- * Method validates input and makes {@link MultipartRequestInput} from input values. Method creates
- * default empty {@link MultipartRequestBody} by {@link MultipartType}
- *
- * @param xid
- * @param type
- * @param ofVersion
- * @param moreRequests
- * @return
- */
- public static MultipartRequestInput makeMultipartRequestInput(final long xid, final short ofVersion,
- @Nonnull final MultipartType type, final boolean moreRequests) {
- return maker(xid, type, ofVersion, moreRequests, makeDefaultEmptyRequestBody(type, ofVersion));
- }
- /**
- * Method validates input values and makes {@link MultipartRequestInput} from input values.
- *
- * @param xid
- * @param type
- * @param ofVersion
- * @param moreRequests
- * @param body
- * @return
- */
- public static MultipartRequestInput makeMultipartRequestInput(final long xid, final short ofVersion,
- @Nonnull final MultipartType type, final boolean moreRequests,
- @Nonnull final MultipartRequestBody body) {
- Preconditions.checkArgument(validationOfMultipartTypeAndRequestBody(type, body));
- return maker(xid, type, ofVersion, moreRequests, body);
- }
/**
* Method build {@link MultipartRequestInput} from input values. It is private because we would like
return bitmapNegotiationEnabled ;
}
- /**
- * @param bitmapNegotiationEnabled the bitmapNegotiationEnabled to set
- */
- public void setBitmapNegotiationEnabled(final boolean bitmapNegotiationEnabled) {
- this.bitmapNegotiationEnabled = bitmapNegotiationEnabled;
- }
@Override
public boolean accept(final InetAddress switchAddress) {
import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandlerRegistration;
import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
+import org.opendaylight.openflowplugin.api.openflow.connection.OutboundQueueProvider;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
import org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.device.exception.DeviceDataException;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceContextClosedHandler;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceDisconnectedHandler;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
public class DeviceContextImpl implements DeviceContext {
private static final Logger LOG = LoggerFactory.getLogger(DeviceContextImpl.class);
- public static final String DEVICE_DISCONNECTED = "Device disconnected.";
private final ConnectionContext primaryConnectionContext;
private final DeviceState deviceState;
private DeviceDisconnectedHandler deviceDisconnectedHandler;
private final Collection<DeviceContextClosedHandler> closeHandlers = new HashSet<>();
private NotificationPublishService notificationPublishService;
- private final OutboundQueue outboundQueueProvider;
- private final MultiMsgCollector multiMsgCollector = new MultiMsgCollectorImpl();
+ private OutboundQueue outboundQueueProvider;
private volatile int outstandingNotificationsAmount = 0;
private volatile boolean filteringPacketIn = false;
private final Object throttlingLock = new Object();
private int filteringHighWaterMark = 0;
- private OutboundQueueHandlerRegistration outboundQueueHandlerRegistration;
-
- @Override
- public MultiMsgCollector getMultiMsgCollector() {
- return multiMsgCollector;
- }
+ private OutboundQueueHandlerRegistration<?> outboundQueueHandlerRegistration;
@Override
public Long getReservedXid() {
this.deviceState = Preconditions.checkNotNull(deviceState);
this.dataBroker = Preconditions.checkNotNull(dataBroker);
this.hashedWheelTimer = Preconditions.checkNotNull(hashedWheelTimer);
- txChainManager = new TransactionChainManager(dataBroker, hashedWheelTimer, 500L, 500L);
+ txChainManager = new TransactionChainManager(dataBroker, deviceState);
auxiliaryConnectionContexts = new HashMap<>();
deviceFlowRegistry = new DeviceFlowRegistryImpl();
deviceGroupRegistry = new DeviceGroupRegistryImpl();
deviceMeterRegistry = new DeviceMeterRegistryImpl();
messageSpy = _messageSpy;
- multiMsgCollector.setDeviceReplyProcessor(this);
- outboundQueueProvider = Preconditions.checkNotNull(primaryConnectionContext.getOutboundQueueProvider());
}
/**
* This method is called from {@link DeviceManagerImpl} only. So we could say "posthandshake process finish"
* and we are able to set a scheduler for an automatic transaction submitting by time (0,5sec).
*/
- void submitTransaction() {
- txChainManager.enableSubmit();
- txChainManager.submitTransaction();
+ void initialSubmitTransaction() {
+ txChainManager.initialSubmitWriteTransaction();
}
@Override
txChainManager.addDeleteOperationTotTxChain(store, path);
}
+ @Override
+ public boolean submitTransaction() {
+ return txChainManager.submitWriteTransaction();
+ }
+
@Override
public ConnectionContext getPrimaryConnectionContext() {
return primaryConnectionContext;
}
}
- @Override
- public void processException(final Xid xid, final DeviceDataException deviceDataException) {
- messageSpy.spyMessage(deviceDataException.getClass(), MessageSpy.STATISTIC_GROUP.FROM_SWITCH_PUBLISHED_FAILURE);
- }
-
@Override
public void processFlowRemovedMessage(final FlowRemoved flowRemoved) {
//TODO: will be defined later
} else if (portStatus.getReason().equals(PortReason.OFPPRDELETE)) {
addDeleteToTxChain(LogicalDatastoreType.OPERATIONAL, iiToNodeConnector);
}
+ submitTransaction();
}
private KeyedInstanceIdentifier<NodeConnector, NodeConnectorKey> provideIIToNodeConnector(final long portNo, final short version) {
}
messageSpy.spyMessage(packetReceived.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.FROM_SWITCH_TRANSLATE_SRC_FAILURE);
- ListenableFuture<? extends Object> offerNotification = notificationPublishService.offerNotification(packetReceived);
+ final ListenableFuture<? extends Object> offerNotification = notificationPublishService.offerNotification(packetReceived);
synchronized (throttlingLock) {
outstandingNotificationsAmount += 1;
}
}
@Override
- public void close() {
+ public void close() throws Exception {
deviceState.setValid(false);
- outboundQueueHandlerRegistration.close();
-
- LOG.trace("Removing node {} from operational DS.", getDeviceState().getNodeId());
- addDeleteToTxChain(LogicalDatastoreType.OPERATIONAL, getDeviceState().getNodeInstanceIdentifier());
-
deviceGroupRegistry.close();
deviceFlowRegistry.close();
deviceMeterRegistry.close();
+ outboundQueueHandlerRegistration.close();
+
if (primaryConnectionContext.getConnectionAdapter().isAlive()) {
primaryConnectionContext.setConnectionState(ConnectionContext.CONNECTION_STATE.RIP);
primaryConnectionContext.getConnectionAdapter().disconnect();
connectionContext.getConnectionAdapter().disconnect();
}
}
+
for (final DeviceContextClosedHandler deviceContextClosedHandler : closeHandlers) {
deviceContextClosedHandler.onDeviceContextClosed(this);
}
+
+ txChainManager.close();
}
@Override
public void onDeviceDisconnected(final ConnectionContext connectionContext) {
- if (this.getPrimaryConnectionContext().equals(connectionContext)) {
+ if (getPrimaryConnectionContext().equals(connectionContext)) {
try {
close();
} catch (final Exception e) {
@Override
public void addDeviceContextClosedHandler(final DeviceContextClosedHandler deviceContextClosedHandler) {
- this.closeHandlers.add(deviceContextClosedHandler);
- }
-
- @Override
- public void startGatheringOperationsToOneTransaction() {
- txChainManager.startGatheringOperationsToOneTransaction();
- }
-
- @Override
- public void commitOperationsGatheredInOneTransaction() {
- txChainManager.commitOperationsGatheredInOneTransaction();
+ closeHandlers.add(deviceContextClosedHandler);
}
@Override
public void onPublished() {
primaryConnectionContext.getConnectionAdapter().setPacketInFiltering(false);
- for (ConnectionContext switchAuxConnectionContext : auxiliaryConnectionContexts.values()) {
+ for (final ConnectionContext switchAuxConnectionContext : auxiliaryConnectionContexts.values()) {
switchAuxConnectionContext.getConnectionAdapter().setPacketInFiltering(false);
}
}
@Override
- public void registerOutboundQueueHandler(final OutboundQueueHandlerRegistration outboundQueueHandlerRegistration) {
- this.outboundQueueHandlerRegistration = outboundQueueHandlerRegistration;
+ public void registerOutboundQueueProvider(final OutboundQueueProvider outboundQueueProvider, final int maxQueueDepth, final long barrierNanos) {
+ final ConnectionAdapter primaryConnectionAdapter = primaryConnectionContext.getConnectionAdapter();
+ outboundQueueHandlerRegistration = primaryConnectionAdapter.registerOutboundQueueHandler(outboundQueueProvider, maxQueueDepth, barrierNanos);
+ this.outboundQueueProvider = outboundQueueProvider;
+ primaryConnectionContext.setOutboundQueueProvider(outboundQueueProvider);
+ }
+
+ @Override
+ public MultiMsgCollector getMultiMsgCollector(final RequestContext<List<MultipartReply>> requestContext) {
+ return new MultiMsgCollectorImpl(this, requestContext);
}
}
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
-import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandlerRegistration;
import org.opendaylight.openflowplugin.api.ConnectionException;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
public void onDeviceContextLevelUp(final DeviceContext deviceContext) {
// final phase - we have to add new Device to MD-SAL DataStore
Preconditions.checkNotNull(deviceContext);
- ((DeviceContextImpl) deviceContext).submitTransaction();
+ ((DeviceContextImpl) deviceContext).initialSubmitTransaction();
deviceContext.onPublished();
}
connectionAdapter.setPacketInFiltering(true);
final Short version = connectionContext.getFeatures().getVersion();
- OutboundQueueProvider outboundQueueProvider = new OutboundQueueProviderImpl(version);
-
- final OutboundQueueHandlerRegistration outboundQueueHandlerRegistration = connectionAdapter.registerOutboundQueueHandler(outboundQueueProvider, maxQueueDepth, barrierNanos);
- connectionContext.setOutboundQueueProvider(outboundQueueProvider);
+ final OutboundQueueProvider outboundQueueProvider = new OutboundQueueProviderImpl(version);
final DeviceState deviceState = new DeviceStateImpl(connectionContext.getFeatures(), connectionContext.getNodeId());
final DeviceContext deviceContext = new DeviceContextImpl(connectionContext, deviceState, dataBroker, hashedWheelTimer, messageIntelligenceAgency);
- deviceContext.registerOutboundQueueHandler(outboundQueueHandlerRegistration);
+ deviceContext.registerOutboundQueueProvider(outboundQueueProvider, maxQueueDepth, barrierNanos);
deviceContext.setNotificationService(notificationService);
deviceContext.setNotificationPublishService(notificationPublishService);
- NodeBuilder nodeBuilder = new NodeBuilder().setId(deviceState.getNodeId()).setNodeConnector(Collections.<NodeConnector>emptyList());
+ final NodeBuilder nodeBuilder = new NodeBuilder().setId(deviceState.getNodeId()).setNodeConnector(Collections.<NodeConnector>emptyList());
deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, deviceState.getNodeInstanceIdentifier(), nodeBuilder.build());
connectionContext.setDeviceDisconnectedHandler(deviceContext);
LOG.trace("Hooking xid {} to device context - precaution.", reserved);
- final MultiMsgCollector multiMsgCollector = deviceContext.getMultiMsgCollector();
- multiMsgCollector.registerMultipartRequestContext(requestContext);
+ final MultiMsgCollector multiMsgCollector = deviceContext.getMultiMsgCollector(requestContext);
queue.commitEntry(xid.getValue(), MultipartRequestInputFactory.makeMultipartRequestInput(xid.getValue(), version, type), new FutureCallback<OfHeader>() {
@Override
public void onSuccess(final OfHeader ofHeader) {
if (ofHeader instanceof MultipartReply) {
- MultipartReply multipartReply = (MultipartReply) ofHeader;
+ final MultipartReply multipartReply = (MultipartReply) ofHeader;
multiMsgCollector.addMultipartMsg(multipartReply);
+ } else if (null != ofHeader) {
+ LOG.info("Unexpected response type received {}.", ofHeader.getClass());
} else {
- if (null != ofHeader) {
- LOG.info("Unexpected response type received {}.", ofHeader.getClass());
- } else {
- LOG.info("Response received is null.");
- }
+ multiMsgCollector.endCollecting();
+ LOG.info("Response received is null.");
}
-
}
@Override
public void onFailure(final Throwable t) {
LOG.info("Fail response from OutboundQueue for multipart type {}.", type, t);
- multiMsgCollector.invalidateRequestContext(requestContext);
+ requestContext.close();
if (MultipartType.OFPMPTABLEFEATURES.equals(type)) {
makeEmptyTables(deviceContext, nodeII, deviceContext.getPrimaryConnectionContext().getFeatures().getTables());
}
}
});
-
return requestContext.getFuture();
}
@Override
public void setNotificationPublishService(final NotificationPublishService notificationService) {
- this.notificationPublishService = notificationService;
+ notificationPublishService = notificationService;
}
@Override
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
-import io.netty.util.HashedWheelTimer;
-import io.netty.util.Timeout;
-import io.netty.util.TimerTask;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
import javax.annotation.Nonnull;
import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
* <p/>
* Created: Apr 2, 2015
*/
-@VisibleForTesting
-class TransactionChainManager implements TransactionChainListener {
+class TransactionChainManager implements TransactionChainListener, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(TransactionChainManager.class);
- private final HashedWheelTimer hashedWheelTimer;
+ private final Object txLock = new Object();
+
+ private final DeviceState deviceState;
private final DataBroker dataBroker;
- private final long maxTx;
- private final long timerValue;
- private BindingTransactionChain txChainFactory;
private WriteTransaction wTx;
- private Timeout submitTaskTime;
- private long nrOfActualTx;
+ private BindingTransactionChain txChainFactory;
private boolean submitIsEnabled;
- TransactionChainManager(@Nonnull final DataBroker dataBroker,
- @Nonnull final HashedWheelTimer hashedWheelTimer,
- final long maxTx,
- final long timerValue) {
+ TransactionChainManager(@Nonnull final DataBroker dataBroker, @Nonnull final DeviceState deviceState) {
this.dataBroker = Preconditions.checkNotNull(dataBroker);
- this.hashedWheelTimer = Preconditions.checkNotNull(hashedWheelTimer);
- this.maxTx = maxTx;
+ this.deviceState = Preconditions.checkNotNull(deviceState);
txChainFactory = dataBroker.createTransactionChain(TransactionChainManager.this);
- nrOfActualTx = 0L;
- this.timerValue = timerValue;
- LOG.debug("created txChainManager with operation limit {}", maxTx);
+ LOG.debug("created txChainManager");
}
-
- public void commitOperationsGatheredInOneTransaction() {
+ void initialSubmitWriteTransaction() {
enableSubmit();
- submitTransaction();
+ submitWriteTransaction();
}
- public void startGatheringOperationsToOneTransaction() {
- submitIsEnabled = false;
- }
-
- <T extends DataObject> void writeToTransaction(final LogicalDatastoreType store,
- final InstanceIdentifier<T> path, final T data) {
- try {
- final WriteTransaction writeTx = getTransactionSafely();
- writeTx.put(store, path, data);
- countTxInAndCommit();
- } catch (final Exception e) {
- LOG.warn("failed to put into writeOnlyTransaction: {}", e.getMessage());
- LOG.trace("failed to put into writeOnlyTransaction.. ", e);
+ boolean submitWriteTransaction() {
+ if ( ! submitIsEnabled) {
+ LOG.trace("transaction not committed - submit block issued");
+ return false;
}
- }
-
- private WriteTransaction getTransactionSafely() {
if (wTx == null) {
- wTx = txChainFactory.newWriteOnlyTransaction();
+ LOG.trace("nothing to commit - submit returns true");
+ return true;
}
- return wTx;
+ if ( ! deviceState.isValid()) {
+ LOG.info("DeviceState is not valid will not submit transaction");
+ return false;
+ }
+ synchronized (txLock) {
+ wTx.submit();
+ wTx = null;
+ }
+ return true;
}
<T extends DataObject> void addDeleteOperationTotTxChain(final LogicalDatastoreType store,
- final InstanceIdentifier<T> path) {
+ final InstanceIdentifier<T> path) {
try {
final WriteTransaction writeTx = getTransactionSafely();
writeTx.delete(store, path);
- countTxInAndCommit();
} catch (final Exception e) {
LOG.warn("failed to put into writeOnlyTransaction : {}", e.getMessage());
LOG.trace("failed to put into writeOnlyTransaction.. ", e);
}
}
- private void countTxInAndCommit() {
- nrOfActualTx += 1L;
- if (nrOfActualTx >= maxTx) {
- submitTransaction();
+ <T extends DataObject> void writeToTransaction(final LogicalDatastoreType store,
+ final InstanceIdentifier<T> path, final T data) {
+ try {
+ final WriteTransaction writeTx = getTransactionSafely();
+ writeTx.put(store, path, data);
+ } catch (final Exception e) {
+ LOG.warn("failed to put into writeOnlyTransaction: {}", e.getMessage());
+ LOG.trace("failed to put into writeOnlyTransaction.. ", e);
}
}
- void submitScheduledTransaction(final Timeout timeout) {
- if (timeout.isCancelled()) {
- // zombie timer executed
- return;
- }
-
- if (submitIsEnabled) {
- if (nrOfActualTx > 0L) {
- submitTransaction();
- }
- } else {
- LOG.info("transaction submit task will not be scheduled - submit block issued.");
- }
+ @Override
+ public void onTransactionChainFailed(final TransactionChain<?, ?> chain,
+ final AsyncTransaction<?, ?> transaction, final Throwable cause) {
+ LOG.warn("txChain failed -> recreating", cause);
+ recreateTxChain();
}
- void submitTransaction() {
- if (submitIsEnabled) {
- if (wTx != null && nrOfActualTx > 0) {
- LOG.trace("submitting transaction, counter: {}", nrOfActualTx);
- final CheckedFuture<Void, TransactionCommitFailedException> submitResult = wTx.submit();
- try {
- submitResult.get();
- } catch (ExecutionException | InterruptedException e) {
- recreateTxChain();
- }
- hookTimeExpenseCounter(submitResult, String.valueOf(wTx.getIdentifier()) + "::" + nrOfActualTx);
- wTx = null;
- nrOfActualTx = 0L;
- }
- if (submitTaskTime != null) {
- // if possible then cancel current timer (even if being executed via timer)
- submitTaskTime.cancel();
- }
- submitTaskTime = hashedWheelTimer.newTimeout(new TimerTask() {
- @Override
- public void run(final Timeout timeout) throws Exception {
- submitScheduledTransaction(timeout);
- }
- }, timerValue, TimeUnit.MILLISECONDS);
+ @Override
+ public void onTransactionChainSuccessful(final TransactionChain<?, ?> chain) {
+ // NOOP - only yet, here is probably place for notification to get new WriteTransaction
+ }
- } else {
- LOG.trace("transaction not committed - submit block issued");
+ private void recreateTxChain() {
+ txChainFactory.close();
+ txChainFactory = dataBroker.createTransactionChain(TransactionChainManager.this);
+ synchronized (txLock) {
+ wTx = null;
}
}
- private static void hookTimeExpenseCounter(final CheckedFuture<Void, TransactionCommitFailedException> submitResult, final String name) {
- final long submitFiredTime = System.nanoTime();
- LOG.debug("submit of {} fired", name);
- Futures.addCallback(submitResult, new FutureCallback<Void>() {
- @Override
- public void onSuccess(final Void result) {
- LOG.debug("submit of {} finished in {} ms", name, System.nanoTime() - submitFiredTime);
- }
-
- @Override
- public void onFailure(final Throwable t) {
- LOG.warn("transaction submit failed: {}", t.getMessage());
+ private WriteTransaction getTransactionSafely() {
+ if (wTx == null) {
+ synchronized (txLock) {
+ if (wTx == null) {
+ wTx = txChainFactory.newWriteOnlyTransaction();
+ }
}
- });
+ }
+ return wTx;
}
+ @VisibleForTesting
void enableSubmit() {
submitIsEnabled = true;
}
@Override
- public void onTransactionChainFailed(final TransactionChain<?, ?> chain,
- final AsyncTransaction<?, ?> transaction, final Throwable cause) {
- LOG.warn("txChain failed -> recreating", cause);
- recreateTxChain();
- }
-
- private void recreateTxChain() {
- txChainFactory.close();
- txChainFactory = dataBroker.createTransactionChain(TransactionChainManager.this);
- }
-
- @Override
- public void onTransactionChainSuccessful(final TransactionChain<?, ?> chain) {
- // NOOP - only yet, here is probably place for notification to get new WriteTransaction
+ public void close() throws Exception {
+ LOG.debug("Removing node {} from operational DS.", deviceState.getNodeId());
+ synchronized (txLock) {
+ final WriteTransaction writeTx = getTransactionSafely();
+ writeTx.delete(LogicalDatastoreType.OPERATIONAL, deviceState.getNodeInstanceIdentifier());
+ writeTx.submit();
+ wTx = null;
+ txChainFactory.close();
+ }
}
-
}
package org.opendaylight.openflowplugin.impl.device.listener;
-import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
-import com.google.common.cache.Cache;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.RemovalListener;
-import com.google.common.cache.RemovalNotification;
import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.TimeUnit;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
-import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.device.exception.DeviceDataException;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceReplyProcessor;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
-import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.slf4j.Logger;
/**
* <p>
- * openflowplugin-api
- * org.opendaylight.openflowplugin.impl.openflow.device
- *
+
* Implementation for {@link MultiMsgCollector} interface
*
* @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
* </p>
* Created: Mar 23, 2015
*/
-@VisibleForTesting
public class MultiMsgCollectorImpl implements MultiMsgCollector {
private static final Logger LOG = LoggerFactory.getLogger(MultiMsgCollectorImpl.class);
- private final Cache<Long, MultiCollectorObject> cache;
- private DeviceReplyProcessor deviceReplyProcessor;
-
- public MultiMsgCollectorImpl() {
- this(DEFAULT_TIME_OUT);
- }
-
- public MultiMsgCollectorImpl(final int timeout) {
- cache = initCacheBuilder(timeout).build();
- }
-
- private static RemovalListener<Long, MultiCollectorObject> getRemovalListener() {
- return new RemovalListener<Long, MultiCollectorObject>() {
- @Override
- public void onRemoval(final RemovalNotification<Long, MultiCollectorObject> notification) {
- LOG.trace("Removing data with XID {} from cache, cause: {}", notification.getKey(), notification.getCause());
- switch (notification.getCause()) {
- case EXPIRED:
- notification.getValue().invalidateFutureByTimeout(notification.getKey());
- }
- }
- };
- }
-
- private static CacheBuilder<Long, MultiCollectorObject> initCacheBuilder(final int timeout) {
- return CacheBuilder.newBuilder()
- .expireAfterAccess(timeout, TimeUnit.SECONDS)
- .removalListener(getRemovalListener())
- .initialCapacity(200)
- .maximumSize(500)
- .concurrencyLevel(1);
- }
+ private final List<MultipartReply> replyCollection = new ArrayList<>();
+ private final RequestContext<List<MultipartReply>> requestContext;
+ private final DeviceReplyProcessor deviceReplyProcessor;
+ private MultipartType msgType;
- @Override
- public void registerMultipartRequestContext(final RequestContext<List<MultipartReply>> requestContext) {
- cache.put(requestContext.getXid().getValue(), new MultiCollectorObject(requestContext));
+ public MultiMsgCollectorImpl(final DeviceReplyProcessor deviceReplyProcessor, final RequestContext<List<MultipartReply>> requestContext) {
+ this.deviceReplyProcessor = Preconditions.checkNotNull(deviceReplyProcessor);
+ this.requestContext = Preconditions.checkNotNull(requestContext);
}
@Override
public void addMultipartMsg(final MultipartReply reply) {
Preconditions.checkNotNull(reply);
+ Preconditions.checkArgument(requestContext.getXid().getValue().equals(reply.getXid()));
LOG.trace("Try to add Multipart reply msg with XID {}", reply.getXid());
- final long xid = reply.getXid();
- final MultiCollectorObject cachedRef = cache.getIfPresent(xid);
- if (cachedRef == null) {
- MultipartType multipartType = reply.getType();
- LOG.trace("Orphaned multipart msg with XID : {} of type {}", xid, multipartType);
- deviceReplyProcessor.processException(new Xid(xid),
- new DeviceDataException("unknown xid received for multipart of type " + multipartType));
- return;
- }
- try {
- cachedRef.add(reply);
- LOG.trace("Multipart reply msg with XID {} added successfully.", reply.getXid());
- if (!reply.getFlags().isOFPMPFREQMORE()) {
- // flag OFPMFFREEQMORE false says "I'm a last one'
- cachedRef.publishCollection(xid); // settable future has now whole collection
- cache.invalidate(xid); // we don't need a reference anymore - remove explicitly
- }
- } catch (DeviceDataException e) {
- deviceReplyProcessor.processException(new Xid(xid), e);
+ if (msgType == null) {
+ msgType = reply.getType();
}
- }
- @Override
- public void setDeviceReplyProcessor(final DeviceReplyProcessor deviceReplyProcessor) {
- this.deviceReplyProcessor = deviceReplyProcessor;
- }
-
- @Override
- public void invalidateRequestContext(final RequestContext<List<MultipartReply>> requestContext) {
- MultiCollectorObject multiCollectorObject = cache.getIfPresent(requestContext);
- if (null != multiCollectorObject){
- multiCollectorObject.invalidateFutureByTimeout(requestContext.getXid().getValue());
+ if (!msgType.equals(reply.getType())) {
+ LOG.warn("MultiMsgCollector get incorrect multipart msg with type {} but expected type is {}", reply.getType(), msgType);
}
- }
-
- private class MultiCollectorObject {
- private final List<MultipartReply> replyCollection = new ArrayList<>();
- private final RequestContext<List<MultipartReply>> requestContext;
- private MultipartType msgType;
- MultiCollectorObject(final RequestContext<List<MultipartReply>> requestContext) {
- this.requestContext = Preconditions.checkNotNull(requestContext);
+ replyCollection.add(reply);
+ if (!reply.getFlags().isOFPMPFREQMORE()) {
+ endCollecting();
}
+ }
- void add(final MultipartReply reply) throws DeviceDataException {
- /* Rise possible exception if it possible */
- msgTypeValidation(reply.getType(), reply.getXid());
- replyCollection.add(reply);
- }
-
- void publishCollection(final long xid) {
- final RpcResult<List<MultipartReply>> rpcResult = RpcResultBuilder
- .<List<MultipartReply>>success()
- .withResult(replyCollection)
- .build();
- requestContext.setResult(rpcResult);
- try {
- requestContext.close();
- } catch (final Exception e) {
- LOG.warn("Closing RequestContext failed: {}", e.getMessage());
- LOG.debug("Closing RequestContext failed.. ", e);
- }
- deviceReplyProcessor.processReply(new Xid(xid), replyCollection);
- }
-
- void invalidateFutureByTimeout(final long key) {
- final String msg = "MultiMsgCollector can not wait for last multipart any more";
- DeviceDataException deviceDataException = new DeviceDataException(msg);
- final RpcResult<List<MultipartReply>> rpcResult = RpcResultBuilder
- .<List<MultipartReply>>failed()
- .withError(RpcError.ErrorType.APPLICATION, String.format("Message processing failed : %s", deviceDataException.getError()), deviceDataException)
- .build();
- requestContext.setResult(rpcResult);
- try {
- requestContext.close();
- } catch (final Exception e) {
- LOG.warn("Closing RequestContext failed: ", e);
- LOG.debug("Closing RequestContext failed..", e);
- }
- deviceReplyProcessor.processException(new Xid(key), deviceDataException);
- }
-
-
- private void msgTypeValidation(final MultipartType type, final long key) throws DeviceDataException {
- if (msgType == null) {
- msgType = type;
- return;
- }
- if (!msgType.equals(type)) {
- final String msg = "MultiMsgCollector get incorrect multipart msg with type {}"
- + " but expected type is {}";
- LOG.trace(msg, type, msgType);
- throw new DeviceDataException("multipart message type mismatch");
- }
- }
+ public void endCollecting() {
+ final RpcResult<List<MultipartReply>> rpcResult = RpcResultBuilder.success(replyCollection).build();
+ requestContext.setResult(rpcResult);
+ requestContext.close();
+ deviceReplyProcessor.processReply(requestContext.getXid(), replyCollection);
}
}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowplugin.impl.karaf;
-
-/**
- * Created by Martin Bobak <mbobak@cisco.com> on 21.5.2015.
- */
-public class StatisticsCommandCompleter {
-}
import java.util.Map;
import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry;
import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor;
-import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowHash;
+import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey;
import org.opendaylight.openflowplugin.impl.util.FlowUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
import org.slf4j.Logger;
*/
public class DeviceFlowRegistryImpl implements DeviceFlowRegistry {
- private final Map<FlowHash, FlowDescriptor> flowRegistry = new HashMap<>();
- private final Collection<FlowHash> marks = new HashSet<>();
+ private final Map<FlowRegistryKey, FlowDescriptor> flowRegistry = new HashMap<>();
+ private final Collection<FlowRegistryKey> marks = new HashSet<>();
private static final Logger LOG = LoggerFactory.getLogger(DeviceFlowRegistryImpl.class);
@Override
- public FlowDescriptor retrieveIdForFlow(final FlowHash flowHash) {
- FlowDescriptor flowDescriptor = flowRegistry.get(flowHash);
+ public FlowDescriptor retrieveIdForFlow(final FlowRegistryKey flowRegistryKey) {
+ FlowDescriptor flowDescriptor = flowRegistry.get(flowRegistryKey);
return flowDescriptor;
}
@Override
- public void store(final FlowHash flowHash, final FlowDescriptor flowDescriptor) {
- LOG.trace("Storing flowDescriptor with table ID : {} and flow ID : {} for flow hash : {}", flowDescriptor.getTableKey().getId(), flowDescriptor.getFlowId().getValue(), flowHash.hashCode());
+ public void store(final FlowRegistryKey flowRegistryKey, final FlowDescriptor flowDescriptor) {
+ LOG.trace("Storing flowDescriptor with table ID : {} and flow ID : {} for flow hash : {}", flowDescriptor.getTableKey().getId(), flowDescriptor.getFlowId().getValue(), flowRegistryKey.hashCode());
synchronized (flowRegistry) {
- flowRegistry.put(flowHash, flowDescriptor);
+ flowRegistry.put(flowRegistryKey, flowDescriptor);
}
}
@Override
- public FlowId storeIfNecessary(final FlowHash flowHash, final short tableId) {
+ public FlowId storeIfNecessary(final FlowRegistryKey flowRegistryKey, final short tableId) {
+
+
FlowId alienFlowId = FlowUtil.createAlienFlowId(tableId);
FlowDescriptor alienFlowDescriptor = FlowDescriptorFactory.create(tableId, alienFlowId);
synchronized (flowRegistry) {
- FlowDescriptor flowDescriptorFromRegistry = flowRegistry.get(flowHash);
+ FlowDescriptor flowDescriptorFromRegistry = flowRegistry.get(flowRegistryKey);
if (flowDescriptorFromRegistry != null) {
return flowDescriptorFromRegistry.getFlowId();
} else {
- LOG.trace("Flow descriptor for flow hash {} wasn't found.", flowHash.hashCode());
- flowRegistry.put(flowHash, alienFlowDescriptor);
+ LOG.trace("Flow descriptor for flow hash {} wasn't found.", flowRegistryKey.hashCode());
+ flowRegistry.put(flowRegistryKey, alienFlowDescriptor);
return alienFlowId;
}
}
}
@Override
- public void markToBeremoved(final FlowHash flowHash) {
+ public void markToBeremoved(final FlowRegistryKey flowRegistryKey) {
synchronized (marks) {
- marks.add(flowHash);
+ marks.add(flowRegistryKey);
}
- LOG.trace("Flow hash {} was marked for removal.", flowHash.hashCode());
+ LOG.trace("Flow hash {} was marked for removal.", flowRegistryKey.hashCode());
}
@Override
public void removeMarked() {
synchronized (flowRegistry) {
- for (FlowHash flowHash : marks) {
- LOG.trace("Removing flowDescriptor for flow hash : {}", flowHash.hashCode());
- flowRegistry.remove(flowHash);
+ for (FlowRegistryKey flowRegistryKey : marks) {
+ LOG.trace("Removing flowDescriptor for flow hash : {}", flowRegistryKey.hashCode());
+ flowRegistry.remove(flowRegistryKey);
}
}
synchronized (marks) {
@Override
- public Map<FlowHash, FlowDescriptor> getAllFlowDescriptors() {
+ public Map<FlowRegistryKey, FlowDescriptor> getAllFlowDescriptors() {
return flowRegistry;
}
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
-import com.google.common.primitives.Longs;
import java.math.BigInteger;
-import java.util.Objects;
import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowHash;
-import org.opendaylight.openflowplugin.impl.util.HashUtil;
+import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
/**
* Created by Martin Bobak <mbobak@cisco.com> on 8.4.2015.
*/
-public class FlowHashFactory {
+public class FlowRegistryKeyFactory {
- public FlowHashFactory() {
+ public FlowRegistryKeyFactory() {
}
- public static FlowHash create(Flow flow, short version) {
- long hash = calculateHash(flow, version);
- return new FlowHashDto(hash, flow);
+ public static FlowRegistryKey create(Flow flow) {
+ return new FlowRegistryKeyDto(flow);
}
- private static long calculateHash(Flow flow, short version) {
- return HashUtil.calculateMatchHash(flow.getMatch(), version);
- }
-
-
- private static final class FlowHashDto implements FlowHash {
-
- private final long flowHash;
- private final int intHashCode;
+ private static final class FlowRegistryKeyDto implements FlowRegistryKey {
private final short tableId;
private final int priority;
private final BigInteger cookie;
+ private final Match match;
- public FlowHashDto(final long flowHash, final Flow flow) {
- this.flowHash = flowHash;
- this.intHashCode = Longs.hashCode(flowHash);
+ public FlowRegistryKeyDto(final Flow flow) {
tableId = Preconditions.checkNotNull(flow.getTableId(), "flow tableId must not be null");
priority = Preconditions.checkNotNull(flow.getPriority(), "flow priority must not be null");
+ match = Preconditions.checkNotNull(flow.getMatch(), "Match value must not be null");
cookie = MoreObjects.firstNonNull(flow.getCookie(), OFConstants.DEFAULT_FLOW_COOKIE).getValue();
}
-
@Override
- public int hashCode() {
- return intHashCode;
- }
+ public boolean equals(final Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
- @Override
- public boolean equals(final Object obj) {
- if (null == obj) {
- return false;
- }
- if (!(obj instanceof FlowHash)) {
- return false;
- }
- FlowHash that = (FlowHash) obj;
- if (this.flowHash == that.getFlowHash()
- && this.tableId == that.getTableId()
- && this.priority == that.getPriority()
- && Objects.equals(this.cookie, that.getCookie())) {
- return true;
- }
- return false;
+ final FlowRegistryKeyDto that = (FlowRegistryKeyDto) o;
+
+ if (priority != that.priority) return false;
+ if (tableId != that.tableId) return false;
+ if (!match.equals(that.match)) return false;
+
+ return true;
}
@Override
- public long getFlowHash() {
- return flowHash;
+ public int hashCode() {
+ int result = (int) tableId;
+ result = 31 * result + priority;
+ result = 31 * result + match.hashCode();
+ return result;
}
@Override
private final RpcProviderRegistry rpcProviderRegistry;
private DeviceInitializationPhaseHandler deviceInitPhaseHandler;
- private final Long maxRequestsQuota;
+ private final int maxRequestsQuota;
public RpcManagerImpl(final RpcProviderRegistry rpcProviderRegistry,
- final Long quotaValue) {
+ final int quotaValue) {
this.rpcProviderRegistry = rpcProviderRegistry;
maxRequestsQuota = quotaValue;
}
@Override
public void onDeviceContextLevelUp(final DeviceContext deviceContext) {
- final RpcContext rpcContext = new RpcContextImpl(deviceContext.getMessageSpy(), rpcProviderRegistry, deviceContext, maxRequestsQuota.intValue());
+ final RpcContext rpcContext = new RpcContextImpl(deviceContext.getMessageSpy(), rpcProviderRegistry, deviceContext, maxRequestsQuota);
deviceContext.setDeviceDisconnectedHandler(rpcContext);
MdSalRegistratorUtils.registerServices(rpcContext, deviceContext);
// finish device initialization cycle back to DeviceManager
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.services;
+
+import com.google.common.util.concurrent.FutureCallback;
+import java.util.List;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+
+public abstract class AbstractMultipartService<I> extends AbstractService<I, List<MultipartReply>> {
+ protected AbstractMultipartService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ super(requestContextStack, deviceContext);
+ }
+
+ @Override
+ protected final FutureCallback<OfHeader> createCallback(final RequestContext<List<MultipartReply>> context, final Class<?> requestType) {
+ return new MultipartRequestCallback(context, requestType, getDeviceContext());
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.services;
+
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.FutureCallback;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
+import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
+import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy.STATISTIC_GROUP;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yangtools.yang.common.RpcError;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+
+abstract class AbstractRequestCallback<T> implements FutureCallback<OfHeader> {
+ private final RequestContext<T> context;
+ private final Class<?> requestType;
+ private final MessageSpy spy;
+
+ protected AbstractRequestCallback(final RequestContext<T> context, final Class<?> requestType, final MessageSpy spy) {
+ this.context = Preconditions.checkNotNull(context);
+ this.requestType = Preconditions.checkNotNull(requestType);
+ this.spy = Preconditions.checkNotNull(spy);
+ }
+
+ protected final void setResult(@Nullable final RpcResult<T> result) {
+ context.setResult(result);
+ context.close();
+ }
+
+ protected final void spyMessage(@Nonnull final STATISTIC_GROUP group) {
+ spy.spyMessage(requestType, Preconditions.checkNotNull(group));
+ }
+
+ @Override
+ public final void onFailure(final Throwable t) {
+ final RpcResultBuilder<T> builder;
+ if (t instanceof DeviceRequestFailedException) {
+ final Error err = ((DeviceRequestFailedException) t).getError();
+ final String errorString = String.format("Device reported error type %s code %s", err.getTypeString(), err.getCodeString());
+
+ builder = RpcResultBuilder.<T>failed().withError(RpcError.ErrorType.APPLICATION, errorString, t);
+ spyMessage(MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
+ } else {
+ builder = RpcResultBuilder.<T>failed().withError(RpcError.ErrorType.APPLICATION, t.getMessage(), t);
+ spyMessage(MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_ERROR);
+ }
+
+ context.setResult(builder.build());
+ RequestContextUtil.closeRequstContext(context);
+ }
+}
*/
package org.opendaylight.openflowplugin.impl.services;
-import com.google.common.base.Function;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Verify;
+import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import java.math.BigInteger;
+import javax.annotation.Nonnull;
import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
+import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-public abstract class CommonService {
- private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(CommonService.class);
+abstract class AbstractService<I, O> {
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractService.class);
private static final long WAIT_TIME = 2000;
private static final BigInteger PRIMARY_CONNECTION = BigInteger.ZERO;
private final ConnectionAdapter primaryConnectionAdapter;
private final MessageSpy messageSpy;
-
- public CommonService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ public AbstractService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
this.requestContextStack = requestContextStack;
this.deviceContext = deviceContext;
final FeaturesReply features = this.deviceContext.getPrimaryConnectionContext().getFeatures();
this.messageSpy = deviceContext.getMessageSpy();
}
- public static BigInteger getPrimaryConnection() {
- return PRIMARY_CONNECTION;
- }
-
public short getVersion() {
return version;
}
return deviceContext;
}
- public ConnectionAdapter getPrimaryConnectionAdapter() {
- return primaryConnectionAdapter;
- }
-
public MessageSpy getMessageSpy() {
return messageSpy;
}
- protected long provideWaitTime() {
- return WAIT_TIME;
- }
-
+ protected abstract OfHeader buildRequest(Xid xid, I input);
+ protected abstract FutureCallback<OfHeader> createCallback(RequestContext<O> context, Class<?> requestType);
- protected ConnectionAdapter provideConnectionAdapter(final BigInteger connectionID) {
- if (connectionID == null) {
- return primaryConnectionAdapter;
- }
- if (connectionID.equals(PRIMARY_CONNECTION)) {
- return primaryConnectionAdapter;
- }
+ public final ListenableFuture<RpcResult<O>> handleServiceCall(@Nonnull final I input) {
+ Preconditions.checkNotNull(input);
- final ConnectionContext auxiliaryConnectionContext =
- deviceContext.getAuxiliaryConnectiobContexts(connectionID);
- if (auxiliaryConnectionContext != null) {
- return auxiliaryConnectionContext.getConnectionAdapter();
+ final Class<?> requestType;
+ if (input instanceof DataContainer) {
+ requestType = ((DataContainer) input).getImplementedInterface();
+ } else {
+ requestType = input.getClass();
}
-
- return primaryConnectionAdapter;
- }
-
- public final <T> ListenableFuture<RpcResult<T>> handleServiceCall(final Function<RequestContext<T>, ListenableFuture<RpcResult<T>>> function) {
+ getMessageSpy().spyMessage(requestType, MessageSpy.STATISTIC_GROUP.TO_SWITCH_ENTERED);
LOG.trace("Handling general service call");
- final RequestContext<T> requestContext = createRequestContext();
+ final RequestContext<O> requestContext = requestContextStack.createRequestContext();
if (requestContext == null) {
LOG.trace("Request context refused.");
- deviceContext.getMessageSpy().spyMessage(CommonService.class, MessageSpy.STATISTIC_GROUP.TO_SWITCH_DISREGARDED);
+ deviceContext.getMessageSpy().spyMessage(AbstractService.class, MessageSpy.STATISTIC_GROUP.TO_SWITCH_DISREGARDED);
return failedFuture();
}
}
messageSpy.spyMessage(requestContext.getClass(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_READY_FOR_SUBMIT);
- function.apply(requestContext);
-
- return requestContext.getFuture();
- }
+ final Xid xid = requestContext.getXid();
+ OfHeader request = null;
+ try {
+ request = buildRequest(xid, input);
+ Verify.verify(xid.getValue().equals(request.getXid()), "Expected XID %s got %s", xid.getValue(), request.getXid());
+ } catch (Exception e) {
+ LOG.error("Failed to build request for {}, forfeiting request {}", input, xid.getValue(), e);
+ // FIXME: complete the requestContext
+ } finally {
+ final OutboundQueue outboundQueue = getDeviceContext().getPrimaryConnectionContext().getOutboundQueueProvider();
+ outboundQueue.commitEntry(xid.getValue(), request, createCallback(requestContext, requestType));
+ }
- protected final <T> RequestContext<T> createRequestContext() {
- return requestContextStack.createRequestContext();
+ return requestContext.getFuture();
}
protected static <T> ListenableFuture<RpcResult<T>> failedFuture() {
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.services;
+
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.FutureCallback;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+
+public abstract class AbstractSimpleService<I, O extends DataObject> extends AbstractService<I, O> {
+ private final Class<O> clazz;
+
+ protected AbstractSimpleService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final Class<O> clazz) {
+ super(requestContextStack, deviceContext);
+ this.clazz = Preconditions.checkNotNull(clazz);
+ }
+
+ @Override
+ protected final FutureCallback<OfHeader> createCallback(final RequestContext<O> context, final Class<?> requestType) {
+ return SimpleRequestCallback.create(context, requestType, getMessageSpy(), clazz);
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.services;
+
+import com.google.common.util.concurrent.FutureCallback;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+
+public abstract class AbstractVoidService<T extends DataObject> extends AbstractService<T, Void> {
+ protected AbstractVoidService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ super(requestContextStack, deviceContext);
+ }
+
+ @Override
+ protected final FutureCallback<OfHeader> createCallback(final RequestContext<Void> context, final Class<?> requestType) {
+ return new VoidRequestCallback(context, requestType, getMessageSpy());
+ }
+}
*/
package org.opendaylight.openflowplugin.impl.services;
-import com.google.common.util.concurrent.FutureCallback;
import java.util.concurrent.Future;
-import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.FlowCapableTransactionService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
-import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class FlowCapableTransactionServiceImpl extends CommonService implements FlowCapableTransactionService {
-
- private static final Logger LOG = LoggerFactory.getLogger(FlowCapableTransactionServiceImpl.class);
+public class FlowCapableTransactionServiceImpl extends AbstractVoidService<SendBarrierInput> implements FlowCapableTransactionService {
public FlowCapableTransactionServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
super(requestContextStack, deviceContext);
}
@Override
public Future<RpcResult<Void>> sendBarrier(final SendBarrierInput input) {
- final RequestContext<Void> requestContext = getRequestContextStack().createRequestContext();
- if (requestContext == null) {
- getMessageSpy().spyMessage(null, MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
- return failedFuture();
- }
-
+ return handleServiceCall(input);
+ }
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final SendBarrierInput input) {
final BarrierInputBuilder barrierInputOFJavaBuilder = new BarrierInputBuilder();
- final Xid xid = requestContext.getXid();
barrierInputOFJavaBuilder.setVersion(getVersion());
barrierInputOFJavaBuilder.setXid(xid.getValue());
-
- LOG.trace("Hooking xid {} to device context - precaution.", requestContext.getXid().getValue());
-
- final OutboundQueue outboundQueue = getDeviceContext().getPrimaryConnectionContext().getOutboundQueueProvider();
- final BarrierInput barrierInput = barrierInputOFJavaBuilder.build();
- outboundQueue.commitEntry(xid.getValue(), barrierInput, new FutureCallback<OfHeader>() {
-
- RpcResultBuilder<Void> rpcResultBuilder;
- @Override
- public void onSuccess(final OfHeader ofHeader) {
- rpcResultBuilder = RpcResultBuilder.<Void>success();
- requestContext.setResult(rpcResultBuilder.build());
- RequestContextUtil.closeRequstContext(requestContext);
-
- getMessageSpy().spyMessage(barrierInput.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
-
- }
-
- @Override
- public void onFailure(final Throwable throwable) {
- rpcResultBuilder = RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, throwable.getMessage(), throwable);
- requestContext.setResult(rpcResultBuilder.build());
- RequestContextUtil.closeRequstContext(requestContext);
-
- getMessageSpy().spyMessage(barrierInput.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
- }
- });
- return requestContext.getFuture();
+ return barrierInputOFJavaBuilder.build();
}
}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.services;
+
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.FlowConvertor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+
+final class FlowRemoveService extends AbstractSimpleService<RemoveFlowInput, RemoveFlowOutput> {
+ FlowRemoveService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ super(requestContextStack, deviceContext, RemoveFlowOutput.class);
+ }
+
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final RemoveFlowInput input) {
+ final FlowModInputBuilder ofFlowModInput = FlowConvertor.toFlowModInput(input, getVersion(),
+ getDatapathId());
+ ofFlowModInput.setXid(xid.getValue());
+ return ofFlowModInput.build();
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.services;
+
+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.SettableFuture;
+import java.util.ArrayList;
+import java.util.List;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.FlowConvertor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+
+final class FlowService<O extends DataObject> extends AbstractSimpleService<FlowModInputBuilder, O> {
+
+ protected FlowService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final Class<O> clazz) {
+ super(requestContextStack, deviceContext, clazz);
+ }
+
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final FlowModInputBuilder input) {
+ input.setXid(xid.getValue());
+ return input.build();
+ }
+
+ List<FlowModInputBuilder> toFlowModInputs(final Flow input) {
+ return FlowConvertor.toFlowModInputs(input, getVersion(), getDatapathId());
+ }
+
+ ListenableFuture<RpcResult<O>> processFlowModInputBuilders(final List<FlowModInputBuilder> ofFlowModInputs) {
+ final List<ListenableFuture<RpcResult<O>>> partialFutures = new ArrayList<>(ofFlowModInputs.size());
+
+ for (final FlowModInputBuilder flowModInputBuilder : ofFlowModInputs) {
+ partialFutures.add(handleServiceCall(flowModInputBuilder));
+ }
+
+ final ListenableFuture<List<RpcResult<O>>> allFutures = Futures.successfulAsList(partialFutures);
+ final SettableFuture<RpcResult<O>> finalFuture = SettableFuture.create();
+ Futures.addCallback(allFutures, new FutureCallback<List<RpcResult<O>>>() {
+ @Override
+ public void onSuccess(final List<RpcResult<O>> results) {
+ RpcResultBuilder<O> rpcResultBuilder = RpcResultBuilder.success();
+ finalFuture.set(rpcResultBuilder.build());
+ }
+
+ @Override
+ public void onFailure(final Throwable t) {
+ RpcResultBuilder<O> rpcResultBuilder = RpcResultBuilder.failed();
+ finalFuture.set(rpcResultBuilder.build());
+ }
+ });
+
+ return finalFuture;
+ }
+
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.services;
+
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.GroupConvertor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+
+final class GroupService<I extends Group, O extends DataObject> extends AbstractSimpleService<I, O> {
+ GroupService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final Class<O> clazz) {
+ super(requestContextStack, deviceContext, clazz);
+ }
+
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final I input) {
+ final GroupModInputBuilder ofGroupModInput = GroupConvertor.toGroupModInput(input, getVersion(), getDatapathId());
+ ofGroupModInput.setXid(xid.getValue());
+
+ return ofGroupModInput.build();
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.services;
+
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.MeterConvertor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+
+final class MeterService<I extends Meter, O extends DataObject> extends AbstractSimpleService<I, O> {
+
+ MeterService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, final Class<O> clazz) {
+ super(requestContextStack, deviceContext, clazz);
+ }
+
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final I input) {
+ final MeterModInputBuilder ofMeterModInput = MeterConvertor.toMeterModInput(input, getVersion());
+ ofMeterModInput.setXid(xid.getValue());
+ return ofMeterModInput.build();
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.services;
+
+import java.util.List;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
+import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yangtools.yang.common.RpcError;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+final class MultipartRequestCallback extends AbstractRequestCallback<List<MultipartReply>> {
+ private static final Logger LOG = LoggerFactory.getLogger(MultipartRequestCallback.class);
+ private final MultiMsgCollector collector;
+
+ public MultipartRequestCallback(final RequestContext<List<MultipartReply>> context, final Class<?> requestType, final DeviceContext deviceContext) {
+ super(context, requestType, deviceContext.getMessageSpy());
+ collector = deviceContext.getMultiMsgCollector(context);
+ }
+
+ @Override
+ public void onSuccess(final OfHeader result) {
+ if (result == null) {
+ LOG.info("Ofheader was null.");
+ collector.endCollecting();
+ return;
+ }
+
+ if (!(result instanceof MultipartReply)) {
+ LOG.info("Unexpected response type received {}.", result.getClass());
+ final RpcResultBuilder<List<MultipartReply>> rpcResultBuilder =
+ RpcResultBuilder.<List<MultipartReply>>failed().withError(RpcError.ErrorType.APPLICATION,
+ String.format("Unexpected response type received %s.", result.getClass()));
+ setResult(rpcResultBuilder.build());
+ } else {
+ collector.addMultipartMsg((MultipartReply) result);
+ }
+ }
+
+}
*/
package org.opendaylight.openflowplugin.impl.services;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.SettableFuture;
import java.util.concurrent.Future;
-import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.NodeConfigService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.SetConfigInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.SetConfigOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInputBuilder;
-import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-
-public class NodeConfigServiceImpl extends CommonService implements NodeConfigService {
-
+public final class NodeConfigServiceImpl extends AbstractSimpleService<SetConfigInput, SetConfigOutput> implements NodeConfigService {
public NodeConfigServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- super(requestContextStack, deviceContext);
+ super(requestContextStack, deviceContext, SetConfigOutput.class);
}
@Override
public Future<RpcResult<SetConfigOutput>> setConfig(final SetConfigInput input) {
- final RequestContext<SetConfigOutput> requestContext = createRequestContext();
- if (requestContext == null) {
- return failedFuture();
- }
+ return handleServiceCall(input);
+ }
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final SetConfigInput input) {
SetConfigInputBuilder builder = new SetConfigInputBuilder();
SwitchConfigFlag flag = SwitchConfigFlag.valueOf(input.getFlag());
- final Xid xid = requestContext.getXid();
builder.setXid(xid.getValue());
builder.setFlags(flag);
builder.setMissSendLen(input.getMissSearchLength());
builder.setVersion(getVersion());
- final OutboundQueue outboundQueue = getDeviceContext().getPrimaryConnectionContext().getOutboundQueueProvider();
-
- final SettableFuture<RpcResult<SetConfigOutput>> settableFuture = SettableFuture.create();
- final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput setConfigInput = builder.build();
- outboundQueue.commitEntry(xid.getValue(), setConfigInput, new FutureCallback<OfHeader>() {
-
- RpcResultBuilder<SetConfigOutput> rpcResultBuilder;
- @Override
- public void onSuccess(final OfHeader ofHeader) {
- rpcResultBuilder = RpcResultBuilder.<SetConfigOutput>success();
- requestContext.setResult(rpcResultBuilder.build());
- RequestContextUtil.closeRequstContext(requestContext);
-
- getMessageSpy().spyMessage(setConfigInput.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
- }
-
- @Override
- public void onFailure(final Throwable throwable) {
- rpcResultBuilder = RpcResultBuilder.<SetConfigOutput>failed().withError(RpcError.ErrorType.APPLICATION, throwable.getMessage(), throwable);
- requestContext.setResult(rpcResultBuilder.build());
- RequestContextUtil.closeRequstContext(requestContext);
-
- getMessageSpy().spyMessage(setConfigInput.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
- }
- });
- return requestContext.getFuture();
-
+ return builder.build();
}
}
*/
package org.opendaylight.openflowplugin.impl.services;
-import com.google.common.base.Function;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.ListenableFuture;
import java.util.concurrent.Future;
-import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PacketOutConvertor;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput;
-import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-public class PacketProcessingServiceImpl extends CommonService implements PacketProcessingService {
+public final class PacketProcessingServiceImpl extends AbstractVoidService<TransmitPacketInput> implements PacketProcessingService {
public PacketProcessingServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
super(requestContextStack, deviceContext);
@Override
public Future<RpcResult<Void>> transmitPacket(final TransmitPacketInput input) {
- getMessageSpy().spyMessage(input.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_ENTERED);
-
- return handleServiceCall(new Function<RequestContext<Void>, ListenableFuture<RpcResult<Void>>>() {
- @Override
- public ListenableFuture<RpcResult<Void>> apply(final RequestContext<Void> requestContext) {
- final Xid xid = requestContext.getXid();
- final PacketOutInput message = PacketOutConvertor.toPacketOutInput(input, getVersion(), xid.getValue(),
- getDatapathId());
-
- final OutboundQueue outboundQueue = getDeviceContext().getPrimaryConnectionContext().getOutboundQueueProvider();
-
- outboundQueue.commitEntry(xid.getValue(), message, new FutureCallback<OfHeader>() {
-
- RpcResultBuilder<Void> rpcResultBuilder;
- @Override
- public void onSuccess(final OfHeader ofHeader) {
- getMessageSpy().spyMessage(message.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
- final RpcResultBuilder<Void> rpcResultBuilder = RpcResultBuilder.<Void>success();
- requestContext.setResult(rpcResultBuilder.build());
- RequestContextUtil.closeRequstContext(requestContext);
- }
-
- @Override
- public void onFailure(final Throwable throwable) {
- getMessageSpy().spyMessage(message.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
- final RpcResultBuilder<Void> rpcResultBuilder = RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, throwable.getMessage(), throwable);
- requestContext.setResult(rpcResultBuilder.build());
- RequestContextUtil.closeRequstContext(requestContext);
- }
- });
- return requestContext.getFuture();
- }
- });
+ return handleServiceCall(input);
+ }
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final TransmitPacketInput input) {
+ return PacketOutConvertor.toPacketOutInput(input, getVersion(), xid.getValue(), getDatapathId());
}
}
*/
package org.opendaylight.openflowplugin.impl.services;
-import com.google.common.util.concurrent.FutureCallback;
import java.util.concurrent.Future;
-import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
import org.opendaylight.yang.gen.v1.urn.opendaylight.echo.service.rev150305.SalEchoService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.echo.service.rev150305.SendEchoInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.echo.service.rev150305.SendEchoOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
-import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SalEchoServiceImpl extends CommonService implements SalEchoService {
-
- private static final Logger LOG = LoggerFactory.getLogger(SalEchoServiceImpl.class);
+public final class SalEchoServiceImpl extends AbstractSimpleService<SendEchoInput, SendEchoOutput> implements SalEchoService {
public SalEchoServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- super(requestContextStack, deviceContext);
+ super(requestContextStack, deviceContext, SendEchoOutput.class);
}
@Override
public Future<RpcResult<SendEchoOutput>> sendEcho(final SendEchoInput sendEchoInput) {
- final RequestContext<SendEchoOutput> requestContext = getRequestContextStack().createRequestContext();
- if (requestContext == null) {
- getMessageSpy().spyMessage(null, MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
- return failedFuture();
- }
-
-
+ return handleServiceCall(sendEchoInput);
+ }
- LOG.trace("Hooking xid {} to device context - precaution.", requestContext.getXid().getValue());
- final Xid xid = requestContext.getXid();
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final SendEchoInput input) {
final EchoInputBuilder echoInputOFJavaBuilder = new EchoInputBuilder();
echoInputOFJavaBuilder.setVersion(getVersion());
- echoInputOFJavaBuilder.setXid(requestContext.getXid().getValue());
- echoInputOFJavaBuilder.setData(sendEchoInput.getData());
- final EchoInput echoInputOFJava = echoInputOFJavaBuilder.build();
-
- LOG.debug("Echo with xid {} was sent from controller", xid);
-
- final OutboundQueue outboundQueue = getDeviceContext().getPrimaryConnectionContext().getOutboundQueueProvider();
- outboundQueue.commitEntry(xid.getValue(), echoInputOFJava, new FutureCallback<OfHeader>() {
-
- RpcResultBuilder<SendEchoOutput> rpcResultBuilder;
- @Override
- public void onSuccess(final OfHeader ofHeader) {
- rpcResultBuilder = RpcResultBuilder.<SendEchoOutput>success();
- requestContext.setResult(rpcResultBuilder.build());
- RequestContextUtil.closeRequstContext(requestContext);
-
- getMessageSpy().spyMessage(echoInputOFJava.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
- }
-
- @Override
- public void onFailure(final Throwable throwable) {
- rpcResultBuilder = RpcResultBuilder.<SendEchoOutput>failed().withError(RpcError.ErrorType.APPLICATION, throwable.getMessage(), throwable);
- requestContext.setResult(rpcResultBuilder.build());
- RequestContextUtil.closeRequstContext(requestContext);
-
- getMessageSpy().spyMessage(echoInputOFJava.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
- }
- });
- return requestContext.getFuture();
+ echoInputOFJavaBuilder.setXid(xid.getValue());
+ echoInputOFJavaBuilder.setData(input.getData());
+ return echoInputOFJavaBuilder.build();
}
}
/**
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- * <p/>
+ *
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
package org.opendaylight.openflowplugin.impl.services;
-import com.google.common.base.Function;
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.SettableFuture;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
-import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry;
import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor;
-import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowHash;
-import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
+import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey;
import org.opendaylight.openflowplugin.impl.registry.flow.FlowDescriptorFactory;
-import org.opendaylight.openflowplugin.impl.registry.flow.FlowHashFactory;
+import org.opendaylight.openflowplugin.impl.registry.flow.FlowRegistryKeyFactory;
import org.opendaylight.openflowplugin.impl.util.FlowUtil;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.FlowConvertor;
import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
import org.opendaylight.yangtools.yang.common.RpcError;
-import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-public class SalFlowServiceImpl extends CommonService implements SalFlowService {
-
- private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(SalFlowServiceImpl.class);
+public class SalFlowServiceImpl implements SalFlowService {
+ private static final Logger LOG = LoggerFactory.getLogger(SalFlowServiceImpl.class);
+ private final FlowService<UpdateFlowOutput> flowUpdate;
+ private final FlowService<AddFlowOutput> flowAdd;
+ private final FlowRemoveService flowRemove;
public SalFlowServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- super(requestContextStack, deviceContext);
+ flowRemove = new FlowRemoveService(requestContextStack, deviceContext);
+ flowAdd = new FlowService<>(requestContextStack, deviceContext, AddFlowOutput.class);
+ flowUpdate = new FlowService<>(requestContextStack, deviceContext, UpdateFlowOutput.class);
}
@Override
public Future<RpcResult<AddFlowOutput>> addFlow(final AddFlowInput input) {
- getMessageSpy().spyMessage(input.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_ENTERED);
-
- final List<FlowModInputBuilder> ofFlowModInputs = FlowConvertor.toFlowModInputs(input, getVersion(), getDatapathId());
- final ListenableFuture<RpcResult<AddFlowOutput>> future = processFlowModInputBuilders(ofFlowModInputs);
+ final ListenableFuture<RpcResult<AddFlowOutput>> future = flowAdd.processFlowModInputBuilders(flowAdd.toFlowModInputs(input));
final FlowId flowId;
if (null != input.getFlowRef()) {
flowId = input.getFlowRef().getValue().firstKeyOf(Flow.class, FlowKey.class).getId();
flowId = FlowUtil.createAlienFlowId(input.getTableId());
}
- final DeviceContext deviceContext = getDeviceContext();
- final FlowHash flowHash = FlowHashFactory.create(input, deviceContext.getPrimaryConnectionContext().getFeatures().getVersion());
+ final DeviceContext deviceContext = flowAdd.getDeviceContext();
+ final FlowRegistryKey flowRegistryKey = FlowRegistryKeyFactory.create(input);
final FlowDescriptor flowDescriptor = FlowDescriptorFactory.create(input.getTableId(), flowId);
- deviceContext.getDeviceFlowRegistry().store(flowHash, flowDescriptor);
+ deviceContext.getDeviceFlowRegistry().store(flowRegistryKey, flowDescriptor);
Futures.addCallback(future, new FutureCallback<RpcResult<AddFlowOutput>>() {
-
-
@Override
public void onSuccess(final RpcResult<AddFlowOutput> rpcResult) {
if (rpcResult.isSuccessful()) {
@Override
public void onFailure(final Throwable throwable) {
- deviceContext.getDeviceFlowRegistry().markToBeremoved(flowHash);
+ deviceContext.getDeviceFlowRegistry().markToBeremoved(flowRegistryKey);
LOG.trace("Service call for adding flows failed, id={}.", flowId.getValue(), throwable);
}
});
@Override
public Future<RpcResult<RemoveFlowOutput>> removeFlow(final RemoveFlowInput input) {
LOG.trace("Calling remove flow for flow with ID ={}.", input.getFlowRef());
- return handleServiceCall(new Function<RequestContext<RemoveFlowOutput>, ListenableFuture<RpcResult<RemoveFlowOutput>>>() {
- @Override
- public ListenableFuture<RpcResult<RemoveFlowOutput>> apply(final RequestContext<RemoveFlowOutput> requestContext) {
- final FlowModInputBuilder ofFlowModInput = FlowConvertor.toFlowModInput(input, getVersion(),
- getDatapathId());
- final ListenableFuture<RpcResult<RemoveFlowOutput>> future = createResultForFlowMod(requestContext, ofFlowModInput);
- Futures.addCallback(future, new FutureCallback<RpcResult<RemoveFlowOutput>>() {
- @Override
- public void onSuccess(final RpcResult<RemoveFlowOutput> o) {
- final DeviceContext deviceContext = getDeviceContext();
- getMessageSpy().spyMessage(input.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
- FlowHash flowHash = FlowHashFactory.create(input, deviceContext.getPrimaryConnectionContext().getFeatures().getVersion());
- deviceContext.getDeviceFlowRegistry().markToBeremoved(flowHash);
- }
- @Override
- public void onFailure(final Throwable throwable) {
- getMessageSpy().spyMessage(input.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
- LOG.trace("Flow modification failed..", throwable);
+ final ListenableFuture<RpcResult<RemoveFlowOutput>> future = flowRemove.handleServiceCall(input);
+ Futures.addCallback(future, new FutureCallback<RpcResult<RemoveFlowOutput>>() {
+ @Override
+ public void onSuccess(final RpcResult<RemoveFlowOutput> result) {
+ if (result.isSuccessful()) {
+ FlowRegistryKey flowRegistryKey = FlowRegistryKeyFactory.create(input);
+ flowRemove.getDeviceContext().getDeviceFlowRegistry().markToBeremoved(flowRegistryKey);
+ } else {
+ if (LOG.isTraceEnabled()) {
StringBuilder errors = new StringBuilder();
- try {
- RpcResult<RemoveFlowOutput> result = future.get();
- Collection<RpcError> rpcErrors = result.getErrors();
- if (null != rpcErrors && rpcErrors.size() > 0) {
- for (RpcError rpcError : rpcErrors) {
- errors.append(rpcError.getMessage());
- }
+ Collection<RpcError> rpcErrors = result.getErrors();
+ if (null != rpcErrors && rpcErrors.size() > 0) {
+ for (RpcError rpcError : rpcErrors) {
+ errors.append(rpcError.getMessage());
}
- } catch (InterruptedException | ExecutionException e) {
- LOG.trace("Flow modification failed. Can't read errors from RpcResult.");
- } finally {
- LOG.trace("Flow modification failed. Errors : {}", errors.toString());
}
+ LOG.trace("Flow modification failed. Errors : {}", errors.toString());
}
- });
- return future;
+ }
+ }
+
+ @Override
+ public void onFailure(final Throwable throwable) {
+ LOG.trace("Flow modification failed..", throwable);
}
});
+
+ return future;
}
@Override
final OriginalFlow original = in.getOriginalFlow();
final List<FlowModInputBuilder> allFlowMods = new ArrayList<>();
- List<FlowModInputBuilder> ofFlowModInputs;
+ final List<FlowModInputBuilder> ofFlowModInputs;
- if (!FlowCreatorUtil.canModifyFlow(original, updated, getVersion())) {
+ if (!FlowCreatorUtil.canModifyFlow(original, updated, flowUpdate.getVersion())) {
// We would need to remove original and add updated.
// remove flow
final RemoveFlowInputBuilder removeflow = new RemoveFlowInputBuilder(original);
- final List<FlowModInputBuilder> ofFlowRemoveInput = FlowConvertor.toFlowModInputs(removeflow.build(),
- getVersion(), getDatapathId());
+ final List<FlowModInputBuilder> ofFlowRemoveInput = flowUpdate.toFlowModInputs(removeflow.build());
// remove flow should be the first
allFlowMods.addAll(ofFlowRemoveInput);
final AddFlowInputBuilder addFlowInputBuilder = new AddFlowInputBuilder(updated);
- ofFlowModInputs = FlowConvertor.toFlowModInputs(addFlowInputBuilder.build(), getVersion(), getDatapathId());
+ ofFlowModInputs = flowUpdate.toFlowModInputs(addFlowInputBuilder.build());
} else {
- ofFlowModInputs = FlowConvertor.toFlowModInputs(updated, getVersion(), getDatapathId());
+ ofFlowModInputs = flowUpdate.toFlowModInputs(updated);
}
allFlowMods.addAll(ofFlowModInputs);
- ListenableFuture<RpcResult<UpdateFlowOutput>> future = processFlowModInputBuilders(allFlowMods);
+ ListenableFuture<RpcResult<UpdateFlowOutput>> future = flowUpdate.processFlowModInputBuilders(allFlowMods);
Futures.addCallback(future, new FutureCallback<RpcResult<UpdateFlowOutput>>() {
@Override
public void onSuccess(final RpcResult<UpdateFlowOutput> o) {
- final DeviceContext deviceContext = getDeviceContext();
- getMessageSpy().spyMessage(input.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
- final short version = deviceContext.getPrimaryConnectionContext().getFeatures().getVersion();
- FlowHash flowHash = FlowHashFactory.create(original, version);
+ FlowRegistryKey flowRegistryKey = FlowRegistryKeyFactory.create(original);
- FlowHash updatedflowHash = FlowHashFactory.create(updated, version);
+ FlowRegistryKey updatedflowRegistryKey = FlowRegistryKeyFactory.create(updated);
FlowId flowId = input.getFlowRef().getValue().firstKeyOf(Flow.class, FlowKey.class).getId();
FlowDescriptor flowDescriptor = FlowDescriptorFactory.create(updated.getTableId(), flowId);
- final DeviceFlowRegistry deviceFlowRegistry = deviceContext.getDeviceFlowRegistry();
- deviceFlowRegistry.markToBeremoved(flowHash);
- deviceFlowRegistry.store(updatedflowHash, flowDescriptor);
+ final DeviceFlowRegistry deviceFlowRegistry = flowUpdate.getDeviceContext().getDeviceFlowRegistry();
+ deviceFlowRegistry.markToBeremoved(flowRegistryKey);
+ deviceFlowRegistry.store(updatedflowRegistryKey, flowDescriptor);
}
@Override
public void onFailure(final Throwable throwable) {
- getMessageSpy().spyMessage(input.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
+ LOG.debug("Flow update failed", throwable);
}
});
return future;
}
-
- private <T> ListenableFuture<RpcResult<T>> processFlowModInputBuilders(final List<FlowModInputBuilder> ofFlowModInputs) {
-
- final List<ListenableFuture<RpcResult<T>>> partialFutures = new ArrayList<>();
-
- for (final FlowModInputBuilder flowModInputBuilder : ofFlowModInputs) {
- ListenableFuture<RpcResult<T>> partialFuture = handleServiceCall(
- new Function<RequestContext<T>, ListenableFuture<RpcResult<T>>>() {
- @Override
- public ListenableFuture<RpcResult<T>> apply(final RequestContext<T> requestContext) {
- return createResultForFlowMod(requestContext, flowModInputBuilder);
- }
- });
- partialFutures.add(partialFuture);
- }
-
- final ListenableFuture<List<RpcResult<T>>> allFutures = Futures.successfulAsList(partialFutures);
- final SettableFuture<RpcResult<T>> finalFuture = SettableFuture.create();
- Futures.addCallback(allFutures, new FutureCallback<List<RpcResult<T>>>() {
- @Override
- public void onSuccess(final List<RpcResult<T>> results) {
- RpcResultBuilder<T> rpcResultBuilder = RpcResultBuilder.success();
- finalFuture.set(rpcResultBuilder.build());
- }
-
- @Override
- public void onFailure(final Throwable t) {
- RpcResultBuilder<T> rpcResultBuilder = RpcResultBuilder.failed();
- finalFuture.set(rpcResultBuilder.build());
- }
- });
-
- return finalFuture;
- }
-
- protected <T> ListenableFuture<RpcResult<T>> createResultForFlowMod(final RequestContext<T> requestContext, final FlowModInputBuilder flowModInputBuilder) {
- final OutboundQueue outboundQueue = getDeviceContext().getPrimaryConnectionContext().getOutboundQueueProvider();
- final long xid = requestContext.getXid().getValue();
- flowModInputBuilder.setXid(xid);
- final FlowModInput flowModInput = flowModInputBuilder.build();
-
- outboundQueue.commitEntry(xid, flowModInput, new FutureCallback<OfHeader>() {
- @Override
- public void onSuccess(final OfHeader ofHeader) {
- getMessageSpy().spyMessage(FlowModInput.class, MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
-
- RpcResultBuilder<T> rpcResultBuilder = RpcResultBuilder.<T>success();
- requestContext.setResult(rpcResultBuilder.build());
-
- RequestContextUtil.closeRequstContext(requestContext);
- }
-
- @Override
- public void onFailure(final Throwable throwable) {
- getMessageSpy().spyMessage(FlowModInput.class, MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
- RpcResultBuilder<T> rpcResultBuilder = RpcResultBuilder.<T>failed().withError(ErrorType.APPLICATION, throwable.getMessage(), throwable);
- requestContext.setResult(rpcResultBuilder.build());
-
- RequestContextUtil.closeRequstContext(requestContext);
- }
- });
- return requestContext.getFuture();
- }
-
}
*/
package org.opendaylight.openflowplugin.impl.services;
-import com.google.common.base.Function;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.ListenableFuture;
import java.util.concurrent.Future;
-import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
-import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.GroupConvertor;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
-import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.slf4j.Logger;
-
-public class SalGroupServiceImpl extends CommonService implements SalGroupService {
+public class SalGroupServiceImpl implements SalGroupService {
+ private final GroupService<AddGroupInput, AddGroupOutput> addGroup;
+ private final GroupService<Group, UpdateGroupOutput> updateGroup;
+ private final GroupService<RemoveGroupInput, RemoveGroupOutput> removeGroup;
public SalGroupServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- super(requestContextStack, deviceContext);
+ addGroup = new GroupService<>(requestContextStack, deviceContext, AddGroupOutput.class);
+ updateGroup = new GroupService<>(requestContextStack, deviceContext, UpdateGroupOutput.class);
+ removeGroup = new GroupService<>(requestContextStack, deviceContext, RemoveGroupOutput.class);
}
- private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(SalGroupServiceImpl.class);
-
@Override
public Future<RpcResult<AddGroupOutput>> addGroup(final AddGroupInput input) {
- getDeviceContext().getDeviceGroupRegistry().store(input.getGroupId());
- return handleServiceCall(new Function<RequestContext<AddGroupOutput>,
- ListenableFuture<RpcResult<AddGroupOutput>>>() {
- @Override
- public ListenableFuture<RpcResult<AddGroupOutput>> apply(final RequestContext<AddGroupOutput> requestContext) {
- return convertAndSend(input, requestContext);
- }
- });
+ addGroup.getDeviceContext().getDeviceGroupRegistry().store(input.getGroupId());
+ return addGroup.handleServiceCall(input);
}
@Override
public Future<RpcResult<UpdateGroupOutput>> updateGroup(final UpdateGroupInput input) {
- return handleServiceCall(new Function<RequestContext<UpdateGroupOutput>,
- ListenableFuture<RpcResult<UpdateGroupOutput>>>() {
-
- @Override
- public ListenableFuture<RpcResult<UpdateGroupOutput>> apply(final RequestContext<UpdateGroupOutput> requestContext) {
- return convertAndSend(input.getUpdatedGroup(), requestContext);
- }
- });
+ return updateGroup.handleServiceCall(input.getUpdatedGroup());
}
@Override
public Future<RpcResult<RemoveGroupOutput>> removeGroup(final RemoveGroupInput input) {
- getDeviceContext().getDeviceGroupRegistry().markToBeremoved(input.getGroupId());
- return handleServiceCall(new Function<RequestContext<RemoveGroupOutput>,
- ListenableFuture<RpcResult<RemoveGroupOutput>>>() {
-
- @Override
- public ListenableFuture<RpcResult<RemoveGroupOutput>> apply(final RequestContext<RemoveGroupOutput> requestContext) {
- return convertAndSend(input, requestContext);
- }
- });
- }
-
- <T> ListenableFuture<RpcResult<T>> convertAndSend(final Group iputGroup, final RequestContext<T> requestContext) {
- final OutboundQueue outboundQueue = getDeviceContext().getPrimaryConnectionContext().getOutboundQueueProvider();
- getMessageSpy().spyMessage(iputGroup.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
- final GroupModInputBuilder ofGroupModInput = GroupConvertor.toGroupModInput(iputGroup, getVersion(), getDatapathId());
- final Xid xid = requestContext.getXid();
- ofGroupModInput.setXid(xid.getValue());
-
- final GroupModInput groupModInput = ofGroupModInput.build();
- outboundQueue.commitEntry(xid.getValue(), groupModInput, new FutureCallback<OfHeader>() {
-
- RpcResultBuilder<T> rpcResultBuilder;
- @Override
- public void onSuccess(final OfHeader ofHeader) {
- rpcResultBuilder = RpcResultBuilder.<T>success();
- requestContext.setResult(rpcResultBuilder.build());
- RequestContextUtil.closeRequstContext(requestContext);
-
- getMessageSpy().spyMessage(groupModInput.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
- }
-
- @Override
- public void onFailure(final Throwable throwable) {
- rpcResultBuilder = RpcResultBuilder.<T>failed().withError(RpcError.ErrorType.APPLICATION, throwable.getMessage(), throwable);
- requestContext.setResult(rpcResultBuilder.build());
- RequestContextUtil.closeRequstContext(requestContext);
-
- getMessageSpy().spyMessage(groupModInput.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
- }
- });
- return requestContext.getFuture();
+ removeGroup.getDeviceContext().getDeviceGroupRegistry().markToBeremoved(input.getGroupId());
+ return removeGroup.handleServiceCall(input);
}
}
*/
package org.opendaylight.openflowplugin.impl.services;
-import com.google.common.base.Function;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.SettableFuture;
import java.util.concurrent.Future;
-import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
-import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.MeterConvertor;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
-import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.slf4j.Logger;
-public class SalMeterServiceImpl extends CommonService implements SalMeterService {
-
- private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(SalMeterServiceImpl.class);
+public class SalMeterServiceImpl implements SalMeterService {
+ private final MeterService<AddMeterInput, AddMeterOutput> addMeter;
+ private final MeterService<Meter, UpdateMeterOutput> updateMeter;
+ private final MeterService<RemoveMeterInput, RemoveMeterOutput> removeMeter;
public SalMeterServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- super(requestContextStack, deviceContext);
+ addMeter = new MeterService<>(requestContextStack, deviceContext, AddMeterOutput.class);
+ updateMeter = new MeterService<>(requestContextStack, deviceContext, UpdateMeterOutput.class);
+ removeMeter = new MeterService<>(requestContextStack, deviceContext, RemoveMeterOutput.class);
}
@Override
public Future<RpcResult<AddMeterOutput>> addMeter(final AddMeterInput input) {
- getDeviceContext().getDeviceMeterRegistry().store(input.getMeterId());
- return handleServiceCall(new Function<RequestContext<AddMeterOutput>,
- ListenableFuture<RpcResult<AddMeterOutput>>>() {
- @Override
- public ListenableFuture<RpcResult<AddMeterOutput>> apply(final RequestContext<AddMeterOutput> requestContext) {
- return convertAndSend(input, requestContext);
- }
- });
+ addMeter.getDeviceContext().getDeviceMeterRegistry().store(input.getMeterId());
+
+ return addMeter.handleServiceCall(input);
}
@Override
public Future<RpcResult<UpdateMeterOutput>> updateMeter(final UpdateMeterInput input) {
- return handleServiceCall(new Function<RequestContext<UpdateMeterOutput>,
- ListenableFuture<RpcResult<UpdateMeterOutput>>>() {
- @Override
- public ListenableFuture<RpcResult<UpdateMeterOutput>> apply(final RequestContext<UpdateMeterOutput> requestContext) {
- return convertAndSend(input.getUpdatedMeter(), requestContext);
- }
- });
+ return updateMeter.handleServiceCall(input.getUpdatedMeter());
}
@Override
public Future<RpcResult<RemoveMeterOutput>> removeMeter(final RemoveMeterInput input) {
- getDeviceContext().getDeviceMeterRegistry().markToBeremoved(input.getMeterId());
- return handleServiceCall(new Function<RequestContext<RemoveMeterOutput>,
- ListenableFuture<RpcResult<RemoveMeterOutput>>>() {
- @Override
- public ListenableFuture<RpcResult<RemoveMeterOutput>> apply(final RequestContext<RemoveMeterOutput> requestContext) {
- return convertAndSend(input, requestContext);
- }
- });
- }
-
- <T> ListenableFuture<RpcResult<T>> convertAndSend(final Meter iputMeter, final RequestContext<T> requestContext) {
- getMessageSpy().spyMessage(iputMeter.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
- final OutboundQueue outboundQueue = getDeviceContext().getPrimaryConnectionContext().getOutboundQueueProvider();
-
- final MeterModInputBuilder ofMeterModInput = MeterConvertor.toMeterModInput(iputMeter, getVersion());
- final Xid xid = requestContext.getXid();
- ofMeterModInput.setXid(xid.getValue());
-
- final MeterModInput meterModInput = ofMeterModInput.build();
- outboundQueue.commitEntry(xid.getValue(), meterModInput, new FutureCallback<OfHeader>() {
-
- RpcResultBuilder<T> rpcResultBuilder;
- @Override
- public void onSuccess(final OfHeader ofHeader) {
- rpcResultBuilder = RpcResultBuilder.<T>success();
- requestContext.setResult(rpcResultBuilder.build());
- RequestContextUtil.closeRequstContext(requestContext);
-
- getMessageSpy().spyMessage(meterModInput.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
- }
-
- @Override
- public void onFailure(final Throwable throwable) {
- rpcResultBuilder = RpcResultBuilder.<T>failed().withError(RpcError.ErrorType.APPLICATION, throwable.getMessage(), throwable);
- requestContext.setResult(rpcResultBuilder.build());
- RequestContextUtil.closeRequstContext(requestContext);
-
- getMessageSpy().spyMessage(meterModInput.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
- }
- });
- return requestContext.getFuture();
+ removeMeter.getDeviceContext().getDeviceMeterRegistry().markToBeremoved(input.getMeterId());
+ return removeMeter.handleServiceCall(input);
}
}
*/
package org.opendaylight.openflowplugin.impl.services;
-import com.google.common.base.Function;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.ListenableFuture;
import java.util.concurrent.Future;
-import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PortConvertor;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.SalPortService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutput;
-import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.slf4j.Logger;
-
-public class SalPortServiceImpl extends CommonService implements SalPortService {
- private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(SalPortServiceImpl.class);
+public final class SalPortServiceImpl extends AbstractSimpleService<UpdatePortInput, UpdatePortOutput> implements SalPortService {
public SalPortServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- super(requestContextStack, deviceContext);
+ super(requestContextStack, deviceContext, UpdatePortOutput.class);
}
@Override
public Future<RpcResult<UpdatePortOutput>> updatePort(final UpdatePortInput input) {
- return handleServiceCall(new Function<RequestContext<UpdatePortOutput>, ListenableFuture<RpcResult<UpdatePortOutput>>>() {
- @Override
- public ListenableFuture<RpcResult<UpdatePortOutput>> apply(final RequestContext<UpdatePortOutput> requestContext) {
- getMessageSpy().spyMessage(input.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
-
- final Port inputPort = input.getUpdatedPort().getPort().getPort().get(0);
- final PortModInput ofPortModInput = PortConvertor.toPortModInput(inputPort, getVersion());
- final PortModInputBuilder mdInput = new PortModInputBuilder(ofPortModInput);
- final Xid xid = requestContext.getXid();
- final OutboundQueue outboundQueue = getDeviceContext().getPrimaryConnectionContext().getOutboundQueueProvider();
-
- mdInput.setXid(xid.getValue());
- final PortModInput portModInput = mdInput.build();
- outboundQueue.commitEntry(xid.getValue(), portModInput, new FutureCallback<OfHeader>() {
- RpcResultBuilder<UpdatePortOutput> rpcResultBuilder;
- @Override
- public void onSuccess(final OfHeader ofHeader) {
- rpcResultBuilder = RpcResultBuilder.<UpdatePortOutput>success();
- requestContext.setResult(rpcResultBuilder.build());
- RequestContextUtil.closeRequstContext(requestContext);
-
- getMessageSpy().spyMessage(portModInput.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
- }
+ return handleServiceCall(input);
+ }
- @Override
- public void onFailure(final Throwable throwable) {
- rpcResultBuilder = RpcResultBuilder.<UpdatePortOutput>failed().withError(RpcError.ErrorType.APPLICATION, throwable.getMessage(), throwable);
- requestContext.setResult(rpcResultBuilder.build());
- RequestContextUtil.closeRequstContext(requestContext);
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final UpdatePortInput input) {
+ final Port inputPort = input.getUpdatedPort().getPort().getPort().get(0);
+ final PortModInput ofPortModInput = PortConvertor.toPortModInput(inputPort, getVersion());
+ final PortModInputBuilder mdInput = new PortModInputBuilder(ofPortModInput);
+ mdInput.setXid(xid.getValue());
- getMessageSpy().spyMessage(portModInput.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
- }
- });
- return requestContext.getFuture();
- }
- });
+ return mdInput.build();
}
-
}
*/
package org.opendaylight.openflowplugin.impl.services;
-import com.google.common.base.Function;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.List;
import java.util.concurrent.Future;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
-import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.TableFeaturesConvertor;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.TableFeaturesReplyConvertor;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.MultipartReplyBody;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.slf4j.Logger;
-public class SalTableServiceImpl extends CommonService implements SalTableService {
-
+public final class SalTableServiceImpl extends AbstractMultipartService<UpdateTableInput> implements SalTableService {
private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(SalTableServiceImpl.class);
public SalTableServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
@Override
public Future<RpcResult<UpdateTableOutput>> updateTable(final UpdateTableInput input) {
- class FunctionImpl implements
- Function<RequestContext<List<MultipartReply>>, ListenableFuture<RpcResult<List<MultipartReply>>>> {
-
- @Override
- public ListenableFuture<RpcResult<List<MultipartReply>>> apply(final RequestContext<List<MultipartReply>> requestContext) {
- getMessageSpy().spyMessage(input.getImplementedInterface(),
- MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
-
- final SettableFuture<RpcResult<List<MultipartReply>>> result = SettableFuture.create();
-
- final MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
- final MultipartRequestTableFeaturesBuilder requestBuilder = new MultipartRequestTableFeaturesBuilder();
- final List<TableFeatures> ofTableFeatureList = TableFeaturesConvertor.toTableFeaturesRequest(input
- .getUpdatedTable());
- requestBuilder.setTableFeatures(ofTableFeatureList);
- caseBuilder.setMultipartRequestTableFeatures(requestBuilder.build());
-
- // Set request body to main multipart request
- final Xid xid = requestContext.getXid();
- final MultipartRequestInputBuilder mprInput = createMultipartHeader(MultipartType.OFPMPTABLEFEATURES,
- xid.getValue());
- mprInput.setMultipartRequestBody(caseBuilder.build());
- final OutboundQueue outboundQueue = getDeviceContext().getPrimaryConnectionContext().getOutboundQueueProvider();
-
- final MultiMsgCollector multiMsgCollector = getDeviceContext().getMultiMsgCollector();
- multiMsgCollector.registerMultipartRequestContext(requestContext);
-
- final MultipartRequestInput multipartRequestInput = mprInput.build();
- outboundQueue.commitEntry(xid.getValue(), multipartRequestInput, new FutureCallback<OfHeader>() {
- @Override
- public void onSuccess(final OfHeader ofHeader) {
- if (ofHeader instanceof MultipartReply) {
- MultipartReply multipartReply = (MultipartReply) ofHeader;
- multiMsgCollector.addMultipartMsg(multipartReply);
- } else {
- if (null != ofHeader) {
- LOG.info("Unexpected response type received {}.", ofHeader.getClass());
- } else {
- LOG.info("Response received is null.");
- }
- }
- getMessageSpy().spyMessage(multipartRequestInput.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
- }
-
- @Override
- public void onFailure(final Throwable throwable) {
- RpcResultBuilder<List<MultipartReply>> rpcResultBuilder = RpcResultBuilder.<List<MultipartReply>>failed().withError(RpcError.ErrorType.APPLICATION, throwable.getMessage(), throwable);
- RequestContextUtil.closeRequstContext(requestContext);
- multiMsgCollector.registerMultipartRequestContext(requestContext);
- getMessageSpy().spyMessage(multipartRequestInput.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
- }
- });
- return requestContext.getFuture();
- }
- }
-
- final ListenableFuture<RpcResult<List<MultipartReply>>> multipartFuture = handleServiceCall(new FunctionImpl());
+ final ListenableFuture<RpcResult<List<MultipartReply>>> multipartFuture = handleServiceCall(input);
final SettableFuture<RpcResult<UpdateTableOutput>> finalFuture = SettableFuture.create();
class CallBackImpl implements FutureCallback<RpcResult<List<MultipartReply>>> {
- private final Logger LOGGER = org.slf4j.LoggerFactory.getLogger(CallBackImpl.class);
-
@Override
public void onSuccess(final RpcResult<List<MultipartReply>> result) {
if (result.isSuccessful()) {
final List<MultipartReply> multipartReplies = result.getResult();
if (multipartReplies.isEmpty()) {
- LOGGER.debug("Multipart reply to table features request shouldn't be empty list.");
+ LOG.debug("Multipart reply to table features request shouldn't be empty list.");
finalFuture.set(RpcResultBuilder.<UpdateTableOutput>failed()
.withError(ErrorType.RPC, "Multipart reply list is empty.").build());
} else {
final Long xid = multipartReplies.get(0).getXid();
- LOGGER.debug(
+ LOG.debug(
"OnSuccess, rpc result successful, multipart response for rpc update-table with xid {} obtained.",
xid);
final UpdateTableOutputBuilder updateTableOutputBuilder = new UpdateTableOutputBuilder();
writeResponseToOperationalDatastore(multipartReplies);
}
} else {
- LOGGER.debug("OnSuccess, rpc result unsuccessful, multipart response for rpc update-table was unsuccessful.");
+ LOG.debug("OnSuccess, rpc result unsuccessful, multipart response for rpc update-table was unsuccessful.");
finalFuture.set(RpcResultBuilder.<UpdateTableOutput>failed().withRpcErrors(result.getErrors())
.build());
}
@Override
public void onFailure(final Throwable t) {
- LOGGER.debug("Failure multipart response for table features request. Exception: {}", t);
+ LOG.debug("Failure multipart response for table features request. Exception: {}", t);
finalFuture.set(RpcResultBuilder.<UpdateTableOutput>failed()
.withError(ErrorType.RPC, "Future error", t).build());
}
+ }
- /**
- * @param multipartReplies
- */
- private void writeResponseToOperationalDatastore(final List<MultipartReply> multipartReplies) {
-
- final List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> salTableFeatures = convertToSalTableFeatures(multipartReplies);
-
- final DeviceContext deviceContext = getDeviceContext();
- final NodeId nodeId = deviceContext.getPrimaryConnectionContext().getNodeId();
- final InstanceIdentifier<FlowCapableNode> flowCapableNodeII = InstanceIdentifier.create(Nodes.class)
- .child(Node.class, new NodeKey(nodeId)).augmentation(FlowCapableNode.class);
- for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures tableFeatureData : salTableFeatures) {
- final Short tableId = tableFeatureData.getTableId();
- KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures, TableFeaturesKey> tableFeaturesII = flowCapableNodeII
- .child(Table.class, new TableKey(tableId))
- .child(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures.class,
- new TableFeaturesKey(tableId));
- deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, tableFeaturesII,
- tableFeatureData);
- }
+ Futures.addCallback(multipartFuture, new CallBackImpl());
- }
+ return finalFuture;
+ }
- private List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> convertToSalTableFeatures(
- final List<MultipartReply> multipartReplies) {
- final List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> salTableFeaturesAll = new ArrayList<>();
- for (MultipartReply multipartReply : multipartReplies) {
- if (multipartReply.getType().equals(MultipartType.OFPMPTABLEFEATURES)) {
- MultipartReplyBody multipartReplyBody = multipartReply.getMultipartReplyBody();
- if (multipartReplyBody instanceof MultipartReplyTableFeaturesCase) {
- MultipartReplyTableFeaturesCase tableFeaturesCase = ((MultipartReplyTableFeaturesCase) multipartReplyBody);
- MultipartReplyTableFeatures salTableFeatures = tableFeaturesCase
- .getMultipartReplyTableFeatures();
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> salTableFeaturesPartial = TableFeaturesReplyConvertor
- .toTableFeaturesReply(salTableFeatures);
- salTableFeaturesAll.addAll(salTableFeaturesPartial);
- LOGGER.debug("TableFeature {} for xid {}.", salTableFeatures, multipartReply.getXid());
- }
- }
+ /**
+ * @param multipartReplies
+ */
+ private void writeResponseToOperationalDatastore(final List<MultipartReply> multipartReplies) {
+
+ final List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> salTableFeatures = convertToSalTableFeatures(multipartReplies);
+
+ final DeviceContext deviceContext = getDeviceContext();
+ final NodeId nodeId = deviceContext.getPrimaryConnectionContext().getNodeId();
+ final InstanceIdentifier<FlowCapableNode> flowCapableNodeII = InstanceIdentifier.create(Nodes.class)
+ .child(Node.class, new NodeKey(nodeId)).augmentation(FlowCapableNode.class);
+ for (final org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures tableFeatureData : salTableFeatures) {
+ final Short tableId = tableFeatureData.getTableId();
+ final KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures, TableFeaturesKey> tableFeaturesII = flowCapableNodeII
+ .child(Table.class, new TableKey(tableId))
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures.class,
+ new TableFeaturesKey(tableId));
+ deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, tableFeaturesII,
+ tableFeatureData);
+ }
+ deviceContext.submitTransaction();
+ }
+
+ protected static List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> convertToSalTableFeatures(
+ final List<MultipartReply> multipartReplies) {
+ final List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> salTableFeaturesAll = new ArrayList<>();
+ for (final MultipartReply multipartReply : multipartReplies) {
+ if (multipartReply.getType().equals(MultipartType.OFPMPTABLEFEATURES)) {
+ final MultipartReplyBody multipartReplyBody = multipartReply.getMultipartReplyBody();
+ if (multipartReplyBody instanceof MultipartReplyTableFeaturesCase) {
+ final MultipartReplyTableFeaturesCase tableFeaturesCase = ((MultipartReplyTableFeaturesCase) multipartReplyBody);
+ final MultipartReplyTableFeatures salTableFeatures = tableFeaturesCase
+ .getMultipartReplyTableFeatures();
+ final List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> salTableFeaturesPartial = TableFeaturesReplyConvertor
+ .toTableFeaturesReply(salTableFeatures);
+ salTableFeaturesAll.addAll(salTableFeaturesPartial);
+ LOG.debug("TableFeature {} for xid {}.", salTableFeatures, multipartReply.getXid());
}
- return salTableFeaturesAll;
}
-
}
-
- Futures.addCallback(multipartFuture, new CallBackImpl());
-
- return finalFuture;
+ return salTableFeaturesAll;
}
private MultipartRequestInputBuilder createMultipartHeader(final MultipartType multipart, final Long xid) {
return mprInput;
}
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final UpdateTableInput input) {
+ final MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
+ final MultipartRequestTableFeaturesBuilder requestBuilder = new MultipartRequestTableFeaturesBuilder();
+ final List<TableFeatures> ofTableFeatureList = TableFeaturesConvertor.toTableFeaturesRequest(input
+ .getUpdatedTable());
+ requestBuilder.setTableFeatures(ofTableFeatureList);
+ caseBuilder.setMultipartRequestTableFeatures(requestBuilder.build());
+
+ // Set request body to main multipart request
+ final MultipartRequestInputBuilder mprInput = createMultipartHeader(MultipartType.OFPMPTABLEFEATURES,
+ xid.getValue());
+ mprInput.setMultipartRequestBody(caseBuilder.build());
+
+ return mprInput.build();
+ }
}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.services;
+
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.FutureCallback;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
+import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+final class SimpleRequestCallback<T extends DataObject> extends AbstractRequestCallback<T> {
+ private static final Logger LOG = LoggerFactory.getLogger(SimpleRequestCallback.class);
+ private final Class<T> clazz;
+
+ private SimpleRequestCallback(final RequestContext<T> context, final Class<?> requestType, final MessageSpy spy, final Class<T> clazz) {
+ super(context, requestType, spy);
+ this.clazz = Preconditions.checkNotNull(clazz);
+ }
+
+ static <T extends DataObject> FutureCallback<OfHeader> create(final RequestContext<T> context, final Class<?> requestType, final MessageSpy spy, final Class<T> clazz) {
+ return new SimpleRequestCallback<>(context, requestType, spy, clazz);
+ }
+
+ @Override
+ public final void onSuccess(final OfHeader result) {
+ spyMessage(MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
+
+ if (result == null) {
+ setResult(RpcResultBuilder.<T>success().build());
+ return;
+ }
+ if (!clazz.isInstance(result)) {
+ LOG.info("Expected response type {}, got {}, result is empty", clazz, result.getClass());
+ setResult(RpcResultBuilder.<T>success().build());
+ return;
+
+ }
+
+ setResult(RpcResultBuilder.success(clazz.cast(result)).build());
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.services;
+
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
+import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
+import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy.STATISTIC_GROUP;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+
+final class VoidRequestCallback extends AbstractRequestCallback<Void> {
+ private static final RpcResult<Void> SUCCESS = RpcResultBuilder.<Void>success().build();
+
+ VoidRequestCallback(final RequestContext<Void> context, final Class<?> requestType, final MessageSpy spy) {
+ super(context, requestType, spy);
+ }
+
+ @Override
+ public void onSuccess(final OfHeader result) {
+ spyMessage(STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS_NO_RESPONSE);
+ setResult(SUCCESS);
+ }
+}
package org.opendaylight.openflowplugin.impl.statistics;
+import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
+import javax.annotation.CheckForNull;
import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
private static final String CONNECTION_CLOSED = "Connection closed.";
private final Collection<RequestContext<?>> requestContexts = new HashSet<>();
private final DeviceContext deviceContext;
+ private final DeviceState devState;
+ private final ListenableFuture<Boolean> emptyFuture;
private final StatisticsGatheringService statisticsGatheringService;
- public StatisticsContextImpl(final DeviceContext deviceContext) {
- this.deviceContext = deviceContext;
+ public StatisticsContextImpl(@CheckForNull final DeviceContext deviceContext) {
+ this.deviceContext = Preconditions.checkNotNull(deviceContext);
+ devState = Preconditions.checkNotNull(deviceContext.getDeviceState());
+ emptyFuture = Futures.immediateFuture(new Boolean(false));
statisticsGatheringService = new StatisticsGatheringService(this, deviceContext);
}
@Override
public ListenableFuture<Boolean> gatherDynamicData() {
-
final SettableFuture<Boolean> settableResultingFuture = SettableFuture.create();
- ListenableFuture<Boolean> resultingFuture = settableResultingFuture;
-
-
- if (ConnectionContext.CONNECTION_STATE.WORKING.equals(deviceContext.getPrimaryConnectionContext().getConnectionState())) {
- final DeviceState devState = deviceContext.getDeviceState();
- final ListenableFuture<Boolean> emptyFuture = Futures.immediateFuture(new Boolean(false));
- final ListenableFuture<Boolean> flowStatistics = devState.isFlowStatisticsAvailable() ? StatisticsGatheringUtils.gatherStatistics(statisticsGatheringService, deviceContext, MultipartType.OFPMPFLOW) : emptyFuture;
-
- final ListenableFuture<Boolean> tableStatistics = devState.isTableStatisticsAvailable() ? StatisticsGatheringUtils.gatherStatistics(statisticsGatheringService, deviceContext, MultipartType.OFPMPTABLE) : emptyFuture;
-
- final ListenableFuture<Boolean> portStatistics = devState.isPortStatisticsAvailable() ? StatisticsGatheringUtils.gatherStatistics(statisticsGatheringService, deviceContext, MultipartType.OFPMPPORTSTATS) : emptyFuture;
-
- final ListenableFuture<Boolean> queueStatistics = devState.isQueueStatisticsAvailable() ? StatisticsGatheringUtils.gatherStatistics(statisticsGatheringService, deviceContext, MultipartType.OFPMPQUEUE) : emptyFuture;
-
- final ListenableFuture<Boolean> groupDescStatistics = devState.isGroupAvailable() ? StatisticsGatheringUtils.gatherStatistics(statisticsGatheringService, deviceContext, MultipartType.OFPMPGROUPDESC) : emptyFuture;
- final ListenableFuture<Boolean> groupStatistics = devState.isGroupAvailable() ? StatisticsGatheringUtils.gatherStatistics(statisticsGatheringService, deviceContext, MultipartType.OFPMPGROUP) : emptyFuture;
-
- final ListenableFuture<Boolean> meterConfigStatistics = devState.isMetersAvailable() ? StatisticsGatheringUtils.gatherStatistics(statisticsGatheringService, deviceContext, MultipartType.OFPMPMETERCONFIG) : emptyFuture;
- final ListenableFuture<Boolean> meterStatistics = devState.isMetersAvailable() ? StatisticsGatheringUtils.gatherStatistics(statisticsGatheringService, deviceContext, MultipartType.OFPMPMETER) : emptyFuture;
-
-
- final ListenableFuture<List<Boolean>> allFutures = Futures.allAsList(Arrays.asList(flowStatistics, tableStatistics, groupDescStatistics, groupStatistics, meterConfigStatistics, meterStatistics, portStatistics, queueStatistics));
- Futures.addCallback(allFutures, new FutureCallback<List<Boolean>>() {
- @Override
- public void onSuccess(final List<Boolean> booleans) {
- boolean atLeastOneSuccess = false;
- for (final Boolean bool : booleans) {
- atLeastOneSuccess |= bool.booleanValue();
- }
- settableResultingFuture.set(new Boolean(atLeastOneSuccess));
- }
-
- @Override
- public void onFailure(final Throwable throwable) {
- settableResultingFuture.setException(throwable);
+ final ListenableFuture<Boolean> flowStatistics = gatherDynamicData(MultipartType.OFPMPFLOW);
+ final ListenableFuture<Boolean> tableStatistics = gatherDynamicData(MultipartType.OFPMPTABLE);
+ final ListenableFuture<Boolean> portStatistics = gatherDynamicData(MultipartType.OFPMPPORTSTATS);
+ final ListenableFuture<Boolean> queueStatistics = gatherDynamicData(MultipartType.OFPMPQUEUE);
+ final ListenableFuture<Boolean> groupDescStatistics = gatherDynamicData(MultipartType.OFPMPGROUPDESC);
+ final ListenableFuture<Boolean> groupStatistics = gatherDynamicData(MultipartType.OFPMPGROUP);
+ final ListenableFuture<Boolean> meterConfigStatistics = gatherDynamicData(MultipartType.OFPMPMETERCONFIG);
+ final ListenableFuture<Boolean> meterStatistics = gatherDynamicData(MultipartType.OFPMPMETER);
+
+ final ListenableFuture<List<Boolean>> allFutures = Futures.allAsList(Arrays.asList(flowStatistics, tableStatistics, groupDescStatistics, groupStatistics, meterConfigStatistics, meterStatistics, portStatistics, queueStatistics));
+ Futures.addCallback(allFutures, new FutureCallback<List<Boolean>>() {
+ @Override
+ public void onSuccess(final List<Boolean> booleans) {
+ boolean atLeastOneSuccess = false;
+ for (final Boolean bool : booleans) {
+ atLeastOneSuccess |= bool.booleanValue();
}
- });
- } else {
- switch (deviceContext.getPrimaryConnectionContext().getConnectionState()) {
- case RIP:
- resultingFuture = Futures.immediateFailedFuture(new Throwable(String.format("Device connection doesn't exist anymore. Primary connection status : %s", deviceContext.getPrimaryConnectionContext().getConnectionState())));
- break;
- default:
- resultingFuture = Futures.immediateCheckedFuture(Boolean.TRUE);
- break;
+ settableResultingFuture.set(new Boolean(atLeastOneSuccess));
}
+ @Override
+ public void onFailure(final Throwable throwable) {
+ settableResultingFuture.setException(throwable);
+ }
+ });
+ return settableResultingFuture;
+ }
+ @Override
+ public ListenableFuture<Boolean> gatherDynamicData(final MultipartType multipartType) {
+ Preconditions.checkArgument(multipartType != null);
+ final ListenableFuture<Boolean> resultingFuture = deviceConnectionCheck();
+ if (resultingFuture != null) {
+ return resultingFuture;
+ }
+ switch (multipartType) {
+ case OFPMPFLOW:
+ return collectFlowStatistics(multipartType);
+ case OFPMPTABLE:
+ return collectTableStatistics(multipartType);
+ case OFPMPPORTSTATS:
+ return collectPortStatistics(multipartType);
+ case OFPMPQUEUE:
+ return collectQueueStatistics(multipartType);
+ case OFPMPGROUPDESC:
+ return collectGroupDescStatistics(multipartType);
+ case OFPMPGROUP:
+ return collectGroupStatistics(multipartType);
+ case OFPMPMETERCONFIG:
+ return collectMeterConfigStatistics(multipartType);
+ case OFPMPMETER:
+ return collectMeterStatistics(multipartType);
+ default:
+ LOG.warn("Unsuported Statistics type {}", multipartType);
+ return Futures.immediateCheckedFuture(Boolean.TRUE);
}
- return resultingFuture;
}
@Override
RequestContextUtil.closeRequestContextWithRpcError(requestContext, CONNECTION_CLOSED);
}
}
+
+ /**
+ * Method checks a device state. It returns null for be able continue. Otherwise it returns immediateFuture
+ * which has to be returned from caller too
+ *
+ * @return
+ */
+ private ListenableFuture<Boolean> deviceConnectionCheck() {
+ if ( ! ConnectionContext.CONNECTION_STATE.WORKING.equals(deviceContext.getPrimaryConnectionContext().getConnectionState())) {
+ ListenableFuture<Boolean> resultingFuture = SettableFuture.create();
+ switch (deviceContext.getPrimaryConnectionContext().getConnectionState()) {
+ case RIP:
+ final String errMsg = String.format("Device connection doesn't exist anymore. Primary connection status : %s",
+ deviceContext.getPrimaryConnectionContext().getConnectionState());
+ resultingFuture = Futures.immediateFailedFuture(new Throwable(errMsg));
+ break;
+ default:
+ resultingFuture = Futures.immediateCheckedFuture(Boolean.TRUE);
+ break;
+ }
+ return resultingFuture;
+ }
+ return null;
+ }
+
+ private ListenableFuture<Boolean> collectFlowStatistics(final MultipartType multipartType) {
+ return devState.isFlowStatisticsAvailable() ? StatisticsGatheringUtils.gatherStatistics(
+ statisticsGatheringService, deviceContext, /*MultipartType.OFPMPFLOW*/ multipartType) : emptyFuture;
+ }
+
+ private ListenableFuture<Boolean> collectTableStatistics(final MultipartType multipartType) {
+ return devState.isTableStatisticsAvailable() ? StatisticsGatheringUtils.gatherStatistics(
+ statisticsGatheringService, deviceContext, /*MultipartType.OFPMPTABLE*/ multipartType) : emptyFuture;
+ }
+
+ private ListenableFuture<Boolean> collectPortStatistics(final MultipartType multipartType) {
+ return devState.isPortStatisticsAvailable() ? StatisticsGatheringUtils.gatherStatistics(
+ statisticsGatheringService, deviceContext, /*MultipartType.OFPMPPORTSTATS*/ multipartType) : emptyFuture;
+ }
+
+ private ListenableFuture<Boolean> collectQueueStatistics(final MultipartType multipartType) {
+ return devState.isQueueStatisticsAvailable() ? StatisticsGatheringUtils.gatherStatistics(
+ statisticsGatheringService, deviceContext, /*MultipartType.OFPMPQUEUE*/ multipartType) : emptyFuture;
+ }
+
+ private ListenableFuture<Boolean> collectGroupDescStatistics(final MultipartType multipartType) {
+ return devState.isGroupAvailable() ? StatisticsGatheringUtils.gatherStatistics(
+ statisticsGatheringService, deviceContext, /*MultipartType.OFPMPGROUPDESC*/ multipartType) : emptyFuture;
+ }
+
+ private ListenableFuture<Boolean> collectGroupStatistics(final MultipartType multipartType) {
+ return devState.isGroupAvailable() ? StatisticsGatheringUtils.gatherStatistics(
+ statisticsGatheringService, deviceContext, /*MultipartType.OFPMPGROUP*/ multipartType) : emptyFuture;
+ }
+
+ private ListenableFuture<Boolean> collectMeterConfigStatistics(final MultipartType multipartType) {
+ return devState.isMetersAvailable() ? StatisticsGatheringUtils.gatherStatistics(
+ statisticsGatheringService, deviceContext, /*MultipartType.OFPMPMETERCONFIG*/ multipartType) : emptyFuture;
+ }
+
+ private ListenableFuture<Boolean> collectMeterStatistics(final MultipartType multipartType) {
+ return devState.isMetersAvailable() ? StatisticsGatheringUtils.gatherStatistics(
+ statisticsGatheringService, deviceContext, /*MultipartType.OFPMPMETER*/ multipartType) : emptyFuture;
+ }
}
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowHash;
-import org.opendaylight.openflowplugin.impl.registry.flow.FlowHashFactory;
+import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey;
+import org.opendaylight.openflowplugin.impl.registry.flow.FlowRegistryKeyFactory;
import org.opendaylight.openflowplugin.impl.statistics.services.dedicated.StatisticsGatheringService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
throw new IllegalStateException("This class should not be instantiated.");
}
- private static KeyedInstanceIdentifier<Node, NodeKey> getInstanceIdentifier(final DeviceContext deviceContext) {
- return InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(deviceContext.getPrimaryConnectionContext().getNodeId()));
- }
+
public static ListenableFuture<Boolean> gatherStatistics(final StatisticsGatheringService statisticsGatheringService,
final DeviceContext deviceContext,
allMultipartData = Iterables.concat(allMultipartData, multipartDataList);
}
- if (deviceContext.getDeviceState().isValid()) {
- deviceContext.startGatheringOperationsToOneTransaction();
- }
-
if (multipartData instanceof GroupStatisticsUpdated) {
- processGroupStatistics((Iterable<GroupStatisticsUpdated>)allMultipartData, deviceContext);
+ processGroupStatistics((Iterable<GroupStatisticsUpdated>) allMultipartData, deviceContext);
} else if (multipartData instanceof MeterStatisticsUpdated) {
- processMetersStatistics((Iterable<MeterStatisticsUpdated>)allMultipartData, deviceContext);
+ processMetersStatistics((Iterable<MeterStatisticsUpdated>) allMultipartData, deviceContext);
} else if (multipartData instanceof NodeConnectorStatisticsUpdate) {
processNodeConnectorStatistics((Iterable<NodeConnectorStatisticsUpdate>) allMultipartData, deviceContext);
} else if (multipartData instanceof FlowTableStatisticsUpdate) {
} else if (multipartData instanceof QueueStatisticsUpdate) {
processQueueStatistics((Iterable<QueueStatisticsUpdate>) allMultipartData, deviceContext);
} else if (multipartData instanceof FlowsStatisticsUpdate) {
- processFlowStatistics((Iterable<FlowsStatisticsUpdate>)allMultipartData, deviceContext);
+ processFlowStatistics((Iterable<FlowsStatisticsUpdate>) allMultipartData, deviceContext);
} else if (multipartData instanceof GroupDescStatsUpdated) {
processGroupDescStats((Iterable<GroupDescStatsUpdated>) allMultipartData, deviceContext);
} else if (multipartData instanceof MeterConfigStatsUpdated) {
}
//TODO : implement experimenter
- if (deviceContext.getDeviceState().isValid()) {
- deviceContext.commitOperationsGatheredInOneTransaction();
- }
return isMultipartProcessed;
}
return Boolean.FALSE;
private static void processMeterConfigStatsUpdated(final Iterable<MeterConfigStatsUpdated> data, final DeviceContext deviceContext) {
for (final MeterConfigStatsUpdated meterConfigStatsUpdated : data) {
- NodeId nodeId = meterConfigStatsUpdated.getId();
+ final NodeId nodeId = meterConfigStatsUpdated.getId();
final InstanceIdentifier<FlowCapableNode> fNodeIdent = getFlowCapableNodeInstanceIdentifier(nodeId);
- for (MeterConfigStats meterConfigStats : meterConfigStatsUpdated.getMeterConfigStats()) {
+ for (final MeterConfigStats meterConfigStats : meterConfigStatsUpdated.getMeterConfigStats()) {
final MeterId meterId = meterConfigStats.getMeterId();
final InstanceIdentifier<Meter> meterInstanceIdentifier = fNodeIdent.child(Meter.class, new MeterKey(meterId));
deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, meterInstanceIdentifier, meterBuilder.build());
}
}
+ deviceContext.submitTransaction();
}
private static void processFlowStatistics(final Iterable<FlowsStatisticsUpdate> data, final DeviceContext deviceContext) {
for (final FlowsStatisticsUpdate flowsStatistics : data) {
for (final FlowAndStatisticsMapList flowStat : flowsStatistics.getFlowAndStatisticsMapList()) {
final FlowBuilder flowBuilder = new FlowBuilder(flowStat);
- short tableId = flowStat.getTableId();
- final Short version = deviceContext.getPrimaryConnectionContext().getFeatures().getVersion();
-
- final FlowHash flowHash = FlowHashFactory.create(flowBuilder.build(), version);
- final FlowId flowId = deviceContext.getDeviceFlowRegistry().storeIfNecessary(flowHash, tableId);
+ final short tableId = flowStat.getTableId();
+ final FlowRegistryKey flowRegistryKey = FlowRegistryKeyFactory.create(flowBuilder.build());
+ final FlowId flowId = deviceContext.getDeviceFlowRegistry().storeIfNecessary(flowRegistryKey, tableId);
final FlowKey flowKey = new FlowKey(flowId);
flowBuilder.setKey(flowKey);
deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, flowIdent, flowBuilder.build());
}
}
+ deviceContext.submitTransaction();
}
private static void deleteAllKnownFlows(final DeviceContext deviceContext, final InstanceIdentifier<Node> nodeIdent) {
if (deviceContext.getDeviceState().deviceSynchronized()) {
final Short numOfTablesOnDevice = deviceContext.getDeviceState().getFeatures().getTables();
for (short i=0; i<numOfTablesOnDevice; i++) {
- KeyedInstanceIdentifier<Table, TableKey> iiToTable
- = nodeIdent.augmentation(FlowCapableNode.class).child( Table.class, new TableKey(i) );
+ final KeyedInstanceIdentifier<Table, TableKey> iiToTable
+ = nodeIdent.augmentation(FlowCapableNode.class).child( Table.class, new TableKey(i));
final ReadTransaction readTx = deviceContext.getReadTransaction();
- CheckedFuture<Optional<Table>, ReadFailedException> tableDataFuture = readTx.read(LogicalDatastoreType.OPERATIONAL, iiToTable);
+ final CheckedFuture<Optional<Table>, ReadFailedException> tableDataFuture = readTx.read(LogicalDatastoreType.OPERATIONAL, iiToTable);
try {
- Optional<Table> tableDataOpt = tableDataFuture.get();
+ final Optional<Table> tableDataOpt = tableDataFuture.get();
if (tableDataOpt.isPresent()) {
final Table tableData = tableDataOpt.get();
final Table table = new TableBuilder(tableData).setFlow(Collections.<Flow>emptyList()).build();
deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, iiToTable, table);
}
- } catch (InterruptedException e) {
- LOG.trace("Reading of table features for table wit ID {} was interrputed.",i);
- } catch (ExecutionException e) {
- LOG.trace("Reading of table features for table wit ID {} encountered execution exception {}.",i,e);
+ } catch (final InterruptedException e) {
+ LOG.trace("Reading of table features for table wit ID {} was interrputed.", i);
+ } catch (final ExecutionException e) {
+ LOG.trace("Reading of table features for table wit ID {} encountered execution exception {}.", i, e);
}
}
}
}
}
}
+ deviceContext.submitTransaction();
}
private static void processFlowTableStatistics(final Iterable<FlowTableStatisticsUpdate> data, final DeviceContext deviceContext) {
- for(final FlowTableStatisticsUpdate flowTableStatisticsUpdate : data) {
+ for (final FlowTableStatisticsUpdate flowTableStatisticsUpdate : data) {
final InstanceIdentifier<FlowCapableNode> fNodeIdent = getFlowCapableNodeInstanceIdentifier(flowTableStatisticsUpdate.getId());
for (final FlowTableAndStatisticsMap tableStat : flowTableStatisticsUpdate.getFlowTableAndStatisticsMap()) {
deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, tStatIdent, stats);
}
}
+ deviceContext.submitTransaction();
}
private static void processNodeConnectorStatistics(final Iterable<NodeConnectorStatisticsUpdate> data, final DeviceContext deviceContext) {
deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, flowCapNodeConnStatIdent, stats);
}
}
+ deviceContext.submitTransaction();
}
private static void processMetersStatistics(final Iterable<MeterStatisticsUpdated> data,
final DeviceContext deviceContext) {
- NodeId nodeId = deviceContext.getDeviceState().getNodeId();
+ final NodeId nodeId = deviceContext.getDeviceState().getNodeId();
final InstanceIdentifier<FlowCapableNode> fNodeIdent = getFlowCapableNodeInstanceIdentifier(nodeId);
deleteAllKnownMeters(deviceContext, fNodeIdent);
- for (MeterStatisticsUpdated meterStatisticsUpdated : data) {
+ for (final MeterStatisticsUpdated meterStatisticsUpdated : data) {
for (final MeterStats mStat : meterStatisticsUpdated.getMeterStats()) {
final MeterStatistics stats = new MeterStatisticsBuilder(mStat).build();
final MeterId meterId = mStat.getMeterId();
deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, msIdent, stats);
}
}
+ deviceContext.submitTransaction();
}
private static void deleteAllKnownMeters(final DeviceContext deviceContext, final InstanceIdentifier<FlowCapableNode> fNodeIdent) {
- for (MeterId meterId : deviceContext.getDeviceMeterRegistry().getAllMeterIds()) {
+ for (final MeterId meterId : deviceContext.getDeviceMeterRegistry().getAllMeterIds()) {
final InstanceIdentifier<Meter> meterIdent = fNodeIdent.child(Meter.class, new MeterKey(meterId));
deviceContext.addDeleteToTxChain(LogicalDatastoreType.OPERATIONAL, meterIdent);
}
}
private static void processGroupDescStats(final Iterable<GroupDescStatsUpdated> data, final DeviceContext deviceContext) {
- for ( GroupDescStatsUpdated groupDescStatsUpdated : data) {
- NodeId nodeId = groupDescStatsUpdated.getId();
+ for (final GroupDescStatsUpdated groupDescStatsUpdated : data) {
+ final NodeId nodeId = groupDescStatsUpdated.getId();
final InstanceIdentifier<FlowCapableNode> fNodeIdent = getFlowCapableNodeInstanceIdentifier(nodeId);
- for (GroupDescStats groupDescStats : groupDescStatsUpdated.getGroupDescStats()) {
+ for (final GroupDescStats groupDescStats : groupDescStatsUpdated.getGroupDescStats()) {
final GroupId groupId = groupDescStats.getGroupId();
final GroupBuilder groupBuilder = new GroupBuilder(groupDescStats);
deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, groupIdent, groupBuilder.build());
}
}
+ deviceContext.submitTransaction();
}
private static void deleteAllKnownGroups(final DeviceContext deviceContext, final InstanceIdentifier<FlowCapableNode> fNodeIdent) {
- for (GroupId groupId : deviceContext.getDeviceGroupRegistry().getAllGroupIds()) {
+ for (final GroupId groupId : deviceContext.getDeviceGroupRegistry().getAllGroupIds()) {
final InstanceIdentifier<Group> groupIdent = fNodeIdent.child(Group.class, new GroupKey(groupId));
deviceContext.addDeleteToTxChain(LogicalDatastoreType.OPERATIONAL, groupIdent);
}
}
private static void processGroupStatistics(final Iterable<GroupStatisticsUpdated> data, final DeviceContext deviceContext) {
- NodeId nodeId = deviceContext.getDeviceState().getNodeId();
+ final NodeId nodeId = deviceContext.getDeviceState().getNodeId();
final InstanceIdentifier<FlowCapableNode> fNodeIdent = getFlowCapableNodeInstanceIdentifier(nodeId);
deleteAllKnownGroups(deviceContext, fNodeIdent);
- for (GroupStatisticsUpdated groupStatistics : data) {
+ for (final GroupStatisticsUpdated groupStatistics : data) {
for (final GroupStats groupStats : groupStatistics.getGroupStats()) {
final InstanceIdentifier<Group> groupIdent = fNodeIdent.child(Group.class, new GroupKey(groupStats.getGroupId()));
deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, gsIdent, stats);
}
}
+ deviceContext.submitTransaction();
}
private static InstanceIdentifier<FlowCapableNode> getFlowCapableNodeInstanceIdentifier(final NodeId nodeId) {
import io.netty.util.TimerTask;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
+import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext;
if (null == hashedWheelTimer) {
LOG.trace("This is first device that delivered timer. Starting statistics polling immediately.");
hashedWheelTimer = deviceContext.getTimer();
- pollStatistics();
}
final StatisticsContext statisticsContext = new StatisticsContextImpl(deviceContext);
if (statisticsGathered.booleanValue()) {
//there are some statistics on device worth gathering
contexts.put(deviceContext, statisticsContext);
+ pollStatistics(deviceContext, statisticsContext);
}
LOG.trace("Device dynamic info collecting done. Going to announce raise to next level.");
deviceInitPhaseHandler.onDeviceContextLevelUp(deviceContext);
});
}
- private void pollStatistics() {
- try {
- timeCounter.markStart();
- for (final StatisticsContext statisticsContext : contexts.values()) {
- ListenableFuture<Boolean> deviceStatisticsCollectionFuture = statisticsContext.gatherDynamicData();
- Futures.addCallback(deviceStatisticsCollectionFuture, new FutureCallback<Boolean>() {
- @Override
- public void onSuccess(final Boolean o) {
- timeCounter.addTimeMark();
- }
-
- @Override
- public void onFailure(final Throwable throwable) {
- timeCounter.addTimeMark();
- LOG.info("Statistics gathering for single node was not successful: {}", throwable.getMessage());
- LOG.debug("Statistics gathering for single node was not successful.. ", throwable);
- }
- });
+ private void pollStatistics(final DeviceContext deviceContext, final StatisticsContext statisticsContext) {
+ timeCounter.markStart();
+ ListenableFuture<Boolean> deviceStatisticsCollectionFuture = statisticsContext.gatherDynamicData();
+ Futures.addCallback(deviceStatisticsCollectionFuture, new FutureCallback<Boolean>() {
+ @Override
+ public void onSuccess(final Boolean o) {
+ timeCounter.addTimeMark();
+ calculateTimerDelay();
+ scheduleNextPolling(deviceContext, statisticsContext);
}
- } finally {
- calculateTimerDelay();
- if (null != hashedWheelTimer) {
- hashedWheelTimer.newTimeout(new TimerTask() {
- @Override
- public void run(final Timeout timeout) throws Exception {
- pollStatistics();
- }
- }, currentTimerDelay, TimeUnit.MILLISECONDS);
+
+ @Override
+ public void onFailure(final Throwable throwable) {
+ timeCounter.addTimeMark();
+ LOG.info("Statistics gathering for single node was not successful: {}", throwable.getMessage());
+ LOG.debug("Statistics gathering for single node was not successful.. ", throwable);
+ if (ConnectionContext.CONNECTION_STATE.WORKING.equals(deviceContext.getPrimaryConnectionContext().getConnectionState())) {
+ calculateTimerDelay();
+ scheduleNextPolling(deviceContext, statisticsContext);
+ }
}
+ });
+ }
+
+ private void scheduleNextPolling(final DeviceContext deviceContext, final StatisticsContext statisticsContext) {
+ if (null != hashedWheelTimer) {
+ hashedWheelTimer.newTimeout(new TimerTask() {
+ @Override
+ public void run(final Timeout timeout) throws Exception {
+ pollStatistics(deviceContext, statisticsContext);
+ }
+ }, currentTimerDelay, TimeUnit.MILLISECONDS);
}
}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder;
+
+final class AggregateFlowsInTableService extends AbstractSimpleService<GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput, GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput> {
+ public AggregateFlowsInTableService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ super(requestContextStack, deviceContext, GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput.class);
+ }
+
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input) {
+ // Create multipart request body for fetch all the group stats
+ final MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder = new MultipartRequestAggregateCaseBuilder();
+ final MultipartRequestAggregateBuilder mprAggregateRequestBuilder = new MultipartRequestAggregateBuilder();
+ mprAggregateRequestBuilder.setTableId(input.getTableId().getValue());
+ mprAggregateRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
+ mprAggregateRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
+ mprAggregateRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
+ mprAggregateRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
+ final short version = getVersion();
+ FlowCreatorUtil.setWildcardedFlowMatch(version, mprAggregateRequestBuilder);
+
+ // Set request body to main multipart request
+ multipartRequestAggregateCaseBuilder.setMultipartRequestAggregate(mprAggregateRequestBuilder
+ .build());
+ final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+ MultipartType.OFPMPAGGREGATE, xid.getValue(), version);
+
+ mprInput.setMultipartRequestBody(multipartRequestAggregateCaseBuilder.build());
+
+ return mprInput.build();
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
+
+final class AllFlowsInAllTablesService extends AbstractSimpleService<GetAllFlowsStatisticsFromAllFlowTablesInput, GetAllFlowsStatisticsFromAllFlowTablesOutput> {
+ private final MultipartRequestFlowCase flowCase;
+
+ AllFlowsInAllTablesService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ super(requestContextStack, deviceContext, GetAllFlowsStatisticsFromAllFlowTablesOutput.class);
+
+ final MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
+ final MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
+ mprFlowRequestBuilder.setTableId(OFConstants.OFPTT_ALL);
+ mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
+ mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
+ mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
+ mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
+ FlowCreatorUtil.setWildcardedFlowMatch(getVersion(), mprFlowRequestBuilder);
+ multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
+
+ flowCase = multipartRequestFlowCaseBuilder.build();
+ }
+
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final GetAllFlowsStatisticsFromAllFlowTablesInput input) {
+ final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+ MultipartType.OFPMPFLOW, xid.getValue(), getVersion());
+ mprInput.setMultipartRequestBody(flowCase);
+
+ return mprInput.build();
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
+
+public class AllFlowsInTableService extends AbstractSimpleService<GetAllFlowStatisticsFromFlowTableInput, GetAllFlowStatisticsFromFlowTableOutput> {
+
+ public AllFlowsInTableService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ super(requestContextStack, deviceContext, GetAllFlowStatisticsFromFlowTableOutput.class);
+ }
+
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final GetAllFlowStatisticsFromFlowTableInput input) {
+ final MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
+ mprFlowRequestBuilder.setTableId(input.getTableId().getValue());
+ mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
+ mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
+ mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
+ mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
+
+ final short version = getVersion();
+ FlowCreatorUtil.setWildcardedFlowMatch(version, mprFlowRequestBuilder);
+
+ final MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
+ multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
+
+ final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+ MultipartType.OFPMPFLOW, xid.getValue(), version);
+
+ mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
+
+ return mprInput.build();
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowjava.protocol.api.util.BinContent;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroupBuilder;
+
+final class AllGroupsStatsService extends AbstractSimpleService<GetAllGroupStatisticsInput, GetAllGroupStatisticsOutput> {
+ private static final MultipartRequestGroupCase GROUP_CASE;
+
+ static {
+ final MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder();
+ final MultipartRequestGroupBuilder mprGroupBuild = new MultipartRequestGroupBuilder();
+ mprGroupBuild.setGroupId(new GroupId(BinContent.intToUnsignedLong(Group.OFPGALL.getIntValue())));
+ caseBuilder.setMultipartRequestGroup(mprGroupBuild.build());
+
+ GROUP_CASE = caseBuilder.build();
+ }
+
+ AllGroupsStatsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ super(requestContextStack, deviceContext, GetAllGroupStatisticsOutput.class);
+ }
+
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final GetAllGroupStatisticsInput input) {
+ // Create multipart request header
+ final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+ MultipartType.OFPMPGROUP, xid.getValue(), getVersion());
+
+ // Set request body to main multipart request
+ mprInput.setMultipartRequestBody(GROUP_CASE);
+
+ // Send the request, no cookies associated, use any connection
+ return mprInput.build();
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowjava.protocol.api.util.BinContent;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Meter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfigCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfigCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter.config._case.MultipartRequestMeterConfigBuilder;
+
+final class AllMeterConfigStatsService extends AbstractSimpleService<GetAllMeterConfigStatisticsInput, GetAllMeterConfigStatisticsOutput> {
+ private static final MultipartRequestMeterConfigCase METER_CONFIG_CASE;
+
+ static {
+ MultipartRequestMeterConfigCaseBuilder caseBuilder =
+ new MultipartRequestMeterConfigCaseBuilder();
+ MultipartRequestMeterConfigBuilder mprMeterConfigBuild =
+ new MultipartRequestMeterConfigBuilder();
+ mprMeterConfigBuild.setMeterId(new MeterId(BinContent.intToUnsignedLong(Meter.OFPMALL.getIntValue())));
+ caseBuilder.setMultipartRequestMeterConfig(mprMeterConfigBuild.build());
+
+ METER_CONFIG_CASE = caseBuilder.build();
+ }
+
+ AllMeterConfigStatsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ super(requestContextStack, deviceContext, GetAllMeterConfigStatisticsOutput.class);
+ }
+
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final GetAllMeterConfigStatisticsInput input) {
+ MultipartRequestInputBuilder mprInput = RequestInputUtils
+ .createMultipartHeader(MultipartType.OFPMPMETERCONFIG, xid.getValue(), getVersion());
+ return mprInput.setMultipartRequestBody(METER_CONFIG_CASE).build();
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowjava.protocol.api.util.BinContent;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Meter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter._case.MultipartRequestMeterBuilder;
+
+final class AllMeterStatsService extends AbstractSimpleService<GetAllMeterStatisticsInput, GetAllMeterStatisticsOutput> {
+ private static final MultipartRequestMeterCase METER_CASE;
+
+ static {
+ MultipartRequestMeterCaseBuilder caseBuilder =
+ new MultipartRequestMeterCaseBuilder();
+ MultipartRequestMeterBuilder mprMeterBuild =
+ new MultipartRequestMeterBuilder();
+ mprMeterBuild.setMeterId(new MeterId(BinContent.intToUnsignedLong(Meter.OFPMALL.getIntValue())));
+ caseBuilder.setMultipartRequestMeter(mprMeterBuild.build());
+
+ METER_CASE = caseBuilder.build();
+ }
+
+ AllMeterStatsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ super(requestContextStack, deviceContext, GetAllMeterStatisticsOutput.class);
+ }
+
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final GetAllMeterStatisticsInput input) {
+ MultipartRequestInputBuilder mprInput = RequestInputUtils
+ .createMultipartHeader(MultipartType.OFPMPMETER, xid.getValue(), getVersion());
+ return mprInput.setMultipartRequestBody(METER_CASE).build();
+ }
+
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutput;
+
+final class AllPortStatsService extends AbstractSimpleService<GetAllNodeConnectorsStatisticsInput, GetAllNodeConnectorsStatisticsOutput> {
+ private static final MultipartRequestPortStatsCase PORT_STATS_CASE;
+
+ static {
+ MultipartRequestPortStatsCaseBuilder caseBuilder =
+ new MultipartRequestPortStatsCaseBuilder();
+ MultipartRequestPortStatsBuilder mprPortStatsBuilder =
+ new MultipartRequestPortStatsBuilder();
+ // Select all ports
+ mprPortStatsBuilder.setPortNo(OFConstants.OFPP_ANY);
+ caseBuilder.setMultipartRequestPortStats(mprPortStatsBuilder.build());
+
+ PORT_STATS_CASE = caseBuilder.build();
+ }
+
+ AllPortStatsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ super(requestContextStack, deviceContext, GetAllNodeConnectorsStatisticsOutput.class);
+ }
+
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final GetAllNodeConnectorsStatisticsInput input) {
+ MultipartRequestInputBuilder mprInput = RequestInputUtils
+ .createMultipartHeader(MultipartType.OFPMPPORTSTATS, xid.getValue(), getVersion());
+ mprInput.setMultipartRequestBody(PORT_STATS_CASE);
+ return mprInput.build();
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutput;
+
+final class AllQueuesAllPortsService extends AbstractSimpleService<GetAllQueuesStatisticsFromAllPortsInput, GetAllQueuesStatisticsFromAllPortsOutput> {
+ private static final MultipartRequestQueueCase QUEUE_CASE;
+
+ static {
+ MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
+ MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
+ // Select all ports
+ // Select all the ports
+ mprQueueBuilder.setQueueId(OFConstants.OFPQ_ALL);
+ mprQueueBuilder.setPortNo(OFConstants.OFPP_ANY);
+ caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
+
+ QUEUE_CASE = caseBuilder.build();
+ }
+
+ AllQueuesAllPortsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ super(requestContextStack, deviceContext, GetAllQueuesStatisticsFromAllPortsOutput.class);
+ }
+
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final GetAllQueuesStatisticsFromAllPortsInput input) {
+ // Set request body to main multipart request
+ MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+ MultipartType.OFPMPQUEUE, xid.getValue(), getVersion());
+ mprInput.setMultipartRequestBody(QUEUE_CASE);
+ return mprInput.build();
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortOutput;
+
+final class AllQueuesOnePortService extends AbstractSimpleService<GetAllQueuesStatisticsFromGivenPortInput, GetAllQueuesStatisticsFromGivenPortOutput> {
+ AllQueuesOnePortService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ super(requestContextStack, deviceContext, GetAllQueuesStatisticsFromGivenPortOutput.class);
+ }
+
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final GetAllQueuesStatisticsFromGivenPortInput input) {
+ MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
+ MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
+ // Select all queues
+ // Select specific port
+ final short version = getVersion();
+ mprQueueBuilder.setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(
+ OpenflowVersion.get(version), input.getNodeConnectorId()));
+
+ mprQueueBuilder.setQueueId(OFConstants.OFPQ_ALL);
+ caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
+
+ // Set request body to main multipart request
+ MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+ MultipartType.OFPMPQUEUE, xid.getValue(), version);
+ mprInput.setMultipartRequestBody(caseBuilder.build());
+
+ return mprInput.build();
+ }
+
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
+
+final class FlowsInTableService extends AbstractSimpleService<GetFlowStatisticsFromFlowTableInput, GetFlowStatisticsFromFlowTableOutput> {
+ FlowsInTableService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ super(requestContextStack, deviceContext, GetFlowStatisticsFromFlowTableOutput.class);
+ }
+
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final GetFlowStatisticsFromFlowTableInput input) {
+ final MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
+ final MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
+ mprFlowRequestBuilder.setTableId(input.getTableId());
+
+ if (input.getOutPort() != null) {
+ mprFlowRequestBuilder.setOutPort(input.getOutPort().longValue());
+ } else {
+ mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
+ }
+
+ if (input.getOutGroup() != null) {
+ mprFlowRequestBuilder.setOutGroup(input.getOutGroup());
+ } else {
+ mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
+ }
+
+ if (input.getCookie() != null) {
+ mprFlowRequestBuilder.setCookie(input.getCookie().getValue());
+ } else {
+ mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
+ }
+
+ if (input.getCookieMask() != null) {
+ mprFlowRequestBuilder.setCookieMask(input.getCookieMask().getValue());
+ } else {
+ mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
+ }
+
+ // convert and inject match
+ final short version = getVersion();
+ final DeviceContext deviceContext = getDeviceContext();
+ MatchReactor.getInstance().convert(input.getMatch(), version, mprFlowRequestBuilder,
+ deviceContext.getPrimaryConnectionContext().getFeatures().getDatapathId());
+
+ // Set request body to main multipart request
+ multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
+ final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+ MultipartType.OFPMPFLOW, xid.getValue(), version);
+ mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
+
+ return mprInput.build();
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupDescCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupDescCaseBuilder;
+
+final class GroupDescriptionService extends AbstractSimpleService<GetGroupDescriptionInput, GetGroupDescriptionOutput> {
+ private static final MultipartRequestGroupDescCase GROUP_DESC_CASE = new MultipartRequestGroupDescCaseBuilder().build();
+
+ GroupDescriptionService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ super(requestContextStack, deviceContext, GetGroupDescriptionOutput.class);
+ }
+
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final GetGroupDescriptionInput input) {
+ final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+ MultipartType.OFPMPGROUPDESC, xid.getValue(), getVersion());
+ mprInput.setMultipartRequestBody(GROUP_DESC_CASE);
+ return mprInput.build();
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupFeaturesCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupFeaturesCaseBuilder;
+
+final class GroupFeaturesService extends AbstractSimpleService<GetGroupFeaturesInput, GetGroupFeaturesOutput> {
+ private static final MultipartRequestGroupFeaturesCase GROUP_FEAT_CASE =
+ new MultipartRequestGroupFeaturesCaseBuilder().build();
+
+ GroupFeaturesService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ super(requestContextStack, deviceContext, GetGroupFeaturesOutput.class);
+ }
+
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final GetGroupFeaturesInput input) {
+ final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+ MultipartType.OFPMPGROUPFEATURES, xid.getValue(), getVersion());
+ mprInput.setMultipartRequestBody(GROUP_FEAT_CASE);
+ return mprInput.build();
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroupBuilder;
+
+final class GroupStatsService extends AbstractSimpleService<GetGroupStatisticsInput, GetGroupStatisticsOutput> {
+ GroupStatsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ super(requestContextStack, deviceContext, GetGroupStatisticsOutput.class);
+ }
+
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final GetGroupStatisticsInput input) {
+ final MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder();
+ final MultipartRequestGroupBuilder mprGroupBuild = new MultipartRequestGroupBuilder();
+ mprGroupBuild.setGroupId(new GroupId(input.getGroupId().getValue()));
+ caseBuilder.setMultipartRequestGroup(mprGroupBuild.build());
+
+ final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+ MultipartType.OFPMPGROUP, xid.getValue(), getVersion());
+
+ mprInput.setMultipartRequestBody(caseBuilder.build());
+ return mprInput.build();
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import com.google.common.base.MoreObjects;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractMultipartService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
+import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder;
+
+final class MatchingFlowsInTableService extends AbstractMultipartService<GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput> {
+
+ public MatchingFlowsInTableService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ super(requestContextStack, deviceContext);
+ }
+
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) {
+ final DeviceContext deviceContext = getDeviceContext();
+ final MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder = new MultipartRequestAggregateCaseBuilder();
+ final MultipartRequestAggregateBuilder mprAggregateRequestBuilder = new MultipartRequestAggregateBuilder();
+ final short tableId = MoreObjects.firstNonNull(input.getTableId(), OFConstants.OFPTT_ALL).shortValue();
+ mprAggregateRequestBuilder.setTableId(tableId);
+ long outputPortValue = MoreObjects.firstNonNull(input.getOutPort(), OFConstants.OFPP_ANY).longValue();
+ mprAggregateRequestBuilder.setOutPort(outputPortValue);
+ // TODO: repeating code
+
+ final short version = getVersion();
+ if (version == OFConstants.OFP_VERSION_1_3) {
+
+ if (input.getCookie() == null) {
+ mprAggregateRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
+ } else {
+ mprAggregateRequestBuilder.setCookie(MoreObjects.firstNonNull(input.getCookie().getValue(), OFConstants.DEFAULT_COOKIE));
+ }
+
+ if (input.getCookieMask() == null) {
+ mprAggregateRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
+ } else {
+ mprAggregateRequestBuilder.setCookieMask(MoreObjects.firstNonNull(input.getCookieMask().getValue(), OFConstants.DEFAULT_COOKIE_MASK));
+ }
+ long outGroup = MoreObjects.firstNonNull(input.getOutGroup(), OFConstants.OFPG_ANY).longValue();
+ mprAggregateRequestBuilder.setOutGroup(outGroup);
+ } else {
+ mprAggregateRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
+ mprAggregateRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
+ mprAggregateRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
+ }
+
+ MatchReactor.getInstance().convert(input.getMatch(), version, mprAggregateRequestBuilder,
+ deviceContext.getPrimaryConnectionContext().getFeatures().getDatapathId());
+
+ FlowCreatorUtil.setWildcardedFlowMatch(version, mprAggregateRequestBuilder);
+
+ // Set request body to main multipart request
+ multipartRequestAggregateCaseBuilder.setMultipartRequestAggregate(mprAggregateRequestBuilder
+ .build());
+
+ final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+ MultipartType.OFPMPAGGREGATE, xid.getValue(), version);
+
+ mprInput.setMultipartRequestBody(multipartRequestAggregateCaseBuilder.build());
+
+ return mprInput.build();
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterFeaturesCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterFeaturesCaseBuilder;
+
+final class MeterFeaturesService extends AbstractSimpleService<GetMeterFeaturesInput, GetMeterFeaturesOutput> {
+ private static final MultipartRequestMeterFeaturesCase METER_FEATURES_CASE = new MultipartRequestMeterFeaturesCaseBuilder().build();
+
+ protected MeterFeaturesService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ super(requestContextStack, deviceContext, GetMeterFeaturesOutput.class);
+ }
+
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final GetMeterFeaturesInput input) {
+ MultipartRequestInputBuilder mprInput =
+ RequestInputUtils.createMultipartHeader(MultipartType.OFPMPMETERFEATURES, xid.getValue(), getVersion());
+ mprInput.setMultipartRequestBody(METER_FEATURES_CASE);
+ return mprInput.build();
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter._case.MultipartRequestMeterBuilder;
+
+final class MeterStatsService extends AbstractSimpleService<GetMeterStatisticsInput, GetMeterStatisticsOutput> {
+
+ MeterStatsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ super(requestContextStack, deviceContext, GetMeterStatisticsOutput.class);
+ }
+
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final GetMeterStatisticsInput input) {
+ MultipartRequestMeterCaseBuilder caseBuilder =
+ new MultipartRequestMeterCaseBuilder();
+ MultipartRequestMeterBuilder mprMeterBuild =
+ new MultipartRequestMeterBuilder();
+ mprMeterBuild.setMeterId(new MeterId(input.getMeterId().getValue()));
+ caseBuilder.setMultipartRequestMeter(mprMeterBuild.build());
+
+ MultipartRequestInputBuilder mprInput =
+ RequestInputUtils.createMultipartHeader(MultipartType.OFPMPMETER, xid.getValue(), getVersion());
+ mprInput.setMultipartRequestBody(caseBuilder.build());
+ return mprInput.build();
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortOutput;
+
+final class OneQueueOnePortService extends AbstractSimpleService<GetQueueStatisticsFromGivenPortInput, GetQueueStatisticsFromGivenPortOutput> {
+ OneQueueOnePortService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ super(requestContextStack, deviceContext, GetQueueStatisticsFromGivenPortOutput.class);
+ }
+
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final GetQueueStatisticsFromGivenPortInput input) {
+ MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
+ MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
+ // Select specific queue
+ mprQueueBuilder.setQueueId(input.getQueueId().getValue());
+ // Select specific port
+ final short version = getVersion();
+ mprQueueBuilder.setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(
+ OpenflowVersion.get(version), input.getNodeConnectorId()));
+ caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
+
+ // Set request body to main multipart request
+ MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+ MultipartType.OFPMPQUEUE, xid.getValue(), version);
+ mprInput.setMultipartRequestBody(caseBuilder.build());
+ return mprInput.build();
+ }
+}
package org.opendaylight.openflowplugin.impl.statistics.services;
import com.google.common.base.Function;
-import com.google.common.base.MoreObjects;
import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Future;
-import javax.annotation.Nullable;
-import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary;
-import org.opendaylight.openflowplugin.api.openflow.device.Xid;
import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey;
-import org.opendaylight.openflowplugin.impl.services.CommonService;
-import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
-import org.opendaylight.openflowplugin.impl.util.StatisticsServiceUtil;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
-import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatistics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.slf4j.Logger;
/**
* @author joe
*/
-public class OpendaylightFlowStatisticsServiceImpl extends CommonService implements OpendaylightFlowStatisticsService {
-
+public class OpendaylightFlowStatisticsServiceImpl implements OpendaylightFlowStatisticsService {
private static final Logger LOG = LoggerFactory.getLogger(OpendaylightFlowStatisticsServiceImpl.class);
- public OpendaylightFlowStatisticsServiceImpl(final RequestContextStack requestContextStack, DeviceContext deviceContext) {
- super(requestContextStack, deviceContext);
- }
-
- @Override
- public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> getAggregateFlowStatisticsFromFlowTableForAllFlows(
- final GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input) {
-
-
- return handleServiceCall(
- new Function<RequestContext<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>,
- ListenableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>>>() {
-
- @Override
- public ListenableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> apply(final RequestContext<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput> requestContext) {
-
- // Create multipart request body for fetch all the group stats
- final MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder = new MultipartRequestAggregateCaseBuilder();
- final MultipartRequestAggregateBuilder mprAggregateRequestBuilder = new MultipartRequestAggregateBuilder();
- mprAggregateRequestBuilder.setTableId(input.getTableId().getValue());
- mprAggregateRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
- mprAggregateRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
- mprAggregateRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
- mprAggregateRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
- final short version = getVersion();
- FlowCreatorUtil.setWildcardedFlowMatch(version, mprAggregateRequestBuilder);
+ private final Function<RpcResult<List<MultipartReply>>, RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> matchingConvertor =
+ new Function<RpcResult<List<MultipartReply>>, RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>>() {
+ @Override
+ public RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput> apply(final RpcResult<List<MultipartReply>> input) {
+ final DeviceContext deviceContext = matchingFlowsInTable.getDeviceContext();
+ TranslatorLibrary translatorLibrary = deviceContext.oook();
+ RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput> rpcResult;
+ if (input.isSuccessful()) {
+ MultipartReply reply = input.getResult().get(0);
+ final TranslatorKey translatorKey = new TranslatorKey(reply.getVersion(), MultipartReplyAggregateCase.class.getName());
+ final MessageTranslator<MultipartReply, AggregatedFlowStatistics> messageTranslator = translatorLibrary.lookupTranslator(translatorKey);
+ List<AggregatedFlowStatistics> aggregStats = new ArrayList<AggregatedFlowStatistics>();
+
+ for (MultipartReply multipartReply : input.getResult()) {
+ aggregStats.add(messageTranslator.translate(multipartReply, deviceContext, null));
+ }
- // Set request body to main multipart request
- multipartRequestAggregateCaseBuilder.setMultipartRequestAggregate(mprAggregateRequestBuilder
- .build());
- final Xid xid = requestContext.getXid();
- final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
- MultipartType.OFPMPAGGREGATE, xid.getValue(), version);
+ GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder getAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder =
+ new GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder();
+ getAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder.setAggregatedFlowStatistics(aggregStats);
- mprInput.setMultipartRequestBody(multipartRequestAggregateCaseBuilder.build());
+ rpcResult = RpcResultBuilder
+ .<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>success()
+ .withResult(getAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder.build())
+ .build();
- return StatisticsServiceUtil.getRpcResultListenableFuture(xid, mprInput.build(), getDeviceContext());
+ } else {
+ rpcResult = RpcResultBuilder
+ .<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>failed()
+ .withRpcErrors(input.getErrors())
+ .build();
}
- });
+ return rpcResult;
+ }
+ };
+
+ private final AggregateFlowsInTableService aggregateFlowsInTable;
+ private final MatchingFlowsInTableService matchingFlowsInTable;
+ private final AllFlowsInAllTablesService allFlowsInAllTables;
+ private final AllFlowsInTableService allFlowsInTable;
+ private final FlowsInTableService flowsInTable;
+
+ public OpendaylightFlowStatisticsServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ aggregateFlowsInTable = new AggregateFlowsInTableService(requestContextStack, deviceContext);
+ allFlowsInAllTables = new AllFlowsInAllTablesService(requestContextStack, deviceContext);
+ allFlowsInTable = new AllFlowsInTableService(requestContextStack, deviceContext);
+ flowsInTable = new FlowsInTableService(requestContextStack, deviceContext);
+ matchingFlowsInTable = new MatchingFlowsInTableService(requestContextStack, deviceContext);
+ }
+ @Override
+ public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> getAggregateFlowStatisticsFromFlowTableForAllFlows(
+ final GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input) {
+ return aggregateFlowsInTable.handleServiceCall(input);
}
@Override
public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> getAggregateFlowStatisticsFromFlowTableForGivenMatch(
final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) {
-
-
- ListenableFuture<RpcResult<List<MultipartReply>>> rpcResultListenableFuture = handleServiceCall(
- new Function<RequestContext<List<MultipartReply>>, ListenableFuture<RpcResult<List<MultipartReply>>>>() {
-
- @Override
- public ListenableFuture<RpcResult<List<MultipartReply>>> apply(final RequestContext<List<MultipartReply>> requestContext) {
- final Xid xid = requestContext.getXid();
- final DeviceContext deviceContext = getDeviceContext();
- deviceContext.getMultiMsgCollector().registerMultipartRequestContext(requestContext);
- final MultipartRequestAggregateCaseBuilder multipartRequestAggregateCaseBuilder = new MultipartRequestAggregateCaseBuilder();
- final MultipartRequestAggregateBuilder mprAggregateRequestBuilder = new MultipartRequestAggregateBuilder();
- final short tableId = MoreObjects.firstNonNull(input.getTableId(), OFConstants.OFPTT_ALL).shortValue();
- mprAggregateRequestBuilder.setTableId(tableId);
- long outputPortValue = MoreObjects.firstNonNull(input.getOutPort(), OFConstants.OFPP_ANY).longValue();
- mprAggregateRequestBuilder.setOutPort(outputPortValue);
- // TODO: repeating code
-
- final short version = getVersion();
- if (version == OFConstants.OFP_VERSION_1_3) {
-
- if (input.getCookie() == null) {
- mprAggregateRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
- } else {
- mprAggregateRequestBuilder.setCookie(MoreObjects.firstNonNull(input.getCookie().getValue(), OFConstants.DEFAULT_COOKIE));
- }
-
- if (input.getCookieMask() == null) {
- mprAggregateRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
- } else {
- mprAggregateRequestBuilder.setCookieMask(MoreObjects.firstNonNull(input.getCookieMask().getValue(), OFConstants.DEFAULT_COOKIE_MASK));
- }
- long outGroup = MoreObjects.firstNonNull(input.getOutGroup(), OFConstants.OFPG_ANY).longValue();
- mprAggregateRequestBuilder.setOutGroup(outGroup);
- } else {
- mprAggregateRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
- mprAggregateRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
- mprAggregateRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
- }
-
- MatchReactor.getInstance().convert(input.getMatch(), version, mprAggregateRequestBuilder,
- deviceContext.getPrimaryConnectionContext().getFeatures().getDatapathId());
-
- FlowCreatorUtil.setWildcardedFlowMatch(version, mprAggregateRequestBuilder);
-
- // Set request body to main multipart request
- multipartRequestAggregateCaseBuilder.setMultipartRequestAggregate(mprAggregateRequestBuilder
- .build());
-
- final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
- MultipartType.OFPMPAGGREGATE, xid.getValue(), version);
-
- mprInput.setMultipartRequestBody(multipartRequestAggregateCaseBuilder.build());
- return StatisticsServiceUtil.getRpcResultListenableFuture(xid, mprInput.build(), getDeviceContext());
- }
- });
-
- return Futures.transform(rpcResultListenableFuture, new Function<RpcResult<List<MultipartReply>>, RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>>() {
- @Nullable
- @Override
- public RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput> apply(RpcResult<List<MultipartReply>> input) {
- final DeviceContext deviceContext = getDeviceContext();
- TranslatorLibrary translatorLibrary = deviceContext.oook();
- RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput> rpcResult;
- if (input.isSuccessful()) {
- MultipartReply reply = input.getResult().get(0);
- final TranslatorKey translatorKey = new TranslatorKey(reply.getVersion(), MultipartReplyAggregateCase.class.getName());
- final MessageTranslator<MultipartReply, AggregatedFlowStatistics> messageTranslator = translatorLibrary.lookupTranslator(translatorKey);
- List<AggregatedFlowStatistics> aggregStats = new ArrayList<AggregatedFlowStatistics>();
-
- for (MultipartReply multipartReply : input.getResult()) {
- aggregStats.add(messageTranslator.translate(multipartReply, deviceContext, null));
- }
-
- GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder getAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder =
- new GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder();
- getAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder.setAggregatedFlowStatistics(aggregStats);
-
- rpcResult = RpcResultBuilder
- .<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>success()
- .withResult(getAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder.build())
- .build();
-
- } else {
- rpcResult = RpcResultBuilder
- .<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>failed()
- .withRpcErrors(input.getErrors())
- .build();
- }
- return rpcResult;
- }
- });
-
+ return Futures.transform(matchingFlowsInTable.handleServiceCall(input), matchingConvertor);
}
@Override
public Future<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> getAllFlowStatisticsFromFlowTable(
final GetAllFlowStatisticsFromFlowTableInput input) {
-
- return handleServiceCall(new Function<RequestContext<GetAllFlowStatisticsFromFlowTableOutput>,
- ListenableFuture<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>>>() {
-
- @Override
- public ListenableFuture<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> apply(final RequestContext<GetAllFlowStatisticsFromFlowTableOutput> requestContext) {
-
- final MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
- mprFlowRequestBuilder.setTableId(input.getTableId().getValue());
- mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
- mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
- mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
- mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
-
- final short version = getVersion();
- FlowCreatorUtil.setWildcardedFlowMatch(version, mprFlowRequestBuilder);
-
- final MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
- multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
-
- final Xid xid = requestContext.getXid();
- final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
- MultipartType.OFPMPFLOW, xid.getValue(), version);
-
- mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
- return StatisticsServiceUtil.getRpcResultListenableFuture(xid, mprInput.build(), getDeviceContext());
- }
- });
+ return allFlowsInTable.handleServiceCall(input);
}
@Override
public Future<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> getAllFlowsStatisticsFromAllFlowTables(
final GetAllFlowsStatisticsFromAllFlowTablesInput input) {
-
-
- return handleServiceCall(new Function<RequestContext<GetAllFlowsStatisticsFromAllFlowTablesOutput>,
- ListenableFuture<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>>>() {
-
- @Override
- public ListenableFuture<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> apply(final RequestContext<GetAllFlowsStatisticsFromAllFlowTablesOutput> requestContext) {
-
- final MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
- final MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
- mprFlowRequestBuilder.setTableId(OFConstants.OFPTT_ALL);
- mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
- mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
- mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
- mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
- final short version = getVersion();
- FlowCreatorUtil.setWildcardedFlowMatch(version, mprFlowRequestBuilder);
-
- final Xid xid = requestContext.getXid();
- final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
- MultipartType.OFPMPFLOW, xid.getValue(), version);
-
- multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
- mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
- return StatisticsServiceUtil.getRpcResultListenableFuture(xid, mprInput.build(), getDeviceContext());
- }
- });
+ return allFlowsInAllTables.handleServiceCall(input);
}
@Override
public Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> getFlowStatisticsFromFlowTable(
final GetFlowStatisticsFromFlowTableInput input) {
-
-
- return handleServiceCall(new Function<RequestContext<GetFlowStatisticsFromFlowTableOutput>, ListenableFuture<RpcResult<GetFlowStatisticsFromFlowTableOutput>>>() {
-
- @Override
- public ListenableFuture<RpcResult<GetFlowStatisticsFromFlowTableOutput>> apply(final RequestContext<GetFlowStatisticsFromFlowTableOutput> requestContext) {
-
- final MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
- final MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
- mprFlowRequestBuilder.setTableId(input.getTableId());
-
- if (input.getOutPort() != null) {
- mprFlowRequestBuilder.setOutPort(input.getOutPort().longValue());
- } else {
- mprFlowRequestBuilder.setOutPort(OFConstants.OFPP_ANY);
- }
-
- if (input.getOutGroup() != null) {
- mprFlowRequestBuilder.setOutGroup(input.getOutGroup());
- } else {
- mprFlowRequestBuilder.setOutGroup(OFConstants.OFPG_ANY);
- }
-
- if (input.getCookie() != null) {
- mprFlowRequestBuilder.setCookie(input.getCookie().getValue());
- } else {
- mprFlowRequestBuilder.setCookie(OFConstants.DEFAULT_COOKIE);
- }
-
- if (input.getCookieMask() != null) {
- mprFlowRequestBuilder.setCookieMask(input.getCookieMask().getValue());
- } else {
- mprFlowRequestBuilder.setCookieMask(OFConstants.DEFAULT_COOKIE_MASK);
- }
-
- // convert and inject match
- final short version = getVersion();
- final DeviceContext deviceContext = getDeviceContext();
- MatchReactor.getInstance().convert(input.getMatch(), version, mprFlowRequestBuilder,
- deviceContext.getPrimaryConnectionContext().getFeatures().getDatapathId());
-
- // Set request body to main multipart request
- final Xid xid = requestContext.getXid();
- multipartRequestFlowCaseBuilder.setMultipartRequestFlow(mprFlowRequestBuilder.build());
- final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
- MultipartType.OFPMPFLOW, xid.getValue(), version);
- mprInput.setMultipartRequestBody(multipartRequestFlowCaseBuilder.build());
- return StatisticsServiceUtil.getRpcResultListenableFuture(xid, mprInput.build(), getDeviceContext());
- }
- });
+ return flowsInTable.handleServiceCall(input);
}
-
}
*/
package org.opendaylight.openflowplugin.impl.statistics.services;
-import com.google.common.base.Function;
-import com.google.common.util.concurrent.ListenableFuture;
import java.util.concurrent.Future;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.impl.services.CommonService;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
-import org.opendaylight.openflowplugin.impl.util.StatisticsServiceUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
-/**
- * @author joe
- */
-public class OpendaylightFlowTableStatisticsServiceImpl extends CommonService implements
+public final class OpendaylightFlowTableStatisticsServiceImpl extends AbstractSimpleService<GetFlowTablesStatisticsInput, GetFlowTablesStatisticsOutput> implements
OpendaylightFlowTableStatisticsService {
- public OpendaylightFlowTableStatisticsServiceImpl(final RequestContextStack requestContextStack, DeviceContext deviceContext) {
- super(requestContextStack, deviceContext);
+ public OpendaylightFlowTableStatisticsServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ super(requestContextStack, deviceContext, GetFlowTablesStatisticsOutput.class);
}
@Override
public Future<RpcResult<GetFlowTablesStatisticsOutput>> getFlowTablesStatistics(
final GetFlowTablesStatisticsInput input) {
+ return handleServiceCall(input);
+ }
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final GetFlowTablesStatisticsInput input) {
+ // Create multipart request body for fetch all the group stats
+ final MultipartRequestTableCaseBuilder multipartRequestTableCaseBuilder = new MultipartRequestTableCaseBuilder();
+ final MultipartRequestTableBuilder multipartRequestTableBuilder = new MultipartRequestTableBuilder();
+ multipartRequestTableBuilder.setEmpty(true);
+ multipartRequestTableCaseBuilder.setMultipartRequestTable(multipartRequestTableBuilder.build());
- return handleServiceCall(new Function<RequestContext<GetFlowTablesStatisticsOutput>,
- ListenableFuture<RpcResult<GetFlowTablesStatisticsOutput>>>() {
-
- @Override
- public ListenableFuture<RpcResult<GetFlowTablesStatisticsOutput>> apply(final RequestContext<GetFlowTablesStatisticsOutput> requestContext) {
-
- // Create multipart request body for fetch all the group stats
- final MultipartRequestTableCaseBuilder multipartRequestTableCaseBuilder = new MultipartRequestTableCaseBuilder();
- final MultipartRequestTableBuilder multipartRequestTableBuilder = new MultipartRequestTableBuilder();
- multipartRequestTableBuilder.setEmpty(true);
- multipartRequestTableCaseBuilder.setMultipartRequestTable(multipartRequestTableBuilder.build());
+ // Set request body to main multipart request
+ final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
+ MultipartType.OFPMPFLOW, xid.getValue(), getVersion());
- // Set request body to main multipart request
- final Xid xid = requestContext.getXid();
- final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
- MultipartType.OFPMPFLOW, xid.getValue(), getVersion());
+ mprInput.setMultipartRequestBody(multipartRequestTableCaseBuilder.build());
- mprInput.setMultipartRequestBody(multipartRequestTableCaseBuilder.build());
- return StatisticsServiceUtil.getRpcResultListenableFuture(xid, mprInput.build(), getDeviceContext());
- }
- });
+ return mprInput.build();
}
-
}
*/
package org.opendaylight.openflowplugin.impl.statistics.services;
-import com.google.common.base.Function;
-import com.google.common.util.concurrent.ListenableFuture;
import java.util.concurrent.Future;
-import org.opendaylight.openflowjava.protocol.api.util.BinContent;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
-import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.impl.services.CommonService;
-import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
-import org.opendaylight.openflowplugin.impl.util.StatisticsServiceUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupDescCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupFeaturesCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroupBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
/**
* @author joe
*/
-public class OpendaylightGroupStatisticsServiceImpl extends CommonService implements OpendaylightGroupStatisticsService {
-
-
- public OpendaylightGroupStatisticsServiceImpl(final RequestContextStack requestContextStack, DeviceContext deviceContext) {
- super(requestContextStack, deviceContext);
+public class OpendaylightGroupStatisticsServiceImpl implements OpendaylightGroupStatisticsService {
+ private final AllGroupsStatsService allGroups;
+ private final GroupDescriptionService groupDesc;
+ private final GroupFeaturesService groupFeat;
+ private final GroupStatsService groupStats;
+
+ public OpendaylightGroupStatisticsServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ allGroups = new AllGroupsStatsService(requestContextStack, deviceContext);
+ groupDesc = new GroupDescriptionService(requestContextStack, deviceContext);
+ groupFeat = new GroupFeaturesService(requestContextStack, deviceContext);
+ groupStats = new GroupStatsService(requestContextStack, deviceContext);
}
@Override
public Future<RpcResult<GetAllGroupStatisticsOutput>> getAllGroupStatistics(final GetAllGroupStatisticsInput input) {
-
-
- return handleServiceCall(new Function<RequestContext<GetAllGroupStatisticsOutput>,
- ListenableFuture<RpcResult<GetAllGroupStatisticsOutput>>>() {
-
- @Override
- public ListenableFuture<RpcResult<GetAllGroupStatisticsOutput>> apply(final RequestContext<GetAllGroupStatisticsOutput> requestContext) {
-
- final MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder();
- final MultipartRequestGroupBuilder mprGroupBuild = new MultipartRequestGroupBuilder();
- mprGroupBuild.setGroupId(new GroupId(
- BinContent
- .intToUnsignedLong(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Group.OFPGALL
- .getIntValue())));
- caseBuilder.setMultipartRequestGroup(mprGroupBuild.build());
-
- // Create multipart request header
- final Xid xid = requestContext.getXid();
- final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
- MultipartType.OFPMPGROUP, xid.getValue(), getVersion());
-
- // Set request body to main multipart request
- mprInput.setMultipartRequestBody(caseBuilder.build());
-
- // Send the request, no cookies associated, use any connection
-
- MultipartRequestInput multipartRequestInput = mprInput.build();
-
- return StatisticsServiceUtil.getRpcResultListenableFuture(xid, multipartRequestInput, getDeviceContext());
- }
- });
-
+ return allGroups.handleServiceCall(input);
}
-
@Override
public Future<RpcResult<GetGroupDescriptionOutput>> getGroupDescription(final GetGroupDescriptionInput input) {
- return handleServiceCall(
- new Function<RequestContext<GetGroupDescriptionOutput>,
- ListenableFuture<RpcResult<GetGroupDescriptionOutput>>>() {
-
- @Override
- public ListenableFuture<RpcResult<GetGroupDescriptionOutput>> apply(final RequestContext<GetGroupDescriptionOutput> requestContext) {
- final MultipartRequestGroupDescCaseBuilder mprGroupDescCaseBuild = new MultipartRequestGroupDescCaseBuilder();
-
- final Xid xid = requestContext.getXid();
- final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
- MultipartType.OFPMPGROUPDESC, xid.getValue(), getVersion());
- mprInput.setMultipartRequestBody(mprGroupDescCaseBuild.build());
- MultipartRequestInput multipartRequestInput = mprInput.build();
- return StatisticsServiceUtil.getRpcResultListenableFuture(xid, multipartRequestInput, getDeviceContext());
- }
- });
-
+ return groupDesc.handleServiceCall(input);
}
@Override
public Future<RpcResult<GetGroupFeaturesOutput>> getGroupFeatures(final GetGroupFeaturesInput input) {
- return handleServiceCall(
- new Function<RequestContext<GetGroupFeaturesOutput>,
- ListenableFuture<RpcResult<GetGroupFeaturesOutput>>>() {
-
- @Override
- public ListenableFuture<RpcResult<GetGroupFeaturesOutput>> apply(final RequestContext<GetGroupFeaturesOutput> requestContext) {
- final MultipartRequestGroupFeaturesCaseBuilder mprGroupFeaturesBuild = new MultipartRequestGroupFeaturesCaseBuilder();
-
- final Xid xid = requestContext.getXid();
- final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
- MultipartType.OFPMPGROUPFEATURES, xid.getValue(), getVersion());
- mprInput.setMultipartRequestBody(mprGroupFeaturesBuild.build());
- MultipartRequestInput multipartRequestInput = mprInput.build();
- return StatisticsServiceUtil.getRpcResultListenableFuture(xid, multipartRequestInput, getDeviceContext());
- }
- });
-
+ return groupFeat.handleServiceCall(input);
}
@Override
public Future<RpcResult<GetGroupStatisticsOutput>> getGroupStatistics(final GetGroupStatisticsInput input) {
- return handleServiceCall(
- new Function<RequestContext<GetGroupStatisticsOutput>, ListenableFuture<RpcResult<GetGroupStatisticsOutput>>>() {
-
- @Override
- public ListenableFuture<RpcResult<GetGroupStatisticsOutput>> apply(final RequestContext<GetGroupStatisticsOutput> requestContext) {
-
- final MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder();
- final MultipartRequestGroupBuilder mprGroupBuild = new MultipartRequestGroupBuilder();
- mprGroupBuild.setGroupId(new GroupId(input.getGroupId().getValue()));
- caseBuilder.setMultipartRequestGroup(mprGroupBuild.build());
-
- final Xid xid = requestContext.getXid();
- final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
- MultipartType.OFPMPGROUP, xid.getValue(), getVersion());
-
- mprInput.setMultipartRequestBody(caseBuilder.build());
- MultipartRequestInput multipartRequestInput = mprInput.build();
- return StatisticsServiceUtil.getRpcResultListenableFuture(xid, multipartRequestInput, getDeviceContext());
- }
- });
+ return groupStats.handleServiceCall(input);
}
-
}
*/
package org.opendaylight.openflowplugin.impl.statistics.services;
-import com.google.common.base.Function;
-import com.google.common.util.concurrent.ListenableFuture;
import java.util.concurrent.Future;
-import org.opendaylight.openflowjava.protocol.api.util.BinContent;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
-import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.impl.services.CommonService;
-import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
-import org.opendaylight.openflowplugin.impl.util.StatisticsServiceUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfigCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterFeaturesCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter._case.MultipartRequestMeterBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter.config._case.MultipartRequestMeterConfigBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;
-/**
- * @author joe
- */
-public class OpendaylightMeterStatisticsServiceImpl extends CommonService implements OpendaylightMeterStatisticsService {
-
-
- public OpendaylightMeterStatisticsServiceImpl(final RequestContextStack requestContextStack, DeviceContext deviceContext) {
- super(requestContextStack, deviceContext);
+public class OpendaylightMeterStatisticsServiceImpl implements OpendaylightMeterStatisticsService {
+ private final AllMeterConfigStatsService allMeterConfig;
+ private final AllMeterStatsService allMeterStats;
+ private final MeterFeaturesService meterFeatures;
+ private final MeterStatsService meterStats;
+
+ public OpendaylightMeterStatisticsServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ allMeterConfig = new AllMeterConfigStatsService(requestContextStack, deviceContext);
+ allMeterStats = new AllMeterStatsService(requestContextStack, deviceContext);
+ meterFeatures = new MeterFeaturesService(requestContextStack, deviceContext);
+ meterStats = new MeterStatsService(requestContextStack, deviceContext);
}
@Override
public Future<RpcResult<GetAllMeterConfigStatisticsOutput>> getAllMeterConfigStatistics(
final GetAllMeterConfigStatisticsInput input) {
- return handleServiceCall(new Function<RequestContext<GetAllMeterConfigStatisticsOutput>,
- ListenableFuture<RpcResult<GetAllMeterConfigStatisticsOutput>>>() {
-
- @Override
- public ListenableFuture<RpcResult<GetAllMeterConfigStatisticsOutput>> apply(final RequestContext<GetAllMeterConfigStatisticsOutput> requestContext) {
-
- MultipartRequestMeterConfigCaseBuilder caseBuilder =
- new MultipartRequestMeterConfigCaseBuilder();
- MultipartRequestMeterConfigBuilder mprMeterConfigBuild =
- new MultipartRequestMeterConfigBuilder();
- mprMeterConfigBuild.setMeterId(new MeterId(BinContent.intToUnsignedLong(
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common
- .types.rev130731.Meter.OFPMALL.getIntValue())));
- caseBuilder.setMultipartRequestMeterConfig(mprMeterConfigBuild.build());
-
- final Xid xid = requestContext.getXid();
- MultipartRequestInputBuilder mprInput = RequestInputUtils
- .createMultipartHeader(MultipartType.OFPMPMETERCONFIG, xid.getValue(), getVersion());
- mprInput.setMultipartRequestBody(caseBuilder.build());
- MultipartRequestInput multipartRequestInput = mprInput.build();
- return StatisticsServiceUtil.getRpcResultListenableFuture(xid, multipartRequestInput, getDeviceContext());
- }
- });
-
+ return allMeterConfig.handleServiceCall(input);
}
@Override
public Future<RpcResult<GetAllMeterStatisticsOutput>> getAllMeterStatistics(final GetAllMeterStatisticsInput input) {
-
- return handleServiceCall(
- new Function<RequestContext<GetAllMeterStatisticsOutput>, ListenableFuture<RpcResult<GetAllMeterStatisticsOutput>>>() {
- @Override
- public ListenableFuture<RpcResult<GetAllMeterStatisticsOutput>> apply(final RequestContext<GetAllMeterStatisticsOutput> requestContext) {
-
- MultipartRequestMeterCaseBuilder caseBuilder =
- new MultipartRequestMeterCaseBuilder();
- MultipartRequestMeterBuilder mprMeterBuild =
- new MultipartRequestMeterBuilder();
- mprMeterBuild.setMeterId(new MeterId(BinContent.intToUnsignedLong(
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common
- .types.rev130731.Meter.OFPMALL.getIntValue())));
- caseBuilder.setMultipartRequestMeter(mprMeterBuild.build());
-
- final Xid xid = requestContext.getXid();
- MultipartRequestInputBuilder mprInput = RequestInputUtils
- .createMultipartHeader(MultipartType.OFPMPMETER, xid.getValue(), getVersion());
- mprInput.setMultipartRequestBody(caseBuilder.build());
- MultipartRequestInput multipartRequestInput = mprInput.build();
- return StatisticsServiceUtil.getRpcResultListenableFuture(xid, multipartRequestInput, getDeviceContext());
- }
- }
- );
-
+ return allMeterStats.handleServiceCall(input);
}
@Override
public Future<RpcResult<GetMeterFeaturesOutput>> getMeterFeatures(final GetMeterFeaturesInput input) {
- return handleServiceCall(
- new Function<RequestContext<GetMeterFeaturesOutput>, ListenableFuture<RpcResult<GetMeterFeaturesOutput>>>() {
- @Override
- public ListenableFuture<RpcResult<GetMeterFeaturesOutput>> apply(final RequestContext<GetMeterFeaturesOutput> requestContext) {
-
- MultipartRequestMeterFeaturesCaseBuilder mprMeterFeaturesBuild =
- new MultipartRequestMeterFeaturesCaseBuilder();
-
- final Xid xid = requestContext.getXid();
- MultipartRequestInputBuilder mprInput =
- RequestInputUtils.createMultipartHeader(MultipartType.OFPMPMETERFEATURES, xid.getValue(), getVersion());
- mprInput.setMultipartRequestBody(mprMeterFeaturesBuild.build());
- MultipartRequestInput multipartRequestInput = mprInput.build();
- return StatisticsServiceUtil.getRpcResultListenableFuture(xid, multipartRequestInput, getDeviceContext());
- }
- });
+ return meterFeatures.handleServiceCall(input);
}
@Override
public Future<RpcResult<GetMeterStatisticsOutput>> getMeterStatistics(final GetMeterStatisticsInput input) {
- return handleServiceCall(
- new Function<RequestContext<GetMeterStatisticsOutput>, ListenableFuture<RpcResult<GetMeterStatisticsOutput>>>() {
- @Override
- public ListenableFuture<RpcResult<GetMeterStatisticsOutput>> apply(final RequestContext<GetMeterStatisticsOutput> requestContext) {
- MultipartRequestMeterCaseBuilder caseBuilder =
- new MultipartRequestMeterCaseBuilder();
- MultipartRequestMeterBuilder mprMeterBuild =
- new MultipartRequestMeterBuilder();
- mprMeterBuild.setMeterId(new MeterId(input.getMeterId().getValue()));
- caseBuilder.setMultipartRequestMeter(mprMeterBuild.build());
-
- final Xid xid = requestContext.getXid();
- MultipartRequestInputBuilder mprInput =
- RequestInputUtils.createMultipartHeader(MultipartType.OFPMPMETER, xid.getValue(), getVersion());
- mprInput.setMultipartRequestBody(caseBuilder.build());
- MultipartRequestInput multipartRequestInput = mprInput.build();
- return StatisticsServiceUtil.getRpcResultListenableFuture(xid, multipartRequestInput, getDeviceContext());
- }
- });
-
+ return meterStats.handleServiceCall(input);
}
-
}
*/
package org.opendaylight.openflowplugin.impl.statistics.services;
-import com.google.common.base.Function;
-import com.google.common.util.concurrent.ListenableFuture;
import java.util.concurrent.Future;
-import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
-import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
-import org.opendaylight.openflowplugin.impl.services.CommonService;
-import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
-import org.opendaylight.openflowplugin.impl.util.StatisticsServiceUtil;
-import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
import org.opendaylight.yangtools.yang.common.RpcResult;
-/**
- * @author joe
- */
-public class OpendaylightPortStatisticsServiceImpl extends CommonService implements OpendaylightPortStatisticsService {
+public class OpendaylightPortStatisticsServiceImpl implements OpendaylightPortStatisticsService {
+ private final AllPortStatsService allPortStats;
+ private final PortStatsService portStats;
- public OpendaylightPortStatisticsServiceImpl(final RequestContextStack requestContextStack, DeviceContext deviceContext) {
- super(requestContextStack, deviceContext);
+ public OpendaylightPortStatisticsServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ allPortStats = new AllPortStatsService(requestContextStack, deviceContext);
+ portStats = new PortStatsService(requestContextStack, deviceContext);
}
@Override
public Future<RpcResult<GetAllNodeConnectorsStatisticsOutput>> getAllNodeConnectorsStatistics(
final GetAllNodeConnectorsStatisticsInput input) {
- return handleServiceCall(
- new Function<RequestContext<GetAllNodeConnectorsStatisticsOutput>,
- ListenableFuture<RpcResult<GetAllNodeConnectorsStatisticsOutput>>>() {
-
- @Override
- public ListenableFuture<RpcResult<GetAllNodeConnectorsStatisticsOutput>> apply(final RequestContext<GetAllNodeConnectorsStatisticsOutput> requestContext) {
-
- MultipartRequestPortStatsCaseBuilder caseBuilder =
- new MultipartRequestPortStatsCaseBuilder();
- MultipartRequestPortStatsBuilder mprPortStatsBuilder =
- new MultipartRequestPortStatsBuilder();
- // Select all ports
- mprPortStatsBuilder.setPortNo(OFConstants.OFPP_ANY);
- caseBuilder.setMultipartRequestPortStats(mprPortStatsBuilder.build());
-
- final Xid xid = requestContext.getXid();
- MultipartRequestInputBuilder mprInput = RequestInputUtils
- .createMultipartHeader(MultipartType.OFPMPPORTSTATS, xid.getValue(), getVersion());
- mprInput.setMultipartRequestBody(caseBuilder.build());
- MultipartRequestInput multipartRequestInput = mprInput.build();
- return StatisticsServiceUtil.getRpcResultListenableFuture(xid, multipartRequestInput, getDeviceContext());
- }
- });
+ return allPortStats.handleServiceCall(input);
}
@Override
public Future<RpcResult<GetNodeConnectorStatisticsOutput>> getNodeConnectorStatistics(
final GetNodeConnectorStatisticsInput input) {
- return handleServiceCall(
- new Function<RequestContext<GetNodeConnectorStatisticsOutput>,
- ListenableFuture<RpcResult<GetNodeConnectorStatisticsOutput>>>() {
-
- @Override
- public ListenableFuture<RpcResult<GetNodeConnectorStatisticsOutput>> apply(final RequestContext<GetNodeConnectorStatisticsOutput> requestContext) {
-
- MultipartRequestPortStatsCaseBuilder caseBuilder =
- new MultipartRequestPortStatsCaseBuilder();
- MultipartRequestPortStatsBuilder mprPortStatsBuilder =
- new MultipartRequestPortStatsBuilder();
- // Set specific port
- final short version = getVersion();
- mprPortStatsBuilder
- .setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(
- OpenflowVersion.get(version),
- input.getNodeConnectorId()));
- caseBuilder.setMultipartRequestPortStats(mprPortStatsBuilder.build());
-
- final Xid xid = requestContext.getXid();
- MultipartRequestInputBuilder mprInput = RequestInputUtils
- .createMultipartHeader(MultipartType.OFPMPPORTSTATS, xid.getValue(), version);
- mprInput.setMultipartRequestBody(caseBuilder.build());
- MultipartRequestInput multipartRequestInput = mprInput.build();
- return StatisticsServiceUtil.getRpcResultListenableFuture(xid, multipartRequestInput, getDeviceContext());
- }
- });
-
+ return portStats.handleServiceCall(input);
}
-
}
*/
package org.opendaylight.openflowplugin.impl.statistics.services;
-import com.google.common.base.Function;
-import com.google.common.util.concurrent.ListenableFuture;
import java.util.concurrent.Future;
-import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
-import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
-import org.opendaylight.openflowplugin.impl.services.CommonService;
-import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
-import org.opendaylight.openflowplugin.impl.util.StatisticsServiceUtil;
-import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.OpendaylightQueueStatisticsService;
import org.opendaylight.yangtools.yang.common.RpcResult;
-/**
- * @author joe
- */
-public class OpendaylightQueueStatisticsServiceImpl extends CommonService implements OpendaylightQueueStatisticsService {
+public class OpendaylightQueueStatisticsServiceImpl implements OpendaylightQueueStatisticsService {
+ private final AllQueuesAllPortsService allQueuesAllPorts;
+ private final AllQueuesOnePortService allQueuesOnePort;
+ private final OneQueueOnePortService oneQueueOnePort;
- public OpendaylightQueueStatisticsServiceImpl(final RequestContextStack requestContextStack, DeviceContext deviceContext) {
- super(requestContextStack, deviceContext);
+ public OpendaylightQueueStatisticsServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ allQueuesAllPorts = new AllQueuesAllPortsService(requestContextStack, deviceContext);
+ allQueuesOnePort = new AllQueuesOnePortService(requestContextStack, deviceContext);
+ oneQueueOnePort = new OneQueueOnePortService(requestContextStack, deviceContext);
}
@Override
public Future<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> getAllQueuesStatisticsFromAllPorts(
final GetAllQueuesStatisticsFromAllPortsInput input) {
- return handleServiceCall(
- new Function<RequestContext<GetAllQueuesStatisticsFromAllPortsOutput>,
- ListenableFuture<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>>>() {
-
- @Override
- public ListenableFuture<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> apply(final RequestContext<GetAllQueuesStatisticsFromAllPortsOutput> requestContext) {
-
-
- MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
- MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
- // Select all ports
- // Select all the ports
- mprQueueBuilder.setQueueId(OFConstants.OFPQ_ALL);
- mprQueueBuilder.setPortNo(OFConstants.OFPP_ANY);
- caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
-
- // Set request body to main multipart request
- final Xid xid = requestContext.getXid();
-
- MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
- MultipartType.OFPMPQUEUE, xid.getValue(), getVersion());
- mprInput.setMultipartRequestBody(caseBuilder.build());
- MultipartRequestInput multipartRequestInput = mprInput.build();
-
- return StatisticsServiceUtil.getRpcResultListenableFuture(xid, multipartRequestInput, getDeviceContext());
- }
- });
-
+ return allQueuesAllPorts.handleServiceCall(input);
}
@Override
public Future<RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> getAllQueuesStatisticsFromGivenPort(
final GetAllQueuesStatisticsFromGivenPortInput input) {
- return handleServiceCall(
- new Function<RequestContext<GetAllQueuesStatisticsFromGivenPortOutput>, ListenableFuture<RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>>>() {
-
- @Override
- public ListenableFuture<RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> apply(final RequestContext<GetAllQueuesStatisticsFromGivenPortOutput> requestContext) {
-
- MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
- MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
- // Select all queues
- // Select specific port
- final short version = getVersion();
- mprQueueBuilder.setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(
- OpenflowVersion.get(version), input.getNodeConnectorId()));
-
- mprQueueBuilder.setQueueId(OFConstants.OFPQ_ALL);
- caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
-
- // Set request body to main multipart request
- final Xid xid = requestContext.getXid();
- MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
- MultipartType.OFPMPQUEUE, xid.getValue(), version);
- mprInput.setMultipartRequestBody(caseBuilder.build());
- MultipartRequestInput multipartRequestInput = mprInput.build();
- return StatisticsServiceUtil.getRpcResultListenableFuture(xid, multipartRequestInput, getDeviceContext());
- }
- });
+ return allQueuesOnePort.handleServiceCall(input);
}
@Override
public Future<RpcResult<GetQueueStatisticsFromGivenPortOutput>> getQueueStatisticsFromGivenPort(
final GetQueueStatisticsFromGivenPortInput input) {
- return handleServiceCall(
- new Function<RequestContext<GetQueueStatisticsFromGivenPortOutput>, ListenableFuture<RpcResult<GetQueueStatisticsFromGivenPortOutput>>>() {
-
- @Override
- public ListenableFuture<RpcResult<GetQueueStatisticsFromGivenPortOutput>> apply(final RequestContext<GetQueueStatisticsFromGivenPortOutput> requestContext) {
-
- MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder();
- MultipartRequestQueueBuilder mprQueueBuilder = new MultipartRequestQueueBuilder();
- // Select specific queue
- mprQueueBuilder.setQueueId(input.getQueueId().getValue());
- // Select specific port
- final short version = getVersion();
- mprQueueBuilder.setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(
- OpenflowVersion.get(version), input.getNodeConnectorId()));
- caseBuilder.setMultipartRequestQueue(mprQueueBuilder.build());
-
- // Set request body to main multipart request
- final Xid xid = requestContext.getXid();
- MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(
- MultipartType.OFPMPQUEUE, xid.getValue(), version);
- mprInput.setMultipartRequestBody(caseBuilder.build());
- MultipartRequestInput multipartRequestInput = mprInput.build();
- return StatisticsServiceUtil.getRpcResultListenableFuture(xid, multipartRequestInput, getDeviceContext());
- }
- });
+ return oneQueueOnePort.handleServiceCall(input);
}
-
}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.impl.statistics.services;
+
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutput;
+
+final class PortStatsService extends AbstractSimpleService<GetNodeConnectorStatisticsInput, GetNodeConnectorStatisticsOutput> {
+
+ protected PortStatsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ super(requestContextStack, deviceContext, GetNodeConnectorStatisticsOutput.class);
+ }
+
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final GetNodeConnectorStatisticsInput input) {
+ MultipartRequestPortStatsCaseBuilder caseBuilder =
+ new MultipartRequestPortStatsCaseBuilder();
+ MultipartRequestPortStatsBuilder mprPortStatsBuilder =
+ new MultipartRequestPortStatsBuilder();
+ // Set specific port
+ final short version = getVersion();
+ mprPortStatsBuilder
+ .setPortNo(InventoryDataServiceUtil.portNumberfromNodeConnectorId(
+ OpenflowVersion.get(version),
+ input.getNodeConnectorId()));
+ caseBuilder.setMultipartRequestPortStats(mprPortStatsBuilder.build());
+
+ MultipartRequestInputBuilder mprInput = RequestInputUtils
+ .createMultipartHeader(MultipartType.OFPMPPORTSTATS, xid.getValue(), version);
+ mprInput.setMultipartRequestBody(caseBuilder.build());
+
+ return mprInput.build();
+ }
+}
package org.opendaylight.openflowplugin.impl.statistics.services.dedicated;
-import com.google.common.base.Function;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.ListenableFuture;
import java.util.List;
import java.util.concurrent.Future;
-import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
import org.opendaylight.openflowplugin.impl.common.MultipartRequestInputFactory;
-import org.opendaylight.openflowplugin.impl.services.CommonService;
-import org.opendaylight.openflowplugin.impl.services.RequestContextUtil;
+import org.opendaylight.openflowplugin.impl.services.AbstractMultipartService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
-import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Created by Martin Bobak <mbobak@cisco.com> on 4.4.2015.
*/
-public class StatisticsGatheringService extends CommonService {
-
- private static final Logger LOG = LoggerFactory.getLogger(StatisticsGatheringService.class);
-
+public class StatisticsGatheringService extends AbstractMultipartService<MultipartType> {
public StatisticsGatheringService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
-
super(requestContextStack, deviceContext);
}
-
public Future<RpcResult<List<MultipartReply>>> getStatisticsOfType(final MultipartType type) {
- return handleServiceCall(new Function<RequestContext<List<MultipartReply>>, ListenableFuture<RpcResult<List<MultipartReply>>>>() {
- @Override
- public ListenableFuture<RpcResult<List<MultipartReply>>> apply(final RequestContext<List<MultipartReply>> requestContext) {
- final Xid xid = requestContext.getXid();
- final DeviceContext deviceContext = getDeviceContext();
- final MultiMsgCollector multiMsgCollector = deviceContext.getMultiMsgCollector();
-
- multiMsgCollector.registerMultipartRequestContext(requestContext);
- MultipartRequestInput multipartRequestInput = MultipartRequestInputFactory.
- makeMultipartRequestInput(xid.getValue(),
- getVersion(),
- type);
- final OutboundQueue outboundQueue = deviceContext.getPrimaryConnectionContext().getOutboundQueueProvider();
- outboundQueue.commitEntry(xid.getValue(), multipartRequestInput, new FutureCallback<OfHeader>() {
- @Override
- public void onSuccess(final OfHeader ofHeader) {
- if (ofHeader instanceof MultipartReply) {
- final MultipartReply multipartReply = (MultipartReply) ofHeader;
- multiMsgCollector.addMultipartMsg(multipartReply);
- } else {
- if (null != ofHeader) {
- LOG.info("Unexpected response type received {}.", ofHeader.getClass());
- RpcResultBuilder<List<MultipartReply>> rpcResultBuilder = RpcResultBuilder.<List<MultipartReply>>failed().withError(RpcError.ErrorType.APPLICATION, String.format("Unexpected response type received %s.", ofHeader.getClass()));
- requestContext.setResult(rpcResultBuilder.build());
- } else {
- LOG.info("Ofheader was null.");
- RpcResultBuilder<List<MultipartReply>> rpcResultBuilder = RpcResultBuilder.<List<MultipartReply>>failed().withError(RpcError.ErrorType.APPLICATION, "OfHeader was null");
- requestContext.setResult(rpcResultBuilder.build());
- }
- }
- }
-
- @Override
- public void onFailure(final Throwable throwable) {
- RpcResultBuilder<List<MultipartReply>> rpcResultBuilder = RpcResultBuilder.<List<MultipartReply>>failed().withError(RpcError.ErrorType.APPLICATION, throwable.getMessage());
- requestContext.setResult(rpcResultBuilder.build());
- RequestContextUtil.closeRequstContext(requestContext);
- }
- });
- return requestContext.getFuture();
- }
- }
-
- );
+ return handleServiceCall(type);
}
+ @Override
+ protected OfHeader buildRequest(final Xid xid, final MultipartType input) {
+ return MultipartRequestInputFactory.makeMultipartRequestInput(xid.getValue(), getVersion(), input);
+ }
}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowplugin.impl.util;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.CharMatcher;
-import java.math.BigInteger;
-import java.util.StringTokenizer;
-import java.util.regex.Pattern;
-import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
-import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpVersion;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestination;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSource;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer4Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFields;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TcpFlagMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.Pbb;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Created by Martin Bobak <mbobak@cisco.com> on 8.4.2015.
- */
-public final class HashUtil {
-
- private static final Logger LOG = LoggerFactory.getLogger(HashUtil.class);
- private static final CharMatcher SLASH_MATCHER = CharMatcher.is('/');
- private static final Pattern DOUBLE_COLON = Pattern.compile("::");
- private static final int BASE_16 = 16;
- private static final int BASE_10 = 10;
- private static final long IPV6_TOKENS_COUNT = 8;
- public static final String IPV6_TOKEN = ":0000";
-
- private HashUtil() {
-
- throw new IllegalStateException("This class should not be instantiated.");
- }
-
- public static long calculateEthernetMatchHash(final EthernetMatch ethernetMatch) {
- long hash = 0;
-
- EthernetType ethernetType = ethernetMatch.getEthernetType();
- if (null != ethernetType) {
- hash += ethernetType.getType().getValue();
- }
-
- EthernetDestination ethernetDestination = ethernetMatch.getEthernetDestination();
- if (null != ethernetDestination) {
- hash += calculateEthernetDestinationHash(ethernetDestination);
- }
-
- EthernetSource ethernetSource = ethernetMatch.getEthernetSource();
- if (null != ethernetSource) {
- hash += calculateEthenetSourceHash(ethernetSource);
- }
-
- return hash;
- }
-
- public static long calculateEthenetSourceHash(final EthernetSource ethernetSource) {
- long hash = calculateMacAddressHash(ethernetSource.getAddress());
- hash += calculateMacAddressHash(ethernetSource.getMask());
- return hash;
- }
-
- public static long calculateEthernetDestinationHash(final EthernetDestination ethernetDestination) {
- long hash = calculateMacAddressHash(ethernetDestination.getAddress());
- hash += calculateMacAddressHash(ethernetDestination.getMask());
- return hash;
- }
-
- public static long calculateMacAddressHash(final MacAddress macAddress) {
-
- long hash = 0;
- if (null != macAddress) {
- StringTokenizer stringTokenizer = new StringTokenizer(macAddress.getValue(), ":");
- hash = parseTokens(stringTokenizer, BASE_16, 8);
- }
- return hash;
- }
-
- public static long calculateMatchHash(final Match match, final short version) {
- long hash = 0;
- long subHash = 0;
- long base = 0;
- if (null != match) {
- if (null != match.getEthernetMatch()) {
- hash = 1 << base;
- subHash += calculateEthernetMatchHash(match.getEthernetMatch());
- }
- base++;
- if (null != match.getIcmpv4Match()) {
- hash = 1 << base;
- subHash += calculateIcmpV4MatchHash(match.getIcmpv4Match());
- }
- base++;
- if (null != match.getIcmpv6Match()) {
- hash = 1 << base;
- subHash += calculateIcmpV6MatchHash(match.getIcmpv6Match());
- }
- base++;
- if (null != match.getInPhyPort()) {
- hash = 1 << base;
- subHash += calculateNodeConnectorIdHash(match.getInPhyPort(), version);
- }
- base++;
- if (null != match.getInPort()) {
- hash = 1 << base;
- subHash += calculateNodeConnectorIdHash(match.getInPort(), version);
- }
- base++;
- if (null != match.getIpMatch()) {
- hash = 1 << base;
- subHash += calculateIpMatchHash(match.getIpMatch());
- }
- base++;
- if (null != match.getLayer3Match()) {
- hash = 1 << base;
- subHash += calculateLayer3MatchHash(match.getLayer3Match());
- }
- base++;
- if (null != match.getLayer4Match()) {
- hash = 1 << base;
- subHash += calculateLayer4MatchHash(match.getLayer4Match());
- }
- base++;
- if (null != match.getIcmpv6Match()) {
- hash = 1 << base;
- subHash += calculateIcmpv6MatchHash(match.getIcmpv6Match());
- }
- base++;
- if (null != match.getMetadata()) {
- hash = 1 << base;
- subHash += calculateMetadataHash(match.getMetadata());
- }
- base++;
- if (null != match.getProtocolMatchFields()) {
- hash = 1 << base;
- subHash += calculateProtocolMatchFieldsHash(match.getProtocolMatchFields());
- }
- base++;
- if (null != match.getTcpFlagMatch()) {
- hash = 1 << base;
- subHash += calculateTcpFlagMatch(match.getTcpFlagMatch());
- }
- base++;
- if (null != match.getVlanMatch()) {
- hash = 1 << base;
- subHash += calculateVlanMatchHash(match.getVlanMatch());
- }
- base++;
- if (null != match.getTunnel()) {
- hash = 1 << base;
- subHash += calculateTunnelHash(match.getTunnel());
- }
- }
- return hash + subHash;
- }
-
- private static long calculateTunnelHash(final Tunnel tunnel) {
- long hash = 0;
- BigInteger tunnelId = tunnel.getTunnelId();
- if (null != tunnelId) {
- hash += tunnelId.intValue();
- }
-
- BigInteger tunnelMask = tunnel.getTunnelMask();
- if (null != tunnelMask) {
- hash += tunnelMask.intValue();
- }
- return hash;
- }
-
- private static long calculateVlanMatchHash(final VlanMatch vlanMatch) {
- long hash = 0;
-
- VlanId vlanId = vlanMatch.getVlanId();
- if (null != vlanId) {
- hash += vlanId.getVlanId().getValue().intValue();
- }
-
- VlanPcp vlanPcp = vlanMatch.getVlanPcp();
- if (null != vlanPcp) {
- hash += vlanPcp.getValue().shortValue();
- }
-
- return hash;
- }
-
- private static long calculateTcpFlagMatch(final TcpFlagMatch tcpFlagMatch) {
- long hash = tcpFlagMatch.getTcpFlag().intValue();
- return hash;
- }
-
- private static long calculateProtocolMatchFieldsHash(final ProtocolMatchFields protocolMatchFields) {
- long hash = 0;
- Short mplsBos = protocolMatchFields.getMplsBos();
- if (null != mplsBos) {
- hash += mplsBos.intValue();
- }
- Short mplsTc = protocolMatchFields.getMplsTc();
- if (null != mplsTc) {
- hash += mplsTc.intValue();
- }
- Pbb pbb = protocolMatchFields.getPbb();
- if (null != pbb) {
- if (null != pbb.getPbbIsid()) {
- hash += pbb.getPbbIsid().intValue();
- }
- if (null != pbb.getPbbMask()) {
- hash += pbb.getPbbMask().intValue();
- }
- }
- Long mplsLabel = protocolMatchFields.getMplsLabel();
- if (null != mplsLabel) {
- hash += mplsLabel.intValue();
- }
- return hash;
- }
-
- private static long calculateMetadataHash(final Metadata metadata) {
- long hash = metadata.getMetadata().intValue();
- if (null != metadata.getMetadataMask()) {
- hash += metadata.getMetadataMask().intValue();
- }
- return hash;
- }
-
- private static long calculateIcmpv6MatchHash(final Icmpv6Match icmpv6Match) {
- long hash = icmpv6Match.getIcmpv6Code().intValue();
- hash += icmpv6Match.getIcmpv6Type().intValue();
- return hash;
- }
-
- private static long calculateLayer4MatchHash(final Layer4Match layer4Match) {
- long hash = 0;
- if (layer4Match instanceof SctpMatch) {
- hash += calculateSctpMatchHash((SctpMatch) layer4Match);
- }
-
- if (layer4Match instanceof TcpMatch) {
- hash += calculateTcpMatchHash((TcpMatch) layer4Match);
- }
- if (layer4Match instanceof UdpMatch) {
- hash += calculateUdpMatchHash((UdpMatch) layer4Match);
- }
- return hash;
- }
-
- private static long calculateUdpMatchHash(final UdpMatch layer4Match) {
- long hash = 0;
- return hash;
- }
-
- private static long calculateTcpMatchHash(final TcpMatch layer4Match) {
- long hash = 0;
- PortNumber sourcePort = layer4Match.getTcpSourcePort();
- if (null != sourcePort) {
- hash += sourcePort.getValue().intValue();
- }
-
- PortNumber destinationPort = layer4Match.getTcpDestinationPort();
- if (null != destinationPort) {
- hash += destinationPort.getValue().intValue();
- }
- return hash;
- }
-
- private static long calculateSctpMatchHash(final SctpMatch layer4Match) {
- long hash = 0;
-
- PortNumber portNumber = layer4Match.getSctpDestinationPort();
- if (null != portNumber) {
- hash += portNumber.getValue().intValue();
- }
-
- PortNumber sourcePort = layer4Match.getSctpSourcePort();
- if (null != sourcePort) {
- hash += sourcePort.getValue().intValue();
- }
- return hash;
- }
-
- private static long calculateLayer3MatchHash(final Layer3Match layer3Match) {
- long hash = 0;
- if (layer3Match instanceof ArpMatch) {
- hash += calculateArpMatchHash((ArpMatch) layer3Match);
- }
- if (layer3Match instanceof Ipv4Match) {
- hash += calculateIpv4MatchHash((Ipv4Match) layer3Match);
- }
- if (layer3Match instanceof Ipv6Match) {
- hash += calculateIpv6MatchHash((Ipv6Match) layer3Match);
-
- }
- if (layer3Match instanceof TunnelIpv4Match) {
- hash += calculateTunnelIpv4Hash((TunnelIpv4Match) layer3Match);
- }
- return hash;
- }
-
- private static long calculateTunnelIpv4Hash(final TunnelIpv4Match layer3Match) {
- Ipv4Prefix tunnelIpv4Destination = layer3Match.getTunnelIpv4Destination();
- long hash = calculateIpv4PrefixHash(tunnelIpv4Destination);
- Ipv4Prefix tunnelIpv4Source = layer3Match.getTunnelIpv4Source();
- hash += calculateIpv4PrefixHash(tunnelIpv4Source);
- return hash;
- }
-
- private static long calculateIpv6MatchHash(final Ipv6Match layer3Match) {
- long hash = 0;
- Ipv6Prefix ipv6Destination = layer3Match.getIpv6Destination();
- if (null != ipv6Destination) {
- hash += calculateIpv6PrefixHash(ipv6Destination);
- }
-
- if (null != layer3Match.getIpv6Source()) {
- hash += calculateIpv6PrefixHash(layer3Match.getIpv6Source());
- }
-
- if (null != layer3Match.getIpv6ExtHeader()) {
- hash += layer3Match.getIpv6ExtHeader().getIpv6Exthdr();
- hash += layer3Match.getIpv6ExtHeader().getIpv6ExthdrMask();
- }
-
- if (null != layer3Match.getIpv6NdSll()) {
- hash += calculateMacAddressHash(layer3Match.getIpv6NdSll());
- }
- if (null != layer3Match.getIpv6NdTll()) {
- hash += calculateMacAddressHash(layer3Match.getIpv6NdTll());
- }
- if (null != layer3Match.getIpv6NdTarget()) {
- hash += calculateIpv6AddressHash(layer3Match.getIpv6NdTarget());
- }
- return hash;
- }
-
-
- public static long calculateIpv6PrefixHash(final Ipv6Prefix ipv6Prefix) {
-
- StringTokenizer stringTokenizer = getStringTokenizerWithFullAddressString(ipv6Prefix.getValue());
-
- long hash = parseTokens(stringTokenizer, BASE_16, 16);
- return hash;
- }
-
- public static long calculateIpv6AddressHash(final Ipv6Address ipv6Address) {
-
- StringTokenizer stringTokenizer = getStringTokenizerWithFullAddressString(ipv6Address.getValue());
-
- long hash = parseTokens(stringTokenizer, BASE_16, 16);
- return hash;
- }
-
- private static StringTokenizer getStringTokenizerWithFullAddressString(final String value) {
- String ipv6Value = DOUBLE_COLON.matcher(value).replaceAll(":0000:");
- StringTokenizer stringTokenizer = new StringTokenizer(ipv6Value, ":");
-
- long delta = IPV6_TOKENS_COUNT - stringTokenizer.countTokens();
-
- StringBuilder additions = new StringBuilder();
-
- if (delta > 0) {
- while (delta > 0) {
- additions.append(IPV6_TOKEN);
- delta--;
- }
- if (ipv6Value.indexOf('/') != -1) {
- additions.append('/');
- ipv6Value = SLASH_MATCHER.replaceFrom(ipv6Value, additions.toString());
- } else {
- ipv6Value += additions.toString();
- }
- stringTokenizer = new StringTokenizer(ipv6Value, ":");
- }
- return stringTokenizer;
- }
-
- private static long calculateStopperBasedOnMaskValue(final Ipv6Prefix ipv6Prefix, final long bitsBase) {
- double maskValue = extractMask(ipv6Prefix);
- double bitCount = maskValue / bitsBase;
- return (int) Math.ceil(bitCount);
- }
-
- private static long extractMask(final Ipv6Prefix ipv6Prefix) {
- StringTokenizer maskTokenizer = new StringTokenizer(ipv6Prefix.getValue(), "/");
- long mask = 0;
- if (maskTokenizer.countTokens() > 1) {
- maskTokenizer.nextToken();
- mask = Integer.parseInt(maskTokenizer.nextToken());
- }
- return mask;
- }
-
- private static long parseTokens(final StringTokenizer stringTokenizer, final int base, final int bitShift) {
- return parseTokens(stringTokenizer, 0, base, bitShift);
- }
-
- private static long parseTokens(final StringTokenizer stringTokenizer, final long stopper, final int base, final int bitShift) {
- long hash = 0;
- if (stringTokenizer.countTokens() > 0) {
- long step = 0;
- while (stringTokenizer.hasMoreTokens()) {
- String token = stringTokenizer.nextToken();
- step++;
-
- if (token.isEmpty()) {
- token = "0";
- }
-
- if (token.indexOf('/') != -1) {
- StringTokenizer tokenizer = new StringTokenizer(token, "/");
- hash += parseTokens(tokenizer, stopper, base, bitShift);
- } else {
- hash += Long.parseLong(token, base) << (bitShift * step);
- if (stopper > 0 && step == stopper) {
- break;
- }
- }
- }
- }
- return hash;
- }
-
- private static long calculateIpv4MatchHash(final Ipv4Match layer3Match) {
- long hash = 0;
- Ipv4Prefix ipv4Destination = layer3Match.getIpv4Destination();
- if (null != ipv4Destination) {
- hash += calculateIpv4PrefixHash(ipv4Destination);
- }
-
- Ipv4Prefix ipv4Source = layer3Match.getIpv4Source();
-
- if (null != ipv4Source) {
- hash += calculateIpv4PrefixHash(ipv4Source);
- }
-
- //TODO : add calculation of hashes for augmentations
- return hash;
- }
-
- private static long calculateArpMatchHash(final ArpMatch layer3Match) {
- long hash = 0;
- Integer arpOp = layer3Match.getArpOp();
- if (null != arpOp) {
- hash += arpOp.intValue();
- }
- ArpSourceHardwareAddress arpSourceHardwareAddress = layer3Match.getArpSourceHardwareAddress();
- if (null != arpSourceHardwareAddress) {
- hash += calculateMacAddressHash(arpSourceHardwareAddress.getAddress());
- hash += calculateMacAddressHash(arpSourceHardwareAddress.getMask());
- }
-
- Ipv4Prefix sourceTransportAddress = layer3Match.getArpSourceTransportAddress();
- if (null != sourceTransportAddress) {
- hash += calculateIpv4PrefixHash(sourceTransportAddress);
- }
-
- ArpTargetHardwareAddress arpTargetHardwareAddress = layer3Match.getArpTargetHardwareAddress();
- if (null != arpTargetHardwareAddress) {
- hash += calculateMacAddressHash(arpTargetHardwareAddress.getAddress());
- hash += calculateMacAddressHash(arpTargetHardwareAddress.getMask());
- }
-
- Ipv4Prefix targetTransportAddress = layer3Match.getArpTargetTransportAddress();
- if (null != targetTransportAddress) {
- hash += calculateIpv4PrefixHash(targetTransportAddress);
- }
-
- return hash;
- }
-
- public static long calculateIpv4PrefixHash(final Ipv4Prefix ipv4Prefix) {
- long hash = 0;
- StringTokenizer prefixAsArray = new StringTokenizer(ipv4Prefix.getValue(), "/");
- if (prefixAsArray.countTokens() == 2) {
- String address = prefixAsArray.nextToken();
- Long mask = Long.parseLong(prefixAsArray.nextToken());
- long numberOfAddressPartsToUse = (int) Math.ceil(mask.doubleValue() / 8);
- hash += calculateIpAdressHash(address, numberOfAddressPartsToUse, BASE_10);
- hash += mask.shortValue();
- }
- return hash;
- }
-
-
- private static long calculateIpAdressHash(final String address, final long numberOfParts, final int base) {
- StringTokenizer stringTokenizer = new StringTokenizer(address, ".");
- long hash = parseTokens(stringTokenizer, numberOfParts, base, 8);
- return hash;
- }
-
- @VisibleForTesting
- public static long calculateIpMatchHash(final IpMatch ipMatch) {
- long hash = 0;
- Short ipEcn = ipMatch.getIpEcn();
- if (null != ipEcn) {
- hash += ipEcn.shortValue();
- }
- Short ipProtocol = ipMatch.getIpProtocol();
- if (null != ipProtocol) {
- hash += ipProtocol;
- }
-
- if (null != ipMatch.getIpDscp()) {
- Short ipDscp = ipMatch.getIpDscp().getValue();
- if (null != ipDscp) {
- hash += ipDscp;
- }
- }
-
- IpVersion ipVersion = ipMatch.getIpProto();
- if (null != ipVersion)
-
- {
- hash += ipVersion.getIntValue();
- }
-
- return hash;
- }
-
- private static long calculateNodeConnectorIdHash(final NodeConnectorId inPhyPort, final short version) {
- long hash = 0;
- Long portFromLogicalName = OpenflowPortsUtil.getPortFromLogicalName(OpenflowVersion.get(version), inPhyPort.getValue());
- hash += portFromLogicalName.intValue();
- return hash;
- }
-
- private static long calculateIcmpV6MatchHash(final Icmpv6Match icmpv6Match) {
- long hash = 0;
- if (null != icmpv6Match.getIcmpv6Code()) {
- hash += icmpv6Match.getIcmpv6Code();
- }
- if (null != icmpv6Match.getIcmpv6Type()) {
- hash += icmpv6Match.getIcmpv6Type();
- }
- return hash;
- }
-
- public static long calculateIcmpV4MatchHash(final Icmpv4Match icmpv4Match) {
- long hash = 0;
- if (null != icmpv4Match.getIcmpv4Code()) {
- hash += icmpv4Match.getIcmpv4Code();
- }
- if (null != icmpv4Match.getIcmpv4Type()) {
- hash += icmpv4Match.getIcmpv4Type();
- }
- return hash;
- }
-
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowplugin.impl.util;
-
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.SettableFuture;
-import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-
-/**
- * Created by Martin Bobak <mbobak@cisco.com> on 18.5.2015.
- */
-public class StatisticsServiceUtil {
-
- private StatisticsServiceUtil() {
- throw new IllegalStateException("This class should not be instantiated");
- }
-
- public static <T> ListenableFuture<RpcResult<T>> getRpcResultListenableFuture(final Xid xid,
- final MultipartRequestInput multipartRequestInput,
- final DeviceContext deviceContext) {
- final SettableFuture<RpcResult<T>> settableFuture = SettableFuture.create();
- final OutboundQueue outboundQueue = deviceContext.getPrimaryConnectionContext().getOutboundQueueProvider();
- outboundQueue.commitEntry(xid.getValue(), multipartRequestInput, new FutureCallback<OfHeader>() {
- @Override
- public void onSuccess(final OfHeader ofHeader) {
- }
-
- @Override
- public void onFailure(final Throwable throwable) {
- }
- });
- return settableFuture;
- }
-
-}
private static final int AWAITED_NUM_OF_CALL_ADD_ROUTED_RPC = 12;
- private static final int AWAITED_NUM_OF_CALL_ADD_NEW_REQUEST = 1;
final ProviderContext mockedProviderContext = mock(ProviderContext.class);
- final RpcManagerImpl rpcManager = new RpcManagerImpl(mockedProviderContext, 500l);
- final RpcContext mockedRpcContext = mock(RpcContext.class);
- final AddFlowInput mockedFlowInput = prepareTestingAddFlow();
+ final RpcManagerImpl rpcManager = new RpcManagerImpl(mockedProviderContext, 500);
final DeviceContext mockedDeviceContext = mock(DeviceContext.class);
@Mock
private MessageSpy messageSpy;
@RunWith(MockitoJUnitRunner.class)
public class ConnectionContextImplTest {
- private ConnectionContextImpl conContext;
@Mock
private ConnectionAdapter conAdapter;
@Before
public void initialization() {
// place for mocking method's general behavior for ConnectorAdapter
- conContext = new ConnectionContextImpl(conAdapter);
}
/**
package org.opendaylight.openflowplugin.impl.device;
import static org.mockito.Matchers.any;
-
import com.google.common.util.concurrent.SettableFuture;
import io.netty.util.HashedWheelTimer;
import java.util.ArrayList;
@Before
public void setUp() {
Mockito.when(dataBroker.createTransactionChain(Mockito.any(TransactionChainManager.class))).thenReturn(txChainFactory);
- txChainManager = new TransactionChainManager(dataBroker, timer, 5L, 5L);
+ txChainManager = new TransactionChainManager(dataBroker, deviceState);
final SettableFuture<RpcResult<GetAsyncReply>> settableFuture = SettableFuture.create();
final SettableFuture<RpcResult<MultipartReply>> settableFutureMultiReply = SettableFuture.create();
Mockito.when(requestContext.getFuture()).thenReturn(settableFuture);
}
@Test(expected = NullPointerException.class)
- public void testDeviceContextImplConstructorNullConnectionContext() {
+ public void testDeviceContextImplConstructorNullConnectionContext() throws Exception {
new DeviceContextImpl(null, deviceState, dataBroker, timer, messageIntelligenceAgency).close();
}
@Test(expected = NullPointerException.class)
- public void testDeviceContextImplConstructorNullDataBroker() {
+ public void testDeviceContextImplConstructorNullDataBroker() throws Exception {
new DeviceContextImpl(connectionContext, deviceState, null, timer, messageIntelligenceAgency).close();
}
@Test(expected = NullPointerException.class)
- public void testDeviceContextImplConstructorNullDeviceState() {
+ public void testDeviceContextImplConstructorNullDeviceState() throws Exception {
new DeviceContextImpl(connectionContext, null, dataBroker, timer, messageIntelligenceAgency).close();
}
@Test(expected = NullPointerException.class)
- public void testDeviceContextImplConstructorNullTimer() {
+ public void testDeviceContextImplConstructorNullTimer() throws Exception {
new DeviceContextImpl(null, deviceState, dataBroker, null, messageIntelligenceAgency).close();
}
Assert.assertEquals(rTx, readTx);
}
- private static GetAsyncOutput createAsyncOutput(final Xid xid) {
- final GetAsyncOutputBuilder asyncOutputBuilder = new GetAsyncOutputBuilder();
- asyncOutputBuilder.setFlowRemovedMask(Collections.<FlowRemovedMask>emptyList());
- asyncOutputBuilder.setPacketInMask(Collections.<PacketInMask>emptyList());
- asyncOutputBuilder.setPortStatusMask(Collections.<PortStatusMask>emptyList());
- asyncOutputBuilder.setVersion(OFConstants.OFP_VERSION_1_3);
- asyncOutputBuilder.setXid(xid.getValue());
- return asyncOutputBuilder.build();
- }
-
-
- private static Error createError(final Xid xid) {
- final ErrorMessageBuilder errorMessageBuilder = new ErrorMessageBuilder();
- errorMessageBuilder.setCode(42);
- errorMessageBuilder.setCodeString("42");
- errorMessageBuilder.setXid(xid.getValue());
- return errorMessageBuilder.build();
- }
-
- private static List<MultipartReply> createMultipartReplyList(final Xid xid) {
- final MultipartReplyDesc descValue = new MultipartReplyDescBuilder().setHwDesc("hw-test-value").build();
- final MultipartReplyDescCase replyBody = new MultipartReplyDescCaseBuilder()
- .setMultipartReplyDesc(descValue).build();
- final List<MultipartReply> multipartReplies = new ArrayList<>();
- multipartReplies.add(new MultipartReplyMessageBuilder()
- .setMultipartReplyBody(replyBody)
- .setXid(xid.getValue())
- .setFlags(new MultipartRequestFlags(false))
- .build());
- multipartReplies.add(new MultipartReplyMessageBuilder()
- .setMultipartReplyBody(replyBody)
- .setXid(xid.getValue())
- .setFlags(new MultipartRequestFlags(true))
- .build());
- return multipartReplies;
- }
-
}
//Assert.assertTrue(mpInputCaptor.getAllValues().get(1).getMultipartRequestBody() instanceof MultipartRequestGroupDescCase);
}
- /**
- * Test method for {@link org.opendaylight.openflowplugin.impl.device.DeviceManagerImpl#sendMessage(org.opendaylight.yangtools.yang.binding.DataObject, org.opendaylight.openflowplugin.api.openflow.device.RequestContext)}.
- */
- @Test
- public void testSendMessage() {
- }
-
- /**
- * Test method for {@link org.opendaylight.openflowplugin.impl.device.DeviceManagerImpl#sendRequest(org.opendaylight.yangtools.yang.binding.DataObject, org.opendaylight.openflowplugin.api.openflow.device.RequestContext)}.
- */
- @Test
- public void testSendRequest() {
- }
-
- /**
- * Test method for {@link org.opendaylight.openflowplugin.impl.device.DeviceManagerImpl#addRequestContextReadyHandler(org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceContextReadyHandler)}.
- */
- @Test
- public void testAddRequestContextReadyHandler() {
- }
@Test
public void testHookRequest() {
import io.netty.util.HashedWheelTimer;
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Matchers;
import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
@Mock
private DataBroker dataBroker;
@Mock
+ private DeviceState deviceState;
+ @Mock
private BindingTransactionChain txChain;
@Mock
private WriteTransaction writeTx;
public void setUp() throws Exception {
Mockito.when(dataBroker.createTransactionChain(Matchers.any(TransactionChainListener.class)))
.thenReturn(txChain);
- txChainManager = new TransactionChainManager(dataBroker, timer, 2, 2);
+ Mockito.when(deviceState.isValid()).thenReturn(Boolean.TRUE);
+ txChainManager = new TransactionChainManager(dataBroker, deviceState);
Mockito.when(txChain.newWriteOnlyTransaction()).thenReturn(writeTx);
nodeId = new NodeId("h2g2:42");
final Node data = new NodeBuilder().setId(nodeId).build();
txChainManager.enableSubmit();
txChainManager.writeToTransaction(LogicalDatastoreType.CONFIGURATION, path, data);
- txChainManager.submitTransaction();
+ txChainManager.submitWriteTransaction();
Mockito.verify(txChain).newWriteOnlyTransaction();
Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data);
Mockito.verify(writeTx).submit();
- Mockito.verify(writeTx).getIdentifier();
}
/**
* @throws Exception
*/
@Test
+ @Ignore // FIXME : think about test -> we don't use submit by time and nrOfOperations
public void testEnableCounter2() throws Exception {
txChainManager.enableSubmit();
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.Mockito;
+import org.mockito.internal.verification.VerificationModeFactory;
import org.mockito.runners.MockitoJUnitRunner;
+import org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.api.openflow.device.exception.DeviceDataException;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceReplyProcessor;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
import org.opendaylight.openflowplugin.impl.connection.testutil.MsgGeneratorTestUtils;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
/**
* openflowplugin-api
@Mock
DeviceReplyProcessor deviceProcessor;
@Captor
- ArgumentCaptor<DeviceDataException> ddeCaptor;
+ ArgumentCaptor<DeviceRequestFailedException> ddeCaptor;
@Captor
ArgumentCaptor<Xid> xidCaptor;
@Captor
ArgumentCaptor<List<MultipartReply>> mmCaptor;
@Mock
- RequestContext requestContext;
+ RequestContext<List<MultipartReply>> requestContext;
final Long xid = 1L;
@Before
public void setUp() {
- collector = new MultiMsgCollectorImpl(1);
- collector.setDeviceReplyProcessor(deviceProcessor);
+ collector = new MultiMsgCollectorImpl(deviceProcessor, requestContext);
cleanUpCheck = Runnables.doNothing();
Mockito.when(requestContext.getXid()).thenReturn(new Xid(xid));
}
Thread.sleep(1100L);
// flush cache action
- collector.registerMultipartRequestContext(requestContext);
cleanUpCheck.run();
Mockito.verifyNoMoreInteractions(deviceProcessor);
}
*/
@Test
public void testAddMultipartMsgOne() {
- final Long xid = 1L;
- collector.registerMultipartRequestContext(requestContext);
collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, false).build());
Mockito.verify(deviceProcessor).processReply(xidCaptor.capture(), mmCaptor.capture());
Assert.assertEquals(xid, xidCaptor.getValue().getValue());
- List<MultipartReply> multipartReplyList = mmCaptor.getValue();
+ final List<MultipartReply> multipartReplyList = mmCaptor.getValue();
Assert.assertEquals(1, multipartReplyList.size());
Assert.assertEquals(MultipartType.OFPMPDESC, multipartReplyList.get(0).getType());
}
*/
@Test
public void testAddMultipartMsgTwo() {
- final Long xid = 1L;
- collector.registerMultipartRequestContext(requestContext);
collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, true).build());
collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, false).build());
Mockito.verify(deviceProcessor).processReply(xidCaptor.capture(), mmCaptor.capture());
Assert.assertEquals(xid, xidCaptor.getValue().getValue());
- List<MultipartReply> multipartReplyList = mmCaptor.getValue();
+ final List<MultipartReply> multipartReplyList = mmCaptor.getValue();
Assert.assertEquals(2, multipartReplyList.size());
Assert.assertEquals(MultipartType.OFPMPDESC, multipartReplyList.get(0).getType());
Assert.assertEquals(MultipartType.OFPMPDESC, multipartReplyList.get(1).getType());
* test of ${link MultiMsgCollector#addMultipartMsg} <br>
* xid not registered before message
*/
- @Test
+ @Test(expected=IllegalArgumentException.class)
public void testAddMultipartMsgNotExpectedXid() {
- final Long xid = 1L;
- collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, true).build());
-
- Mockito.verify(deviceProcessor).processException(xidCaptor.capture(), ddeCaptor.capture());
- Assert.assertEquals(xid, xidCaptor.getValue().getValue());
- Assert.assertEquals(expectedUnknownXidMsg, ddeCaptor.getValue().getMessage());
+ final Long dif_xid = 5L;
+ final MultipartReplyMessage mrMsg = MsgGeneratorTestUtils.makeMultipartDescReply(dif_xid, hwTestValue, true).build();
+ collector.addMultipartMsg(mrMsg);
}
/**
*/
@Test
public void testAddMultipartMsgWrongType1() {
- collector.registerMultipartRequestContext(requestContext);
collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, true).build());
collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, false)
.setType(MultipartType.OFPMPPORTDESC).build());
-
- Mockito.verify(deviceProcessor).processException(xidCaptor.capture(), ddeCaptor.capture());
+ Mockito.verify(deviceProcessor).processReply(xidCaptor.capture(), mmCaptor.capture());
Assert.assertEquals(xid, xidCaptor.getValue().getValue());
- Assert.assertEquals(expectedTypMismatchMsg, ddeCaptor.getValue().getMessage());
Mockito.reset(deviceProcessor);
cleanUpCheck = new Runnable() {
@Override
public void run() {
- Mockito.verify(deviceProcessor).processException(xidCaptor.capture(), ddeCaptor.capture());
+ Mockito.verify(deviceProcessor, VerificationModeFactory.noMoreInteractions())
+ .processReply(xidCaptor.capture(), mmCaptor.capture());
Assert.assertEquals(xid, xidCaptor.getValue().getValue());
- Assert.assertEquals(expectedExpirationMsg, ddeCaptor.getValue().getMessage());
}
};
}
*/
@Test
public void testAddMultipartMsgWrongType2() {
- final Long xid = 1L;
- collector.registerMultipartRequestContext(requestContext);
collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, true).build());
collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, true)
.setType(MultipartType.OFPMPPORTDESC).build());
+ collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, false).build());
- Mockito.verify(deviceProcessor).processException(xidCaptor.capture(), ddeCaptor.capture());
+ Mockito.verify(deviceProcessor).processReply(xidCaptor.capture(), mmCaptor.capture());
+ Mockito.verify(deviceProcessor).processReply(xidCaptor.capture(), mmCaptor.capture());
Assert.assertEquals(xid, xidCaptor.getValue().getValue());
- Assert.assertEquals(expectedTypMismatchMsg, ddeCaptor.getValue().getMessage());
Mockito.reset(deviceProcessor);
cleanUpCheck = new Runnable() {
@Override
public void run() {
- Mockito.verify(deviceProcessor).processException(xidCaptor.capture(), ddeCaptor.capture());
+ Mockito.verify(deviceProcessor, VerificationModeFactory.noMoreInteractions())
+ .processReply(xidCaptor.capture(), mmCaptor.capture());
Assert.assertEquals(xid, xidCaptor.getValue().getValue());
- Assert.assertEquals(expectedExpirationMsg, ddeCaptor.getValue().getMessage());
}
};
}
*/
@Test
public void testAddMultipartMsgWrongType3() {
- final Long xid = 1L;
- collector.registerMultipartRequestContext(requestContext);
collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, true).build());
collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, true)
.setType(MultipartType.OFPMPPORTDESC).build());
collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, false).build());
- Mockito.verify(deviceProcessor).processException(xidCaptor.capture(), ddeCaptor.capture());
+ Mockito.verify(deviceProcessor).processReply(xidCaptor.capture(), mmCaptor.capture());
Assert.assertEquals(xid, xidCaptor.getValue().getValue());
- Assert.assertEquals(expectedTypMismatchMsg, ddeCaptor.getValue().getMessage());
Mockito.verify(deviceProcessor).processReply(xidCaptor.capture(), mmCaptor.capture());
Assert.assertEquals(xid, xidCaptor.getValue().getValue());
- List<MultipartReply> multipartReplyList = mmCaptor.getValue();
- Assert.assertEquals(2, multipartReplyList.size());
+ final List<MultipartReply> multipartReplyList = mmCaptor.getValue();
+ Assert.assertEquals(3, multipartReplyList.size());
Assert.assertEquals(MultipartType.OFPMPDESC, multipartReplyList.get(0).getType());
- Assert.assertEquals(MultipartType.OFPMPDESC, multipartReplyList.get(1).getType());
+ Assert.assertEquals(MultipartType.OFPMPPORTDESC, multipartReplyList.get(1).getType());
+ Assert.assertEquals(MultipartType.OFPMPDESC, multipartReplyList.get(2).getType());
}
-
- /**
- * test of ${link MultiMsgCollector#addMultipartMsg} <br>
- * no second message arrived within expiration limit - first message should expire
- */
- @Test
- public void testAddMultipartMsgExpiration() throws InterruptedException {
- final Long xid = 1L;
- collector.registerMultipartRequestContext(requestContext);
- collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, true).build());
-
- cleanUpCheck = new Runnable() {
- @Override
- public void run() {
- Mockito.verify(deviceProcessor).processException(xidCaptor.capture(), ddeCaptor.capture());
- Assert.assertEquals(xid, xidCaptor.getValue().getValue());
- Assert.assertEquals(expectedExpirationMsg, ddeCaptor.getValue().getMessage());
- }
- };
- }
-
}
@Mock
private ConnectionAdapter connectionAdapter;
- private final String hwDescValue = "test-val";
private final long xid = 42L;
@Before
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
+
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashSet;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
-import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowHash;
+import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
@RunWith(MockitoJUnitRunner.class)
-public class FlowHashFactoryTest {
+public class FlowRegistryKeyFactoryTest {
- private static final Logger LOG = LoggerFactory.getLogger(FlowHashFactoryTest.class);
+ private static final Logger LOG = LoggerFactory.getLogger(FlowRegistryKeyFactoryTest.class);
private static final FlowsStatisticsUpdateBuilder FLOWS_STATISTICS_UPDATE_BUILDER = new FlowsStatisticsUpdateBuilder();
public void testEquals() throws Exception {
FlowsStatisticsUpdate flowStats = FLOWS_STATISTICS_UPDATE_BUILDER.build();
- HashSet<FlowHash> flowHashs = new HashSet<>();
+ HashSet<FlowRegistryKey> flowRegistryKeys = new HashSet<>();
for (FlowAndStatisticsMapList item : flowStats.getFlowAndStatisticsMapList()) {
- flowHashs.add(FlowHashFactory.create(item, OFConstants.OFP_VERSION_1_3));
- flowHashs.add(FlowHashFactory.create(item, OFConstants.OFP_VERSION_1_3));
+ flowRegistryKeys.add(FlowRegistryKeyFactory.create(item));
+ flowRegistryKeys.add(FlowRegistryKeyFactory.create(item));
}
- assertEquals(3, flowHashs.size());
+ assertEquals(3, flowRegistryKeys.size());
}
@Test
.setPriority(2)
.setTableId((short) 0);
- FlowHash flow1Hash = FlowHashFactory.create(flow1Builder.build(), OFConstants.OFP_VERSION_1_3);
+ FlowRegistryKey flow1Hash = FlowRegistryKeyFactory.create(flow1Builder.build());
LOG.info("flowHash1: {}", flow1Hash.hashCode());
.setCookie(new FlowCookie(BigInteger.valueOf(148)))
.setMatch(match2Builder.build());
- FlowHash flow2Hash = FlowHashFactory.create(flow2Builder.build(), OFConstants.OFP_VERSION_1_3);
+ FlowRegistryKey flow2Hash = FlowRegistryKeyFactory.create(flow2Builder.build());
LOG.info("flowHash2: {}", flow2Hash.hashCode());
Assert.assertNotSame(flow1Hash, flow2Hash);
FlowBuilder fb1 = new FlowBuilder(flow1Builder.build());
fb1.setTableId(null);
try {
- FlowHashFactory.create(fb1.build(), OFConstants.OFP_VERSION_1_3);
+ FlowRegistryKeyFactory.create(fb1.build());
Assert.fail("hash creation should have failed because of NPE");
} catch (Exception e) {
// expected
FlowBuilder fb2 = new FlowBuilder(flow1Builder.build());
fb2.setPriority(null);
try {
- FlowHashFactory.create(fb2.build(), OFConstants.OFP_VERSION_1_3);
+ FlowRegistryKeyFactory.create(fb2.build());
Assert.fail("hash creation should have failed because of NPE");
} catch (Exception e) {
// expected
FlowBuilder fb3 = new FlowBuilder(flow1Builder.build());
fb3.setCookie(null);
- FlowHash flowHash = FlowHashFactory.create(fb3.build(), OFConstants.OFP_VERSION_1_3);
- Assert.assertNotNull(flowHash.getCookie());
- Assert.assertEquals(OFConstants.DEFAULT_COOKIE, flowHash.getCookie());
+ FlowRegistryKey flowRegistryKey = FlowRegistryKeyFactory.create(fb3.build());
+ Assert.assertNotNull(flowRegistryKey.getCookie());
+ Assert.assertEquals(OFConstants.DEFAULT_COOKIE, flowRegistryKey.getCookie());
}
@Test
FlowsStatisticsUpdate flowStats = FLOWS_STATISTICS_UPDATE_BUILDER.build();
for (FlowAndStatisticsMapList item : flowStats.getFlowAndStatisticsMapList()) {
- FlowHash flowHash = FlowHashFactory.create(item, OFConstants.OFP_VERSION_1_3);
- FlowHash lastHash = null;
+ FlowRegistryKey flowRegistryKey = FlowRegistryKeyFactory.create(item);
+ FlowRegistryKey lastHash = null;
if (null != lastHash) {
- assertNotEquals(lastHash, flowHash);
+ assertNotEquals(lastHash, flowRegistryKey);
} else {
- lastHash = flowHash;
+ lastHash = flowRegistryKey;
}
}
}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.openflowplugin.impl.util;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class HashUtilTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(HashUtilTest.class);
-
- private static final MacAddress[] MAC_ADDRESSES = {
- new MacAddress("00:00:00:00:00:00"),
- new MacAddress("AA:BB:CC:DD:EE:FF"),
- new MacAddress("FF:EE:DD:CC:BB:AA"),
- new MacAddress("0A:37:C1:00:AB:FF"),
- new MacAddress("0A:37:C1:00:AB:FE"),
- new MacAddress("0A:37:C1:00:FE:AB")
- };
-
- private static final Ipv4Prefix[] IPV_4_PREFIXES = {
- new Ipv4Prefix("10.0.0.1/24"),
- new Ipv4Prefix("10.0.1.0/24"),
- new Ipv4Prefix("10.0.1.0/31"),
- new Ipv4Prefix("0.0.0.0/32"),
- new Ipv4Prefix("4.3.2.1/32"),
- new Ipv4Prefix("1.2.3.4/32")
- };
-
- private static final Ipv6Prefix[] IPV_6_PREFIXES = {
- new Ipv6Prefix("FFFF:0DB8:0000:0000:0000:0000:1428:57ab"),
- new Ipv6Prefix("2001:0DB8:0000:0000:0000:0000:1428:57ab"),
- new Ipv6Prefix("0DB8:2001:0000:0000:0000:0000:1428:57ab"),
- new Ipv6Prefix("2001:0DB8:0000:0000:0000:0000:57ab:1428")
- };
-
- private static final Ipv6Prefix shortIpv6 = new Ipv6Prefix("fe80::2acf:e9ff:fe21:6431/128");
- private static final Ipv6Prefix fullIpv6 = new Ipv6Prefix("fe80:0000:2acf:e9ff:fe21:6431:0000:0000/128");
- private static final Ipv6Prefix[] IPV_6_PREFIXES_WITH_MASK = {
- new Ipv6Prefix("FFFF:0DB8:0000:0000:0000:0000:1428:57ab/72"),
- new Ipv6Prefix("2001:0DB8:0000:0000:0000:0000:1428:57ab/94"),
- new Ipv6Prefix("0DB8:2001:0000:0000:0000:0000:1428:57ab/32"),
- new Ipv6Prefix("2001:0DB8:0000:0000:0000:0000:57ab:1428/64")
- };
-
-
- @Test
- public void trivialLongTest() {
-
- Long longA = new Long(42);
- Long longB = new Long(42);
- Assert.assertNotSame(longA, longB);
- Long longC = Long.valueOf(42);
- Long longD = Long.valueOf(42);
- Assert.assertSame(longC, longD);
-
- }
-
-
- @Test
- public void testCalculateMatchHash() throws Exception {
- long hashShort = HashUtil.calculateIpv6PrefixHash(shortIpv6);
- long hashLong = HashUtil.calculateIpv6PrefixHash(fullIpv6);
- Assert.assertEquals(hashShort, hashLong);
- }
-
- @Test
- public void testCalculateMacAddressHash() {
- for (int i = 0; i < MAC_ADDRESSES.length - 1; i++) {
- long hash = HashUtil.calculateMacAddressHash(MAC_ADDRESSES[i]);
- long otherHash = HashUtil.calculateMacAddressHash(MAC_ADDRESSES[i + 1]);
- Assert.assertNotEquals(hash, otherHash);
- }
- }
-
- @Test
- public void testCalculateIpv4PrefixHash() {
- for (int i = 0; i < IPV_4_PREFIXES.length - 1; i++) {
- Ipv4Prefix prefixA = IPV_4_PREFIXES[i];
- Ipv4Prefix prefixB = IPV_4_PREFIXES[i + 1];
- long hash = HashUtil.calculateIpv4PrefixHash(prefixA);
- long hash_n = HashUtil.calculateIpv4PrefixHash(prefixB);
- LOG.info("Comparing {} vs. {} (hash {} vs. hash {})", prefixA, prefixB, hash, hash_n);
- Assert.assertNotEquals(hash, hash_n);
- }
-
- }
-
- @Test
- public void testCalculateIpv6PrefixHash() {
- for (int i = 0; i < IPV_6_PREFIXES.length - 1; i++) {
- long hash_n = HashUtil.calculateIpv6PrefixHash(IPV_6_PREFIXES[i]);
- long hash_n1 = HashUtil.calculateIpv6PrefixHash(IPV_6_PREFIXES[i + 1]);
- Assert.assertNotNull(hash_n);
- Assert.assertNotNull(hash_n1);
- Assert.assertNotEquals(hash_n, hash_n1);
- }
- }
-
- @Test
- public void testCalculateIpv6PrefixHashWithMask() {
- for (int i = 0; i < IPV_6_PREFIXES.length - 1; i++) {
- long hash_n = HashUtil.calculateIpv6PrefixHash(IPV_6_PREFIXES_WITH_MASK[i]);
- long hash_n1 = HashUtil.calculateIpv6PrefixHash(IPV_6_PREFIXES_WITH_MASK[i + 1]);
- Assert.assertNotNull(hash_n);
- Assert.assertNotNull(hash_n1);
- Assert.assertNotEquals(hash_n, hash_n1);
- }
- }
-
- @Test
- public void calculateIpMatchHash() {
- IpMatchBuilder ipMatchBuilder = new IpMatchBuilder();
- ipMatchBuilder.setIpEcn((short) 42);
- HashUtil.calculateIpMatchHash(ipMatchBuilder.build());
- }
-
-}
\ No newline at end of file
*/
package org.opendaylight.openflowplugin.openflow.md.core.extension;
+import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey;
import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionSerializerKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
import org.opendaylight.openflowplugin.extension.api.ConvertorActionFromOFJava;
+import org.opendaylight.openflowplugin.extension.api.TypeVersionKey;
import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action.container.action.choice.ExperimenterIdCase;
*/
public static org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action
processAlienAction(Action action, OpenflowVersion ofVersion, ActionPath actionPath) {
- ExperimenterIdCase actionCase = (ExperimenterIdCase) action.getActionChoice();
- /** TODO: EXTENSION PROPOSAL (action, OFJava to MD-SAL) */
- ExperimenterActionSerializerKey key = new ExperimenterActionSerializerKey(
- ofVersion.getVersion(),
- actionCase.getExperimenter().getExperimenter().getValue(),
- actionCase.getExperimenter().getSubType());
-
+ ConvertorActionFromOFJava<Action, ActionPath> convertor = null;
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action alienAction = null;
- ConvertorActionFromOFJava<Action, ActionPath> convertor = OFSessionUtil.getExtensionConvertorProvider().getActionConverter(key);
+ if(action.getActionChoice() instanceof ExperimenterIdCase) {
+ ExperimenterIdCase actionCase = (ExperimenterIdCase) action.getActionChoice();
+ /** TODO: EXTENSION PROPOSAL (action, OFJava to MD-SAL) */
+ ExperimenterActionSerializerKey key = new ExperimenterActionSerializerKey(
+ ofVersion.getVersion(),
+ actionCase.getExperimenter().getExperimenter().getValue(),
+ actionCase.getExperimenter().getSubType());
+ convertor = OFSessionUtil.getExtensionConvertorProvider().getActionConverter(key);
+ } else if (action.getActionChoice() != null){
+ ActionSerializerKey<?> key = new ActionSerializerKey(EncodeConstants.OF13_VERSION_ID, action.getActionChoice().getImplementedInterface(), null);
+ convertor = OFSessionUtil.getExtensionConvertorProvider().getActionConverter(key);
+ }
if (convertor != null) {
alienAction = convertor.convert(
action, actionPath);
public final class ActionConvertor {
private static final Logger LOG = LoggerFactory.getLogger(ActionConvertor.class);
private static final String UNKNOWN_ACTION_TYPE_VERSION = "Unknown Action Type for the Version";
+ private static final Ordering<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> ACTION_ORDERING =
+ Ordering.from(OrderComparator.<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>build());
private ActionConvertor() {
// NOOP
Action ofAction;
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> sortedActions =
- Ordering.from(OrderComparator.<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>build())
- .sortedCopy(actions);
+ ACTION_ORDERING.sortedCopy(actions);
for (int actionItem = 0; actionItem < sortedActions.size(); actionItem++) {
ofAction = null;
} else if (action instanceof SetNwTosActionCase) {
ofAction = salToOFSetNwTos(action, actionBuilder, version);
} else if (action instanceof GeneralExtensionGrouping) {
-
/**
* TODO: EXTENSION PROPOSAL (action, MD-SAL to OFJava)
* - we might need sessionContext as converter input
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder setNwDstActionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder();
bucketActions.add(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilder.build()).build());
- } else if (action.getActionChoice() instanceof ExperimenterIdCase) {
+ } else {
/**
* TODO: EXTENSION PROPOSAL (action, OFJava to MD-SAL)
* - we might also need a way on how to identify exact type of augmentation to be
import java.math.BigInteger;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
-
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.OrderComparator;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flowflag.FlowFlagReactor;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Objects;
+import com.google.common.base.MoreObjects;
import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
import com.google.common.collect.Ordering;
/**
*/
public static final List<MatchEntry> DEFAULT_MATCH_ENTRIES = new ArrayList<MatchEntry>();
+ private static final Ordering<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> INSTRUCTION_ORDERING =
+ Ordering.from(OrderComparator.<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction>build());
+
+ private static final VlanMatch VLAN_MATCH_FALSE;
+ private static final VlanMatch VLAN_MATCH_TRUE;
+
+ static {
+ final VlanId zeroVlan = new VlanId(0);
+ VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
+ VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
+ vlanIdBuilder.setVlanIdPresent(false);
+ vlanIdBuilder.setVlanId(zeroVlan);
+ vlanMatchBuilder.setVlanId(vlanIdBuilder.build());
+
+ VLAN_MATCH_FALSE = vlanMatchBuilder.build();
+
+ VlanMatchBuilder vlanMatchBuilder2 = new VlanMatchBuilder();
+ VlanIdBuilder vlanIdBuilder2 = new VlanIdBuilder();
+ vlanIdBuilder2.setVlanIdPresent(true);
+ vlanIdBuilder2.setVlanId(zeroVlan);
+ vlanMatchBuilder2.setVlanId(vlanIdBuilder2.build());
+
+ VLAN_MATCH_TRUE = vlanMatchBuilder2.build();
+ }
private FlowConvertor() {
//hiding implicit constructor
* If yes its handled separately
*/
public static List<FlowModInputBuilder> toFlowModInputs(Flow srcFlow, short version, BigInteger datapathId) {
- List<FlowModInputBuilder> list = new ArrayList<>();
-
if (version >= OFConstants.OFP_VERSION_1_3 && isSetVlanIdActionCasePresent(srcFlow)) {
- list.addAll(handleSetVlanIdForOF13(srcFlow, version, datapathId));
+ return handleSetVlanIdForOF13(srcFlow, version, datapathId);
} else {
- list.add(toFlowModInput(srcFlow, version, datapathId));
+ return Collections.singletonList(toFlowModInput(srcFlow, version, datapathId));
}
- return list;
}
public static FlowModInputBuilder toFlowModInput(Flow flow, short version, BigInteger datapathid) {
if (flow instanceof AddFlowInput) {
flowMod.setCommand(FlowModCommand.OFPFCADD);
} else if (flow instanceof RemoveFlowInput) {
- if (Objects.firstNonNull(flow.isStrict(), Boolean.FALSE)) {
+ if (MoreObjects.firstNonNull(flow.isStrict(), Boolean.FALSE)) {
flowMod.setCommand(FlowModCommand.OFPFCDELETESTRICT);
} else {
flowMod.setCommand(FlowModCommand.OFPFCDELETE);
}
} else if (flow instanceof UpdatedFlow) {
- if (Objects.firstNonNull(flow.isStrict(), Boolean.FALSE)) {
+ if (MoreObjects.firstNonNull(flow.isStrict(), Boolean.FALSE)) {
flowMod.setCommand(FlowModCommand.OFPFCMODIFYSTRICT);
} else {
flowMod.setCommand(FlowModCommand.OFPFCMODIFY);
} else if (curInstruction instanceof WriteMetadataCase) {
WriteMetadataCase writeMetadatacase = (WriteMetadataCase) curInstruction;
WriteMetadata writeMetadata = writeMetadatacase.getWriteMetadata();
-
+
WriteMetadataCaseBuilder writeMetadataCaseBuilder = new WriteMetadataCaseBuilder();
WriteMetadataBuilder writeMetadataBuilder = new WriteMetadataBuilder();
writeMetadataBuilder.setMetadata(ByteUtil.convertBigIntegerToNBytes(writeMetadata.getMetadata(),
} else if (curInstruction instanceof ApplyActionsCase) {
ApplyActionsCase applyActionscase = (ApplyActionsCase) curInstruction;
ApplyActions applyActions = applyActionscase.getApplyActions();
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder applyActionsCaseBuilder =
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder applyActionsCaseBuilder =
new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder();
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder applyActionsBuilder =
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder applyActionsBuilder =
new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder();
applyActionsBuilder.setAction(ActionConvertor.getActions(applyActions.getAction(), version, datapathid, flow));
applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
instructionBuilder.setInstructionChoice(applyActionsCaseBuilder.build());
instructionsList.add(instructionBuilder.build());
} else if (curInstruction instanceof ClearActionsCase) {
- ClearActionsCaseBuilder clearActionsCaseBuilder = new ClearActionsCaseBuilder();
+ ClearActionsCaseBuilder clearActionsCaseBuilder = new ClearActionsCaseBuilder();
instructionBuilder.setInstructionChoice(clearActionsCaseBuilder.build());
instructionsList.add(instructionBuilder.build());
} else if (curInstruction instanceof MeterCase) {
org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions instructions = flow.getInstructions();
List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> sortedInstructions =
- Ordering.from(OrderComparator.<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction>build())
- .sortedCopy(instructions.getInstruction());
+ INSTRUCTION_ORDERING.sortedCopy(instructions.getInstruction());
for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction instruction : sortedInstructions) {
org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction curInstruction = instruction
// check if set vlanid action is present in the flow
private static boolean isSetVlanIdActionCasePresent(Flow flow) {
- boolean isPresent = false;
// we are trying to find if there is a set-vlan-id action (OF1.0) action present in the flow.
// If yes,then we would need to two flows
if (flow.getInstructions() != null) {
for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action action :
applyActions.getAction()) {
if (action.getAction() instanceof SetVlanIdActionCase) {
- isPresent = true;
- break;
+ return true;
}
}
}
}
}
- return isPresent;
+ return false;
}
* Â Â 2) Match on (OFPVID_PRESENT) with mask (OFPVID_PRESENT ) + action [ set_field]
*/
private static List<FlowModInputBuilder> handleSetVlanIdForOF13(Flow srcFlow, short version, BigInteger datapathId) {
- List<FlowModInputBuilder> list = new ArrayList<>();
+ List<FlowModInputBuilder> list = new ArrayList<>(2);
- VlanMatch srcVlanMatch = srcFlow.getMatch().getVlanMatch();
- boolean hasVlanMatch = (srcFlow.getMatch() != null && srcVlanMatch != null);
- if (hasVlanMatch) {
+ final Match srcMatch = Preconditions.checkNotNull(srcFlow.getMatch());
+ final VlanMatch srcVlanMatch = srcMatch.getVlanMatch();
+ if (srcVlanMatch != null) {
//create flow with setfield and match
// match on vlan tag or vlanid with no mask
VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder(srcVlanMatch);
vlanIdBuilder.setVlanIdPresent(srcVlanMatch.getVlanId().isVlanIdPresent());
vlanIdBuilder.setVlanId(srcVlanMatch.getVlanId().getVlanId());
vlanMatchBuilder.setVlanId(vlanIdBuilder.build());
- Match match = new MatchBuilder(srcFlow.getMatch()).setVlanMatch(vlanMatchBuilder.build()).build();
+ Match match = new MatchBuilder(srcMatch).setVlanMatch(vlanMatchBuilder.build()).build();
Optional<? extends Flow> optional = injectMatchToFlow(srcFlow, match);
if (optional.isPresent()) {
// create 2 flows
//flow 1
// match on no vlan tag with no mask
- VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
- VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
- vlanIdBuilder.setVlanIdPresent(false);
- vlanIdBuilder.setVlanId(new VlanId(0));
- vlanMatchBuilder.setVlanId(vlanIdBuilder.build());
- Match match1 = new MatchBuilder(srcFlow.getMatch()).setVlanMatch(vlanMatchBuilder.build()).build();
+ Match match1 = new MatchBuilder(srcMatch).setVlanMatch(VLAN_MATCH_FALSE).build();
Optional<? extends Flow> optional1 = injectMatchAndAction(srcFlow, match1);
if (optional1.isPresent()) {
//flow2
// match on vlan tag with mask
- VlanMatchBuilder vlanMatchBuilder2 = new VlanMatchBuilder();
- VlanIdBuilder vlanIdBuilder2 = new VlanIdBuilder();
- vlanIdBuilder2.setVlanIdPresent(true);
- vlanIdBuilder2.setVlanId(new VlanId(0));
- vlanMatchBuilder2.setVlanId(vlanIdBuilder2.build());
- Match match2 = new MatchBuilder(srcFlow.getMatch()).setVlanMatch(vlanMatchBuilder2.build()).build();
+ Match match2 = new MatchBuilder(srcMatch).setVlanMatch(VLAN_MATCH_TRUE).build();
Optional<? extends Flow> optional2 = injectMatchToFlow(srcFlow, match2);
if (optional2.isPresent()) {
list.add(toFlowModInput(optional2.get(), version, datapathId));
*/
package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
-import java.util.HashMap;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
import java.util.Map;
/**
* @author tkubas
*
*/
-
//TODO make a model in YANG for protocols
public enum IPProtocols {
ICMP((short) 1),
private short protocol;
- private static Map<Short, IPProtocols> valueMap;
+ private static final Map<Short, IPProtocols> VALUE_MAP;
static {
- valueMap = new HashMap<>();
+ Builder<Short, IPProtocols> builder = ImmutableMap.builder();
for(IPProtocols protocols : IPProtocols.values()) {
- valueMap.put(protocols.protocol, protocols);
+ builder.put(protocols.protocol, protocols);
}
+ VALUE_MAP = builder.build();
}
private IPProtocols(short value) {
}
public static IPProtocols fromProtocolNum(Short protocolNum) {
- return valueMap.get(protocolNum);
+ return VALUE_MAP.get(protocolNum);
}
}
/*
+ * Copyright (c) 2015 Brocade, Communications Systems, Inc
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
import java.util.Iterator;
+import com.google.common.collect.Iterators;
+import java.util.Arrays;
+import java.net.UnknownHostException;
+import java.net.Inet6Address;
+import java.net.Inet4Address;
+import java.net.InetAddress;
+import com.google.common.net.InetAddresses;
+import com.google.common.base.Preconditions;
+
/**
* Created by Martin Bobak <mbobak@cisco.com> on 5.3.2015.
+ * v6 routines added by Anton Ivanov on 14.6.2015
*/
public final class IpConversionUtil {
public static final String PREFIX_SEPARATOR = "/";
public static final Splitter PREFIX_SPLITTER = Splitter.on('/');
+ final private static int INADDR4SZ = 4;
+ final private static int INADDR6SZ = 16;
+ final private static int INT16SZ = 2;
private IpConversionUtil() {
throw new IllegalStateException("This class should not be instantiated.");
}
public static Iterator<String> splitToParts(final Ipv4Address ipv4Address) {
- return PREFIX_SPLITTER.split(ipv4Address.getValue()).iterator();
+ /* Invalid (Ab)use of ip address as prefix!!! */
+ String [] tempPrefix = {ipv4Address.getValue(), "32"};
+ return Iterators.forArray(tempPrefix);
+ }
+
+ public static Iterator<String> splitToParts(final Ipv6Prefix ipv6Prefix) {
+ return PREFIX_SPLITTER.split(ipv6Prefix.getValue()).iterator();
}
public static Iterator<String> splitToParts(final Ipv6Address ipv6Address) {
- return PREFIX_SPLITTER.split(ipv6Address.getValue()).iterator();
+ /* Invalid (Ab)use of ip address as prefix!!! */
+ String [] tempPrefix = {ipv6Address.getValue(), "128"};
+ return Iterators.forArray(tempPrefix);
}
+
+ /* This forest of functions has a purpose:
+ *
+ * 1. There are multiple coding styles around the plugin, this is necessary in order to have
+ * one mechanism to convert them all, one mechanism to find them...
+ * 2. I hope that one day yangtools will actually deliver code fit for purpose in a packet
+ * processing application (presently it is not. When this happens, these can be optimized
+ * for "side-load" of pre-vetted data. Example. IP Address (v4 or v6) is prevetted left of the
+ * prefix. It should be loadable into Prefix without _RERUNNING_ 100ms+ of regexps. When (and if)
+ * that happens, it will be a simple fix here without chasing it across the whole plugin.
+ */
+
public static Ipv4Prefix createPrefix(Ipv4Address ipv4Address){
- Iterator<String> addressParts = splitToParts(ipv4Address);
- String address = addressParts.next();
- Ipv4Prefix retval = null;
- if (addressParts.hasNext()) {
- retval = new Ipv4Prefix(address + PREFIX_SEPARATOR + Integer.parseInt(addressParts.next()));
+ return new Ipv4Prefix(ipv4Address.getValue() + PREFIX_SEPARATOR + 32);
+ }
+
+ public static Ipv4Prefix createPrefix(Ipv4Address ipv4Address, String mask){
+ /*
+ * Ipv4Address has already validated the address part of the prefix,
+ * It is mandated to comply to the same regexp as the address
+ * There is absolutely no point rerunning additional checks vs this
+ * Note - there is no canonical form check here!!!
+ */
+ if (null != mask && !mask.equals("")) {
+ return new Ipv4Prefix(ipv4Address.getValue() + PREFIX_SEPARATOR + mask);
} else {
- retval = new Ipv4Prefix(address + PREFIX_SEPARATOR + 32);
+ return new Ipv4Prefix(ipv4Address.getValue() + PREFIX_SEPARATOR + "32");
}
- return retval;
}
- public static Ipv4Prefix createPrefix(Ipv4Address ipv4Address, String mask){
- Iterator<String> addressParts = splitToParts(ipv4Address);
- String address = addressParts.next();
- Ipv4Prefix retval = null;
+
+ public static Ipv4Prefix createPrefix(Ipv4Address ipv4Address, int intmask){
+ return createPrefix(ipv4Address, "" + intmask);
+ }
+
+ public static Ipv4Prefix createPrefix(Ipv4Address ipv4Address, byte [] bytemask){
+ return createPrefix(ipv4Address, "" + countBits(bytemask));
+ }
+
+ public static Ipv6Prefix createPrefix(Ipv6Address ipv6Address){
+ return new Ipv6Prefix(ipv6Address.getValue() + PREFIX_SEPARATOR + 128);
+ }
+
+ public static Ipv6Prefix createPrefix(Ipv6Address ipv6Address, String mask){
+ /*
+ * Ipv6Address has already validated the address part of the prefix,
+ * It is mandated to comply to the same regexp as the address
+ * There is absolutely no point rerunning additional checks vs this
+ * Note - there is no canonical form check here!!!
+ */
if (null != mask && !mask.equals("")) {
- retval = new Ipv4Prefix(address + mask);
+ return new Ipv6Prefix(ipv6Address.getValue() + PREFIX_SEPARATOR + mask);
} else {
- retval = new Ipv4Prefix(address + PREFIX_SEPARATOR + 32);
+ return new Ipv6Prefix(ipv6Address.getValue() + PREFIX_SEPARATOR + "128");
}
- return retval;
}
- public static Integer extractPrefix(Ipv4Address ipv4Address) {
- Iterator<String> addressParts = splitToParts(ipv4Address);
+
+ public static Ipv6Prefix createPrefix(Ipv6Address ipv6Address, int intmask){
+ return createPrefix(ipv6Address, "" + intmask);
+ }
+
+ public static Ipv6Prefix createPrefix(Ipv6Address ipv6Address, byte [] bytemask){
+ /*
+ * Ipv4Address has already validated the address part of the prefix,
+ * It is mandated to comply to the same regexp as the address
+ * There is absolutely no point rerunning additional checks vs this
+ * Note - there is no canonical form check here!!!
+ */
+ return createPrefix(ipv6Address, "" + countBits(bytemask));
+ }
+ public static Integer extractPrefix(Ipv4Prefix ipv4Prefix) {
+ Iterator<String> addressParts = splitToParts(ipv4Prefix);
addressParts.next();
Integer retval = null;
if (addressParts.hasNext()) {
}
return retval;
}
- public static Integer extractPrefix(Ipv6Address ipv6Address) {
- Iterator<String> addressParts = splitToParts(ipv6Address);
+
+ public static Integer extractPrefix(Ipv6Prefix ipv6Prefix) {
+ Iterator<String> addressParts = splitToParts(ipv6Prefix);
addressParts.next();
Integer retval = null;
if (addressParts.hasNext()) {
return retval;
}
+ public static Integer extractPrefix(Ipv4Address ipv4Prefix) {
+ return 32;
+ }
- public static byte[] convertIpv6PrefixToByteArray(final int prefix) {
- // TODO: Temporary fix. Has performance impacts.
- byte[] mask = new byte[16];
- int oneCount = prefix;
- for (int count = 0; count < 16; count++) {
- int byteBits = 0;
- if (oneCount >= 8) {
- byteBits = 8;
- oneCount = oneCount - 8;
- } else {
- byteBits = oneCount;
- oneCount = 0;
+ public static Integer extractPrefix(Ipv6Address ipv6Prefix) {
+ return 128;
+ }
+
+ /*
+ * BIG FAT WARNING!!!
+ * Read all of the following before you touch any v6 code or decide to
+ * optimize it by invoking a "simple" Guava call
+ *
+ * Java IPv6 is fundamentally broken and Google libraries do not fix it.
+ * 1. Java will allways implicitly rewrite v4 mapped into v6 as a v4 address
+ * and there is absolutely no way to override this behaviour
+ * 2. Guava libraries cannot parse non-canonical IPv6. They will throw an
+ * exception. Even if they did, they re-use the same broken java code
+ * underneath.
+ *
+ * This is why we have to parse v6 by ourselves.
+ *
+ * The following conversion code is based on inet_cidr_pton_ipv6 in NetBSD
+ *
+ * The original BSD code is licensed under standard BSD license. While we
+ * are not obliged to provide an attribution, credit where credit is due.
+ * As far as why it is similar to Sun's sun.net.util please ask Sun why
+ * their code has the same variable names, comments and code flow.
+ *
+ */
+
+
+ /**
+ * Convert Ipv6Address object to a valid Canonical v6 address in byte format
+ *
+ * @param ipv6Address - v6 Address object
+ * @return - byte array of size 16. Last byte contains netmask
+ */
+
+
+ public static byte[] canonicalBinaryV6Address(Ipv6Address ipv6Address) {
+ /*
+ * Do not modify this routine to take direct strings input!!!
+ * Key checks have been removed based on the assumption that
+ * the input is validated via regexps in Ipv6Prefix()
+ */
+
+ String [] address = (ipv6Address.getValue()).split("%");
+
+ int colonp;
+ char ch;
+ boolean saw_xdigit;
+
+ /* Isn't it fun - the above variable names are the same in BSD and Sun sources */
+
+ int val;
+
+ char[] src = address[0].toCharArray();
+
+ byte[] dst = new byte[INADDR6SZ];
+
+ int src_length = src.length;
+
+ colonp = -1;
+ int i = 0, j = 0;
+
+ /* Leading :: requires some special handling. */
+
+ /* Isn't it fun - the above comment is again the same in BSD and Sun sources,
+ * We will derive our code from BSD. Shakespear always sounds better
+ * in original Clingon. So does Dilbert.
+ */
+
+ if (src[i] == ':') {
+ Preconditions.checkArgument(src[++i] == ':', "Invalid v6 address");
+ }
+
+ int curtok = i;
+ saw_xdigit = false;
+
+
+ val = 0;
+ while (i < src_length) {
+ ch = src[i++];
+ int chval = Character.digit(ch, 16);
+
+ /* Business as usual - ipv6 address digit.
+ * We can remove all checks from the original BSD code because
+ * the regexp has already verified that we are not being fed
+ * anything bigger than 0xffff between the separators.
+ */
+
+ if (chval != -1) {
+ val <<= 4;
+ val |= chval;
+ saw_xdigit = true;
+ continue;
+ }
+
+ /* v6 separator */
+
+ if (ch == ':') {
+ curtok = i;
+ if (!saw_xdigit) {
+ /* no need to check separator position validity - regexp does that */
+ colonp = j;
+ continue;
+ }
+
+ /* removed overrun check - the regexp checks for valid data */
+
+ dst[j++] = (byte) ((val >> 8) & 0xff);
+ dst[j++] = (byte) (val & 0xff);
+ saw_xdigit = false;
+ val = 0;
+ continue;
}
- mask[count] = (byte) (256 - Math.pow(2, 8 - byteBits));
+ /* frankenstein - v4 attached to v6, mixed notation */
+
+ if (ch == '.' && ((j + INADDR4SZ) <= INADDR6SZ)) {
+
+ /* this has passed the regexp so it is fairly safe to parse it
+ * straight away. As v4 addresses do not suffer from the same
+ * defficiencies as the java v6 implementation we can invoke it
+ * straight away and be done with it
+ */
+
+ Preconditions.checkArgument(j != (INADDR6SZ - INADDR4SZ - 1), "Invalid v4 in v6 mapping");
+
+ InetAddress _inet_form = InetAddresses.forString(address[0].substring(curtok, src_length));
+
+ Preconditions.checkArgument(_inet_form instanceof Inet4Address);
+
+ byte[] v4addr = _inet_form.getAddress();
+
+ for (int k = 0; k < INADDR4SZ; k++) {
+ dst[j++] = v4addr[k];
+ }
+ saw_xdigit = false;
+ break;
+ }
+ /* removed parser exit on ivalid char - no need to do it, regexp checks it */
+ }
+ if (saw_xdigit) {
+ Preconditions.checkArgument(j + INT16SZ <= INADDR6SZ, "Overrun in v6 parsing, should not occur");
+ dst[j++] = (byte) ((val >> 8) & 0xff);
+ dst[j++] = (byte) (val & 0xff);
+ }
+
+ if (colonp != -1) {
+ int n = j - colonp;
+
+ Preconditions.checkArgument(j != INADDR6SZ, "Overrun in v6 parsing, should not occur");
+ for (i = 1; i <= n; i++) {
+ dst[INADDR6SZ - i] = dst[colonp + n - i];
+ dst[colonp + n - i] = 0;
+ }
+ j = INADDR6SZ;
+ }
+
+ Preconditions.checkArgument(j == INADDR6SZ, "Overrun in v6 parsing, should not occur");
+
+ return dst;
+ }
+
+ static public String byteArrayV6AddressToString (byte [] _binary_form) throws UnknownHostException{
+ /* DO NOT DIY!!! - InetAddresses will actually print correct canonical
+ * zero compressed form.
+ */
+ return InetAddresses.toAddrString(InetAddress.getByAddress(_binary_form));
+ }
+
+
+ static private int nextNibble(int mask) {
+ if (mask <= 0) {
+ return 0;
+ }
+ if (mask > 8) {
+ return 0xff;
+ }
+ return 0xff << (8 - mask);
+ }
+
+ /**
+ * Convert Ipv6Prefix object to a valid Canonical v6 prefix in byte format
+ *
+ * @param ipv6Prefix - v6 prefix object
+ * @return - byte array of size 16 + 1. Last byte contains netmask
+ */
+
+
+ public static byte[] canonicalBinaryV6Prefix(Ipv6Prefix ipv6Prefix) {
+ /*
+ * Do not modify this routine to take direct strings input!!!
+ * Key checks have been removed based on the assumption that
+ * the input is validated via regexps in Ipv6Prefix()
+ */
+
+ int mask = 128;
+
+ String [] address = null;
+
+ boolean valid = true;
+
+ address = (ipv6Prefix.getValue()).split("/");
+ try {
+ mask = Integer.parseInt(address[1]);
+ if (mask > 128) {
+ valid = false;
+ }
+ } catch (NumberFormatException | ArrayIndexOutOfBoundsException e) {
+ valid = false;
+ }
+
+ Preconditions.checkArgument(valid, "Supplied netmask in %s is invalid", ipv6Prefix.getValue());
+
+
+ int colonp;
+ char ch;
+ boolean saw_xdigit;
+
+ /* Isn't it fun - the above variable names are the same in BSD and Sun sources */
+
+ int val;
+
+ char[] src = address[0].toCharArray();
+
+ byte[] dst = new byte[INADDR6SZ + 1];
+
+ int m = mask;
+
+ int src_length = src.length;
+
+ colonp = -1;
+ int i = 0, j = 0;
+
+ /* Leading :: requires some special handling. */
+
+ /* Isn't it fun - the above comment is again the same in BSD and Sun sources,
+ * We will derive our code from BSD. Shakespear always sounds better
+ * in original Clingon. So does Dilbert.
+ */
+
+ if (src[i] == ':') {
+ Preconditions.checkArgument(src[++i] == ':', "Invalid v6 address");
+ }
+
+ int curtok = i;
+ saw_xdigit = false;
+
+
+ val = 0;
+ while (i < src_length) {
+ ch = src[i++];
+ int chval = Character.digit(ch, 16);
+
+ /* Business as usual - ipv6 address digit.
+ * We can remove all checks from the original BSD code because
+ * the regexp has already verified that we are not being fed
+ * anything bigger than 0xffff between the separators.
+ */
+
+ if (chval != -1) {
+ val <<= 4;
+ val |= chval;
+ saw_xdigit = true;
+ continue;
+ }
+
+ /* v6 separator */
+
+ if (ch == ':') {
+ curtok = i;
+ if (!saw_xdigit) {
+ /* no need to check separator position validity - regexp does that */
+ colonp = j;
+ continue;
+ }
+
+ /* removed overrun check - the regexp checks for valid data */
+
+ saw_xdigit = false;
+
+ if (m < 0) {
+ /* stop parsing if we are past the mask */
+ break;
+ }
+
+ dst[j] = (byte) ((val >> 8) & nextNibble(m)); j++; m = m - 8;
+
+ if (m < 0) {
+ /* stop parsing if we are past the mask */
+ break;
+ }
+
+ dst[j] = (byte) (val & nextNibble(m)); j++; m = m - 8;
+
+ val = 0;
+ continue;
+ }
+
+ /* frankenstein - v4 attached to v6, mixed notation */
+
+ if (ch == '.' && ((j + INADDR4SZ) <= INADDR6SZ)) {
+
+ /* this has passed the regexp so it is fairly safe to parse it
+ * straight away. As v4 addresses do not suffer from the same
+ * defficiencies as the java v6 implementation we can invoke it
+ * straight away and be done with it
+ */
+
+ Preconditions.checkArgument(j != (INADDR6SZ - INADDR4SZ - 1), "Invalid v4 in v6 mapping");
+
+ InetAddress _inet_form = InetAddresses.forString(address[0].substring(curtok, src_length));
+
+ Preconditions.checkArgument(_inet_form instanceof Inet4Address);
+
+ byte[] v4addr = _inet_form.getAddress();
+
+ for (int k = 0; k < INADDR4SZ; k++) {
+ dst[j++] = v4addr[k];
+ }
+ saw_xdigit = false;
+ break;
+ }
+ /* removed parser exit on ivalid char - no need to do it, regexp checks it */
+ }
+ if (saw_xdigit) {
+ Preconditions.checkArgument(j + INT16SZ <= INADDR6SZ, "Overrun in v6 parsing, should not occur");
+ dst[j] = (byte) ((val >> 8) & nextNibble(m)) ; j++; m = m - 8;
+ dst[j] = (byte) (val & nextNibble(m)); j++; m = m - 8;
+ }
+
+ if ((j < INADDR6SZ) && (m < 0)) {
+ /* past the mask */
+ for (i = j; i < INADDR6SZ; i++) {
+ dst[i] = 0;
+ }
+ } else {
+ /* normal parsing */
+ if (colonp != -1) {
+ int n = j - colonp;
+
+ Preconditions.checkArgument(j != INADDR6SZ, "Overrun in v6 parsing, should not occur");
+ for (i = 1; i <= n; i++) {
+ dst[INADDR6SZ - i] = dst[colonp + n - i];
+ dst[colonp + n - i] = 0;
+ }
+ j = INADDR6SZ;
+ }
+ Preconditions.checkArgument(j == INADDR6SZ, "Overrun in v6 parsing, should not occur");
+ }
+
+ dst[INADDR6SZ] = (byte) mask;
+ return dst;
+ }
+
+ /**
+ * Print a v6 prefix in byte array + 1 notation
+ *
+ * @param _binary_form - prefix, in byte [] form, last byte is netmask
+ */
+
+
+ static public String byteArrayV6PrefixToString(byte [] _binary_form) throws UnknownHostException {
+ /* NO DIY!!! - InetAddresses will actually print correct canonical
+ * zero compressed form
+ */
+ StringBuilder sb = new java.lang.StringBuilder();
+ /* Yang RFC specifies that the normalized form is RFC 5952, note - java
+ * core type is not RFC compliant, guava is.
+ */
+ sb.append(
+ InetAddresses.toAddrString(
+ InetAddress.getByAddress(
+ Arrays.copyOfRange(_binary_form, 0, INADDR6SZ)
+ )
+ )
+ );
+ sb.append("/");
+ sb.append(_binary_form[INADDR6SZ] & 0xff);
+ return sb.toString();
+ }
+
+
+ /**
+ * Canonicalize a v6 prefix while in binary form
+ *
+ * @param _prefix - prefix, in byte [] form
+ * @param mask - mask - number of bits
+ */
+
+ static public void canonicalizeIpv6Prefix(byte [] _prefix, int mask) {
+
+ for (int i=0; i < INADDR6SZ; i++) {
+ _prefix[i] = (byte) (_prefix[i] & nextNibble(mask));
+ mask = mask - 8;
+ }
+ }
+
+ public static byte[] convertIpv6PrefixToByteArray(int prefix) {
+ byte[] mask = new byte[16];
+ for (int count = 0; count < 16; count++) {
+ mask[count] = (byte) nextNibble(prefix);
+ prefix = prefix - 8;
}
return mask;
}
return prefix;
}
+ private static int toInt(byte b) {
+ return b < 0 ? b + 256 : b;
+ }
+
+ public static int countBits(byte[] mask) {
+ int netmask = 0;
+ for (byte b : mask) {
+ netmask += Integer.bitCount(toInt(b));
+ }
+ return netmask;
+ }
+
+
}
package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.Ordering;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.OrderComparator;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCase;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
*/
public class TableFeaturesConvertor {
private static final Logger LOG = LoggerFactory.getLogger(TableFeaturesConvertor.class);
+ private static final Ordering<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties> TABLE_FEATURE_PROPS_ORDERING =
+ Ordering.from(OrderComparator.<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties>build());
private TableFeaturesConvertor() {
//hiding implicit construcotr
List<TableFeatureProperties> ofTablePropertiesList = new ArrayList<>();
List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties>
- sortedTableProperties =
- Ordering.from(OrderComparator.<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties>build())
- .sortedCopy(tableProperties.getTableFeatureProperties());
+ sortedTableProperties = TABLE_FEATURE_PROPS_ORDERING.sortedCopy(tableProperties.getTableFeatureProperties());
for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties
property : sortedTableProperties) {
builder.addAugmentation(ActionRelatedTableFeatureProperty.class, propBuilder.build());
}
- private static Map<Class<?>, Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField>> SAL_TO_OF_TABLE_FEATURES = new HashMap<>();
+ private static final Map<Class<?>, Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField>> SAL_TO_OF_TABLE_FEATURES;
static {
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp.class, ArpOp.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSha.class, ArpSha.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSpa.class, ArpSpa.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTha.class, ArpTha.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTpa.class, ArpTpa.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst.class, EthDst.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc.class, EthSrc.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthType.class, EthType.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Code.class, Icmpv4Code.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Type.class, Icmpv4Type.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Code.class, Icmpv6Code.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Type.class, Icmpv6Type.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPhyPort.class, InPhyPort.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort.class, InPort.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpDscp.class, IpDscp.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn.class, IpEcn.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto.class, IpProto.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst.class, Ipv4Dst.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Src.class, Ipv4Src.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Dst.class, Ipv6Dst.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr.class, Ipv6Exthdr.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Flabel.class, Ipv6Flabel.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdSll.class, Ipv6NdSll.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTarget.class, Ipv6NdTarget.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTll.class, Ipv6NdTll.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Src.class, Ipv6Src.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata.class, Metadata.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos.class, MplsBos.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel.class, MplsLabel.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsTc.class, MplsTc.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.PbbIsid.class, PbbIsid.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpDst.class, SctpDst.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpSrc.class, SctpSrc.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpDst.class, TcpDst.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc.class, TcpSrc.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelId.class, TunnelId.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class, UdpDst.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class, UdpSrc.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp.class, VlanPcp.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid.class, VlanVid.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Dst.class, Ipv4Dst.class);
- SAL_TO_OF_TABLE_FEATURES.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Src.class, Ipv4Src.class);
+ Builder<Class<?>, Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField>> builder = ImmutableMap.builder();
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp.class, ArpOp.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSha.class, ArpSha.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSpa.class, ArpSpa.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTha.class, ArpTha.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTpa.class, ArpTpa.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst.class, EthDst.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc.class, EthSrc.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthType.class, EthType.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Code.class, Icmpv4Code.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Type.class, Icmpv4Type.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Code.class, Icmpv6Code.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Type.class, Icmpv6Type.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPhyPort.class, InPhyPort.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort.class, InPort.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpDscp.class, IpDscp.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn.class, IpEcn.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto.class, IpProto.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst.class, Ipv4Dst.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Src.class, Ipv4Src.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Dst.class, Ipv6Dst.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr.class, Ipv6Exthdr.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Flabel.class, Ipv6Flabel.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdSll.class, Ipv6NdSll.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTarget.class, Ipv6NdTarget.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTll.class, Ipv6NdTll.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Src.class, Ipv6Src.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata.class, Metadata.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos.class, MplsBos.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel.class, MplsLabel.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsTc.class, MplsTc.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.PbbIsid.class, PbbIsid.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpDst.class, SctpDst.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpSrc.class, SctpSrc.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpDst.class, TcpDst.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc.class, TcpSrc.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelId.class, TunnelId.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class, UdpDst.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc.class, UdpSrc.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp.class, VlanPcp.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid.class, VlanVid.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Dst.class, Ipv4Dst.class);
+ builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Src.class, Ipv4Src.class);
+ SAL_TO_OF_TABLE_FEATURES = builder.build();
}
private static void setSetFieldTableFeatureProperty(
package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.opendaylight.openflowplugin.api.OFConstants;
return salTableFeaturesList;
}
- private static final Map<TableFeaturesPropType, ActionExecutor> TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION = new HashMap<>();
+ private static final Map<TableFeaturesPropType, ActionExecutor> TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION;
static {
+ final Builder<TableFeaturesPropType, ActionExecutor> builder = ImmutableMap.builder();
- TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTINSTRUCTIONS, new ActionExecutor() {
+ builder.put(TableFeaturesPropType.OFPTFPTINSTRUCTIONS, new ActionExecutor() {
@Override
public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
propBuilder.setTableFeaturePropType(instructionBuilder.build());
}
});
- TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS, new ActionExecutor() {
+ builder.put(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS, new ActionExecutor() {
@Override
public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
propBuilder.setTableFeaturePropType(instructionMissBuilder.build());
}
});
- TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTNEXTTABLES, new ActionExecutor() {
+ builder.put(TableFeaturesPropType.OFPTFPTNEXTTABLES, new ActionExecutor() {
@Override
public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
propBuilder.setTableFeaturePropType(nextTableBuilder.build());
}
});
- TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS, new ActionExecutor() {
+ builder.put(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS, new ActionExecutor() {
@Override
public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
propBuilder.setTableFeaturePropType(nextTableMissBuilder.build());
}
});
- TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTWRITEACTIONS, new ActionExecutor() {
+ builder.put(TableFeaturesPropType.OFPTFPTWRITEACTIONS, new ActionExecutor() {
@Override
public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
propBuilder.setTableFeaturePropType(writeActionsBuilder.build());
}
});
- TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS, new ActionExecutor() {
+ builder.put(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS, new ActionExecutor() {
@Override
public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
propBuilder.setTableFeaturePropType(writeActionsMissBuilder.build());
}
});
- TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTAPPLYACTIONS, new ActionExecutor() {
+ builder.put(TableFeaturesPropType.OFPTFPTAPPLYACTIONS, new ActionExecutor() {
@Override
public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
propBuilder.setTableFeaturePropType(applyActionsBuilder.build());
}
});
- TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS, new ActionExecutor() {
+ builder.put(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS, new ActionExecutor() {
@Override
public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
propBuilder.setTableFeaturePropType(applyActionsMissBuilder.build());
}
});
- TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTMATCH, new ActionExecutor() {
+ builder.put(TableFeaturesPropType.OFPTFPTMATCH, new ActionExecutor() {
@Override
public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
propBuilder.setTableFeaturePropType(new MatchBuilder().setMatchSetfield(matchBuilder.build()).build());
}
});
- TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTWILDCARDS, new ActionExecutor() {
+ builder.put(TableFeaturesPropType.OFPTFPTWILDCARDS, new ActionExecutor() {
@Override
public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
propBuilder.setTableFeaturePropType(new WildcardsBuilder().setWildcardSetfield(wildcardsBuilder.build()).build());
}
});
- TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTWRITESETFIELD, new ActionExecutor() {
+ builder.put(TableFeaturesPropType.OFPTFPTWRITESETFIELD, new ActionExecutor() {
@Override
public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldBuilder().setWriteSetfield(writeSetfieldBuilder.build()).build());
}
});
- TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS, new ActionExecutor() {
+ builder.put(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS, new ActionExecutor() {
@Override
public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMissBuilder().setWriteSetfieldMiss(writeSetfieldMissBuilder.build()).build());
}
});
- TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD, new ActionExecutor() {
+ builder.put(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD, new ActionExecutor() {
@Override
public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldBuilder().setApplySetfield(applySetfieldBuilder.build()).build());
}
});
- TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS, new ActionExecutor() {
+ builder.put(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS, new ActionExecutor() {
@Override
public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
}
});
- TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTEXPERIMENTER, new ActionExecutor() {
+ builder.put(TableFeaturesPropType.OFPTFPTEXPERIMENTER, new ActionExecutor() {
@Override
public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
}
});
- TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.put(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS, new ActionExecutor() {
+ builder.put(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS, new ActionExecutor() {
@Override
public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
}
});
+ TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION = builder.build();
+
}
private static TableProperties toTableProperties(final List<TableFeatureProperties> ofTablePropertiesList) {
return nextTableIdsList;
}
- private static final Map<Class<?>, org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> OF_TO_SAL_ACTION = new HashMap<>();
+ private static final Map<Class<?>, org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> OF_TO_SAL_ACTION;
static {
-
- OF_TO_SAL_ACTION.put(OutputActionCase.class, new OutputActionCaseBuilder().build());
- OF_TO_SAL_ACTION.put(GroupCase.class, new GroupActionCaseBuilder().build());
- OF_TO_SAL_ACTION.put(CopyTtlOutCase.class, new CopyTtlOutCaseBuilder().build());
- OF_TO_SAL_ACTION.put(CopyTtlInCase.class, new CopyTtlInCaseBuilder().build());
- OF_TO_SAL_ACTION.put(SetMplsTtlCase.class, new SetMplsTtlActionCaseBuilder().build());
- OF_TO_SAL_ACTION.put(DecMplsTtlCase.class, new DecMplsTtlCaseBuilder().build());
- OF_TO_SAL_ACTION.put(PushVlanCase.class, new PushVlanActionCaseBuilder().build());
- OF_TO_SAL_ACTION.put(PopVlanCase.class, new PopVlanActionCaseBuilder().build());
- OF_TO_SAL_ACTION.put(PushMplsCase.class, new PushMplsActionCaseBuilder().build());
- OF_TO_SAL_ACTION.put(PopMplsCase.class, new PopMplsActionCaseBuilder().build());
- OF_TO_SAL_ACTION.put(SetQueueCase.class, new SetQueueActionCaseBuilder().build());
- OF_TO_SAL_ACTION.put(SetNwTtlCase.class, new SetNwTtlActionCaseBuilder().build());
- OF_TO_SAL_ACTION.put(DecNwTtlCase.class, new DecNwTtlCaseBuilder().build());
- OF_TO_SAL_ACTION.put(SetFieldCase.class, new SetFieldCaseBuilder().build());
- OF_TO_SAL_ACTION.put(PushPbbCase.class, new PushPbbActionCaseBuilder().build());
- OF_TO_SAL_ACTION.put(PopPbbCase.class, new PopPbbActionCaseBuilder().build());
- OF_TO_SAL_ACTION.put(SetNwSrcCase.class, new SetNwSrcActionCaseBuilder().build());
- OF_TO_SAL_ACTION.put(SetNwDstCase.class, new SetNwDstActionCaseBuilder().build());
+ Builder<Class<?>, org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> builder = ImmutableMap.builder();
+
+ builder.put(OutputActionCase.class, new OutputActionCaseBuilder().build());
+ builder.put(GroupCase.class, new GroupActionCaseBuilder().build());
+ builder.put(CopyTtlOutCase.class, new CopyTtlOutCaseBuilder().build());
+ builder.put(CopyTtlInCase.class, new CopyTtlInCaseBuilder().build());
+ builder.put(SetMplsTtlCase.class, new SetMplsTtlActionCaseBuilder().build());
+ builder.put(DecMplsTtlCase.class, new DecMplsTtlCaseBuilder().build());
+ builder.put(PushVlanCase.class, new PushVlanActionCaseBuilder().build());
+ builder.put(PopVlanCase.class, new PopVlanActionCaseBuilder().build());
+ builder.put(PushMplsCase.class, new PushMplsActionCaseBuilder().build());
+ builder.put(PopMplsCase.class, new PopMplsActionCaseBuilder().build());
+ builder.put(SetQueueCase.class, new SetQueueActionCaseBuilder().build());
+ builder.put(SetNwTtlCase.class, new SetNwTtlActionCaseBuilder().build());
+ builder.put(DecNwTtlCase.class, new DecNwTtlCaseBuilder().build());
+ builder.put(SetFieldCase.class, new SetFieldCaseBuilder().build());
+ builder.put(PushPbbCase.class, new PushPbbActionCaseBuilder().build());
+ builder.put(PopPbbCase.class, new PopPbbActionCaseBuilder().build());
+ builder.put(SetNwSrcCase.class, new SetNwSrcActionCaseBuilder().build());
+ builder.put(SetNwDstCase.class, new SetNwDstActionCaseBuilder().build());
+
+ OF_TO_SAL_ACTION = builder.build();
}
private static List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> setActionTableFeatureProperty(
return actionList;
}
- private static final Map<Class<? extends MatchField>, Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField>> OF_TO_SAL_TABLE_FEATURE_PROPERTIES = new HashMap<>();
+ private static final Map<Class<? extends MatchField>, Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField>> OF_TO_SAL_TABLE_FEATURE_PROPERTIES;
static {
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(ArpOp.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(ArpSha.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSha.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(ArpSpa.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSpa.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(ArpTha.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTha.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(ArpTpa.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTpa.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(EthDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(EthSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(EthType.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthType.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(Icmpv4Code.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Code.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(Icmpv4Type.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Type.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(Icmpv6Code.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Code.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(Icmpv6Type.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Type.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(InPhyPort.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPhyPort.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(InPort.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(IpDscp.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpDscp.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(IpEcn.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(IpProto.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(Ipv4Dst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(Ipv4Src.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Src.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(Ipv6Dst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Dst.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(Ipv6Exthdr.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(Ipv6Flabel.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Flabel.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(Ipv6NdSll.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdSll.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(Ipv6NdTarget.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTarget.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(Ipv6NdTll.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTll.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(Ipv6Src.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Src.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(Metadata.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(MplsBos.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(MplsLabel.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(MplsTc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsTc.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(PbbIsid.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.PbbIsid.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(SctpDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpDst.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(SctpSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpSrc.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(TcpDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpDst.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(TcpSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(TunnelId.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelId.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(UdpDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(UdpSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(VlanPcp.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp.class);
- OF_TO_SAL_TABLE_FEATURE_PROPERTIES.put(VlanVid.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid.class);
+ final Builder<Class<? extends MatchField>, Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField>> builder = ImmutableMap.builder();
+
+ builder.put(ArpOp.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp.class);
+ builder.put(ArpSha.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSha.class);
+ builder.put(ArpSpa.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSpa.class);
+ builder.put(ArpTha.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTha.class);
+ builder.put(ArpTpa.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTpa.class);
+ builder.put(EthDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst.class);
+ builder.put(EthSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc.class);
+ builder.put(EthType.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthType.class);
+ builder.put(Icmpv4Code.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Code.class);
+ builder.put(Icmpv4Type.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Type.class);
+ builder.put(Icmpv6Code.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Code.class);
+ builder.put(Icmpv6Type.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Type.class);
+ builder.put(InPhyPort.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPhyPort.class);
+ builder.put(InPort.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort.class);
+ builder.put(IpDscp.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpDscp.class);
+ builder.put(IpEcn.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn.class);
+ builder.put(IpProto.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto.class);
+ builder.put(Ipv4Dst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst.class);
+ builder.put(Ipv4Src.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Src.class);
+ builder.put(Ipv6Dst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Dst.class);
+ builder.put(Ipv6Exthdr.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr.class);
+ builder.put(Ipv6Flabel.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Flabel.class);
+ builder.put(Ipv6NdSll.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdSll.class);
+ builder.put(Ipv6NdTarget.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTarget.class);
+ builder.put(Ipv6NdTll.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTll.class);
+ builder.put(Ipv6Src.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Src.class);
+ builder.put(Metadata.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata.class);
+ builder.put(MplsBos.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos.class);
+ builder.put(MplsLabel.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel.class);
+ builder.put(MplsTc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsTc.class);
+ builder.put(PbbIsid.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.PbbIsid.class);
+ builder.put(SctpDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpDst.class);
+ builder.put(SctpSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpSrc.class);
+ builder.put(TcpDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpDst.class);
+ builder.put(TcpSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc.class);
+ builder.put(TunnelId.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelId.class);
+ builder.put(UdpDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class);
+ builder.put(UdpSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc.class);
+ builder.put(VlanPcp.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp.class);
+ builder.put(VlanVid.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid.class);
+
+ OF_TO_SAL_TABLE_FEATURE_PROPERTIES = builder.build();
}
private static List<SetFieldMatch> setSetFieldTableFeatureProperty(final TableFeatureProperties properties,
return setFieldMatchList;
}
-}
\ No newline at end of file
+}
package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.Ordered;
-
import java.util.Comparator;
/**
*/
public class OrderComparator<T extends Ordered> implements Comparator<T> {
- private static OrderComparator instance = new OrderComparator();
- public static OrderComparator build() {
- return instance;
+ @SuppressWarnings("rawtypes")
+ private static final OrderComparator INSTANCE = new OrderComparator();
+
+ @SuppressWarnings("unchecked")
+ public static <T extends Ordered> OrderComparator<T> build() {
+ return INSTANCE;
}
@Override
} else if (ofMatch.getOxmMatchField().equals(ArpSpa.class)) {
org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.spa._case.ArpSpa arpSpa = ((ArpSpaCase) ofMatch.getMatchEntryValue()).getArpSpa();
if (arpSpa != null) {
- String mask ="";
+ int mask = 32;
if (null != arpSpa.getMask()){
- mask = MatchConvertorUtil.getIpv4Mask(arpSpa.getMask());
+ mask = IpConversionUtil.countBits(arpSpa.getMask());
}
Ipv4Prefix ipv4Prefix = IpConversionUtil.createPrefix(arpSpa.getIpv4Address(), mask);
arpMatchBuilder.setArpSourceTransportAddress(ipv4Prefix);
} else if (ofMatch.getOxmMatchField().equals(ArpTpa.class)) {
org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.tpa._case.ArpTpa arpTpa = ((ArpTpaCase) ofMatch.getMatchEntryValue()).getArpTpa();
if (arpTpa != null) {
- String mask ="";
+ int mask = 32;
if (null != arpTpa.getMask()){
- mask = MatchConvertorUtil.getIpv4Mask(arpTpa.getMask());
+ mask = IpConversionUtil.countBits(arpTpa.getMask());
}
Ipv4Prefix ipv4Prefix = IpConversionUtil.createPrefix(arpTpa.getIpv4Address(), mask);
}
private static void setIpv6MatchBuilderFields(final Ipv6MatchBuilder ipv6MatchBuilder, final MatchEntry ofMatch, String ipv6PrefixStr, final byte[] mask) {
+ Ipv6Prefix ipv6Prefix;
+
if (mask != null) {
- ipv6PrefixStr += IpConversionUtil.PREFIX_SEPARATOR
- + MatchConvertorUtil.ipv6NetmaskArrayToCIDRValue(mask);
+ ipv6Prefix = IpConversionUtil.createPrefix(new Ipv6Address(ipv6PrefixStr), mask);
+ } else {
+ ipv6Prefix = IpConversionUtil.createPrefix(new Ipv6Address(ipv6PrefixStr));
}
if (ofMatch.getOxmMatchField().equals(Ipv6Src.class)) {
- ipv6MatchBuilder.setIpv6Source(new Ipv6Prefix(ipv6PrefixStr));
+ ipv6MatchBuilder.setIpv6Source(ipv6Prefix);
}
if (ofMatch.getOxmMatchField().equals(Ipv6Dst.class)) {
- ipv6MatchBuilder.setIpv6Destination(new Ipv6Prefix(ipv6PrefixStr));
+ ipv6MatchBuilder.setIpv6Destination(ipv6Prefix);
}
}
private static void setIpv4MatchBuilderFields(final Ipv4MatchBuilder ipv4MatchBuilder, final MatchEntry ofMatch, final byte[] mask, String ipv4PrefixStr) {
+ Ipv4Prefix ipv4Prefix;
if (mask != null) {
- ipv4PrefixStr += MatchConvertorUtil.getIpv4Mask(mask);
+ ipv4Prefix = IpConversionUtil.createPrefix(new Ipv4Address(ipv4PrefixStr), mask);
} else {
//Openflow Spec : 1.3.2
//An all-one-bits oxm_mask is equivalent to specifying 0 for oxm_hasmask and omitting oxm_mask.
// So when user specify 32 as a mast, switch omit that mast and we get null as a mask in flow
// statistics response.
-
- ipv4PrefixStr += IpConversionUtil.PREFIX_SEPARATOR + "32";
+ ipv4Prefix = IpConversionUtil.createPrefix(new Ipv4Address(ipv4PrefixStr));
}
if (ofMatch.getOxmMatchField().equals(Ipv4Src.class)) {
- ipv4MatchBuilder.setIpv4Source(new Ipv4Prefix(ipv4PrefixStr));
+ ipv4MatchBuilder.setIpv4Source(ipv4Prefix);
}
if (ofMatch.getOxmMatchField().equals(Ipv4Dst.class)) {
- ipv4MatchBuilder.setIpv4Destination(new Ipv4Prefix(ipv4PrefixStr));
+ ipv4MatchBuilder.setIpv4Destination(ipv4Prefix);
}
}
private static final String PREFIX_SEPARATOR = "/";
- /**
- * @param maskEntry
- * @return subnetwork suffix in form of "/"+<mask value {0..32}>
- */
- public static String getIpv4Mask(byte[] maskEntry) {
- int receivedMask = ByteBuffer.wrap(maskEntry).getInt();
- int shiftCount = 0;
-
- if (receivedMask == 0) {
- shiftCount = 32;
- } else {
- while (receivedMask != 0xffffffff) {
- receivedMask = receivedMask >> 1;
- shiftCount++;
- if (shiftCount >= 32) {
- throw new IllegalArgumentException("given mask is invalid: " + Arrays.toString(maskEntry));
- }
- }
- }
- return PREFIX_SEPARATOR + (32 - shiftCount);
- }
-
/**
* @param pField
* @return integer containing lower 9 bits filled with corresponding flags
return bitmap;
}
- public static int ipv6NetmaskArrayToCIDRValue(byte[] rawMask) {
-
- /*
- * Openflow Spec : 1.3.2+
- * An all-one-bits oxm_mask is equivalent to specifying 0 for oxm_hasmask and omitting oxm_mask.
- * So when user specify 128 as a mask, switch omit that mask and we get null as a mask in flow
- * statistics response.
- */
-
- int maskValue = 128;
-
- if (rawMask != null) {
- maskValue = 0;
- for (int subArrayCounter = 0; subArrayCounter < 4; subArrayCounter++) {
- int copyFrom = subArrayCounter * 4;
-
- byte[] subArray = Arrays.copyOfRange(rawMask, copyFrom, copyFrom + 4);
-
- int receivedMask = ByteBuffer.wrap(subArray).getInt();
-
- int shiftCount = 0;
-
- if (receivedMask == 0) {
- break;
- }
-
- while (receivedMask != 0xffffffff) {
- receivedMask = receivedMask >> 1;
- shiftCount++;
- }
-
- maskValue = maskValue + (32 - shiftCount);
- if (shiftCount != 0) {
- break;
- }
- }
- }
- return maskValue;
- }
-
}
*/
public class MatchReactor extends ConvertReactor<Match> {
- private static MatchReactor INSTANCE = new MatchReactor();
+ private static final MatchReactor INSTANCE = new MatchReactor();
private MatchReactor() {
//NOOP
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.IpConversionUtil;
public class FlowRemovedTranslator implements IMDMessageTranslator<OfHeader, List<DataObject>> {
}
if (field.equals(Ipv4Src.class)) {
Ipv4SrcCase ipv4SrcCase = ((Ipv4SrcCase) entry.getMatchEntryValue());
- Ipv4Address ipv4Address = ipv4SrcCase.getIpv4Src().getIpv4Address();
- String ipAddressString = ipv4Address.getValue();
- String prefix = "";
+ int prefix;
if (entry.isHasMask()) {
- byte[] mask = ipv4SrcCase.getIpv4Src().getMask();
- prefix = prefix + PREFIX_SEPARATOR + countBits(mask);
+ prefix = IpConversionUtil.countBits(ipv4SrcCase.getIpv4Src().getMask());
} else {
- prefix += PREFIX_SEPARATOR + "32";
+ prefix = 32;
}
- ipv4Match.setIpv4Source(createIpv4Prefix(ipAddressString, prefix));
+ ipv4Match.setIpv4Source(
+ IpConversionUtil.createPrefix(ipv4SrcCase.getIpv4Src().getIpv4Address(), prefix)
+ );
} else if (field.equals(Ipv4Dst.class)) {
Ipv4DstCase ipv4DstCase = ((Ipv4DstCase) entry.getMatchEntryValue());
- Ipv4Address ipv4Address = ipv4DstCase.getIpv4Dst().getIpv4Address();
- String ipAddressString = ipv4Address.getValue();
- String prefix = "";
+ int prefix;
if (entry.isHasMask()) {
- byte[] mask = ipv4DstCase.getIpv4Dst().getMask();
- prefix = prefix + PREFIX_SEPARATOR + countBits(mask);
+ prefix = IpConversionUtil.countBits(ipv4DstCase.getIpv4Dst().getMask());
} else {
- prefix += PREFIX_SEPARATOR + "32";
+ prefix = 32;
}
- ipv4Match.setIpv4Destination(createIpv4Prefix(ipAddressString, prefix));
+ ipv4Match.setIpv4Destination(
+ IpConversionUtil.createPrefix(ipv4DstCase.getIpv4Dst().getIpv4Address(), prefix)
+ );
}
} else if (field.equals(ArpOp.class) || field.equals(ArpSpa.class) || field.equals(ArpTpa.class)
|| field.equals(ArpSha.class) || field.equals(ArpTha.class)) {
} else if (field.equals(ArpSpa.class)) {
ArpSpaCase arpSpaCase = ((ArpSpaCase) entry.getMatchEntryValue());
- Ipv4Address ipv4Address = arpSpaCase.getArpSpa().getIpv4Address();
- String ipAddressString = ipv4Address.getValue();
- String prefix = "";
+ int prefix;
if (entry.isHasMask()) {
- byte[] mask = arpSpaCase.getArpSpa().getMask();
- prefix = prefix + PREFIX_SEPARATOR + countBits(mask);
+ prefix = IpConversionUtil.countBits(arpSpaCase.getArpSpa().getMask());
} else {
- prefix += PREFIX_SEPARATOR + "32";
+ prefix = 32;
}
-
- arpMatch.setArpSourceTransportAddress(createIpv4Prefix(ipAddressString, prefix));
+ arpMatch.setArpSourceTransportAddress(
+ IpConversionUtil.createPrefix(arpSpaCase.getArpSpa().getIpv4Address(), prefix)
+ );
} else if (field.equals(ArpTpa.class)) {
ArpTpaCase arpTpaCase = ((ArpTpaCase) entry.getMatchEntryValue());
- Ipv4Address ipv4Address = arpTpaCase.getArpTpa().getIpv4Address();
- String ipAddressString = ipv4Address.getValue();
- String prefix = "";
+ int prefix;
if (entry.isHasMask()) {
- byte[] mask = arpTpaCase.getArpTpa().getMask();
- prefix = prefix + PREFIX_SEPARATOR + countBits(mask);
+ prefix = IpConversionUtil.countBits(arpTpaCase.getArpTpa().getMask());
} else {
- prefix += PREFIX_SEPARATOR + "32";
+ prefix = 32;
}
- arpMatch.setArpTargetTransportAddress(createIpv4Prefix(ipAddressString, prefix));
+ arpMatch.setArpTargetTransportAddress(
+ IpConversionUtil.createPrefix(arpTpaCase.getArpTpa().getIpv4Address(), prefix)
+ );
} else if (field.equals(ArpSha.class)) {
ArpSourceHardwareAddressBuilder arpSha = new ArpSourceHardwareAddressBuilder();
ArpShaCase arpShaCase = ((ArpShaCase) entry.getMatchEntryValue());
}
if (field.equals(TunnelIpv4Src.class)) {
Ipv4SrcCase ipv4SrcCase = ((Ipv4SrcCase) entry.getMatchEntryValue());
- Ipv4Address ipv4Address = ipv4SrcCase.getIpv4Src().getIpv4Address();
- String ipAddressString = ipv4Address.getValue();
-
- String prefix = "";
+ int prefix;
if (entry.isHasMask()) {
- byte[] mask = ipv4SrcCase.getIpv4Src().getMask();
- prefix = prefix + PREFIX_SEPARATOR + countBits(mask);
+ prefix = IpConversionUtil.countBits(ipv4SrcCase.getIpv4Src().getMask());
} else {
- prefix += PREFIX_SEPARATOR + "32";
+ prefix = 32;
}
-
- ipv4Match.setIpv4Source(createIpv4Prefix(ipAddressString, prefix));
+
+ ipv4Match.setIpv4Source(
+ IpConversionUtil.createPrefix(ipv4SrcCase.getIpv4Src().getIpv4Address(), prefix)
+ );
} else if (field.equals(TunnelIpv4Dst.class)) {
Ipv4DstCase ipv4DstCase = ((Ipv4DstCase) entry.getMatchEntryValue());
- Ipv4Address ipv4Address = ipv4DstCase.getIpv4Dst().getIpv4Address();
- String ipAddressString = ipv4Address.getValue();
- String prefix = "";
+ int prefix;
if (entry.isHasMask()) {
- byte[] mask = ipv4DstCase.getIpv4Dst().getMask();
- prefix = prefix + PREFIX_SEPARATOR + countBits(mask);
+ prefix = IpConversionUtil.countBits(ipv4DstCase.getIpv4Dst().getMask());
} else {
- prefix += PREFIX_SEPARATOR + "32";
+ prefix = 32;
}
-
- ipv4Match.setIpv4Destination(createIpv4Prefix(ipAddressString, prefix));
- }
+
+ ipv4Match.setIpv4Destination(
+ IpConversionUtil.createPrefix(ipv4DstCase.getIpv4Dst().getIpv4Address(), prefix)
+ ); }
} else if (field.equals(Ipv6Src.class) || field.equals(Ipv6Dst.class) || field.equals(Ipv6Flabel.class)
|| field.equals(Ipv6NdTarget.class) || field.equals(Ipv6NdSll.class)
|| field.equals(Ipv6NdTll.class) || field.equals(Ipv6Exthdr.class)) {
}
if (field.equals(Ipv6Src.class)) {
Ipv6SrcCase ipv6SrcCase = ((Ipv6SrcCase) entry.getMatchEntryValue());
- Ipv6Address ipv6Address = ipv6SrcCase.getIpv6Src().getIpv6Address();
- String ipv6string = ipv6Address.getValue();
- String prefix = "";
+ int prefix ;
if (entry.isHasMask()) {
- byte[] mask = ipv6SrcCase.getIpv6Src().getMask();
- prefix = prefix + PREFIX_SEPARATOR + countBits(mask);
+ prefix = IpConversionUtil.countBits(ipv6SrcCase.getIpv6Src().getMask());
+ } else {
+ prefix = 128;
}
-
- ipv6Match.setIpv6Source(createIpv6Prefix(ipv6string, prefix));
+ ipv6Match.setIpv6Source(
+ IpConversionUtil.createPrefix(ipv6SrcCase.getIpv6Src().getIpv6Address(), prefix)
+ );
} else if (field.equals(Ipv6Dst.class)) {
Ipv6DstCase ipv6DstCase = ((Ipv6DstCase) entry.getMatchEntryValue());
- Ipv6Address ipv6Address = ipv6DstCase.getIpv6Dst().getIpv6Address();
- String ipv6string = ipv6Address.getValue();
- String prefix = "";
+ int prefix;
if (entry.isHasMask()) {
- byte[] mask = ipv6DstCase.getIpv6Dst().getMask();
- prefix = prefix + PREFIX_SEPARATOR + countBits(mask);
+ prefix = IpConversionUtil.countBits(ipv6DstCase.getIpv6Dst().getMask());
+ } else {
+ prefix = 128;
}
-
- ipv6Match.setIpv6Destination(createIpv6Prefix(ipv6string, prefix));
+ ipv6Match.setIpv6Destination(
+ IpConversionUtil.createPrefix(ipv6DstCase.getIpv6Dst().getIpv6Address(), prefix)
+ );
} else if (field.equals(Ipv6Flabel.class)) {
Ipv6LabelBuilder ipv6Label = new Ipv6LabelBuilder();
Ipv6FlabelCase ipv6FlabelCase = ((Ipv6FlabelCase) entry.getMatchEntryValue());
return matchBuilder.build();
}
- private Ipv6Prefix createIpv6Prefix(final String ipv6string, final String prefix) {
- return new Ipv6Prefix(ipv6string + prefix);
- }
-
- private Ipv4Prefix createIpv4Prefix(final String ipAddressString, final String prefix) {
- return new Ipv4Prefix(ipAddressString + prefix);
- }
-
- private int toInt(byte b) {
- return b < 0 ? b + 256 : b;
- }
-
- private int countBits(byte[] mask) {
- int netmask = 0;
- for (byte b : mask) {
- netmask += Integer.bitCount(toInt(b));
- }
- return netmask;
- }
}
org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder =
new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
Address address;
- address = new Ipv6Builder().setIpv6Address(new Ipv6Prefix("2001:0db8:85a3:0042:1000:8a2e:0370:7334")).build();
+ /* Use canonical form - no leading zeroes!!! */
+ address = new Ipv6Builder().setIpv6Address(new Ipv6Prefix("2001:db8:85a3:42:1000:8a2e:370:7334/128")).build();
SetNwDstActionCase action = provisionNwDstActionBuilder(address);
org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action ofAction = ActionConvertor.salToOFSetNwDst(action, actionBuilder, version);
Assert.assertNull(ofAction);
org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder =
new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
Address address;
- address = new Ipv6Builder().setIpv6Address(new Ipv6Prefix("2001:0db8:85a3:0042:1000:8a2e:0370:7334")).build();
+ /* Use canonical form - no leading zeroes and a prefix, even if the prefix is /128 !!! */
+ address = new Ipv6Builder().setIpv6Address(new Ipv6Prefix("2001:db8:85a3:42:1000:8a2e:370:7334/128")).build();
SetNwDstActionCase action = provisionNwDstActionBuilder(address);
ActionConvertor.salToOFSetNwDst(action, actionBuilder, version);
Assert.assertEquals(SetFieldCase.class.getName(), actionBuilder.getActionChoice().getImplementedInterface().getName());
MatchEntry matchEntry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
Assert.assertEquals(Ipv6Dst.class.getName(), matchEntry.getOxmMatchField().getName());
Ipv6DstCase ipv6DstCase = ((Ipv6DstCase) matchEntry.getMatchEntryValue());
- Assert.assertEquals("2001:0db8:85a3:0042:1000:8a2e:0370:7334", ipv6DstCase.getIpv6Dst().getIpv6Address().getValue());
+ /* We check the IP only, the netmask should have gone into the wildcard field */
+ Assert.assertEquals("2001:db8:85a3:42:1000:8a2e:370:7334", ipv6DstCase.getIpv6Dst().getIpv6Address().getValue());
}
org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder =
new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
Address address;
- address = new Ipv6Builder().setIpv6Address(new Ipv6Prefix("2001:0db8:85a3:0042:1000:8a2e:0370:7334")).build();
+ /* Use canonical form - no leading zeroes and a prefix, even if the prefix is /128 !!! */
+ address = new Ipv6Builder().setIpv6Address(new Ipv6Prefix("2001:db8:85a3:42:1000:8a2e:370:7334/128")).build();
SetNwSrcActionCase action = provisionNwSrcActionBuilder(address);
org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action ofAction = ActionConvertor.salToOFSetNwSrc(action, actionBuilder, version);
Assert.assertNull(ofAction);
org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionBuilder =
new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
Address address;
- address = new Ipv6Builder().setIpv6Address(new Ipv6Prefix("2001:0db8:85a3:0042:1000:8a2e:0370:7334")).build();
+ /* Use canonical form - no leading zeroes and a prefix, even if the prefix is /128 !!! */
+ address = new Ipv6Builder().setIpv6Address(new Ipv6Prefix("2001:db8:85a3:42:1000:8a2e:370:7334/128")).build();
SetNwSrcActionCase action = provisionNwSrcActionBuilder(address);
ActionConvertor.salToOFSetNwSrc(action, actionBuilder, version);
Assert.assertEquals(SetFieldCase.class.getName(), actionBuilder.getActionChoice().getImplementedInterface().getName());
MatchEntry matchEntry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
Ipv6SrcCase ipv6SrcCase = ((Ipv6SrcCase) matchEntry.getMatchEntryValue());
Assert.assertEquals(Ipv6Src.class.getName(), matchEntry.getOxmMatchField().getName());
- Assert.assertEquals("2001:0db8:85a3:0042:1000:8a2e:0370:7334", ipv6SrcCase.getIpv6Src().getIpv6Address().getValue());
+ /* We check the IP only, the netmask should have gone into the wildcard field */
+ Assert.assertEquals("2001:db8:85a3:42:1000:8a2e:370:7334", ipv6SrcCase.getIpv6Src().getIpv6Address().getValue());
}
/**
SetNwSrcActionCaseBuilder nwSrcCaseBuilder = new SetNwSrcActionCaseBuilder();\r
SetNwSrcActionBuilder nwSrcBuilder = new SetNwSrcActionBuilder();\r
Ipv4Builder ipv4Builder = new Ipv4Builder();\r
- ipv4Builder.setIpv4Address(new Ipv4Prefix("10.0.0.1/24"));\r
+ /* Use prefix which is correct in canonical representation in test */\r
+ ipv4Builder.setIpv4Address(new Ipv4Prefix("10.0.0.0/24"));\r
nwSrcBuilder.setAddress(ipv4Builder.build());\r
nwSrcCaseBuilder.setSetNwSrcAction(nwSrcBuilder.build());\r
actionBuilder.setAction(nwSrcCaseBuilder.build());\r
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"\r
+ ".action.rev150203.action.grouping.action.choice.SetNwSrcCase", action.getActionChoice().getImplementedInterface().getName());\r
SetNwSrcCase setNwSrcCase = (SetNwSrcCase) action.getActionChoice();\r
- Assert.assertEquals("Wrong nw src", "10.0.0.1", setNwSrcCase.getSetNwSrcAction().getIpAddress().getValue());\r
+ Assert.assertEquals("Wrong nw src", "10.0.0.0", setNwSrcCase.getSetNwSrcAction().getIpAddress().getValue());\r
\r
action = actions.get(5);\r
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"\r
Assert.assertEquals("Wrong output port", "14", outputAction.getOutputAction().getOutputNodeConnector().getValue());\r
Assert.assertEquals("Wrong max length", 555, outputAction.getOutputAction().getMaxLength().intValue());\r
}\r
-}
\ No newline at end of file
+}\r
SetNwSrcActionCaseBuilder nwSrcCaseBuilder = new SetNwSrcActionCaseBuilder();\r
SetNwSrcActionBuilder nwSrcBuilder = new SetNwSrcActionBuilder();\r
Ipv4Builder ipv4Builder = new Ipv4Builder();\r
- ipv4Builder.setIpv4Address(new Ipv4Prefix("10.0.0.1/24"));\r
+ /* Correct canonical form for v4 prefix!!! */\r
+ ipv4Builder.setIpv4Address(new Ipv4Prefix("10.0.0.0/24"));\r
nwSrcBuilder.setAddress(ipv4Builder.build());\r
nwSrcCaseBuilder.setSetNwSrcAction(nwSrcBuilder.build());\r
actionBuilder.setAction(nwSrcCaseBuilder.build());\r
nwSrcCaseBuilder = new SetNwSrcActionCaseBuilder();\r
nwSrcBuilder = new SetNwSrcActionBuilder();\r
Ipv6Builder ipv6Builder = new Ipv6Builder();\r
- ipv6Builder.setIpv6Address(new Ipv6Prefix("0000:0000:0000:0000:0000:0000:0000:0005/128"));\r
+ /* Use canonical form, 00:00:0000 is not a valid v6 notation */\r
+ ipv6Builder.setIpv6Address(new Ipv6Prefix("::5/128"));\r
nwSrcBuilder.setAddress(ipv6Builder.build());\r
nwSrcCaseBuilder.setSetNwSrcAction(nwSrcBuilder.build());\r
actionBuilder.setAction(nwSrcCaseBuilder.build());\r
nwDstCaseBuilder = new SetNwDstActionCaseBuilder();\r
nwDstBuilder = new SetNwDstActionBuilder();\r
ipv6Builder = new Ipv6Builder();\r
- ipv6Builder.setIpv6Address(new Ipv6Prefix("0000:0000:0000:0000:0000:0000:0000:0008/64"));\r
+ /* Use canonical form, 00:00:0006/64 is not a valid v6 notation - this equates to ::/64 */\r
+ ipv6Builder.setIpv6Address(new Ipv6Prefix("::/64"));\r
nwDstBuilder.setAddress(ipv6Builder.build());\r
nwDstCaseBuilder.setSetNwDstAction(nwDstBuilder.build());\r
actionBuilder.setAction(nwDstCaseBuilder.build());\r
+ ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());\r
entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);\r
checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Src.class, false);\r
- Assert.assertEquals("Wrong ipv4 src", "10.0.0.1", ((Ipv4SrcCase) entry.getMatchEntryValue()).getIpv4Src()\r
+ Assert.assertEquals("Wrong ipv4 src", "10.0.0.0", ((Ipv4SrcCase) entry.getMatchEntryValue()).getIpv4Src()\r
.getIpv4Address().getValue());\r
\r
action = actions.get(5);\r
+ ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());\r
entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);\r
checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Src.class, false);\r
- Assert.assertEquals("Wrong ipv4 src", "0000:0000:0000:0000:0000:0000:0000:0005",\r
+ Assert.assertEquals("Wrong ipv6 src", "::5",\r
((Ipv6SrcCase) entry.getMatchEntryValue()).getIpv6Src().getIpv6Address().getValue());\r
\r
action = actions.get(11);\r
+ ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());\r
entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);\r
checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Dst.class, false);\r
- Assert.assertEquals("Wrong ipv4 dst", "0000:0000:0000:0000:0000:0000:0000:0008",\r
+ Assert.assertEquals("Wrong ipv6 dst", "::",\r
((Ipv6DstCase) entry.getMatchEntryValue()).getIpv6Dst().getIpv6Address().getValue());\r
}\r
\r
Assert.assertEquals("Wrong oxm field", field, entry.getOxmMatchField());\r
Assert.assertEquals("Wrong hasMask", hasMask, entry.isHasMask());\r
}\r
-}
\ No newline at end of file
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2014 Brocade Communications Systems Inc and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;\r
+\r
+\r
+import org.junit.Assert;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import java.util.Arrays;\r
+import java.math.BigInteger;\r
+\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;\r
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.IpConversionUtil;\r
+\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.opendaylight.openflowjava.util.ByteBufUtils;\r
+\r
+\r
+/**\r
+ * @author Anton Ivanov aivanov@brocade.com\r
+ *\r
+ */\r
+public class IpConversionUtilTest {\r
+\r
+ private static Logger LOG = LoggerFactory\r
+ .getLogger(IpConversionUtilTest.class);\r
+\r
+\r
+\r
+ /*\r
+ * Test canonicalBinaryV6Address\r
+ */\r
+ @Test\r
+ public void canonicalBinaryV6AddressTest() {\r
+\r
+ byte [] ipv6binary = IpConversionUtil.canonicalBinaryV6Address(new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0001"));\r
+ byte [] expected = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,1};\r
+\r
+ Assert.assertTrue("Incorrect canonicalization - binary", Arrays.equals(ipv6binary, expected));\r
+ try {\r
+ Assert.assertEquals("Incorrect canonicalization - string", "::1", IpConversionUtil.byteArrayV6AddressToString(ipv6binary));\r
+ } catch (java.net.UnknownHostException e) {\r
+ Assert.assertTrue("Incorrect canonicalization - wrong length of byte[]", false);\r
+ }\r
+ }\r
+\r
+ /*\r
+ * Test canonicalBinaryV6Prefix\r
+ */\r
+ @Test\r
+ public void canonicalBinaryV6AddressPrefixTest() {\r
+\r
+ byte [] ipv6binary = IpConversionUtil.canonicalBinaryV6Prefix(new Ipv6Prefix("0000:0000:0000:0000:0000:0000:0000:0001/64"));\r
+ byte [] expected = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 64};\r
+\r
+ Assert.assertTrue("Incorrect canonicalization - binary", Arrays.equals(ipv6binary, expected));\r
+ try {\r
+ Assert.assertEquals("Incorrect canonicalization - string", "::/64", IpConversionUtil.byteArrayV6PrefixToString(ipv6binary));\r
+ } catch (java.net.UnknownHostException e){\r
+ Assert.assertTrue("Incorrect canonicalization - wrong length of byte[]", false);\r
+ }\r
+ }\r
+\r
+ @Test\r
+ public void testCountBitsAsCIDRReplacement() throws Exception {\r
+ BigInteger maskSeed = new BigInteger("1ffffffffffffffffffffffffffffffff", 16);\r
+ byte[] maskArray = new byte[16];\r
+ LOG.debug("maskSeed= {}", ByteBufUtils.bytesToHexString(maskSeed.toByteArray()));\r
+\r
+ for (int i = 0; i <= 128; i++) {\r
+ System.arraycopy(maskSeed.toByteArray(), 1, maskArray, 0, 16);\r
+ LOG.debug("maskHex[{}] = {}", i, ByteBufUtils.bytesToHexString(maskArray));\r
+ int cidr = IpConversionUtil.countBits(maskArray);\r
+ LOG.debug("cidr = {}", cidr);\r
+ Assert.assertEquals(128 - i, cidr);\r
+\r
+ maskSeed = maskSeed.clearBit(i);\r
+ }\r
+ }\r
+\r
+\r
+ /**\r
+ * Test method for {@link MatchConvertorUtil#getIpv4Mask(byte[])}.\r
+ *\r
+ * @throws Exception\r
+ */\r
+\r
+ @Test\r
+ public void testcountBitsAsGetIpv4Mask() {\r
+ byte[][] maskInputs = new byte[][]{\r
+ {(byte) 255, (byte) 255, (byte) 255, (byte) 255},\r
+ {(byte) 255, (byte) 255, (byte) 254, 0},\r
+ {(byte) 128, 0, 0, 0},\r
+ {0, 0, 0, 0},\r
+ };\r
+\r
+ int[] maskOutputs = new int[]{\r
+ 32, 23, 1, 0\r
+ };\r
+\r
+ for (int i = 0; i < maskInputs.length; i++) {\r
+ int mask = IpConversionUtil.countBits(maskInputs[i]);\r
+ Assert.assertEquals(maskOutputs[i], mask);\r
+ }\r
+ }\r
+}\r
*/
package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action;
+import java.math.BigInteger;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
-import java.math.BigInteger;
/**
* match conversion and injection test
addresses = new Address[]{
new Ipv4Builder().setIpv4Address(new Ipv4Prefix("10.0.10.1/32")).build(),
new Ipv4Builder().setIpv4Address(new Ipv4Prefix("10.0.10.1/16")).build(),
- new Ipv6Builder().setIpv6Address(new Ipv6Prefix("1234:5678:9abc:def1:2345:6789:abcd:ef12")).build(),
+ new Ipv6Builder().setIpv6Address(new Ipv6Prefix("1234:5678:9abc:def1:2345:6789:abcd:ef12/128")).build(),
new Ipv6Builder().setIpv6Address(new Ipv6Prefix("1234:5678:9abc:def1:2345:6789:abcd:ef12/42")).build(),
};
}
*/
@Test
public void testMatchConvertorV13_flow() {
- ActionBuilder target = new ActionBuilder();
- for (Address address : addresses) {
- SetNwDstActionCase action = prepareSetNwDstActionCase(address);
+ final ActionBuilder target = new ActionBuilder();
+ for (final Address address : addresses) {
+ final SetNwDstActionCase action = prepareSetNwDstActionCase(address);
ActionSetNwDstReactor.getInstance().convert(action,
OFConstants.OFP_VERSION_1_3, target, BigInteger.ONE);
- Object mEntry = target.getActionChoice();
+ final Object mEntry = target.getActionChoice();
/*
Assert.assertNotNull(mEntry);
if (address instanceof Ipv4) {
* @param address
* @return
*/
- private static SetNwDstActionCase prepareSetNwDstActionCase(Address address) {
+ private static SetNwDstActionCase prepareSetNwDstActionCase(final Address address) {
return new SetNwDstActionCaseBuilder().setSetNwDstAction(
new SetNwDstActionBuilder().setAddress(address).build()).build();
}
*/
@Test
public void testMatchConvertorV10_flow() {
- ActionBuilder target = new ActionBuilder();
- for (Address address : addresses) {
- SetNwDstActionCase action = prepareSetNwDstActionCase(address);
+ final ActionBuilder target = new ActionBuilder();
+ for (final Address address : addresses) {
+ final SetNwDstActionCase action = prepareSetNwDstActionCase(address);
if (address instanceof Ipv4) {
ActionSetNwDstReactor.getInstance().convert(action,
ActionSetNwDstReactor.getInstance().convert(action,
OFConstants.OFP_VERSION_1_0, target, BigInteger.ONE);
Assert.fail("address of this type must not pass the reactor: " + address.getClass().getName());
- } catch (Exception e) {
+ } catch (final Exception e) {
//expected
Assert.assertEquals(IllegalArgumentException.class, e.getClass());
}
*/
package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action;
+import java.math.BigInteger;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
-import java.math.BigInteger;
/**
* match conversion and injection test
addresses = new Address[]{
new Ipv4Builder().setIpv4Address(new Ipv4Prefix("10.0.10.1/32")).build(),
new Ipv4Builder().setIpv4Address(new Ipv4Prefix("10.0.10.1/16")).build(),
- new Ipv6Builder().setIpv6Address(new Ipv6Prefix("1234:5678:9abc:def1:2345:6789:abcd:ef12")).build(),
+ new Ipv6Builder().setIpv6Address(new Ipv6Prefix("1234:5678:9abc:def1:2345:6789:abcd:ef12/128")).build(),
new Ipv6Builder().setIpv6Address(new Ipv6Prefix("1234:5678:9abc:def1:2345:6789:abcd:ef12/42")).build(),
};
}
@Test
public void testMatchConvertorV13_flow() {
- ActionBuilder target = new ActionBuilder();
- for (Address address : addresses) {
- SetNwSrcActionCase action = prepareSetNwSrcActionCase(address);
+ final ActionBuilder target = new ActionBuilder();
+ for (final Address address : addresses) {
+ final SetNwSrcActionCase action = prepareSetNwSrcActionCase(address);
ActionSetNwSrcReactor.getInstance().convert(action,
OFConstants.OFP_VERSION_1_3, target, BigInteger.ONE);
/*
* @param address
* @return
*/
- private static SetNwSrcActionCase prepareSetNwSrcActionCase(Address address) {
+ private static SetNwSrcActionCase prepareSetNwSrcActionCase(final Address address) {
return new SetNwSrcActionCaseBuilder().setSetNwSrcAction(
new SetNwSrcActionBuilder().setAddress(address).build()).build();
}
*/
@Test
public void testMatchConvertorV10_flow() {
- ActionBuilder target = new ActionBuilder();
- for (Address address : addresses) {
- SetNwSrcActionCase action = prepareSetNwSrcActionCase(address);
+ final ActionBuilder target = new ActionBuilder();
+ for (final Address address : addresses) {
+ final SetNwSrcActionCase action = prepareSetNwSrcActionCase(address);
if (address instanceof Ipv4) {
ActionSetNwSrcReactor.getInstance().convert(action,
ActionSetNwSrcReactor.getInstance().convert(action,
OFConstants.OFP_VERSION_1_0, target, BigInteger.ONE);
Assert.fail("address of this type must not pass the reactor: " + address.getClass().getName());
- } catch (Exception e) {
+ } catch (final Exception e) {
//expected
Assert.assertEquals(IllegalArgumentException.class, e.getClass());
}
public void testArpMatchConversionWithMasks() {\r
MatchBuilder builder = new MatchBuilder();\r
ArpMatchBuilder arpBuilder = new ArpMatchBuilder();\r
- arpBuilder.setArpSourceTransportAddress(new Ipv4Prefix("10.0.0.3/8"));\r
+ /* Use canonnical prefixes !!! */\r
+ arpBuilder.setArpSourceTransportAddress(new Ipv4Prefix("10.0.0.0/8"));\r
arpBuilder.setArpTargetTransportAddress(new Ipv4Prefix("10.0.0.4/31"));\r
ArpSourceHardwareAddressBuilder srcHwBuilder = new ArpSourceHardwareAddressBuilder();\r
srcHwBuilder.setAddress(new MacAddress("00:00:00:00:00:05"));\r
MatchEntry entry = entries.get(0);\r
entry = entries.get(0);\r
checkEntryHeader(entry, ArpSpa.class, true);\r
- Assert.assertEquals("Wrong arp spa", "10.0.0.3", ((ArpSpaCase) entry.getMatchEntryValue())\r
+ Assert.assertEquals("Wrong arp spa", "10.0.0.0", ((ArpSpaCase) entry.getMatchEntryValue())\r
.getArpSpa().getIpv4Address().getValue());\r
Assert.assertArrayEquals("Wrong arp spa mask", new byte[]{(byte) 255, 0, 0, 0},\r
((ArpSpaCase) entry.getMatchEntryValue()).getArpSpa().getMask());\r
public void testIpv6MatchConversion() {\r
MatchBuilder builder = new MatchBuilder();\r
Ipv6MatchBuilder ipv6Builder = new Ipv6MatchBuilder();\r
- ipv6Builder.setIpv6Source(new Ipv6Prefix("0000:0000:0000:0000:0000:0000:0000:0001"));\r
- ipv6Builder.setIpv6Destination(new Ipv6Prefix("0000:0000:0000:0000:0000:0000:0000:0002"));\r
+ ipv6Builder.setIpv6Source(new Ipv6Prefix("::1/128"));\r
+ ipv6Builder.setIpv6Destination(new Ipv6Prefix("::2/128"));\r
Ipv6LabelBuilder ipv6LabelBuilder = new Ipv6LabelBuilder();\r
ipv6LabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(3L));\r
ipv6Builder.setIpv6Label(ipv6LabelBuilder.build());\r
- ipv6Builder.setIpv6NdTarget(new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0004"));\r
+ ipv6Builder.setIpv6NdTarget(new Ipv6Address("::4"));\r
ipv6Builder.setIpv6NdSll(new MacAddress("00:00:00:00:00:05"));\r
ipv6Builder.setIpv6NdTll(new MacAddress("00:00:00:00:00:06"));\r
Ipv6ExtHeaderBuilder extHdrBuilder = new Ipv6ExtHeaderBuilder();\r
List<MatchEntry> entries = convertor.convert(match, new BigInteger("42"));\r
Assert.assertEquals("Wrong entries size", 7, entries.size());\r
MatchEntry entry = entries.get(0);\r
- checkEntryHeader(entry, Ipv6Src.class, false);\r
- Assert.assertEquals("Wrong ipv6 src", "0000:0000:0000:0000:0000:0000:0000:0001",\r
+ /* Due to conversion ambiguities, we always get "has mask" because \r
+ * an ip with no mask and prefix with /128 (or 32 in v4) cannot \r
+ * be distinguished */\r
+ checkEntryHeader(entry, Ipv6Src.class, true);\r
+ Assert.assertEquals("Wrong ipv6 src", "::1",\r
((Ipv6SrcCase) entry.getMatchEntryValue()).getIpv6Src().getIpv6Address().getValue());\r
entry = entries.get(1);\r
- checkEntryHeader(entry, Ipv6Dst.class, false);\r
- Assert.assertEquals("Wrong ipv6 dst", "0000:0000:0000:0000:0000:0000:0000:0002",\r
+ checkEntryHeader(entry, Ipv6Dst.class, true);\r
+ Assert.assertEquals("Wrong ipv6 dst", "::2",\r
((Ipv6DstCase) entry.getMatchEntryValue()).getIpv6Dst().getIpv6Address().getValue());\r
entry = entries.get(2);\r
checkEntryHeader(entry, Ipv6Flabel.class, false);\r
((Ipv6FlabelCase) entry.getMatchEntryValue()).getIpv6Flabel().getIpv6Flabel().getValue().intValue());\r
entry = entries.get(3);\r
checkEntryHeader(entry, Ipv6NdTarget.class, false);\r
- Assert.assertEquals("Wrong ipv6 nd target", "0000:0000:0000:0000:0000:0000:0000:0004",\r
+ Assert.assertEquals("Wrong ipv6 nd target", "::4",\r
((Ipv6NdTargetCase) entry.getMatchEntryValue()).getIpv6NdTarget().getIpv6Address().getValue());\r
entry = entries.get(4);\r
checkEntryHeader(entry, Ipv6NdSll.class, false);\r
public void testIpv6MatchConversionWithMasks() {\r
MatchBuilder builder = new MatchBuilder();\r
Ipv6MatchBuilder ipv6Builder = new Ipv6MatchBuilder();\r
- ipv6Builder.setIpv6Source(new Ipv6Prefix("0000:0000:0000:0000:0000:0000:0000:0001/24"));\r
- ipv6Builder.setIpv6Destination(new Ipv6Prefix("0000:0000:0000:0000:0000:0000:0000:0002/64"));\r
+ ipv6Builder.setIpv6Source(new Ipv6Prefix("::/24"));\r
+ ipv6Builder.setIpv6Destination(new Ipv6Prefix("::/64"));\r
builder.setLayer3Match(ipv6Builder.build());\r
Match match = builder.build();\r
\r
Assert.assertEquals("Wrong entries size", 2, entries.size());\r
MatchEntry entry = entries.get(0);\r
checkEntryHeader(entry, Ipv6Src.class, true);\r
- Assert.assertEquals("Wrong ipv6 src", "0000:0000:0000:0000:0000:0000:0000:0001",\r
+ Assert.assertEquals("Wrong ipv6 src", "::",\r
((Ipv6SrcCase) entry.getMatchEntryValue()).getIpv6Src().getIpv6Address().getValue());\r
Assert.assertArrayEquals("Wrong ipv6 src mask", new byte[]{(byte) 255, (byte) 255, (byte) 255, 0, 0, 0, 0,\r
0, 0, 0, 0, 0, 0, 0, 0, 0}, ((Ipv6SrcCase) entry.getMatchEntryValue()).getIpv6Src().getMask());\r
entry = entries.get(1);\r
checkEntryHeader(entry, Ipv6Dst.class, true);\r
- Assert.assertEquals("Wrong ipv6 dst", "0000:0000:0000:0000:0000:0000:0000:0002",\r
+ Assert.assertEquals("Wrong ipv6 dst", "::",\r
((Ipv6DstCase) entry.getMatchEntryValue()).getIpv6Dst().getIpv6Address().getValue());\r
Assert.assertArrayEquals("Wrong ipv6 src mask", new byte[]{(byte) 255, (byte) 255, (byte) 255, (byte) 255,\r
(byte) 255, (byte) 255, (byte) 255, (byte) 255, 0, 0, 0, 0, 0, 0, 0, 0},\r
tunnelBuilder.setTunnelMask(new BigInteger("14"));\r
builder.setTunnel(tunnelBuilder.build());\r
Ipv4MatchBuilder ipv4MatchBuilder = new Ipv4MatchBuilder();\r
- ipv4MatchBuilder.setIpv4Source(new Ipv4Prefix("10.0.0.1/24"));\r
- ipv4MatchBuilder.setIpv4Destination(new Ipv4Prefix("10.0.0.2/8"));\r
+ ipv4MatchBuilder.setIpv4Source(new Ipv4Prefix("10.0.0.0/24"));\r
+ ipv4MatchBuilder.setIpv4Destination(new Ipv4Prefix("10.0.0.0/8"));\r
builder.setLayer3Match(ipv4MatchBuilder.build());\r
Match match = builder.build();\r
\r
((VlanVidCase) entry.getMatchEntryValue()).getVlanVid().getMask());\r
entry = entries.get(4);\r
checkEntryHeader(entry, Ipv4Src.class, true);\r
- Assert.assertEquals("Wrong ipv4 src", "10.0.0.1", ((Ipv4SrcCase) entry.getMatchEntryValue())\r
+ Assert.assertEquals("Wrong ipv4 src", "10.0.0.0", ((Ipv4SrcCase) entry.getMatchEntryValue())\r
.getIpv4Src().getIpv4Address().getValue());\r
Assert.assertArrayEquals("Wrong ipv4 src mask", new byte[]{(byte) 255, (byte) 255, (byte) 255, 0},\r
((Ipv4SrcCase) entry.getMatchEntryValue()).getIpv4Src().getMask());\r
entry = entries.get(5);\r
checkEntryHeader(entry, Ipv4Dst.class, true);\r
- Assert.assertEquals("Wrong ipv4 dst", "10.0.0.2", ((Ipv4DstCase) entry.getMatchEntryValue())\r
+ Assert.assertEquals("Wrong ipv4 dst", "10.0.0.0", ((Ipv4DstCase) entry.getMatchEntryValue())\r
.getIpv4Dst().getIpv4Address().getValue());\r
Assert.assertArrayEquals("Wrong ipv4 dst mask", new byte[]{(byte) 255, 0, 0, 0},\r
((Ipv4DstCase) entry.getMatchEntryValue()).getIpv4Dst().getMask());\r
Assert.assertArrayEquals("Wrong tunnel id mask", new byte[]{0, 0, 0, 0, 0, 0, 0, 14},\r
((TunnelIdCase) entry.getMatchEntryValue()).getTunnelId().getMask());\r
}\r
-}
\ No newline at end of file
+}\r
\r
package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match;\r
\r
+import java.math.BigInteger;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
import org.junit.Assert;\r
import org.junit.Before;\r
import org.junit.Test;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.vid._case.VlanVidBuilder;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder;\r
-import java.math.BigInteger;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
\r
/**\r
* @author michal.polkorab\r
*/\r
@Test(expected = NullPointerException.class)\r
public void testEmptyMatch() {\r
- MatchBuilder builder = new MatchBuilder();\r
+ final MatchBuilder builder = new MatchBuilder();\r
\r
MatchConvertorImpl.fromOFMatchToSALMatch(builder.build(), new BigInteger("42"), OpenflowVersion.OF10);\r
}\r
@Test\r
public void testEmptyMatchEntry() {\r
\r
- MatchBuilder builder = new MatchBuilder();\r
+ final MatchBuilder builder = new MatchBuilder();\r
builder.setType(OxmMatchType.class);\r
- List<MatchEntry> entries = new ArrayList<>();\r
+ final List<MatchEntry> entries = new ArrayList<>();\r
builder.setMatchEntry(entries);\r
- Match match = builder.build();\r
+ final Match match = builder.build();\r
\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
.MatchBuilder salMatch = MatchConvertorImpl.fromOFMatchToSALMatch(match, new BigInteger("42"), OpenflowVersion.OF10);\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
\r
Assert.assertEquals("Wrong match entries", null, builtMatch.getEthernetMatch());\r
Assert.assertEquals("Wrong match entries", null, builtMatch.getIcmpv4Match());\r
*/\r
@Test\r
public void testWithMatchEntryNoMasks() {\r
- List<MatchEntry> entries = new ArrayList<>();\r
+ final List<MatchEntry> entries = new ArrayList<>();\r
MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort.class);\r
entriesBuilder.setHasMask(false);\r
- InPortCaseBuilder caseBuilder = new InPortCaseBuilder();\r
- InPortBuilder portBuilder = new InPortBuilder();\r
+ final InPortCaseBuilder caseBuilder = new InPortCaseBuilder();\r
+ final InPortBuilder portBuilder = new InPortBuilder();\r
portBuilder.setPortNumber(new PortNumber(1L));\r
caseBuilder.setInPort(portBuilder.build());\r
entriesBuilder.setMatchEntryValue(caseBuilder.build());\r
entries.add(entriesBuilder.build());\r
\r
- InPhyPortCaseBuilder inPhyPortCaseBuilder = new InPhyPortCaseBuilder();\r
+ final InPhyPortCaseBuilder inPhyPortCaseBuilder = new InPhyPortCaseBuilder();\r
entriesBuilder = new MatchEntryBuilder();\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPhyPort.class);\r
entriesBuilder.setHasMask(false);\r
- InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder();\r
+ final InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder();\r
inPhyPortBuilder.setPortNumber(new PortNumber(2L));\r
inPhyPortCaseBuilder.setInPhyPort(inPhyPortBuilder.build());\r
entriesBuilder.setMatchEntryValue(inPhyPortCaseBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);\r
entriesBuilder.setHasMask(false);\r
- MetadataCaseBuilder metadataCaseBuilder = new MetadataCaseBuilder();\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder metadataBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder();\r
+ final MetadataCaseBuilder metadataCaseBuilder = new MetadataCaseBuilder();\r
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder metadataBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder();\r
metadataBuilder.setMetadata(new byte[]{0, 1, 2, 3, 4, 5, 6, 7});\r
metadataCaseBuilder.setMetadata(metadataBuilder.build());\r
entriesBuilder.setMatchEntryValue(metadataCaseBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(EthDst.class);\r
entriesBuilder.setHasMask(false);\r
- EthDstCaseBuilder ethDstCaseBuilder = new EthDstCaseBuilder();\r
- EthDstBuilder ethDstBuilder = new EthDstBuilder();\r
+ final EthDstCaseBuilder ethDstCaseBuilder = new EthDstCaseBuilder();\r
+ final EthDstBuilder ethDstBuilder = new EthDstBuilder();\r
ethDstBuilder.setMacAddress(new MacAddress("00:00:00:00:00:01"));\r
ethDstCaseBuilder.setEthDst(ethDstBuilder.build());\r
entriesBuilder.setMatchEntryValue(ethDstCaseBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(EthSrc.class);\r
entriesBuilder.setHasMask(false);\r
- EthSrcCaseBuilder ethSrcCaseBuilder = new EthSrcCaseBuilder();\r
- EthSrcBuilder ethSrcBuilder = new EthSrcBuilder();\r
+ final EthSrcCaseBuilder ethSrcCaseBuilder = new EthSrcCaseBuilder();\r
+ final EthSrcBuilder ethSrcBuilder = new EthSrcBuilder();\r
ethSrcBuilder.setMacAddress(new MacAddress("00:00:00:00:00:02"));\r
ethSrcCaseBuilder.setEthSrc(ethSrcBuilder.build());\r
entriesBuilder.setMatchEntryValue(ethSrcCaseBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(EthType.class);\r
entriesBuilder.setHasMask(false);\r
- EthTypeCaseBuilder ethTypeCaseBuilder = new EthTypeCaseBuilder();\r
+ final EthTypeCaseBuilder ethTypeCaseBuilder = new EthTypeCaseBuilder();\r
\r
- EthTypeBuilder ethTypeBuilder = new EthTypeBuilder();\r
+ final EthTypeBuilder ethTypeBuilder = new EthTypeBuilder();\r
ethTypeBuilder.setEthType(new EtherType(3));\r
ethTypeCaseBuilder.setEthType(ethTypeBuilder.build());\r
entriesBuilder.setMatchEntryValue(ethTypeCaseBuilder.build());\r
entriesBuilder = new MatchEntryBuilder();\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(VlanVid.class);\r
- VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();\r
+ final VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();\r
entriesBuilder.setHasMask(false);\r
- VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();\r
+ final VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();\r
vlanVidBuilder.setVlanVid(4);\r
vlanVidBuilder.setCfiBit(true);\r
vlanVidCaseBuilder.setVlanVid(vlanVidBuilder.build());\r
entriesBuilder = new MatchEntryBuilder();\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(VlanPcp.class);\r
- VlanPcpCaseBuilder vlanPcpCaseBuilder = new VlanPcpCaseBuilder();\r
+ final VlanPcpCaseBuilder vlanPcpCaseBuilder = new VlanPcpCaseBuilder();\r
entriesBuilder.setHasMask(false);\r
- VlanPcpBuilder vlanPcpBuilder = new VlanPcpBuilder();\r
+ final VlanPcpBuilder vlanPcpBuilder = new VlanPcpBuilder();\r
vlanPcpBuilder.setVlanPcp((short) 5);\r
vlanPcpCaseBuilder.setVlanPcp(vlanPcpBuilder.build());\r
entriesBuilder.setMatchEntryValue(vlanPcpCaseBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(IpDscp.class);\r
entriesBuilder.setHasMask(false);\r
- IpDscpCaseBuilder ipDscpCaseBuilder = new IpDscpCaseBuilder();\r
- IpDscpBuilder ipDscpBuilder = new IpDscpBuilder();\r
+ final IpDscpCaseBuilder ipDscpCaseBuilder = new IpDscpCaseBuilder();\r
+ final IpDscpBuilder ipDscpBuilder = new IpDscpBuilder();\r
ipDscpBuilder.setDscp(new Dscp((short) 6));\r
ipDscpCaseBuilder.setIpDscp(ipDscpBuilder.build());\r
entriesBuilder.setMatchEntryValue(ipDscpCaseBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(IpEcn.class);\r
entriesBuilder.setHasMask(false);\r
- IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder();\r
- IpEcnBuilder ipEcnBuilder = new IpEcnBuilder();\r
+ final IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder();\r
+ final IpEcnBuilder ipEcnBuilder = new IpEcnBuilder();\r
ipEcnBuilder.setEcn((short) 7);\r
ipEcnCaseBuilder.setIpEcn(ipEcnBuilder.build());\r
entriesBuilder.setMatchEntryValue(ipEcnCaseBuilder.build());\r
entriesBuilder = new MatchEntryBuilder();\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(IpProto.class);\r
- IpProtoCaseBuilder ipProtoCaseBuilder = new IpProtoCaseBuilder();\r
+ final IpProtoCaseBuilder ipProtoCaseBuilder = new IpProtoCaseBuilder();\r
entriesBuilder.setHasMask(false);\r
- IpProtoBuilder ipProtoBuilder = new IpProtoBuilder();\r
+ final IpProtoBuilder ipProtoBuilder = new IpProtoBuilder();\r
ipProtoBuilder.setProtocolNumber((short) 8);\r
ipProtoCaseBuilder.setIpProto(ipProtoBuilder.build());\r
entriesBuilder.setMatchEntryValue(ipProtoCaseBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(Ipv4Src.class);\r
entriesBuilder.setHasMask(false);\r
- Ipv4SrcCaseBuilder ipv4AddressBuilder = new Ipv4SrcCaseBuilder();\r
- Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();\r
+ final Ipv4SrcCaseBuilder ipv4AddressBuilder = new Ipv4SrcCaseBuilder();\r
+ final Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();\r
ipv4SrcBuilder.setIpv4Address(new Ipv4Address("10.0.0.1"));\r
ipv4AddressBuilder.setIpv4Src(ipv4SrcBuilder.build());\r
entriesBuilder.setMatchEntryValue(ipv4AddressBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(Ipv4Dst.class);\r
entriesBuilder.setHasMask(false);\r
- Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();\r
- Ipv4DstBuilder ipv4DstBuilder = new Ipv4DstBuilder();\r
+ final Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();\r
+ final Ipv4DstBuilder ipv4DstBuilder = new Ipv4DstBuilder();\r
ipv4DstBuilder.setIpv4Address(new Ipv4Address("10.0.0.2"));\r
ipv4DstCaseBuilder.setIpv4Dst(ipv4DstBuilder.build());\r
entriesBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(TcpSrc.class);\r
entriesBuilder.setHasMask(false);\r
- TcpSrcCaseBuilder tcpSrcCaseBuilder = new TcpSrcCaseBuilder();\r
- TcpSrcBuilder tcpSrcBuilder = new TcpSrcBuilder();\r
+ final TcpSrcCaseBuilder tcpSrcCaseBuilder = new TcpSrcCaseBuilder();\r
+ final TcpSrcBuilder tcpSrcBuilder = new TcpSrcBuilder();\r
tcpSrcBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf\r
.inet.types.rev100924.PortNumber(9));\r
tcpSrcCaseBuilder.setTcpSrc(tcpSrcBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(TcpDst.class);\r
entriesBuilder.setHasMask(false);\r
- TcpDstCaseBuilder tcpDstCaseBuilder = new TcpDstCaseBuilder();\r
- TcpDstBuilder tcpDstBuilder = new TcpDstBuilder();\r
+ final TcpDstCaseBuilder tcpDstCaseBuilder = new TcpDstCaseBuilder();\r
+ final TcpDstBuilder tcpDstBuilder = new TcpDstBuilder();\r
tcpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf\r
.inet.types.rev100924.PortNumber(10));\r
tcpDstCaseBuilder.setTcpDst(tcpDstBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(Icmpv4Type.class);\r
entriesBuilder.setHasMask(false);\r
- Icmpv4TypeCaseBuilder icmpv4TypeCaseBuilder = new Icmpv4TypeCaseBuilder();\r
- Icmpv4TypeBuilder icmpv4TypeBuilder = new Icmpv4TypeBuilder();\r
+ final Icmpv4TypeCaseBuilder icmpv4TypeCaseBuilder = new Icmpv4TypeCaseBuilder();\r
+ final Icmpv4TypeBuilder icmpv4TypeBuilder = new Icmpv4TypeBuilder();\r
icmpv4TypeBuilder.setIcmpv4Type((short) 15);\r
icmpv4TypeCaseBuilder.setIcmpv4Type(icmpv4TypeBuilder.build());\r
entriesBuilder.setMatchEntryValue(icmpv4TypeCaseBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(Icmpv4Code.class);\r
entriesBuilder.setHasMask(false);\r
- Icmpv4CodeCaseBuilder icmpv4CodeCaseBuilder = new Icmpv4CodeCaseBuilder();\r
- Icmpv4CodeBuilder icmpv4CodeBuilder = new Icmpv4CodeBuilder();\r
+ final Icmpv4CodeCaseBuilder icmpv4CodeCaseBuilder = new Icmpv4CodeCaseBuilder();\r
+ final Icmpv4CodeBuilder icmpv4CodeBuilder = new Icmpv4CodeBuilder();\r
icmpv4CodeBuilder.setIcmpv4Code((short) 16);\r
icmpv4CodeCaseBuilder.setIcmpv4Code(icmpv4CodeBuilder.build());\r
entriesBuilder.setMatchEntryValue(icmpv4CodeCaseBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(Icmpv6Type.class);\r
entriesBuilder.setHasMask(false);\r
- Icmpv6TypeCaseBuilder icmpv6TypeCaseBuilder = new Icmpv6TypeCaseBuilder();\r
- Icmpv6TypeBuilder icmpv6TypeBuilder = new Icmpv6TypeBuilder();\r
+ final Icmpv6TypeCaseBuilder icmpv6TypeCaseBuilder = new Icmpv6TypeCaseBuilder();\r
+ final Icmpv6TypeBuilder icmpv6TypeBuilder = new Icmpv6TypeBuilder();\r
icmpv6TypeBuilder.setIcmpv6Type((short) 19);\r
icmpv6TypeCaseBuilder.setIcmpv6Type(icmpv6TypeBuilder.build());\r
entriesBuilder.setMatchEntryValue(icmpv6TypeCaseBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(Icmpv6Code.class);\r
entriesBuilder.setHasMask(false);\r
- Icmpv6CodeCaseBuilder icmpv6CodeCaseBuilder = new Icmpv6CodeCaseBuilder();\r
- Icmpv6CodeBuilder icmpv6CodeBuilder = new Icmpv6CodeBuilder();\r
+ final Icmpv6CodeCaseBuilder icmpv6CodeCaseBuilder = new Icmpv6CodeCaseBuilder();\r
+ final Icmpv6CodeBuilder icmpv6CodeBuilder = new Icmpv6CodeBuilder();\r
icmpv6CodeBuilder.setIcmpv6Code((short) 20);\r
icmpv6CodeCaseBuilder.setIcmpv6Code(icmpv6CodeBuilder.build());\r
entriesBuilder.setMatchEntryValue(icmpv6CodeCaseBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(MplsLabel.class);\r
entriesBuilder.setHasMask(false);\r
- MplsLabelCaseBuilder mplsLabelCaseBuilder = new MplsLabelCaseBuilder();\r
+ final MplsLabelCaseBuilder mplsLabelCaseBuilder = new MplsLabelCaseBuilder();\r
\r
- MplsLabelBuilder mplsLabelBuilder = new MplsLabelBuilder();\r
+ final MplsLabelBuilder mplsLabelBuilder = new MplsLabelBuilder();\r
mplsLabelBuilder.setMplsLabel(21L);\r
mplsLabelCaseBuilder.setMplsLabel(mplsLabelBuilder.build());\r
entriesBuilder.setMatchEntryValue(mplsLabelCaseBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(MplsTc.class);\r
entriesBuilder.setHasMask(false);\r
- MplsTcCaseBuilder mplsTcCaseBuilder = new MplsTcCaseBuilder();\r
- MplsTcBuilder mplsTcBuilder = new MplsTcBuilder();\r
+ final MplsTcCaseBuilder mplsTcCaseBuilder = new MplsTcCaseBuilder();\r
+ final MplsTcBuilder mplsTcBuilder = new MplsTcBuilder();\r
mplsTcBuilder.setTc((short) 22);\r
mplsTcCaseBuilder.setMplsTc(mplsTcBuilder.build());\r
entriesBuilder.setMatchEntryValue(mplsTcCaseBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(MplsBos.class);\r
entriesBuilder.setHasMask(false);\r
- MplsBosCaseBuilder mplsBosCaseBuilder = new MplsBosCaseBuilder();\r
- MplsBosBuilder mplsBosBuilder = new MplsBosBuilder();\r
+ final MplsBosCaseBuilder mplsBosCaseBuilder = new MplsBosCaseBuilder();\r
+ final MplsBosBuilder mplsBosBuilder = new MplsBosBuilder();\r
mplsBosBuilder.setBos(true);\r
mplsBosCaseBuilder.setMplsBos(mplsBosBuilder.build());\r
entriesBuilder.setMatchEntryValue(mplsBosCaseBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(PbbIsid.class);\r
entriesBuilder.setHasMask(false);\r
- PbbIsidCaseBuilder pbbIsidCaseBuilder = new PbbIsidCaseBuilder();\r
- PbbIsidBuilder pbbIsidBuilder = new PbbIsidBuilder();\r
+ final PbbIsidCaseBuilder pbbIsidCaseBuilder = new PbbIsidCaseBuilder();\r
+ final PbbIsidBuilder pbbIsidBuilder = new PbbIsidBuilder();\r
pbbIsidBuilder.setIsid(23L);\r
pbbIsidCaseBuilder.setPbbIsid(pbbIsidBuilder.build());\r
entriesBuilder.setMatchEntryValue(pbbIsidCaseBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(TunnelId.class);\r
entriesBuilder.setHasMask(false);\r
- TunnelIdCaseBuilder tunnelIdCaseBuilder = new TunnelIdCaseBuilder();\r
- TunnelIdBuilder tunnelIdBuilder = new TunnelIdBuilder();\r
+ final TunnelIdCaseBuilder tunnelIdCaseBuilder = new TunnelIdCaseBuilder();\r
+ final TunnelIdBuilder tunnelIdBuilder = new TunnelIdBuilder();\r
tunnelIdBuilder.setTunnelId(new byte[]{1, 2, 3, 4, 5, 6, 7, 8});\r
tunnelIdCaseBuilder.setTunnelId(tunnelIdBuilder.build());\r
entriesBuilder.setMatchEntryValue(tunnelIdCaseBuilder.build());\r
entries.add(entriesBuilder.build());\r
\r
- MatchBuilder builder = new MatchBuilder();\r
+ final MatchBuilder builder = new MatchBuilder();\r
builder.setMatchEntry(entries);\r
\r
- Match match = builder.build();\r
+ final Match match = builder.build();\r
\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
.MatchBuilder salMatch = MatchConvertorImpl.fromOFMatchToSALMatch(match, new BigInteger("42"), OpenflowVersion.OF10);\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
\r
Assert.assertEquals("Wrong in port", "openflow:42:1", builtMatch.getInPort().getValue());\r
Assert.assertEquals("Wrong in phy port", "openflow:42:2", builtMatch.getInPhyPort().getValue());\r
Assert.assertEquals("Wrong ip proto", null, builtMatch.getIpMatch().getIpProto());\r
Assert.assertEquals("Wrong ip protocol", 8, builtMatch.getIpMatch().getIpProtocol().intValue());\r
\r
- TcpMatch tcpMatch = (TcpMatch) builtMatch.getLayer4Match();\r
+ final TcpMatch tcpMatch = (TcpMatch) builtMatch.getLayer4Match();\r
Assert.assertEquals("Wrong tcp src port", 9, tcpMatch.getTcpSourcePort().getValue().intValue());\r
Assert.assertEquals("Wrong tcp dst port", 10, tcpMatch.getTcpDestinationPort().getValue().intValue());\r
Assert.assertEquals("Wrong icmpv4 type", 15, builtMatch.getIcmpv4Match().getIcmpv4Type().intValue());\r
Assert.assertEquals("Wrong icmpv6 type", 19, builtMatch.getIcmpv6Match().getIcmpv6Type().intValue());\r
Assert.assertEquals("Wrong icmpv6 code", 20, builtMatch.getIcmpv6Match().getIcmpv6Code().intValue());\r
\r
- Ipv4Match ipv4Match = (Ipv4Match) builtMatch.getLayer3Match();\r
+ final Ipv4Match ipv4Match = (Ipv4Match) builtMatch.getLayer3Match();\r
Assert.assertEquals("Wrong ipv4 src address", "10.0.0.1/32", ipv4Match.getIpv4Source().getValue());\r
Assert.assertEquals("Wrong ipv4 dst address", "10.0.0.2/32", ipv4Match.getIpv4Destination().getValue());\r
Assert.assertEquals("Wrong mpls label", 21, builtMatch.getProtocolMatchFields().getMplsLabel().intValue());\r
*/\r
@Test\r
public void testWithMatchEntryWithMasks() {\r
- MatchBuilder builder = new MatchBuilder();\r
+ final MatchBuilder builder = new MatchBuilder();\r
builder.setType(OxmMatchType.class);\r
- List<MatchEntry> entries = new ArrayList<>();\r
+ final List<MatchEntry> entries = new ArrayList<>();\r
MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);\r
entriesBuilder.setHasMask(true);\r
\r
\r
- MetadataCaseBuilder metadataCaseBuilder = new MetadataCaseBuilder();\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder metadataBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder();\r
+ final MetadataCaseBuilder metadataCaseBuilder = new MetadataCaseBuilder();\r
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder metadataBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder();\r
metadataBuilder.setMetadata(new byte[]{0, 1, 2, 3, 4, 5, 6, 7});\r
metadataBuilder.setMask(new byte[]{0, 0, 0, 0, 0, 0, 0, 1});\r
metadataCaseBuilder.setMetadata(metadataBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(EthDst.class);\r
entriesBuilder.setHasMask(true);\r
- EthDstCaseBuilder ethDstCaseBuilder = new EthDstCaseBuilder();\r
- EthDstBuilder ethDstBuilder = new EthDstBuilder();\r
+ final EthDstCaseBuilder ethDstCaseBuilder = new EthDstCaseBuilder();\r
+ final EthDstBuilder ethDstBuilder = new EthDstBuilder();\r
ethDstBuilder.setMacAddress(new MacAddress("00:00:00:00:00:01"));\r
ethDstBuilder.setMask(new byte[]{0, 0, 0, 0, 1, 1});\r
ethDstCaseBuilder.setEthDst(ethDstBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(EthSrc.class);\r
entriesBuilder.setHasMask(true);\r
- EthSrcCaseBuilder ethSrcCaseBuilder = new EthSrcCaseBuilder();\r
- EthSrcBuilder ethSrcBuilder = new EthSrcBuilder();\r
+ final EthSrcCaseBuilder ethSrcCaseBuilder = new EthSrcCaseBuilder();\r
+ final EthSrcBuilder ethSrcBuilder = new EthSrcBuilder();\r
ethSrcBuilder.setMacAddress(new MacAddress("00:00:00:00:00:02"));\r
ethSrcBuilder.setMask(new byte[]{0, 0, 0, 0, 2, 2});\r
ethSrcCaseBuilder.setEthSrc(ethSrcBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(VlanVid.class);\r
entriesBuilder.setHasMask(true);\r
- VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();\r
- VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();\r
+ final VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();\r
+ final VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();\r
vlanVidBuilder.setVlanVid(4);\r
vlanVidBuilder.setCfiBit(true);\r
vlanVidBuilder.setMask(new byte[]{0, 4});\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(Ipv4Src.class);\r
entriesBuilder.setHasMask(true);\r
- Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();\r
- Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();\r
- ipv4SrcBuilder.setIpv4Address(new Ipv4Address("10.0.0.1"));\r
+ final Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();\r
+ final Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();\r
+ ipv4SrcBuilder.setIpv4Address(new Ipv4Address("10.0.0.0"));\r
ipv4SrcBuilder.setMask(new byte[]{(byte) 255, (byte) 255, (byte) 255, 0});\r
ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());\r
entriesBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(Ipv4Dst.class);\r
entriesBuilder.setHasMask(true);\r
- Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();\r
- Ipv4DstBuilder ipv4AddressBuilder = new Ipv4DstBuilder();\r
- ipv4AddressBuilder.setIpv4Address(new Ipv4Address("10.0.0.2"));\r
+ final Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();\r
+ final Ipv4DstBuilder ipv4AddressBuilder = new Ipv4DstBuilder();\r
+ ipv4AddressBuilder.setIpv4Address(new Ipv4Address("10.0.0.0"));\r
ipv4AddressBuilder.setMask(new byte[]{(byte) 255, (byte) 255, (byte) 240, 0});\r
ipv4DstCaseBuilder.setIpv4Dst(ipv4AddressBuilder.build());\r
entriesBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(PbbIsid.class);\r
entriesBuilder.setHasMask(true);\r
- PbbIsidCaseBuilder pbbIsidCaseBuilder = new PbbIsidCaseBuilder();\r
+ final PbbIsidCaseBuilder pbbIsidCaseBuilder = new PbbIsidCaseBuilder();\r
\r
- PbbIsidBuilder pbbIsidBuilder = new PbbIsidBuilder();\r
+ final PbbIsidBuilder pbbIsidBuilder = new PbbIsidBuilder();\r
pbbIsidBuilder.setIsid(23L);\r
pbbIsidBuilder.setMask(new byte[]{0, 0, 7});\r
pbbIsidCaseBuilder.setPbbIsid(pbbIsidBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(TunnelId.class);\r
entriesBuilder.setHasMask(true);\r
- TunnelIdCaseBuilder tunnelIdCaseBuilder = new TunnelIdCaseBuilder();\r
- TunnelIdBuilder tunnelIdBuilder = new TunnelIdBuilder();\r
+ final TunnelIdCaseBuilder tunnelIdCaseBuilder = new TunnelIdCaseBuilder();\r
+ final TunnelIdBuilder tunnelIdBuilder = new TunnelIdBuilder();\r
tunnelIdBuilder.setTunnelId(new byte[]{1, 2, 3, 4, 5, 6, 7, 8});\r
tunnelIdBuilder.setMask(new byte[]{0, 0, 0, 0, 0, 0, 0, 8});\r
tunnelIdCaseBuilder.setTunnelId(tunnelIdBuilder.build());\r
entriesBuilder.setMatchEntryValue(tunnelIdCaseBuilder.build());\r
entries.add(entriesBuilder.build());\r
builder.setMatchEntry(entries);\r
- Match match = builder.build();\r
+ final Match match = builder.build();\r
\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
.MatchBuilder salMatch = MatchConvertorImpl.fromOFMatchToSALMatch(match, new BigInteger("42"), OpenflowVersion.OF10);\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
\r
Assert.assertEquals("Wrong metadata", new BigInteger(1, new byte[]{0, 1, 2, 3, 4, 5, 6, 7}), builtMatch.getMetadata().getMetadata());\r
Assert.assertEquals("Wrong metadata mask", new BigInteger(1, new byte[]{0, 0, 0, 0, 0, 0, 0, 1}),\r
Assert.assertEquals("Wrong eth src mask", new MacAddress("00:00:00:00:02:02"), builtMatch.getEthernetMatch().getEthernetSource().getMask());\r
Assert.assertEquals("Wrong vlan id", 4, builtMatch.getVlanMatch().getVlanId().getVlanId().getValue().intValue());\r
Assert.assertEquals("Wrong vlan id entries", true, builtMatch.getVlanMatch().getVlanId().isVlanIdPresent());\r
- Ipv4Match ipv4Match = (Ipv4Match) builtMatch.getLayer3Match();\r
- Assert.assertEquals("Wrong ipv4 src address", "10.0.0.1/24", ipv4Match.getIpv4Source().getValue());\r
- Assert.assertEquals("Wrong ipv4 dst address", "10.0.0.2/20", ipv4Match.getIpv4Destination().getValue());\r
+ final Ipv4Match ipv4Match = (Ipv4Match) builtMatch.getLayer3Match();\r
+ Assert.assertEquals("Wrong ipv4 src address", "10.0.0.0/24", ipv4Match.getIpv4Source().getValue());\r
+ Assert.assertEquals("Wrong ipv4 dst address", "10.0.0.0/20", ipv4Match.getIpv4Destination().getValue());\r
Assert.assertEquals("Wrong pbb isid", 23, builtMatch.getProtocolMatchFields().getPbb().getPbbIsid().intValue());\r
Assert.assertEquals("Wrong tunnel id", new BigInteger(1, new byte[]{1, 2, 3, 4, 5, 6, 7, 8}),\r
builtMatch.getTunnel().getTunnelId());\r
*/\r
@Test\r
public void testLayer4MatchUdp() {\r
- MatchBuilder builder = new MatchBuilder();\r
+ final MatchBuilder builder = new MatchBuilder();\r
builder.setType(OxmMatchType.class);\r
- List<MatchEntry> entries = new ArrayList<>();\r
+ final List<MatchEntry> entries = new ArrayList<>();\r
MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpSrc.class);\r
entriesBuilder.setHasMask(false);\r
- UdpSrcCaseBuilder udpSrcCaseBuilder = new UdpSrcCaseBuilder();\r
- UdpSrcBuilder portBuilder = new UdpSrcBuilder();\r
+ final UdpSrcCaseBuilder udpSrcCaseBuilder = new UdpSrcCaseBuilder();\r
+ final UdpSrcBuilder portBuilder = new UdpSrcBuilder();\r
portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf\r
.inet.types.rev100924.PortNumber(11));\r
udpSrcCaseBuilder.setUdpSrc(portBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(UdpDst.class);\r
entriesBuilder.setHasMask(false);\r
- UdpDstCaseBuilder udpDstCaseBuilder = new UdpDstCaseBuilder();\r
- UdpDstBuilder udpDstBuilder = new UdpDstBuilder();\r
+ final UdpDstCaseBuilder udpDstCaseBuilder = new UdpDstCaseBuilder();\r
+ final UdpDstBuilder udpDstBuilder = new UdpDstBuilder();\r
udpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf\r
.inet.types.rev100924.PortNumber(12));\r
udpDstCaseBuilder.setUdpDst(udpDstBuilder.build());\r
\r
builder.setMatchEntry(entries);\r
\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
.MatchBuilder builtMatch = MatchConvertorImpl.fromOFMatchToSALMatch(builder.build(), new BigInteger("42"), OpenflowVersion.OF13);\r
\r
- UdpMatch udpMatch = (UdpMatch) builtMatch.getLayer4Match();\r
+ final UdpMatch udpMatch = (UdpMatch) builtMatch.getLayer4Match();\r
Assert.assertEquals("Wrong udp src port", 11, udpMatch.getUdpSourcePort().getValue().intValue());\r
Assert.assertEquals("Wrong udp dst port", 12, udpMatch.getUdpDestinationPort().getValue().intValue());\r
}\r
*/\r
@Test\r
public void testLayer4MatchSctp() {\r
- MatchBuilder builder = new MatchBuilder();\r
+ final MatchBuilder builder = new MatchBuilder();\r
builder.setType(OxmMatchType.class);\r
- List<MatchEntry> entries = new ArrayList<>();\r
+ final List<MatchEntry> entries = new ArrayList<>();\r
MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(SctpSrc.class);\r
entriesBuilder.setHasMask(false);\r
- SctpSrcCaseBuilder sctpSrcCaseBuilder = new SctpSrcCaseBuilder();\r
- SctpSrcBuilder portBuilder = new SctpSrcBuilder();\r
+ final SctpSrcCaseBuilder sctpSrcCaseBuilder = new SctpSrcCaseBuilder();\r
+ final SctpSrcBuilder portBuilder = new SctpSrcBuilder();\r
portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf\r
.inet.types.rev100924.PortNumber(13));\r
sctpSrcCaseBuilder.setSctpSrc(portBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(SctpDst.class);\r
entriesBuilder.setHasMask(false);\r
- SctpDstCaseBuilder sctpDstCaseBuilder = new SctpDstCaseBuilder();\r
- SctpDstBuilder sctpDstBuilder = new SctpDstBuilder();\r
+ final SctpDstCaseBuilder sctpDstCaseBuilder = new SctpDstCaseBuilder();\r
+ final SctpDstBuilder sctpDstBuilder = new SctpDstBuilder();\r
sctpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf\r
.inet.types.rev100924.PortNumber(14));\r
sctpDstCaseBuilder.setSctpDst(sctpDstBuilder.build());\r
entries.add(entriesBuilder.build());\r
builder.setMatchEntry(entries);\r
\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
.MatchBuilder salMatchBuilder = MatchConvertorImpl.fromOFMatchToSALMatch(builder.build(), new BigInteger("42"), OpenflowVersion.OF13);\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
\r
- SctpMatch udpMatch = (SctpMatch) builtMatch.getLayer4Match();\r
+ final SctpMatch udpMatch = (SctpMatch) builtMatch.getLayer4Match();\r
Assert.assertEquals("Wrong sctp src port", 13, udpMatch.getSctpSourcePort().getValue().intValue());\r
Assert.assertEquals("Wrong sctp dst port", 14, udpMatch.getSctpDestinationPort().getValue().intValue());\r
}\r
*/\r
@Test\r
public void testLayer3MatchIpv6() {\r
- MatchBuilder builder = new MatchBuilder();\r
+ final MatchBuilder builder = new MatchBuilder();\r
builder.setType(OxmMatchType.class);\r
- List<MatchEntry> entries = new ArrayList<>();\r
+ final List<MatchEntry> entries = new ArrayList<>();\r
MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(Ipv6Src.class);\r
entriesBuilder.setHasMask(false);\r
- Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();\r
- Ipv6SrcBuilder ipv6AddressBuilder = new Ipv6SrcBuilder();\r
- ipv6AddressBuilder.setIpv6Address(new Ipv6Address("0000:0001:0002:0003:0004:0005:0006:0007"));\r
+ final Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();\r
+ final Ipv6SrcBuilder ipv6AddressBuilder = new Ipv6SrcBuilder();\r
+ ipv6AddressBuilder.setIpv6Address(new Ipv6Address("2001:cdba:0000:0000:0000:0000:3257:9657"));\r
ipv6SrcCaseBuilder.setIpv6Src(ipv6AddressBuilder.build());\r
entriesBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());\r
entries.add(entriesBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(Ipv6Dst.class);\r
entriesBuilder.setHasMask(false);\r
- Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();\r
- Ipv6DstBuilder ipv6DstBuilder = new Ipv6DstBuilder();\r
- ipv6DstBuilder.setIpv6Address(new Ipv6Address("0001:0002:0003:0004:0005:0006:0007:0008"));\r
+ final Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();\r
+ final Ipv6DstBuilder ipv6DstBuilder = new Ipv6DstBuilder();\r
+ ipv6DstBuilder.setIpv6Address(new Ipv6Address("2001:cdba:0000:0000:0000:0000:3257:9658"));\r
ipv6DstCaseBuilder.setIpv6Dst(ipv6DstBuilder.build());\r
entriesBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());\r
entries.add(entriesBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(Ipv6Flabel.class);\r
entriesBuilder.setHasMask(false);\r
- Ipv6FlabelCaseBuilder ipv6FlabelCaseBuilder = new Ipv6FlabelCaseBuilder();\r
- Ipv6FlabelBuilder ipv6FlabelBuilder = new Ipv6FlabelBuilder();\r
+ final Ipv6FlabelCaseBuilder ipv6FlabelCaseBuilder = new Ipv6FlabelCaseBuilder();\r
+ final Ipv6FlabelBuilder ipv6FlabelBuilder = new Ipv6FlabelBuilder();\r
ipv6FlabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(18L));\r
ipv6FlabelCaseBuilder.setIpv6Flabel(ipv6FlabelBuilder.build());\r
entriesBuilder.setMatchEntryValue(ipv6FlabelCaseBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(Ipv6NdTarget.class);\r
entriesBuilder.setHasMask(false);\r
- Ipv6NdTargetCaseBuilder ipv6NdTargetCaseBuilder = new Ipv6NdTargetCaseBuilder();\r
- Ipv6NdTargetBuilder ipv6NdTargetBuilder = new Ipv6NdTargetBuilder();\r
- ipv6NdTargetBuilder.setIpv6Address(new Ipv6Address("0002:0003:0004:0005:0006:0007:0008:0009"));\r
+ final Ipv6NdTargetCaseBuilder ipv6NdTargetCaseBuilder = new Ipv6NdTargetCaseBuilder();\r
+ final Ipv6NdTargetBuilder ipv6NdTargetBuilder = new Ipv6NdTargetBuilder();\r
+ ipv6NdTargetBuilder.setIpv6Address(new Ipv6Address("2001:cdba:0000:0000:0000:0000:3257:9659"));\r
ipv6NdTargetCaseBuilder.setIpv6NdTarget(ipv6NdTargetBuilder.build());\r
entriesBuilder.setMatchEntryValue(ipv6NdTargetCaseBuilder.build());\r
entries.add(entriesBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(Ipv6NdSll.class);\r
entriesBuilder.setHasMask(false);\r
- Ipv6NdSllCaseBuilder ipv6NdSllCaseBuilder = new Ipv6NdSllCaseBuilder();\r
- Ipv6NdSllBuilder ipv6NdSllBuilder = new Ipv6NdSllBuilder();\r
+ final Ipv6NdSllCaseBuilder ipv6NdSllCaseBuilder = new Ipv6NdSllCaseBuilder();\r
+ final Ipv6NdSllBuilder ipv6NdSllBuilder = new Ipv6NdSllBuilder();\r
ipv6NdSllBuilder.setMacAddress(new MacAddress("00:00:00:00:00:05"));\r
ipv6NdSllCaseBuilder.setIpv6NdSll(ipv6NdSllBuilder.build());\r
entriesBuilder.setMatchEntryValue(ipv6NdSllCaseBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(Ipv6NdTll.class);\r
entriesBuilder.setHasMask(false);\r
- Ipv6NdTllCaseBuilder ipv6NdTllCaseBuilder = new Ipv6NdTllCaseBuilder();\r
- Ipv6NdTllBuilder ipv6NdTllBuilder = new Ipv6NdTllBuilder();\r
+ final Ipv6NdTllCaseBuilder ipv6NdTllCaseBuilder = new Ipv6NdTllCaseBuilder();\r
+ final Ipv6NdTllBuilder ipv6NdTllBuilder = new Ipv6NdTllBuilder();\r
ipv6NdTllBuilder.setMacAddress(new MacAddress("00:00:00:00:00:06"));\r
ipv6NdTllCaseBuilder.setIpv6NdTll(ipv6NdTllBuilder.build());\r
entriesBuilder.setMatchEntryValue(ipv6NdTllCaseBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(Ipv6Exthdr.class);\r
entriesBuilder.setHasMask(false);\r
- Ipv6ExthdrCaseBuilder ipv6ExthdrCaseBuilder = new Ipv6ExthdrCaseBuilder();\r
- Ipv6ExthdrBuilder ipv6ExthdrBuilder = new Ipv6ExthdrBuilder();\r
+ final Ipv6ExthdrCaseBuilder ipv6ExthdrCaseBuilder = new Ipv6ExthdrCaseBuilder();\r
+ final Ipv6ExthdrBuilder ipv6ExthdrBuilder = new Ipv6ExthdrBuilder();\r
ipv6ExthdrBuilder.setPseudoField(new Ipv6ExthdrFlags(true, false, true, false, true, false, true, false, true));\r
ipv6ExthdrCaseBuilder.setIpv6Exthdr(ipv6ExthdrBuilder.build());\r
entriesBuilder.setMatchEntryValue(ipv6ExthdrCaseBuilder.build());\r
builder.setMatchEntry(entries);\r
entries.add(entriesBuilder.build());\r
\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
.MatchBuilder salMatchBuilder = MatchConvertorImpl.fromOFMatchToSALMatch(builder.build(), new BigInteger("42"), OpenflowVersion.OF13);\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
\r
- Ipv6Match ipv6Match = (Ipv6Match) builtMatch.getLayer3Match();\r
- Assert.assertEquals("Wrong ipv6 src address", "0000:0001:0002:0003:0004:0005:0006:0007",\r
+ final Ipv6Match ipv6Match = (Ipv6Match) builtMatch.getLayer3Match();\r
+ Assert.assertEquals("Wrong ipv6 src address", "2001:cdba:0000:0000:0000:0000:3257:9657/128",\r
ipv6Match.getIpv6Source().getValue());\r
- Assert.assertEquals("Wrong ipv6 dst address", "0001:0002:0003:0004:0005:0006:0007:0008",\r
+ Assert.assertEquals("Wrong ipv6 dst address", "2001:cdba:0000:0000:0000:0000:3257:9658/128",\r
ipv6Match.getIpv6Destination().getValue());\r
- Assert.assertEquals("Wrong ipv6 nd target", "0002:0003:0004:0005:0006:0007:0008:0009",\r
+ Assert.assertEquals("Wrong ipv6 nd target", "2001:cdba:0000:0000:0000:0000:3257:9659",\r
ipv6Match.getIpv6NdTarget().getValue());\r
Assert.assertEquals("Wrong ipv6 flabel", 18, ipv6Match.getIpv6Label().getIpv6Flabel().getValue().intValue());\r
Assert.assertEquals("Wrong ipv6 nd sll", new MacAddress("00:00:00:00:00:05"), ipv6Match.getIpv6NdSll());\r
*/\r
@Test\r
public void testLayer3MatchIpv6ExtHeader2() {\r
- MatchBuilder builder = new MatchBuilder();\r
+ final MatchBuilder builder = new MatchBuilder();\r
builder.setType(OxmMatchType.class);\r
- List<MatchEntry> entries = new ArrayList<>();\r
- MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
+ final List<MatchEntry> entries = new ArrayList<>();\r
+ final MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(Ipv6Exthdr.class);\r
entriesBuilder.setHasMask(true);\r
- Ipv6ExthdrCaseBuilder ipv6ExthdrCaseBuilder = new Ipv6ExthdrCaseBuilder();\r
- Ipv6ExthdrBuilder ipv6ExthdrBuilder = new Ipv6ExthdrBuilder();\r
+ final Ipv6ExthdrCaseBuilder ipv6ExthdrCaseBuilder = new Ipv6ExthdrCaseBuilder();\r
+ final Ipv6ExthdrBuilder ipv6ExthdrBuilder = new Ipv6ExthdrBuilder();\r
ipv6ExthdrBuilder.setPseudoField(new Ipv6ExthdrFlags(false, true, false, true, false, true, false, true, false));\r
ipv6ExthdrBuilder.setMask(new byte[]{1, 2});\r
ipv6ExthdrCaseBuilder.setIpv6Exthdr(ipv6ExthdrBuilder.build());\r
entries.add(entriesBuilder.build());\r
builder.setMatchEntry(entries);\r
\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
.MatchBuilder salMatchBuilder = MatchConvertorImpl.fromOFMatchToSALMatch(builder.build(), new BigInteger("42"), OpenflowVersion.OF13);\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
\r
- Ipv6Match ipv6Match = (Ipv6Match) builtMatch.getLayer3Match();\r
+ final Ipv6Match ipv6Match = (Ipv6Match) builtMatch.getLayer3Match();\r
Assert.assertEquals("Wrong ipv6 ext header", 153, ipv6Match.getIpv6ExtHeader().getIpv6Exthdr().intValue());\r
Assert.assertEquals("Wrong ipv6 ext header mask", 258, ipv6Match.getIpv6ExtHeader().getIpv6ExthdrMask().intValue());\r
}\r
*/\r
@Test\r
public void testLayer3MatchArp() {\r
- MatchBuilder builder = new MatchBuilder();\r
+ final MatchBuilder builder = new MatchBuilder();\r
builder.setType(OxmMatchType.class);\r
- List<MatchEntry> entries = new ArrayList<>();\r
+ final List<MatchEntry> entries = new ArrayList<>();\r
MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(ArpOp.class);\r
entriesBuilder.setHasMask(false);\r
- ArpOpCaseBuilder arpOpCaseBuilder = new ArpOpCaseBuilder();\r
- ArpOpBuilder arpOpBuilder = new ArpOpBuilder();\r
+ final ArpOpCaseBuilder arpOpCaseBuilder = new ArpOpCaseBuilder();\r
+ final ArpOpBuilder arpOpBuilder = new ArpOpBuilder();\r
arpOpBuilder.setOpCode(17);\r
arpOpCaseBuilder.setArpOp(arpOpBuilder.build());\r
entriesBuilder.setMatchEntryValue(arpOpCaseBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(ArpSpa.class);\r
entriesBuilder.setHasMask(false);\r
- ArpSpaCaseBuilder arpSpaCaseBuilder = new ArpSpaCaseBuilder();\r
- ArpSpaBuilder arpSpaBuilder = new ArpSpaBuilder();\r
+ final ArpSpaCaseBuilder arpSpaCaseBuilder = new ArpSpaCaseBuilder();\r
+ final ArpSpaBuilder arpSpaBuilder = new ArpSpaBuilder();\r
arpSpaBuilder.setIpv4Address(new Ipv4Address("10.0.0.3"));\r
arpSpaCaseBuilder.setArpSpa(arpSpaBuilder.build());\r
entriesBuilder.setMatchEntryValue(arpSpaCaseBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(ArpTpa.class);\r
entriesBuilder.setHasMask(false);\r
- ArpTpaCaseBuilder arpTpaCaseBuilder = new ArpTpaCaseBuilder();\r
- ArpTpaBuilder arpTpaBuilder = new ArpTpaBuilder();\r
+ final ArpTpaCaseBuilder arpTpaCaseBuilder = new ArpTpaCaseBuilder();\r
+ final ArpTpaBuilder arpTpaBuilder = new ArpTpaBuilder();\r
arpTpaBuilder.setIpv4Address(new Ipv4Address("10.0.0.4"));\r
arpTpaCaseBuilder.setArpTpa(arpTpaBuilder.build());\r
entriesBuilder.setMatchEntryValue(arpTpaCaseBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(ArpSha.class);\r
entriesBuilder.setHasMask(false);\r
- ArpShaCaseBuilder arpShaCaseBuilder = new ArpShaCaseBuilder();\r
- ArpShaBuilder arpShaBuilder = new ArpShaBuilder();\r
+ final ArpShaCaseBuilder arpShaCaseBuilder = new ArpShaCaseBuilder();\r
+ final ArpShaBuilder arpShaBuilder = new ArpShaBuilder();\r
arpShaBuilder.setMacAddress(new MacAddress("00:00:00:00:00:03"));\r
arpShaCaseBuilder.setArpSha(arpShaBuilder.build());\r
entriesBuilder.setMatchEntryValue(arpShaCaseBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTha.class);\r
entriesBuilder.setHasMask(false);\r
- ArpThaCaseBuilder arpThaCaseBuilder = new ArpThaCaseBuilder();\r
- ArpThaBuilder arpThaBuilder = new ArpThaBuilder();\r
+ final ArpThaCaseBuilder arpThaCaseBuilder = new ArpThaCaseBuilder();\r
+ final ArpThaBuilder arpThaBuilder = new ArpThaBuilder();\r
arpThaBuilder.setMacAddress(new MacAddress("00:00:00:00:00:04"));\r
arpThaCaseBuilder.setArpTha(arpThaBuilder.build());\r
entriesBuilder.setMatchEntryValue(arpThaCaseBuilder.build());\r
entries.add(entriesBuilder.build());\r
builder.setMatchEntry(entries);\r
\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
.MatchBuilder salMatchBuilder = MatchConvertorImpl.fromOFMatchToSALMatch(builder.build(), new BigInteger("42"), OpenflowVersion.OF13);\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
\r
- ArpMatch arpMatch = (ArpMatch) builtMatch.getLayer3Match();\r
+ final ArpMatch arpMatch = (ArpMatch) builtMatch.getLayer3Match();\r
Assert.assertEquals("Wrong arp op", 17, arpMatch.getArpOp().intValue());\r
Assert.assertEquals("Wrong arp spa", "10.0.0.3/32", arpMatch.getArpSourceTransportAddress().getValue());\r
Assert.assertEquals("Wrong arp tpa", "10.0.0.4/32", arpMatch.getArpTargetTransportAddress().getValue());\r
*/\r
@Test\r
public void testLayer3MatchArpWithMasks() {\r
- MatchBuilder builder = new MatchBuilder();\r
+ final MatchBuilder builder = new MatchBuilder();\r
builder.setType(OxmMatchType.class);\r
- List<MatchEntry> entries = new ArrayList<>();\r
+ final List<MatchEntry> entries = new ArrayList<>();\r
MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(ArpSpa.class);\r
entriesBuilder.setHasMask(true);\r
- ArpSpaCaseBuilder arpSpaCaseBuilder = new ArpSpaCaseBuilder();\r
- ArpSpaBuilder arpSpaBuilder = new ArpSpaBuilder();\r
+ final ArpSpaCaseBuilder arpSpaCaseBuilder = new ArpSpaCaseBuilder();\r
+ final ArpSpaBuilder arpSpaBuilder = new ArpSpaBuilder();\r
arpSpaBuilder.setIpv4Address(new Ipv4Address("10.0.0.3"));\r
arpSpaBuilder.setMask(new byte[]{(byte) 255, (byte) 255, (byte) 255, 0});\r
arpSpaCaseBuilder.setArpSpa(arpSpaBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(ArpTpa.class);\r
entriesBuilder.setHasMask(true);\r
- ArpTpaCaseBuilder arpTpaCaseBuilder = new ArpTpaCaseBuilder();\r
- ArpTpaBuilder arpTpaBuilder = new ArpTpaBuilder();\r
- arpTpaBuilder.setIpv4Address(new Ipv4Address("10.0.0.4"));\r
+ final ArpTpaCaseBuilder arpTpaCaseBuilder = new ArpTpaCaseBuilder();\r
+ final ArpTpaBuilder arpTpaBuilder = new ArpTpaBuilder();\r
+ arpTpaBuilder.setIpv4Address(new Ipv4Address("10.0.0.0"));\r
arpTpaBuilder.setMask(new byte[]{(byte) 255, (byte) 128, 0, 0});\r
arpTpaCaseBuilder.setArpTpa(arpTpaBuilder.build());\r
entriesBuilder.setMatchEntryValue(arpTpaCaseBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(ArpSha.class);\r
entriesBuilder.setHasMask(true);\r
- ArpShaCaseBuilder arpShaCaseBuilder = new ArpShaCaseBuilder();\r
- ArpShaBuilder arpShaBuilder = new ArpShaBuilder();\r
+ final ArpShaCaseBuilder arpShaCaseBuilder = new ArpShaCaseBuilder();\r
+ final ArpShaBuilder arpShaBuilder = new ArpShaBuilder();\r
arpShaBuilder.setMacAddress(new MacAddress("00:00:00:00:00:03"));\r
arpShaBuilder.setMask(new byte[]{0, 0, 1, 0, 4, 0});\r
arpShaCaseBuilder.setArpSha(arpShaBuilder.build());\r
entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTha.class);\r
entriesBuilder.setHasMask(true);\r
- ArpThaCaseBuilder arpThaCaseBuilder = new ArpThaCaseBuilder();\r
- ArpThaBuilder arpThaBuilder = new ArpThaBuilder();\r
+ final ArpThaCaseBuilder arpThaCaseBuilder = new ArpThaCaseBuilder();\r
+ final ArpThaBuilder arpThaBuilder = new ArpThaBuilder();\r
arpThaBuilder.setMacAddress(new MacAddress("00:00:00:00:00:04"));\r
arpThaBuilder.setMask(new byte[]{1, 1, 1, 2, 2, 2});\r
arpThaCaseBuilder.setArpTha(arpThaBuilder.build());\r
\r
builder.setMatchEntry(entries);\r
\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
.MatchBuilder salMatchBuilder = MatchConvertorImpl.fromOFMatchToSALMatch(builder.build(), new BigInteger("42"), OpenflowVersion.OF13);\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
\r
- ArpMatch arpMatch = (ArpMatch) builtMatch.getLayer3Match();\r
+ final ArpMatch arpMatch = (ArpMatch) builtMatch.getLayer3Match();\r
Assert.assertEquals("Wrong arp spa", "10.0.0.3/24", arpMatch.getArpSourceTransportAddress().getValue());\r
- Assert.assertEquals("Wrong arp tpa", "10.0.0.4/9", arpMatch.getArpTargetTransportAddress().getValue());\r
+ Assert.assertEquals("Wrong arp tpa", "10.0.0.0/9", arpMatch.getArpTargetTransportAddress().getValue());\r
Assert.assertEquals("Wrong arp sha", "00:00:00:00:00:03", arpMatch.getArpSourceHardwareAddress().getAddress().getValue());\r
Assert.assertEquals("Wrong arp sha mask", "00:00:01:00:04:00", arpMatch.getArpSourceHardwareAddress().getMask().getValue());\r
Assert.assertEquals("Wrong arp tha", "00:00:00:00:00:04", arpMatch.getArpTargetHardwareAddress().getAddress().getValue());\r
Assert.assertEquals("Wrong arp tha mask", "01:01:01:02:02:02", arpMatch.getArpTargetHardwareAddress().getMask().getValue());\r
}\r
-}
\ No newline at end of file
+}\r
return flags;
}
- /**
- * Test method for {@link MatchConvertorUtil#ipv6NetmaskArrayToCIDRValue(byte[])} (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MatchEntry)}.
- *
- * @throws Exception
- */
-
- @Test
- public void testIpv6NetmaskArrayToCIDRValue() throws Exception {
- BigInteger maskSeed = new BigInteger("1ffffffffffffffffffffffffffffffff", 16);
- byte[] maskArray = new byte[16];
- LOG.debug("maskSeed= {}", ByteBufUtils.bytesToHexString(maskSeed.toByteArray()));
-
- for (int i = 0; i <= 128; i++) {
- System.arraycopy(maskSeed.toByteArray(), 1, maskArray, 0, 16);
- LOG.debug("maskHex[{}] = {}", i, ByteBufUtils.bytesToHexString(maskArray));
- int cidr = MatchConvertorUtil.ipv6NetmaskArrayToCIDRValue(maskArray);
- LOG.debug("cidr = {}", cidr);
- Assert.assertEquals(128 - i, cidr);
-
- maskSeed = maskSeed.clearBit(i);
- }
- }
-
- /**
- * Test method for {@link MatchConvertorUtil#getIpv4Mask(byte[])}.
- *
- * @throws Exception
- */
-
- @Test
- public void testGetIpv4Mask() {
- byte[][] maskInputs = new byte[][]{
- {(byte) 255, (byte) 255, (byte) 255, (byte) 255},
- {(byte) 255, (byte) 255, (byte) 254, 0},
- {(byte) 128, 0, 0, 0},
- {0, 0, 0, 0},
- };
-
- String[] maskOutputs = new String[]{
- "/32", "/23", "/1", "/0"
- };
-
- for (int i = 0; i < maskInputs.length; i++) {
- String mask = MatchConvertorUtil.getIpv4Mask(maskInputs[i]);
- Assert.assertEquals(maskOutputs[i], mask);
- }
- }
-
- /**
- * Test method for {@link MatchConvertorUtil#getIpv4Mask(byte[])}.
- *
- * @throws Exception
- */
-
- @Test
- public void testGetIpv4MaskNegative() {
- byte[][] maskInputs = new byte[][]{
- {(byte) 127, 0, 0, 0},
- {(byte) 127, 0, 0},
- };
-
- for (int i = 0; i < maskInputs.length; i++) {
- try {
- String mask = MatchConvertorUtil.getIpv4Mask(maskInputs[i]);
- Assert.fail("invalid mask should not have passed: " + Arrays.toString(maskInputs[i]));
- } catch (Exception e) {
- // expected
- LOG.info("ipv4 mask excepted exception: {}", e.getMessage(), e);
- }
- }
- }
}
import static org.opendaylight.openflowjava.util.ByteBufUtils.macAddressToString;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.RejectedExecutionHandler;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
static final long STARTUP_LOOP_TICK = 500L;
static final int STARTUP_LOOP_MAX_RETRIES = 8;
+ private static final int PROCESSING_POOL_SIZE = 10000;
- private final ExecutorService executorService = Executors.newFixedThreadPool(8);
+ private final int POOL_THREAD_AMOUNT = 8;
+ private final ExecutorService executorService;
private static final AtomicIntegerFieldUpdater<AbstractDropTest> SENT_UPDATER = AtomicIntegerFieldUpdater.newUpdater(AbstractDropTest.class, "sent");
return new DropTestStats(this.sent, this.rcvd, this.excs, this.ftrFailed, this.ftrSuccess, this.runablesExecuted, this.runablesRejected);
}
+ public AbstractDropTest() {
+ final ArrayBlockingQueue<Runnable> workQueue = new ArrayBlockingQueue<Runnable>(PROCESSING_POOL_SIZE);
+ ThreadPoolExecutor threadPool = new ThreadPoolExecutor(POOL_THREAD_AMOUNT, POOL_THREAD_AMOUNT, 0,
+ TimeUnit.MILLISECONDS,
+ workQueue);
+ threadPool.setThreadFactory(new ThreadFactoryBuilder().setNameFormat("dropTest-%d").build());
+ threadPool.setRejectedExecutionHandler(new RejectedExecutionHandler() {
+ @Override
+ public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
+ try {
+ workQueue.put(r);
+ } catch (InterruptedException e) {
+ throw new RejectedExecutionException("Interrupted while waiting on queue", e);
+ }
+ }
+ });
+
+ executorService = threadPool;
+ }
+
public final void clearStats() {
this.sent = 0;
this.rcvd = 0;
this.excs = 0;
this.ftrSuccess = 0;
this.ftrFailed = 0;
-
+ this.runablesExecuted = 0;
+ this.runablesRejected = 0;
}
private final void incrementRunableExecuted() {
RUNABLES_EXECUTED.incrementAndGet(this);
}
+
private final void incrementRunableRejected() {
RUNABLES_REJECTED.incrementAndGet(this);
}
processPacket(notification);
}
});
- } catch (RejectedExecutionException e){
+ } catch (Exception e) {
incrementRunableRejected();
}
LOG.debug("onPacketReceived - Leaving", notification);
this.message = null;
this.runablesExecuted = runablesExecuted;
this.runablesRejected = runablesRejected;
- runablesRejected = 0;
}
public DropTestStats(String message) {
result.append(this.ftrFailed);
result.append("\n run() executions :");
result.append(this.runablesExecuted);
+ result.append("\n run() rejected :");
+ result.append(this.runablesRejected);
} else {
result.append(this.message);
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.PbbBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.node.error.service.rev140410.NodeErrorListener;
-import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
private final NodeErrorListener nodeErrorListener = new NodeErrorListenerLoggingImpl();
private static NotificationService notificationService;
- public OpenflowpluginTestCommandProvider(BundleContext ctx) {
+ public OpenflowpluginTestCommandProvider(final BundleContext ctx) {
this.ctx = ctx;
}
- public void onSessionInitiated(ProviderContext session) {
+ public void onSessionInitiated(final ProviderContext session) {
notificationService = session.getSALService(NotificationService.class);
// For switch events
notificationService.registerNotificationListener(flowEventListener);
createTestFlow(createTestNode(null), null, null);
}
- private NodeBuilder createTestNode(String nodeId) {
+ private NodeBuilder createTestNode(final String nodeId) {
String localNodeId;
if (nodeId == null) {
localNodeId = nodeId;
}
- NodeBuilder builder = new NodeBuilder();
+ final NodeBuilder builder = new NodeBuilder();
builder.setId(new NodeId(localNodeId));
builder.setKey(new NodeKey(builder.getId()));
return builder;
}
- private InstanceIdentifier<Node> nodeBuilderToInstanceId(NodeBuilder node) {
+ private InstanceIdentifier<Node> nodeBuilderToInstanceId(final NodeBuilder node) {
return InstanceIdentifier.create(Nodes.class).child(Node.class, node.getKey());
}
- private FlowBuilder createTestFlow(NodeBuilder nodeBuilder, String flowTypeArg, String tableId) {
+ private FlowBuilder createTestFlow(final NodeBuilder nodeBuilder, final String flowTypeArg, final String tableId) {
final long TEST_ID = 123;
- FlowBuilder flow = new FlowBuilder();
+ final FlowBuilder flow = new FlowBuilder();
long id = TEST_ID;
String flowType = flowTypeArg;
LOG.warn("flow type not understood: {}", flowType);
}
- FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
+ final FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
if (null == flow.isBarrier()) {
flow.setBarrier(Boolean.FALSE);
}
- BigInteger value = BigInteger.valueOf(10);
+ final BigInteger value = BigInteger.valueOf(10);
flow.setCookie(new FlowCookie(value));
flow.setCookieMask(new FlowCookie(value));
flow.setHardTimeout(0);
}
- private FlowBuilder createTestFlowPerfTest(String flowTypeArg, String tableId, int id) {
- FlowBuilder flow = new FlowBuilder();
+ private FlowBuilder createTestFlowPerfTest(final String flowTypeArg, final String tableId, final int id) {
+ final FlowBuilder flow = new FlowBuilder();
String flowType = flowTypeArg;
int flowId = id;
LOG.warn("flow type not understood: {}", flowType);
}
- FlowKey key = new FlowKey(new FlowId(Long.toString(flowId)));
+ final FlowKey key = new FlowKey(new FlowId(Long.toString(flowId)));
if (null == flow.isBarrier()) {
flow.setBarrier(Boolean.FALSE);
}
- BigInteger value = BigInteger.valueOf(10);
+ final BigInteger value = BigInteger.valueOf(10);
flow.setCookie(new FlowCookie(value));
flow.setCookieMask(new FlowCookie(value));
flow.setHardTimeout(0);
}
private FlowBuilder createtablemiss() {
- FlowBuilder flow = new FlowBuilder();
- long id = 456;
- MatchBuilder matchBuilder = new MatchBuilder();
+ final FlowBuilder flow = new FlowBuilder();
+ final long id = 456;
+ final MatchBuilder matchBuilder = new MatchBuilder();
flow.setMatch(matchBuilder.build());
flow.setInstructions(createSentToControllerInstructions().build());
flow.setPriority(0);
flow.setTableId((short) 0);
- FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
+ final FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
flow.setKey(key);
testFlow = flow;
return flow;
}
- private short getTableId(String tableId) {
+ private short getTableId(final String tableId) {
final short TABLE_ID = 2;
short table = TABLE_ID;
try {
table = Short.parseShort(tableId);
- } catch (Exception ex) {
+ } catch (final Exception ex) {
LOG.info("Parsing String tableId {} failed. Continuing with default tableId {}.",
tableId, table);
}
* @return
*/
private static InstructionsBuilder createDecNwTtlInstructions() {
- DecNwTtlBuilder ta = new DecNwTtlBuilder();
- DecNwTtl decNwTtl = ta.build();
- ActionBuilder ab = new ActionBuilder();
+ final DecNwTtlBuilder ta = new DecNwTtlBuilder();
+ final DecNwTtl decNwTtl = ta.build();
+ final ActionBuilder ab = new ActionBuilder();
ab.setAction(new DecNwTtlCaseBuilder().setDecNwTtl(decNwTtl).build());
ab.setKey(new ActionKey(0));
// Add our drop action to a list
- List<Action> actionList = new ArrayList<Action>();
+ final List<Action> actionList = new ArrayList<Action>();
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
ib.setKey(new InstructionKey(0));
ib.setOrder(0);
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
instructions.add(ib.build());
ib.setKey(new InstructionKey(0));
isb.setInstruction(instructions);
*/
private static InstructionsBuilder createMeterInstructions() {
- MeterBuilder aab = new MeterBuilder();
+ final MeterBuilder aab = new MeterBuilder();
aab.setMeterId(new MeterId(1L));
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new MeterCaseBuilder().setMeter(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createMetadataInstructions() {
- WriteMetadataBuilder aab = new WriteMetadataBuilder();
+ final WriteMetadataBuilder aab = new WriteMetadataBuilder();
aab.setMetadata(BigInteger.valueOf(10));
aab.setMetadataMask(BigInteger.valueOf(10));
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new WriteMetadataCaseBuilder().setWriteMetadata(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createGotoTableInstructions() {
- GoToTableBuilder aab = new GoToTableBuilder();
+ final GoToTableBuilder aab = new GoToTableBuilder();
aab.setTableId((short) 5);
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new GoToTableCaseBuilder().setGoToTable(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
}
private static InstructionsBuilder createDropInstructions() {
- DropActionBuilder dab = new DropActionBuilder();
- DropAction dropAction = dab.build();
- ActionBuilder ab = new ActionBuilder();
+ final DropActionBuilder dab = new DropActionBuilder();
+ final DropAction dropAction = dab.build();
+ final ActionBuilder ab = new ActionBuilder();
ab.setAction(new DropActionCaseBuilder().setDropAction(dropAction).build());
ab.setKey(new ActionKey(0));
// Add our drop action to a list
- List<Action> actionList = new ArrayList<Action>();
+ final List<Action> actionList = new ArrayList<Action>();
actionList.add(ab.build());
ab.setKey(new ActionKey(0));
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
- ControllerActionBuilder controller = new ControllerActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
+ final ControllerActionBuilder controller = new ControllerActionBuilder();
controller.setMaxLength(5);
ab.setAction(new ControllerActionCaseBuilder().setControllerAction(controller.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction1() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- OutputActionBuilder output = new OutputActionBuilder();
+ final OutputActionBuilder output = new OutputActionBuilder();
output.setMaxLength(56);
- Uri value = new Uri("PCEP");
+ final Uri value = new Uri("PCEP");
output.setOutputNodeConnector(value);
ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
// test case for Output Port works if the particular port exists
// this particular test-case is for Port : 1
// tested as (addMDFlow openflow:<dpid> f82)
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
- OutputActionBuilder output = new OutputActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
+ final OutputActionBuilder output = new OutputActionBuilder();
- Uri value = new Uri("1");
+ final Uri value = new Uri("1");
output.setOutputNodeConnector(value);
ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
ab.setOrder(0);
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
ib.setOrder(0);
ib.setKey(new InstructionKey(0));
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
}
private static InstructionsBuilder createSentToControllerInstructions() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- OutputActionBuilder output = new OutputActionBuilder();
+ final OutputActionBuilder output = new OutputActionBuilder();
output.setMaxLength(Integer.valueOf(0xffff));
- Uri value = new Uri(OutputPortValues.CONTROLLER.toString());
+ final Uri value = new Uri(OutputPortValues.CONTROLLER.toString());
output.setOutputNodeConnector(value);
ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
ab.setOrder(0);
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
ib.setOrder(0);
ib.setKey(new InstructionKey(0));
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
}
- private static InstructionsBuilder createOutputInstructions(String outputType, int outputValue) {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ private static InstructionsBuilder createOutputInstructions(final String outputType, final int outputValue) {
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- OutputActionBuilder output = new OutputActionBuilder();
+ final OutputActionBuilder output = new OutputActionBuilder();
output.setMaxLength(outputValue);
- Uri value = new Uri(outputType);
+ final Uri value = new Uri(outputType);
output.setOutputNodeConnector(value);
ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
ab.setOrder(0);
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
ib.setOrder(0);
ib.setKey(new InstructionKey(0));
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
}
private static InstructionsBuilder createStripVlanInstructions() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- StripVlanActionBuilder stripActionBuilder = new StripVlanActionBuilder();
+ final StripVlanActionBuilder stripActionBuilder = new StripVlanActionBuilder();
ab.setAction(new StripVlanActionCaseBuilder().setStripVlanAction(stripActionBuilder.build()).build());
ab.setOrder(0);
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
ib.setOrder(0);
ib.setKey(new InstructionKey(0));
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
private static InstructionsBuilder createAppyActionInstruction2() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- PushMplsActionBuilder push = new PushMplsActionBuilder();
+ final PushMplsActionBuilder push = new PushMplsActionBuilder();
push.setEthernetType(Integer.valueOf(0x8847));
ab.setAction(new PushMplsActionCaseBuilder().setPushMplsAction(push.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction3() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- PushPbbActionBuilder pbb = new PushPbbActionBuilder();
+ final PushPbbActionBuilder pbb = new PushPbbActionBuilder();
pbb.setEthernetType(Integer.valueOf(0x88E7));
ab.setAction(new PushPbbActionCaseBuilder().setPushPbbAction(pbb.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction4() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- PushVlanActionBuilder vlan = new PushVlanActionBuilder();
+ final PushVlanActionBuilder vlan = new PushVlanActionBuilder();
vlan.setEthernetType(Integer.valueOf(0x8100));
ab.setAction(new PushVlanActionCaseBuilder().setPushVlanAction(vlan.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction5() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- SetDlDstActionBuilder setdl = new SetDlDstActionBuilder();
+ final SetDlDstActionBuilder setdl = new SetDlDstActionBuilder();
setdl.setAddress(new MacAddress("00:05:b9:7c:81:5f"));
ab.setAction(new SetDlDstActionCaseBuilder().setSetDlDstAction(setdl.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction6() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- SetDlSrcActionBuilder src = new SetDlSrcActionBuilder();
+ final SetDlSrcActionBuilder src = new SetDlSrcActionBuilder();
src.setAddress(new MacAddress("00:05:b9:7c:81:5f"));
ab.setAction(new SetDlSrcActionCaseBuilder().setSetDlSrcAction(src.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction7() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- SetVlanIdActionBuilder vl = new SetVlanIdActionBuilder();
- VlanId a = new VlanId(4000);
+ final SetVlanIdActionBuilder vl = new SetVlanIdActionBuilder();
+ final VlanId a = new VlanId(4000);
vl.setVlanId(a);
ab.setAction(new SetVlanIdActionCaseBuilder().setSetVlanIdAction(vl.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction8() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- SetVlanPcpActionBuilder pcp = new SetVlanPcpActionBuilder();
- VlanPcp pcp1 = new VlanPcp((short) 2);
+ final SetVlanPcpActionBuilder pcp = new SetVlanPcpActionBuilder();
+ final VlanPcp pcp1 = new VlanPcp((short) 2);
pcp.setVlanPcp(pcp1);
ab.setAction(new SetVlanPcpActionCaseBuilder().setSetVlanPcpAction(pcp.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction88() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- SetVlanPcpActionBuilder pcp = new SetVlanPcpActionBuilder();
+ final SetVlanPcpActionBuilder pcp = new SetVlanPcpActionBuilder();
// the code point is a 3-bit(0-7) field representing the frame priority level
- VlanPcp pcp1 = new VlanPcp((short) 4);
+ final VlanPcp pcp1 = new VlanPcp((short) 4);
pcp.setVlanPcp(pcp1);
ab.setAction(new SetVlanPcpActionCaseBuilder().setSetVlanPcpAction(pcp.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction9() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- CopyTtlInBuilder ttlin = new CopyTtlInBuilder();
+ final CopyTtlInBuilder ttlin = new CopyTtlInBuilder();
ab.setAction(new CopyTtlInCaseBuilder().setCopyTtlIn(ttlin.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction10() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- CopyTtlOutBuilder ttlout = new CopyTtlOutBuilder();
+ final CopyTtlOutBuilder ttlout = new CopyTtlOutBuilder();
ab.setAction(new CopyTtlOutCaseBuilder().setCopyTtlOut(ttlout.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction11() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- DecMplsTtlBuilder mpls = new DecMplsTtlBuilder();
+ final DecMplsTtlBuilder mpls = new DecMplsTtlBuilder();
ab.setAction(new DecMplsTtlCaseBuilder().setDecMplsTtl(mpls.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
ib.setKey(new InstructionKey(0));
ib.setOrder(0);
// Put our Instruction in a list of Instruction
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
private static InstructionsBuilder createAppyActionInstruction12() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- DecNwTtlBuilder nwttl = new DecNwTtlBuilder();
+ final DecNwTtlBuilder nwttl = new DecNwTtlBuilder();
ab.setAction(new DecNwTtlCaseBuilder().setDecNwTtl(nwttl.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction13() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- DropActionBuilder drop = new DropActionBuilder();
+ final DropActionBuilder drop = new DropActionBuilder();
ab.setAction(new DropActionCaseBuilder().setDropAction(drop.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction14() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- FloodActionBuilder fld = new FloodActionBuilder();
+ final FloodActionBuilder fld = new FloodActionBuilder();
ab.setAction(new FloodActionCaseBuilder().setFloodAction(fld.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction15() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- FloodAllActionBuilder fldall = new FloodAllActionBuilder();
+ final FloodAllActionBuilder fldall = new FloodAllActionBuilder();
ab.setAction(new FloodAllActionCaseBuilder().setFloodAllAction(fldall.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction16() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- GroupActionBuilder groupActionB = new GroupActionBuilder();
+ final GroupActionBuilder groupActionB = new GroupActionBuilder();
groupActionB.setGroupId(1L);
groupActionB.setGroup("0");
ab.setAction(new GroupActionCaseBuilder().setGroupAction(groupActionB.build()).build());
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction17() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- HwPathActionBuilder hwPathB = new HwPathActionBuilder();
+ final HwPathActionBuilder hwPathB = new HwPathActionBuilder();
ab.setAction(new HwPathActionCaseBuilder().setHwPathAction(hwPathB.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction18() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- LoopbackActionBuilder loopbackActionBuilder = new LoopbackActionBuilder();
+ final LoopbackActionBuilder loopbackActionBuilder = new LoopbackActionBuilder();
ab.setAction(new LoopbackActionCaseBuilder().setLoopbackAction(loopbackActionBuilder.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction19() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- PopMplsActionBuilder popMplsActionBuilder = new PopMplsActionBuilder();
+ final PopMplsActionBuilder popMplsActionBuilder = new PopMplsActionBuilder();
popMplsActionBuilder.setEthernetType(0XB);
ab.setAction(new PopMplsActionCaseBuilder().setPopMplsAction(popMplsActionBuilder.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction20() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- PopPbbActionBuilder popPbbActionBuilder = new PopPbbActionBuilder();
+ final PopPbbActionBuilder popPbbActionBuilder = new PopPbbActionBuilder();
ab.setAction(new PopPbbActionCaseBuilder().setPopPbbAction(popPbbActionBuilder.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction21() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- PopVlanActionBuilder popVlanActionBuilder = new PopVlanActionBuilder();
+ final PopVlanActionBuilder popVlanActionBuilder = new PopVlanActionBuilder();
ab.setAction(new PopVlanActionCaseBuilder().setPopVlanAction(popVlanActionBuilder.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction22() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- SetDlTypeActionBuilder setDlTypeActionBuilder = new SetDlTypeActionBuilder();
+ final SetDlTypeActionBuilder setDlTypeActionBuilder = new SetDlTypeActionBuilder();
setDlTypeActionBuilder.setDlType(new EtherType(8L));
ab.setAction(new SetDlTypeActionCaseBuilder().setSetDlTypeAction(setDlTypeActionBuilder.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
}
- private static InstructionsBuilder createAppyActionInstruction23(NodeId nodeId) {
+ private static InstructionsBuilder createAppyActionInstruction23(final NodeId nodeId) {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+ final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
setFieldBuilder.setInPort(new NodeConnectorId(nodeId + ":2"));
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction24() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- SetMplsTtlActionBuilder setMplsTtlActionBuilder = new SetMplsTtlActionBuilder();
+ final SetMplsTtlActionBuilder setMplsTtlActionBuilder = new SetMplsTtlActionBuilder();
setMplsTtlActionBuilder.setMplsTtl((short) 0X1);
ab.setAction(new SetMplsTtlActionCaseBuilder().setSetMplsTtlAction(setMplsTtlActionBuilder.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction25() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- SetNextHopActionBuilder setNextHopActionBuilder = new SetNextHopActionBuilder();
- Ipv4Builder ipnext = new Ipv4Builder();
- Ipv4Prefix prefix = new Ipv4Prefix(IPV4_PREFIX);
+ final SetNextHopActionBuilder setNextHopActionBuilder = new SetNextHopActionBuilder();
+ final Ipv4Builder ipnext = new Ipv4Builder();
+ final Ipv4Prefix prefix = new Ipv4Prefix(IPV4_PREFIX);
ipnext.setIpv4Address(prefix);
setNextHopActionBuilder.setAddress(ipnext.build());
ab.setAction(new SetNextHopActionCaseBuilder().setSetNextHopAction(setNextHopActionBuilder.build()).build());
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction26() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
- Ipv4Builder ipdst = new Ipv4Builder();
- Ipv4Prefix prefixdst = new Ipv4Prefix("10.0.0.21/24");
+ final SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
+ final Ipv4Builder ipdst = new Ipv4Builder();
+ final Ipv4Prefix prefixdst = new Ipv4Prefix("10.0.0.21/24");
ipdst.setIpv4Address(prefixdst);
setNwDstActionBuilder.setAddress(ipdst.build());
ab.setAction(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilder.build()).build());
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction27() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- SetNwSrcActionBuilder setNwsrcActionBuilder = new SetNwSrcActionBuilder();
- Ipv4Builder ipsrc = new Ipv4Builder();
- Ipv4Prefix prefixsrc = new Ipv4Prefix("10.0.23.21/24");
+ final SetNwSrcActionBuilder setNwsrcActionBuilder = new SetNwSrcActionBuilder();
+ final Ipv4Builder ipsrc = new Ipv4Builder();
+ final Ipv4Prefix prefixsrc = new Ipv4Prefix("10.0.23.21/24");
ipsrc.setIpv4Address(prefixsrc);
setNwsrcActionBuilder.setAddress(ipsrc.build());
ab.setAction(new SetNwSrcActionCaseBuilder().setSetNwSrcAction(setNwsrcActionBuilder.build()).build());
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction28() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- SetNwTosActionBuilder setNwTosActionBuilder = new SetNwTosActionBuilder();
+ final SetNwTosActionBuilder setNwTosActionBuilder = new SetNwTosActionBuilder();
setNwTosActionBuilder.setTos(8);
ab.setAction(new SetNwTosActionCaseBuilder().setSetNwTosAction(setNwTosActionBuilder.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction29() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- SetNwTtlActionBuilder setNwTtlActionBuilder = new SetNwTtlActionBuilder();
+ final SetNwTtlActionBuilder setNwTtlActionBuilder = new SetNwTtlActionBuilder();
setNwTtlActionBuilder.setNwTtl((short) 1);
ab.setAction(new SetNwTtlActionCaseBuilder().setSetNwTtlAction(setNwTtlActionBuilder.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction30() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- SetQueueActionBuilder setQueueActionBuilder = new SetQueueActionBuilder();
+ final SetQueueActionBuilder setQueueActionBuilder = new SetQueueActionBuilder();
setQueueActionBuilder.setQueueId(1L);
ab.setAction(new SetQueueActionCaseBuilder().setSetQueueAction(setQueueActionBuilder.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction31() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- SetTpDstActionBuilder setTpDstActionBuilder = new SetTpDstActionBuilder();
+ final SetTpDstActionBuilder setTpDstActionBuilder = new SetTpDstActionBuilder();
setTpDstActionBuilder.setPort(new PortNumber(109));
ab.setAction(new SetTpDstActionCaseBuilder().setSetTpDstAction(setTpDstActionBuilder.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction32() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- SetTpSrcActionBuilder setTpSrcActionBuilder = new SetTpSrcActionBuilder();
+ final SetTpSrcActionBuilder setTpSrcActionBuilder = new SetTpSrcActionBuilder();
setTpSrcActionBuilder.setPort(new PortNumber(109));
ab.setAction(new SetTpSrcActionCaseBuilder().setSetTpSrcAction(setTpSrcActionBuilder.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction33() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- SetVlanCfiActionBuilder setVlanCfiActionBuilder = new SetVlanCfiActionBuilder();
+ final SetVlanCfiActionBuilder setVlanCfiActionBuilder = new SetVlanCfiActionBuilder();
setVlanCfiActionBuilder.setVlanCfi(new VlanCfi(2));
ab.setAction(new SetVlanCfiActionCaseBuilder().setSetVlanCfiAction(setVlanCfiActionBuilder.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction34() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
- SwPathActionBuilder swPathAction = new SwPathActionBuilder();
+ final SwPathActionBuilder swPathAction = new SwPathActionBuilder();
ab.setAction(new SwPathActionCaseBuilder().setSwPathAction(swPathAction.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction35() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
- ActionBuilder ab1 = new ActionBuilder();
- ActionBuilder ab2 = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
+ final ActionBuilder ab1 = new ActionBuilder();
+ final ActionBuilder ab2 = new ActionBuilder();
- SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
- SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
- SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
+ final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+ final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
+ final SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
// Ethernet
- EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
- EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
+ final EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
+ final EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
ethSourceBuilder.setAddress(new MacAddress("00:00:00:00:00:01"));
- EthernetMatchBuilder ethernetMatch1 = new EthernetMatchBuilder();
- EthernetDestinationBuilder ethDestBuilder = new EthernetDestinationBuilder();
+ final EthernetMatchBuilder ethernetMatch1 = new EthernetMatchBuilder();
+ final EthernetDestinationBuilder ethDestBuilder = new EthernetDestinationBuilder();
ethDestBuilder.setAddress(new MacAddress("00:00:00:00:00:02"));
- EthernetMatchBuilder ethernetMatch2 = new EthernetMatchBuilder();
- EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+ final EthernetMatchBuilder ethernetMatch2 = new EthernetMatchBuilder();
+ final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x86ddL));
ethernetMatch.setEthernetSource(ethSourceBuilder.build());
ab2.setKey(new ActionKey(2));
actionList.add(ab2.build());
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setKey(new InstructionKey(0));
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
private static InstructionsBuilder createAppyActionInstruction36() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
- ActionBuilder ab1 = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
+ final ActionBuilder ab1 = new ActionBuilder();
- SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
- SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
+ final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+ final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
// Vlan
- VlanMatchBuilder vlanBuilder = new VlanMatchBuilder();
- VlanMatchBuilder vlanBuilder1 = new VlanMatchBuilder();
- VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
- VlanId vlanId = new VlanId(10);
- VlanPcp vpcp = new VlanPcp((short) 3);
+ final VlanMatchBuilder vlanBuilder = new VlanMatchBuilder();
+ final VlanMatchBuilder vlanBuilder1 = new VlanMatchBuilder();
+ final VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
+ final VlanId vlanId = new VlanId(10);
+ final VlanPcp vpcp = new VlanPcp((short) 3);
vlanBuilder.setVlanPcp(vpcp);
vlanBuilder1.setVlanId(vlanIdBuilder.setVlanId(vlanId).setVlanIdPresent(true).build());
setFieldBuilder.setVlanMatch(vlanBuilder.build());
ab1.setKey(new ActionKey(1));
actionList.add(ab1.build());
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setKey(new InstructionKey(0));
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
private static InstructionsBuilder createAppyActionInstruction37() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
- ActionBuilder ab1 = new ActionBuilder();
- ActionBuilder ab2 = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
+ final ActionBuilder ab1 = new ActionBuilder();
+ final ActionBuilder ab2 = new ActionBuilder();
- SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
- SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
- SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
+ final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+ final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
+ final SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
// Ip
- IpMatchBuilder ipmatch = new IpMatchBuilder();
- IpMatchBuilder ipmatch1 = new IpMatchBuilder();
- IpMatchBuilder ipmatch2 = new IpMatchBuilder();
- Dscp dscp = new Dscp((short) 3);
+ final IpMatchBuilder ipmatch = new IpMatchBuilder();
+ final IpMatchBuilder ipmatch1 = new IpMatchBuilder();
+ final IpMatchBuilder ipmatch2 = new IpMatchBuilder();
+ final Dscp dscp = new Dscp((short) 3);
ipmatch.setIpDscp(dscp);
ipmatch1.setIpEcn((short) 2);
ipmatch2.setIpProtocol((short) 120);
ab2.setKey(new ActionKey(2));
actionList.add(ab2.build());
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setKey(new InstructionKey(0));
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
private static InstructionsBuilder createAppyActionInstruction38() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
- ActionBuilder ab1 = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
+ final ActionBuilder ab1 = new ActionBuilder();
- SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
- SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
+ final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+ final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
// IPv4
- Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
- Ipv4MatchBuilder ipv4Match1 = new Ipv4MatchBuilder();
- Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.5210");
- Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1");
+ final Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
+ final Ipv4MatchBuilder ipv4Match1 = new Ipv4MatchBuilder();
+ final Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.5210");
+ final Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1");
ipv4Match1.setIpv4Destination(dstip);
ipv4Match.setIpv4Source(srcip);
setFieldBuilder.setLayer3Match(ipv4Match.build());
ab1.setKey(new ActionKey(1));
actionList.add(ab1.build());
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setKey(new InstructionKey(0));
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
private static InstructionsBuilder createAppyActionInstruction39() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
- ActionBuilder ab1 = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
+ final ActionBuilder ab1 = new ActionBuilder();
- SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
- SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
+ final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+ final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
// Tcp
- PortNumber tcpsrcport = new PortNumber(1213);
- PortNumber tcpdstport = new PortNumber(646);
- TcpMatchBuilder tcpmatch = new TcpMatchBuilder();
- TcpMatchBuilder tcpmatch1 = new TcpMatchBuilder();
+ final PortNumber tcpsrcport = new PortNumber(1213);
+ final PortNumber tcpdstport = new PortNumber(646);
+ final TcpMatchBuilder tcpmatch = new TcpMatchBuilder();
+ final TcpMatchBuilder tcpmatch1 = new TcpMatchBuilder();
tcpmatch.setTcpSourcePort(tcpsrcport);
tcpmatch1.setTcpDestinationPort(tcpdstport);
setFieldBuilder.setLayer4Match(tcpmatch.build());
ab1.setKey(new ActionKey(1));
actionList.add(ab.build());
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setKey(new InstructionKey(0));
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
private static InstructionsBuilder createAppyActionInstruction40() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
- ActionBuilder ab1 = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
+ final ActionBuilder ab1 = new ActionBuilder();
- SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
- SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
+ final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+ final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
// Udp
- PortNumber udpsrcport = new PortNumber(1325);
- PortNumber udpdstport = new PortNumber(42);
- UdpMatchBuilder udpmatch = new UdpMatchBuilder();
- UdpMatchBuilder udpmatch1 = new UdpMatchBuilder();
+ final PortNumber udpsrcport = new PortNumber(1325);
+ final PortNumber udpdstport = new PortNumber(42);
+ final UdpMatchBuilder udpmatch = new UdpMatchBuilder();
+ final UdpMatchBuilder udpmatch1 = new UdpMatchBuilder();
udpmatch.setUdpDestinationPort(udpdstport);
udpmatch1.setUdpSourcePort(udpsrcport);
setFieldBuilder.setLayer4Match(udpmatch.build());
ab1.setKey(new ActionKey(1));
actionList.add(ab1.build());
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setKey(new InstructionKey(0));
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
private static InstructionsBuilder createAppyActionInstruction41() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
- ActionBuilder ab1 = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
+ final ActionBuilder ab1 = new ActionBuilder();
- SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
- SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
+ final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+ final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
// Sctp
- SctpMatchBuilder sctpmatch = new SctpMatchBuilder();
- SctpMatchBuilder sctpmatch1 = new SctpMatchBuilder();
- PortNumber srcport = new PortNumber(1435);
- PortNumber dstport = new PortNumber(22);
+ final SctpMatchBuilder sctpmatch = new SctpMatchBuilder();
+ final SctpMatchBuilder sctpmatch1 = new SctpMatchBuilder();
+ final PortNumber srcport = new PortNumber(1435);
+ final PortNumber dstport = new PortNumber(22);
sctpmatch.setSctpSourcePort(srcport);
sctpmatch1.setSctpDestinationPort(dstport);
setFieldBuilder.setLayer4Match(sctpmatch.build());
ab1.setKey(new ActionKey(1));
actionList.add(ab1.build());
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setKey(new InstructionKey(0));
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
private static InstructionsBuilder createAppyActionInstruction42() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
- ActionBuilder ab1 = new ActionBuilder();
- SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
- SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
+ final ActionBuilder ab1 = new ActionBuilder();
+ final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+ final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
// Icmpv4
- Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder();
- Icmpv4MatchBuilder icmpv4match1 = new Icmpv4MatchBuilder();
+ final Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder();
+ final Icmpv4MatchBuilder icmpv4match1 = new Icmpv4MatchBuilder();
icmpv4match.setIcmpv4Type((short) 8);
icmpv4match1.setIcmpv4Code((short) 0);
setFieldBuilder.setIcmpv4Match(icmpv4match.build());
ab1.setKey(new ActionKey(1));
actionList.add(ab1.build());
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setKey(new InstructionKey(0));
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
private static InstructionsBuilder createAppyActionInstruction43() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
- ActionBuilder ab1 = new ActionBuilder();
- ActionBuilder ab2 = new ActionBuilder();
- ActionBuilder ab3 = new ActionBuilder();
- ActionBuilder ab4 = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
+ final ActionBuilder ab1 = new ActionBuilder();
+ final ActionBuilder ab2 = new ActionBuilder();
+ final ActionBuilder ab3 = new ActionBuilder();
+ final ActionBuilder ab4 = new ActionBuilder();
- SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
- SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
- SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
- SetFieldBuilder setFieldBuilder3 = new SetFieldBuilder();
- SetFieldBuilder setFieldBuilder4 = new SetFieldBuilder();
+ final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+ final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
+ final SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
+ final SetFieldBuilder setFieldBuilder3 = new SetFieldBuilder();
+ final SetFieldBuilder setFieldBuilder4 = new SetFieldBuilder();
// setting the values of ARP
- MacAddress macdest = new MacAddress(DEST_MAC_ADDRESS);
- MacAddress macsrc = new MacAddress(SRC_MAC_ADDRESS);
- Ipv4Prefix dstiparp = new Ipv4Prefix("200.71.9.52");
- Ipv4Prefix srciparp = new Ipv4Prefix("100.1.1.1");
+ final MacAddress macdest = new MacAddress(DEST_MAC_ADDRESS);
+ final MacAddress macsrc = new MacAddress(SRC_MAC_ADDRESS);
+ final Ipv4Prefix dstiparp = new Ipv4Prefix("200.71.9.52");
+ final Ipv4Prefix srciparp = new Ipv4Prefix("100.1.1.1");
// create ARP match action
- ArpMatchBuilder arpmatch = new ArpMatchBuilder();
- ArpMatchBuilder arpmatch1 = new ArpMatchBuilder();
- ArpMatchBuilder arpmatch2 = new ArpMatchBuilder();
- ArpMatchBuilder arpmatch3 = new ArpMatchBuilder();
- ArpMatchBuilder arpmatch4 = new ArpMatchBuilder();
- ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
+ final ArpMatchBuilder arpmatch = new ArpMatchBuilder();
+ final ArpMatchBuilder arpmatch1 = new ArpMatchBuilder();
+ final ArpMatchBuilder arpmatch2 = new ArpMatchBuilder();
+ final ArpMatchBuilder arpmatch3 = new ArpMatchBuilder();
+ final ArpMatchBuilder arpmatch4 = new ArpMatchBuilder();
+ final ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
arpsrc.setAddress(macsrc);
- ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
+ final ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
arpdst.setAddress(macdest);
arpmatch.setArpOp(2);
arpmatch1.setArpSourceHardwareAddress(arpsrc.build());
ab4.setKey(new ActionKey(4));
actionList.add(ab4.build());
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setKey(new InstructionKey(0));
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
private static InstructionsBuilder createAppyActionInstruction44() {
- List<Action> actionLists = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
- SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
- ActionBuilder ab1 = new ActionBuilder();
- SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
- ActionBuilder ab5 = new ActionBuilder();
- SetFieldBuilder setFieldBuilder5 = new SetFieldBuilder();
- ActionBuilder ab6 = new ActionBuilder();
- SetFieldBuilder setFieldBuilder6 = new SetFieldBuilder();
+ final List<Action> actionLists = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
+ final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+ final ActionBuilder ab1 = new ActionBuilder();
+ final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
+ final ActionBuilder ab5 = new ActionBuilder();
+ final SetFieldBuilder setFieldBuilder5 = new SetFieldBuilder();
+ final ActionBuilder ab6 = new ActionBuilder();
+ final SetFieldBuilder setFieldBuilder6 = new SetFieldBuilder();
// IPv6
- Ipv6MatchBuilder ipv6Builder = new Ipv6MatchBuilder();
- Ipv6MatchBuilder ipv6Builder1 = new Ipv6MatchBuilder();
- Ipv6MatchBuilder ipv6Builder5 = new Ipv6MatchBuilder();
- Ipv6MatchBuilder ipv6Builder6 = new Ipv6MatchBuilder();
-
- Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2");
- Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1");
- Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
+ final Ipv6MatchBuilder ipv6Builder = new Ipv6MatchBuilder();
+ final Ipv6MatchBuilder ipv6Builder1 = new Ipv6MatchBuilder();
+ final Ipv6MatchBuilder ipv6Builder5 = new Ipv6MatchBuilder();
+ final Ipv6MatchBuilder ipv6Builder6 = new Ipv6MatchBuilder();
+
+ final Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2/128");
+ final Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1/128");
+ final Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
nextheader.setIpv6Exthdr(58);
- Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
- Ipv6FlowLabel label = new Ipv6FlowLabel(10028L);
+ final Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
+ final Ipv6FlowLabel label = new Ipv6FlowLabel(10028L);
ipv6label.setIpv6Flabel(label);
ipv6Builder.setIpv6Source(srcip6);
ab6.setKey(new ActionKey(6));
actionLists.add(ab6.build());
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionLists);
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setKey(new InstructionKey(0));
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
private static InstructionsBuilder createAppyActionInstruction45() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
- SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
- ActionBuilder ab1 = new ActionBuilder();
- SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
+ final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+ final ActionBuilder ab1 = new ActionBuilder();
+ final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
// Icmpv6
- Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder();
- Icmpv6MatchBuilder icmpv6match1 = new Icmpv6MatchBuilder();
+ final Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder();
+ final Icmpv6MatchBuilder icmpv6match1 = new Icmpv6MatchBuilder();
icmpv6match.setIcmpv6Type((short) 135);
icmpv6match1.setIcmpv6Code((short) 0);
setFieldBuilder.setIcmpv6Match(icmpv6match.build());
ab1.setKey(new ActionKey(1));
actionList.add(ab1.build());
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setKey(new InstructionKey(0));
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
private static InstructionsBuilder createAppyActionInstruction46() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
- SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
- ActionBuilder ab1 = new ActionBuilder();
- SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
- ActionBuilder ab2 = new ActionBuilder();
- SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
+ final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+ final ActionBuilder ab1 = new ActionBuilder();
+ final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
+ final ActionBuilder ab2 = new ActionBuilder();
+ final SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
// MPLS
- ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder();
- ProtocolMatchFieldsBuilder protomatch1 = new ProtocolMatchFieldsBuilder();
- ProtocolMatchFieldsBuilder protomatch2 = new ProtocolMatchFieldsBuilder();
+ final ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder();
+ final ProtocolMatchFieldsBuilder protomatch1 = new ProtocolMatchFieldsBuilder();
+ final ProtocolMatchFieldsBuilder protomatch2 = new ProtocolMatchFieldsBuilder();
protomatch.setMplsLabel((long) 36008);
protomatch1.setMplsTc((short) 4);
protomatch2.setMplsBos((short) 1);
ab2.setKey(new ActionKey(2));
actionList.add(ab2.build());
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setKey(new InstructionKey(0));
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
private static InstructionsBuilder createAppyActionInstruction47() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
- SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
+ final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
// PBB
- ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder();
+ final ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder();
protomatch.setPbb(new PbbBuilder().setPbbIsid(4L).setPbbMask((new BigInteger(new byte[]{0, 1, 0, 0}).longValue())).build());
setFieldBuilder.setProtocolMatchFields(protomatch.build());
ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
actionList.add(ab.build());
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setKey(new InstructionKey(0));
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
private static InstructionsBuilder createAppyActionInstruction48() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
- SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
+ final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
// Tunnel
- TunnelBuilder tunnel = new TunnelBuilder();
+ final TunnelBuilder tunnel = new TunnelBuilder();
tunnel.setTunnelId(BigInteger.valueOf(10668));
setFieldBuilder.setTunnel(tunnel.build());
ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setKey(new InstructionKey(0));
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
private static InstructionsBuilder createTunnelIpv4DstInstructions() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
// Build the tunnel endpoint destination IPv4 address
- SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
- Ipv4Prefix dstIp = new Ipv4Prefix("172.16.100.100");
+ final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+ final Ipv4Prefix dstIp = new Ipv4Prefix("172.16.100.100");
// Add the mew IPv4 object as the tunnel destination
- TunnelIpv4MatchBuilder tunnelIpv4DstMatchBuilder = new TunnelIpv4MatchBuilder();
+ final TunnelIpv4MatchBuilder tunnelIpv4DstMatchBuilder = new TunnelIpv4MatchBuilder();
tunnelIpv4DstMatchBuilder.setTunnelIpv4Destination(dstIp);
setFieldBuilder.setLayer3Match(tunnelIpv4DstMatchBuilder.build());
// Add the IPv4 tunnel dst to the set_field value
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Resulting action is a per/flow src TEP (set_field:172.16.100.100->tun_dst)
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Add the action to the ordered list of Instructions
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setOrder(0);
ib.setKey(new InstructionKey(0));
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Add the Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
private static InstructionsBuilder createTunnelIpv4SrcInstructions() {
- List<Action> actionList = new ArrayList<Action>();
- ActionBuilder ab = new ActionBuilder();
+ final List<Action> actionList = new ArrayList<Action>();
+ final ActionBuilder ab = new ActionBuilder();
// Build the tunnel endpoint source IPv4 address
- SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
- Ipv4Prefix dstIp = new Ipv4Prefix("172.16.100.200");
+ final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
+ final Ipv4Prefix dstIp = new Ipv4Prefix("172.16.100.200");
// Add the new IPv4 object as the tunnel destination
- TunnelIpv4MatchBuilder tunnelIpv4MatchBuilder = new TunnelIpv4MatchBuilder();
+ final TunnelIpv4MatchBuilder tunnelIpv4MatchBuilder = new TunnelIpv4MatchBuilder();
tunnelIpv4MatchBuilder.setTunnelIpv4Source(dstIp);
setFieldBuilder.setLayer3Match(tunnelIpv4MatchBuilder.build());
// Add the IPv4 tunnel src to the set_field value
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Resulting action is a per/flow src TEP (set_field:172.16.100.100->tun_src)
- ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Add the action to the ordered list of Instructions
- InstructionBuilder ib = new InstructionBuilder();
+ final InstructionBuilder ib = new InstructionBuilder();
ib.setOrder(0);
ib.setKey(new InstructionKey(0));
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
- InstructionsBuilder isb = new InstructionsBuilder();
- List<Instruction> instructions = new ArrayList<Instruction>();
+ final InstructionsBuilder isb = new InstructionsBuilder();
+ final List<Instruction> instructions = new ArrayList<Instruction>();
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
}
private static MatchBuilder createLLDPMatch() {
- MatchBuilder match = new MatchBuilder();
- EthernetMatchBuilder eth = new EthernetMatchBuilder();
- EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+ final MatchBuilder match = new MatchBuilder();
+ final EthernetMatchBuilder eth = new EthernetMatchBuilder();
+ final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x88ccL));
eth.setEthernetType(ethTypeBuilder.build());
match.setEthernetMatch(eth.build());
* @return
*/
private static MatchBuilder createMatch1() {
- MatchBuilder match = new MatchBuilder();
- Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
- Ipv4Prefix prefix = new Ipv4Prefix(IPV4_PREFIX);;
+ final MatchBuilder match = new MatchBuilder();
+ final Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
+ final Ipv4Prefix prefix = new Ipv4Prefix(IPV4_PREFIX);;
ipv4Match.setIpv4Destination(prefix);
- Ipv4Match i4m = ipv4Match.build();
+ final Ipv4Match i4m = ipv4Match.build();
match.setLayer3Match(i4m);
- EthernetMatchBuilder eth = new EthernetMatchBuilder();
- EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+ final EthernetMatchBuilder eth = new EthernetMatchBuilder();
+ final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x0800L));
eth.setEthernetType(ethTypeBuilder.build());
match.setEthernetMatch(eth.build());
* @return
*/
private static MatchBuilder createMatch2() {
- MatchBuilder match = new MatchBuilder();
- Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
- Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1");
+ final MatchBuilder match = new MatchBuilder();
+ final Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
+ final Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1");
ipv4Match.setIpv4Source(prefix);
- Ipv4Match i4m = ipv4Match.build();
+ final Ipv4Match i4m = ipv4Match.build();
match.setLayer3Match(i4m);
- EthernetMatchBuilder eth = new EthernetMatchBuilder();
- EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+ final EthernetMatchBuilder eth = new EthernetMatchBuilder();
+ final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x0800L));
eth.setEthernetType(ethTypeBuilder.build());
match.setEthernetMatch(eth.build());
* @return
*/
private static MatchBuilder createMatch3() {
- MatchBuilder match = new MatchBuilder();
- EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
- EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
+ final MatchBuilder match = new MatchBuilder();
+ final EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
+ final EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
ethSourceBuilder.setAddress(new MacAddress("00:00:00:00:00:01"));
ethernetMatch.setEthernetSource(ethSourceBuilder.build());
match.setEthernetMatch(ethernetMatch.build());
*/
private static MatchBuilder createICMPv6Match1() {
- MatchBuilder match = new MatchBuilder();
- EthernetMatchBuilder eth = new EthernetMatchBuilder();
- EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+ final MatchBuilder match = new MatchBuilder();
+ final EthernetMatchBuilder eth = new EthernetMatchBuilder();
+ final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x86ddL));
eth.setEthernetType(ethTypeBuilder.build());
match.setEthernetMatch(eth.build());
// ipv4 version
- IpMatchBuilder ipmatch = new IpMatchBuilder();
+ final IpMatchBuilder ipmatch = new IpMatchBuilder();
ipmatch.setIpProtocol((short) 256);
match.setIpMatch(ipmatch.build());
// icmpv6
- Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder();
+ final Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder();
// match
icmpv6match.setIcmpv6Type((short) 135);
private static MatchBuilder createMatch33() {
- MatchBuilder match = new MatchBuilder();
- Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
- Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.10");
+ final MatchBuilder match = new MatchBuilder();
+ final Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
+ final Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.10");
ipv4Match.setIpv4Source(prefix);
- Ipv4Match i4m = ipv4Match.build();
+ final Ipv4Match i4m = ipv4Match.build();
match.setLayer3Match(i4m);
- EthernetMatchBuilder eth = new EthernetMatchBuilder();
- EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+ final EthernetMatchBuilder eth = new EthernetMatchBuilder();
+ final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0xfffeL));
eth.setEthernetType(ethTypeBuilder.build());
match.setEthernetMatch(eth.build());
return match;
}
- private static MatchBuilder createInphyportMatch(NodeId nodeId) {
- MatchBuilder match = new MatchBuilder();
+ private static MatchBuilder createInphyportMatch(final NodeId nodeId) {
+ final MatchBuilder match = new MatchBuilder();
match.setInPort(new NodeConnectorId(nodeId + ":202"));
match.setInPhyPort(new NodeConnectorId(nodeId + ":10122"));
return match;
}
private static MatchBuilder createEthernetMatch() {
- MatchBuilder match = new MatchBuilder();
- EthernetMatchBuilder ethmatch = new EthernetMatchBuilder(); // ethernettype
+ final MatchBuilder match = new MatchBuilder();
+ final EthernetMatchBuilder ethmatch = new EthernetMatchBuilder(); // ethernettype
// match
- EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
- EtherType type = new EtherType(0x0800L);
+ final EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
+ final EtherType type = new EtherType(0x0800L);
ethmatch.setEthernetType(ethtype.setType(type).build());
- EthernetDestinationBuilder ethdest = new EthernetDestinationBuilder(); // ethernet
+ final EthernetDestinationBuilder ethdest = new EthernetDestinationBuilder(); // ethernet
// macaddress
// match
- MacAddress macdest = new MacAddress(DEST_MAC_ADDRESS);
+ final MacAddress macdest = new MacAddress(DEST_MAC_ADDRESS);
ethdest.setAddress(macdest);
ethdest.setMask(new MacAddress("ff:ff:ff:00:00:00"));
ethmatch.setEthernetDestination(ethdest.build());
- EthernetSourceBuilder ethsrc = new EthernetSourceBuilder();
- MacAddress macsrc = new MacAddress(SRC_MAC_ADDRESS);
+ final EthernetSourceBuilder ethsrc = new EthernetSourceBuilder();
+ final MacAddress macsrc = new MacAddress(SRC_MAC_ADDRESS);
ethsrc.setAddress(macsrc);
ethsrc.setMask(new MacAddress("ff:ff:00:00:00:00"));
*/
private static MatchBuilder createVlanMatch() {
- MatchBuilder match = new MatchBuilder();
+ final MatchBuilder match = new MatchBuilder();
// vlan match
- VlanMatchBuilder vlanBuilder = new VlanMatchBuilder();
- VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
- VlanId vlanId = new VlanId(10);
- VlanPcp vpcp = new VlanPcp((short) 3);
+ final VlanMatchBuilder vlanBuilder = new VlanMatchBuilder();
+ final VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
+ final VlanId vlanId = new VlanId(10);
+ final VlanPcp vpcp = new VlanPcp((short) 3);
vlanBuilder.setVlanPcp(vpcp);
vlanIdBuilder.setVlanId(vlanId);
vlanIdBuilder.setVlanIdPresent(true);
* @return
*/
private static MatchBuilder createArpMatch() {
- MatchBuilder match = new MatchBuilder();
+ final MatchBuilder match = new MatchBuilder();
- EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
- MacAddress macdest = new MacAddress(DEST_MAC_ADDRESS);
- MacAddress macsrc = new MacAddress(SRC_MAC_ADDRESS);
+ final EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
+ final MacAddress macdest = new MacAddress(DEST_MAC_ADDRESS);
+ final MacAddress macsrc = new MacAddress(SRC_MAC_ADDRESS);
- EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
- EtherType type = new EtherType(0x0806L);
+ final EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
+ final EtherType type = new EtherType(0x0806L);
ethmatch.setEthernetType(ethtype.setType(type).build());
// ipv4 match
- Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.52/10");
- Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1/8");
+ final Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.52/10");
+ final Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1/8");
// arp match
- ArpMatchBuilder arpmatch = new ArpMatchBuilder();
- ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
+ final ArpMatchBuilder arpmatch = new ArpMatchBuilder();
+ final ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
arpsrc.setAddress(macsrc);
arpsrc.setMask(new MacAddress("ff:ff:ff:00:00:00"));
- ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
+ final ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
arpdst.setAddress(macdest);
arpdst.setMask(new MacAddress("ff:ff:00:00:00:00"));
arpmatch.setArpOp(2);
* @return
*/
private static MatchBuilder createL3IPv4Match() {
- MatchBuilder match = new MatchBuilder();
+ final MatchBuilder match = new MatchBuilder();
- EthernetMatchBuilder eth = new EthernetMatchBuilder();
- EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+ final EthernetMatchBuilder eth = new EthernetMatchBuilder();
+ final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x0800L));
eth.setEthernetType(ethTypeBuilder.build());
match.setEthernetMatch(eth.build());
- Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
+ final Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
// ipv4 match
- Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.52/10");
- Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1/8");
- Ipv4MatchBuilder ipv4match = new Ipv4MatchBuilder();
+ final Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.52/10");
+ final Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1/8");
+ final Ipv4MatchBuilder ipv4match = new Ipv4MatchBuilder();
ipv4match.setIpv4Destination(dstip);
ipv4match.setIpv4Source(srcip);
match.setLayer3Match(ipv4match.build());
* @return
*/
private static MatchBuilder createL3IPv6Match() {
- MatchBuilder match = new MatchBuilder();
+ final MatchBuilder match = new MatchBuilder();
- EthernetMatchBuilder eth = new EthernetMatchBuilder();
- EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+ final EthernetMatchBuilder eth = new EthernetMatchBuilder();
+ final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x86ddL));
eth.setEthernetType(ethTypeBuilder.build());
match.setEthernetMatch(eth.build());
- Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2/64");
- Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1/56");
- Ipv6Address ndtarget = new Ipv6Address("2001:db8:0:1:fd97:f9f0:a810:782e");
- MacAddress ndsll = new MacAddress("c2:00:54:f5:00:00");
- MacAddress ndtll = new MacAddress("00:0c:29:0e:4c:67");
- Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
+ final Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2/64");
+ final Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1/56");
+ final Ipv6Address ndtarget = new Ipv6Address("2001:db8:0:1:fd97:f9f0:a810:782e");
+ final MacAddress ndsll = new MacAddress("c2:00:54:f5:00:00");
+ final MacAddress ndtll = new MacAddress("00:0c:29:0e:4c:67");
+ final Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
nextheader.setIpv6Exthdr(58);
- Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
- Ipv6FlowLabel label = new Ipv6FlowLabel(10028L);
+ final Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
+ final Ipv6FlowLabel label = new Ipv6FlowLabel(10028L);
ipv6label.setIpv6Flabel(label);
ipv6label.setFlabelMask(new Ipv6FlowLabel(1L));
- Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
+ final Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
// match
icmpv6match.setIcmpv6Type((short) 135);
icmpv6match.setIcmpv6Code((short) 0);
match.setIcmpv6Match(icmpv6match.build());
- Ipv6MatchBuilder ipv6match = new Ipv6MatchBuilder();
+ final Ipv6MatchBuilder ipv6match = new Ipv6MatchBuilder();
// ipv6match.setIpv6Source(srcip6);
// ipv6match.setIpv6Destination(dstip6);
// ipv6match.setIpv6ExtHeader(nextheader.build());
*/
private static MatchBuilder createICMPv4Match() {
- MatchBuilder match = new MatchBuilder();
- EthernetMatchBuilder eth = new EthernetMatchBuilder();
- EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+ final MatchBuilder match = new MatchBuilder();
+ final EthernetMatchBuilder eth = new EthernetMatchBuilder();
+ final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x0800L));
eth.setEthernetType(ethTypeBuilder.build());
match.setEthernetMatch(eth.build());
- IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
+ final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
ipmatch.setIpProtocol((short) 1);
match.setIpMatch(ipmatch.build());
- Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder(); // icmpv4
+ final Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder(); // icmpv4
// match
icmpv4match.setIcmpv4Type((short) 8);
icmpv4match.setIcmpv4Code((short) 0);
*/
private static MatchBuilder createICMPv6Match() {
- MatchBuilder match = new MatchBuilder();
- EthernetMatchBuilder eth = new EthernetMatchBuilder();
- EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+ final MatchBuilder match = new MatchBuilder();
+ final EthernetMatchBuilder eth = new EthernetMatchBuilder();
+ final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x86ddL));
eth.setEthernetType(ethTypeBuilder.build());
match.setEthernetMatch(eth.build());
- IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
+ final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
ipmatch.setIpProtocol((short) 58);
match.setIpMatch(ipmatch.build());
- Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
+ final Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
// match
icmpv6match.setIcmpv6Type((short) 135);
icmpv6match.setIcmpv6Code((short) 1);
* @return
*/
private static MatchBuilder createToSMatch() {
- MatchBuilder match = new MatchBuilder();
- EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
- EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
- EtherType type = new EtherType(0x0800L);
+ final MatchBuilder match = new MatchBuilder();
+ final EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
+ final EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
+ final EtherType type = new EtherType(0x0800L);
ethmatch.setEthernetType(ethtype.setType(type).build());
match.setEthernetMatch(ethmatch.build());
- IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
+ final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
ipmatch.setIpProtocol((short) 6);
- Dscp dscp = new Dscp((short) 8);
+ final Dscp dscp = new Dscp((short) 8);
ipmatch.setIpDscp(dscp);
match.setIpMatch(ipmatch.build());
return match;
*/
private static MatchBuilder createL4TCPMatch() {
- MatchBuilder match = new MatchBuilder();
+ final MatchBuilder match = new MatchBuilder();
- EthernetMatchBuilder eth = new EthernetMatchBuilder();
- EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+ final EthernetMatchBuilder eth = new EthernetMatchBuilder();
+ final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x0800L));
eth.setEthernetType(ethTypeBuilder.build());
match.setEthernetMatch(eth.build());
- IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
+ final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
ipmatch.setIpProtocol((short) 6);
match.setIpMatch(ipmatch.build());
- PortNumber srcport = new PortNumber(1213);
- PortNumber dstport = new PortNumber(646);
- TcpMatchBuilder tcpmatch = new TcpMatchBuilder(); // tcp match
+ final PortNumber srcport = new PortNumber(1213);
+ final PortNumber dstport = new PortNumber(646);
+ final TcpMatchBuilder tcpmatch = new TcpMatchBuilder(); // tcp match
tcpmatch.setTcpSourcePort(srcport);
tcpmatch.setTcpDestinationPort(dstport);
match.setLayer4Match(tcpmatch.build());
* @return
*/
private static MatchBuilder createL4UDPMatch() {
- MatchBuilder match = new MatchBuilder();
+ final MatchBuilder match = new MatchBuilder();
- EthernetMatchBuilder eth = new EthernetMatchBuilder();
- EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+ final EthernetMatchBuilder eth = new EthernetMatchBuilder();
+ final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x0800L));
eth.setEthernetType(ethTypeBuilder.build());
match.setEthernetMatch(eth.build());
- IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
+ final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
ipmatch.setIpProtocol((short) 17);
match.setIpMatch(ipmatch.build());
- PortNumber srcport = new PortNumber(1325);
- PortNumber dstport = new PortNumber(42);
- UdpMatchBuilder udpmatch = new UdpMatchBuilder(); // udp match
+ final PortNumber srcport = new PortNumber(1325);
+ final PortNumber dstport = new PortNumber(42);
+ final UdpMatchBuilder udpmatch = new UdpMatchBuilder(); // udp match
udpmatch.setUdpDestinationPort(dstport);
udpmatch.setUdpSourcePort(srcport);
match.setLayer4Match(udpmatch.build());
* @return
*/
private static MatchBuilder createL4SCTPMatch() {
- MatchBuilder match = new MatchBuilder();
+ final MatchBuilder match = new MatchBuilder();
- EthernetMatchBuilder eth = new EthernetMatchBuilder();
- EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+ final EthernetMatchBuilder eth = new EthernetMatchBuilder();
+ final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x0800L));
eth.setEthernetType(ethTypeBuilder.build());
match.setEthernetMatch(eth.build());
- IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
+ final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
ipmatch.setIpProtocol((short) 132);
match.setIpMatch(ipmatch.build());
- SctpMatchBuilder sctpmatch = new SctpMatchBuilder();
- PortNumber srcport = new PortNumber(1435);
- PortNumber dstport = new PortNumber(22);
+ final SctpMatchBuilder sctpmatch = new SctpMatchBuilder();
+ final PortNumber srcport = new PortNumber(1435);
+ final PortNumber dstport = new PortNumber(22);
sctpmatch.setSctpSourcePort(srcport);
sctpmatch.setSctpDestinationPort(dstport);
match.setLayer4Match(sctpmatch.build());
* @return
*/
private static MatchBuilder createMetadataMatch() {
- MatchBuilder match = new MatchBuilder();
- byte[] metamask = new byte[]{(byte) -1, (byte) -1, (byte) -1, 0, 0, 0, (byte) 1, (byte) 1};
- MetadataBuilder metadata = new MetadataBuilder(); // metadata match
+ final MatchBuilder match = new MatchBuilder();
+ final byte[] metamask = new byte[]{(byte) -1, (byte) -1, (byte) -1, 0, 0, 0, (byte) 1, (byte) 1};
+ final MetadataBuilder metadata = new MetadataBuilder(); // metadata match
metadata.setMetadata(BigInteger.valueOf(500L));
metadata.setMetadataMask(new BigInteger(1, metamask));
match.setMetadata(metadata.build());
* @return
*/
private static MatchBuilder createMplsMatch() {
- MatchBuilder match = new MatchBuilder();
+ final MatchBuilder match = new MatchBuilder();
- EthernetMatchBuilder eth = new EthernetMatchBuilder();
- EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+ final EthernetMatchBuilder eth = new EthernetMatchBuilder();
+ final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x8847L));
eth.setEthernetType(ethTypeBuilder.build());
match.setEthernetMatch(eth.build());
- ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls
+ final ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls
// match
protomatch.setMplsLabel((long) 36008);
protomatch.setMplsTc((short) 4);
* @return
*/
private static MatchBuilder createPbbMatch() {
- MatchBuilder match = new MatchBuilder();
+ final MatchBuilder match = new MatchBuilder();
- EthernetMatchBuilder eth = new EthernetMatchBuilder();
- EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+ final EthernetMatchBuilder eth = new EthernetMatchBuilder();
+ final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x88E7L));
eth.setEthernetType(ethTypeBuilder.build());
match.setEthernetMatch(eth.build());
- ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls
+ final ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls
// match
protomatch.setPbb(new PbbBuilder().setPbbIsid(4L).setPbbMask(new BigInteger(new byte[]{0, 1, 0, 0}).longValue()).build());
match.setProtocolMatchFields(protomatch.build());
* @return
*/
private static MatchBuilder createTunnelIDMatch() {
- MatchBuilder match = new MatchBuilder();
- TunnelBuilder tunnel = new TunnelBuilder(); // tunnel id match
+ final MatchBuilder match = new MatchBuilder();
+ final TunnelBuilder tunnel = new TunnelBuilder(); // tunnel id match
tunnel.setTunnelId(BigInteger.valueOf(10668));
- byte[] mask = new byte[]{(byte) -1, (byte) -1, (byte) -1, 0, 0, 0, (byte) 1, (byte) 1};
+ final byte[] mask = new byte[]{(byte) -1, (byte) -1, (byte) -1, 0, 0, 0, (byte) 1, (byte) 1};
tunnel.setTunnelMask(new BigInteger(1, mask));
match.setTunnel(tunnel.build());
*/
//FIXME: move to extensible support
private static MatchBuilder createTcpFlagMatch() {
- MatchBuilder match = new MatchBuilder();
+ final MatchBuilder match = new MatchBuilder();
// Ethertype match
- EthernetMatchBuilder ethernetType = new EthernetMatchBuilder();
- EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+ final EthernetMatchBuilder ethernetType = new EthernetMatchBuilder();
+ final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x0800L));
ethernetType.setEthernetType(ethTypeBuilder.build());
match.setEthernetMatch(ethernetType.build());
// TCP Protocol Match
- IpMatchBuilder ipMatch = new IpMatchBuilder(); // ipv4 version
+ final IpMatchBuilder ipMatch = new IpMatchBuilder(); // ipv4 version
ipMatch.setIpProtocol((short) 6);
match.setIpMatch(ipMatch.build());
// TCP Port Match
- PortNumber dstPort = new PortNumber(80);
- TcpMatchBuilder tcpMatch = new TcpMatchBuilder();
+ final PortNumber dstPort = new PortNumber(80);
+ final TcpMatchBuilder tcpMatch = new TcpMatchBuilder();
tcpMatch.setTcpDestinationPort(dstPort);
match.setLayer4Match(tcpMatch.build());
/**
* TCP_PSH 0x008 / TCP_ACK 0x010 / TCP_URG 0x020
* TCP_ECE 0x040 / TCP_CWR 0x080 / TCP_NS 0x100
*/
- TcpFlagMatchBuilder tcpFlagMatch = new TcpFlagMatchBuilder();
+ final TcpFlagMatchBuilder tcpFlagMatch = new TcpFlagMatchBuilder();
tcpFlagMatch.setTcpFlag(0x002);
match.setTcpFlagMatch(tcpFlagMatch.build());
}
public void _removeMDFlow(final CommandInterpreter ci) {
- ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
- NodeBuilder tn = createTestNode(ci.nextArgument());
- String flowtype = ci.nextArgument();
+ final ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
+ final NodeBuilder tn = createTestNode(ci.nextArgument());
+ final String flowtype = ci.nextArgument();
FlowBuilder tf;
if (flowtype.equals("fTM")) {
tf = createtablemiss();
} else {
tf = createTestFlow(tn, flowtype, ci.nextArgument());
}
- InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.getKey())
+ final InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.getKey())
.augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf.getTableId()))
.child(Flow.class, tf.getKey());
modification.delete(LogicalDatastoreType.CONFIGURATION, path1);
- CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
+ final CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
Futures.addCallback(commitFuture, new FutureCallback<Void>() {
@Override
- public void onSuccess(Void aVoid) {
+ public void onSuccess(final Void aVoid) {
ci.println("Status of Group Data Loaded Transaction: success.");
}
@Override
- public void onFailure(Throwable throwable) {
+ public void onFailure(final Throwable throwable) {
LOG.error(throwable.getMessage(), throwable);
ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
}
* e.g.: addMDFlow openflow:1 f1 42
* </pre>
*/
- public void _addMDFlow(CommandInterpreter ci) {
- NodeBuilder tn = createTestNode(ci.nextArgument());
- String flowtype = ci.nextArgument();
+ public void _addMDFlow(final CommandInterpreter ci) {
+ final NodeBuilder tn = createTestNode(ci.nextArgument());
+ final String flowtype = ci.nextArgument();
FlowBuilder tf;
if (flowtype.equals("fTM")) {
tf = createtablemiss();
writeFlow(ci, tf, tn);
}
- private void writeFlow(final CommandInterpreter ci, FlowBuilder flow, NodeBuilder nodeBuilder) {
- ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
- InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class)
+ private void writeFlow(final CommandInterpreter ci, final FlowBuilder flow, final NodeBuilder nodeBuilder) {
+ final ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
+ final InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class)
.child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class)
.child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flow.getKey());
modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
modification.merge(LogicalDatastoreType.CONFIGURATION, path1, flow.build(), true);
- CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
+ final CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
Futures.addCallback(commitFuture, new FutureCallback<Void>() {
@Override
- public void onSuccess(Void aVoid) {
+ public void onSuccess(final Void aVoid) {
ci.println("Status of Group Data Loaded Transaction: success.");
}
@Override
- public void onFailure(Throwable throwable) {
+ public void onFailure(final Throwable throwable) {
LOG.error(throwable.getMessage(), throwable);
ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
}
});
}
- public void _modifyMDFlow(CommandInterpreter ci) {
- NodeBuilder tn = createTestNode(ci.nextArgument());
- FlowBuilder tf = createTestFlow(tn, ci.nextArgument(), ci.nextArgument());
+ public void _modifyMDFlow(final CommandInterpreter ci) {
+ final NodeBuilder tn = createTestNode(ci.nextArgument());
+ final FlowBuilder tf = createTestFlow(tn, ci.nextArgument(), ci.nextArgument());
tf.setFlowName(UPDATED_FLOW_NAME);
writeFlow(ci, tf, tn);
tf.setFlowName(ORIGINAL_FLOW_NAME);
writeFlow(ci, tf, tn);
}
- private static NodeRef createNodeRef(String string) {
- NodeKey key = new NodeKey(new NodeId(string));
- InstanceIdentifier<Node> path = InstanceIdentifier.create(Nodes.class).child(Node.class, key);
+ private static NodeRef createNodeRef(final String string) {
+ final NodeKey key = new NodeKey(new NodeId(string));
+ final InstanceIdentifier<Node> path = InstanceIdentifier.create(Nodes.class).child(Node.class, key);
return new NodeRef(path);
}
* usage testSwitchFlows <numberOfSwitches> <numberOfFlows> <warmup iterations> <Number Of Threads>
* ex: _perfFlowTest 10 5 1 2
*/
- public void _perfFlowTest(CommandInterpreter ci) {
+ public void _perfFlowTest(final CommandInterpreter ci) {
- String numberOfSwtichesStr = ci.nextArgument();
- String numberOfFlowsStr = ci.nextArgument();
- String warmupIterationsStr = ci.nextArgument();
- String threadCountStr = ci.nextArgument();
- String warmUpStr = ci.nextArgument();
+ final String numberOfSwtichesStr = ci.nextArgument();
+ final String numberOfFlowsStr = ci.nextArgument();
+ final String warmupIterationsStr = ci.nextArgument();
+ final String threadCountStr = ci.nextArgument();
+ final String warmUpStr = ci.nextArgument();
Collection<String> testResults = null;
if (testResults == null) {
String dataPath = "openflow:1";
NodeBuilder tn;
FlowBuilder tf;
- String tableId = "0";
+ final String tableId = "0";
if (warmUpIterations) {
ci.println("----Warmup Started-----");
for (int j = 1; j <= warmupIterations; j++) {
ci.println("----Warmup Done-----");
}
try {
- ExecutorService executor = Executors.newFixedThreadPool(threadCount);
+ final ExecutorService executor = Executors.newFixedThreadPool(threadCount);
int tableID = 0;
for (int t = 0; t < threadCount; t++) {
tableID = t + 1;
- Runnable tRunnable = new TestFlowThread(numberOfSwtiches, numberOfFlows, ci, t, tableID);
+ final Runnable tRunnable = new TestFlowThread(numberOfSwtiches, numberOfFlows, ci, t, tableID);
executor.execute(tRunnable);
}
executor.shutdown();
executor.awaitTermination(1, TimeUnit.SECONDS);
- } catch (Exception e) {
+ } catch (final Exception e) {
ci.println("Exception:" + e.getMessage());
}
}
Collection<String> testResults = null;
int tableID = 0;
- TestFlowThread(int numberOfSwtiches, int numberOfFlows, CommandInterpreter ci, int t, int tableID) {
+ TestFlowThread(final int numberOfSwtiches, final int numberOfFlows, final CommandInterpreter ci, final int t, final int tableID) {
this.numberOfSwitches = numberOfSwtiches;
this.numberOfFlows = numberOfFlows;
this.ci = ci;
ci.println("New Thread started with id: ID_"
+ this.theadNumber);
int totalNumberOfFlows = 0;
- long startTime = System.currentTimeMillis();
+ final long startTime = System.currentTimeMillis();
for (int i = 1; i <= this.numberOfSwitches; i++) {
dataPath = "openflow:" + i;
totalNumberOfFlows++;
}
}
- long endTime = System.currentTimeMillis();
- long timeInSeconds = Math.round((endTime - startTime) / 1000);
+ final long endTime = System.currentTimeMillis();
+ final long timeInSeconds = Math.round((endTime - startTime) / 1000);
if (timeInSeconds > 0) {
ci.println("Total flows added in Thread:" + this.theadNumber + ": Flows/Sec::" + Math.round(totalNumberOfFlows / timeInSeconds));
} else {
* usage testAllFlows <dp>
* ex: _perfFlowTest 1
*/
- public void _testAllFlows(CommandInterpreter ci) {
+ public void _testAllFlows(final CommandInterpreter ci) {
String dataPathID = ci.nextArgument();
- int numberOfFlows = 82;
+ final int numberOfFlows = 82;
if (dataPathID == null || dataPathID.trim().equals("")) {
dataPathID = "1";
}
ci.println("* Test All Flows *");
ci.println("* dataPathID:::" + dataPathID + "");
- String dataPath = "openflow:" + dataPathID;
- String tableId = "0";
- NodeBuilder tn = createTestNode(dataPath);
+ final String dataPath = "openflow:" + dataPathID;
+ final String tableId = "0";
+ final NodeBuilder tn = createTestNode(dataPath);
FlowBuilder tf;
for (int flow = 1; flow < numberOfFlows; flow++) {
- String flowID = "f" + flow;
+ final String flowID = "f" + flow;
try {
tf = createTestFlow(tn, flowID, tableId);
writeFlow(ci, tf, tn);
- } catch (Exception e) {
+ } catch (final Exception e) {
ci.println("--Test Failed--Issue found while adding flow" + flow);
break;
}