Search in sources :

Example 6 with RemoveGroupInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput in project openflowplugin by opendaylight.

the class SalGroupsBatchServiceImpl method removeGroupsBatch.

@Override
public Future<RpcResult<RemoveGroupsBatchOutput>> removeGroupsBatch(final RemoveGroupsBatchInput input) {
    LOG.trace("Removing groups @ {} : {}", PathUtil.extractNodeId(input.getNode()), input.getBatchRemoveGroups().size());
    final ArrayList<ListenableFuture<RpcResult<RemoveGroupOutput>>> resultsLot = new ArrayList<>();
    for (BatchRemoveGroups addGroup : input.getBatchRemoveGroups()) {
        final RemoveGroupInput removeGroupInput = new RemoveGroupInputBuilder(addGroup).setGroupRef(createGroupRef(input.getNode(), addGroup)).setNode(input.getNode()).build();
        resultsLot.add(JdkFutureAdapters.listenInPoolThread(salGroupService.removeGroup(removeGroupInput)));
    }
    final ListenableFuture<RpcResult<List<BatchFailedGroupsOutput>>> commonResult = Futures.transform(Futures.allAsList(resultsLot), GroupUtil.<RemoveGroupOutput>createCumulatingFunction(input.getBatchRemoveGroups()));
    ListenableFuture<RpcResult<RemoveGroupsBatchOutput>> removeGroupsBulkFuture = Futures.transform(commonResult, GroupUtil.GROUP_REMOVE_TRANSFORM);
    if (input.isBarrierAfter()) {
        removeGroupsBulkFuture = BarrierUtil.chainBarrier(removeGroupsBulkFuture, input.getNode(), transactionService, GroupUtil.GROUP_REMOVE_COMPOSING_TRANSFORM);
    }
    return removeGroupsBulkFuture;
}
Also used : RemoveGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput) RemoveGroupOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutput) BatchRemoveGroups(org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.remove.groups.batch.input.BatchRemoveGroups) BatchFailedGroupsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.batch.group.output.list.grouping.BatchFailedGroupsOutput) ArrayList(java.util.ArrayList) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) RemoveGroupInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInputBuilder)

Example 7 with RemoveGroupInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput in project openflowplugin by opendaylight.

the class GroupConvertor method convert.

@Override
public GroupModInputBuilder convert(Group source, VersionDatapathIdConvertorData data) {
    GroupModInputBuilder groupModInputBuilder = new GroupModInputBuilder();
    if (source instanceof AddGroupInput) {
        groupModInputBuilder.setCommand(GroupModCommand.OFPGCADD);
    } else if (source instanceof RemoveGroupInput) {
        groupModInputBuilder.setCommand(GroupModCommand.OFPGCDELETE);
    } else if (source instanceof UpdatedGroup) {
        groupModInputBuilder.setCommand(GroupModCommand.OFPGCMODIFY);
    }
    if (GroupTypes.GroupAll.equals(source.getGroupType())) {
        groupModInputBuilder.setType(GroupType.OFPGTALL);
    }
    if (GroupTypes.GroupSelect.equals(source.getGroupType())) {
        groupModInputBuilder.setType(GroupType.OFPGTSELECT);
    }
    if (GroupTypes.GroupIndirect.equals(source.getGroupType())) {
        groupModInputBuilder.setType(GroupType.OFPGTINDIRECT);
    }
    if (GroupTypes.GroupFf.equals(source.getGroupType())) {
        groupModInputBuilder.setType(GroupType.OFPGTFF);
    }
    groupModInputBuilder.setGroupId(new GroupId(source.getGroupId().getValue()));
    // During group deletion do not push the buckets
    if (groupModInputBuilder.getCommand() != GroupModCommand.OFPGCDELETE) {
        if (source.getBuckets() != null && source.getBuckets().getBucket().size() != 0) {
            Collections.sort(source.getBuckets().getBucket(), COMPARATOR);
            List<BucketsList> bucketLists = salToOFBucketList(source.getBuckets(), data.getVersion(), source.getGroupType().getIntValue(), data.getDatapathId());
            groupModInputBuilder.setBucketsList(bucketLists);
        }
    }
    groupModInputBuilder.setVersion(data.getVersion());
    return groupModInputBuilder;
}
Also used : RemoveGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput) AddGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput) GroupModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInputBuilder) UpdatedGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroup) BucketsList(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId)

Aggregations

RemoveGroupInput (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput)7 Test (org.junit.Test)4 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)4 RemoveGroupOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutput)3 InOrder (org.mockito.InOrder)2 AddGroupInput (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput)2 RemoveGroupInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInputBuilder)2 RemoveGroupOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutputBuilder)2 GroupId (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId)2 RemoveGroupsBatchInput (org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.RemoveGroupsBatchInput)2 RemoveGroupsBatchInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.RemoveGroupsBatchInputBuilder)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 ArrayList (java.util.ArrayList)1 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)1 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)1 UpdatedGroup (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroup)1 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)1 GroupBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder)1 GroupKey (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey)1 StaleGroup (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroup)1