use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey in project openflowplugin by opendaylight.
the class SyncPlanPushStrategyIncrementalImpl method flushAddGroupPortionAndBarrier.
private ListenableFuture<RpcResult<Void>> flushAddGroupPortionAndBarrier(final InstanceIdentifier<FlowCapableNode> nodeIdent, final ItemSyncBox<Group> groupsPortion) {
final List<ListenableFuture<RpcResult<AddGroupOutput>>> allResults = new ArrayList<>();
final List<ListenableFuture<RpcResult<UpdateGroupOutput>>> allUpdateResults = new ArrayList<>();
for (Group group : groupsPortion.getItemsToPush()) {
final KeyedInstanceIdentifier<Group, GroupKey> groupIdent = nodeIdent.child(Group.class, group.getKey());
allResults.add(JdkFutureAdapters.listenInPoolThread(groupForwarder.add(groupIdent, group, nodeIdent)));
}
for (ItemSyncBox.ItemUpdateTuple<Group> groupTuple : groupsPortion.getItemsToUpdate()) {
final Group existingGroup = groupTuple.getOriginal();
final Group group = groupTuple.getUpdated();
final KeyedInstanceIdentifier<Group, GroupKey> groupIdent = nodeIdent.child(Group.class, group.getKey());
allUpdateResults.add(JdkFutureAdapters.listenInPoolThread(groupForwarder.update(groupIdent, existingGroup, group, nodeIdent)));
}
final ListenableFuture<RpcResult<Void>> singleVoidAddResult = Futures.transform(Futures.allAsList(allResults), ReconcileUtil.<AddGroupOutput>createRpcResultCondenser("group add"), MoreExecutors.directExecutor());
final ListenableFuture<RpcResult<Void>> singleVoidUpdateResult = Futures.transform(Futures.allAsList(allUpdateResults), ReconcileUtil.<UpdateGroupOutput>createRpcResultCondenser("group update"), MoreExecutors.directExecutor());
final ListenableFuture<RpcResult<Void>> summaryResult = Futures.transform(Futures.allAsList(singleVoidAddResult, singleVoidUpdateResult), ReconcileUtil.<Void>createRpcResultCondenser("group add/update"), MoreExecutors.directExecutor());
return Futures.transformAsync(summaryResult, ReconcileUtil.chainBarrierFlush(PathUtil.digNodePath(nodeIdent), transactionService), MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey in project openflowplugin by opendaylight.
the class SyncPlanPushStrategyIncrementalImpl method flushRemoveGroupPortionAndBarrier.
private ListenableFuture<RpcResult<Void>> flushRemoveGroupPortionAndBarrier(final InstanceIdentifier<FlowCapableNode> nodeIdent, final ItemSyncBox<Group> groupsPortion) {
List<ListenableFuture<RpcResult<RemoveGroupOutput>>> allResults = new ArrayList<>();
for (Group group : groupsPortion.getItemsToPush()) {
final KeyedInstanceIdentifier<Group, GroupKey> groupIdent = nodeIdent.child(Group.class, group.getKey());
allResults.add(JdkFutureAdapters.listenInPoolThread(groupForwarder.remove(groupIdent, group, nodeIdent)));
}
final ListenableFuture<RpcResult<Void>> singleVoidResult = Futures.transform(Futures.allAsList(allResults), ReconcileUtil.<RemoveGroupOutput>createRpcResultCondenser("group remove"), MoreExecutors.directExecutor());
return Futures.transformAsync(singleVoidResult, ReconcileUtil.chainBarrierFlush(PathUtil.digNodePath(nodeIdent), transactionService), MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey in project openflowplugin by opendaylight.
the class GroupListenerTest method removeGroupTest.
@Test
public void removeGroupTest() throws Exception {
addFlowCapableNode(NODE_KEY);
GroupKey groupKey = new GroupKey(new GroupId((long) 255));
InstanceIdentifier<Group> groupII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Group.class, groupKey);
Group group = new GroupBuilder().setKey(groupKey).setGroupName("Group1").build();
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, groupII, group);
assertCommit(writeTx.submit());
SalGroupServiceMock salGroupService = (SalGroupServiceMock) forwardingRulesManager.getSalGroupService();
List<AddGroupInput> addGroupCalls = salGroupService.getAddGroupCalls();
assertEquals(1, addGroupCalls.size());
assertEquals("DOM-0", addGroupCalls.get(0).getTransactionUri().getValue());
writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.delete(LogicalDatastoreType.CONFIGURATION, groupII);
assertCommit(writeTx.submit());
salGroupService = (SalGroupServiceMock) forwardingRulesManager.getSalGroupService();
List<RemoveGroupInput> removeGroupCalls = salGroupService.getRemoveGroupCalls();
assertEquals(1, removeGroupCalls.size());
assertEquals("DOM-1", removeGroupCalls.get(0).getTransactionUri().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey in project openflowplugin by opendaylight.
the class StatisticsGatheringUtilsTest method testGatherStatistics_groupDesc.
@Test
public void testGatherStatistics_groupDesc() throws Exception {
final MultipartType type = MultipartType.OFPMPGROUPDESC;
final long groupIdValue = 27L;
final BucketsListBuilder bucketsListBld = new BucketsListBuilder().setWatchPort(new PortNumber(5L));
final GroupDescBuilder groupStatsBld = new GroupDescBuilder().setBucketsList(Lists.newArrayList(bucketsListBld.build())).setGroupId(new GroupId(groupIdValue)).setType(GroupType.OFPGTALL);
final MultipartReplyGroupDescBuilder mpReplyGroupBld = new MultipartReplyGroupDescBuilder();
mpReplyGroupBld.setGroupDesc(Lists.newArrayList(groupStatsBld.build()));
final MultipartReplyGroupDescCaseBuilder mpReplyGroupCaseBld = new MultipartReplyGroupDescCaseBuilder();
mpReplyGroupCaseBld.setMultipartReplyGroupDesc(mpReplyGroupBld.build());
final MultipartReply groupStatsUpdated = assembleMPReplyMessage(type, mpReplyGroupCaseBld.build());
final List<MultipartReply> statsData = Collections.singletonList(groupStatsUpdated);
fireAndCheck(type, statsData);
final org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId storedGroupId = new org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId(groupIdValue);
final KeyedInstanceIdentifier<Group, GroupKey> groupPath = dummyNodePath.augmentation(FlowCapableNode.class).child(Group.class, new GroupKey(storedGroupId));
verify(deviceContext, Mockito.never()).addDeleteToTxChain(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.<InstanceIdentifier<?>>any());
verify(deviceGroupRegistry).store(storedGroupId);
verify(deviceContext).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(groupPath), Matchers.any(Group.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey in project openflowplugin by opendaylight.
the class OpenflowPluginBulkGroupTransactionProvider method writeGroup.
private void writeGroup(final CommandInterpreter ci, Group group, Group group1) {
ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
InstanceIdentifier<Group> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode12.getKey()).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);
InstanceIdentifier<Group> path2 = InstanceIdentifier.create(Nodes.class).child(Node.class, testNode12.getKey()).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);
CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
Futures.addCallback(commitFuture, new FutureCallback<Void>() {
@Override
public void onSuccess(Void notUsed) {
ci.println("Status of Group Data Loaded Transaction: success.");
}
@Override
public void onFailure(Throwable throwable) {
ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
}
}, MoreExecutors.directExecutor());
}
Aggregations