use of org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.update.groups.batch.input.BatchUpdateGroups in project openflowplugin by opendaylight.
the class SalGroupsBatchServiceImpl method updateGroupsBatch.
@Override
public Future<RpcResult<UpdateGroupsBatchOutput>> updateGroupsBatch(final UpdateGroupsBatchInput input) {
final List<BatchUpdateGroups> batchUpdateGroups = input.getBatchUpdateGroups();
LOG.trace("Updating groups @ {} : {}", PathUtil.extractNodeId(input.getNode()), batchUpdateGroups.size());
final ArrayList<ListenableFuture<RpcResult<UpdateGroupOutput>>> resultsLot = new ArrayList<>();
for (BatchUpdateGroups batchGroup : batchUpdateGroups) {
final UpdateGroupInput updateGroupInput = new UpdateGroupInputBuilder(input).setOriginalGroup(new OriginalGroupBuilder(batchGroup.getOriginalBatchedGroup()).build()).setUpdatedGroup(new UpdatedGroupBuilder(batchGroup.getUpdatedBatchedGroup()).build()).setGroupRef(createGroupRef(input.getNode(), batchGroup)).setNode(input.getNode()).build();
resultsLot.add(JdkFutureAdapters.listenInPoolThread(salGroupService.updateGroup(updateGroupInput)));
}
final Iterable<Group> groups = batchUpdateGroups.stream().map(BatchGroupInputUpdateGrouping::getUpdatedBatchedGroup).collect(Collectors.toList());
final ListenableFuture<RpcResult<List<BatchFailedGroupsOutput>>> commonResult = Futures.transform(Futures.allAsList(resultsLot), GroupUtil.<UpdateGroupOutput>createCumulatingFunction(groups, batchUpdateGroups.size()));
ListenableFuture<RpcResult<UpdateGroupsBatchOutput>> updateGroupsBulkFuture = Futures.transform(commonResult, GroupUtil.GROUP_UPDATE_TRANSFORM);
if (input.isBarrierAfter()) {
updateGroupsBulkFuture = BarrierUtil.chainBarrier(updateGroupsBulkFuture, input.getNode(), transactionService, GroupUtil.GROUP_UPDATE_COMPOSING_TRANSFORM);
}
return updateGroupsBulkFuture;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.update.groups.batch.input.BatchUpdateGroups in project openflowplugin by opendaylight.
the class FlatBatchGroupAdapters method adaptFlatBatchUpdateGroup.
/**
* Adapt flat batch update group.
* @param planStep batch step containing changes of the same type
* @param node pointer for RPC routing
* @return input suitable for {@link org.opendaylight.yang.gen.v1.urn
* .opendaylight.groups.service.rev160315.SalGroupsBatchService#updateGroupsBatch(UpdateGroupsBatchInput)}
*/
public static UpdateGroupsBatchInput adaptFlatBatchUpdateGroup(final BatchPlanStep planStep, final NodeRef node) {
final List<BatchUpdateGroups> batchGroups = new ArrayList<>();
for (FlatBatchUpdateGroup batchUpdateGroup : planStep.<FlatBatchUpdateGroup>getTaskBag()) {
final BatchUpdateGroups updateGroups = new BatchUpdateGroupsBuilder(batchUpdateGroup).build();
batchGroups.add(updateGroups);
}
return new UpdateGroupsBatchInputBuilder().setBarrierAfter(planStep.isBarrierAfter()).setNode(node).setBatchUpdateGroups(batchGroups).build();
}
Aggregations