<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
Flow flow, Integer sourceIp, Short tableId) {
if (add) {
LOG.trace("Adding flow for flowId: {}, flowIid: {}", flowId, flowIid);
- writeTransaction.put(LogicalDatastoreType.CONFIGURATION, flowIid, flow, isCreateParents);
+ if (isCreateParents) {
+ writeTransaction.mergeParentStructurePut(LogicalDatastoreType.CONFIGURATION, flowIid, flow);
+ } else {
+ writeTransaction.put(LogicalDatastoreType.CONFIGURATION, flowIid, flow);
+ }
} else {
LOG.trace("Deleting flow for flowId: {}, flowIid: {}", flowId, flowIid);
writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, flowIid);
*/
package org.opendaylight.openflowplugin.applications.bulk.o.matic;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
-import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ExecutionException;
try (ReadTransaction readOnlyTransaction = dataBroker.newReadOnlyTransaction()) {
Optional<Nodes> nodesDataNode = readOnlyTransaction.read(LogicalDatastoreType.OPERATIONAL, nodes).get();
if (nodesDataNode.isPresent()) {
- List<Node> nodesCollection = nodesDataNode.get().getNode();
- if (nodesCollection != null && !nodesCollection.isEmpty()) {
+ Collection<Node> nodesCollection = nodesDataNode.get().nonnullNode().values();
+ if (!nodesCollection.isEmpty()) {
for (Node node : nodesCollection) {
LOG.info("Switch with ID {} discovered !!", node.getId().getValue());
nodeIds.add(node.getId().getValue());
Flow flow) {
if (add) {
LOG.trace("Adding flow for flowId: {}, flowIid: {}", flowId, flowIid);
- writeTransaction.put(LogicalDatastoreType.CONFIGURATION, flowIid, flow, isCreateParents);
+ if (isCreateParents) {
+ writeTransaction.mergeParentStructurePut(LogicalDatastoreType.CONFIGURATION, flowIid, flow);
+ } else {
+ writeTransaction.put(LogicalDatastoreType.CONFIGURATION, flowIid, flow);
+ }
} else {
LOG.trace("Deleting flow for flowId: {}, flowIid: {}", flowId, flowIid);
writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, flowIid);
Flow flow, Integer sourceIp, Short tableId) {
if (add) {
LOG.trace("Adding flow for flowId: {}, flowIid: {}", flowId, flowIid);
- writeTransaction.put(LogicalDatastoreType.CONFIGURATION, flowIid, flow, isCreateParents);
+ if (isCreateParents) {
+ writeTransaction.mergeParentStructurePut(LogicalDatastoreType.CONFIGURATION, flowIid, flow);
+ } else {
+ writeTransaction.put(LogicalDatastoreType.CONFIGURATION, flowIid, flow);
+ }
} else {
LOG.trace("Deleting flow for flowId: {}, flowIid: {}", flowId, flowIid);
writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, flowIid);
import javax.management.MalformedObjectNameException;
import javax.management.NotCompliantMBeanException;
import javax.management.ObjectName;
-
import org.opendaylight.infrautils.utils.concurrent.LoggingFutures;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.WriteTransaction;
FlowBuilder flowBuilder = new FlowBuilder(bulkFlow);
flowBuilder.setTableId(bulkFlow.getTableId());
flowBuilder.setId(new FlowId(bulkFlow.getFlowId()));
- writeTransaction.put(LogicalDatastoreType.CONFIGURATION, getFlowInstanceIdentifier(bulkFlow),
- flowBuilder.build(), createParents);
+ if (createParents) {
+ writeTransaction.mergeParentStructurePut(LogicalDatastoreType.CONFIGURATION,
+ getFlowInstanceIdentifier(bulkFlow),
+ flowBuilder.build());
+ } else {
+ writeTransaction.put(LogicalDatastoreType.CONFIGURATION, getFlowInstanceIdentifier(bulkFlow),
+ flowBuilder.build());
+ }
createParents = createParentsNextTime;
}
FluentFuture<?> submitFuture = writeTransaction.commit();
InstanceIdentifier<Table> tableIId = BulkOMaticUtils.getTableId(tableId, dpId);
if (isAdd) {
- wtx.put(LogicalDatastoreType.CONFIGURATION, tableIId, table, true);
+ wtx.mergeParentStructurePut(LogicalDatastoreType.CONFIGURATION, tableIId, table);
} else {
wtx.delete(LogicalDatastoreType.CONFIGURATION, tableIId);
}
@Test
public void testAddFlows() {
flowWriterConcurrent.addFlows(1, FLOWS_PER_DPN, 10, 10, 10, (short) 0, (short) 1, true);
- Mockito.verify(writeTransaction, Mockito.times(FLOWS_PER_DPN)).put(ArgumentMatchers.any(),
- ArgumentMatchers.any(), ArgumentMatchers.any(),
- ArgumentMatchers.anyBoolean());
+ Mockito.verify(writeTransaction, Mockito.times(FLOWS_PER_DPN)).mergeParentStructurePut(ArgumentMatchers.any(),
+ ArgumentMatchers.any(), ArgumentMatchers.any());
}
@Test
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.when;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ExecutorService;
import org.junit.Before;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
import org.opendaylight.yangtools.util.concurrent.FluentFutures;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.slf4j.Logger;
NodeBuilder nodeBuilder = new NodeBuilder()
.setId(new NodeId("1"));
- final List<Node> nodes = new ArrayList<>();
+ final Map<NodeKey, Node> nodes = new HashMap<>();
final Node node = nodeBuilder.build();
- nodes.add(node);
+ nodes.put(node.key(), node);
- when(mockNodes.getNode()).thenReturn(nodes);
+ when(mockNodes.nonnullNode()).thenReturn(nodes);
doReturn(FluentFutures.immediateFluentFuture(Optional.of(mockNodes))).when(readOnlyTransaction)
.read(any(LogicalDatastoreType.class), any());
@Test
public void testAddFlows() {
flowWriterSequential.addFlows(1, FLOWS_PER_DPN, 10, 10, (short) 0, (short) 1, true);
- Mockito.verify(writeTransaction, Mockito.times(FLOWS_PER_DPN)).put(ArgumentMatchers.any(),
- ArgumentMatchers.any(), ArgumentMatchers.any(),
- ArgumentMatchers.anyBoolean());
+ Mockito.verify(writeTransaction, Mockito.times(FLOWS_PER_DPN)).mergeParentStructurePut(ArgumentMatchers.any(),
+ ArgumentMatchers.any(), ArgumentMatchers.any());
}
@Test
@Test
public void testAddFlows() {
flowWriterTxChain.addFlows(1, FLOWS_PER_DPN, 10, 10, 10, (short) 0, (short) 1, true);
- Mockito.verify(writeTransaction, Mockito.times(FLOWS_PER_DPN)).put(ArgumentMatchers.any(),
- ArgumentMatchers.any(), ArgumentMatchers.any(),
- ArgumentMatchers.anyBoolean());
+ Mockito.verify(writeTransaction, Mockito.times(FLOWS_PER_DPN)).mergeParentStructurePut(ArgumentMatchers.any(),
+ ArgumentMatchers.any(), ArgumentMatchers.any());
}
@Test
salBulkFlowService.addFlowsDs(addFlowsDsInput);
verify(writeTransaction).commit();
- verify(writeTransaction).put(ArgumentMatchers.any(), ArgumentMatchers.any(),
- flowArgumentCaptor.capture(), Mockito.anyBoolean());
+ verify(writeTransaction).mergeParentStructurePut(ArgumentMatchers.any(), ArgumentMatchers.any(),
+ flowArgumentCaptor.capture());
Flow flow = flowArgumentCaptor.getValue();
Assert.assertEquals("1", flow.getId().getValue());
public void testAddTables() {
tableWriter.addTables(DPN_COUNT, START_TABLE_ID, END_TABLE_ID);
Mockito.verify(writeTransaction, Mockito.times(TABLES_PER_DPN))
- .put(ArgumentMatchers.any(),
- ArgumentMatchers.any(), ArgumentMatchers.any(),
- ArgumentMatchers.anyBoolean());
+ .mergeParentStructurePut(ArgumentMatchers.any(),
+ ArgumentMatchers.any(), ArgumentMatchers.any());
}
@Test
<artifactId>blueprint-maven-plugin-annotation</artifactId>
<optional>true</optional>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-binding-runtime-spi</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-binding-generator-impl</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
private void persistStaleFlow(StaleFlow staleFlow, InstanceIdentifier<FlowCapableNode> nodeIdent) {
WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
writeTransaction.put(LogicalDatastoreType.CONFIGURATION, getStaleFlowInstanceIdentifier(staleFlow, nodeIdent),
- staleFlow, false);
+ staleFlow);
FluentFuture<?> submitFuture = writeTransaction.commit();
handleStaleFlowResultFuture(submitFuture);
}, service);
/* Bundles not supported for meters */
- List<Meter> meters = flowNode.get().getMeter() != null ? flowNode.get().getMeter()
- : Collections.emptyList();
+ Collection<Meter> meters = flowNode.get().nonnullMeter().values();
Futures.transformAsync(commitBundleFuture,
rpcResult -> {
if (rpcResult.isSuccessful()) {
//put the dpn info into the map
reconciliationStates.put(dpnId.toString(), reconciliationState);
LOG.debug("Triggering reconciliation for node {} with state: {}", dpnId, STARTED);
- List<TableFeatures> tableList = flowNode.get().getTableFeatures() != null
- ? flowNode.get().getTableFeatures()
- : Collections.<TableFeatures>emptyList();
+ Collection<TableFeatures> tableList = flowNode.get().nonnullTableFeatures().values();
for (TableFeatures tableFeaturesItem : tableList) {
TableFeaturesKey tableKey = tableFeaturesItem.key();
KeyedInstanceIdentifier<TableFeatures, TableFeaturesKey> tableFeaturesII = nodeIdentity
}
/* Groups - have to be first */
- List<Group> groups = flowNode.get().getGroup() != null ? flowNode.get().getGroup()
- : Collections.<Group>emptyList();
+ Collection<Group> groups = flowNode.get().nonnullGroup().values();
List<Group> toBeInstalledGroups = new ArrayList<>();
toBeInstalledGroups.addAll(groups);
// new list for suspected groups pointing to ports .. when the ports come up
Group group = iterator.next();
boolean okToInstall = true;
Buckets buckets = group.getBuckets();
- List<Bucket> bucketList = buckets == null ? null : buckets.getBucket();
+ Collection<Bucket> bucketList = buckets == null ? null : buckets.nonnullBucket().values();
if (bucketList == null) {
bucketList = Collections.<Bucket>emptyList();
}
for (Bucket bucket : bucketList) {
- List<Action> actions = bucket.getAction();
+ Collection<Action> actions = bucket.nonnullAction().values();
if (actions == null) {
actions = Collections.<Action>emptyList();
}
}
}
/* Meters */
- List<Meter> meters = flowNode.get().getMeter() != null ? flowNode.get().getMeter()
- : Collections.<Meter>emptyList();
+ Collection<Meter> meters = flowNode.get().nonnullMeter().values();
for (Meter meter : meters) {
final KeyedInstanceIdentifier<Meter, MeterKey> meterIdent = nodeIdentity.child(Meter.class,
meter.key());
awaitGroups(node, groupFutures.values());
/* Flows */
- List<Table> tables = flowNode.get().getTable() != null ? flowNode.get().getTable()
+ Collection<Table> tables = flowNode.get().getTable() != null ? flowNode.get().nonnullTable().values()
: Collections.<Table>emptyList();
int flowCount = 0;
for (Table table : tables) {
final KeyedInstanceIdentifier<Table, TableKey> tableIdent = nodeIdentity.child(Table.class,
table.key());
- List<Flow> flows = table.getFlow() != null ? table.getFlow() : Collections.<Flow>emptyList();
+ Collection<Flow> flows = table.nonnullFlow().values();
flowCount += flows.size();
for (Flow flow : flows) {
final KeyedInstanceIdentifier<Flow, FlowKey> flowIdent = tableIdent.child(Flow.class,
LOG.debug("Proceeding with deletion of stale-marked Flows on switch {} using Openflow interface",
nodeIdent);
/* Stale-Flows - Stale-marked Flows have to be removed first for safety */
- List<Table> tables = flowNode.get().getTable() != null ? flowNode.get().getTable()
- : Collections.<Table>emptyList();
+ Collection<Table> tables = flowNode.get().nonnullTable().values();
for (Table table : tables) {
final KeyedInstanceIdentifier<Table, TableKey> tableIdent = nodeIdent.child(Table.class,
table.key());
- List<StaleFlow> staleFlows = table.getStaleFlow() != null ? table.getStaleFlow()
- : Collections.<StaleFlow>emptyList();
+ Collection<StaleFlow> staleFlows = table.nonnullStaleFlow().values();
for (StaleFlow staleFlow : staleFlows) {
FlowBuilder flowBuilder = new FlowBuilder(staleFlow);
// before attempting to delete groups - just in case there are references
/* Stale-marked Groups - Can be deleted after flows */
- List<StaleGroup> staleGroups = flowNode.get().getStaleGroup() != null ? flowNode.get().getStaleGroup()
- : Collections.<StaleGroup>emptyList();
+ Collection<StaleGroup> staleGroups = flowNode.get().nonnullStaleGroup().values();
for (StaleGroup staleGroup : staleGroups) {
GroupBuilder groupBuilder = new GroupBuilder(staleGroup);
LOG.debug("Proceeding with deletion of stale-marked Meters for switch {} using Openflow interface",
nodeIdent);
/* Stale-marked Meters - can be deleted anytime - so least priority */
- List<StaleMeter> staleMeters = flowNode.get().getStaleMeter() != null ? flowNode.get().getStaleMeter()
- : Collections.<StaleMeter>emptyList();
+ Collection<StaleMeter> staleMeters = flowNode.get().getStaleMeter().values();
for (StaleMeter staleMeter : staleMeters) {
final BundleId bundleIdValue,
final InstanceIdentifier<FlowCapableNode> nodeIdentity) {
List<ListenableFuture<RpcResult<AddBundleMessagesOutput>>> futureList = new ArrayList<>();
- for (Group group : flowNode.nonnullGroup()) {
+ for (Group group : flowNode.nonnullGroup().values()) {
final KeyedInstanceIdentifier<Group, GroupKey> groupIdent = nodeIdentity.child(Group.class, group.key());
futureList.add(provider.getBundleGroupListener().add(groupIdent, group, nodeIdentity, bundleIdValue));
}
- for (Table table : flowNode.nonnullTable()) {
+ for (Table table : flowNode.nonnullTable().values()) {
final KeyedInstanceIdentifier<Table, TableKey> tableIdent = nodeIdentity.child(Table.class, table.key());
- for (Flow flow : table.nonnullFlow()) {
+ for (Flow flow : table.nonnullFlow().values()) {
final KeyedInstanceIdentifier<Flow, FlowKey> flowIdent = tableIdent.child(Flow.class, flow.key());
futureList.add(provider.getBundleFlowListener().add(flowIdent, flow, nodeIdentity, bundleIdValue));
}
private void persistStaleGroup(StaleGroup staleGroup, InstanceIdentifier<FlowCapableNode> nodeIdent) {
WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
writeTransaction.put(LogicalDatastoreType.CONFIGURATION, getStaleGroupInstanceIdentifier(staleGroup, nodeIdent),
- staleGroup, false);
+ staleGroup);
FluentFuture<?> submitFuture = writeTransaction.commit();
handleStaleGroupResultFuture(submitFuture);
private void persistStaleMeter(StaleMeter staleMeter, InstanceIdentifier<FlowCapableNode> nodeIdent) {
WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
writeTransaction.put(LogicalDatastoreType.CONFIGURATION, getStaleMeterInstanceIdentifier(staleMeter, nodeIdent),
- staleMeter, false);
+ staleMeter);
FluentFuture<?> submitFuture = writeTransaction.commit();
handleStaleMeterResultFuture(submitFuture);
package org.opendaylight.openflowplugin.applications.frm.util;
import java.math.BigInteger;
+import java.util.Collection;
import java.util.Collections;
-import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
public static Uint32 isFlowDependentOnGroup(final Flow flow) {
LOG.debug("Check if flow {} is dependent on group", flow);
if (flow.getInstructions() != null) {
- List<Instruction> instructions = flow.getInstructions().getInstruction();
+ Collection<Instruction> instructions = flow.getInstructions().nonnullInstruction().values();
for (Instruction instruction : instructions) {
- List<Action> actions = Collections.emptyList();
+ Collection<Action> actions = Collections.emptyList();
if (instruction.getInstruction().implementedInterface()
.equals(ActionType.APPLY_ACTION.getActionType())) {
actions = ((ApplyActionsCase) instruction.getInstruction())
- .getApplyActions().getAction();
+ .getApplyActions().nonnullAction().values();
} else if (instruction.getInstruction().implementedInterface()
.equals(ActionType.WRITE_ACTION.getActionType())) {
actions = ((WriteActionsCase)instruction.getInstruction())
- .getWriteActions().getAction();
+ .getWriteActions().nonnullAction().values();
}
for (Action action : actions) {
if (action.getAction().implementedInterface()
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
-import java.util.List;
+import java.util.Map;
import java.util.Optional;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.binding.api.DataObjectModification;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
if (node == null) {
return true;
}
- final List<NodeConnector> nodeConnectors = node.getNodeConnector();
+ final Map<NodeConnectorKey, NodeConnector> nodeConnectors = node.getNodeConnector();
return nodeConnectors == null || nodeConnectors.isEmpty();
}
import com.google.common.util.concurrent.MoreExecutors;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@VisibleForTesting
private static List<ItemSyncBox<Group>> extractGroupsToAddOrUpdate(final NodeId nodeId,
final FlowCapableNode flowCapableNodeConfigured, final FlowCapableNode flowCapableNodeOperational) {
- final List<Group> groupsConfigured = ReconcileUtil.safeGroups(flowCapableNodeConfigured);
- final List<Group> groupsOperational = ReconcileUtil.safeGroups(flowCapableNodeOperational);
+ final Collection<Group> groupsConfigured = ReconcileUtil.safeGroups(flowCapableNodeConfigured);
+ final Collection<Group> groupsOperational = ReconcileUtil.safeGroups(flowCapableNodeOperational);
final Map<Uint32, Group> groupOperationalMap = FlowCapableNodeLookups.wrapGroupsToMap(groupsOperational);
final List<Group> pendingGroups = new ArrayList<>();
private static ItemSyncBox<Meter> extractMetersToAddOrUpdate(final NodeId nodeId,
final FlowCapableNode flowCapableNodeConfigured,
final FlowCapableNode flowCapableNodeOperational) {
- final List<Meter> metersConfigured = ReconcileUtil.safeMeters(flowCapableNodeConfigured);
- final List<Meter> metersOperational = ReconcileUtil.safeMeters(flowCapableNodeOperational);
+ final Collection<Meter> metersConfigured = ReconcileUtil.safeMeters(flowCapableNodeConfigured);
+ final Collection<Meter> metersOperational = ReconcileUtil.safeMeters(flowCapableNodeOperational);
final Map<MeterId, Meter> meterOperationalMap = FlowCapableNodeLookups.wrapMetersToMap(metersOperational);
return ReconcileUtil.resolveMeterDiffs(nodeId, meterOperationalMap, metersConfigured, true);
@VisibleForTesting
private static Map<TableKey, ItemSyncBox<Flow>> extractFlowsToAddOrUpdate(final NodeId nodeId,
final FlowCapableNode flowCapableNodeConfigured, final FlowCapableNode flowCapableNodeOperational) {
- final List<Table> tablesConfigured = ReconcileUtil.safeTables(flowCapableNodeConfigured);
+ final Collection<Table> tablesConfigured = ReconcileUtil.safeTables(flowCapableNodeConfigured);
if (tablesConfigured.isEmpty()) {
return Collections.emptyMap();
}
- final List<Table> tablesOperational = ReconcileUtil.safeTables(flowCapableNodeOperational);
+ final Collection<Table> tablesOperational = ReconcileUtil.safeTables(flowCapableNodeOperational);
final Map<Uint8, Table> tableOperationalMap = FlowCapableNodeLookups.wrapTablesToMap(tablesOperational);
return ReconcileUtil.resolveFlowDiffsInAllTables(nodeId, tableOperationalMap, tablesConfigured, true);
@VisibleForTesting
private static Map<TableKey, ItemSyncBox<Flow>> extractFlowsToRemove(final NodeId nodeId,
final FlowCapableNode flowCapableNodeConfigured, final FlowCapableNode flowCapableNodeOperational) {
- final List<Table> tablesOperational = ReconcileUtil.safeTables(flowCapableNodeOperational);
+ final Collection<Table> tablesOperational = ReconcileUtil.safeTables(flowCapableNodeOperational);
if (tablesOperational.isEmpty()) {
return Collections.emptyMap();
}
- final List<Table> tablesConfigured = ReconcileUtil.safeTables(flowCapableNodeConfigured);
+ final Collection<Table> tablesConfigured = ReconcileUtil.safeTables(flowCapableNodeConfigured);
final Map<Uint8, Table> tableConfiguredMap = FlowCapableNodeLookups.wrapTablesToMap(tablesConfigured);
return ReconcileUtil.resolveFlowDiffsInAllTables(nodeId, tableConfiguredMap, tablesOperational, false);
private static ItemSyncBox<Meter> extractMetersToRemove(final NodeId nodeId,
final FlowCapableNode flowCapableNodeConfigured,
final FlowCapableNode flowCapableNodeOperational) {
- final List<Meter> metersConfigured = ReconcileUtil.safeMeters(flowCapableNodeConfigured);
- final List<Meter> metersOperational = ReconcileUtil.safeMeters(flowCapableNodeOperational);
+ final Collection<Meter> metersConfigured = ReconcileUtil.safeMeters(flowCapableNodeConfigured);
+ final Collection<Meter> metersOperational = ReconcileUtil.safeMeters(flowCapableNodeOperational);
final Map<MeterId, Meter> meterConfiguredMap = FlowCapableNodeLookups.wrapMetersToMap(metersConfigured);
return ReconcileUtil.resolveMeterDiffs(nodeId, meterConfiguredMap, metersOperational, false);
private static List<ItemSyncBox<Group>> extractGroupsToRemove(final NodeId nodeId,
final FlowCapableNode flowCapableNodeConfigured,
final FlowCapableNode flowCapableNodeOperational) {
- final List<Group> groupsConfigured = ReconcileUtil.safeGroups(flowCapableNodeConfigured);
- final List<Group> groupsOperational = ReconcileUtil.safeGroups(flowCapableNodeOperational);
+ final Collection<Group> groupsConfigured = ReconcileUtil.safeGroups(flowCapableNodeConfigured);
+ final Collection<Group> groupsOperational = ReconcileUtil.safeGroups(flowCapableNodeOperational);
final Map<Uint32, Group> groupConfiguredMap = FlowCapableNodeLookups.wrapGroupsToMap(groupsConfigured);
final List<Group> pendingGroups = new ArrayList<>();
import com.google.common.util.concurrent.MoreExecutors;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
if (!result.isSuccessful() && result.getResult() != null
&& !result.getResult().getBatchFailure().isEmpty()) {
Map<Range<Uint16>, Batch> batchMap = mapBatchesToRanges(inputBatchBag, failureIndexLimit);
- decrementBatchFailuresCounters(result.getResult().getBatchFailure(), batchMap, counters);
+ decrementBatchFailuresCounters(result.getResult().nonnullBatchFailure().values(), batchMap,
+ counters);
}
}
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
justification = "https://github.com/spotbugs/spotbugs/issues/811")
- private static void decrementBatchFailuresCounters(final List<BatchFailure> batchFailures,
+ private static void decrementBatchFailuresCounters(final Collection<BatchFailure> batchFailures,
final Map<Range<Uint16>, Batch> batchMap,
final SyncCrudCounters counters) {
for (BatchFailure batchFailure : batchFailures) {
*/
package org.opendaylight.openflowplugin.applications.frsync.util;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
}
@NonNull
- public static Map<Uint8, Table> wrapTablesToMap(@Nullable final List<Table> tables) {
+ public static Map<Uint8, Table> wrapTablesToMap(@Nullable final Collection<Table> tables) {
final Map<Uint8, Table> tableMap;
if (tables == null) {
}
@NonNull
- public static Map<FlowDescriptor, Flow> wrapFlowsToMap(@Nullable final List<Flow> flows) {
+ public static Map<FlowDescriptor, Flow> wrapFlowsToMap(@Nullable final Collection<Flow> flows) {
final Map<FlowDescriptor, Flow> flowMap;
if (flows == null) {
}
@NonNull
- public static Map<MeterId, Meter> wrapMetersToMap(@Nullable final List<Meter> meters) {
+ public static Map<MeterId, Meter> wrapMetersToMap(@Nullable final Collection<Meter> meters) {
final Map<MeterId, Meter> meterMap;
if (meters == null) {
}
@NonNull
- public static Map<Uint32, Group> wrapGroupsToMap(@Nullable final List<Group> groups) {
+ public static Map<Uint32, Group> wrapGroupsToMap(@Nullable final Collection<Group> groups) {
final Map<Uint32, Group> groupMap;
if (groups == null) {
public static boolean checkGroupPrecondition(final Set<Uint32> installedGroupIds, final Group pendingGroup) {
boolean okToInstall = true;
// check each bucket in the pending group
- for (Bucket bucket : pendingGroup.getBuckets().getBucket()) {
- for (Action action : bucket.getAction()) {
+ for (Bucket bucket : pendingGroup.getBuckets().nonnullBucket().values()) {
+ for (Action action : bucket.nonnullAction().values()) {
// if the output action is a group
if (GroupActionCase.class.equals(action.getAction().implementedInterface())) {
Uint32 groupId = ((GroupActionCase) action.getAction()).getGroupAction().getGroupId();
*/
public static ItemSyncBox<Meter> resolveMeterDiffs(final NodeId nodeId,
final Map<MeterId, Meter> meterOperationalMap,
- final List<Meter> metersConfigured,
+ final Collection<Meter> metersConfigured,
final boolean gatherUpdates) {
LOG.trace("resolving meters for {}", nodeId.getValue());
final ItemSyncBox<Meter> syncBox = new ItemSyncBox<>();
* @param gatherUpdates check content of pending item if present on device (and create update task eventually)
* @return list of safe synchronization steps
*/
- private static ItemSyncBox<Flow> resolveFlowDiffsInTable(final List<Flow> flowsConfigured,
+ private static ItemSyncBox<Flow> resolveFlowDiffsInTable(final Collection<Flow> flowsConfigured,
final Map<FlowDescriptor, Flow> flowOperationalMap,
final boolean gatherUpdates) {
final ItemSyncBox<Flow> flowsSyncBox = new ItemSyncBox<>();
* @return map : key={@link TableKey}, value={@link ItemSyncBox} of safe synchronization steps
*/
public static Map<TableKey, ItemSyncBox<Flow>> resolveFlowDiffsInAllTables(final NodeId nodeId,
- final Map<Uint8, Table> tableOperationalMap, final List<Table> tablesConfigured,
+ final Map<Uint8, Table> tableOperationalMap, final Collection<Table> tablesConfigured,
final boolean gatherUpdates) {
LOG.trace("resolving flows in tables for {}", nodeId.getValue());
final Map<TableKey, ItemSyncBox<Flow>> tableFlowSyncBoxes = new HashMap<>();
for (final Table tableConfigured : tablesConfigured) {
- final List<Flow> flowsConfigured = tableConfigured.getFlow();
- if (flowsConfigured == null || flowsConfigured.isEmpty()) {
+ final Collection<Flow> flowsConfigured = tableConfigured.nonnullFlow().values();
+ if (flowsConfigured.isEmpty()) {
continue;
}
// wrap existing (on device) flows in current table into map
final Map<FlowDescriptor, Flow> flowOperationalMap = FlowCapableNodeLookups.wrapFlowsToMap(
tableOperational != null
- ? tableOperational.getFlow()
+ ? tableOperational.nonnullFlow().values()
: null);
return tableFlowSyncBoxes;
}
- public static List<Group> safeGroups(FlowCapableNode node) {
- return node == null ? Collections.emptyList() : node.nonnullGroup();
+ public static Collection<Group> safeGroups(FlowCapableNode node) {
+ return node == null ? Collections.emptyList() : node.nonnullGroup().values();
}
- public static List<Table> safeTables(FlowCapableNode node) {
- return node == null ? Collections.emptyList() : node.nonnullTable();
+ public static Collection<Table> safeTables(FlowCapableNode node) {
+ return node == null ? Collections.emptyList() : node.nonnullTable().values();
}
- public static List<Meter> safeMeters(FlowCapableNode node) {
- return node == null ? Collections.emptyList() : node.nonnullMeter();
+ public static Collection<Meter> safeMeters(FlowCapableNode node) {
+ return node == null ? Collections.emptyList() : node.nonnullMeter().values();
}
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder;
public static Group createGroupWithPreconditions(final long groupIdValue, final long... requiredId) {
final List<Action> actionBag = new ArrayList<>();
+ int key = 0;
for (long groupIdPrecondition : requiredId) {
final GroupAction groupAction = new GroupActionBuilder()
.setGroupId(groupIdPrecondition)
.build();
final Action action = new ActionBuilder()
.setAction(groupActionCase)
+ .withKey(new ActionKey(key++))
.build();
actionBag.add(action);
}
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Collections;
-import java.util.List;
+import java.util.Map;
import java.util.Optional;
import org.junit.Assert;
import org.junit.Before;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.snapshot.gathering.status.grouping.SnapshotGatheringStatusEnd;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
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.util.concurrent.FluentFutures;
@Mock
private DeviceMastershipManager deviceMastershipManager;
@Mock
- private List nodeConnector;
+ private Map<NodeConnectorKey, NodeConnector> nodeConnector;
@Mock
private Node operationalNodeEmpty;
Assert.assertEquals(nodePath, updateTableInput.getNode().getValue());
Assert.assertEquals(1, updateTableInput.getOriginalTable().getTableFeatures().size());
- Assert.assertEquals("test-table", updateTableInput.getOriginalTable().getTableFeatures().get(0).getName());
+ Assert.assertEquals("test-table", updateTableInput.getOriginalTable().nonnullTableFeatures().values()
+ .iterator().next().getName());
Assert.assertEquals(1, updateTableInput.getUpdatedTable().getTableFeatures().size());
- Assert.assertEquals("another-table", updateTableInput.getUpdatedTable().getTableFeatures().get(0).getName());
+ Assert.assertEquals("another-table", updateTableInput.getUpdatedTable().nonnullTableFeatures().values()
+ .iterator().next().getName());
}
}
\ No newline at end of file
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
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.flow.transaction.rev150304.SendBarrierOutput;
private static Group createGroupWithPreconditions(final long groupIdValue, final long... requiredId) {
final List<Action> actionBag = new ArrayList<>();
+ int key = 0;
for (long groupIdPrecondition : requiredId) {
final GroupAction groupAction = new GroupActionBuilder()
.setGroupId(groupIdPrecondition)
.build();
final Action action = new ActionBuilder()
.setAction(groupActionCase)
+ .withKey(new ActionKey(key++))
.build();
actionBag.add(action);
}
.createNotification(createTestConnectorStat(), createTestConnectorStatPath());
assertNotNull(notification);
assertEquals(FLOW_NODE_ID, notification.getId().getValue());
- assertEquals(FLOW_CODE_CONNECTOR_ID, notification.getNodeConnector().get(0).getId().getValue());
+ assertEquals(FLOW_CODE_CONNECTOR_ID, notification.nonnullNodeConnector().values().iterator().next().getId()
+ .getValue());
}
@Test
.createNotification(createTestQueueStat(), createTestQueueStatPath());
assertNotNull(notification);
assertEquals(FLOW_NODE_ID, notification.getId().getValue());
- assertEquals(FLOW_CODE_CONNECTOR_ID, notification.getNodeConnector().get(0).getId().getValue());
+ assertEquals(FLOW_CODE_CONNECTOR_ID, notification.nonnullNodeConnector().values().iterator().next().getId()
+ .getValue());
}
@Test
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
}
}
try {
- tx.merge(LogicalDatastoreType.OPERATIONAL, instanceIdentifier, counterBuilder.build(), true);
+ tx.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, instanceIdentifier,
+ counterBuilder.build());
tx.commit().get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Exception while submitting counter for {}", nodeId, e);
package org.opendaylight.openflowplugin.applications.southboundcli.cli;
+import java.util.Collection;
import java.util.Formatter;
-import java.util.List;
import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.shell.console.OsgiCommandSupport;
import org.opendaylight.mdsal.binding.api.DataBroker;
@SuppressWarnings("checkstyle:RegexpSinglelineJava")
@Override
protected Object doExecute() {
- List<ReconcileCounter> result = ShellUtil.getReconcileCount(dataBroker);
+ Collection<ReconcileCounter> result = ShellUtil.getReconcileCount(dataBroker);
if (result.isEmpty()) {
System.out.println("Reconciliation count not yet available for openflow nodes.");
} else {
package org.opendaylight.openflowplugin.applications.southboundcli.util;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Optional<Node> result = tx.read(LogicalDatastoreType.OPERATIONAL, path).get();
if (result.isPresent()) {
Node node = result.get();
- String name = null;
- List<NodeConnector> nodeConnectors = null;
+ String name;
+ Collection<NodeConnector> nodeConnectors = node.nonnullNodeConnector().values();
List<String> portList = new ArrayList<>();
FlowCapableNode flowCapableNode = node.<FlowCapableNode>augmentation(FlowCapableNode.class);
if (flowCapableNode != null) {
LOG.error("Error while converting OFNode:{} to FlowCapableNode", node.getId());
return null;
}
- nodeConnectors = node.getNodeConnector();
for (NodeConnector nodeConnector : nodeConnectors) {
FlowCapableNodeConnector flowCapableNodeConnector =
nodeConnector.augmentation(FlowCapableNodeConnector.class);
return ofNode;
}
- public static List<ReconcileCounter> getReconcileCount(final DataBroker dataBroker) {
+ public static Collection<ReconcileCounter> getReconcileCount(final DataBroker dataBroker) {
InstanceIdentifier<ReconciliationCounter> instanceIdentifier = InstanceIdentifier
.builder(ReconciliationCounter.class).build();
- List<ReconcileCounter> output = Collections.emptyList();
+ Collection<ReconcileCounter> output = Collections.emptyList();
try (ReadTransaction tx = dataBroker.newReadOnlyTransaction()) {
Optional<ReconciliationCounter> result =
tx.read(LogicalDatastoreType.OPERATIONAL, instanceIdentifier).get();
if (result.isPresent()) {
- output = result.get().getReconcileCounter();
+ output = result.get().nonnullReconcileCounter().values();
}
} catch (ExecutionException | InterruptedException | NullPointerException e) {
LOG.error("Error reading reconciliation counter from datastore", e);
}
private static void evaluateInstruction(final Instruction instruction) {
- if (instruction.getInstruction() instanceof ApplyActionsCase) {
+ if (instruction != null && instruction.getInstruction() instanceof ApplyActionsCase) {
ApplyActionsCase applyActionsCase = (ApplyActionsCase) instruction.getInstruction();
assertNotNull(applyActionsCase.getApplyActions().getAction());
assertEquals(1, applyActionsCase.getApplyActions().getAction().size());
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Optional;
-import org.apache.commons.lang3.ArrayUtils;
import org.opendaylight.mdsal.eos.binding.api.Entity;
import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService;
import org.opendaylight.mdsal.eos.common.api.EntityOwnershipState;
boolean secAuthenticatorOk = false;
if (hashLldptlv != null) {
byte[] rawTlvValue = hashLldptlv.getValue();
- byte[] lldpCustomSecurityHash = ArrayUtils.subarray(rawTlvValue, 4, rawTlvValue.length);
+ byte[] lldpCustomSecurityHash = Arrays.copyOfRange(rawTlvValue, 4, rawTlvValue.length);
byte[] calculatedHash = getValueForLLDPPacketIntegrityEnsuring(srcNodeConnectorId);
secAuthenticatorOk = Arrays.equals(calculatedHash, lldpCustomSecurityHash);
} else {
return;
}
- for (Link link : topologyOptional.get().nonnullLink()) {
+ for (Link link : topologyOptional.get().nonnullLink().values()) {
if (id.equals(link.getSource().getSourceNode()) || id.equals(link.getDestination().getDestNode())) {
manager.addDeleteOperationToTxChain(LogicalDatastoreType.OPERATIONAL, linkPath(link, topology));
}
return;
}
- for (Link link : topologyOptional.get().nonnullLink()) {
+ for (Link link : topologyOptional.get().nonnullLink().values()) {
if (id.equals(link.getSource().getSourceTp()) || id.equals(link.getDestination().getDestTp())) {
manager.addDeleteOperationToTxChain(LogicalDatastoreType.OPERATIONAL, linkPath(link, topology));
}
waitForSubmit(submitLatch);
ArgumentCaptor<Link> mergedNode = ArgumentCaptor.forClass(Link.class);
- verify(mockTx).merge(eq(LogicalDatastoreType.OPERATIONAL), eq(topologyIID.child(
+ verify(mockTx).mergeParentStructureMerge(eq(LogicalDatastoreType.OPERATIONAL), eq(topologyIID.child(
Link.class, new LinkKey(new LinkId(sourceNodeConnKey.getId())))),
- mergedNode.capture(), eq(true));
+ mergedNode.capture());
assertEquals("Source node ID", "sourceNode",
mergedNode.getValue().getSource().getSourceNode().getValue());
assertEquals("Dest TP ID", "sourceTP",
List<Link> linkList = Arrays.asList(
newLink("link1", newSourceNode("node1"), newDestNode("dest")),
newLink("link2", newSourceNode("source"), newDestNode("node1")),
- newLink("link2", newSourceNode("source2"), newDestNode("dest2")));
+ newLink("link3", newSourceNode("source2"), newDestNode("dest2")));
final Topology topology = new TopologyBuilder().setLink(linkList).build();
final InstanceIdentifier[] expDeletedIIDs = {
ArgumentCaptor<Node> mergedNode = ArgumentCaptor.forClass(Node.class);
NodeId expNodeId = new NodeId("node1");
- verify(mockTx).merge(eq(LogicalDatastoreType.OPERATIONAL), eq(topologyIID.child(Node.class,
- new NodeKey(expNodeId))), mergedNode.capture(), eq(true));
+ verify(mockTx).mergeParentStructureMerge(eq(LogicalDatastoreType.OPERATIONAL), eq(topologyIID.child(Node.class,
+ new NodeKey(expNodeId))), mergedNode.capture());
assertEquals("getNodeId", expNodeId, mergedNode.getValue().getNodeId());
InventoryNode augmentation = mergedNode.getValue().augmentation(InventoryNode.class);
assertNotNull("Missing augmentation", augmentation);
InstanceIdentifier<TerminationPoint> expTpPath = topologyIID.child(
Node.class, new NodeKey(expNodeId)).child(TerminationPoint.class,
new TerminationPointKey(expTpId));
- verify(mockTx).merge(eq(LogicalDatastoreType.OPERATIONAL), eq(expTpPath),
- mergedNode.capture(), eq(true));
+ verify(mockTx).mergeParentStructureMerge(eq(LogicalDatastoreType.OPERATIONAL), eq(expTpPath),
+ mergedNode.capture());
assertEquals("getTpId", expTpId, mergedNode.getValue().getTpId());
InventoryNodeConnector augmentation = mergedNode.getValue().augmentation(
InventoryNodeConnector.class);
Node.class, new NodeKey(new NodeId("node1"))).child(TerminationPoint.class,
new TerminationPointKey(new TpId("tp1")));
- verify(mockTx).merge(eq(LogicalDatastoreType.OPERATIONAL), eq(expTpPath),
- any(TerminationPoint.class), eq(true));
+ verify(mockTx).mergeParentStructureMerge(eq(LogicalDatastoreType.OPERATIONAL), eq(expTpPath),
+ any(TerminationPoint.class));
assertDeletedIDs(new InstanceIdentifier[]{topologyIID.child(Link.class,
linkList.get(0).key())}, deletedLinkIDs);
Node.class, new NodeKey(new NodeId("node1"))).child(TerminationPoint.class,
new TerminationPointKey(new TpId("tp1")));
- verify(mockTx).merge(eq(LogicalDatastoreType.OPERATIONAL), eq(expTpPath),
- any(TerminationPoint.class), eq(true));
+ verify(mockTx).mergeParentStructureMerge(eq(LogicalDatastoreType.OPERATIONAL), eq(expTpPath),
+ any(TerminationPoint.class));
assertDeletedIDs(new InstanceIdentifier[]{topologyIID.child(Link.class,
linkList.get(0).key())}, deletedLinkIDs);
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.LinkBuilder;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.LinkKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
}
static Link newLink(String id, Source source, Destination dest) {
- return new LinkBuilder().setLinkId(new LinkId(id)).setSource(source).setDestination(dest).build();
+ return new LinkBuilder().setLinkId(new LinkId(id)).setSource(source).setDestination(dest)
+ .withKey(new LinkKey(new LinkId(id))).build();
}
static Destination newDestTp(String id) {
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>karaf4-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
</parent>
<groupId>org.opendaylight.openflowplugin</groupId>
<artifactId>openflowplugin-karaf</artifactId>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>feature-repo-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<modelVersion>4.0.0</modelVersion>
mb2.addAugmentation(GeneralAugMatchNotifPacketIn.class, odlxxx2).build();
Assert.assertEquals(JoachimTheBig.class,
- eqGroup.getExtension(match1).get().getExtensionList().get(0).getExtensionKey());
+ eqGroup.getExtension(match1).get().nonnullExtensionList().values().iterator().next().getExtensionKey());
Assert.assertEquals(JoachimTheTiny.class,
- eqGroup.getExtension(match2).get().getExtensionList().get(0).getExtensionKey());
+ eqGroup.getExtension(match2).get().nonnullExtensionList().values().iterator().next().getExtensionKey());
}
private interface JoachimTheBig extends ExtensionKey {
Match match2 = mb2.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, odlxxx2).build();
Assert.assertEquals(JoachimTheBig.class,
- eqGroup.getExtension(match1).get().getExtensionList().get(0).getExtensionKey());
+ eqGroup.getExtension(match1).get().nonnullExtensionList().values().iterator().next().getExtensionKey());
Assert.assertEquals(JoachimTheTiny.class,
- eqGroup.getExtension(match2).get().getExtensionList().get(0).getExtensionKey());
+ eqGroup.getExtension(match2).get().nonnullExtensionList().values().iterator().next().getExtensionKey());
}
private interface JoachimTheBig extends ExtensionKey {
odlxxx2).build();
Assert.assertEquals(ZVendorExt1.class,
- eqGroup.getExtension(setField1).get().getExtensionList().get(0).getExtensionKey());
+ eqGroup.getExtension(setField1).get().nonnullExtensionList().values().iterator().next()
+ .getExtensionKey());
Assert.assertEquals(ZVendorExt2.class,
- eqGroup.getExtension(setField2).get().getExtensionList().get(0).getExtensionKey());
+ eqGroup.getExtension(setField2).get().nonnullExtensionList().values().iterator().next()
+ .getExtensionKey());
}
private interface ZVendorExt1 extends ExtensionKey {
SetField setField = sb.addAugmentation(GeneralAugMatchNodesNodeTableFlowWriteActionsSetField.class,
ndOptionsTypeSetField).build();
- Assert.assertEquals(Icmpv6NdOptionsTypeKey.class, eqGroup.getExtension(setField).get().getExtensionList().get(0)
- .getExtensionKey());
+ Assert.assertEquals(Icmpv6NdOptionsTypeKey.class, eqGroup.getExtension(setField).get().nonnullExtensionList()
+ .values().iterator().next().getExtensionKey());
}
}
\ No newline at end of file
SetField setField = sb.addAugmentation(GeneralAugMatchNodesNodeTableFlowWriteActionsSetField.class,
ndReservedSetField).build();
- Assert.assertEquals(Icmpv6NdReservedKey.class, eqGroup.getExtension(setField).get().getExtensionList().get(0)
- .getExtensionKey());
+ Assert.assertEquals(Icmpv6NdReservedKey.class, eqGroup.getExtension(setField).get().nonnullExtensionList()
+ .values().iterator().next().getExtensionKey());
}
}
\ No newline at end of file
package org.opendaylight.openflowplugin.extension.onf.converter;
+import java.util.Collection;
import java.util.List;
import java.util.Optional;
import org.opendaylight.openflowplugin.extension.api.ConverterMessageToOFJava;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroupBuilder;
Optional<PortModInput> portModInput = Optional.empty();
final Class<?> clazz = messageCase.implementedInterface();
if (clazz.equals(BundleUpdatePortCase.class)) {
- portModInput = CONVERTER_EXECUTOR.convert(new PortBuilder(
- ((BundleUpdatePortCase) messageCase).getUpdatePortCaseData().getPort().getPort().get(0)).build(),
- data);
+ Collection<Port> ports
+ = ((BundleUpdatePortCase) messageCase).getUpdatePortCaseData().getPort().nonnullPort().values();
+ Port port = ports.iterator().next();
+ portModInput = CONVERTER_EXECUTOR.convert(port, data);
}
if (portModInput.isPresent()) {
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.PortBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
.setAdvertisedFeatures(Mockito.mock(PortFeatures.class))
.setPortNumber(new PortNumberUni(Uint32.ZERO))
.setHardwareAddress(Mockito.mock(MacAddress.class))
+ .withKey(new PortKey(Uint32.ZERO))
.build()))
.build()).build())
.build(), BundlePortModCase.class);
convertedProperty.getBundlePropertyExperimenterData());
} else {
Assert.assertTrue("Properties not empty",
- converted.getOnfAddMessageGroupingData().getBundleProperty().isEmpty());
+ converted.getOnfAddMessageGroupingData().nonnullBundleProperty().isEmpty());
}
}
Assert.assertTrue("Properties not empty",
ofjMessage
.getOnfControlGroupingData()
- .getBundleProperty()
+ .nonnullBundleProperty()
.isEmpty());
}
}
Assert.assertEquals("Wrong type",
BundleControlType.ONFBCTOPENREPLY, builtByFactory.getOnfControlGroupingData().getType());
Assert.assertTrue("Properties not empty",
- builtByFactory.getOnfControlGroupingData().getBundleProperty().isEmpty());
+ builtByFactory.getOnfControlGroupingData().nonnullBundleProperty().isEmpty());
}
@Test
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>feature-repo-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-openflowplugin-libraries">
<feature name="odl-openflowplugin-libraries">
- <feature version="[6,7)">odl-guava</feature>
+ <feature version="[7,8)">odl-guava</feature>
</feature>
</features>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-artifacts</artifactId>
- <version>5.0.9</version>
+ <version>6.0.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<!-- Controller infrastructure -->
<dependency>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>1.11.0</version>
+ <artifactId>controller-artifacts</artifactId>
+ <version>2.0.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<!-- Controller infrastructure -->
<dependency>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>1.11.0</version>
+ <artifactId>controller-artifacts</artifactId>
+ <version>2.0.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<artifactId>guava</artifactId>
</dependency>
<dependency>
- <groupId>javax.xml.bind</groupId>
- <artifactId>jaxb-api</artifactId>
+ <groupId>jakarta.xml.bind</groupId>
+ <artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
</dependencies>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>feature-repo-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-artifacts</artifactId>
- <version>5.0.9</version>
+ <version>6.0.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
grouping instructions-grouping {
list instruction {
config false;
- key "experimenter-id";
+ ordered-by user;
uses instruction-grouping;
leaf experimenter-id {
type oft:experimenter-id;
+ "00 00 00 00" // padding
);
HelloMessage builtByFactory = BufferHelper.deserialize(factory, bb);
- Assert.assertEquals("Wrong - no element has been expected", 0, builtByFactory.getElements().size());
+ Assert.assertEquals("Wrong - no element has been expected", 0, builtByFactory.nonnullElements().size());
}
- private static List<Elements> createElement(int lengthInByte, int type) {
+ private static List<Elements> createElement(final int lengthInByte, final int type) {
final ElementsBuilder elementsBuilder = new ElementsBuilder();
final List<Elements> elementsList = new ArrayList<>();
List<Boolean> booleanList = new ArrayList<>();
builtByFactory.getCapabilitiesV10());
Assert.assertEquals("Wrong actions", new ActionTypeV10(false, false, false, false, false, false, false,
false, false, false, false, false, false), builtByFactory.getActionsV10());
- Assert.assertEquals("Wrong ports size", 0, builtByFactory.getPhyPort().size());
+ Assert.assertEquals("Wrong ports size", 0, builtByFactory.nonnullPhyPort().size());
}
}
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody();
MultipartReplyFlow message = messageCase.getMultipartReplyFlow();
- Assert.assertEquals("Wrong flow stats size", 0, message.getFlowStats().size());
+ Assert.assertEquals("Wrong flow stats size", 0, message.nonnullFlowStats().size());
}
/**
Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyPortDescCase messageCase = (MultipartReplyPortDescCase) builtByFactory.getMultipartReplyBody();
MultipartReplyPortDesc message = messageCase.getMultipartReplyPortDesc();
- Assert.assertEquals("Wrong table features size", 0, message.getPorts().size());
+ Assert.assertEquals("Wrong table features size", 0, message.nonnullPorts().size());
}
/**
MultipartReplyTableFeaturesCase messageCase =
(MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody();
MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures();
- Assert.assertEquals("Wrong table features size", 0, message.getTableFeatures().size());
+ Assert.assertEquals("Wrong table features size", 0, message.nonnullTableFeatures().size());
}
/**
throw new TransactionChainClosedException(CANNOT_WRITE_INTO_TRANSACTION);
}
- writeTx.put(store, path, data, createParents);
+ if (createParents) {
+ writeTx.mergeParentStructurePut(store, path, data);
+ } else {
+ writeTx.put(store, path, data);
+ }
}
}
throw new TransactionChainClosedException(CANNOT_WRITE_INTO_TRANSACTION);
}
- writeTx.merge(store, path, data, createParents);
+ if (createParents) {
+ writeTx.mergeParentStructureMerge(store, path, data);
+ } else {
+ writeTx.merge(store, path, data);
+ }
}
}
@Override
public void storeStatistics(final FlowAndStatisticsMapList statistics, final boolean withParents) {
- statistics.getFlowAndStatisticsMapList()
+ statistics.nonnullFlowAndStatisticsMapList().values()
.forEach(stat -> {
final FlowBuilder flow = new FlowBuilder(stat)
.addAugmentation(
@Override
public void storeStatistics(final GroupDescStatsReply statistics, final boolean withParents) {
- statistics.getGroupDescStats()
+ statistics.nonnullGroupDescStats().values()
.forEach(stat -> {
writeToTransaction(
getInstanceIdentifier()
@Override
public void storeStatistics(final GroupStatisticsReply statistics, final boolean withParents) {
- statistics.getGroupStats()
+ statistics.nonnullGroupStats().values()
.forEach(stat -> {
writeToTransaction(
getInstanceIdentifier()
@Override
public void storeStatistics(final MeterConfigStatsReply statistics, final boolean withParents) {
- statistics.getMeterConfigStats()
+ statistics.nonnullMeterConfigStats().values()
.forEach(stat -> {
writeToTransaction(
getInstanceIdentifier()
@Override
public void storeStatistics(final MeterStatisticsReply statistics, final boolean withParents) {
- statistics.getMeterStats()
+ statistics.nonnullMeterStats().values()
.forEach(stat -> writeToTransaction(
getInstanceIdentifier()
.augmentation(FlowCapableNode.class)
@Override
public void storeStatistics(final NodeConnectorStatisticsAndPortNumberMap statistics, final boolean withParents) {
- statistics.getNodeConnectorStatisticsAndPortNumberMap()
+ statistics.nonnullNodeConnectorStatisticsAndPortNumberMap().values()
.forEach(stat -> {
final OpenflowVersion openflowVersion = OpenflowVersion.get(features.getVersion());
final Uint32 port = InventoryDataServiceUtil.portNumberfromNodeConnectorId(openflowVersion,
public void storeStatistics(final QueueIdAndStatisticsMap statistics, final boolean withParents) {
final OpenflowVersion openflowVersion = OpenflowVersion.get(features.getVersion());
- statistics.getQueueIdAndStatisticsMap()
+ statistics.nonnullQueueIdAndStatisticsMap().values()
.forEach((stat) -> {
final Uint32 port = InventoryDataServiceUtil
.portNumberfromNodeConnectorId(openflowVersion, stat.getNodeConnectorId());
@Override
public void storeStatistics(final TableFeatures statistics, final boolean withParents) {
- statistics.getTableFeatures()
+ statistics.nonnullTableFeatures().values()
.forEach(stat -> {
writeToTransaction(getInstanceIdentifier()
.augmentation(FlowCapableNode.class)
@Override
public void storeStatistics(final FlowTableAndStatisticsMap statistics,
final boolean withParents) {
- statistics.getFlowTableAndStatisticsMap()
+ statistics.nonnullFlowTableAndStatisticsMap().values()
.forEach(stat -> writeToTransaction(
getInstanceIdentifier()
.augmentation(FlowCapableNode.class)
if (result != null) {
for (Optional<FlowCapableNode> optNode : result) {
if (optNode.isPresent()) {
- flowCount += optNode.get().nonnullTable().stream()
+ flowCount += optNode.get().nonnullTable().values().stream()
.filter(Objects::nonNull)
- .flatMap(table -> table.nonnullFlow().stream())
+ .flatMap(table -> table.nonnullFlow().values().stream())
.filter(Objects::nonNull)
.count();
}
}
@Override
- public void onNotAbleToStartMastership(@NonNull final DeviceInfo deviceInfo, @NonNull final String reason,
- final boolean mandatory) {
+ public void onNotAbleToStartMastership(final DeviceInfo deviceInfo, final String reason, final boolean mandatory) {
LOG.warn("Not able to set MASTER role on device {}, reason: {}", deviceInfo, reason);
if (!mandatory) {
}
@Override
- public void onMasterRoleAcquired(@NonNull final DeviceInfo deviceInfo,
- @NonNull final ContextChainMastershipState mastershipState) {
+ public void onMasterRoleAcquired(final DeviceInfo deviceInfo, final ContextChainMastershipState mastershipState) {
Optional.ofNullable(contextChainMap.get(deviceInfo)).ifPresent(contextChain -> {
if (!ContextChainMastershipState.INITIAL_SUBMIT.equals(mastershipState)) {
if (contextChain.isMastered(mastershipState, true)) {
import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdDeserializerKey;
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.BandId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterFlags;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.MeterBandHeadersBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.meter.band.header.MeterBandTypesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterModCommand;
import org.slf4j.Logger;
.setMeterId(new MeterId(message.readUnsignedInt()));
final List<MeterBandHeader> bands = new ArrayList<>();
+ long key = 0;
while (message.readableBytes() > 0) {
final MeterBandHeaderBuilder bandBuilder = new MeterBandHeaderBuilder();
// no operation
}
- bands.add(bandBuilder.build());
+ bands.add(bandBuilder.withKey(new MeterBandHeaderKey(new BandId(key++))).build());
}
return builder
import org.opendaylight.openflowplugin.impl.util.MatchUtil;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.multipart.reply.multipart.reply.body.MultipartReplyFlowStatsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
public MultipartReplyBody deserialize(ByteBuf message) {
final MultipartReplyFlowStatsBuilder builder = new MultipartReplyFlowStatsBuilder();
final List<FlowAndStatisticsMapList> items = new ArrayList<>();
+ int key = 0;
while (message.readableBytes() > 0) {
final FlowAndStatisticsMapListBuilder itemBuilder = new FlowAndStatisticsMapListBuilder();
.build());
}
+ itemBuilder.withKey(new FlowAndStatisticsMapListKey(new FlowId(String.valueOf(key++))));
items.add(itemBuilder.build());
}
* @param startIndex start index of byte buffer
*/
protected void writeActions(ActionList actions, short version, ByteBuf outBuffer, int startIndex) {
- Optional.ofNullable(actions).flatMap(as -> Optional.ofNullable(as.getAction())).map(as -> {
+ Optional.ofNullable(actions).flatMap(as -> Optional.ofNullable(as.nonnullAction())).map(as -> {
final int lengthIndex = outBuffer.writerIndex();
outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH);
outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
- as.stream().sorted(OrderComparator.build()).forEach(a -> ActionUtil
+ as.values().stream().sorted(OrderComparator.build()).forEach(a -> ActionUtil
.writeAction(a.getAction(), version, registry, outBuffer));
outBuffer.setShort(lengthIndex, outBuffer.writerIndex() - startIndex);
return actions;
package org.opendaylight.openflowplugin.impl.protocol.serialization.match;
import io.netty.buffer.ByteBuf;
+import java.util.Collection;
import java.util.LinkedHashMap;
-import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer;
private SerializerRegistry registry;
@Override
- public void serialize(Match match, ByteBuf outBuffer) {
+ public void serialize(final Match match, final ByteBuf outBuffer) {
// Save start index in buffer
final int matchStartIndex = outBuffer.writerIndex();
}
@Override
- public void serializeHeader(Match match, ByteBuf outBuffer) {
+ public void serializeHeader(final Match match, final ByteBuf outBuffer) {
if (match == null) {
LOG.debug("Match is null, skipping serialization of match entries");
return;
ExtensionResolvers
.getMatchExtensionResolver()
.getExtension(match)
- .flatMap(extensions -> Optional.ofNullable(extensions.getExtensionList()))
- .ifPresent(extensionList -> serializeExtensionList(extensionList, outBuffer));
+ .flatMap(extensions -> Optional.ofNullable(extensions.nonnullExtensionList()))
+ .ifPresent(extensionList -> serializeExtensionList(extensionList.values(), outBuffer));
}
- private void serializeExtensionList(final List<ExtensionList> extensionList, final ByteBuf outBuffer) {
+ private void serializeExtensionList(final Collection<ExtensionList> extensionList, final ByteBuf outBuffer) {
// TODO: Remove also extension converters
extensionList.forEach(extension -> {
final ConverterExtensionKey<? extends ExtensionKey> converterExtensionKey =
}
@Override
- public void injectSerializerRegistry(SerializerRegistry serializerRegistry) {
+ public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) {
registry = serializerRegistry;
}
@Override
- public void registerEntrySerializer(org.opendaylight.openflowplugin.api.openflow.protocol.serialization
- .MatchEntrySerializerKey key, MatchEntrySerializer serializer) {
+ public void registerEntrySerializer(
+ final org.opendaylight.openflowplugin.api.openflow.protocol.serialization.MatchEntrySerializerKey key,
+ final MatchEntrySerializer serializer) {
if (key == null || serializer == null) {
throw new IllegalArgumentException("MatchEntrySerializerKey or Serializer is null");
}
}
@Override
- public boolean unregisterEntrySerializer(org.opendaylight.openflowplugin.api.openflow.protocol.serialization
- .MatchEntrySerializerKey key) {
+ public boolean unregisterEntrySerializer(
+ final org.opendaylight.openflowplugin.api.openflow.protocol.serialization.MatchEntrySerializerKey key) {
return entryRegistry.remove(key) != null;
}
}
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcActionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowMessage;
* @param message OpenFlow flow mod message
* @param outBuffer output buffer
*/
- @SuppressWarnings("unchecked")
private void writeInstructions(final FlowMessage message, final ByteBuf outBuffer) {
// Try to get IP protocol from IP match
final Optional<Uint8> protocol = Optional
// Update instructions if needed and then serialize all instructions
Optional.ofNullable(message.getInstructions())
- .flatMap(is -> Optional.ofNullable(is.getInstruction()))
- .ifPresent(is -> is.stream()
+ .flatMap(is -> Optional.ofNullable(is.nonnullInstruction()))
+ .ifPresent(is -> is.values().stream()
.filter(Objects::nonNull)
.sorted(OrderComparator.build())
.map(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types
if (instruction instanceof ApplyActionsCase) {
return Optional
.ofNullable(((ApplyActionsCase) instruction).getApplyActions())
- .flatMap(aa -> Optional.ofNullable(aa.getAction()))
+ .flatMap(aa -> Optional.ofNullable(aa.nonnullAction()))
.map(as -> new ApplyActionsCaseBuilder()
.setApplyActions(new ApplyActionsBuilder()
.setAction(as
+ .values()
.stream()
.filter(Objects::nonNull)
.map(a -> updateSetTpActions(a, protocol))
*/
private static List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list
.Instruction> updateSetVlanIdAction(final FlowMessage message) {
- return message.getInstructions().getInstruction()
+ return message.getInstructions().nonnullInstruction().values()
.stream()
.map(i -> {
final int[] offset = {0};
return i.getInstruction() instanceof ApplyActionsCase
? Optional
.ofNullable(((ApplyActionsCase) i.getInstruction()).getApplyActions())
- .flatMap(as -> Optional.ofNullable(as.getAction()))
- .map(a -> a.stream()
+ .flatMap(as -> Optional.ofNullable(as.nonnullAction()))
+ .map(a -> a.values().stream()
.sorted(OrderComparator.build())
.flatMap(action -> {
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112
// Update offset of action if there is any inserted PushVlan actions
actions.add(offset[0] > 0
? new ActionBuilder(action).setOrder(action.getOrder() + offset[0])
+ .withKey(new ActionKey(action.getOrder() + offset[0]))
.build()
: action);
private static boolean isSetVlanIdActionCasePresent(final Flow flow) {
return Optional
.ofNullable(flow.getInstructions())
- .flatMap(is -> Optional.ofNullable(is.getInstruction()))
- .flatMap(is -> is.stream()
+ .flatMap(is -> Optional.ofNullable(is.nonnullInstruction()))
+ .flatMap(is -> is.values().stream()
.map(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types
.rev131026.Instruction::getInstruction)
.filter(ApplyActionsCase.class::isInstance)
.map(i -> ((ApplyActionsCase) i).getApplyActions())
.filter(Objects::nonNull)
- .map(ActionList::getAction)
+ .map(ActionList::nonnullAction)
.filter(Objects::nonNull)
- .flatMap(Collection::stream)
+ .flatMap(map -> map.values().stream())
.map(Action::getAction)
.filter(SetVlanIdActionCase.class::isInstance)
.findFirst())
Optional.ofNullable(message.getBuckets())
.filter(b -> !GroupModCommand.OFPGCDELETE.equals(message.getCommand()))
- .flatMap(b -> Optional.ofNullable(b.getBucket()))
- .ifPresent(b -> b.stream()
+ .flatMap(b -> Optional.ofNullable(b.nonnullBucket()))
+ .ifPresent(b -> b.values().stream()
.sorted(COMPARATOR)
.forEach(bucket -> {
final int bucketIndex = outBuffer.writerIndex();
.intValue());
outBuffer.writeZero(PADDING_IN_BUCKET);
- Optional.ofNullable(bucket.getAction()).ifPresent(as -> as
+ Optional.ofNullable(bucket.nonnullAction()).ifPresent(as -> as.values()
.stream()
.sorted(OrderComparator.build())
.forEach(a -> ActionUtil.writeAction(
private void serializeBands(final MeterBandHeaders meterBandHeaders, final ByteBuf outBuffer) {
if (meterBandHeaders != null && meterBandHeaders.getMeterBandHeader() != null) {
- meterBandHeaders.getMeterBandHeader().forEach(meterBandHeader ->
+ meterBandHeaders.nonnullMeterBandHeader().values().forEach(meterBandHeader ->
Optional.ofNullable(meterBandHeader.getMeterBandTypes())
.flatMap(m -> Optional.ofNullable(m.getFlags()))
.ifPresent(flags -> Optional.ofNullable(meterBandHeader.getBandType()).ifPresent(type -> {
@Override
public void serialize(final MultipartRequestTableFeatures multipartRequestTableFeatures, final ByteBuf byteBuf) {
Optional
- .ofNullable(multipartRequestTableFeatures.getTableFeatures())
- .ifPresent(tableFeatures -> tableFeatures
+ .ofNullable(multipartRequestTableFeatures.nonnullTableFeatures())
+ .ifPresent(tableFeatures -> tableFeatures.values()
.stream()
.filter(Objects::nonNull)
.forEach(tableFeature -> {
private void serializeProperties(final TableProperties tableProperties, final ByteBuf byteBuf) {
Optional
.ofNullable(tableProperties)
- .flatMap(properties -> Optional.ofNullable(properties.getTableFeatureProperties()))
- .ifPresent(properties -> properties
+ .flatMap(properties -> Optional.ofNullable(properties.nonnullTableFeatureProperties()))
+ .ifPresent(properties -> properties.values()
.stream()
.filter(Objects::nonNull)
.forEach(property -> {
protected void serializeProperty(final ApplyActionsMiss property, final ByteBuf byteBuf) {
property
.getApplyActionsMiss()
- .getAction()
+ .nonnullAction().values()
.stream()
.sorted(OrderComparator.build())
.map(Action::getAction)
protected void serializeProperty(final ApplyActions property, final ByteBuf byteBuf) {
property
.getApplyActions()
- .getAction()
+ .nonnullAction()
+ .values()
.stream()
.sorted(OrderComparator.build())
.map(Action::getAction)
protected void serializeProperty(final ApplySetfieldMiss property, final ByteBuf byteBuf) {
property
.getApplySetfieldMiss()
- .getSetFieldMatch()
+ .nonnullSetFieldMatch().values()
.forEach(setFieldMatch -> Preconditions.checkNotNull(registry)
.<MatchField, OFSerializer<SetFieldMatch>>getSerializer(
new MessageTypeKey<>(
protected void serializeProperty(final ApplySetfield property, final ByteBuf byteBuf) {
property
.getApplySetfield()
- .getSetFieldMatch()
+ .nonnullSetFieldMatch().values()
.forEach(setFieldMatch -> Preconditions.checkNotNull(registry)
.<MatchField, OFSerializer<SetFieldMatch>>getSerializer(
new MessageTypeKey<>(
protected void serializeProperty(final InstructionsMiss property, final ByteBuf byteBuf) {
property
.getInstructionsMiss()
- .getInstruction()
- .stream()
+ .nonnullInstruction()
+ .values().stream()
.sorted(OrderComparator.build())
.map(Instruction::getInstruction)
.forEach(instruction -> InstructionUtil
protected void serializeProperty(final Instructions property, final ByteBuf byteBuf) {
property
.getInstructions()
- .getInstruction()
+ .nonnullInstruction().values()
.stream()
.sorted(OrderComparator.build())
.map(Instruction::getInstruction)
protected void serializeProperty(final Match property, final ByteBuf byteBuf) {
property
.getMatchSetfield()
- .getSetFieldMatch()
+ .nonnullSetFieldMatch().values()
.forEach(setFieldMatch -> Preconditions.checkNotNull(registry)
.<MatchField, OFSerializer<SetFieldMatch>>getSerializer(
new MessageTypeKey<>(
protected void serializeProperty(final Wildcards property, final ByteBuf byteBuf) {
property
.getWildcardSetfield()
- .getSetFieldMatch()
+ .nonnullSetFieldMatch().values()
.forEach(setFieldMatch -> Preconditions.checkNotNull(registry)
.<MatchField, OFSerializer<SetFieldMatch>>getSerializer(
new MessageTypeKey<>(
protected void serializeProperty(final WriteActionsMiss property, final ByteBuf byteBuf) {
property
.getWriteActionsMiss()
- .getAction()
+ .nonnullAction().values()
.stream()
.sorted(OrderComparator.build())
.map(Action::getAction)
protected void serializeProperty(final WriteActions property, final ByteBuf byteBuf) {
property
.getWriteActions()
- .getAction()
+ .nonnullAction()
+ .values()
.stream()
.sorted(OrderComparator.build())
.map(Action::getAction)
protected void serializeProperty(final WriteSetfieldMiss property, final ByteBuf byteBuf) {
property
.getWriteSetfieldMiss()
- .getSetFieldMatch()
+ .nonnullSetFieldMatch().values()
.forEach(setFieldMatch -> Preconditions.checkNotNull(registry)
.<MatchField, OFSerializer<SetFieldMatch>>getSerializer(
new MessageTypeKey<>(
protected void serializeProperty(final WriteSetfield property, final ByteBuf byteBuf) {
property
.getWriteSetfield()
- .getSetFieldMatch()
+ .nonnullSetFieldMatch().values()
.forEach(setFieldMatch -> Preconditions.checkNotNull(registry)
.<MatchField, OFSerializer<SetFieldMatch>>getSerializer(
new MessageTypeKey<>(
@Override
public void onSuccess(final Optional<FlowCapableNode> result) {
result.ifPresent(flowCapableNode -> {
- flowCapableNode.nonnullTable().stream()
+ flowCapableNode.nonnullTable().values().stream()
.filter(Objects::nonNull)
- .flatMap(table -> table.nonnullFlow().stream())
+ .flatMap(table -> table.nonnullFlow().values().stream())
.filter(Objects::nonNull)
.filter(flow -> flow.getId() != null)
.forEach(flowConsumer);
if (!Objects.equals(match.getVlanMatch(), input.getVlanMatch())) {
return false;
}
- for (ExtensionList inputExtensionList : inputAug.getExtensionList()) {
- if (!thisAug.getExtensionList().contains(inputExtensionList)) {
+ for (ExtensionList inputExtensionList : inputAug.nonnullExtensionList().values()) {
+ if (!thisAug.nonnullExtensionList().containsValue(inputExtensionList)) {
return false;
}
}
private final RequestContext<T> context;
private final Class<?> requestType;
private final MessageSpy spy;
- private EventIdentifier eventIdentifier;
+ private final EventIdentifier eventIdentifier;
AbstractRequestCallback(final RequestContext<T> context,
final Class<?> requestType,
}
@Override
- public final void onFailure(@NonNull final Throwable throwable) {
+ public final void onFailure(final Throwable throwable) {
final RpcResultBuilder<T> builder;
if (null != eventIdentifier) {
EventsTimeCounter.markEnd(eventIdentifier);
final RpcResult<T> input, final int stepOffset) {
final List<BatchFailure> batchFailures = new ArrayList<>();
if (input.getResult().getBatchFailedFlowsOutput() != null) {
- for (BatchFailedFlowsOutput stepOutput : input.getResult().getBatchFailedFlowsOutput()) {
+ for (BatchFailedFlowsOutput stepOutput : input.getResult().nonnullBatchFailedFlowsOutput().values()) {
final BatchFailure batchFailure = new BatchFailureBuilder()
.setBatchOrder(stepOffset + stepOutput.getBatchOrder().toJava())
.setBatchItemIdChoice(new FlatBatchFailureFlowIdCaseBuilder()
final RpcResult<T> input, final int stepOffset) {
final List<BatchFailure> batchFailures = new ArrayList<>();
if (input.getResult().getBatchFailedGroupsOutput() != null) {
- for (BatchFailedGroupsOutput stepOutput : input.getResult().getBatchFailedGroupsOutput()) {
+ for (BatchFailedGroupsOutput stepOutput : input.getResult().nonnullBatchFailedGroupsOutput().values()) {
final BatchFailure batchFailure = new BatchFailureBuilder()
.setBatchOrder(stepOffset + stepOutput.getBatchOrder().toJava())
.setBatchItemIdChoice(new FlatBatchFailureGroupIdCaseBuilder()
final RpcResult<T> input, final int stepOffset) {
final List<BatchFailure> batchFailures = new ArrayList<>();
if (input.getResult().getBatchFailedMetersOutput() != null) {
- for (BatchFailedMetersOutput stepOutput : input.getResult().getBatchFailedMetersOutput()) {
+ for (BatchFailedMetersOutput stepOutput : input.getResult().nonnullBatchFailedMetersOutput().values()) {
final BatchFailure batchFailure = new BatchFailureBuilder()
.setBatchOrder(stepOffset + stepOutput.getBatchOrder().toJava())
.setBatchItemIdChoice(new FlatBatchFailureMeterIdCaseBuilder()
PathUtil.extractNodeId(input.getNode()).getValue(),
input.getBatch().size());
// create plan
- final List<BatchPlanStep> batchPlan = FlatBatchUtil.assembleBatchPlan(input.getBatch());
+ final List<BatchPlanStep> batchPlan = FlatBatchUtil.assembleBatchPlan(input.nonnullBatch().values());
// add barriers where needed
FlatBatchUtil.markBarriersWhereNeeded(batchPlan);
// prepare chain elements
PathUtil.extractNodeId(input.getNode()),
input.getBatchRemoveFlows().size());
final ArrayList<ListenableFuture<RpcResult<RemoveFlowOutput>>> resultsLot = new ArrayList<>();
- for (BatchFlowInputGrouping batchFlow : input.getBatchRemoveFlows()) {
+ for (BatchFlowInputGrouping batchFlow : input.nonnullBatchRemoveFlows().values()) {
final RemoveFlowInput removeFlowInput = new RemoveFlowInputBuilder(batchFlow)
.setFlowRef(createFlowRef(input.getNode(), batchFlow))
.setNode(input.getNode())
final ListenableFuture<RpcResult<List<BatchFailedFlowsOutput>>> commonResult =
Futures.transform(Futures.successfulAsList(resultsLot),
- FlowUtil.createCumulatingFunction(input.getBatchRemoveFlows()),
+ FlowUtil.createCumulatingFunction(input.nonnullBatchRemoveFlows().values()),
MoreExecutors.directExecutor());
ListenableFuture<RpcResult<RemoveFlowsBatchOutput>> removeFlowsBulkFuture =
public ListenableFuture<RpcResult<AddFlowsBatchOutput>> addFlowsBatch(final AddFlowsBatchInput input) {
LOG.trace("Adding flows @ {} : {}", PathUtil.extractNodeId(input.getNode()), input.getBatchAddFlows().size());
final ArrayList<ListenableFuture<RpcResult<AddFlowOutput>>> resultsLot = new ArrayList<>();
- for (BatchFlowInputGrouping batchFlow : input.getBatchAddFlows()) {
+ for (BatchFlowInputGrouping batchFlow : input.nonnullBatchAddFlows().values()) {
final AddFlowInput addFlowInput = new AddFlowInputBuilder(batchFlow)
.setFlowRef(createFlowRef(input.getNode(), batchFlow))
.setNode(input.getNode())
final ListenableFuture<RpcResult<List<BatchFailedFlowsOutput>>> commonResult =
Futures.transform(Futures.successfulAsList(resultsLot),
- FlowUtil.createCumulatingFunction(input.getBatchAddFlows()),
+ FlowUtil.createCumulatingFunction(input.nonnullBatchAddFlows().values()),
MoreExecutors.directExecutor());
ListenableFuture<RpcResult<AddFlowsBatchOutput>> addFlowsBulkFuture =
PathUtil.extractNodeId(input.getNode()),
input.getBatchUpdateFlows().size());
final ArrayList<ListenableFuture<RpcResult<UpdateFlowOutput>>> resultsLot = new ArrayList<>();
- for (BatchUpdateFlows batchFlow : input.getBatchUpdateFlows()) {
+ for (BatchUpdateFlows batchFlow : input.nonnullBatchUpdateFlows().values()) {
final UpdateFlowInput updateFlowInput = new UpdateFlowInputBuilder(input)
.setOriginalFlow(new OriginalFlowBuilder(batchFlow.getOriginalBatchedFlow()).build())
.setUpdatedFlow(new UpdatedFlowBuilder(batchFlow.getUpdatedBatchedFlow()).build())
final ListenableFuture<RpcResult<List<BatchFailedFlowsOutput>>> commonResult =
Futures.transform(Futures.successfulAsList(resultsLot),
- FlowUtil.createCumulatingFunction(input.getBatchUpdateFlows()),
+ FlowUtil.createCumulatingFunction(input.nonnullBatchUpdateFlows().values()),
MoreExecutors.directExecutor());
ListenableFuture<RpcResult<UpdateFlowsBatchOutput>> updateFlowsBulkFuture =
public ListenableFuture<RpcResult<AddGroupsBatchOutput>> addGroupsBatch(final AddGroupsBatchInput input) {
LOG.trace("Adding groups @ {} : {}", PathUtil.extractNodeId(input.getNode()), input.getBatchAddGroups().size());
final ArrayList<ListenableFuture<RpcResult<AddGroupOutput>>> resultsLot = new ArrayList<>();
- for (BatchAddGroups addGroup : input.getBatchAddGroups()) {
+ for (BatchAddGroups addGroup : input.nonnullBatchAddGroups().values()) {
final AddGroupInput addGroupInput = new AddGroupInputBuilder(addGroup)
.setGroupRef(createGroupRef(input.getNode(), addGroup)).setNode(input.getNode()).build();
resultsLot.add(salGroupService.addGroup(addGroupInput));
final ListenableFuture<RpcResult<List<BatchFailedGroupsOutput>>> commonResult = Futures
.transform(Futures.allAsList(resultsLot),
- GroupUtil.createCumulatingFunction(input.getBatchAddGroups()),
+ GroupUtil.createCumulatingFunction(input.nonnullBatchAddGroups().values()),
MoreExecutors.directExecutor());
ListenableFuture<RpcResult<AddGroupsBatchOutput>> addGroupsBulkFuture = Futures
LOG.trace("Removing groups @ {} : {}", PathUtil.extractNodeId(input.getNode()),
input.getBatchRemoveGroups().size());
final ArrayList<ListenableFuture<RpcResult<RemoveGroupOutput>>> resultsLot = new ArrayList<>();
- for (BatchRemoveGroups addGroup : input.getBatchRemoveGroups()) {
+ for (BatchRemoveGroups addGroup : input.nonnullBatchRemoveGroups().values()) {
final RemoveGroupInput removeGroupInput = new RemoveGroupInputBuilder(addGroup)
.setGroupRef(createGroupRef(input.getNode(), addGroup)).setNode(input.getNode()).build();
resultsLot.add(salGroupService.removeGroup(removeGroupInput));
final ListenableFuture<RpcResult<List<BatchFailedGroupsOutput>>> commonResult = Futures
.transform(Futures.allAsList(resultsLot),
- GroupUtil.createCumulatingFunction(input.getBatchRemoveGroups()),
+ GroupUtil.createCumulatingFunction(input.nonnullBatchRemoveGroups().values()),
MoreExecutors.directExecutor());
ListenableFuture<RpcResult<RemoveGroupsBatchOutput>> removeGroupsBulkFuture = Futures
public ListenableFuture<RpcResult<AddMetersBatchOutput>> addMetersBatch(final AddMetersBatchInput input) {
LOG.trace("Adding meters @ {} : {}", PathUtil.extractNodeId(input.getNode()), input.getBatchAddMeters().size());
final ArrayList<ListenableFuture<RpcResult<AddMeterOutput>>> resultsLot = new ArrayList<>();
- for (BatchAddMeters addMeter : input.getBatchAddMeters()) {
+ for (BatchAddMeters addMeter : input.nonnullBatchAddMeters().values()) {
final AddMeterInput addMeterInput = new AddMeterInputBuilder(addMeter)
.setMeterRef(createMeterRef(input.getNode(), addMeter))
.setNode(input.getNode())
final ListenableFuture<RpcResult<List<BatchFailedMetersOutput>>> commonResult =
Futures.transform(Futures.allAsList(resultsLot),
- MeterUtil.createCumulativeFunction(input.getBatchAddMeters()),
+ MeterUtil.createCumulativeFunction(input.nonnullBatchAddMeters().values()),
MoreExecutors.directExecutor());
ListenableFuture<RpcResult<AddMetersBatchOutput>> addMetersBulkFuture =
PathUtil.extractNodeId(input.getNode()),
input.getBatchRemoveMeters().size());
final ArrayList<ListenableFuture<RpcResult<RemoveMeterOutput>>> resultsLot = new ArrayList<>();
- for (BatchRemoveMeters addMeter : input.getBatchRemoveMeters()) {
+ for (BatchRemoveMeters addMeter : input.nonnullBatchRemoveMeters().values()) {
final RemoveMeterInput removeMeterInput = new RemoveMeterInputBuilder(addMeter)
.setMeterRef(createMeterRef(input.getNode(), addMeter))
.setNode(input.getNode())
final ListenableFuture<RpcResult<List<BatchFailedMetersOutput>>> commonResult =
Futures.transform(Futures.allAsList(resultsLot),
- MeterUtil.createCumulativeFunction(input.getBatchRemoveMeters()),
+ MeterUtil.createCumulativeFunction(input.nonnullBatchRemoveMeters().values()),
MoreExecutors.directExecutor());
ListenableFuture<RpcResult<RemoveMetersBatchOutput>> removeMetersBulkFuture =
}
private Port getPortFromInput(final UpdatePortInput input) {
- return input.getUpdatedPort().getPort().getPort().get(0);
+ return input.getUpdatedPort().getPort().nonnullPort().values().iterator().next();
}
}
.map(MultipartReply::getMultipartReplyBody)
.filter(MultipartReplyTableFeatures.class::isInstance)
.flatMap(multipartReplyBody -> ((MultipartReplyTableFeatures) multipartReplyBody)
- .getTableFeatures()
+ .nonnullTableFeatures().values()
.stream())
.collect(Collectors.toList()));
} catch (Exception e) {
// we have to read actual tables with all information before we set empty Flow list,
// merge is expensive and not applicable for lists
if (flowCapNodeOpt != null && flowCapNodeOpt.isPresent()) {
- for (final Table tableData : flowCapNodeOpt.get().getTable()) {
+ for (final Table tableData : flowCapNodeOpt.get().nonnullTable().values()) {
final Table table = new TableBuilder(tableData).setFlow(Collections.emptyList()).build();
final InstanceIdentifier<Table> iiToTable = instanceIdentifier
.child(Table.class, tableData.key());
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicLongFieldUpdater;
-import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageIntelligenceAgency;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
new ConcurrentHashMap<>();
@Override
- public void spyMessage(@NonNull final Class<?> message, final StatisticsGroup statGroup) {
+ public void spyMessage(final Class<?> message, final StatisticsGroup statGroup) {
Preconditions.checkNotNull(message, "Message can't be null.");
getCounters(message, statGroup).increment();
}
*/
package org.opendaylight.openflowplugin.impl.statistics.services;
+import com.google.common.collect.Lists;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.Optional;
+import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
+import java.util.stream.Collectors;
import org.opendaylight.openflowjava.protocol.api.util.BinContent;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
final Optional<List<MeterConfigStats>> meterConfigStatsList =
convertorExecutor.convert(replyBody.getMeterConfig(), data);
- meterConfigStatsList.ifPresent(meterConfigStats -> message.getMeterConfigStats().addAll(meterConfigStats));
+ meterConfigStatsList.ifPresent(meterConfigStats -> {
+ if (message.getMeterConfigStats() == null) {
+ message.setMeterConfigStats(Lists.newArrayList(meterConfigStats));
+ } else {
+ Set<MeterConfigStats> stats = new HashSet<>(message.getMeterConfigStats().values());
+ stats.addAll(meterConfigStats);
+ message.setMeterConfigStats(stats.stream().collect(Collectors.toList()));
+ }
+ });
}
return message.build();
*/
package org.opendaylight.openflowplugin.impl.statistics.services;
+import com.google.common.collect.Lists;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.Optional;
+import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
+import java.util.stream.Collectors;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
final Optional<List<GroupDescStats>> groupDescStatsList = convertorExecutor.convert(
replyBody.getGroupDesc(), data);
- groupDescStatsList.ifPresent(groupDescStats -> notification.getGroupDescStats().addAll(groupDescStats));
+ groupDescStatsList.ifPresent(groupDescStats -> {
+ if (notification.getGroupDescStats() == null) {
+ List<GroupDescStats> stats = Lists.newArrayList(groupDescStats);
+ notification.setGroupDescStats(stats);
+ } else {
+ Set<GroupDescStats> stats = new HashSet<>(notification.getGroupDescStats().values());
+ stats.addAll(groupDescStats);
+ notification.setGroupDescStats(stats.stream().collect(Collectors.toList()));
+ }
+ });
+
+
}
return notification.build();
package org.opendaylight.openflowplugin.impl.statistics.services.compatibility;
+import com.google.common.collect.Lists;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
final Optional<List<GroupStats>> groupStatsList = convertorExecutor.convert(
replyBody.getGroupStats(), data);
- groupStatsList.ifPresent(groupStats -> notification.getGroupStats().addAll(groupStats));
+ groupStatsList.ifPresent(groupStats -> {
+ if (notification.getGroupStats() == null) {
+ List<GroupStats> stats = Lists.newArrayList(groupStats);
+ notification.setGroupStats(stats);
+ } else {
+ Set<GroupStats> stats = new HashSet<>(notification.getGroupStats().values());
+ stats.addAll(groupStats);
+ notification.setGroupStats(stats.stream().collect(Collectors.toList()));
+ }
+ });
}
return notification.build();
}
package org.opendaylight.openflowplugin.impl.statistics.services.compatibility;
+import com.google.common.collect.Lists;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
final Optional<List<MeterStats>> meterStatsList =
convertorExecutor.convert(replyBody.getMeterStats(), data);
- meterStatsList.ifPresent(meterStats -> notification.getMeterStats().addAll(meterStats));
+ meterStatsList.ifPresent(meterStats -> {
+ if (notification.getMeterStats() == null) {
+ notification.setMeterStats(Lists.newArrayList(meterStats));
+ } else {
+ Set<MeterStats> stats = new HashSet<>(notification.getMeterStats().values());
+ stats.addAll(meterStats);
+ notification.setMeterStats(stats.stream().collect(Collectors.toList()));
+ }
+ });
}
return notification.build();
package org.opendaylight.openflowplugin.impl.statistics.services.compatibility;
import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.Lists;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.multipart.reply.port.stats.PortStats;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdate;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapKey;
for (PortStats portStats : replyBody.getPortStats()) {
NodeConnectorStatisticsAndPortNumberMapBuilder statsBuilder =
processSingleNodeConnectorStats(deviceInfo, ofVersion, portStats);
- notification.getNodeConnectorStatisticsAndPortNumberMap().add(statsBuilder.build());
+ if (notification.getNodeConnectorStatisticsAndPortNumberMap() != null) {
+ Set<NodeConnectorStatisticsAndPortNumberMap> stats
+ = new HashSet<>(notification.getNodeConnectorStatisticsAndPortNumberMap().values());
+ stats.add(statsBuilder.build());
+ notification.setNodeConnectorStatisticsAndPortNumberMap(
+ stats.stream().collect(Collectors.toList()));
+ } else {
+ notification.setNodeConnectorStatisticsAndPortNumberMap(Lists.newArrayList(statsBuilder.build()));
+ }
}
}
return notification.build();
package org.opendaylight.openflowplugin.impl.statistics.services.compatibility;
+import com.google.common.collect.Lists;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStats;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.QueueStatisticsUpdate;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.QueueStatisticsUpdateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapBuilder;
/**
statsBuilder.setQueueId(new QueueId(queueStats.getQueueId()));
- notification.getQueueIdAndStatisticsMap().add(statsBuilder.build());
+ if (notification.getQueueIdAndStatisticsMap() == null) {
+ notification.setQueueIdAndStatisticsMap(Lists.newArrayList(statsBuilder.build()));
+ } else {
+ Set<QueueIdAndStatisticsMap> stats
+ = new HashSet<>(notification.getQueueIdAndStatisticsMap().values());
+ stats.add(statsBuilder.build());
+ notification.setQueueIdAndStatisticsMap(stats.stream().collect(Collectors.toList()));
+ }
}
}
return notification.build();
.setFlowAndStatisticsMapList(input
.stream()
.flatMap(multipartReply -> ((MultipartReplyFlowStats) multipartReply.getMultipartReplyBody())
- .getFlowAndStatisticsMapList()
+ .nonnullFlowAndStatisticsMapList().values()
.stream())
.map(flowAndStatisticsMapList -> {
final FlowId flowId = new FlowId(generateFlowId(flowAndStatisticsMapList));
.setGroupStats(input
.stream()
.flatMap(multipartReply -> ((MultipartReplyGroupStats) multipartReply.getMultipartReplyBody())
- .getGroupStats()
+ .nonnullGroupStats().values()
.stream())
.collect(Collectors.toList()))
.build();
.setMeterStats(input
.stream()
.flatMap(multipartReply -> ((MultipartReplyMeterStats) multipartReply.getMultipartReplyBody())
- .getMeterStats()
+ .nonnullMeterStats().values()
.stream())
.collect(Collectors.toList()))
.build();
.setNodeConnectorStatisticsAndPortNumberMap(input
.stream()
.flatMap(multipartReply -> ((MultipartReplyPortStats) multipartReply.getMultipartReplyBody())
- .getNodeConnectorStatisticsAndPortNumberMap()
- .stream())
+ .nonnullNodeConnectorStatisticsAndPortNumberMap()
+ .values().stream())
.collect(Collectors.toList()))
.build();
}
.setQueueIdAndStatisticsMap(input
.stream()
.flatMap(multipartReply -> ((MultipartReplyQueueStats) multipartReply.getMultipartReplyBody())
- .getQueueIdAndStatisticsMap()
+ .nonnullQueueIdAndStatisticsMap().values()
.stream())
.collect(Collectors.toList()))
.build();
.orElseGet(MatchBuilder::new);
final AugmentTuple<org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match>
- matchExtensionWrap = MatchExtensionHelper
- .processAllExtensions(input.getMatch().getMatchEntry(), OpenflowVersion.get(input.getVersion()),
- MatchPath.PACKET_RECEIVED_MATCH);
+ matchExtensionWrap = MatchExtensionHelper.processAllExtensions(input.getMatch().nonnullMatchEntry(),
+ OpenflowVersion.get(input.getVersion()), MatchPath.PACKET_RECEIVED_MATCH);
if (matchExtensionWrap != null) {
matchBuilder.addAugmentation(matchExtensionWrap.getAugmentationClass(),
* @param protocolVersion the OpenFLow protocol version
* @return normalized uri
*/
- @Nullable
- public static Uri normalizeProtocolAgnosticPort(@Nullable final Uri port, final short protocolVersion) {
+ public static @Nullable Uri normalizeProtocolAgnosticPort(@Nullable final Uri port, final short protocolVersion) {
if (port == null) {
return null;
}
* @param ipv6Prefix the Ipv6 prefix
* @return normalized Ipv6 prefix
*/
- @Nullable
- public static Ipv6Prefix normalizeIpv6Prefix(@Nullable final Ipv6Prefix ipv6Prefix) {
+ public static @Nullable Ipv6Prefix normalizeIpv6Prefix(@Nullable final Ipv6Prefix ipv6Prefix) {
if (ipv6Prefix == null) {
return null;
}
* @param ipv4Mask the Ipv4 mask
* @return normalized Ipv6 prefix
*/
- @Nullable
- public static Ipv6Prefix normalizeIpv6Arbitrary(@Nullable final Ipv6Address ipv6Address,
- @Nullable final Ipv6ArbitraryMask ipv4Mask) {
+ public static @Nullable Ipv6Prefix normalizeIpv6Arbitrary(@Nullable final Ipv6Address ipv6Address,
+ @Nullable final Ipv6ArbitraryMask ipv4Mask) {
if (ipv6Address == null) {
return null;
}
* @param ipv6Address the Ipv6 address
* @return normalized Ipv6 address
*/
- @Nullable
- public static Ipv6Address normalizeIpv6AddressWithoutMask(@Nullable final Ipv6Address ipv6Address) {
+ public static @Nullable Ipv6Address normalizeIpv6AddressWithoutMask(@Nullable final Ipv6Address ipv6Address) {
final Ipv6Prefix ipv6Prefix = normalizeIpv6Arbitrary(ipv6Address, null);
return ipv6Prefix == null ? null : new Ipv6Address(ipv6Prefix.getValue().split(PREFIX_SEPARATOR)[0]);
}
* @param ipv4Prefix the Ipv4 prefix
* @return normalized Ipv4 prefix
*/
- @Nullable
- public static Ipv4Prefix normalizeIpv4Prefix(@Nullable final Ipv4Prefix ipv4Prefix) {
+ public static @Nullable Ipv4Prefix normalizeIpv4Prefix(@Nullable final Ipv4Prefix ipv4Prefix) {
if (ipv4Prefix == null) {
return null;
}
* @param ipv4Mask the Ipv4 mask
* @return normalized Ipv4 prefix
*/
- @Nullable
- public static Ipv4Prefix normalizeIpv4Arbitrary(@Nullable final Ipv4Address ipv4Address,
- @Nullable final DottedQuad ipv4Mask) {
+ public static @Nullable Ipv4Prefix normalizeIpv4Arbitrary(@Nullable final Ipv4Address ipv4Address,
+ @Nullable final DottedQuad ipv4Mask) {
if (ipv4Address == null) {
return null;
}
* @param mask Ipv4 mask byte array
* @return normalized Ipv4 prefix
*/
- @Nullable
- public static Ipv4Prefix normalizeIpv4Address(@Nullable final byte[] address, @Nullable final byte[] mask) {
+ public static @Nullable Ipv4Prefix normalizeIpv4Address(final byte @Nullable [] address,
+ final byte @Nullable [] mask) {
final String addressPrefix = normalizeInetAddressWithMask(normalizeIpAddress(address, mask), mask);
if (addressPrefix == null) {
* @param mask Ipv6 mask byte array
* @return normalized Ipv6 prefix
*/
- @Nullable
- public static Ipv6Prefix normalizeIpv6Address(@Nullable final byte[] address, @Nullable final byte[] mask) {
+ public static @Nullable Ipv6Prefix normalizeIpv6Address(final byte @Nullable [] address,
+ final byte @Nullable [] mask) {
final String addressPrefix = normalizeInetAddressWithMask(normalizeIpAddress(address, mask), mask);
if (addressPrefix == null) {
* @param mask mask byte array
* @return normalized Inet address
*/
- @Nullable
- public static InetAddress normalizeIpAddress(@Nullable final byte[] address, @Nullable final byte[] mask) {
+ public static @Nullable InetAddress normalizeIpAddress(final byte @Nullable [] address,
+ final byte @Nullable [] mask) {
if (address == null) {
return null;
}
* @param mask the mask
* @return the string
*/
- @Nullable
- public static String normalizeInetAddressWithMask(@Nullable final InetAddress address,
- @Nullable final byte[] mask) {
+ public static @Nullable String normalizeInetAddressWithMask(final @Nullable InetAddress address,
+ final byte @Nullable [] mask) {
if (address == null) {
return null;
}
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.EnumSet;
import java.util.List;
import org.opendaylight.openflowplugin.impl.services.batch.BatchPlanStep;
}
private static boolean isGroupBarrierNeeded(final EnumSet<BatchStepType> previousTypes, final BatchStepType type) {
- return (type == BatchStepType.GROUP_ADD
+ return type == BatchStepType.GROUP_ADD
&& (previousTypes.contains(BatchStepType.GROUP_ADD)
- || previousTypes.contains(BatchStepType.GROUP_UPDATE)))
- || (type == BatchStepType.GROUP_REMOVE
+ || previousTypes.contains(BatchStepType.GROUP_UPDATE))
+ || type == BatchStepType.GROUP_REMOVE
&& (previousTypes.contains(BatchStepType.FLOW_REMOVE)
|| previousTypes.contains(BatchStepType.FLOW_UPDATE)
|| previousTypes.contains(BatchStepType.GROUP_REMOVE)
- || previousTypes.contains(BatchStepType.GROUP_UPDATE)));
+ || previousTypes.contains(BatchStepType.GROUP_UPDATE));
}
private static boolean isMeterBarrierNeeded(final EnumSet<BatchStepType> previousTypes, final BatchStepType type) {
|| previousTypes.contains(BatchStepType.FLOW_UPDATE));
}
- public static List<BatchPlanStep> assembleBatchPlan(List<Batch> batches) {
+ public static List<BatchPlanStep> assembleBatchPlan(final Collection<Batch> batches) {
final List<BatchPlanStep> plan = new ArrayList<>();
BatchPlanStep planStep;
return plan;
}
- private static List<? extends BatchOrderGrouping> extractBatchData(final BatchStepType batchStepType,
+ private static Collection<? extends BatchOrderGrouping> extractBatchData(final BatchStepType batchStepType,
final BatchChoice batchChoice) {
- final List<? extends BatchOrderGrouping> batchData;
+ final Collection<? extends BatchOrderGrouping> batchData;
switch (batchStepType) {
case FLOW_ADD:
- batchData = ((FlatBatchAddFlowCase) batchChoice).getFlatBatchAddFlow();
+ batchData = ((FlatBatchAddFlowCase) batchChoice).nonnullFlatBatchAddFlow().values();
break;
case FLOW_REMOVE:
- batchData = ((FlatBatchRemoveFlowCase) batchChoice).getFlatBatchRemoveFlow();
+ batchData = ((FlatBatchRemoveFlowCase) batchChoice).nonnullFlatBatchRemoveFlow().values();
break;
case FLOW_UPDATE:
- batchData = ((FlatBatchUpdateFlowCase) batchChoice).getFlatBatchUpdateFlow();
+ batchData = ((FlatBatchUpdateFlowCase) batchChoice).nonnullFlatBatchUpdateFlow().values();
break;
case GROUP_ADD:
- batchData = ((FlatBatchAddGroupCase) batchChoice).getFlatBatchAddGroup();
+ batchData = ((FlatBatchAddGroupCase) batchChoice).nonnullFlatBatchAddGroup().values();
break;
case GROUP_REMOVE:
- batchData = ((FlatBatchRemoveGroupCase) batchChoice).getFlatBatchRemoveGroup();
+ batchData = ((FlatBatchRemoveGroupCase) batchChoice).nonnullFlatBatchRemoveGroup().values();
break;
case GROUP_UPDATE:
- batchData = ((FlatBatchUpdateGroupCase) batchChoice).getFlatBatchUpdateGroup();
+ batchData = ((FlatBatchUpdateGroupCase) batchChoice).nonnullFlatBatchUpdateGroup().values();
break;
case METER_ADD:
- batchData = ((FlatBatchAddMeterCase) batchChoice).getFlatBatchAddMeter();
+ batchData = ((FlatBatchAddMeterCase) batchChoice).nonnullFlatBatchAddMeter().values();
break;
case METER_REMOVE:
- batchData = ((FlatBatchRemoveMeterCase) batchChoice).getFlatBatchRemoveMeter();
+ batchData = ((FlatBatchRemoveMeterCase) batchChoice).nonnullFlatBatchRemoveMeter().values();
break;
case METER_UPDATE:
- batchData = ((FlatBatchUpdateMeterCase) batchChoice).getFlatBatchUpdateMeter();
+ batchData = ((FlatBatchUpdateMeterCase) batchChoice).nonnullFlatBatchUpdateMeter().values();
break;
default:
throw new IllegalArgumentException("Unsupported batch step type obtained: " + batchStepType);
for (RpcResult<ProcessFlatBatchOutput> jobResult : jobsResults) {
if (jobResult != null) {
- isSuccessful = (isSuccessful && jobResult.isSuccessful());
+ isSuccessful = isSuccessful && jobResult.isSuccessful();
rpcErrors.addAll(jobResult.getErrors());
- batchFailures.addAll(jobResult.getResult().getBatchFailure());
+ batchFailures.addAll(jobResult.getResult().nonnullBatchFailure().values());
}
}
import java.util.Iterator;
import java.util.List;
import org.apache.commons.lang3.tuple.Pair;
-import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
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;
* @return static reusable function
*/
public static <O> Function<List<RpcResult<O>>, RpcResult<List<BatchFailedFlowsOutput>>> createCumulatingFunction(
- final List<? extends BatchFlowIdGrouping> inputBatchFlows) {
+ final Collection<? extends BatchFlowIdGrouping> inputBatchFlows) {
return new CumulatingFunction<O>(inputBatchFlows).invoke();
}
private static class CumulatingFunction<O> {
- private final List<? extends BatchFlowIdGrouping> inputBatchFlows;
+ private final Collection<? extends BatchFlowIdGrouping> inputBatchFlows;
- CumulatingFunction(final List<? extends BatchFlowIdGrouping> inputBatchFlows) {
+ CumulatingFunction(final Collection<? extends BatchFlowIdGrouping> inputBatchFlows) {
this.inputBatchFlows = inputBatchFlows;
}
public Function<List<RpcResult<O>>, RpcResult<List<BatchFailedFlowsOutput>>> invoke() {
- return (@NonNull final List<RpcResult<O>> innerInput) -> {
+ return (final List<RpcResult<O>> innerInput) -> {
final int sizeOfFutures = innerInput.size();
final int sizeOfInputBatch = inputBatchFlows.size();
Preconditions.checkArgument(sizeOfFutures == sizeOfInputBatch,
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
+import java.util.stream.Collectors;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.openflowplugin.openflow.md.core.extension.ExtensionResolvers;
return ExtensionResolvers
.getMatchExtensionResolver()
.getExtension(match)
- .flatMap(matchExtension -> Optional.ofNullable(matchExtension.getExtensionList()));
+ .flatMap(matchExtension ->
+ Optional.ofNullable(matchExtension.nonnullExtensionList().values()
+ .stream().collect(Collectors.toList())));
}
}
txChainManager.writeToTransaction(LogicalDatastoreType.CONFIGURATION, path, data, false);
Mockito.verify(txChain).newReadWriteTransaction();
- Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data, false);
+ Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data);
}
/**
txChainManager.submitTransaction();
Mockito.verify(txChain).newReadWriteTransaction();
- Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data, false);
+ Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data);
Mockito.verify(writeTx).commit();
}
txChainManager.submitTransaction();
Mockito.verify(txChain).newReadWriteTransaction();
- Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data, false);
+ Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data);
Mockito.verify(writeTx, Mockito.never()).commit();
}
txChainManager.submitTransaction();
Mockito.verify(txChain).newReadWriteTransaction();
- Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data, false);
+ Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data);
Mockito.verify(writeTx).commit();
}
txChainManager.writeToTransaction(LogicalDatastoreType.CONFIGURATION, path, data, false);
Mockito.verify(txChain).newReadWriteTransaction();
- Mockito.verify(writeTx, Mockito.times(2)).put(LogicalDatastoreType.CONFIGURATION, path, data, false);
+ Mockito.verify(writeTx, Mockito.times(2)).put(LogicalDatastoreType.CONFIGURATION, path, data);
Mockito.verify(writeTx, Mockito.never()).commit();
}
txChainManager.deactivateTransactionManager();
Mockito.verify(txChain).newReadWriteTransaction();
- Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data, false);
+ Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data);
Mockito.verify(writeTx, Mockito.never()).commit();
Mockito.verify(writeTx).cancel();
Mockito.verify(txChain).close();
txChainManager.shuttingDown();
Mockito.verify(txChain).newReadWriteTransaction();
- Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data, false);
+ Mockito.verify(writeTx).put(LogicalDatastoreType.CONFIGURATION, path, data);
Mockito.verify(writeTx).commit();
}
assertEquals(ApplyActionsCase.class, instruction.implementedInterface());
final ApplyActionsCase actionCase = (ApplyActionsCase) instruction;
assertEquals(1, actionCase.getApplyActions().getAction().size());
- assertEquals(PopPbbActionCase.class, actionCase.getApplyActions().getAction().get(0)
+ assertEquals(PopPbbActionCase.class, actionCase.getApplyActions().nonnullAction().values().iterator().next()
.getAction().implementedInterface());
assertEquals(0, in.readableBytes());
}
assertEquals(WriteActionsCase.class, instruction.implementedInterface());
final WriteActionsCase actionCase = (WriteActionsCase) instruction;
assertEquals(1, actionCase.getWriteActions().getAction().size());
- assertEquals(PopPbbActionCase.class, actionCase.getWriteActions().getAction().get(0)
+ assertEquals(PopPbbActionCase.class, actionCase.getWriteActions().nonnullAction().values().iterator().next()
.getAction().implementedInterface());
assertEquals(0, in.readableBytes());
}
assertEquals(MPLS_LABEL, message.getMatch().getProtocolMatchFields().getMplsLabel().intValue());
assertEquals(1, message.getInstructions().getInstruction().size());
- final Instruction instruction = message.getInstructions().getInstruction().get(0).getInstruction();
+ final Instruction instruction = message.getInstructions().nonnullInstruction().values().iterator().next()
+ .getInstruction();
assertEquals(ApplyActionsCase.class, instruction.implementedInterface());
final ApplyActionsCase applyActions = (ApplyActionsCase) instruction;
assertEquals(1, applyActions.getApplyActions().getAction().size());
- assertEquals(PopPbbActionCase.class, applyActions.getApplyActions().getAction().get(0)
+ assertEquals(PopPbbActionCase.class, applyActions.getApplyActions().nonnullAction().values().iterator().next()
.getAction().implementedInterface());
}
* 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.protocol.deserialization.messages;
import static org.junit.Assert.assertEquals;
assertEquals(GROUP_TYPE.getIntValue(), message.getGroupType().getIntValue());
assertEquals(1, message.getBuckets().getBucket().size());
- final Bucket bucket = message.getBuckets().getBucket().get(0);
+ final Bucket bucket = message.getBuckets().nonnullBucket().values().iterator().next();
assertEquals(WEIGHT, bucket.getWeight().shortValue());
assertEquals(WATCH_PORT, bucket.getWatchPort().intValue());
assertEquals(WATCH_GROUP, bucket.getWatchGroup().intValue());
assertEquals(1, bucket.getAction().size());
- assertEquals(PopPbbActionCase.class, bucket.getAction().get(0).getAction().implementedInterface());
+ assertEquals(PopPbbActionCase.class,
+ bucket.nonnullAction().values().iterator().next().getAction().implementedInterface());
}
}
import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator;
-import java.util.List;
+import java.util.Iterator;
+import java.util.Map;
import org.junit.Test;
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
import org.opendaylight.openflowjava.util.ByteBufUtils;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Drop;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DscpRemark;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterModCommand;
public class MeterMessageDeserializerTest extends AbstractDeserializerTest {
assertEquals(message.getFlags().isMeterStats(), IS_STATS);
assertEquals(message.getMeterId().getValue().intValue(), ID);
- final List<MeterBandHeader> meterBandHeader = message.getMeterBandHeaders().getMeterBandHeader();
+ final Map<MeterBandHeaderKey, MeterBandHeader> meterBandHeader =
+ message.getMeterBandHeaders().nonnullMeterBandHeader();
assertEquals(meterBandHeader.size(), 2);
+ final Iterator<MeterBandHeader> meterBandHeaderIt = meterBandHeader.values().iterator();
// Drop band
- final MeterBandHeader dropHeader = meterBandHeader.get(0);
+ final MeterBandHeader dropHeader = meterBandHeaderIt.next();
assertEquals(Drop.class, dropHeader.getBandType().implementedInterface());
assertTrue(dropHeader.getMeterBandTypes().getFlags().isOfpmbtDrop());
assertEquals(DROP_BURST, drop.getDropBurstSize().intValue());
// Dscp band
- final MeterBandHeader dscpHeader = meterBandHeader.get(1);
+ final MeterBandHeader dscpHeader = meterBandHeaderIt.next();
assertEquals(DscpRemark.class, dscpHeader.getBandType().implementedInterface());
assertTrue(dscpHeader.getMeterBandTypes().getFlags().isOfpmbtDscpRemark());
buffer.setShort(instructionLengthIndex, buffer.writerIndex() - instructionStartIndex);
final MultipartReplyFlowStats reply = (MultipartReplyFlowStats) deserializeMultipart(buffer);
- final FlowAndStatisticsMapList flowAndStatisticsMapList = reply.getFlowAndStatisticsMapList().get(0);
+ final FlowAndStatisticsMapList flowAndStatisticsMapList =
+ reply.nonnullFlowAndStatisticsMapList().values().iterator().next();
assertEquals(TABLE_ID, flowAndStatisticsMapList.getTableId().shortValue());
assertEquals(SECOND, flowAndStatisticsMapList.getDuration().getSecond().getValue().intValue());
assertEquals(NANOSECOND, flowAndStatisticsMapList.getDuration().getNanosecond().getValue().intValue());
assertEquals(PACKET_COUNT, flowAndStatisticsMapList.getPacketCount().getValue().longValue());
assertEquals(2, flowAndStatisticsMapList.getInstructions().getInstruction().size());
+ final var instructionIter = flowAndStatisticsMapList.getInstructions().nonnullInstruction().values().iterator();
- final Instruction instruction =
- flowAndStatisticsMapList.getInstructions().getInstruction().get(0).getInstruction();
+ final Instruction instruction = instructionIter.next().getInstruction();
assertEquals(ApplyActionsCase.class, instruction.implementedInterface());
final ApplyActionsCase applyActions = (ApplyActionsCase) instruction;
- assertEquals(1, applyActions.getApplyActions().getAction().size());
- assertEquals(PopPbbActionCase.class, applyActions.getApplyActions().getAction().get(0)
+ assertEquals(1, applyActions.getApplyActions().nonnullAction().size());
+ assertEquals(PopPbbActionCase.class, applyActions.getApplyActions().nonnullAction().values().iterator().next()
.getAction().implementedInterface());
- final Instruction instruction1 =
- flowAndStatisticsMapList.getInstructions().getInstruction().get(1).getInstruction();
+ final Instruction instruction1 = instructionIter.next().getInstruction();
assertEquals(WriteActionsCase.class, instruction1.implementedInterface());
final WriteActionsCase writeActions = (WriteActionsCase) instruction1;
assertEquals(1, writeActions.getWriteActions().getAction().size());
- assertEquals(PopVlanActionCase.class, writeActions.getWriteActions().getAction().get(0)
+ assertEquals(PopVlanActionCase.class, writeActions.getWriteActions().nonnullAction().values().iterator().next()
.getAction().implementedInterface());
}
import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator;
import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.multipart.reply.multipart.reply.body.MultipartReplyFlowTableStats;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
buffer.writeLong(PACKETS_MATCHED);
final MultipartReplyFlowTableStats reply = (MultipartReplyFlowTableStats) deserializeMultipart(buffer);
- assertEquals(TABLE_ID, reply.getFlowTableAndStatisticsMap().get(0).getTableId().getValue().byteValue());
- assertEquals(ACTIVE_FLOWS, reply.getFlowTableAndStatisticsMap().get(0).getActiveFlows().getValue().intValue());
- assertEquals(PACKETS_LOOKEDUP, reply.getFlowTableAndStatisticsMap().get(0).getPacketsLookedUp().getValue()
- .longValue());
- assertEquals(PACKETS_MATCHED, reply.getFlowTableAndStatisticsMap().get(0).getPacketsMatched().getValue()
- .longValue());
+ final FlowTableAndStatisticsMap first = reply.nonnullFlowTableAndStatisticsMap().values().iterator().next();
+ assertEquals(TABLE_ID, first.getTableId().getValue().byteValue());
+ assertEquals(ACTIVE_FLOWS, first.getActiveFlows().getValue().intValue());
+ assertEquals(PACKETS_LOOKEDUP, first.getPacketsLookedUp().getValue().longValue());
+ assertEquals(PACKETS_MATCHED, first.getPacketsMatched().getValue().longValue());
assertEquals(0, buffer.readableBytes());
}
import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyGroupDesc;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
public class MultipartReplyGroupDescDeserializerTest extends AbstractMultipartDeserializerTest {
buffer.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER);
final MultipartReplyGroupDesc reply = (MultipartReplyGroupDesc) deserializeMultipart(buffer);
+ final GroupDescStats firstGroupDescStats = reply.nonnullGroupDescStats().values().iterator().next();
+ assertEquals(GROUP_ID, firstGroupDescStats.getGroupId().getValue().intValue());
+ assertEquals(GROUP_TYPE, firstGroupDescStats.getGroupType().getIntValue());
- assertEquals(GROUP_ID, reply.getGroupDescStats().get(0).getGroupId().getValue().intValue());
- assertEquals(WEIGHT, reply.getGroupDescStats().get(0).getBuckets().getBucket().get(0).getWeight().intValue());
- assertEquals(WATCH_PORT, reply.getGroupDescStats().get(0).getBuckets().getBucket().get(0).getWatchPort()
- .intValue());
- assertEquals(WATCH_GROUP, reply.getGroupDescStats().get(0).getBuckets().getBucket().get(0).getWatchGroup()
- .intValue());
- assertEquals(GROUP_TYPE, reply.getGroupDescStats().get(0).getGroupType().getIntValue());
+ final Bucket firstBucket = firstGroupDescStats.getBuckets().nonnullBucket().values().iterator().next();
+ assertEquals(WEIGHT, firstBucket.getWeight().intValue());
+ assertEquals(WATCH_PORT, firstBucket.getWatchPort().intValue());
+ assertEquals(WATCH_GROUP, firstBucket.getWatchGroup().intValue());
assertEquals(0, buffer.readableBytes());
}
import io.netty.buffer.UnpooledByteBufAllocator;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyGroupStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
public class MultipartReplyGroupStatsDeserializerTest extends AbstractMultipartDeserializerTest {
buffer.writeLong(BYTE_COUNT);
final MultipartReplyGroupStats reply = (MultipartReplyGroupStats) deserializeMultipart(buffer);
- assertEquals(GROUP_ID, reply.getGroupStats().get(0).getGroupId().getValue().intValue());
- assertEquals(REF_COUNT, reply.getGroupStats().get(0).getRefCount().getValue().intValue());
- assertEquals(PACKET_COUNT, reply.getGroupStats().get(0).getPacketCount().getValue().longValue());
- assertEquals(BYTE_COUNT, reply.getGroupStats().get(0).getByteCount().getValue().longValue());
- assertEquals(SECOND, reply.getGroupStats().get(0).getDuration().getSecond().getValue().intValue());
- assertEquals(NANOSECOND, reply.getGroupStats().get(0).getDuration().getNanosecond().getValue().intValue());
- assertEquals(PACKET_COUNT, reply.getGroupStats().get(0).getPacketCount().getValue().longValue());
- assertEquals(BYTE_COUNT, reply.getGroupStats().get(0).getByteCount().getValue().longValue());
+ final GroupStats firstGroupStats = reply.nonnullGroupStats().values().iterator().next();
+ assertEquals(GROUP_ID, firstGroupStats.getGroupId().getValue().intValue());
+ assertEquals(REF_COUNT, firstGroupStats.getRefCount().getValue().intValue());
+ assertEquals(PACKET_COUNT, firstGroupStats.getPacketCount().getValue().longValue());
+ assertEquals(BYTE_COUNT, firstGroupStats.getByteCount().getValue().longValue());
+ assertEquals(SECOND, firstGroupStats.getDuration().getSecond().getValue().intValue());
+ assertEquals(NANOSECOND, firstGroupStats.getDuration().getNanosecond().getValue().intValue());
+ assertEquals(PACKET_COUNT, firstGroupStats.getPacketCount().getValue().longValue());
+ assertEquals(BYTE_COUNT, firstGroupStats.getByteCount().getValue().longValue());
assertEquals(0, buffer.readableBytes());
}
final MultipartReplyFlowStats reply = (MultipartReplyFlowStats) message.getMultipartReplyBody();
assertEquals(XID, message.getXid().intValue());
- final FlowAndStatisticsMapList flowAndStatisticsMapList = reply.getFlowAndStatisticsMapList().get(0);
+ final FlowAndStatisticsMapList flowAndStatisticsMapList =
+ reply.nonnullFlowAndStatisticsMapList().values().iterator().next();
assertEquals(TABLE_ID, flowAndStatisticsMapList.getTableId().shortValue());
assertEquals(SECOND, flowAndStatisticsMapList.getDuration().getSecond().getValue().intValue());
assertEquals(NANOSECOND, flowAndStatisticsMapList.getDuration().getNanosecond().getValue().intValue());
assertEquals(1, flowAndStatisticsMapList.getInstructions().getInstruction().size());
final Instruction instruction =
- flowAndStatisticsMapList.getInstructions().getInstruction().get(0).getInstruction();
+ flowAndStatisticsMapList.getInstructions().nonnullInstruction().values().iterator().next()
+ .getInstruction();
assertEquals(ApplyActionsCase.class, instruction.implementedInterface());
final ApplyActionsCase applyActions = (ApplyActionsCase) instruction;
assertEquals(1, applyActions.getApplyActions().getAction().size());
- assertEquals(PopPbbActionCase.class, applyActions.getApplyActions().getAction().get(0)
+ assertEquals(PopPbbActionCase.class, applyActions.getApplyActions().nonnullAction().values().iterator().next()
.getAction().implementedInterface());
}
}
final MultipartReplyMeterConfig reply = (MultipartReplyMeterConfig) deserializeMultipart(buffer);
- assertEquals(METER_ID, reply.getMeterConfigStats().get(0).getMeterId().getValue().intValue());
- assertEquals(FLAGS, reply.getMeterConfigStats().get(0).getFlags());
- final Drop drop = (Drop) reply.getMeterConfigStats().get(0)
- .getMeterBandHeaders().getMeterBandHeader().get(0).getBandType();
+ assertEquals(METER_ID,
+ reply.nonnullMeterConfigStats().values().iterator().next().getMeterId().getValue().intValue());
+ assertEquals(FLAGS, reply.nonnullMeterConfigStats().values().iterator().next().getFlags());
+ final Drop drop = (Drop) reply.nonnullMeterConfigStats().values().iterator().next()
+ .getMeterBandHeaders().nonnullMeterBandHeader().values().iterator().next().getBandType();
assertEquals(DROP_RATE, drop.getDropRate().intValue());
assertEquals(DROP_BURST_SIZE, drop.getDropBurstSize().intValue());
}
final MultipartReplyMeterConfig reply = (MultipartReplyMeterConfig) deserializeMultipart(buffer);
- final DscpRemark dscpRemark = (DscpRemark) reply.getMeterConfigStats().get(0)
- .getMeterBandHeaders().getMeterBandHeader().get(0).getBandType();
+ final DscpRemark dscpRemark = (DscpRemark) reply.nonnullMeterConfigStats().values().iterator().next()
+ .getMeterBandHeaders().nonnullMeterBandHeader().values().iterator().next().getBandType();
assertEquals(DSCP_REMARK_RATE, dscpRemark.getDscpRemarkRate().intValue());
assertEquals(DSCP_REMARK_BURST_SIZE, dscpRemark.getDscpRemarkBurstSize().intValue());
assertEquals(PREC_LEVEL, dscpRemark.getPrecLevel().byteValue());
return MultipartType.OFPMPMETERCONFIG.getIntValue();
}
- private void writeCommonAtributes(ByteBuf buffer) {
+ private void writeCommonAtributes(final ByteBuf buffer) {
buffer.writeShort(ITEM_LENGTH);
buffer.writeShort(ByteBufUtils.fillBitMask(0,
FLAGS.isMeterKbps(),
final MultipartReplyMeterStats reply = (MultipartReplyMeterStats) deserializeMultipart(buffer);
- final MeterStats meterStats = reply.getMeterStats().get(0);
+ final MeterStats meterStats = reply.nonnullMeterStats().values().iterator().next();
assertEquals(METER_ID, meterStats.getMeterId().getValue().intValue());
assertEquals(FLOW_COUNT, meterStats.getFlowCount().getValue().intValue());
assertEquals(BYTE_IN_COUNT, meterStats.getByteInCount().getValue().intValue());
assertEquals(SECOND, meterStats.getDuration().getSecond().getValue().intValue());
assertEquals(NANOSECOND, meterStats.getDuration().getNanosecond().getValue().intValue());
- assertEquals(PACKET_BAND_COUNT, meterStats.getMeterBandStats().getBandStat().get(0)
+ assertEquals(PACKET_BAND_COUNT, meterStats.getMeterBandStats().nonnullBandStat().values().iterator().next()
.getPacketBandCount().getValue().longValue());
- assertEquals(BYTE_BAND_COUNT, meterStats.getMeterBandStats().getBandStat().get(0)
+ assertEquals(BYTE_BAND_COUNT, meterStats.getMeterBandStats().nonnullBandStat().values().iterator().next()
.getByteBandCount().getValue().longValue());
assertEquals(0, buffer.readableBytes());
}
final MultipartReplyPortStats reply = (MultipartReplyPortStats) deserializeMultipart(buffer);
final NodeConnectorStatisticsAndPortNumberMap portStats =
- reply.getNodeConnectorStatisticsAndPortNumberMap().get(0);
+ reply.nonnullNodeConnectorStatisticsAndPortNumberMap().values().iterator().next();
assertEquals(PACKETS_RECEIVED, portStats.getPackets().getReceived().longValue());
assertEquals(PACKETS_TRANSMITTED, portStats.getPackets().getTransmitted().longValue());
assertEquals(BYTES_RECEIVED, portStats.getBytes().getReceived().longValue());
final MultipartReplyQueueStats reply = (MultipartReplyQueueStats) deserializeMultipart(buffer);
- final QueueIdAndStatisticsMap queueStats = reply.getQueueIdAndStatisticsMap().get(0);
+ final QueueIdAndStatisticsMap queueStats = reply.nonnullQueueIdAndStatisticsMap().values().iterator().next();
assertEquals(QUEUE_ID, queueStats.getQueueId().getValue().intValue());
assertEquals(TRANSMITTED_BYTES, queueStats.getTransmittedBytes().getValue().longValue());
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMiss;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfield;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMiss;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
public class MultipartReplyTableFeaturesDeserializerTest extends AbstractMultipartDeserializerTest {
writeValues(buffer, OFPTFPT_INSTRUCTIONS);
MultipartReplyTableFeatures reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer);
- assertEquals(TABLE_ID, reply.getTableFeatures().get(0).getTableId().byteValue());
- assertEquals(METADATA_MATCH, reply.getTableFeatures().get(0).getMetadataMatch().longValue());
- assertEquals(METADATA_WRITE, reply.getTableFeatures().get(0).getMetadataWrite().longValue());
- assertEquals(MAX_ENTRIES, reply.getTableFeatures().get(0).getMaxEntries().longValue());
- assertEquals(MAX_ENTRIES, reply.getTableFeatures().get(0).getMaxEntries().longValue());
- assertEquals(Instructions.class, reply.getTableFeatures().get(0).getTableProperties()
- .getTableFeatureProperties().get(0).getTableFeaturePropType().implementedInterface());
+ TableFeatures firstTableFeature = reply.nonnullTableFeatures().values().iterator().next();
+ assertEquals(TABLE_ID, firstTableFeature.getTableId().byteValue());
+ assertEquals(METADATA_MATCH, firstTableFeature.getMetadataMatch().longValue());
+ assertEquals(METADATA_WRITE, firstTableFeature.getMetadataWrite().longValue());
+ assertEquals(MAX_ENTRIES, firstTableFeature.getMaxEntries().longValue());
+ assertEquals(MAX_ENTRIES, firstTableFeature.getMaxEntries().longValue());
+ assertEquals(Instructions.class, firstTableFeature.getTableProperties()
+ .nonnullTableFeatureProperties().values().iterator().next().getTableFeaturePropType()
+ .implementedInterface());
writeValues(buffer, OFPTFPT_INSTRUCTIONS_MISS);
reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer);
- assertEquals(InstructionsMiss.class, reply.getTableFeatures().get(0).getTableProperties()
- .getTableFeatureProperties().get(0).getTableFeaturePropType().implementedInterface());
+ assertEquals(InstructionsMiss.class, reply.nonnullTableFeatures().values().iterator().next()
+ .getTableProperties().nonnullTableFeatureProperties().values().iterator().next()
+ .getTableFeaturePropType().implementedInterface());
writeValues(buffer, OFPTFPT_NEXT_TABLES);
reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer);
- assertEquals(NextTable.class, reply.getTableFeatures().get(0).getTableProperties()
- .getTableFeatureProperties().get(0).getTableFeaturePropType().implementedInterface());
+ assertEquals(NextTable.class, reply.nonnullTableFeatures().values().iterator().next().getTableProperties()
+ .nonnullTableFeatureProperties().values().iterator().next().getTableFeaturePropType()
+ .implementedInterface());
writeValues(buffer, OFPTFPT_NEXT_TABLES_MISS);
reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer);
- assertEquals(NextTableMiss.class, reply.getTableFeatures().get(0).getTableProperties()
- .getTableFeatureProperties().get(0).getTableFeaturePropType().implementedInterface());
+ assertEquals(NextTableMiss.class, reply.nonnullTableFeatures().values().iterator().next().getTableProperties()
+ .nonnullTableFeatureProperties().values().iterator().next().getTableFeaturePropType()
+ .implementedInterface());
writeValues(buffer, OFPTFPT_WRITE_ACTIONS);
reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer);
- assertEquals(WriteActions.class, reply.getTableFeatures().get(0).getTableProperties()
- .getTableFeatureProperties().get(0).getTableFeaturePropType().implementedInterface());
+ assertEquals(WriteActions.class, reply.nonnullTableFeatures().values().iterator().next().getTableProperties()
+ .nonnullTableFeatureProperties().values().iterator().next().getTableFeaturePropType()
+ .implementedInterface());
writeValues(buffer, OFPTFPT_WRITE_ACTIONS_MISS);
reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer);
- assertEquals(WriteActionsMiss.class, reply.getTableFeatures().get(0).getTableProperties()
- .getTableFeatureProperties().get(0).getTableFeaturePropType().implementedInterface());
+ assertEquals(WriteActionsMiss.class, reply.nonnullTableFeatures().values().iterator().next()
+ .getTableProperties().nonnullTableFeatureProperties().values().iterator().next()
+ .getTableFeaturePropType().implementedInterface());
writeValues(buffer, OFPTFPT_APPLY_ACTIONS);
reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer);
- assertEquals(ApplyActions.class, reply.getTableFeatures().get(0).getTableProperties()
- .getTableFeatureProperties().get(0).getTableFeaturePropType().implementedInterface());
+ assertEquals(ApplyActions.class, reply.nonnullTableFeatures().values().iterator().next().getTableProperties()
+ .nonnullTableFeatureProperties().values().iterator().next().getTableFeaturePropType()
+ .implementedInterface());
writeValues(buffer, OFPTFPT_APPLY_ACTIONS_MISS);
reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer);
- assertEquals(ApplyActionsMiss.class, reply.getTableFeatures().get(0).getTableProperties()
- .getTableFeatureProperties().get(0).getTableFeaturePropType().implementedInterface());
+ assertEquals(ApplyActionsMiss.class, reply.nonnullTableFeatures().values().iterator().next()
+ .getTableProperties().nonnullTableFeatureProperties().values().iterator().next()
+ .getTableFeaturePropType().implementedInterface());
writeValues(buffer, OFPTFPT_MATCH);
reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer);
- assertEquals(Match.class, reply.getTableFeatures().get(0).getTableProperties()
- .getTableFeatureProperties().get(0).getTableFeaturePropType().implementedInterface());
+ assertEquals(Match.class, reply.nonnullTableFeatures().values().iterator().next().getTableProperties()
+ .nonnullTableFeatureProperties().values().iterator().next().getTableFeaturePropType()
+ .implementedInterface());
writeValues(buffer, OFPTFPT_WILDCARDS);
reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer);
- assertEquals(Wildcards.class, reply.getTableFeatures().get(0).getTableProperties()
- .getTableFeatureProperties().get(0).getTableFeaturePropType().implementedInterface());
+ assertEquals(Wildcards.class, reply.nonnullTableFeatures().values().iterator().next().getTableProperties()
+ .nonnullTableFeatureProperties().values().iterator().next().getTableFeaturePropType()
+ .implementedInterface());
writeValues(buffer, OFPTFPT_WRITE_SETFIELD);
reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer);
- assertEquals(WriteSetfield.class, reply.getTableFeatures().get(0).getTableProperties()
- .getTableFeatureProperties().get(0).getTableFeaturePropType().implementedInterface());
+ assertEquals(WriteSetfield.class, reply.nonnullTableFeatures().values().iterator().next().getTableProperties()
+ .nonnullTableFeatureProperties().values().iterator().next().getTableFeaturePropType()
+ .implementedInterface());
writeValues(buffer, OFPTFPT_WRITE_SETFIELD_MISS);
reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer);
- assertEquals(WriteSetfieldMiss.class, reply.getTableFeatures().get(0).getTableProperties()
- .getTableFeatureProperties().get(0).getTableFeaturePropType().implementedInterface());
+ assertEquals(WriteSetfieldMiss.class, reply.nonnullTableFeatures().values().iterator().next()
+ .getTableProperties().nonnullTableFeatureProperties().values().iterator().next()
+ .getTableFeaturePropType().implementedInterface());
writeValues(buffer, OFPTFPT_APPLY_SETFIELD);
reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer);
- assertEquals(ApplySetfield.class, reply.getTableFeatures().get(0).getTableProperties()
- .getTableFeatureProperties().get(0).getTableFeaturePropType().implementedInterface());
+ assertEquals(ApplySetfield.class, reply.nonnullTableFeatures().values().iterator().next().getTableProperties()
+ .nonnullTableFeatureProperties().values().iterator().next().getTableFeaturePropType()
+ .implementedInterface());
writeValues(buffer, OFPTFPT_APPLY_SETFIELD_MISS);
reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer);
- assertEquals(ApplySetfieldMiss.class, reply.getTableFeatures().get(0).getTableProperties()
- .getTableFeatureProperties().get(0).getTableFeaturePropType().implementedInterface());
+ assertEquals(ApplySetfieldMiss.class, reply.nonnullTableFeatures().values().iterator().next()
+ .getTableProperties().nonnullTableFeatureProperties().values().iterator().next()
+ .getTableFeaturePropType().implementedInterface());
assertEquals(0, buffer.readableBytes());
}
- private void writeValues(ByteBuf buffer, int propertyType) {
+
+ private static void writeValues(final ByteBuf buffer, final int propertyType) {
buffer.clear();
final int replyIndex = buffer.readerIndex();
buffer.writeShort(EncodeConstants.EMPTY_LENGTH);
.setInstruction(new ApplyActionsCaseBuilder()
.setApplyActions(new ApplyActionsBuilder()
.setAction(Collections.singletonList(new ActionBuilder()
- .setOrder(0)
- .withKey(new ActionKey(0))
+ .setOrder(1)
+ .withKey(new ActionKey(1))
.setAction(new SetTpDstActionCaseBuilder()
.setSetTpDstAction(new SetTpDstActionBuilder()
.setIpProtocol(IP_PROTOCOL)
.setInstruction(new ApplyActionsCaseBuilder()
.setApplyActions(new ApplyActionsBuilder()
.setAction(Collections.singletonList(new ActionBuilder()
- .setOrder(0)
- .withKey(new ActionKey(0))
+ .setOrder(2)
+ .withKey(new ActionKey(2))
.setAction(new SetTpSrcActionCaseBuilder()
.setSetTpSrcAction(new SetTpSrcActionBuilder()
.setIpProtocol(IP_PROTOCOL)
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.DscpRemarkBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.MeterBandHeadersBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.meter.band.header.MeterBandTypesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterModCommand;
.meter.types.rev130918.MeterBandType(true, false, false))
.build())
.setBandBurstSize(BAND_BURST_SIZE)
- .setBandId(new BandId(BAND_ID))
+ .withKey(new MeterBandHeaderKey(new BandId(BAND_ID)))
.setBandRate(BAND_RATE)
.setBandType(new DropBuilder()
.setDropRate(DROP_RATE)
.meter.types.rev130918.MeterBandType(false, true, false))
.build())
.setBandBurstSize(BAND_BURST_SIZE)
- .setBandId(new BandId(BAND_ID))
+ .withKey(new MeterBandHeaderKey(new BandId(BAND_ID + 1)))
.setBandRate(BAND_RATE)
.setBandType(new DscpRemarkBuilder()
.setDscpRemarkBurstSize(DSCP_BURST_SIZE)
fillRegistry(path, null);
- fillRegistry(path, new FlowCapableNodeBuilder()
- .setTable(null)
- .build());
+ fillRegistry(path, new FlowCapableNodeBuilder().build());
fillRegistry(path, new FlowCapableNodeBuilder()
- .setTable(Collections.singletonList(null))
+ .setTable(Collections.EMPTY_LIST)
.build());
fillRegistry(path, new FlowCapableNodeBuilder()
- .setTable(Collections.singletonList(new TableBuilder()
- .setFlow(null)
- .build()))
+ .setTable(Collections.singletonList(new TableBuilder().build()))
.build());
fillRegistry(path, new FlowCapableNodeBuilder()
.setTable(Collections.singletonList(new TableBuilder()
- .setFlow(Collections.singletonList(null))
+ .setFlow(Collections.EMPTY_LIST)
.build()))
.build());
FlowsStatisticsUpdate flowStats = FLOWS_STATISTICS_UPDATE_BUILDER.build();
HashSet<FlowRegistryKey> flowRegistryKeys = new HashSet<>();
- for (FlowAndStatisticsMapList item : flowStats.getFlowAndStatisticsMapList()) {
+ for (FlowAndStatisticsMapList item : flowStats.nonnullFlowAndStatisticsMapList().values()) {
final FlowRegistryKey key1 = FlowRegistryKeyFactory.create(deviceInfo.getVersion(), item);
final FlowRegistryKey key2 = FlowRegistryKeyFactory.create(deviceInfo.getVersion(), item);
flowRegistryKeys.add(key1);
public void testGetHash() {
FlowsStatisticsUpdate flowStats = FLOWS_STATISTICS_UPDATE_BUILDER.build();
- for (FlowAndStatisticsMapList item : flowStats.getFlowAndStatisticsMapList()) {
+ for (FlowAndStatisticsMapList item : flowStats.nonnullFlowAndStatisticsMapList().values()) {
FlowRegistryKey flowRegistryKey = FlowRegistryKeyFactory.create(deviceInfo.getVersion(), item);
FlowRegistryKey lastHash = null;
if (null != lastHash) {
import java.math.BigInteger;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
matchBuilder.setEthernetMatch(ethernetMatchBuilder.build());
flowAndStatisticsMapListBuilder.setMatch(matchBuilder.build());
+ flowAndStatisticsMapListBuilder.withKey(new FlowAndStatisticsMapListKey(new FlowId(String.valueOf(index))));
return flowAndStatisticsMapListBuilder;
}
}
package org.opendaylight.openflowplugin.impl.services.batch;
import com.google.common.collect.Lists;
+import java.util.Iterator;
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.BatchFlowOutputListGrouping;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.RemoveFlowsBatchInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.UpdateFlowsBatchInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.add.flows.batch.input.BatchAddFlows;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.output.list.grouping.BatchFailedFlowsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.output.list.grouping.BatchFailedFlowsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.remove.flows.batch.input.BatchRemoveFlows;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.update.flows.batch.input.BatchUpdateFlows;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
createAddFlowBatch("2")));
final AddFlowsBatchInput addFlowsBatchInput = FlatBatchFlowAdapters.adaptFlatBatchAddFlow(planStep, NODE_REF);
+ Iterator<BatchAddFlows> iterator = addFlowsBatchInput.nonnullBatchAddFlows().values().iterator();
Assert.assertTrue(addFlowsBatchInput.isBarrierAfter());
Assert.assertEquals(2, addFlowsBatchInput.getBatchAddFlows().size());
- Assert.assertEquals("1", addFlowsBatchInput.getBatchAddFlows().get(0).getFlowId().getValue());
- Assert.assertEquals("2", addFlowsBatchInput.getBatchAddFlows().get(1).getFlowId().getValue());
+ Assert.assertEquals("1", iterator.next().getFlowId().getValue());
+ Assert.assertEquals("2", iterator.next().getFlowId().getValue());
}
private FlatBatchAddFlow createAddFlowBatch(final String flowIdValue) {
final RemoveFlowsBatchInput removeFlowsBatchInput =
FlatBatchFlowAdapters.adaptFlatBatchRemoveFlow(planStep, NODE_REF);
+ Iterator<BatchRemoveFlows> iterator = removeFlowsBatchInput.nonnullBatchRemoveFlows().values().iterator();
Assert.assertTrue(removeFlowsBatchInput.isBarrierAfter());
Assert.assertEquals(2, removeFlowsBatchInput.getBatchRemoveFlows().size());
- Assert.assertEquals("1", removeFlowsBatchInput.getBatchRemoveFlows().get(0).getFlowId().getValue());
- Assert.assertEquals("2", removeFlowsBatchInput.getBatchRemoveFlows().get(1).getFlowId().getValue());
+ Assert.assertEquals("1", iterator.next().getFlowId().getValue());
+ Assert.assertEquals("2", iterator.next().getFlowId().getValue());
}
@Test
final UpdateFlowsBatchInput updateFlowsBatchInput =
FlatBatchFlowAdapters.adaptFlatBatchUpdateFlow(planStep, NODE_REF);
+ Iterator<BatchUpdateFlows> iterator = updateFlowsBatchInput.nonnullBatchUpdateFlows().values().iterator();
Assert.assertTrue(updateFlowsBatchInput.isBarrierAfter());
Assert.assertEquals(2, updateFlowsBatchInput.getBatchUpdateFlows().size());
- Assert.assertEquals("1", updateFlowsBatchInput.getBatchUpdateFlows().get(0).getFlowId().getValue());
- Assert.assertEquals("2", updateFlowsBatchInput.getBatchUpdateFlows().get(1).getFlowId().getValue());
+ Assert.assertEquals("1", iterator.next().getFlowId().getValue());
+ Assert.assertEquals("2", iterator.next().getFlowId().getValue());
}
@Test
final RpcResult<ProcessFlatBatchOutput> rpcResult = FlatBatchFlowAdapters
.convertBatchFlowResult(3).apply(input);
+ Iterator<BatchFailure> iterator = rpcResult.getResult().nonnullBatchFailure().values().iterator();
Assert.assertFalse(rpcResult.isSuccessful());
Assert.assertEquals(1, rpcResult.getErrors().size());
Assert.assertEquals(2, rpcResult.getResult().getBatchFailure().size());
- Assert.assertEquals(3, rpcResult.getResult().getBatchFailure().get(0).getBatchOrder().intValue());
- Assert.assertEquals(4, rpcResult.getResult().getBatchFailure().get(1).getBatchOrder().intValue());
+ Assert.assertEquals(3, iterator.next()
+ .getBatchOrder().intValue());
+ BatchFailure secondBatchFailure = iterator.next();
+ Assert.assertEquals(4, secondBatchFailure.getBatchOrder().intValue());
Assert.assertEquals("f2",
- ((FlatBatchFailureFlowIdCase) rpcResult.getResult().getBatchFailure().get(1).getBatchItemIdChoice())
+ ((FlatBatchFailureFlowIdCase) secondBatchFailure.getBatchItemIdChoice())
.getFlowId().getValue());
}
Assert.assertTrue(rpcResult.isSuccessful());
Assert.assertEquals(0, rpcResult.getErrors().size());
- Assert.assertEquals(0, rpcResult.getResult().getBatchFailure().size());
+ Assert.assertEquals(0, rpcResult.getResult().nonnullBatchFailure().size());
}
private BatchFailedFlowsOutput createBatchFailedFlowsOutput(final Integer batchOrder, final String flowIdValue) {
package org.opendaylight.openflowplugin.impl.services.batch;
import com.google.common.collect.Lists;
+import java.util.Iterator;
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.BatchGroupOutputListGrouping;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.RemoveGroupsBatchInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.UpdateGroupsBatchInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.add.groups.batch.input.BatchAddGroups;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.batch.group.input.update.grouping.OriginalBatchedGroupBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.batch.group.input.update.grouping.UpdatedBatchedGroupBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.batch.group.output.list.grouping.BatchFailedGroupsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.batch.group.output.list.grouping.BatchFailedGroupsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.remove.groups.batch.input.BatchRemoveGroups;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
final AddGroupsBatchInput addGroupsBatchInput =
FlatBatchGroupAdapters.adaptFlatBatchAddGroup(planStep, NODE_REF);
+ Iterator<BatchAddGroups> iterator = addGroupsBatchInput.nonnullBatchAddGroups().values().iterator();
Assert.assertTrue(addGroupsBatchInput.isBarrierAfter());
Assert.assertEquals(2, addGroupsBatchInput.getBatchAddGroups().size());
- Assert.assertEquals(1L, addGroupsBatchInput.getBatchAddGroups().get(0).getGroupId().getValue().longValue());
- Assert.assertEquals(2L, addGroupsBatchInput.getBatchAddGroups().get(1).getGroupId().getValue().longValue());
+ Assert.assertEquals(1L, iterator.next().getGroupId().getValue().longValue());
+ Assert.assertEquals(2L, iterator.next().getGroupId().getValue().longValue());
}
private FlatBatchAddGroup createAddGroupBatch(final long groupIdValue) {
final RemoveGroupsBatchInput removeGroupsBatchInput =
FlatBatchGroupAdapters.adaptFlatBatchRemoveGroup(planStep, NODE_REF);
+ Iterator<BatchRemoveGroups> iterator = removeGroupsBatchInput.nonnullBatchRemoveGroups().values().iterator();
Assert.assertTrue(removeGroupsBatchInput.isBarrierAfter());
Assert.assertEquals(2, removeGroupsBatchInput.getBatchRemoveGroups().size());
- Assert.assertEquals(1L,
- removeGroupsBatchInput.getBatchRemoveGroups().get(0).getGroupId().getValue().longValue());
- Assert.assertEquals(2L,
- removeGroupsBatchInput.getBatchRemoveGroups().get(1).getGroupId().getValue().longValue());
+ Assert.assertEquals(1L, iterator.next().getGroupId().getValue().longValue());
+ Assert.assertEquals(2L, iterator.next().getGroupId().getValue().longValue());
}
@Test
final RpcResult<ProcessFlatBatchOutput> rpcResult = FlatBatchGroupAdapters
.convertBatchGroupResult(3).apply(input);
+ Iterator<BatchFailure> iterator = rpcResult.getResult().nonnullBatchFailure().values().iterator();
Assert.assertFalse(rpcResult.isSuccessful());
Assert.assertEquals(1, rpcResult.getErrors().size());
- Assert.assertEquals(2, rpcResult.getResult().getBatchFailure().size());
- Assert.assertEquals(3, rpcResult.getResult().getBatchFailure().get(0).getBatchOrder().intValue());
- Assert.assertEquals(4, rpcResult.getResult().getBatchFailure().get(1).getBatchOrder().intValue());
- Assert.assertEquals(2L, ((FlatBatchFailureGroupIdCase) rpcResult.getResult().getBatchFailure().get(1)
+ Assert.assertEquals(2, rpcResult.getResult().nonnullBatchFailure().size());
+ Assert.assertEquals(3, iterator.next().getBatchOrder().intValue());
+ BatchFailure secondBatchFailure = iterator.next();
+ Assert.assertEquals(4, secondBatchFailure.getBatchOrder().intValue());
+ Assert.assertEquals(2L, ((FlatBatchFailureGroupIdCase) secondBatchFailure
.getBatchItemIdChoice()).getGroupId().getValue().longValue());
}
Assert.assertTrue(rpcResult.isSuccessful());
Assert.assertEquals(0, rpcResult.getErrors().size());
- Assert.assertEquals(0, rpcResult.getResult().getBatchFailure().size());
+ Assert.assertEquals(0, rpcResult.getResult().nonnullBatchFailure().size());
}
private BatchFailedGroupsOutput createBatchFailedGroupsOutput(final Integer batchOrder, final long groupIdValue) {
* 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.batch;
import com.google.common.collect.Lists;
+import java.util.Iterator;
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.BatchMeterOutputListGrouping;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.RemoveMetersBatchInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.UpdateMetersBatchInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.add.meters.batch.input.BatchAddMeters;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.input.update.grouping.OriginalBatchedMeterBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.input.update.grouping.UpdatedBatchedMeterBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.output.list.grouping.BatchFailedMetersOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.output.list.grouping.BatchFailedMetersOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.remove.meters.batch.input.BatchRemoveMeters;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
FlatBatchMeterAdapters.adaptFlatBatchAddMeter(planStep, NODE_REF);
Assert.assertTrue(addMetersBatchInput.isBarrierAfter());
- Assert.assertEquals(2, addMetersBatchInput.getBatchAddMeters().size());
- Assert.assertEquals(1L, addMetersBatchInput.getBatchAddMeters().get(0).getMeterId().getValue().longValue());
- Assert.assertEquals(2L, addMetersBatchInput.getBatchAddMeters().get(1).getMeterId().getValue().longValue());
+ Assert.assertEquals(2, addMetersBatchInput.nonnullBatchAddMeters().size());
+ final Iterator<BatchAddMeters> it = addMetersBatchInput.nonnullBatchAddMeters().values().iterator();
+
+ Assert.assertEquals(1L, it.next().getMeterId().getValue().longValue());
+ Assert.assertEquals(2L, it.next().getMeterId().getValue().longValue());
}
private FlatBatchAddMeter createAddMeterBatch(final long groupIdValue) {
final RemoveMetersBatchInput removeMetersBatchInput =
FlatBatchMeterAdapters.adaptFlatBatchRemoveMeter(planStep, NODE_REF);
+ Iterator<BatchRemoveMeters> iterator = removeMetersBatchInput.nonnullBatchRemoveMeters().values().iterator();
Assert.assertTrue(removeMetersBatchInput.isBarrierAfter());
- Assert.assertEquals(2, removeMetersBatchInput.getBatchRemoveMeters().size());
- Assert.assertEquals(1L,
- removeMetersBatchInput.getBatchRemoveMeters().get(0).getMeterId().getValue().longValue());
- Assert.assertEquals(2L,
- removeMetersBatchInput.getBatchRemoveMeters().get(1).getMeterId().getValue().longValue());
+ Assert.assertEquals(2, removeMetersBatchInput.nonnullBatchRemoveMeters().size());
+ Assert.assertEquals(1L, iterator.next().getMeterId().getValue().longValue());
+ Assert.assertEquals(2L, iterator.next().getMeterId().getValue().longValue());
}
@Test
final RpcResult<ProcessFlatBatchOutput> rpcResult = FlatBatchMeterAdapters
.convertBatchMeterResult(3).apply(input);
+ Iterator<BatchFailure> iterator = rpcResult.getResult().nonnullBatchFailure().values().iterator();
Assert.assertFalse(rpcResult.isSuccessful());
Assert.assertEquals(1, rpcResult.getErrors().size());
- Assert.assertEquals(2, rpcResult.getResult().getBatchFailure().size());
- Assert.assertEquals(3, rpcResult.getResult().getBatchFailure().get(0).getBatchOrder().intValue());
- Assert.assertEquals(4, rpcResult.getResult().getBatchFailure().get(1).getBatchOrder().intValue());
- Assert.assertEquals(2L, ((FlatBatchFailureMeterIdCase) rpcResult.getResult().getBatchFailure().get(1)
+ Assert.assertEquals(2, rpcResult.getResult().nonnullBatchFailure().size());
+ Assert.assertEquals(3, iterator.next().getBatchOrder().intValue());
+ BatchFailure secondBatchFailure = iterator.next();
+ Assert.assertEquals(4, secondBatchFailure.getBatchOrder().intValue());
+ Assert.assertEquals(2L, ((FlatBatchFailureMeterIdCase) secondBatchFailure
.getBatchItemIdChoice()).getMeterId().getValue().longValue());
}
Assert.assertTrue(rpcResult.isSuccessful());
Assert.assertEquals(0, rpcResult.getErrors().size());
- Assert.assertEquals(0, rpcResult.getResult().getBatchFailure().size());
+ Assert.assertEquals(0, rpcResult.getResult().nonnullBatchFailure().size());
}
private BatchFailedMetersOutput createBatchFailedMetersOutput(final Integer batchOrder, final long groupIdValue) {
private SalExperimenterMpMessageServiceImpl salExperimenterMpMessageService;
@Override
- @SuppressWarnings("unchecked")
protected void setup() {
this.<List<MultipartReply>>mockSuccessfulFuture();
import com.google.common.util.concurrent.ListenableFuture;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Future;
import org.junit.After;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.Batch;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.BatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.BatchKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchAddFlowCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchAddGroupCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchAddMeterCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateMeterCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlowKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.group._case.FlatBatchAddGroupBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.meter._case.FlatBatchAddMeterBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.flow._case.FlatBatchRemoveFlowBuilder;
createGroupRemoveBatch(4, 2L),
createGroupUpdateBatch(5, 3L),
- createMeterAddBatch(3, 1L),
- createMeterRemoveBatch(4, 2L),
- createMeterUpdateBatch(5, 3L)
+ createMeterAddBatch(6, 1L),
+ createMeterRemoveBatch(7, 2L),
+ createMeterUpdateBatch(8, 3L)
))
.setExitOnFirstError(true)
.build();
final RpcResult<ProcessFlatBatchOutput> rpcResult = rpcResultFuture.get();
Assert.assertTrue(rpcResult.isSuccessful());
Assert.assertTrue(rpcResult.getErrors().isEmpty());
- Assert.assertTrue(rpcResult.getResult().getBatchFailure().isEmpty());
+ Assert.assertTrue(rpcResult.getResult().nonnullBatchFailure().isEmpty());
final InOrder inOrder = Mockito.inOrder(salFlowsBatchService, salGroupsBatchService, salMetersBatchService);
inOrder.verify(salFlowsBatchService).addFlowsBatch(ArgumentMatchers.any());
final RpcResult<ProcessFlatBatchOutput> rpcResult = rpcResultFuture.get();
Assert.assertFalse(rpcResult.isSuccessful());
Assert.assertEquals(1, rpcResult.getErrors().size());
- Assert.assertEquals(1, rpcResult.getResult().getBatchFailure().size());
- Assert.assertEquals(3, rpcResult.getResult().getBatchFailure().get(0).getBatchOrder().intValue());
+ Assert.assertEquals(1, rpcResult.getResult().nonnullBatchFailure().size());
+ Assert.assertEquals(3, rpcResult.getResult().nonnullBatchFailure().values().iterator().next()
+ .getBatchOrder().intValue());
final InOrder inOrder = Mockito.inOrder(salFlowsBatchService, salGroupsBatchService, salMetersBatchService);
inOrder.verify(salFlowsBatchService).addFlowsBatch(ArgumentMatchers.any());
final RpcResult<ProcessFlatBatchOutput> rpcResult = rpcResultFuture.get();
Assert.assertFalse(rpcResult.isSuccessful());
Assert.assertEquals(1, rpcResult.getErrors().size());
- Assert.assertEquals(1, rpcResult.getResult().getBatchFailure().size());
- Assert.assertEquals(3, rpcResult.getResult().getBatchFailure().get(0).getBatchOrder().intValue());
+ Assert.assertEquals(1, rpcResult.getResult().nonnullBatchFailure().size());
+ Assert.assertEquals(3, rpcResult.getResult().nonnullBatchFailure().values().iterator().next()
+ .getBatchOrder().intValue());
final InOrder inOrder = Mockito.inOrder(salFlowsBatchService, salGroupsBatchService, salMetersBatchService);
inOrder.verify(salFlowsBatchService).addFlowsBatch(ArgumentMatchers.any());
return createFlowAddBatch(batchOrder, flowIdValue, 1);
}
- private Batch createFlowAddBatch(final int batchOrder, final String flowIdValue, int amount) {
+ private Batch createFlowAddBatch(final int batchOrder, final String flowIdValue, final int amount) {
return new BatchBuilder()
.setBatchOrder(batchOrder)
.setBatchChoice(new FlatBatchAddFlowCaseBuilder()
- .setFlatBatchAddFlow(repeatInList(new FlatBatchAddFlowBuilder()
- .setFlowId(new FlowId(flowIdValue))
- .build(), amount))
+ .setFlatBatchAddFlow(repeatFlatBatchAddFlowInList(flowIdValue, amount))
.build())
.build();
}
+ private List<FlatBatchAddFlow> repeatFlatBatchAddFlowInList(final String flowIdValue, final int amount) {
+ final List<FlatBatchAddFlow> list = new ArrayList<>();
+ for (int i = 0; i < amount; i++) {
+ list.add(new FlatBatchAddFlowBuilder()
+ .setFlowId(new FlowId(flowIdValue + i))
+ .withKey(new FlatBatchAddFlowKey(i))
+ .build());
+ }
+ return list;
+ }
+
private <T> List<T> repeatInList(final T item, final int amount) {
final List<T> list = new ArrayList<>();
for (int i = 0; i < amount; i++) {
private Batch createFlowUpdateBatch(final int batchOrder, final String flowIdValue) {
return new BatchBuilder()
.setBatchOrder(batchOrder)
+ .withKey(new BatchKey(batchOrder))
.setBatchChoice(new FlatBatchUpdateFlowCaseBuilder()
.setFlatBatchUpdateFlow(Collections.singletonList(new FlatBatchUpdateFlowBuilder()
.setFlowId(new FlowId(flowIdValue))
final RpcResult<ProcessFlatBatchOutput> rpcResult = rpcResultFuture.get();
Assert.assertFalse(rpcResult.isSuccessful());
Assert.assertEquals(1, rpcResult.getErrors().size());
- Assert.assertEquals(2, rpcResult.getResult().getBatchFailure().size());
+ Assert.assertEquals(2, rpcResult.getResult().nonnullBatchFailure().size());
+ Iterator<BatchFailure> iterator = rpcResult.getResult().nonnullBatchFailure().values().iterator();
+ //Moving iterator two get second element
+ iterator.next();
Assert.assertEquals("f2",
- ((FlatBatchFailureFlowIdCase) rpcResult.getResult().getBatchFailure().get(1).getBatchItemIdChoice())
+ ((FlatBatchFailureFlowIdCase) iterator.next().getBatchItemIdChoice())
.getFlowId().getValue());
}
.build();
}
- private ProcessFlatBatchOutput createFlatBatchOutput(BatchFailure... batchFailures) {
+ private ProcessFlatBatchOutput createFlatBatchOutput(final BatchFailure... batchFailures) {
return new ProcessFlatBatchOutputBuilder()
.setBatchFailure(Lists.newArrayList(batchFailures))
.build();
@Test
public void testPrepareBatchPlan_success() throws Exception {
- final FlatBatchAddFlow flatBatchAddFlow = new FlatBatchAddFlowBuilder()
+ final FlatBatchAddFlow flatBatchAddFlow_1 = new FlatBatchAddFlowBuilder()
.setFlowId(new FlowId("f1"))
.build();
+ final FlatBatchAddFlow flatBatchAddFlow_2 = new FlatBatchAddFlowBuilder()
+ .setFlowId(new FlowId("f2"))
+ .build();
final BatchPlanStep batchPlanStep = new BatchPlanStep(BatchStepType.FLOW_ADD);
- batchPlanStep.getTaskBag().addAll(Lists.newArrayList(flatBatchAddFlow, flatBatchAddFlow));
+ batchPlanStep.getTaskBag().addAll(Lists.newArrayList(flatBatchAddFlow_1, flatBatchAddFlow_2));
final List<BatchPlanStep> batchPlan = Lists.newArrayList(batchPlanStep);
final List<BatchStepJob> batchChain = salFlatBatchService.prepareBatchChain(batchPlan, NODE_REF, true);
final RpcResult<ProcessFlatBatchOutput> rpcResult = rpcResultFuture.get();
Assert.assertTrue(rpcResult.isSuccessful());
Assert.assertEquals(0, rpcResult.getErrors().size());
- Assert.assertEquals(0, rpcResult.getResult().getBatchFailure().size());
+ Assert.assertEquals(0, rpcResult.getResult().nonnullBatchFailure().size());
Mockito.verify(salFlowsBatchService).addFlowsBatch(ArgumentMatchers.any());
}
@Test
public void testPrepareBatchPlan_failure() throws Exception {
- final FlatBatchAddFlow flatBatchAddFlow = new FlatBatchAddFlowBuilder()
+ final FlatBatchAddFlow flatBatchAddFlow_1 = new FlatBatchAddFlowBuilder()
.setFlowId(new FlowId("f1"))
.build();
+ final FlatBatchAddFlow flatBatchAddFlow_2 = new FlatBatchAddFlowBuilder()
+ .setFlowId(new FlowId("f2"))
+ .build();
final BatchPlanStep batchPlanStep = new BatchPlanStep(BatchStepType.FLOW_ADD);
- batchPlanStep.getTaskBag().addAll(Lists.newArrayList(flatBatchAddFlow, flatBatchAddFlow));
+ batchPlanStep.getTaskBag().addAll(Lists.newArrayList(flatBatchAddFlow_1, flatBatchAddFlow_2));
final List<BatchPlanStep> batchPlan = Lists.newArrayList(batchPlanStep, batchPlanStep);
package org.opendaylight.openflowplugin.impl.services.sal;
import com.google.common.collect.Lists;
+import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Future;
import org.junit.After;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.add.flows.batch.input.BatchAddFlowsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.input.update.grouping.OriginalBatchedFlowBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.input.update.grouping.UpdatedBatchedFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.output.list.grouping.BatchFailedFlowsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.remove.flows.batch.input.BatchRemoveFlows;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.remove.flows.batch.input.BatchRemoveFlowsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.update.flows.batch.input.BatchUpdateFlows;
final RpcResult<RemoveFlowsBatchOutput> rpcResult = resultFuture.get();
Assert.assertTrue(rpcResult.isSuccessful());
final RemoveFlowsBatchOutput result = rpcResult.getResult();
- Assert.assertEquals(0, result.getBatchFailedFlowsOutput().size());
+ Assert.assertEquals(0, result.nonnullBatchFailedFlowsOutput().size());
final InOrder inOrder = Mockito.inOrder(salFlowService, transactionService);
final RpcResult<RemoveFlowsBatchOutput> rpcResult = resultFuture.get();
Assert.assertFalse(rpcResult.isSuccessful());
final RemoveFlowsBatchOutput result = rpcResult.getResult();
- Assert.assertEquals(2, result.getBatchFailedFlowsOutput().size());
- Assert.assertEquals(FLOW_ID_VALUE_1, result.getBatchFailedFlowsOutput().get(0).getFlowId().getValue());
- Assert.assertEquals(FLOW_ID_VALUE_2, result.getBatchFailedFlowsOutput().get(1).getFlowId().getValue());
+ Iterator<BatchFailedFlowsOutput> iterator = result.nonnullBatchFailedFlowsOutput().values().iterator();
+ Assert.assertEquals(2, result.nonnullBatchFailedFlowsOutput().size());
+ Assert.assertEquals(FLOW_ID_VALUE_1, iterator.next().getFlowId().getValue());
+ Assert.assertEquals(FLOW_ID_VALUE_2, iterator.next().getFlowId().getValue());
final InOrder inOrder = Mockito.inOrder(salFlowService, transactionService);
.build();
final Future<RpcResult<AddFlowsBatchOutput>> resultFuture = salFlowsBatchService.addFlowsBatch(input);
+ Iterator<BatchFailedFlowsOutput> iterator = resultFuture.get().getResult().nonnullBatchFailedFlowsOutput()
+ .values().iterator();
Assert.assertTrue(resultFuture.isDone());
Assert.assertFalse(resultFuture.get().isSuccessful());
- Assert.assertEquals(2, resultFuture.get().getResult().getBatchFailedFlowsOutput().size());
- Assert.assertEquals(FLOW_ID_VALUE_1,
- resultFuture.get().getResult().getBatchFailedFlowsOutput().get(0).getFlowId().getValue());
- Assert.assertEquals(FLOW_ID_VALUE_2,
- resultFuture.get().getResult().getBatchFailedFlowsOutput().get(1).getFlowId().getValue());
+ Assert.assertEquals(2, resultFuture.get().getResult().nonnullBatchFailedFlowsOutput().size());
+ Assert.assertEquals(FLOW_ID_VALUE_1, iterator.next().getFlowId().getValue());
+ Assert.assertEquals(FLOW_ID_VALUE_2, iterator.next().getFlowId().getValue());
Assert.assertEquals(2, resultFuture.get().getErrors().size());
final InOrder inOrder = Mockito.inOrder(salFlowService, transactionService);
.build();
final Future<RpcResult<UpdateFlowsBatchOutput>> resultFuture = salFlowsBatchService.updateFlowsBatch(input);
+ Iterator<BatchFailedFlowsOutput> iterator = resultFuture.get().getResult().nonnullBatchFailedFlowsOutput()
+ .values().iterator();
Assert.assertTrue(resultFuture.isDone());
Assert.assertFalse(resultFuture.get().isSuccessful());
Assert.assertFalse(resultFuture.get().isSuccessful());
- Assert.assertEquals(2, resultFuture.get().getResult().getBatchFailedFlowsOutput().size());
- Assert.assertEquals(FLOW_ID_VALUE_1,
- resultFuture.get().getResult().getBatchFailedFlowsOutput().get(0).getFlowId().getValue());
- Assert.assertEquals(FLOW_ID_VALUE_2,
- resultFuture.get().getResult().getBatchFailedFlowsOutput().get(1).getFlowId().getValue());
+ Assert.assertEquals(2, resultFuture.get().getResult().nonnullBatchFailedFlowsOutput().size());
+ Assert.assertEquals(FLOW_ID_VALUE_1, iterator.next().getFlowId().getValue());
+ Assert.assertEquals(FLOW_ID_VALUE_2, iterator.next().getFlowId().getValue());
Assert.assertEquals(2, resultFuture.get().getErrors().size());
final InOrder inOrder = Mockito.inOrder(salFlowService, transactionService);
package org.opendaylight.openflowplugin.impl.services.sal;
import com.google.common.collect.Lists;
+import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Future;
import org.junit.After;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.add.groups.batch.input.BatchAddGroupsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.batch.group.input.update.grouping.OriginalBatchedGroupBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.batch.group.input.update.grouping.UpdatedBatchedGroupBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.batch.group.output.list.grouping.BatchFailedGroupsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.remove.groups.batch.input.BatchRemoveGroups;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.remove.groups.batch.input.BatchRemoveGroupsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.update.groups.batch.input.BatchUpdateGroups;
.build();
final Future<RpcResult<UpdateGroupsBatchOutput>> resultFuture = salGroupsBatchService.updateGroupsBatch(input);
+ Iterator<BatchFailedGroupsOutput> iterator = resultFuture.get().getResult().nonnullBatchFailedGroupsOutput()
+ .values().iterator();
Assert.assertTrue(resultFuture.isDone());
Assert.assertFalse(resultFuture.get().isSuccessful());
- Assert.assertEquals(2, resultFuture.get().getResult().getBatchFailedGroupsOutput().size());
- Assert.assertEquals(43L,
- resultFuture.get().getResult().getBatchFailedGroupsOutput().get(0).getGroupId().getValue().longValue());
- Assert.assertEquals(45L,
- resultFuture.get().getResult().getBatchFailedGroupsOutput().get(1).getGroupId().getValue().longValue());
+ Assert.assertEquals(2, resultFuture.get().getResult().nonnullBatchFailedGroupsOutput().size());
+ Assert.assertEquals(43L, iterator.next().getGroupId().getValue().longValue());
+ Assert.assertEquals(45L, iterator.next().getGroupId().getValue().longValue());
Assert.assertEquals(2, resultFuture.get().getErrors().size());
.build();
final Future<RpcResult<AddGroupsBatchOutput>> resultFuture = salGroupsBatchService.addGroupsBatch(input);
+ Iterator<BatchFailedGroupsOutput> iterator = resultFuture.get().getResult().nonnullBatchFailedGroupsOutput()
+ .values().iterator();
Assert.assertTrue(resultFuture.isDone());
Assert.assertFalse(resultFuture.get().isSuccessful());
- Assert.assertEquals(2, resultFuture.get().getResult().getBatchFailedGroupsOutput().size());
- Assert.assertEquals(42L,
- resultFuture.get().getResult().getBatchFailedGroupsOutput().get(0).getGroupId().getValue().longValue());
- Assert.assertEquals(43L,
- resultFuture.get().getResult().getBatchFailedGroupsOutput().get(1).getGroupId().getValue().longValue());
+ Assert.assertEquals(2, resultFuture.get().getResult().nonnullBatchFailedGroupsOutput().size());
+ Assert.assertEquals(42L, iterator.next().getGroupId().getValue().longValue());
+ Assert.assertEquals(43L, iterator.next().getGroupId().getValue().longValue());
Assert.assertEquals(2, resultFuture.get().getErrors().size());
.build();
final Future<RpcResult<RemoveGroupsBatchOutput>> resultFuture = salGroupsBatchService.removeGroupsBatch(input);
+ Iterator<BatchFailedGroupsOutput> iterator = resultFuture.get().getResult().nonnullBatchFailedGroupsOutput()
+ .values().iterator();
Assert.assertTrue(resultFuture.isDone());
Assert.assertFalse(resultFuture.get().isSuccessful());
- Assert.assertEquals(2, resultFuture.get().getResult().getBatchFailedGroupsOutput().size());
- Assert.assertEquals(42L,
- resultFuture.get().getResult().getBatchFailedGroupsOutput().get(0).getGroupId().getValue().longValue());
- Assert.assertEquals(43L,
- resultFuture.get().getResult().getBatchFailedGroupsOutput().get(1).getGroupId().getValue().longValue());
+ Assert.assertEquals(2, resultFuture.get().getResult().nonnullBatchFailedGroupsOutput().size());
+ Assert.assertEquals(42L, iterator.next().getGroupId().getValue().longValue());
+ Assert.assertEquals(43L, iterator.next().getGroupId().getValue().longValue());
Assert.assertEquals(2, resultFuture.get().getErrors().size());
final InOrder inOrder = Mockito.inOrder(salGroupService, transactionService);
import static org.mockito.ArgumentMatchers.any;
import com.google.common.collect.Lists;
+import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Future;
import org.junit.After;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.add.meters.batch.input.BatchAddMetersBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.input.update.grouping.OriginalBatchedMeterBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.input.update.grouping.UpdatedBatchedMeterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.output.list.grouping.BatchFailedMetersOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.remove.meters.batch.input.BatchRemoveMeters;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.remove.meters.batch.input.BatchRemoveMetersBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.update.meters.batch.input.BatchUpdateMeters;
.build();
final Future<RpcResult<UpdateMetersBatchOutput>> resultFuture = salMetersBatchService.updateMetersBatch(input);
+ Iterator<BatchFailedMetersOutput> iterator = resultFuture.get().getResult().nonnullBatchFailedMetersOutput()
+ .values().iterator();
Assert.assertTrue(resultFuture.isDone());
Assert.assertFalse(resultFuture.get().isSuccessful());
- Assert.assertEquals(2, resultFuture.get().getResult().getBatchFailedMetersOutput().size());
- Assert.assertEquals(43L,
- resultFuture.get().getResult().getBatchFailedMetersOutput().get(0).getMeterId().getValue().longValue());
- Assert.assertEquals(45L,
- resultFuture.get().getResult().getBatchFailedMetersOutput().get(1).getMeterId().getValue().longValue());
+ Assert.assertEquals(2, resultFuture.get().getResult().nonnullBatchFailedMetersOutput().size());
+ Assert.assertEquals(43L, iterator.next().getMeterId().getValue().longValue());
+ Assert.assertEquals(45L,iterator.next().getMeterId().getValue().longValue());
Assert.assertEquals(2, resultFuture.get().getErrors().size());
.build();
final Future<RpcResult<AddMetersBatchOutput>> resultFuture = salMetersBatchService.addMetersBatch(input);
+ Iterator<BatchFailedMetersOutput> iterator = resultFuture.get().getResult().nonnullBatchFailedMetersOutput()
+ .values().iterator();
Assert.assertTrue(resultFuture.isDone());
Assert.assertFalse(resultFuture.get().isSuccessful());
- Assert.assertEquals(2, resultFuture.get().getResult().getBatchFailedMetersOutput().size());
- Assert.assertEquals(42L,
- resultFuture.get().getResult().getBatchFailedMetersOutput().get(0).getMeterId().getValue().longValue());
- Assert.assertEquals(43L,
- resultFuture.get().getResult().getBatchFailedMetersOutput().get(1).getMeterId().getValue().longValue());
+ Assert.assertEquals(2, resultFuture.get().getResult().nonnullBatchFailedMetersOutput().size());
+ Assert.assertEquals(42L, iterator.next().getMeterId().getValue().longValue());
+ Assert.assertEquals(43L,iterator.next().getMeterId().getValue().longValue());
Assert.assertEquals(2, resultFuture.get().getErrors().size());
.build();
final Future<RpcResult<RemoveMetersBatchOutput>> resultFuture = salMetersBatchService.removeMetersBatch(input);
+ Iterator<BatchFailedMetersOutput> iterator = resultFuture.get().getResult().nonnullBatchFailedMetersOutput()
+ .values().iterator();
Assert.assertTrue(resultFuture.isDone());
Assert.assertFalse(resultFuture.get().isSuccessful());
- Assert.assertEquals(2, resultFuture.get().getResult().getBatchFailedMetersOutput().size());
- Assert.assertEquals(42L,
- resultFuture.get().getResult().getBatchFailedMetersOutput().get(0).getMeterId().getValue().longValue());
- Assert.assertEquals(43L,
- resultFuture.get().getResult().getBatchFailedMetersOutput().get(1).getMeterId().getValue().longValue());
+ Assert.assertEquals(2, resultFuture.get().getResult().nonnullBatchFailedMetersOutput().size());
+ Assert.assertEquals(42L, iterator.next().getMeterId().getValue().longValue());
+ Assert.assertEquals(43L, iterator.next().getMeterId().getValue().longValue());
Assert.assertEquals(2, resultFuture.get().getErrors().size());
final InOrder inOrder = Mockito.inOrder(salMeterService, transactionService);
final MultipartRequestTableFeatures result = (MultipartRequestTableFeatures) ((MultipartRequest) ofHeader)
.getMultipartRequestBody();
- assertEquals(MAX_ENTRIES, result.getTableFeatures().get(0).getMaxEntries().longValue());
+ assertEquals(MAX_ENTRIES, result.nonnullTableFeatures().values().iterator().next().getMaxEntries().longValue());
}
@Test
import com.google.common.collect.Lists;
import java.util.Collections;
-import java.util.List;
+import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupStatisticsReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStatsKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.AggregateFlowStatistics;
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.GroupType;
org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsAndPortNumberMap
nodeConnectorStatisticsUpdate = (org.opendaylight.yang.gen.v1.urn
.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsAndPortNumberMap) dataObject;
- List<NodeConnectorStatisticsAndPortNumberMap> nodeConnectorStatisticsAndPortNumberMaps =
- nodeConnectorStatisticsUpdate.getNodeConnectorStatisticsAndPortNumberMap();
+ var nodeConnectorStatisticsAndPortNumberMaps =
+ nodeConnectorStatisticsUpdate.nonnullNodeConnectorStatisticsAndPortNumberMap();
assertEquals(1, nodeConnectorStatisticsAndPortNumberMaps.size());
NodeConnectorStatisticsAndPortNumberMap nodeConnectorStatisticsAndPortNumberMap =
- nodeConnectorStatisticsAndPortNumberMaps.get(0);
+ nodeConnectorStatisticsAndPortNumberMaps.values().iterator().next();
assertEquals("openflow:" + DUMMY_DATAPATH_ID + ":" + DUMMY_PORT_NO,
nodeConnectorStatisticsAndPortNumberMap.getNodeConnectorId().getValue());
assertEquals(DUMMY_RX_BYTES, nodeConnectorStatisticsAndPortNumberMap.getBytes().getReceived());
DataContainer dataObject = validateOutput(result);
assertTrue(dataObject instanceof GroupStatisticsReply);
GroupStatisticsReply groupStatisticsUpdate = (GroupStatisticsReply)dataObject;
- List<org.opendaylight.yang.gen.v1.urn
- .opendaylight.group.types.rev131018.group.statistics.reply.GroupStats> groupStats =
- groupStatisticsUpdate.getGroupStats();
+ var groupStats = groupStatisticsUpdate.nonnullGroupStats();
assertEquals(1, groupStats.size());
- org.opendaylight.yang.gen.v1.urn
- .opendaylight.group.types.rev131018.group.statistics.reply.GroupStats groupStat = groupStats.get(0);
+ var groupStat = groupStats.values().iterator().next();
assertEquals(DUMMY_BYTE_COUNT, groupStat.getByteCount().getValue());
assertEquals(DUMMY_DURATION_SEC, groupStat.getDuration().getSecond().getValue());
DataContainer dataObject = validateOutput(result);
assertTrue(dataObject instanceof GroupDescStatsReply);
GroupDescStatsReply groupStatistics = (GroupDescStatsReply) dataObject;
- List<GroupDescStats> groupDescStats = groupStatistics.getGroupDescStats();
+ Map<GroupDescStatsKey, GroupDescStats> groupDescStats = groupStatistics.nonnullGroupDescStats();
assertEquals(1, groupDescStats.size());
- GroupDescStats groupDescStat = groupDescStats.get(0);
+ GroupDescStats groupDescStat = groupDescStats.values().iterator().next();
assertEquals(DUMMY_GROUP_ID.getValue(),groupDescStat.getGroupId().getValue());
assertEquals(DUMMY_GROUPS_TYPE,groupDescStat.getGroupType());
}
import java.math.BigInteger;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowAndStatisticsMap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
when(reply.getMultipartReplyBody()).thenReturn(flowCase);
final GetFlowStatisticsOutput output = service.buildReply(input, true);
- assertTrue(output.getFlowAndStatisticsMapList().size() > 0);
+ assertTrue(output.nonnullFlowAndStatisticsMapList().size() > 0);
- final FlowAndStatisticsMap stats = output.getFlowAndStatisticsMapList().get(0);
+ final FlowAndStatisticsMap stats = output.nonnullFlowAndStatisticsMapList().values().iterator().next();
assertEquals(stats.getTableId(), TABLE_NO);
}
when(stat.getTableId()).thenReturn(TABLE_NO);
when(stat.getMatch()).thenReturn(new MatchBuilder().build());
- final List<FlowAndStatisticsMapList> stats = Collections.singletonList(stat);
+ final Map<FlowAndStatisticsMapListKey, FlowAndStatisticsMapList> stats
+ = Collections.singletonMap(stat.key(), stat);
final GetFlowStatisticsOutput output = mock(GetFlowStatisticsOutput.class);
- when(output.getFlowAndStatisticsMapList()).thenReturn(stats);
+ when(output.nonnullFlowAndStatisticsMapList()).thenReturn(stats);
multipartWriterProvider.lookup(MultipartType.OFPMPFLOW).get().write(output, true);
verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any());
assertTrue(output.getGroupStats().size() > 0);
final org.opendaylight.yang.gen.v1.urn
- .opendaylight.group.types.rev131018.group.statistics.reply.GroupStats stats = output.getGroupStats().get(0);
+ .opendaylight.group.types.rev131018.group.statistics.reply.GroupStats stats =
+ output.nonnullGroupStats().values().iterator().next();
assertEquals(stats.getGroupId().getValue(), GROUP_NO);
}
@Override
public void testStoreStatistics() {
- final org.opendaylight.yang.gen.v1.urn
- .opendaylight.group.types.rev131018.group.statistics.reply.GroupStats stat =
- mock(org.opendaylight.yang.gen.v1.urn
- .opendaylight.group.types.rev131018.group.statistics.reply.GroupStats.class);
- when(stat.getGroupId()).thenReturn(new GroupId(GROUP_NO));
-
- final List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply
- .GroupStats>
- stats = Collections.singletonList(stat);
+ final var stat = new org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply
+ .GroupStatsBuilder().setGroupId(new GroupId(GROUP_NO)).build();
+
final GetGroupStatisticsOutput output = mock(GetGroupStatisticsOutput.class);
- when(output.getGroupStats()).thenReturn(stats);
+ when(output.nonnullGroupStats()).thenReturn(Collections.singletonMap(stat.key(), stat));
multipartWriterProvider.lookup(MultipartType.OFPMPGROUP).get().write(output, true);
verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any());
import java.math.BigInteger;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
import org.opendaylight.openflowplugin.impl.statistics.services.direct.AbstractDirectStatisticsServiceTest;
import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetMeterStatisticsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetMeterStatisticsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsKey;
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;
when(reply.getMultipartReplyBody()).thenReturn(MeterCase);
final GetMeterStatisticsOutput output = service.buildReply(input, true);
- assertTrue(output.getMeterStats().size() > 0);
+ assertTrue(output.nonnullMeterStats().size() > 0);
final org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats
- stats = output.getMeterStats().get(0);
+ stats = output.nonnullMeterStats().values().iterator().next();
assertEquals(stats.getMeterId().getValue(), METER_NO);
}
= mock(
org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats
.class);
+ when(stat.key()).thenReturn(new MeterStatsKey(new MeterId(METER_NO)));
when(stat.getMeterId()).thenReturn(new MeterId(METER_NO));
- final List<org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply
- .MeterStats>
- stats = Collections.singletonList(stat);
+ final Map<MeterStatsKey,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats>
+ stats = Collections.singletonMap(stat.key(), stat);
final GetMeterStatisticsOutput output = mock(GetMeterStatisticsOutput.class);
- when(output.getMeterStats()).thenReturn(stats);
+ when(output.nonnullMeterStats()).thenReturn(stats);
multipartWriterProvider.lookup(MultipartType.OFPMPMETER).get().write(output, true);
verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any());
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
import org.opendaylight.openflowplugin.impl.statistics.services.direct.AbstractDirectStatisticsServiceTest;
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.multipart.request.port.stats._case.MultipartRequestPortStats;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapKey;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.common.Uint64;
assertTrue(output.getNodeConnectorStatisticsAndPortNumberMap().size() > 0);
final NodeConnectorStatisticsAndPortNumberMap stats =
- output.getNodeConnectorStatisticsAndPortNumberMap().get(0);
+ output.nonnullNodeConnectorStatisticsAndPortNumberMap().values().iterator().next();
assertEquals(stats.getNodeConnectorId(), nodeConnectorId);
}
@Override
public void testStoreStatistics() {
final NodeConnectorStatisticsAndPortNumberMap stat = mock(NodeConnectorStatisticsAndPortNumberMap.class);
+ when(stat.key()).thenReturn(new NodeConnectorStatisticsAndPortNumberMapKey(nodeConnectorId));
when(stat.getNodeConnectorId()).thenReturn(nodeConnectorId);
- final List<NodeConnectorStatisticsAndPortNumberMap> stats = Collections.singletonList(stat);
+ final Map<NodeConnectorStatisticsAndPortNumberMapKey, NodeConnectorStatisticsAndPortNumberMap> stats
+ = Collections.singletonMap(stat.key(), stat);
final GetNodeConnectorStatisticsOutput output = mock(GetNodeConnectorStatisticsOutput.class);
- when(output.getNodeConnectorStatisticsAndPortNumberMap()).thenReturn(stats);
+ when(output.nonnullNodeConnectorStatisticsAndPortNumberMap()).thenReturn(stats);
multipartWriterProvider.lookup(MultipartType.OFPMPPORTSTATS).get().write(output, true);
verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any());
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import org.junit.Test;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
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.multipart.request.queue._case.MultipartRequestQueue;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapKey;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.common.Uint64;
when(queueStat.getDurationNsec()).thenReturn(Uint32.ZERO);
final GetQueueStatisticsOutput output = service.buildReply(input, true);
- assertTrue(output.getQueueIdAndStatisticsMap().size() > 0);
+ assertTrue(output.nonnullQueueIdAndStatisticsMap().size() > 0);
- final QueueIdAndStatisticsMap map = output.getQueueIdAndStatisticsMap().get(0);
+ final QueueIdAndStatisticsMap map = output.nonnullQueueIdAndStatisticsMap().values().iterator().next();
assertEquals(map.getQueueId().getValue(), QUEUE_NO);
assertEquals(map.getNodeConnectorId(), nodeConnectorId);
}
final QueueIdAndStatisticsMap map = mock(QueueIdAndStatisticsMap.class);
when(map.getQueueId()).thenReturn(new QueueId(QUEUE_NO));
when(map.getNodeConnectorId()).thenReturn(new NodeConnectorId("1"));
+ when(map.key()).thenReturn(new QueueIdAndStatisticsMapKey(new NodeConnectorId("1"), new QueueId(QUEUE_NO)));
- final List<QueueIdAndStatisticsMap> maps = Collections.singletonList(map);
+ final Map<QueueIdAndStatisticsMapKey, QueueIdAndStatisticsMap> maps
+ = Collections.singletonMap(map.key(), map);
final GetQueueStatisticsOutput output = mock(GetQueueStatisticsOutput.class);
- when(output.getQueueIdAndStatisticsMap()).thenReturn(maps);
+ when(output.nonnullQueueIdAndStatisticsMap()).thenReturn(maps);
multipartWriterProvider.lookup(MultipartType.OFPMPQUEUE).get().write(output, true);
verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any());
final QueueIdAndStatisticsMap map = mock(QueueIdAndStatisticsMap.class);
when(map.getQueueId()).thenReturn(new QueueId(QUEUE_NO));
when(map.getNodeConnectorId()).thenReturn(new NodeConnectorId("openflow:1:1"));
+ when(map.key()).thenReturn(new QueueIdAndStatisticsMapKey(new NodeConnectorId("openflow:1:1"),
+ new QueueId(QUEUE_NO)));
- final List<QueueIdAndStatisticsMap> maps = Collections.singletonList(map);
+ final Map<QueueIdAndStatisticsMapKey, QueueIdAndStatisticsMap> maps
+ = Collections.singletonMap(map.key(), map);
final GetQueueStatisticsOutput output = mock(GetQueueStatisticsOutput.class);
- when(output.getQueueIdAndStatisticsMap()).thenReturn(maps);
+ when(output.nonnullQueueIdAndStatisticsMap()).thenReturn(maps);
multipartWriterProvider.lookup(MultipartType.OFPMPQUEUE).get().write(output, true);
verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any());
import java.math.BigInteger;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowAndStatisticsMap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.multipart.reply.multipart.reply.body.MultipartReplyFlowStatsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
final GetFlowStatisticsOutput output = service.buildReply(input, true);
assertTrue(output.getFlowAndStatisticsMapList().size() > 0);
- final FlowAndStatisticsMap stats = output.getFlowAndStatisticsMapList().get(0);
+ final FlowAndStatisticsMap stats = output.nonnullFlowAndStatisticsMapList().values().iterator().next();
assertEquals(stats.getTableId(), TABLE_NO);
}
when(stat.getTableId()).thenReturn(TABLE_NO);
when(stat.getMatch()).thenReturn(new MatchBuilder().build());
- final List<FlowAndStatisticsMapList> stats = Collections.singletonList(stat);
+ final Map<FlowAndStatisticsMapListKey, FlowAndStatisticsMapList> stats
+ = Collections.singletonMap(stat.key(), stat);
final GetFlowStatisticsOutput output = mock(GetFlowStatisticsOutput.class);
- when(output.getFlowAndStatisticsMapList()).thenReturn(stats);
+ when(output.nonnullFlowAndStatisticsMapList()).thenReturn(stats);
multipartWriterProvider.lookup(MultipartType.OFPMPFLOW).get().write(output, true);
verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any());
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
import org.opendaylight.openflowplugin.impl.statistics.services.direct.AbstractDirectStatisticsServiceTest;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStatsKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReplyBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartRequest;
final List<MultipartReply> input = Collections.singletonList(reply);
final GetGroupStatisticsOutput output = service.buildReply(input, true);
- assertTrue(output.getGroupStats().size() > 0);
+ assertTrue(output.nonnullGroupStats().size() > 0);
final org.opendaylight.yang.gen.v1.urn
- .opendaylight.group.types.rev131018.group.statistics.reply.GroupStats stats = output.getGroupStats().get(0);
+ .opendaylight.group.types.rev131018.group.statistics.reply.GroupStats stats =
+ output.nonnullGroupStats().values().iterator().next();
assertEquals(stats.getGroupId().getValue(), GROUP_NO);
}
.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats.class);
when(stat.getGroupId()).thenReturn(new GroupId(GROUP_NO));
- final List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply
- .GroupStats>
- stats = Collections.singletonList(stat);
+ final Map<GroupStatsKey, GroupStats> stats = Collections.singletonMap(stat.key(), stat);
final GetGroupStatisticsOutput output = mock(GetGroupStatisticsOutput.class);
- when(output.getGroupStats()).thenReturn(stats);
+ when(output.nonnullGroupStats()).thenReturn(stats);
multipartWriterProvider.lookup(MultipartType.OFPMPGROUP).get().write(output, true);
verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any());
import java.math.BigInteger;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
import org.opendaylight.openflowplugin.impl.statistics.services.direct.AbstractDirectStatisticsServiceTest;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.MeterBandStatsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReplyBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartRequest;
final List<MultipartReply> input = Collections.singletonList(reply);
final GetMeterStatisticsOutput output = service.buildReply(input, true);
- assertTrue(output.getMeterStats().size() > 0);
+ assertTrue(output.nonnullMeterStats().size() > 0);
- final MeterStats stats = output.getMeterStats().get(0);
+ final MeterStats stats = output.nonnullMeterStats().values().iterator().next();
assertEquals(stats.getMeterId().getValue(), METER_NO);
}
.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats.class);
when(stat.getMeterId()).thenReturn(new MeterId(METER_NO));
- final List<org.opendaylight.yang.gen.v1.urn
+ final Map<MeterStatsKey, org.opendaylight.yang.gen.v1.urn
.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats>
- stats = Collections.singletonList(stat);
+ stats = Collections.singletonMap(stat.key(), stat);
final GetMeterStatisticsOutput output = mock(GetMeterStatisticsOutput.class);
- when(output.getMeterStats()).thenReturn(stats);
+ when(output.nonnullMeterStats()).thenReturn(stats);
multipartWriterProvider.lookup(MultipartType.OFPMPMETER).get().write(output, true);
verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any());
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
import org.opendaylight.openflowplugin.impl.statistics.services.direct.AbstractDirectStatisticsServiceTest;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.multipart.request.multipart.request.body.MultipartRequestPortStats;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapKey;
import org.opendaylight.yangtools.yang.common.Uint32;
public class NodeConnectorDirectStatisticsServiceTest extends AbstractDirectStatisticsServiceTest {
final List<MultipartReply> input = Collections.singletonList(reply);
final GetNodeConnectorStatisticsOutput output = service.buildReply(input, true);
- assertTrue(output.getNodeConnectorStatisticsAndPortNumberMap().size() > 0);
+ assertTrue(output.nonnullNodeConnectorStatisticsAndPortNumberMap().size() > 0);
final NodeConnectorStatisticsAndPortNumberMap stats =
- output.getNodeConnectorStatisticsAndPortNumberMap().get(0);
+ output.nonnullNodeConnectorStatisticsAndPortNumberMap().values().iterator().next();
assertEquals(stats.getNodeConnectorId(), nodeConnectorId);
}
final NodeConnectorStatisticsAndPortNumberMap stat = mock(NodeConnectorStatisticsAndPortNumberMap.class);
when(stat.getNodeConnectorId()).thenReturn(nodeConnectorId);
- final List<NodeConnectorStatisticsAndPortNumberMap> stats = Collections.singletonList(stat);
+ final Map<NodeConnectorStatisticsAndPortNumberMapKey, NodeConnectorStatisticsAndPortNumberMap> stats
+ = Collections.singletonMap(stat.key(), stat);
final GetNodeConnectorStatisticsOutput output = mock(GetNodeConnectorStatisticsOutput.class);
- when(output.getNodeConnectorStatisticsAndPortNumberMap()).thenReturn(stats);
+ when(output.nonnullNodeConnectorStatisticsAndPortNumberMap()).thenReturn(stats);
multipartWriterProvider.lookup(MultipartType.OFPMPPORTSTATS).get().write(output, true);
verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any());
import java.math.BigInteger;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import org.junit.Test;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.multipart.request.multipart.request.body.MultipartRequestQueueStats;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapKey;
import org.opendaylight.yangtools.yang.common.Uint32;
public class QueueDirectStatisticsServiceTest extends AbstractDirectStatisticsServiceTest {
final List<MultipartReply> input = Collections.singletonList(reply);
final GetQueueStatisticsOutput output = service.buildReply(input, true);
- assertTrue(output.getQueueIdAndStatisticsMap().size() > 0);
+ assertTrue(output.nonnullQueueIdAndStatisticsMap().size() > 0);
- final QueueIdAndStatisticsMap map = output.getQueueIdAndStatisticsMap().get(0);
+ final QueueIdAndStatisticsMap map = output.nonnullQueueIdAndStatisticsMap().values().iterator().next();
assertEquals(map.getQueueId().getValue(), QUEUE_NO);
assertEquals(map.getNodeConnectorId().getValue(), PORT_NO.toString());
}
final QueueIdAndStatisticsMap map = mock(QueueIdAndStatisticsMap.class);
when(map.getQueueId()).thenReturn(new QueueId(QUEUE_NO));
when(map.getNodeConnectorId()).thenReturn(new NodeConnectorId("1"));
+ when(map.key()).thenReturn(
+ new QueueIdAndStatisticsMapKey(new NodeConnectorId("1"), new QueueId(QUEUE_NO)));
- final List<QueueIdAndStatisticsMap> maps = Collections.singletonList(map);
final GetQueueStatisticsOutput output = mock(GetQueueStatisticsOutput.class);
- when(output.getQueueIdAndStatisticsMap()).thenReturn(maps);
+ Map<QueueIdAndStatisticsMapKey, QueueIdAndStatisticsMap> stats = Collections.singletonMap(map.key(), map);
+ when(output.nonnullQueueIdAndStatisticsMap()).thenReturn(stats);
multipartWriterProvider.lookup(MultipartType.OFPMPQUEUE).get().write(output, true);
verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any());
final QueueIdAndStatisticsMap map = mock(QueueIdAndStatisticsMap.class);
when(map.getQueueId()).thenReturn(new QueueId(QUEUE_NO));
when(map.getNodeConnectorId()).thenReturn(new NodeConnectorId("openflow:1:1"));
+ when(map.key()).thenReturn(
+ new QueueIdAndStatisticsMapKey(new NodeConnectorId("openflow:1:1"), new QueueId(QUEUE_NO)));
- final List<QueueIdAndStatisticsMap> maps = Collections.singletonList(map);
+ final Map<QueueIdAndStatisticsMapKey, QueueIdAndStatisticsMap> maps = Collections.singletonMap(map.key(), map);
final GetQueueStatisticsOutput output = mock(GetQueueStatisticsOutput.class);
- when(output.getQueueIdAndStatisticsMap()).thenReturn(maps);
+ when(output.nonnullQueueIdAndStatisticsMap()).thenReturn(maps);
multipartWriterProvider.lookup(MultipartType.OFPMPQUEUE).get().write(output, true);
verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any());
* 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.translator;
import org.junit.Assert;
Assert.assertEquals(portFeatures, nodeConnector.getPeerFeatures());
Assert.assertEquals(portFeatures, nodeConnector.getSupported());
Assert.assertEquals(portStateBld.build(), nodeConnector.getState());
- Assert.assertTrue(nodeConnector.getQueue().isEmpty());
+ Assert.assertNull(nodeConnector.getQueue());
}
- private void commonCheck(FlowCapableNodeConnector nodeConnector) {
+ private static void commonCheck(final FlowCapableNodeConnector nodeConnector) {
Assert.assertEquals(84L, nodeConnector.getCurrentSpeed().longValue());
Assert.assertEquals(84L * 2, nodeConnector.getMaximumSpeed().longValue());
Assert.assertEquals("utPortName:21", nodeConnector.getName());
Assert.assertNull(nodeConnector.getQueue());
}
- private PortStatusMessageBuilder assemblePortStatusMessage(long portNoValue, long speed) {
+ private static PortStatusMessageBuilder assemblePortStatusMessage(final long portNoValue, final long speed) {
final PortFeatures portFeatures13 = PortFeatures.getDefaultInstance("_100gbFd");
final PortFeaturesV10 portFeatures10 = PortFeaturesV10.getDefaultInstance("_100mbFd");
final PortConfig portConfig13 = PortConfig.getDefaultInstance("noFwd");
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateFlowCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateGroupCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateMeterCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlowKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.group._case.FlatBatchAddGroup;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.group._case.FlatBatchAddGroupBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.group._case.FlatBatchAddGroupKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.meter._case.FlatBatchAddMeter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.meter._case.FlatBatchAddMeterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.meter._case.FlatBatchAddMeterKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.flow._case.FlatBatchRemoveFlow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.flow._case.FlatBatchRemoveFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.flow._case.FlatBatchRemoveFlowKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.group._case.FlatBatchRemoveGroup;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.group._case.FlatBatchRemoveGroupBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.group._case.FlatBatchRemoveGroupKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.meter._case.FlatBatchRemoveMeter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.meter._case.FlatBatchRemoveMeterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.meter._case.FlatBatchRemoveMeterKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.flow._case.FlatBatchUpdateFlow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.flow._case.FlatBatchUpdateFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.flow._case.FlatBatchUpdateFlowKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.group._case.FlatBatchUpdateGroup;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.group._case.FlatBatchUpdateGroupBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.group._case.FlatBatchUpdateGroupKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.meter._case.FlatBatchUpdateMeter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.meter._case.FlatBatchUpdateMeterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.meter._case.FlatBatchUpdateMeterKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailure;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailureBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailureKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.batch.failure.batch.item.id.choice.FlatBatchFailureFlowIdCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.opendaylight.yangtools.yang.common.Uint16;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
switch (type) {
case FLOW_ADD:
batchCase = new FlatBatchAddFlowCaseBuilder()
- .setFlatBatchAddFlow(repeatIntoList(new FlatBatchAddFlowBuilder().build(), size))
+ .setFlatBatchAddFlow(repeatFlatBatchAddFlowIntoList(size))
.build();
break;
case FLOW_REMOVE:
batchCase = new FlatBatchRemoveFlowCaseBuilder()
- .setFlatBatchRemoveFlow(repeatIntoList(new FlatBatchRemoveFlowBuilder().build(), size))
+ .setFlatBatchRemoveFlow(repeatFlatBatchRemoveFlowIntoList(size))
.build();
break;
case FLOW_UPDATE:
batchCase = new FlatBatchUpdateFlowCaseBuilder()
- .setFlatBatchUpdateFlow(repeatIntoList(new FlatBatchUpdateFlowBuilder().build(), size))
+ .setFlatBatchUpdateFlow(repeatFlatBatchUpdateFlowIntoList(size))
.build();
break;
case GROUP_ADD:
batchCase = new FlatBatchAddGroupCaseBuilder()
- .setFlatBatchAddGroup(repeatIntoList(new FlatBatchAddGroupBuilder().build(), size))
+ .setFlatBatchAddGroup(repeatFlatBatchAddGroupIntoList(size))
.build();
break;
case GROUP_REMOVE:
batchCase = new FlatBatchRemoveGroupCaseBuilder()
- .setFlatBatchRemoveGroup(repeatIntoList(new FlatBatchRemoveGroupBuilder().build(), size))
+ .setFlatBatchRemoveGroup(repeatFlatBatchRemoveGroupIntoList(size))
.build();
break;
case GROUP_UPDATE:
batchCase = new FlatBatchUpdateGroupCaseBuilder()
- .setFlatBatchUpdateGroup(repeatIntoList(new FlatBatchUpdateGroupBuilder().build(), size))
+ .setFlatBatchUpdateGroup(repeatFlatBatchUpdateGroupIntoList(size))
.build();
break;
case METER_ADD:
batchCase = new FlatBatchAddMeterCaseBuilder()
- .setFlatBatchAddMeter(repeatIntoList(new FlatBatchAddMeterBuilder().build(), size))
+ .setFlatBatchAddMeter(repeatFlatBatchAddMeterIntoList(size))
.build();
break;
case METER_REMOVE:
batchCase = new FlatBatchRemoveMeterCaseBuilder()
- .setFlatBatchRemoveMeter(repeatIntoList(new FlatBatchRemoveMeterBuilder().build(), size))
+ .setFlatBatchRemoveMeter(repeatFlatBatchRemoveMeterIntoList(size))
.build();
break;
case METER_UPDATE:
batchCase = new FlatBatchUpdateMeterCaseBuilder()
- .setFlatBatchUpdateMeter(repeatIntoList(new FlatBatchUpdateMeterBuilder().build(), size))
+ .setFlatBatchUpdateMeter(repeatFlatBatchUpdateMeterIntoList(size))
.build();
break;
default:
.build();
}
- private <T> List<T> repeatIntoList(final T element, final int size) {
- final List<T> list = new ArrayList<>();
+ private List<FlatBatchAddGroup> repeatFlatBatchAddGroupIntoList(final int size) {
+ final List<FlatBatchAddGroup> list = new ArrayList<>();
for (int i = 0; i < size; i++) {
- list.add(element);
+ list.add(new FlatBatchAddGroupBuilder().withKey(new FlatBatchAddGroupKey(i)).build());
+ }
+ return list;
+ }
+
+ private List<FlatBatchUpdateGroup> repeatFlatBatchUpdateGroupIntoList(final int size) {
+ final List<FlatBatchUpdateGroup> list = new ArrayList<>();
+ for (int i = 0; i < size; i++) {
+ list.add(new FlatBatchUpdateGroupBuilder().withKey(new FlatBatchUpdateGroupKey(i)).build());
+ }
+ return list;
+ }
+
+ private List<FlatBatchRemoveGroup> repeatFlatBatchRemoveGroupIntoList(final int size) {
+ final List<FlatBatchRemoveGroup> list = new ArrayList<>();
+ for (int i = 0; i < size; i++) {
+ list.add(new FlatBatchRemoveGroupBuilder().withKey(new FlatBatchRemoveGroupKey(i)).build());
+ }
+ return list;
+ }
+
+ private List<FlatBatchAddFlow> repeatFlatBatchAddFlowIntoList(final int size) {
+ final List<FlatBatchAddFlow> list = new ArrayList<>();
+ for (int i = 0; i < size; i++) {
+ list.add(new FlatBatchAddFlowBuilder().withKey(new FlatBatchAddFlowKey(i)).build());
+ }
+ return list;
+ }
+
+ private List<FlatBatchUpdateFlow> repeatFlatBatchUpdateFlowIntoList(final int size) {
+ final List<FlatBatchUpdateFlow> list = new ArrayList<>();
+ for (int i = 0; i < size; i++) {
+ list.add(new FlatBatchUpdateFlowBuilder().withKey(new FlatBatchUpdateFlowKey(i)).build());
+ }
+ return list;
+ }
+
+ private List<FlatBatchRemoveFlow> repeatFlatBatchRemoveFlowIntoList(final int size) {
+ final List<FlatBatchRemoveFlow> list = new ArrayList<>();
+ for (int i = 0; i < size; i++) {
+ list.add(new FlatBatchRemoveFlowBuilder().withKey(new FlatBatchRemoveFlowKey(i)).build());
+ }
+ return list;
+ }
+
+ private List<FlatBatchAddMeter> repeatFlatBatchAddMeterIntoList(final int size) {
+ final List<FlatBatchAddMeter> list = new ArrayList<>();
+ for (int i = 0; i < size; i++) {
+ list.add(new FlatBatchAddMeterBuilder().withKey(new FlatBatchAddMeterKey(i)).build());
+ }
+ return list;
+ }
+
+ private List<FlatBatchUpdateMeter> repeatFlatBatchUpdateMeterIntoList(final int size) {
+ final List<FlatBatchUpdateMeter> list = new ArrayList<>();
+ for (int i = 0; i < size; i++) {
+ list.add(new FlatBatchUpdateMeterBuilder().withKey(new FlatBatchUpdateMeterKey(i)).build());
+ }
+ return list;
+ }
+
+ private List<FlatBatchRemoveMeter> repeatFlatBatchRemoveMeterIntoList(final int size) {
+ final List<FlatBatchRemoveMeter> list = new ArrayList<>();
+ for (int i = 0; i < size; i++) {
+ list.add(new FlatBatchRemoveMeterBuilder().withKey(new FlatBatchRemoveMeterKey(i)).build());
}
return list;
}
.setBatchItemIdChoice(new FlatBatchFailureFlowIdCaseBuilder()
.setFlowId(new FlowId("11"))
.build())
+ .withKey(new BatchFailureKey(Uint16.ZERO))
+ .build();
+ final BatchFailure batchFailure_1 = new BatchFailureBuilder()
+ .setBatchOrder(9)
+ .setBatchItemIdChoice(new FlatBatchFailureFlowIdCaseBuilder()
+ .setFlowId(new FlowId("11"))
+ .build())
+ .withKey(new BatchFailureKey(Uint16.ONE))
.build();
final ProcessFlatBatchOutput output
= new ProcessFlatBatchOutputBuilder().setBatchFailure(Lists.newArrayList(batchFailure)).build();
+ final ProcessFlatBatchOutput output_1
+ = new ProcessFlatBatchOutputBuilder().setBatchFailure(Lists.newArrayList(batchFailure_1)).build();
+
final RpcResult<ProcessFlatBatchOutput> rpcResultFailed = RpcResultBuilder.<ProcessFlatBatchOutput>failed()
.withError(RpcError.ErrorType.APPLICATION, "ut-rpcError")
.withResult(output).build();
+
+ final RpcResult<ProcessFlatBatchOutput> rpcResultFailed_1 = RpcResultBuilder.<ProcessFlatBatchOutput>failed()
+ .withError(RpcError.ErrorType.APPLICATION, "ut-rpcError")
+ .withResult(output_1).build();
final RpcResult<ProcessFlatBatchOutput> rpcResultSuccess = RpcResultBuilder.<ProcessFlatBatchOutput>success()
.withResult(new ProcessFlatBatchOutputBuilder().setBatchFailure(new ArrayList<>())).build();
Assert.assertFalse(rpcResult1.isSuccessful());
final RpcResult<ProcessFlatBatchOutput> rpcResult2
- = FlatBatchUtil.mergeRpcResults().apply(Lists.newArrayList(rpcResultFailed, rpcResultFailed));
+ = FlatBatchUtil.mergeRpcResults().apply(Lists.newArrayList(rpcResultFailed, rpcResultFailed_1));
Assert.assertEquals(2, rpcResult2.getErrors().size());
Assert.assertFalse(rpcResult2.isSuccessful());
import com.google.common.collect.Lists;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import java.util.function.Function;
import org.apache.commons.lang3.tuple.Pair;
import org.junit.Assert;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.BatchFlowOutputListGrouping;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.output.list.grouping.BatchFailedFlowsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.output.list.grouping.BatchFailedFlowsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.batch.flow.output.list.grouping.BatchFailedFlowsOutputKey;
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;
private <T extends BatchFlowOutputListGrouping> void checkBatchSuccessOutcomeTransformation(
final RpcResult<T> output) {
Assert.assertTrue(output.isSuccessful());
- Assert.assertEquals(0, output.getResult().getBatchFailedFlowsOutput().size());
+ Map<BatchFailedFlowsOutputKey, BatchFailedFlowsOutput> failedFlows
+ = output.getResult().nonnullBatchFailedFlowsOutput();
+ Assert.assertEquals(0, failedFlows.size());
Assert.assertEquals(0, output.getErrors().size());
}
- private RpcResult<List<BatchFailedFlowsOutput>> createEmptyBatchOutcome() {
+ private static RpcResult<List<BatchFailedFlowsOutput>> createEmptyBatchOutcome() {
return RpcResultBuilder
.success(Collections.<BatchFailedFlowsOutput>emptyList())
.build();
}
- private RpcResult<List<BatchFailedFlowsOutput>> createBatchOutcomeWithError() {
+ private static RpcResult<List<BatchFailedFlowsOutput>> createBatchOutcomeWithError() {
return RpcResultBuilder.<List<BatchFailedFlowsOutput>>failed()
.withError(RpcError.ErrorType.APPLICATION, "ut-flowAddFail")
.withResult(Collections.singletonList(new BatchFailedFlowsOutputBuilder()
.build();
}
- private <T extends BatchFlowOutputListGrouping> void checkBatchErrorOutcomeTransformation(
+ private static <T extends BatchFlowOutputListGrouping> void checkBatchErrorOutcomeTransformation(
final RpcResult<T> output) {
Assert.assertFalse(output.isSuccessful());
- Assert.assertEquals(1, output.getResult().getBatchFailedFlowsOutput().size());
- Assert.assertEquals(DUMMY_FLOW_ID, output.getResult().getBatchFailedFlowsOutput().get(0).getFlowId());
+ Assert.assertEquals(1, output.getResult().nonnullBatchFailedFlowsOutput().size());
+ Assert.assertEquals(DUMMY_FLOW_ID,
+ output.getResult().nonnullBatchFailedFlowsOutput().values().iterator().next().getFlowId());
Assert.assertEquals(1, output.getErrors().size());
}
Assert.assertTrue(composite.isSuccessful());
Assert.assertEquals(0, composite.getErrors().size());
- Assert.assertEquals(0, composite.getResult().getBatchFailedFlowsOutput().size());
+ Map<BatchFailedFlowsOutputKey, BatchFailedFlowsOutput> failedFlows
+ = composite.getResult().nonnullBatchFailedFlowsOutput();
+ Assert.assertEquals(0, failedFlows.size());
}
@Test
Assert.assertFalse(composite.isSuccessful());
Assert.assertEquals(1, composite.getErrors().size());
- Assert.assertEquals(0, composite.getResult().getBatchFailedFlowsOutput().size());
+ Map<BatchFailedFlowsOutputKey, BatchFailedFlowsOutput> failedFlows
+ = composite.getResult().nonnullBatchFailedFlowsOutput();
+ Assert.assertEquals(0, failedFlows.size());
}
@Test
checkBatchSuccessOutcomeTransformation(GroupUtil.GROUP_UPDATE_TRANSFORM.apply(input));
}
- private <T extends BatchGroupOutputListGrouping> void checkBatchSuccessOutcomeTransformation(
+ private static <T extends BatchGroupOutputListGrouping> void checkBatchSuccessOutcomeTransformation(
final RpcResult<T> output) {
Assert.assertTrue(output.isSuccessful());
- Assert.assertEquals(0, output.getResult().getBatchFailedGroupsOutput().size());
+ Assert.assertEquals(0, output.getResult().nonnullBatchFailedGroupsOutput().size());
Assert.assertEquals(0, output.getErrors().size());
}
- private RpcResult<List<BatchFailedGroupsOutput>> createEmptyBatchOutcome() {
+ private static RpcResult<List<BatchFailedGroupsOutput>> createEmptyBatchOutcome() {
return RpcResultBuilder
.success(Collections.<BatchFailedGroupsOutput>emptyList())
.build();
}
- private RpcResult<List<BatchFailedGroupsOutput>> createBatchOutcomeWithError() {
+ private static RpcResult<List<BatchFailedGroupsOutput>> createBatchOutcomeWithError() {
return RpcResultBuilder.<List<BatchFailedGroupsOutput>>failed()
.withError(RpcError.ErrorType.APPLICATION, "ut-flowAddFail")
.withResult(Collections.singletonList(new BatchFailedGroupsOutputBuilder()
.build();
}
- private <T extends BatchGroupOutputListGrouping> void checkBatchErrorOutcomeTransformation(
+ private static <T extends BatchGroupOutputListGrouping> void checkBatchErrorOutcomeTransformation(
final RpcResult<T> output) {
Assert.assertFalse(output.isSuccessful());
- Assert.assertEquals(1, output.getResult().getBatchFailedGroupsOutput().size());
- Assert.assertEquals(DUMMY_GROUP_ID, output.getResult().getBatchFailedGroupsOutput().get(0).getGroupId());
+ Assert.assertEquals(1, output.getResult().nonnullBatchFailedGroupsOutput().size());
+ Assert.assertEquals(DUMMY_GROUP_ID,
+ output.getResult().nonnullBatchFailedGroupsOutput().values().iterator().next().getGroupId());
Assert.assertEquals(1, output.getErrors().size());
}
Assert.assertTrue(composite.isSuccessful());
Assert.assertEquals(0, composite.getErrors().size());
- Assert.assertEquals(0, composite.getResult().getBatchFailedGroupsOutput().size());
+ Assert.assertEquals(0, composite.getResult().nonnullBatchFailedGroupsOutput().size());
}
@Test
Assert.assertFalse(composite.isSuccessful());
Assert.assertEquals(1, composite.getErrors().size());
- Assert.assertEquals(0, composite.getResult().getBatchFailedGroupsOutput().size());
+ Assert.assertEquals(0, composite.getResult().nonnullBatchFailedGroupsOutput().size());
}
@Test
import com.google.common.collect.Lists;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import org.apache.commons.lang3.tuple.Pair;
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.BatchMeterOutputListGrouping;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.output.list.grouping.BatchFailedMetersOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.output.list.grouping.BatchFailedMetersOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.output.list.grouping.BatchFailedMetersOutputKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
checkBatchSuccessOutcomeTransformation(MeterUtil.METER_UPDATE_TRANSFORM.apply(input));
}
- private <T extends BatchMeterOutputListGrouping> void checkBatchSuccessOutcomeTransformation(
+ private static <T extends BatchMeterOutputListGrouping> void checkBatchSuccessOutcomeTransformation(
final RpcResult<T> output) {
Assert.assertTrue(output.isSuccessful());
- Assert.assertEquals(0, output.getResult().getBatchFailedMetersOutput().size());
+ Assert.assertEquals(0, output.getResult().nonnullBatchFailedMetersOutput().size());
Assert.assertEquals(0, output.getErrors().size());
}
- private RpcResult<List<BatchFailedMetersOutput>> createEmptyBatchOutcome() {
+ private static RpcResult<List<BatchFailedMetersOutput>> createEmptyBatchOutcome() {
return RpcResultBuilder
.success(Collections.<BatchFailedMetersOutput>emptyList())
.build();
}
- private RpcResult<List<BatchFailedMetersOutput>> createBatchOutcomeWithError() {
+ private static RpcResult<List<BatchFailedMetersOutput>> createBatchOutcomeWithError() {
return RpcResultBuilder.<List<BatchFailedMetersOutput>>failed()
.withError(RpcError.ErrorType.APPLICATION, "ut-flowAddFail")
.withResult(Collections.singletonList(new BatchFailedMetersOutputBuilder()
.build();
}
- private <T extends BatchMeterOutputListGrouping> void checkBatchErrorOutcomeTransformation(
+ private static <T extends BatchMeterOutputListGrouping> void checkBatchErrorOutcomeTransformation(
final RpcResult<T> output) {
Assert.assertFalse(output.isSuccessful());
- Assert.assertEquals(1, output.getResult().getBatchFailedMetersOutput().size());
- Assert.assertEquals(DUMMY_METER_ID, output.getResult().getBatchFailedMetersOutput().get(0).getMeterId());
+ Assert.assertEquals(1, output.getResult().nonnullBatchFailedMetersOutput().size());
+ Assert.assertEquals(DUMMY_METER_ID,
+ output.getResult().nonnullBatchFailedMetersOutput().values().iterator().next().getMeterId());
Assert.assertEquals(1, output.getErrors().size());
}
Assert.assertTrue(composite.isSuccessful());
Assert.assertEquals(0, composite.getErrors().size());
- Assert.assertEquals(0, composite.getResult().getBatchFailedMetersOutput().size());
+ Map<BatchFailedMetersOutputKey, BatchFailedMetersOutput> failedMeters
+ = composite.getResult().nonnullBatchFailedMetersOutput();
+ Assert.assertEquals(0, failedMeters.size());
}
@Test
Assert.assertFalse(composite.isSuccessful());
Assert.assertEquals(1, composite.getErrors().size());
- Assert.assertEquals(0, composite.getResult().getBatchFailedMetersOutput().size());
+ Map<BatchFailedMetersOutputKey, BatchFailedMetersOutput> failedMeters
+ = composite.getResult().nonnullBatchFailedMetersOutput();
+ Assert.assertEquals(0, failedMeters.size());
}
@Test
private RpcResult<AddMetersBatchOutput> createAddMetersBatchSuccessOutput() {
return RpcResultBuilder
.success(new AddMetersBatchOutputBuilder()
- .setBatchFailedMetersOutput(Collections.emptyList())
+ .setBatchFailedMetersOutput(Collections.emptyMap())
.build())
.build();
}
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
final ExtensionListBuilder extBuilder = processExtension(matchEntry, ofVersion, matchPath);
+ // TODO: remove the Optional.ofNullable() here, which will result more performant and easier to understand code
final GeneralAugMatchNodesNodeTableFlowBuilder builder = Optional
.ofNullable(matchBuilder.augmentation(GeneralAugMatchNodesNodeTableFlow.class))
.map(GeneralAugMatchNodesNodeTableFlowBuilder::new)
- .orElse(new GeneralAugMatchNodesNodeTableFlowBuilder().setExtensionList(new ArrayList<>()));
+ .orElse(new GeneralAugMatchNodesNodeTableFlowBuilder().setExtensionList(new HashMap<>()));
if (extBuilder != null) {
- builder.getExtensionList().add(extBuilder.build());
+ final ExtensionList ext = extBuilder.build();
+ builder.getExtensionList().put(ext.key(), ext);
} else {
LOG.warn("Convertor for {} for version {} with match path {} not found.",
matchEntry, ofVersion, matchPath.name());
final Collection<MatchEntry> matchEntries, final OpenflowVersion ofVersion, final MatchPath matchPath) {
List<ExtensionList> extensionsList = new ArrayList<>();
- for (MatchEntry matchEntry : matchEntries) {
- ExtensionListBuilder extensionListBld = processExtension(matchEntry, ofVersion.getVersion(), matchPath);
- if (extensionListBld == null) {
- continue;
- }
+ if (matchEntries != null) {
+ for (MatchEntry matchEntry : matchEntries) {
+ ExtensionListBuilder extensionListBld = processExtension(matchEntry, ofVersion.getVersion(), matchPath);
+ if (extensionListBld == null) {
+ continue;
+ }
- extensionsList.add(extensionListBld.build());
+ extensionsList.add(extensionListBld.build());
+ }
}
AugmentTuple<E> augmentTuple = null;
package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
import java.util.Collection;
+import java.util.Map;
import java.util.Optional;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorData;
* @return the result (can be empty, if no convertor was found)
*/
<F, T, D extends ConvertorData> Optional<T> convert(Collection<F> source, D data);
+
+ /**
+ * Lookup and use convertor by specified type, then converts source collection and returns converted result.
+ *
+ * @param <K> the source key type
+ * @param <F> the source value type
+ * @param <T> the result type
+ * @param <D> the data type
+ * @param source the source collection
+ * @param data convertor data
+ * @return the result (can be empty, if no convertor was found)
+ */
+ <K, F, T, D extends ConvertorData> Optional<T> convert(Map<K, F> source, D data);
}
return findConvertor(data.getVersion(), type).map(convertor -> (T)convertor.convert(source, data));
}
+ @Override
+ @SuppressWarnings("unchecked")
+ public <K, F, T, D extends ConvertorData> Optional<T> convert(final Map<K, F> source, final D data) {
+ Optional<T> result = Optional.empty();
+
+ if (source == null) {
+ LOG.trace("Cannot extract type from null source");
+ return result;
+ }
+
+ final Optional<F> firstOptional = source.values().stream().findFirst();
+
+ if (!firstOptional.isPresent()) {
+ LOG.trace("Cannot extract type from empty collection");
+ return result;
+ }
+
+ final F first = firstOptional.get();
+
+ final Class<?> type = first instanceof DataContainer ? ((DataContainer) first).implementedInterface()
+ : first.getClass();
+
+ if (type == null) {
+ LOG.warn("Cannot extract type from {}, because implementedInterface() returns null", source);
+ return result;
+ }
+
+ return findConvertor(data.getVersion(), type).map(convertor -> (T)convertor.convert(source.values(), data));
+ }
+
@Override
@SuppressWarnings("unchecked")
public <F, T, D extends ConvertorData> Optional<T> convert(final Collection<F> source, final D data) {
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
import org.opendaylight.openflowjava.protocol.api.util.BinContent;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
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.GroupModCommand;
return bucket1.getBucketId().getValue().compareTo(bucket2.getBucketId().getValue());
};
- private List<BucketsList> salToOFBucketList(final Buckets buckets, final short version, final int groupType,
+ private List<BucketsList> salToOFBucketList(final List<Bucket> buckets, final short version, final int groupType,
final Uint64 datapathid) {
final List<BucketsList> bucketLists = new ArrayList<>();
final ActionConvertorData data = new ActionConvertorData(version);
data.setDatapathId(datapathid);
for (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket groupBucket :
- buckets.getBucket()) {
+ buckets) {
BucketsListBuilder bucketBuilder = new BucketsListBuilder();
salToOFBucketListWeight(groupBucket, bucketBuilder, groupType);
// Only if the bucket is configured for the group then add it
// During group deletion do not push the buckets
if (groupModInputBuilder.getCommand() != GroupModCommand.OFPGCDELETE) {
- if (source.getBuckets() != null && source.getBuckets().getBucket().size() != 0) {
-
- List<Bucket> bucketList = new ArrayList<>(source.getBuckets().getBucket());
- Group group = new GroupBuilder(source)
- .setBuckets(new BucketsBuilder().setBucket(bucketList).build())
- .build();
- Collections.sort(group.getBuckets().getBucket(), COMPARATOR);
-
- List<BucketsList> bucketLists = salToOFBucketList(group.getBuckets(), data.getVersion(),
- group.getGroupType().getIntValue(), data.getDatapathId());
- groupModInputBuilder.setBucketsList(bucketLists);
+ final Buckets buckets = source.getBuckets();
+ if (buckets != null) {
+ final Map<BucketKey, Bucket> bucket = buckets.nonnullBucket();
+ if (!bucket.isEmpty()) {
+ // TODO: we should be able to just sort the resulting the resulting list and not go through
+ // two copies
+ List<Bucket> bucketList = new ArrayList<>(bucket.values());
+ Collections.sort(bucketList, COMPARATOR);
+ List<BucketsList> bucketLists = salToOFBucketList(bucketList, data.getVersion(),
+ source.getGroupType().getIntValue(), data.getDatapathId());
+ groupModInputBuilder.setBucketsList(bucketLists);
+ }
}
}
for (GroupDesc groupDesc : source) {
GroupDescStatsBuilder salGroupDescStats = new GroupDescStatsBuilder();
- salGroupDescStats.setBuckets(toSALBucketsDesc(groupDesc.getBucketsList(), data.getVersion()));
+ salGroupDescStats.setBuckets(toSALBucketsDesc(groupDesc.nonnullBucketsList(), data.getVersion()));
salGroupDescStats.setGroupId(new GroupId(groupDesc.getGroupId().getValue()));
salGroupDescStats.setGroupType(GroupTypes.forValue(groupDesc.getType().getIntValue()));
salGroupDescStats.withKey(new GroupDescStatsKey(salGroupDescStats.getGroupId()));
.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart
.reply.group.GroupStats.class);
- private Buckets toSALBuckets(List<BucketStats> bucketStats) {
+ private static Buckets toSALBuckets(List<BucketStats> bucketStats) {
BucketsBuilder salBuckets = new BucketsBuilder();
List<BucketCounter> allBucketStats = new ArrayList<>();
.body.multipart.reply.group._case.multipart.reply.group.GroupStats groupStats : source) {
GroupStatsBuilder salGroupStats = new GroupStatsBuilder();
- salGroupStats.setBuckets(toSALBuckets(groupStats.getBucketStats()));
+ salGroupStats.setBuckets(toSALBuckets(groupStats.nonnullBucketStats()));
salGroupStats.setByteCount(new Counter64(groupStats.getByteCount()));
DurationBuilder time = new DurationBuilder();
}
@Override
- public List<MeterConfigStats> convert(List<MeterConfig> source, VersionConvertorData data) {
+ public List<MeterConfigStats> convert(final List<MeterConfig> source, final VersionConvertorData data) {
List<MeterConfigStats> listMeterConfigStats = new ArrayList<>();
for (MeterConfig meterConfig : source) {
meterConfigStatsBuilder.setMeterId(new MeterId(meterConfig.getMeterId().getValue()));
meterConfigStatsBuilder.withKey(new MeterConfigStatsKey(meterConfigStatsBuilder.getMeterId()));
MeterBandHeadersBuilder meterBandHeadersBuilder = new MeterBandHeadersBuilder();
- List<Bands> bands = meterConfig.getBands();
MeterFlags meterFlags = new MeterFlags(meterConfig.getFlags().isOFPMFBURST(),
meterConfig.getFlags().isOFPMFKBPS(),
List<MeterBandHeader> listBandHeaders = new ArrayList<>();
int bandKey = 0;
- for (Bands band : bands) {
+ for (Bands band : meterConfig.nonnullBands()) {
MeterBandHeaderBuilder meterBandHeaderBuilder = new MeterBandHeaderBuilder();
if (band.getMeterBand() instanceof MeterBandDropCase) {
MeterBandDropCase dropCaseBand = (MeterBandDropCase) band.getMeterBand();
MeterBandTypesBuilder meterBandTypesBuilder = new MeterBandTypesBuilder();
meterBandTypesBuilder.setFlags(new MeterBandType(false, true, false));
meterBandHeaderBuilder.setMeterBandTypes(meterBandTypesBuilder.build());
+ meterBandHeaderBuilder.withKey(new MeterBandHeaderKey(bandId));
listBandHeaders.add(meterBandHeaderBuilder.build());
} else if (band.getMeterBand() instanceof MeterBandExperimenterCase) {
MeterBandTypesBuilder meterBandTypesBuilder = new MeterBandTypesBuilder();
meterBandTypesBuilder.setFlags(new MeterBandType(false, false, true));
meterBandHeaderBuilder.setMeterBandTypes(meterBandTypesBuilder.build());
+ meterBandHeaderBuilder.withKey(new MeterBandHeaderKey(bandId));
listBandHeaders.add(meterBandHeaderBuilder.build());
}
-
bandKey++;
}
* @param version Openflow version
* @return default empty meter mod input builder
*/
- public static MeterModInputBuilder defaultResult(short version) {
+ public static MeterModInputBuilder defaultResult(final short version) {
return new MeterModInputBuilder()
.setVersion(version)
.setFlags(new MeterFlags(false, false, true, false));
}
- private static void getBandsFromSAL(MeterBandHeaders meterBandHeaders, List<Bands> bands) {
- for (MeterBandHeader meterBandHeader : meterBandHeaders.getMeterBandHeader()) {
+ private static void getBandsFromSAL(final MeterBandHeaders meterBandHeaders, final List<Bands> bands) {
+ for (MeterBandHeader meterBandHeader : meterBandHeaders.nonnullMeterBandHeader().values()) {
// The band types :drop,DSCP_Remark or experimenter.
if (null != meterBandHeader.getMeterBandTypes() && null != meterBandHeader.getMeterBandTypes().getFlags()) {
if (meterBandHeader.getMeterBandTypes().getFlags().isOfpmbtDrop()) {
}
@Override
- public MeterModInputBuilder convert(Meter source, VersionConvertorData data) {
+ public MeterModInputBuilder convert(final Meter source, final VersionConvertorData data) {
MeterModInputBuilder meterModInputBuilder = new MeterModInputBuilder();
List<Bands> bands = new ArrayList<>();
salMeterStats.setPacketInCount(new Counter64(meterStats.getPacketInCount()));
salMeterStats.withKey(new MeterStatsKey(salMeterStats.getMeterId()));
- List<MeterBandStats> allMeterBandStats = meterStats.getMeterBandStats();
+ List<MeterBandStats> allMeterBandStats = meterStats.nonnullMeterBandStats();
MeterBandStatsBuilder meterBandStatsBuilder = new MeterBandStatsBuilder();
List<BandStat> listAllBandStats = new ArrayList<>();
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
import java.util.Set;
import org.opendaylight.controller.sal.common.util.Arguments;
LOG.error("PORT NR not exist in Egress");
}
- List<Action> actions = new ArrayList<>();
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> inputActions =
- source.getAction();
+ final List<Action> actions;
+ Map<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> inputActions =
+ source.nonnullAction();
- if (inputActions != null) {
+ if (!inputActions.isEmpty()) {
final ActionConvertorData actionConvertorData = new ActionConvertorData(data.getVersion());
actionConvertorData.setDatapathId(data.getDatapathId());
outputActionCaseBuilder.setOutputAction(outputActionBuilder.build());
ActionBuilder actionBuild = new ActionBuilder();
actionBuild.setActionChoice(outputActionCaseBuilder.build());
+ actions = new ArrayList<>();
actions.add(actionBuild.build());
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlags;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeatureProperty;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeatureProperty;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeaturePropertyBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeaturePropertyBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatchKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.TableFeaturePropType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActions;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss;
List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table
.properties.TableFeatureProperties> sortedTableProperties = TABLE_FEATURE_PROPS_ORDERING.sortedCopy(
- tableProperties.getTableFeatureProperties());
+ tableProperties.nonnullTableFeatureProperties().values());
for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table
.properties.TableFeatureProperties property : sortedTableProperties) {
private static void setTableFeatureProperty(final ApplySetfieldMiss propType,
final TableFeaturePropertiesBuilder propBuilder) {
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch>
- setFieldMatch = null;
+ Map<SetFieldMatchKey, SetFieldMatch> setFieldMatch = null;
org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
.type.apply.setfield.miss.ApplySetfieldMiss applySetfieldMiss = propType.getApplySetfieldMiss();
if (null != applySetfieldMiss) {
- setFieldMatch = applySetfieldMiss.getSetFieldMatch();
+ setFieldMatch = applySetfieldMiss.nonnullSetFieldMatch();
}
setSetFieldTableFeatureProperty(
propBuilder,
TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS,
- setFieldMatch == null ? new ArrayList<>()
- : setFieldMatch);
+ setFieldMatch == null ? Collections.emptyMap() : setFieldMatch);
}
private static void setTableFeatureProperty(final ApplySetfield propType,
final TableFeaturePropertiesBuilder propBuilder) {
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch>
- setFieldMatch = null;
+ Map<SetFieldMatchKey, SetFieldMatch> setFieldMatch = null;
org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
.type.apply.setfield.ApplySetfield applySetfield = propType.getApplySetfield();
if (null != applySetfield) {
- setFieldMatch = applySetfield.getSetFieldMatch();
+ setFieldMatch = applySetfield.nonnullSetFieldMatch();
}
setSetFieldTableFeatureProperty(
propBuilder,
TableFeaturesPropType.OFPTFPTAPPLYSETFIELD,
- setFieldMatch == null ? new ArrayList<>()
- : setFieldMatch);
+ setFieldMatch == null ? Collections.emptyMap() : setFieldMatch);
}
private static void setTableFeatureProperty(final WriteSetfieldMiss propType,
final TableFeaturePropertiesBuilder propBuilder) {
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch>
- setFieldMatch = null;
+ Map<SetFieldMatchKey, SetFieldMatch> setFieldMatch = null;
org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
.type.write.setfield.miss.WriteSetfieldMiss writeSetfieldMiss = propType.getWriteSetfieldMiss();
if (null != writeSetfieldMiss) {
- setFieldMatch = writeSetfieldMiss.getSetFieldMatch();
+ setFieldMatch = writeSetfieldMiss.nonnullSetFieldMatch();
}
setSetFieldTableFeatureProperty(
propBuilder,
TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS,
- setFieldMatch == null ? new ArrayList<>()
- : setFieldMatch);
+ setFieldMatch == null ? Collections.emptyMap() : setFieldMatch);
}
private static void setTableFeatureProperty(final WriteSetfield propType,
final TableFeaturePropertiesBuilder propBuilder) {
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch>
- setFieldMatch = null;
+ Map<SetFieldMatchKey, SetFieldMatch> setFieldMatch = null;
org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
.type.write.setfield.WriteSetfield writeSetField = propType.getWriteSetfield();
if (null != writeSetField) {
- setFieldMatch = writeSetField.getSetFieldMatch();
+ setFieldMatch = writeSetField.nonnullSetFieldMatch();
}
setSetFieldTableFeatureProperty(
propBuilder,
TableFeaturesPropType.OFPTFPTWRITESETFIELD,
- setFieldMatch == null ? new ArrayList<>()
- : setFieldMatch);
+ setFieldMatch == null ? Collections.emptyMap() : setFieldMatch);
}
private static void setTableFeatureProperty(final Wildcards propType,
final TableFeaturePropertiesBuilder propBuilder) {
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch>
- setFieldMatch = null;
+ Map<SetFieldMatchKey, SetFieldMatch> setFieldMatch = null;
WildcardSetfield wildcardSetField = propType.getWildcardSetfield();
if (null != wildcardSetField) {
- setFieldMatch = wildcardSetField.getSetFieldMatch();
+ setFieldMatch = wildcardSetField.nonnullSetFieldMatch();
}
setSetFieldTableFeatureProperty(
propBuilder,
TableFeaturesPropType.OFPTFPTWILDCARDS,
- setFieldMatch == null ? new ArrayList<>()
- : setFieldMatch);
+ setFieldMatch == null ? Collections.emptyMap() : setFieldMatch);
}
private static void setTableFeatureProperty(final Match propType, final TableFeaturePropertiesBuilder propBuilder) {
MatchSetfield matchSetField = propType.getMatchSetfield();
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch>
- setFieldMatch = null;
+ Map<SetFieldMatchKey, SetFieldMatch> setFieldMatch = null;
if (null != matchSetField) {
- setFieldMatch = matchSetField.getSetFieldMatch();
+ setFieldMatch = matchSetField.nonnullSetFieldMatch();
}
setSetFieldTableFeatureProperty(
propBuilder,
TableFeaturesPropType.OFPTFPTMATCH,
- setFieldMatch == null ? new ArrayList<>()
- : setFieldMatch);
+ setFieldMatch == null ? Collections.emptyMap() : setFieldMatch);
}
private static void setTableFeatureProperty(final ApplyActionsMiss propType,
setActionTableFeatureProperty(
propBuilder,
TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS,
- applyActionsMiss == null ? new ArrayList<>()
- : applyActionsMiss.getAction());
+ applyActionsMiss == null ? Collections.emptyMap() : applyActionsMiss.nonnullAction());
}
private static void setTableFeatureProperty(final ApplyActions propType,
setActionTableFeatureProperty(
propBuilder,
TableFeaturesPropType.OFPTFPTAPPLYACTIONS,
- applyActions == null ? new ArrayList<>()
- : applyActions.getAction());
+ applyActions == null ? Collections.emptyMap() : applyActions.nonnullAction());
}
private static void setTableFeatureProperty(final WriteActionsMiss propType,
setActionTableFeatureProperty(
propBuilder,
TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS,
- writeActionsMiss == null ? new ArrayList<>()
- : writeActionsMiss.getAction());
+ writeActionsMiss == null ? Collections.emptyMap() : writeActionsMiss.nonnullAction());
}
private static void setTableFeatureProperty(final WriteActions propType,
setActionTableFeatureProperty(
propBuilder,
TableFeaturesPropType.OFPTFPTWRITEACTIONS,
- writeActions == null ? new ArrayList<>()
- : writeActions.getAction());
+ writeActions == null ? Collections.emptyMap() : writeActions.nonnullAction());
}
private static void setTableFeatureProperty(final NextTableMiss propType,
org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
.type.instructions.miss.InstructionsMiss instructions = propType.getInstructionsMiss();
setInstructionTableFeatureProperty(propBuilder, TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS,
- instructions == null ? new ArrayList<>() : instructions.getInstruction());
+ instructions == null ? Collections.emptyMap() : instructions.nonnullInstruction());
}
private static void setTableFeatureProperty(final Instructions propType,
org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
.type.instructions.Instructions instructions = propType.getInstructions();
setInstructionTableFeatureProperty(propBuilder, TableFeaturesPropType.OFPTFPTINSTRUCTIONS,
- instructions == null ? new ArrayList<>() : instructions.getInstruction());
+ instructions == null ? Collections.emptyMap() : instructions.nonnullInstruction());
}
private static void setInstructionTableFeatureProperty(final TableFeaturePropertiesBuilder builder,
- final TableFeaturesPropType type, final List<Instruction> instructionList) {
+ final TableFeaturesPropType type, final Map<InstructionKey, Instruction> instructionList) {
List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping
- .Instruction> instructionTypeList = new ArrayList<>();
+ .Instruction> instructionTypeList = new ArrayList<>(instructionList.size());
- for (Instruction currInstruction : instructionList) {
+ for (Instruction currInstruction : instructionList.values()) {
InstructionBuilder instructionType = new InstructionBuilder();
org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction instruction =
InstructionRelatedTableFeaturePropertyBuilder propBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
propBuilder.setInstruction(instructionTypeList);
builder.setType(type);
- builder.addAugmentation(InstructionRelatedTableFeatureProperty.class, propBuilder.build());
+ builder.addAugmentation(propBuilder.build());
}
private static void setNextTableFeatureProperty(final TableFeaturePropertiesBuilder builder,
private static void setActionTableFeatureProperty(final TableFeaturePropertiesBuilder builder,
final TableFeaturesPropType type,
- final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>
- salActions) {
+ final Map<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>
+ salActions) {
- List<Action> actionList = new ArrayList<>();
+ List<Action> actionList = new ArrayList<>(salActions.size());
for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action currAction :
- salActions) {
+ salActions.values()) {
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionType = currAction
.getAction();
ActionBuilder actionBuilder = new ActionBuilder();
ActionRelatedTableFeaturePropertyBuilder propBuilder = new ActionRelatedTableFeaturePropertyBuilder();
propBuilder.setAction(actionList);
builder.setType(type);
- builder.addAugmentation(ActionRelatedTableFeatureProperty.class, propBuilder.build());
+ builder.addAugmentation(propBuilder.build());
}
private static void setSetFieldTableFeatureProperty(
final TableFeaturePropertiesBuilder builder,
final TableFeaturesPropType type,
- final List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match
- .SetFieldMatch> setFields) {
+ final Map<SetFieldMatchKey, SetFieldMatch> setFields) {
List<MatchEntry> matchEntriesList = new ArrayList<>();
- for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch
- currMatch : setFields) {
+ for (SetFieldMatch currMatch : setFields.values()) {
Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField>
currMatchType = currMatch.getMatchType();
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
TableFeaturesBuilder ofTableFeatures = new TableFeaturesBuilder();
for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures
- salTableFeatures : source.getTableFeatures()) {
+ salTableFeatures : source.nonnullTableFeatures().values()) {
ofTableFeatures.setTableId(salTableFeatures.getTableId());
ofTableFeatures.setName(salTableFeatures.getName());
ofTableFeatures.setMetadataMatch(salTableFeatures.getMetadataMatch());
* </pre>
*/
public final class ActionConvertor extends Convertor<
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>,
- List<Action>,
+ Collection<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>,
+ Collection<Action>,
ActionConvertorData> {
private static final ConvertorProcessor<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112
}
@Override
- public List<Action> convert(List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action
+ public List<Action> convert(Collection<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action
.list.Action> source, ActionConvertorData data) {
// Prepare list of converted actions
final List<Action> result = new ArrayList<>();
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;
Instructions instructions = flow.getInstructions();
for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction
- instruction : instructions.getInstruction()) {
+ instruction : instructions.nonnullInstruction().values()) {
org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction
curInstruction = instruction.getInstruction();
private List<Action> getActions(final short version, final Uint64 datapathid, final Flow flow) {
Instructions instructions = flow.getInstructions();
List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction>
- sortedInstructions = INSTRUCTION_ORDERING.sortedCopy(instructions.getInstruction());
+ sortedInstructions = INSTRUCTION_ORDERING.sortedCopy(instructions.nonnullInstruction().values());
for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction
instruction : sortedInstructions) {
// If yes,then we would need to two flows
if (flow.getInstructions() != null && flow.getInstructions().getInstruction() != null) {
for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction
- instruction : flow.getInstructions().getInstruction()) {
+ instruction : flow.getInstructions().nonnullInstruction().values()) {
org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction
curInstruction = instruction.getInstruction();
.rev131026.instruction.instruction.ApplyActionsCase) curInstruction;
ApplyActions applyActions = applyActionscase.getApplyActions();
for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action
- action : applyActions.getAction()) {
+ action : applyActions.nonnullAction().values()) {
if (action.getAction() instanceof SetVlanIdActionCase) {
return true;
}
private static List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction>
injectPushActionToInstruction(final Flow sourceFlow) {
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction>
- srcInstructionList = sourceFlow.getInstructions().getInstruction();
+ Map<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction>
+ srcInstructionList = sourceFlow.getInstructions().nonnullInstruction();
List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction>
targetInstructionList = new ArrayList<>(srcInstructionList.size());
.list.InstructionBuilder();
for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction
- srcInstruction : srcInstructionList) {
+ srcInstruction : srcInstructionList.values()) {
org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction
curSrcInstruction = srcInstruction.getInstruction();
.ApplyActionsCase applyActionscase = (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types
.rev131026.instruction.instruction.ApplyActionsCase) curSrcInstruction;
ApplyActions applyActions = applyActionscase.getApplyActions();
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>
- srcActionList = applyActions.getAction();
+ Map<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>
+ srcActionList = applyActions.nonnullAction();
int offset = 0;
for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action
- actionItem : srcActionList) {
+ actionItem : srcActionList.values()) {
// check if its a set-vlan-action. If yes, then add the injected-action
if (actionItem.getAction() instanceof SetVlanIdActionCase) {
// we need to increment the order for all the actions added after injection
ActionBuilder actionBuilder =
new ActionBuilder(actionItem);
- actionBuilder.setOrder(actionItem.getOrder() + offset);
+ actionBuilder.setOrder(actionItem.getOrder() + offset)
+ .withKey(new ActionKey(actionItem.key().getOrder() + offset));
actionItem = actionBuilder.build();
}
final AugmentTuple<Match> matchExtensionWrap =
MatchExtensionHelper.processAllExtensions(
- flowStats.getMatch().getMatchEntry(),
+ flowStats.getMatch().nonnullMatchEntry(),
OpenflowVersion.get(data.getVersion()),
data.getMatchPath());
Optional<GeneralExtensionListGrouping> extensionListOpt =
ExtensionResolvers.getMatchExtensionResolver().getExtension(source);
if (extensionListOpt.isPresent()) {
- List<ExtensionList> extensionListList = extensionListOpt.get().getExtensionList();
- for (ExtensionList extensionItem : extensionListList) {
+ for (ExtensionList extensionItem : extensionListOpt.get().nonnullExtensionList().values()) {
// TODO: get real version
ConverterExtensionKey<? extends ExtensionKey> key =
new ConverterExtensionKey<>(extensionItem.getExtensionKey(), OFConstants.OFP_VERSION_1_3);
data.setTunnelIpv4MatchBuilder(new TunnelIpv4MatchBuilder());
data.setTcpFlagsMatchBuilder(new TcpFlagsMatchBuilder());
- for (MatchEntry ofMatch : source.getMatchEntry()) {
+ for (MatchEntry ofMatch : source.nonnullMatchEntry()) {
if (TunnelIpv4Dst.class.isAssignableFrom(ofMatch.getOxmMatchField())
|| TunnelIpv4Src.class.isAssignableFrom(ofMatch.getOxmMatchField())) {
/*
* 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.openflow.md.core.extension;
import static org.junit.Assert.assertNotNull;
@Mock
private ExtensionConverterProvider extensionConverterProvider;
- private static final int PRESET_COUNT = 7;
- private static final MatchEntrySerializerKey<? extends OxmClassBase, ? extends MatchField> KEY =
- new MatchEntrySerializerKey<>(OpenflowVersion.OF13.getVersion(), MockOxmClassBase.class, MockMatchField.class);
+ private static final MatchEntrySerializerKey<? extends OxmClassBase, ? extends MatchField> KEY_1 =
+ new MatchEntrySerializerKey<>(OpenflowVersion.OF13.getVersion(), MockOxmClassBase.class, MockMatchField1.class);
+ private static final MatchEntrySerializerKey<? extends OxmClassBase, ? extends MatchField> KEY_2 =
+ new MatchEntrySerializerKey<>(OpenflowVersion.OF13.getVersion(), MockOxmClassBase.class, MockMatchField2.class);
@Before
public void setup() {
OFSessionUtil.getSessionManager().setExtensionConverterProvider(extensionConverterProvider);
- when(extensionConverterProvider.getConverter(KEY))
- .thenReturn((input, path) -> {
- MockAugmentation mockAugmentation = new MockAugmentation();
- return new ExtensionAugment<>(MockAugmentation.class, mockAugmentation, MockExtensionKey.class);
- });
+ when(extensionConverterProvider.getConverter(KEY_1))
+ .thenReturn((input, path) -> {
+ MockAugmentation mockAugmentation = new MockAugmentation();
+ return new ExtensionAugment<>(MockAugmentation.class, mockAugmentation, MockExtensionKey1.class);
+ });
+ when(extensionConverterProvider.getConverter(KEY_2))
+ .thenReturn((input, path) -> {
+ MockAugmentation mockAugmentation = new MockAugmentation();
+ return new ExtensionAugment<>(MockAugmentation.class, mockAugmentation, MockExtensionKey2.class);
+ });
}
private static List<MatchEntry> createMatchEntrieses() {
+ MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+ matchEntryBuilder.setHasMask(true);
+ matchEntryBuilder.setOxmClass(MockOxmClassBase.class);
+ matchEntryBuilder.setOxmMatchField(MockMatchField1.class);
List<MatchEntry> matchEntries = new ArrayList<>();
- for (int i = 0; i < PRESET_COUNT; i++) {
- MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
- matchEntryBuilder.setHasMask(true);
- matchEntryBuilder.setOxmClass(MockOxmClassBase.class);
- matchEntryBuilder.setOxmMatchField(MockMatchField.class);
- matchEntries.add(matchEntryBuilder.build());
- }
+ matchEntries.add(matchEntryBuilder.build());
+
+
+ MatchEntryBuilder matchEntryBuilder1 = new MatchEntryBuilder();
+ matchEntryBuilder1.setHasMask(true);
+ matchEntryBuilder1.setOxmClass(MockOxmClassBase.class);
+ matchEntryBuilder1.setOxmMatchField(MockMatchField2.class);
+ matchEntries.add(matchEntryBuilder1.build());
return matchEntries;
}
}
- private interface MockMatchField extends MatchField {
+ private class MockMatchField1 implements MatchField {
+ }
+
+ private class MockMatchField2 implements MatchField {
+ }
+
+ private interface MockExtensionKey1 extends ExtensionKey {
}
- private interface MockExtensionKey extends ExtensionKey {
+ private interface MockExtensionKey2 extends ExtensionKey {
}
private final class MockAugmentation implements Augmentation<Extension> {
-
+ @Override
+ public Class<MockAugmentation> implementedInterface() {
+ return MockAugmentation.class;
+ }
}
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
bucketB.setWeight(10);
bucketB.setWatchPort(20L);
bucketB.setWatchGroup(22L);
+ bucketB.withKey(new BucketKey(new BucketId(Uint32.ZERO)));
bucketB.setAction(actionsList);
final Bucket bucket = bucketB.build();
bucketB1.setWeight(50);
bucketB1.setWatchPort(60L);
bucketB1.setWatchGroup(70L);
+ bucketB1.withKey(new BucketKey(new BucketId(Uint32.ONE)));
// Action1
final CopyTtlInBuilder copyTtlB = new CopyTtlInBuilder();
final BucketBuilder bucketB = new BucketBuilder();
- bucketB.setAction(actionsList);
+ bucketB.setAction(actionsList).withKey(new BucketKey(new BucketId(Uint32.ZERO)));
final Bucket bucket = bucketB.build();
bucketList.add(bucket); // List of bucket
// Action2:
actionsList1.add(assembleSetMplsTtlActionBuilder(actionOrder++).build());
- bucketB1.setAction(actionsList1);
+ bucketB1.setAction(actionsList1).withKey(new BucketKey(new BucketId(Uint32.ONE)));
final Bucket bucket1 = bucketB1.build(); // second bucket
final BucketBuilder bucketB = new BucketBuilder();
- bucketB.setAction(actionsList);
+ bucketB.setAction(actionsList).withKey(new BucketKey(new BucketId(Uint32.ZERO)));
final Bucket bucket = bucketB.build();
bucketList.add(bucket); // List of bucket
// Action2:
actionsList1.add(assembleSetMplsTtlActionBuilder(actionOrder++).build());
- bucketB1.setAction(actionsList);
+ bucketB1.setAction(actionsList).withKey(new BucketKey(new BucketId(Uint32.ONE)));
final Bucket bucket1 = bucketB1.build(); // second bucket
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import org.junit.Assert;
Assert.assertEquals("Wrong type", GroupTypes.GroupAll, stat.getGroupType());
Assert.assertEquals("Wrong group-id", 42, stat.getGroupId().getValue().intValue());
Assert.assertEquals("Wrong key", 42, stat.key().getGroupId().getValue().intValue());
- Assert.assertEquals("Wrong buckets size", 0, stat.getBuckets().getBucket().size());
+ Assert.assertEquals("Wrong buckets size", 0, stat.getBuckets().nonnullBucket().size());
}
/**
Assert.assertEquals("Wrong type", GroupTypes.GroupFf, stat.getGroupType());
Assert.assertEquals("Wrong group-id", 42, stat.getGroupId().getValue().intValue());
Assert.assertEquals("Wrong key", 42, stat.key().getGroupId().getValue().intValue());
- Assert.assertEquals("Wrong buckets size", 1, stat.getBuckets().getBucket().size());
+ Assert.assertEquals("Wrong buckets size", 1, stat.getBuckets().nonnullBucket().size());
// Test first bucket for first group desc
- Bucket bucket = stat.getBuckets().getBucket().get(0);
+ Iterator<Bucket> bucketIt = stat.getBuckets().nonnullBucket().values().iterator();
+ Bucket bucket = bucketIt.next();
Assert.assertEquals("Wrong type", 0, bucket.key().getBucketId().getValue().intValue());
Assert.assertEquals("Wrong type", 0, bucket.getBucketId().getValue().intValue());
Assert.assertEquals("Wrong type", 16, bucket.getWeight().intValue());
// Test first action for first bucket for first group desc
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list
- .Action action = bucket.getAction().get(0);
+ .Action action = bucket.nonnullAction().values().iterator().next();
Assert.assertEquals("Wrong type", 0, action.getOrder().intValue());
Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112"
+ ".action.action.CopyTtlInCase", action.getAction().implementedInterface().getName());
Assert.assertEquals("Wrong type", GroupTypes.GroupIndirect, stat.getGroupType());
Assert.assertEquals("Wrong group-id", 50, stat.getGroupId().getValue().intValue());
Assert.assertEquals("Wrong key", 50, stat.key().getGroupId().getValue().intValue());
- Assert.assertEquals("Wrong buckets size", 2, stat.getBuckets().getBucket().size());
+ Assert.assertEquals("Wrong buckets size", 2, stat.getBuckets().nonnullBucket().size());
// Test first bucket for second group desc
- bucket = stat.getBuckets().getBucket().get(0);
+ bucketIt = stat.getBuckets().nonnullBucket().values().iterator();
+ bucket = bucketIt.next();
Assert.assertEquals("Wrong type", 0, bucket.key().getBucketId().getValue().intValue());
Assert.assertEquals("Wrong type", 0, bucket.getBucketId().getValue().intValue());
Assert.assertEquals("Wrong type", 100, bucket.getWeight().intValue());
Assert.assertEquals("Wrong type", 400, bucket.getWatchGroup().intValue());
Assert.assertEquals("Wrong type", 200, bucket.getWatchPort().intValue());
- Assert.assertEquals("Wrong type", 3, bucket.getAction().size());
+ Assert.assertEquals("Wrong type", 3, bucket.nonnullAction().size());
// Test first action for first bucket of second group desc
- action = bucket.getAction().get(0);
+ var actionIt = bucket.nonnullAction().values().iterator();
+ action = actionIt.next();
Assert.assertEquals("Wrong type", 0, action.getOrder().intValue());
Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112"
+ ".action.action.CopyTtlOutCase", action.getAction().implementedInterface().getName());
// Test second action for first bucket of second group desc
- action = bucket.getAction().get(1);
+ action = actionIt.next();
Assert.assertEquals("Wrong type", 1, action.getOrder().intValue());
Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112"
+ ".action.action.DecNwTtlCase", action.getAction().implementedInterface().getName());
// Test third action for first bucket of second group desc
- action = bucket.getAction().get(2);
+ action = actionIt.next();
Assert.assertEquals("Wrong type", 2, action.getOrder().intValue());
Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112"
+ ".action.action.PopPbbActionCase", action.getAction().implementedInterface().getName());
// Test second bucket for second group desc
- bucket = stat.getBuckets().getBucket().get(1);
+ bucket = bucketIt.next();
Assert.assertEquals("Wrong type", 1, bucket.key().getBucketId().getValue().intValue());
Assert.assertEquals("Wrong type", 1, bucket.getBucketId().getValue().intValue());
Assert.assertEquals("Wrong type", 5, bucket.getWeight().intValue());
Assert.assertEquals("Wrong type", 15, bucket.getWatchGroup().intValue());
Assert.assertEquals("Wrong type", 10, bucket.getWatchPort().intValue());
- Assert.assertEquals("Wrong type", 0, bucket.getAction().size());
+ Assert.assertEquals("Wrong type", 0, bucket.nonnullAction().size());
}
private List<GroupDescStats> convert(List<GroupDesc> groupDescStats,VersionConvertorData data) {
import java.math.BigInteger;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import org.junit.Assert;
Assert.assertEquals("Wrong byte count", 12345, stat.getByteCount().getValue().intValue());
Assert.assertEquals("Wrong duration sec", 5000, stat.getDuration().getSecond().getValue().intValue());
Assert.assertEquals("Wrong duration n sec", 1000000, stat.getDuration().getNanosecond().getValue().intValue());
- Assert.assertEquals("Wrong bucket stats", 0, stat.getBuckets().getBucketCounter().size());
+ Assert.assertEquals("Wrong bucket stats", 0, stat.getBuckets().nonnullBucketCounter().size());
}
/**
Assert.assertEquals("Wrong byte count", 12345, stat.getByteCount().getValue().intValue());
Assert.assertEquals("Wrong duration sec", 5000, stat.getDuration().getSecond().getValue().intValue());
Assert.assertEquals("Wrong duration n sec", 1000000, stat.getDuration().getNanosecond().getValue().intValue());
- Assert.assertEquals("Wrong bucket stats", 0, stat.getBuckets().getBucketCounter().size());
+ Assert.assertEquals("Wrong bucket stats", 0, stat.getBuckets().nonnullBucketCounter().size());
stat = salGroupStats.get(1);
Assert.assertEquals("Wrong group-id", 4, stat.getGroupId().getValue().intValue());
Assert.assertEquals("Wrong key", 4, stat.key().getGroupId().getValue().intValue());
Assert.assertEquals("Wrong byte count", 1, stat.getByteCount().getValue().intValue());
Assert.assertEquals("Wrong duration sec", 3, stat.getDuration().getSecond().getValue().intValue());
Assert.assertEquals("Wrong duration n sec", 2, stat.getDuration().getNanosecond().getValue().intValue());
- Assert.assertEquals("Wrong bucket stats", 0, stat.getBuckets().getBucketCounter().size());
+ Assert.assertEquals("Wrong bucket stats", 0, stat.getBuckets().nonnullBucketCounter().size());
}
/**
Assert.assertEquals("Wrong duration sec", 5000, stat.getDuration().getSecond().getValue().intValue());
Assert.assertEquals("Wrong duration n sec", 1000000, stat.getDuration().getNanosecond().getValue().intValue());
Assert.assertEquals("Wrong bucket stats", 2, stat.getBuckets().getBucketCounter().size());
- List<BucketCounter> list = stat.getBuckets().getBucketCounter();
- Assert.assertEquals("Wrong bucket-id", 0, list.get(0).getBucketId().getValue().intValue());
- Assert.assertEquals("Wrong bucket packet count", 654, list.get(0).getPacketCount().getValue().intValue());
- Assert.assertEquals("Wrong bucket byte count", 987, list.get(0).getByteCount().getValue().intValue());
- Assert.assertEquals("Wrong bucket-id", 1, list.get(1).getBucketId().getValue().intValue());
- Assert.assertEquals("Wrong bucket packet count", 456, list.get(1).getPacketCount().getValue().intValue());
- Assert.assertEquals("Wrong bucket byte count", 123, list.get(1).getByteCount().getValue().intValue());
+ Iterator<BucketCounter> it = stat.getBuckets().nonnullBucketCounter().values().iterator();
+ BucketCounter counter = it.next();
+ Assert.assertEquals("Wrong bucket-id", 0, counter.getBucketId().getValue().intValue());
+ Assert.assertEquals("Wrong bucket packet count", 654, counter.getPacketCount().getValue().intValue());
+ Assert.assertEquals("Wrong bucket byte count", 987, counter.getByteCount().getValue().intValue());
+ counter = it.next();
+ Assert.assertEquals("Wrong bucket-id", 1, counter.getBucketId().getValue().intValue());
+ Assert.assertEquals("Wrong bucket packet count", 456, counter.getPacketCount().getValue().intValue());
+ Assert.assertEquals("Wrong bucket byte count", 123, counter.getByteCount().getValue().intValue());
}
}
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.BandId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterFlags;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.MeterBandHeadersBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.meter.band.header.MeterBandTypesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdMeterBand;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterModCommand;
MeterBandHeaderBuilder meterBandHeaderBuilder = new MeterBandHeaderBuilder();
meterBandHeaderBuilder.setBandType(drp);
meterBandHeaderBuilder.setMeterBandTypes(meterBandTypesB.build());
+ meterBandHeaderBuilder.withKey(new MeterBandHeaderKey(new BandId(Uint32.ZERO)));
final MeterBandHeader meterBH = meterBandHeaderBuilder.build();
MeterBandHeaderBuilder meterBandHeaderBuilder1 = new MeterBandHeaderBuilder();
meterBandHeaderBuilder1.setBandType(dscpRemark);
meterBandHeaderBuilder1.setMeterBandTypes(meterBandTypesB1.build());
+ meterBandHeaderBuilder1.withKey(new MeterBandHeaderKey(new BandId(Uint32.ONE)));
final MeterBandHeader meterBH1 = meterBandHeaderBuilder1.build();
MeterBandHeaderBuilder meterBandHeaderBuilder2 = new MeterBandHeaderBuilder();
meterBandHeaderBuilder2.setBandType(experimenter);
meterBandHeaderBuilder2.setMeterBandTypes(meterBandTypesB2.build());
+ meterBandHeaderBuilder.withKey(new MeterBandHeaderKey(new BandId(Uint32.TWO)));
MeterBandHeader meterBH2 = meterBandHeaderBuilder2.build();
List<MeterBandHeader> meterBandList = new ArrayList<>();
MeterBandHeaderBuilder meterBandHeaderBuilder = new MeterBandHeaderBuilder();
meterBandHeaderBuilder.setBandType(drp);
meterBandHeaderBuilder.setMeterBandTypes(meterBandTypesB.build());
+ meterBandHeaderBuilder.withKey(new MeterBandHeaderKey(new BandId(Uint32.ZERO)));
final MeterBandHeader meterBH = meterBandHeaderBuilder.build();
MeterBandHeaderBuilder meterBandHeaderBuilder1 = new MeterBandHeaderBuilder();
meterBandHeaderBuilder1.setBandType(dscpRemark);
meterBandHeaderBuilder1.setMeterBandTypes(meterBandTypesB1.build());
+ meterBandHeaderBuilder1.withKey(new MeterBandHeaderKey(new BandId(Uint32.ONE)));
final MeterBandHeader meterBH1 = meterBandHeaderBuilder1.build();
MeterBandHeaderBuilder meterBandHeaderBuilder2 = new MeterBandHeaderBuilder();
meterBandHeaderBuilder2.setBandType(experimenter);
meterBandHeaderBuilder2.setMeterBandTypes(meterBandTypesB2.build());
+ meterBandHeaderBuilder2.withKey(new MeterBandHeaderKey(new BandId(Uint32.TWO)));
MeterBandHeader meterBH2 = meterBandHeaderBuilder2.build();
List<MeterBandHeader> meterBandList = new ArrayList<>();
meterBandTypesB.setFlags(bandFlag);// _ofpmbtDrop
meterBandHeaderBuilder.setMeterBandTypes(meterBandTypesB.build());
+ meterBandHeaderBuilder.withKey(new MeterBandHeaderKey(new BandId(Uint32.ZERO)));
final MeterBandHeader meterBH = meterBandHeaderBuilder.build();
MeterBandHeaderBuilder meterBandHeaderBuilder1 = new MeterBandHeaderBuilder();
meterBandHeaderBuilder1.setBandType(dscpRemark);
meterBandHeaderBuilder1.setMeterBandTypes(meterBandTypesB1.build());
+ meterBandHeaderBuilder1.withKey(new MeterBandHeaderKey(new BandId(Uint32.ONE)));
final MeterBandHeader meterBH1 = meterBandHeaderBuilder1.build();
MeterBandTypesBuilder meterBandTypesB2 = new MeterBandTypesBuilder();
meterBandHeaderBuilder2.setMeterBandTypes(meterBandTypesB2.build());
+ meterBandHeaderBuilder2.withKey(new MeterBandHeaderKey(new BandId(Uint32.TWO)));
MeterBandHeader meterBH2 = meterBandHeaderBuilder2.build();
List<MeterBandHeader> meterBandList = new ArrayList<>();
assertEquals(Uint32.valueOf(cnt), meterStats.getFlowCount().getValue());
assertEquals(Uint64.valueOf(cnt), meterStats.getByteInCount().getValue());
- assertEquals(PRESET_COUNT, meterStats.getMeterBandStats().getBandStat().size());
+ assertEquals(PRESET_COUNT, meterStats.getMeterBandStats().nonnullBandStat().size());
int bandStatCount = 0;
- for (BandStat bandStat : meterStats.getMeterBandStats().getBandStat()) {
+ for (BandStat bandStat : meterStats.getMeterBandStats().nonnullBandStat().values()) {
assertEquals(Uint64.valueOf(bandStatCount), bandStat.getByteBandCount().getValue());
assertEquals(Uint64.valueOf(bandStatCount), bandStat.getPacketBandCount().getValue());
bandStatCount++;
import java.math.BigInteger;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Optional;
import org.junit.Assert;
TransmitPacketInputBuilder transmitPacketInputBuilder = new TransmitPacketInputBuilder();
- Long bufferId = null;
-
String nodeId = "0";
String port = "0";
NodeConnectorRef egressConfRef = new NodeConnectorRef(
createNodeConnRef(nodeId, nodeConnKey));
- transmitPacketInputBuilder.setBufferId(bufferId);
+ transmitPacketInputBuilder.setBufferId((Uint32) null);
transmitPacketInputBuilder.setConnectionCookie(null);
- transmitPacketInputBuilder.setAction(null);
transmitPacketInputBuilder.setNode(ref);
transmitPacketInputBuilder.setPayload(null);
transmitPacketInputBuilder.setEgress(egressConfRef);
Optional<List<Action>> actionsOptional = convertorManager.convert(actionList, actionConvertorData);
- List<Action> actions = actionsOptional.orElse(Collections.emptyList());
+ List<Action> actions = actionsOptional.orElse(null);
Assert.assertEquals(actions, message.getAction());
Assert.assertArrayEquals(transmitPacketInput.getPayload(), message.getData());
}
import java.math.BigInteger;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TablePropertiesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesKey;
public class TableFeaturesConvertorTest {
private static final TablePropertiesBuilder TABLE_PROPERTIES_BUILDER = new TablePropertiesBuilder();
}
private static void setupFieldTableFeatures() {
+ int order = 0;
SetFieldMatchBuilder setFieldMatchBuilder = new SetFieldMatchBuilder();
setFieldMatchBuilder.setHasMask(true);
setFieldMatchBuilder
.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class);
FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
setFieldMatchBuilder
- .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class);
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc.class);
FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
setFieldMatchBuilder
.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp.class);
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder actionBuilder =
new ActionBuilder();
+ int order = 0;
OutputActionCaseBuilder outputActionCaseBuilder = new OutputActionCaseBuilder();
- ACTIONS.add(actionBuilder.setAction(outputActionCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setOrder(order++).setAction(outputActionCaseBuilder.build()).build());
GroupActionCaseBuilder groupActionCaseBuilder = new GroupActionCaseBuilder();
- ACTIONS.add(actionBuilder.setAction(groupActionCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setOrder(order++).setAction(groupActionCaseBuilder.build()).build());
CopyTtlOutCaseBuilder copyTtlOutCaseBuilder = new CopyTtlOutCaseBuilder();
- ACTIONS.add(actionBuilder.setAction(copyTtlOutCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setOrder(order++).setAction(copyTtlOutCaseBuilder.build()).build());
CopyTtlInCaseBuilder copyTtlInCaseBuilder = new CopyTtlInCaseBuilder();
- ACTIONS.add(actionBuilder.setAction(copyTtlInCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setOrder(order++).setAction(copyTtlInCaseBuilder.build()).build());
SetMplsTtlActionCaseBuilder setMplsTtlActionCaseBuilder = new SetMplsTtlActionCaseBuilder();
- ACTIONS.add(actionBuilder.setAction(setMplsTtlActionCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setOrder(order++).setAction(setMplsTtlActionCaseBuilder.build()).build());
DecMplsTtlCaseBuilder decMplsTtlCaseBuilder = new DecMplsTtlCaseBuilder();
- ACTIONS.add(actionBuilder.setAction(decMplsTtlCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setOrder(order++).setAction(decMplsTtlCaseBuilder.build()).build());
PushVlanActionCaseBuilder pushVlanActionCaseBuilder = new PushVlanActionCaseBuilder();
- ACTIONS.add(actionBuilder.setAction(pushVlanActionCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setOrder(order++).setAction(pushVlanActionCaseBuilder.build()).build());
PopVlanActionCaseBuilder popVlanActionCaseBuilder = new PopVlanActionCaseBuilder();
- ACTIONS.add(actionBuilder.setAction(popVlanActionCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setOrder(order++).setAction(popVlanActionCaseBuilder.build()).build());
PushMplsActionCaseBuilder pushMplsActionCaseBuilder = new PushMplsActionCaseBuilder();
- ACTIONS.add(actionBuilder.setAction(pushMplsActionCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setOrder(order++).setAction(pushMplsActionCaseBuilder.build()).build());
PopMplsActionCaseBuilder popMplsActionCaseBuilder = new PopMplsActionCaseBuilder();
- ACTIONS.add(actionBuilder.setAction(popMplsActionCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setOrder(order++).setAction(popMplsActionCaseBuilder.build()).build());
SetQueueActionCaseBuilder setQueueActionCaseBuilder = new SetQueueActionCaseBuilder();
- ACTIONS.add(actionBuilder.setAction(setQueueActionCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setOrder(order++).setAction(setQueueActionCaseBuilder.build()).build());
SetNwTtlActionCaseBuilder setNwTtlActionCaseBuilder = new SetNwTtlActionCaseBuilder();
- ACTIONS.add(actionBuilder.setAction(setNwTtlActionCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setOrder(order++).setAction(setNwTtlActionCaseBuilder.build()).build());
DecNwTtlCaseBuilder decNwTtlCaseBuilder = new DecNwTtlCaseBuilder();
- ACTIONS.add(actionBuilder.setAction(decNwTtlCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setOrder(order++).setAction(decNwTtlCaseBuilder.build()).build());
SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
- ACTIONS.add(actionBuilder.setAction(setFieldCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setOrder(order++).setAction(setFieldCaseBuilder.build()).build());
PushPbbActionCaseBuilder pushPbbActionCaseBuilder = new PushPbbActionCaseBuilder();
- ACTIONS.add(actionBuilder.setAction(pushPbbActionCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setOrder(order++).setAction(pushPbbActionCaseBuilder.build()).build());
PopPbbActionCaseBuilder popPbbActionCaseBuilder = new PopPbbActionCaseBuilder();
- ACTIONS.add(actionBuilder.setAction(popPbbActionCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setOrder(order++).setAction(popPbbActionCaseBuilder.build()).build());
}
setupFieldTableFeatures();
InstructionsBuilder instructionsBuilder = new InstructionsBuilder();
List<Instruction> instructions = new ArrayList<>();
- for (int i = 0; i < INSTRUCTIONS_LIST.size(); i++) {
- InstructionBuilder instructionBuilder = new InstructionBuilder();
- instructionBuilder.setInstruction(INSTRUCTIONS_LIST.get(i));
- instructions.add(instructionBuilder.build());
+ int order = 0;
+ for (var element : INSTRUCTIONS_LIST) {
+ instructions.add(new InstructionBuilder()
+ .setOrder(order++)
+ .setInstruction(element).build());
}
org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature
.prop.type.instructions.InstructionsBuilder instructionsBuilder1 =
assertNotNull(tableFeatures);
assertEquals(10, tableFeatures.getTableFeatures().size());
- List<TableFeatureProperties> tableFeaturePropertieses = tableFeatures.getTableFeatures().get(0)
- .getTableProperties().getTableFeatureProperties();
+ Collection<TableFeatureProperties> tableFeaturePropertieses = tableFeatures.nonnullTableFeatures().values()
+ .iterator().next().getTableProperties().nonnullTableFeatureProperties().values();
assertEquals(AUGMENTATIONS_MAP.size() + 1, tableFeaturePropertieses.size());
org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature
.prop.type.ApplyActionsMiss applyActionsMiss = null;
- for (int i = 0; i < tableFeaturePropertieses.size(); i++) {
- if (tableFeaturePropertieses.get(i).getTableFeaturePropType().implementedInterface().isAssignableFrom(
- org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
- .feature.prop.type.ApplyActionsMiss.class)) {
+ for (var featureProp : tableFeaturePropertieses) {
+ var prop = featureProp.getTableFeaturePropType();
+ if (prop.implementedInterface().isAssignableFrom(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types
+ .rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss.class)) {
applyActionsMiss = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature
- .prop.type.table.feature.prop.type.ApplyActionsMiss) tableFeaturePropertieses.get(i)
- .getTableFeaturePropType();
+ .prop.type.table.feature.prop.type.ApplyActionsMiss) prop;
break;
}
}
TableFeaturePropertiesBuilder tableFeaturePropertiesBuilder = new TableFeaturePropertiesBuilder();
List<TableFeatureProperties> tableFeaturePropertieses = new ArrayList<>();
int counter = 0;
+ int order = 0;
for (Entry<Class<? extends TableFeaturePropType>, TableFeaturePropType> entry : AUGMENTATIONS_MAP.entrySet()) {
counter++;
tableFeaturePropertiesBuilder.setTableFeaturePropType(entry.getValue());
tableFeaturePropertiesBuilder.setOrder(counter);
+ tableFeaturePropertiesBuilder.withKey(new TableFeaturePropertiesKey(order++));
tableFeaturePropertieses.add(tableFeaturePropertiesBuilder.build());
}
- tableFeaturePropertieses.add(tableFeaturePropertiesBuilder.build());
+ tableFeaturePropertieses.add(
+ tableFeaturePropertiesBuilder.withKey(new TableFeaturePropertiesKey(order++)).build());
TABLE_PROPERTIES_BUILDER.setTableFeatureProperties(tableFeaturePropertieses);
return TABLE_PROPERTIES_BUILDER.build();
}
package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import org.junit.Assert;
Assert.assertEquals("Wrong metadata write", Uint64.valueOf("08090A0B0C0D0E0F", 16), feature.getMetadataWrite());
Assert.assertEquals("Wrong config", false, feature.getConfig().isDEPRECATEDMASK());
Assert.assertEquals("Wrong max-entries", 42, feature.getMaxEntries().intValue());
- Assert.assertEquals("Wrong properties", 0, feature.getTableProperties().getTableFeatureProperties().size());
+ Assert.assertEquals("Wrong properties", 0, feature.getTableProperties().nonnullTableFeatureProperties().size());
}
/**
Assert.assertEquals("Wrong metadata write",Uint64.valueOf("08090A0B0C0D0E0F", 16), feature.getMetadataWrite());
Assert.assertEquals("Wrong config", false, feature.getConfig().isDEPRECATEDMASK());
Assert.assertEquals("Wrong max-entries", 42, feature.getMaxEntries().intValue());
- Assert.assertEquals("Wrong properties", 4, feature.getTableProperties().getTableFeatureProperties().size());
+ Assert.assertEquals("Wrong properties", 4, feature.getTableProperties().nonnullTableFeatureProperties().size());
+
+ var featProps = feature.getTableProperties().getTableFeatureProperties().values().iterator();
org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table
- .properties.TableFeatureProperties property = feature.getTableProperties().getTableFeatureProperties()
- .get(0);
+ .properties.TableFeatureProperties property = featProps.next();
Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ "rev131026.table.feature.prop.type.table.feature.prop.type.NextTable",
property.getTableFeaturePropType().implementedInterface().getName());
Assert.assertEquals("Wrong next table-id size", 2, ids.size());
Assert.assertEquals("Wrong next-registry-id", 1, ids.get(0).intValue());
Assert.assertEquals("Wrong next-registry-id", 2, ids.get(1).intValue());
- property = feature.getTableProperties().getTableFeatureProperties().get(1);
+ property = featProps.next();
Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ "rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMiss",
property.getTableFeaturePropType().implementedInterface().getName());
Assert.assertEquals("Wrong next table-id size", 1, ids.size());
Assert.assertEquals("Wrong next-registry-id", 3, ids.get(0).intValue());
- property = feature.getTableProperties().getTableFeatureProperties().get(2);
+ property = featProps.next();
Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ "rev131026.table.feature.prop.type.table.feature.prop.type.Instructions",
property.getTableFeaturePropType().implementedInterface().getName());
Instructions propType3 = (Instructions) property.getTableFeaturePropType();
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list
- .Instruction> instructionIds = propType3.getInstructions().getInstruction();
+ var instructionIds = propType3.getInstructions().nonnullInstruction().values();
Assert.assertEquals("Wrong instruction-ids size", 2, instructionIds.size());
+ var instructionIt = instructionIds.iterator();
Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types."
+ "rev131026.instruction.instruction.WriteActionsCase",
- instructionIds.get(0).getInstruction().implementedInterface().getName());
+ instructionIt.next().getInstruction().implementedInterface().getName());
Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types."
+ "rev131026.instruction.instruction.GoToTableCase",
- instructionIds.get(1).getInstruction().implementedInterface().getName());
- property = feature.getTableProperties().getTableFeatureProperties().get(3);
+ instructionIt.next().getInstruction().implementedInterface().getName());
+ property = featProps.next();
Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ "rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMiss",
property.getTableFeaturePropType().implementedInterface().getName());
InstructionsMiss propType4 = (InstructionsMiss) property.getTableFeaturePropType();
- instructionIds = propType4.getInstructionsMiss().getInstruction();
+ instructionIds = propType4.getInstructionsMiss().nonnullInstruction().values();
Assert.assertEquals("Wrong instruction-ids size", 5, instructionIds.size());
+ instructionIt = instructionIds.iterator();
Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types."
+ "rev131026.instruction.instruction.WriteMetadataCase",
- instructionIds.get(0).getInstruction().implementedInterface().getName());
+ instructionIt.next().getInstruction().implementedInterface().getName());
Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types."
+ "rev131026.instruction.instruction.ApplyActionsCase",
- instructionIds.get(1).getInstruction().implementedInterface().getName());
+ instructionIt.next().getInstruction().implementedInterface().getName());
Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types."
+ "rev131026.instruction.instruction.MeterCase",
- instructionIds.get(2).getInstruction().implementedInterface().getName());
+ instructionIt.next().getInstruction().implementedInterface().getName());
Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types."
+ "rev131026.instruction.instruction.ClearActionsCase",
- instructionIds.get(3).getInstruction().implementedInterface().getName());
+ instructionIt.next().getInstruction().implementedInterface().getName());
Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types."
+ "rev131026.instruction.instruction.GoToTableCase",
- instructionIds.get(4).getInstruction().implementedInterface().getName());
+ instructionIt.next().getInstruction().implementedInterface().getName());
feature = list.get(1);
Assert.assertEquals("Wrong table-id", 6, feature.getTableId().intValue());
Assert.assertEquals("Wrong config", false, feature.getConfig().isDEPRECATEDMASK());
Assert.assertEquals("Wrong max-entries", 24, feature.getMaxEntries().intValue());
Assert.assertEquals("Wrong properties", 12, feature.getTableProperties().getTableFeatureProperties().size());
- property = feature.getTableProperties().getTableFeatureProperties().get(0);
+ featProps = feature.getTableProperties().nonnullTableFeatureProperties().values().iterator();
+ property = featProps.next();
Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ "rev131026.table.feature.prop.type.table.feature.prop.type.Match",
property.getTableFeaturePropType().implementedInterface().getName());
Match propType5 = (Match) property.getTableFeaturePropType();
- List<SetFieldMatch> fieldMatch = propType5.getMatchSetfield().getSetFieldMatch();
+ Collection<SetFieldMatch> fieldMatch = propType5.getMatchSetfield().nonnullSetFieldMatch().values();
Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());
+ Iterator<SetFieldMatch> fieldIt = fieldMatch.iterator();
Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
- + "rev131026.InPhyPort", fieldMatch.get(0).getMatchType().getName());
+ + "rev131026.InPhyPort", fieldIt.next().getMatchType().getName());
Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
- + "rev131026.InPort", fieldMatch.get(1).getMatchType().getName());
- property = feature.getTableProperties().getTableFeatureProperties().get(1);
+ + "rev131026.InPort", fieldIt.next().getMatchType().getName());
+ property = featProps.next();
Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ "rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfield",
property.getTableFeaturePropType().implementedInterface().getName());
ApplySetfield propType6 = (ApplySetfield) property.getTableFeaturePropType();
- fieldMatch = propType6.getApplySetfield().getSetFieldMatch();
+ fieldMatch = propType6.getApplySetfield().nonnullSetFieldMatch().values();
Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());
+ fieldIt = fieldMatch.iterator();
Assert.assertEquals("Wrong match-entry-id",
"org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto",
- fieldMatch.get(0).getMatchType().getName());
+ fieldIt.next().getMatchType().getName());
Assert.assertEquals("Wrong match-entry-id",
"org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn",
- fieldMatch.get(1).getMatchType().getName());
- property = feature.getTableProperties().getTableFeatureProperties().get(2);
+ fieldIt.next().getMatchType().getName());
+ property = featProps.next();
Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ "rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfield",
property.getTableFeaturePropType().implementedInterface().getName());
WriteSetfield propType7 = (WriteSetfield) property.getTableFeaturePropType();
- fieldMatch = propType7.getWriteSetfield().getSetFieldMatch();
+ fieldMatch = propType7.getWriteSetfield().nonnullSetFieldMatch().values();
Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());
+ fieldIt = fieldMatch.iterator();
Assert.assertEquals("Wrong match-entry-id",
"org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr",
- fieldMatch.get(0).getMatchType().getName());
+ fieldIt.next().getMatchType().getName());
Assert.assertEquals("Wrong match-entry-id",
"org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid",
- fieldMatch.get(1).getMatchType().getName());
- property = feature.getTableProperties().getTableFeatureProperties().get(3);
+ fieldIt.next().getMatchType().getName());
+ property = featProps.next();
Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ "rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMiss",
property.getTableFeaturePropType().implementedInterface().getName());
WriteSetfieldMiss propType8 = (WriteSetfieldMiss) property.getTableFeaturePropType();
- fieldMatch = propType8.getWriteSetfieldMiss().getSetFieldMatch();
+ fieldMatch = propType8.getWriteSetfieldMiss().nonnullSetFieldMatch().values();
Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());
+ fieldIt = fieldMatch.iterator();
Assert.assertEquals("Wrong match-entry-id",
"org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp",
- fieldMatch.get(0).getMatchType().getName());
+ fieldIt.next().getMatchType().getName());
Assert.assertEquals("Wrong match-entry-id",
"org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc",
- fieldMatch.get(1).getMatchType().getName());
- property = feature.getTableProperties().getTableFeatureProperties().get(4);
+ fieldIt.next().getMatchType().getName());
+ property = featProps.next();
Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ "rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMiss",
property.getTableFeaturePropType().implementedInterface().getName());
ApplySetfieldMiss propType9 = (ApplySetfieldMiss) property.getTableFeaturePropType();
- fieldMatch = propType9.getApplySetfieldMiss().getSetFieldMatch();
+ fieldMatch = propType9.getApplySetfieldMiss().nonnullSetFieldMatch().values();
Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());
+ fieldIt = fieldMatch.iterator();
Assert.assertEquals("Wrong match-entry-id",
"org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc",
- fieldMatch.get(0).getMatchType().getName());
+ fieldIt.next().getMatchType().getName());
Assert.assertEquals("Wrong match-entry-id",
"org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst",
- fieldMatch.get(1).getMatchType().getName());
- property = feature.getTableProperties().getTableFeatureProperties().get(5);
+ fieldIt.next().getMatchType().getName());
+ property = featProps.next();
Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ "rev131026.table.feature.prop.type.table.feature.prop.type.Wildcards",
property.getTableFeaturePropType().implementedInterface().getName());
Wildcards propType10 = (Wildcards) property.getTableFeaturePropType();
- fieldMatch = propType10.getWildcardSetfield().getSetFieldMatch();
+ fieldMatch = propType10.getWildcardSetfield().nonnullSetFieldMatch().values();
Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());
+ fieldIt = fieldMatch.iterator();
Assert.assertEquals("Wrong match-entry-id",
"org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc",
- fieldMatch.get(0).getMatchType().getName());
+ fieldIt.next().getMatchType().getName());
Assert.assertEquals("Wrong match-entry-id",
"org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst",
- fieldMatch.get(1).getMatchType().getName());
+ fieldIt.next().getMatchType().getName());
- property = feature.getTableProperties().getTableFeatureProperties().get(6);
+ property = featProps.next();
Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ "rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActions",
property.getTableFeaturePropType().implementedInterface().getName());
org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
.type.ApplyActions propType11 = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table
.feature.prop.type.table.feature.prop.type.ApplyActions) property.getTableFeaturePropType();
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionsList =
- propType11.getApplyActions().getAction();
+ var actionsList = propType11.getApplyActions().nonnullAction().values();
Assert.assertEquals("Wrong actions-ids size", 3, actionsList.size());
+ var actionsIt = actionsList.iterator();
Assert.assertEquals("Wrong actions-id",
"org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase",
- actionsList.get(0).getAction().implementedInterface().getName());
+ actionsIt.next().getAction().implementedInterface().getName());
Assert.assertEquals("Wrong actions-id",
"org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase",
- actionsList.get(1).getAction().implementedInterface().getName());
+ actionsIt.next().getAction().implementedInterface().getName());
Assert.assertEquals("Wrong actions-id",
"org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase",
- actionsList.get(2).getAction().implementedInterface().getName());
+ actionsIt.next().getAction().implementedInterface().getName());
- property = feature.getTableProperties().getTableFeatureProperties().get(7);
+ property = featProps.next();
Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ "rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss",
property.getTableFeaturePropType().implementedInterface().getName());
org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
.type.ApplyActionsMiss propType12 = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026
.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss) property.getTableFeaturePropType();
- actionsList = propType12.getApplyActionsMiss().getAction();
+ actionsList = propType12.getApplyActionsMiss().nonnullAction().values();
Assert.assertEquals("Wrong actions-ids size", 3, actionsList.size());
+ actionsIt = actionsList.iterator();
Assert.assertEquals("Wrong actions-id",
"org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase",
- actionsList.get(0).getAction().implementedInterface().getName());
+ actionsIt.next().getAction().implementedInterface().getName());
Assert.assertEquals("Wrong actions-id",
"org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCase",
- actionsList.get(1).getAction().implementedInterface().getName());
+ actionsIt.next().getAction().implementedInterface().getName());
Assert.assertEquals("Wrong actions-id",
"org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCase",
- actionsList.get(2).getAction().implementedInterface().getName());
- property = feature.getTableProperties().getTableFeatureProperties().get(8);
+ actionsIt.next().getAction().implementedInterface().getName());
+ property = featProps.next();
Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ "rev131026.table.feature.prop.type.table.feature.prop.type.WriteActions",
property.getTableFeaturePropType().implementedInterface().getName());
org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
.type.WriteActions propType13 = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table
.feature.prop.type.table.feature.prop.type.WriteActions) property.getTableFeaturePropType();
- actionsList = propType13.getWriteActions().getAction();
+ actionsList = propType13.getWriteActions().nonnullAction().values();
Assert.assertEquals("Wrong actions-ids size", 3, actionsList.size());
+ actionsIt = actionsList.iterator();
Assert.assertEquals("Wrong actions-id",
"org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCase",
- actionsList.get(0).getAction().implementedInterface().getName());
+ actionsIt.next().getAction().implementedInterface().getName());
Assert.assertEquals("Wrong actions-id",
"org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCase",
- actionsList.get(1).getAction().implementedInterface().getName());
+ actionsIt.next().getAction().implementedInterface().getName());
Assert.assertEquals("Wrong actions-id",
"org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase",
- actionsList.get(2).getAction().implementedInterface().getName());
- property = feature.getTableProperties().getTableFeatureProperties().get(9);
+ actionsIt.next().getAction().implementedInterface().getName());
+ property = featProps.next();
Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ "rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMiss",
property.getTableFeaturePropType().implementedInterface().getName());
org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
.type.WriteActionsMiss propType14 = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026
.table.feature.prop.type.table.feature.prop.type.WriteActionsMiss) property.getTableFeaturePropType();
- actionsList = propType14.getWriteActionsMiss().getAction();
+ actionsList = propType14.getWriteActionsMiss().nonnullAction().values();
Assert.assertEquals("Wrong actions-ids size", 3, actionsList.size());
+ actionsIt = actionsList.iterator();
Assert.assertEquals("Wrong actions-id",
"org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCase",
- actionsList.get(0).getAction().implementedInterface().getName());
+ actionsIt.next().getAction().implementedInterface().getName());
Assert.assertEquals("Wrong actions-id",
"org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCase",
- actionsList.get(1).getAction().implementedInterface().getName());
+ actionsIt.next().getAction().implementedInterface().getName());
Assert.assertEquals("Wrong actions-id",
"org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase",
- actionsList.get(2).getAction().implementedInterface().getName());
+ actionsIt.next().getAction().implementedInterface().getName());
}
private static SetNwSrcCase createSetNwSrcAction() {
Assert.assertEquals("Wrong match",
"org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType",
flowMod.get(0).getMatch().getType().getName());
- Assert.assertEquals("Wrong match entries size", 0, flowMod.get(0).getMatch().getMatchEntry().size());
+ Assert.assertEquals("Wrong match entries size", 0, flowMod.get(0).getMatch().nonnullMatchEntry().size());
}
/**
+ ".instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase",
instruction.getInstructionChoice().implementedInterface().getName());
WriteActionsCase writeActionsCase = (WriteActionsCase) instruction.getInstructionChoice();
- Assert.assertEquals("Wrong actions size", 0, writeActionsCase.getWriteActions().getAction().size());
+ Assert.assertEquals("Wrong actions size", 0, writeActionsCase.getWriteActions().nonnullAction().size());
instruction = flowMod.get(0).getInstruction().get(3);
Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
+ ".instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase",
instruction.getInstructionChoice().implementedInterface().getName());
ApplyActionsCase applyActionsCase = (ApplyActionsCase) instruction.getInstructionChoice();
- Assert.assertEquals("Wrong actions size", 0, applyActionsCase.getApplyActions().getAction().size());
+ Assert.assertEquals("Wrong actions size", 0, applyActionsCase.getApplyActions().nonnullAction().size());
instruction = flowMod.get(0).getInstruction().get(4);
Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
+ ".instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCase",
/**
* Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
*/
- @Test(expected = NullPointerException.class)
public void testEmptyMatch() {
final VersionDatapathIdConvertorData datapathIdConvertorData =
new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
datapathIdConvertorData.setDatapathId(Uint64.valueOf(42));
- convert(new MatchBuilder().build(), datapathIdConvertorData);
+ // Empty null match is the same as empty match
+ Assert.assertNotNull(convert(new MatchBuilder().build(), datapathIdConvertorData));
}
/**
new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
datapathIdConvertorData.setDatapathId(Uint64.valueOf(42));
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow
- .MatchBuilder salMatch = convert(match, datapathIdConvertorData);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder salMatch =
+ convert(match, datapathIdConvertorData);
final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch =
salMatch.build();
<parent>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>binding-parent</artifactId>
- <version>5.0.9</version>
+ <version>6.0.0</version>
<relativePath/>
</parent>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>1.11.0</version>
+ <artifactId>controller-artifacts</artifactId>
+ <version>2.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@Override
public ListenableFuture<?> writeFlowToConfig(InstanceIdentifier<Flow> flowPath, Flow flowBody) {
ReadWriteTransaction addFlowTransaction = dataBrokerService.newReadWriteTransaction();
- addFlowTransaction.put(LogicalDatastoreType.CONFIGURATION, flowPath, flowBody, true);
+ addFlowTransaction.mergeParentStructurePut(LogicalDatastoreType.CONFIGURATION, flowPath, flowBody);
return addFlowTransaction.commit();
}
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>6.0.4</version>
+ <version>7.0.1</version>
<relativePath/>
</parent>
<artifactId>argparse4j</artifactId>
</dependency>
<dependency>
- <groupId>javax.xml.bind</groupId>
- <artifactId>jaxb-api</artifactId>
+ <groupId>jakarta.xml.bind</groupId>
+ <artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
</dependencies>
</project>
if (LOG.isDebugEnabled()) {
LOG.debug("onPacketReceived - About to write flow {}", flow);
}
- transaction.put(LogicalDatastoreType.CONFIGURATION, flowInstanceId, flow, true);
+ transaction.mergeParentStructurePut(LogicalDatastoreType.CONFIGURATION, flowInstanceId, flow);
transaction.commit();
LOG.debug("onPacketReceived - About to write flow commited");
}
InstanceIdentifier<Group> path1 = InstanceIdentifier.create(Nodes.class)
.child(Node.class, testNode12.key()).augmentation(FlowCapableNode.class)
.child(Group.class, new GroupKey(group.getGroupId()));
- modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode12), testNode12, true);
- modification.merge(LogicalDatastoreType.CONFIGURATION, path1, group, true);
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode12),
+ testNode12);
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path1, group);
InstanceIdentifier<Group> path2 = InstanceIdentifier.create(Nodes.class)
.child(Node.class, testNode12.key()).augmentation(FlowCapableNode.class)
.child(Group.class, new GroupKey(group1.getGroupId()));
- modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode12), testNode12, true);
- modification.merge(LogicalDatastoreType.CONFIGURATION, path2, group1, true);
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode12),
+ testNode12);
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path2, group1);
modification.commit().addCallback(new FutureCallback<Object>() {
@Override
public void onSuccess(Object notUsed) {
InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class)
.child(Node.class, nodeBuilder.key()).augmentation(FlowCapableNode.class)
.child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flow.key());
- modification.merge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(),
- true);
- modification.merge(LogicalDatastoreType.OPERATIONAL, path1, flow.build(), true);
- modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder),
- nodeBuilder.build(), true);
- modification.merge(LogicalDatastoreType.CONFIGURATION, path1, flow.build(), true);
+ modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder),
+ nodeBuilder.build());
+ modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, path1, flow.build());
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder),
+ nodeBuilder.build());
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path1, flow.build());
InstanceIdentifier<Flow> path2 = InstanceIdentifier.create(Nodes.class)
.child(Node.class, nodeBuilder.key()).augmentation(FlowCapableNode.class)
.child(Table.class, new TableKey(flow1.getTableId())).child(Flow.class, flow1.key());
- modification.merge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(),
- true);
- modification.merge(LogicalDatastoreType.OPERATIONAL, path2, flow1.build(), true);
- modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder),
- nodeBuilder.build(), true);
- modification.merge(LogicalDatastoreType.CONFIGURATION, path2, flow1.build(), true);
+ modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder),
+ nodeBuilder.build());
+ modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, path2, flow1.build());
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder),
+ nodeBuilder.build());
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path2, flow1.build());
InstanceIdentifier<Flow> path3 = InstanceIdentifier.create(Nodes.class)
.child(Node.class, nodeBuilder.key()).augmentation(FlowCapableNode.class)
.child(Table.class, new TableKey(flow2.getTableId())).child(Flow.class, flow2.key());
- modification.merge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(),
- true);
- modification.merge(LogicalDatastoreType.OPERATIONAL, path3, flow2.build(), true);
- modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder),
- nodeBuilder.build(), true);
- modification.merge(LogicalDatastoreType.CONFIGURATION, path3, flow2.build(), true);
+ modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder),
+ nodeBuilder.build());
+ modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, path3, flow2.build());
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder),
+ nodeBuilder.build());
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path3, flow2.build());
InstanceIdentifier<Flow> path4 = InstanceIdentifier.create(Nodes.class)
.child(Node.class, nodeBuilder.key()).augmentation(FlowCapableNode.class)
.child(Table.class, new TableKey(flow3.getTableId())).child(Flow.class, flow3.key());
- modification.merge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(),
- true);
- modification.merge(LogicalDatastoreType.OPERATIONAL, path4, flow3.build(), true);
- modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder),
- nodeBuilder.build(), true);
- modification.merge(LogicalDatastoreType.CONFIGURATION, path4, flow3.build(), true);
+ modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder),
+ nodeBuilder.build());
+ modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, path4, flow3.build());
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder),
+ nodeBuilder.build());
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path4, flow3.build());
modification.commit().addCallback(new FutureCallback<Object>() {
@Override
public void onSuccess(Object notUsed) {
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.MoreExecutors;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.eclipse.osgi.framework.console.CommandInterpreter;
import org.eclipse.osgi.framework.console.CommandProvider;
bucket.setAction(createInportOutputAction());
break;
case "a24":
- bucket.setAction(null);
+ bucket.setAction(Collections.EMPTY_LIST);
break;
case "a25":
bucket.setAction(createNonAppyOutputAction());
InstanceIdentifier<Group> path1 = InstanceIdentifier.create(Nodes.class)
.child(Node.class, testNode.key()).augmentation(FlowCapableNode.class)
.child(Group.class, new GroupKey(group.getGroupId()));
- modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true);
- modification.merge(LogicalDatastoreType.CONFIGURATION, path1, group, true);
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode),
+ testNode);
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path1, group);
modification.commit().addCallback(new FutureCallback<Object>() {
@Override
public void onSuccess(Object notUsed) {
ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
InstanceIdentifier<Meter> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.key())
.augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(meter.getMeterId()));
- modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true);
- modification.merge(LogicalDatastoreType.CONFIGURATION, path1, meter, true);
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode),
+ testNode);
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path1, meter);
modification.commit().addCallback(new FutureCallback<Object>() {
@Override
public void onSuccess(Object notUsed) {
ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
InstanceIdentifier<Meter> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.key())
.augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(meter.getMeterId()));
- modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true);
- modification.merge(LogicalDatastoreType.CONFIGURATION, path1, meter, true);
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode),
+ testNode);
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path1, meter);
InstanceIdentifier<Meter> path2 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode.key())
.augmentation(FlowCapableNode.class).child(Meter.class, new MeterKey(meter1.getMeterId()));
- modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true);
- modification.merge(LogicalDatastoreType.CONFIGURATION, path2, meter1, true);
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode),
+ testNode);
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path2, meter1);
modification.commit().addCallback(new FutureCallback<Object>() {
@Override
package org.opendaylight.openflowplugin.test;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.util.List;
+import java.util.Collection;
import org.eclipse.osgi.framework.console.CommandInterpreter;
import org.eclipse.osgi.framework.console.CommandProvider;
import org.opendaylight.mdsal.binding.api.DataBroker;
public void _portStats(CommandInterpreter ci) {
int nodeConnectorCount = 0;
int nodeConnectorStatsCount = 0;
- List<Node> nodes = getNodes();
+ Collection<Node> nodes = getNodes();
for (Node node2 : nodes) {
NodeKey nodeKey = node2.key();
InstanceIdentifier<Node> nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey);
Node node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
if (node != null) {
if (node.getNodeConnector() != null) {
- List<NodeConnector> ports = node.getNodeConnector();
+ Collection<NodeConnector> ports = node.nonnullNodeConnector().values();
for (NodeConnector nodeConnector2 : ports) {
nodeConnectorCount++;
public void _portDescStats(CommandInterpreter ci) {
int nodeConnectorCount = 0;
int nodeConnectorDescStatsCount = 0;
- List<Node> nodes = getNodes();
+ Collection<Node> nodes = getNodes();
for (Node node2 : nodes) {
NodeKey nodeKey = node2.key();
InstanceIdentifier<Node> nodeRef = InstanceIdentifier.create(Nodes.class).child(Node.class, nodeKey);
Node node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
if (node != null) {
if (node.getNodeConnector() != null) {
- List<NodeConnector> ports = node.getNodeConnector();
+ Collection<NodeConnector> ports = node.nonnullNodeConnector().values();
for (NodeConnector nodeConnector2 : ports) {
nodeConnectorCount++;
NodeConnectorKey nodeConnectorKey = nodeConnector2.key();
public void _flowStats(CommandInterpreter ci) {
int flowCount = 0;
int flowStatsCount = 0;
- List<Node> nodes = getNodes();
+ Collection<Node> nodes = getNodes();
for (Node node2 : nodes) {
NodeKey nodeKey = node2.key();
InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.create(Nodes.class)
FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
if (node != null) {
- List<Table> tables = node.getTable();
+ Collection<Table> tables = node.nonnullTable().values();
for (Table table2 : tables) {
TableKey tableKey = table2.key();
InstanceIdentifier<Table> tableRef = InstanceIdentifier.create(Nodes.class)
Table table = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, tableRef);
if (table != null) {
if (table.getFlow() != null) {
- List<Flow> flows = table.getFlow();
+ Collection<Flow> flows = table.nonnullFlow().values();
for (Flow flow2 : flows) {
flowCount++;
FlowKey flowKey = flow2.key();
public void _tableStats(CommandInterpreter ci) {
int tableCount = 0;
int tableStatsCount = 0;
- List<Node> nodes = getNodes();
+ Collection<Node> nodes = getNodes();
for (Node node2 : nodes) {
NodeKey nodeKey = node2.key();
InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.create(Nodes.class)
ReadTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
if (node != null) {
- List<Table> tables = node.getTable();
+ Collection<Table> tables = node.nonnullTable().values();
for (Table table2 : tables) {
tableCount++;
TableKey tableKey = table2.key();
int groupCount = 0;
int groupStatsCount = 0;
NodeGroupStatistics data = null;
- List<Node> nodes = getNodes();
+ Collection<Node> nodes = getNodes();
for (Node node2 : nodes) {
NodeKey nodeKey = node2.key();
InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.create(Nodes.class)
FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
if (node != null) {
if (node.getGroup() != null) {
- List<Group> groups = node.getGroup();
+ Collection<Group> groups = node.nonnullGroup().values();
for (Group group2 : groups) {
groupCount++;
GroupKey groupKey = group2.key();
int groupCount = 0;
int groupDescStatsCount = 0;
NodeGroupDescStats data = null;
- List<Node> nodes = getNodes();
+ Collection<Node> nodes = getNodes();
for (Node node2 : nodes) {
NodeKey nodeKey = node2.key();
InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.create(Nodes.class)
if (node != null) {
if (node.getGroup() != null) {
- List<Group> groups = node.getGroup();
+ Collection<Group> groups = node.nonnullGroup().values();
for (Group group2 : groups) {
groupCount++;
GroupKey groupKey = group2.key();
int meterCount = 0;
int meterStatsCount = 0;
NodeMeterStatistics data = null;
- List<Node> nodes = getNodes();
+ Collection<Node> nodes = getNodes();
for (Node node2 : nodes) {
NodeKey nodeKey = node2.key();
InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.create(Nodes.class)
FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
if (node != null) {
if (node.getMeter() != null) {
- List<Meter> meters = node.getMeter();
+ Collection<Meter> meters = node.nonnullMeter().values();
for (Meter meter2 : meters) {
meterCount++;
MeterKey meterKey = meter2.key();
int meterCount = 0;
int meterConfigStatsCount = 0;
NodeMeterConfigStats data = null;
- List<Node> nodes = getNodes();
+ Collection<Node> nodes = getNodes();
for (Node node2 : nodes) {
NodeKey nodeKey = node2.key();
InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.create(Nodes.class)
FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
if (node != null) {
if (node.getMeter() != null) {
- List<Meter> meters = node.getMeter();
+ Collection<Meter> meters = node.nonnullMeter().values();
for (Meter meter2 : meters) {
meterCount++;
MeterKey meterKey = meter2.key();
public void _aggregateStats(CommandInterpreter ci) {
int aggregateFlowCount = 0;
int aggerateFlowStatsCount = 0;
- List<Node> nodes = getNodes();
+ Collection<Node> nodes = getNodes();
for (Node node2 : nodes) {
NodeKey nodeKey = node2.key();
InstanceIdentifier<FlowCapableNode> nodeRef = InstanceIdentifier.create(Nodes.class)
ReadTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
FlowCapableNode node = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodeRef);
if (node != null) {
- List<Table> tables = node.getTable();
+ Collection<Table> tables = node.nonnullTable().values();
for (Table table2 : tables) {
aggregateFlowCount++;
TableKey tableKey = table2.key();
public void _descStats(CommandInterpreter ci) {
int descCount = 0;
int descStatsCount = 0;
- List<Node> nodes = getNodes();
+ Collection<Node> nodes = getNodes();
for (Node node2 : nodes) {
descCount++;
NodeKey nodeKey = node2.key();
}
- private List<Node> getNodes() {
+ private Collection<Node> getNodes() {
ReadTransaction readOnlyTransaction = dataProviderService.newReadOnlyTransaction();
InstanceIdentifier<Nodes> nodesID = InstanceIdentifier.create(Nodes.class);
Nodes nodes = TestProviderTransactionUtil.getDataObject(readOnlyTransaction, nodesID);
if (nodes == null) {
throw new RuntimeException("nodes are not found, pls add the node.");
}
- return nodes.getNode();
+ return nodes.nonnullNode().values();
}
@Override
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
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;
private TableFeaturePropertiesBuilder createInstructionsTblFeatureProp() {
- InstructionBuilder ib = new InstructionBuilder();
- ib.setOrder(1);
- ib.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction
- .instruction.ApplyActionsCaseBuilder().build());
- ib.withKey(new InstructionKey(1));
-
List<Instruction> instLst = new ArrayList<>();
TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
tableFeatureProperty.setTableFeaturePropType(
private TableFeaturePropertiesBuilder createInstructionsMissTblFeatureProp() {
// To set the instructions miss -- "t7"
- InstructionBuilder ib1 = new InstructionBuilder();
- ib1.setOrder(1);
- ib1.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction
- .instruction.WriteMetadataCaseBuilder().build());
- ib1.withKey(new InstructionKey(1));
-
- InstructionBuilder ib2 = new InstructionBuilder();
- ib2.setOrder(2);
- ib2.setInstruction(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction
- .instruction.MeterCaseBuilder().build());
- ib2.withKey(new InstructionKey(2));
-
List<Instruction> instLst = new ArrayList<>();
TableFeaturePropertiesBuilder tableFeatureProperty = new TableFeaturePropertiesBuilder();
tableFeatureProperty.setTableFeaturePropType(
.child(Node.class, testNode.key()).augmentation(FlowCapableNode.class)
.child(TableFeatures.class, new TableFeaturesKey(tableFeatures.getTableId()));
- modification.merge(LogicalDatastoreType.OPERATIONAL, nodeToInstanceId(testNode), testNode, true);
- modification.merge(LogicalDatastoreType.OPERATIONAL, path1, tableFeatures, true);
- modification.merge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode), testNode, true);
- modification.merge(LogicalDatastoreType.CONFIGURATION, path1, tableFeatures, true);
+ modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, nodeToInstanceId(testNode), testNode);
+ modification.mergeParentStructureMerge(LogicalDatastoreType.OPERATIONAL, path1, tableFeatures);
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, nodeToInstanceId(testNode),
+ testNode);
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path1, tableFeatures);
modification.commit().addCallback(new FutureCallback<Object>() {
@Override
public void onSuccess(Object notUsed) {
final List<Action> actionList = new ArrayList<>();
final ActionBuilder ab = new ActionBuilder();
- final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
- setFieldBuilder.setInPort(new NodeConnectorId(nodeId + ":2"));
ab.withKey(new ActionKey(0));
actionList.add(ab.build());
setFieldBuilder1.setLayer4Match(tcpmatch1.build());
ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
ab1.withKey(new ActionKey(1));
- actionList.add(ab.build());
+ actionList.add(ab1.build());
final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
final InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class)
.child(Node.class, nodeBuilder.key()).augmentation(FlowCapableNode.class)
.child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flow.key());
- modification.merge(LogicalDatastoreType.CONFIGURATION,
- nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
- modification.merge(LogicalDatastoreType.CONFIGURATION, path1, flow.build(), true);
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION,
+ nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
+ modification.mergeParentStructureMerge(LogicalDatastoreType.CONFIGURATION, path1, flow.build());
modification.commit().addCallback(new FutureCallback<Object>() {
@Override
public void onSuccess(final Object notUsed) {