public static <O> Function<List<RpcResult<O>>, RpcResult<List<BatchFailedGroupsOutput>>> createCumulatingFunction(
final Iterable<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group> inputBatchGroups,
final int sizeOfInputBatch) {
- return new Function<List<RpcResult<O>>, RpcResult<List<BatchFailedGroupsOutput>>>() {
- @Nullable
- @Override
- public RpcResult<List<BatchFailedGroupsOutput>> apply(@Nullable final List<RpcResult<O>> innerInput) {
- final int sizeOfFutures = innerInput.size();
- Preconditions.checkArgument(sizeOfFutures == sizeOfInputBatch,
- "wrong amount of returned futures: {} <> {}", sizeOfFutures, sizeOfInputBatch);
-
- final List<BatchFailedGroupsOutput> batchGroups = new ArrayList<>();
- final Iterator<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group>
- batchGroupIterator = inputBatchGroups.iterator();
-
- Collection<RpcError> groupErrors = new ArrayList<>(sizeOfFutures);
-
- int batchOrder = 0;
- for (RpcResult<O> groupModOutput : innerInput) {
- final GroupId groupId = batchGroupIterator.next().getGroupId();
-
- if (!groupModOutput.isSuccessful()) {
- batchGroups.add(new BatchFailedGroupsOutputBuilder()
- .setGroupId(groupId)
- .setBatchOrder(batchOrder)
- .build());
- groupErrors.addAll(groupModOutput.getErrors());
- }
- batchOrder++;
- }
-
- final RpcResultBuilder<List<BatchFailedGroupsOutput>> resultBuilder;
- if (!groupErrors.isEmpty()) {
- resultBuilder = RpcResultBuilder.<List<BatchFailedGroupsOutput>>failed()
- .withRpcErrors(groupErrors).withResult(batchGroups);
- } else {
- resultBuilder = SUCCESSFUL_GROUP_OUTPUT_RPC_RESULT;
- }
- return resultBuilder.build();
- }
- };
+ return new CumulatingFunction<O>(inputBatchGroups, sizeOfInputBatch).invoke();
}
+ /*
+ * Method returns the bitmap of actions supported by each group.
+ *
+ * @param actionsSupported
+ * @return
+ */
+ public static List<Long> extractGroupActionsSupportBitmap(final List<ActionType> actionsSupported) {
+ List<Long> supportActionByGroups = new ArrayList<>();
+ for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType supportedActions : actionsSupported) {
+ long supportActionBitmap = 0;
+ supportActionBitmap |= supportedActions.isOFPATOUTPUT() ? (1) : 0;
+ supportActionBitmap |= supportedActions.isOFPATCOPYTTLOUT() ? (1 << 11) : 0;
+ supportActionBitmap |= supportedActions.isOFPATCOPYTTLIN() ? (1 << 12) : 0;
+ supportActionBitmap |= supportedActions.isOFPATSETMPLSTTL() ? (1 << 15) : 0;
+ supportActionBitmap |= supportedActions.isOFPATDECMPLSTTL() ? (1 << 16) : 0;
+ supportActionBitmap |= supportedActions.isOFPATPUSHVLAN() ? (1 << 17) : 0;
+ supportActionBitmap |= supportedActions.isOFPATPOPVLAN() ? (1 << 18) : 0;
+ supportActionBitmap |= supportedActions.isOFPATPUSHMPLS() ? (1 << 19) : 0;
+ supportActionBitmap |= supportedActions.isOFPATPOPMPLS() ? (1 << 20) : 0;
+ supportActionBitmap |= supportedActions.isOFPATSETQUEUE() ? (1 << 21) : 0;
+ supportActionBitmap |= supportedActions.isOFPATGROUP() ? (1 << 22) : 0;
+ supportActionBitmap |= supportedActions.isOFPATSETNWTTL() ? (1 << 23) : 0;
+ supportActionBitmap |= supportedActions.isOFPATDECNWTTL() ? (1 << 24) : 0;
+ supportActionBitmap |= supportedActions.isOFPATSETFIELD() ? (1 << 25) : 0;
+ supportActionBitmap |= supportedActions.isOFPATPUSHPBB() ? (1 << 26) : 0;
+ supportActionBitmap |= supportedActions.isOFPATPOPPBB() ? (1 << 27) : 0;
+ supportActionByGroups.add(supportActionBitmap);
+ }
+ return supportActionByGroups;
+ }
+
/**
* Factory method: create {@link Function} which attaches barrier response to given {@link RpcResult}<T>
* and changes success flag if needed.