Search in sources :

Example 16 with Batch

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.Batch in project openflowplugin by opendaylight.

the class FlatBatchUtil method detectBatchStepType.

@VisibleForTesting
static <T extends BatchChoice> BatchStepType detectBatchStepType(final T batchCase) {
    final BatchStepType type;
    final Class<? extends DataContainer> implementedInterface = batchCase.getImplementedInterface();
    if (FlatBatchAddFlowCase.class.equals(implementedInterface)) {
        type = BatchStepType.FLOW_ADD;
    } else if (FlatBatchRemoveFlowCase.class.equals(implementedInterface)) {
        type = BatchStepType.FLOW_REMOVE;
    } else if (FlatBatchUpdateFlowCase.class.equals(implementedInterface)) {
        type = BatchStepType.FLOW_UPDATE;
    } else if (FlatBatchAddGroupCase.class.equals(implementedInterface)) {
        type = BatchStepType.GROUP_ADD;
    } else if (FlatBatchRemoveGroupCase.class.equals(implementedInterface)) {
        type = BatchStepType.GROUP_REMOVE;
    } else if (FlatBatchUpdateGroupCase.class.equals(implementedInterface)) {
        type = BatchStepType.GROUP_UPDATE;
    } else if (FlatBatchAddMeterCase.class.equals(implementedInterface)) {
        type = BatchStepType.METER_ADD;
    } else if (FlatBatchRemoveMeterCase.class.equals(implementedInterface)) {
        type = BatchStepType.METER_REMOVE;
    } else if (FlatBatchUpdateMeterCase.class.equals(implementedInterface)) {
        type = BatchStepType.METER_UPDATE;
    } else {
        throw new IllegalArgumentException("Unsupported batch obtained: " + implementedInterface);
    }
    return type;
}
Also used : FlatBatchRemoveMeterCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchRemoveMeterCase) FlatBatchRemoveFlowCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchRemoveFlowCase) FlatBatchAddGroupCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchAddGroupCase) BatchStepType(org.opendaylight.openflowplugin.impl.services.batch.BatchStepType) FlatBatchUpdateGroupCase(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateGroupCase) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 17 with Batch

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.Batch in project bgpcep by opendaylight.

the class AppPeerBenchmark method addRoute.

private long addRoute(final Ipv4Prefix ipv4Prefix, final Ipv4Address nextHop, final long count, final long batch) {
    final AttributesBuilder attributesBuilder = new AttributesBuilder();
    attributesBuilder.setCNextHop(new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(new Ipv4Address(nextHop)).build()).build());
    attributesBuilder.setMultiExitDisc(MED);
    attributesBuilder.setLocalPref(LOC_PREF);
    attributesBuilder.setOrigin(ORIGIN);
    attributesBuilder.setAsPath(AS_PATH);
    final Attributes attributes = attributesBuilder.build();
    return processRoutes(ipv4Prefix, count, batch, attributes);
}
Also used : Ipv4NextHopBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder) Ipv4NextHopCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv4NextHopCaseBuilder) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Example 18 with Batch

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.Batch in project bgpcep by opendaylight.

the class AdjRibOutListener method processRouteChange.

private void processRouteChange(final DataTreeCandidateNode route) {
    final Update update;
    switch(route.getModificationType()) {
        case UNMODIFIED:
            LOG.debug("Skipping unmodified route {}", route.getIdentifier());
            return;
        case DELETE:
        case DISAPPEARED:
            // FIXME: we can batch deletions into a single batch
            update = withdraw((MapEntryNode) route.getDataBefore().get());
            LOG.debug("Withdrawing routes {}", update);
            break;
        case APPEARED:
        case SUBTREE_MODIFIED:
        case WRITE:
            update = advertise((MapEntryNode) route.getDataAfter().get());
            LOG.debug("Advertising routes {}", update);
            break;
        default:
            LOG.warn("Ignoring unhandled modification type {}", route.getModificationType());
            return;
    }
    this.session.write(update);
}
Also used : Update(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)

Example 19 with Batch

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.Batch in project netvirt by opendaylight.

the class ElanL2GatewayUtils method deleteElanMacsFromL2GatewayDevice.

/**
 * Delete elan macs from L2 gateway device.<br>
 * This includes deleting ELAN mac table entries plus external device
 * UcastLocalMacs which are part of the same ELAN.
 *
 * @param hwvtepNodeId
 *            the hwvtepNodeId
 * @param elanName
 *            the elan name
 * @return the listenable future
 */
public ListenableFuture<Void> deleteElanMacsFromL2GatewayDevice(String hwvtepNodeId, String elanName) {
    String logicalSwitch = getLogicalSwitchFromElan(elanName);
    List<MacAddress> lstElanMacs = getRemoteUcastMacs(new NodeId(hwvtepNodeId), logicalSwitch, LogicalDatastoreType.CONFIGURATION);
    ListenableFuture<Void> future = HwvtepUtils.deleteRemoteUcastMacs(broker, new NodeId(hwvtepNodeId), logicalSwitch, lstElanMacs);
    Futures.addCallback(future, new FutureCallback<Void>() {

        @Override
        public void onSuccess(Void noarg) {
            LOG.trace("Successful in batch deletion of elan [{}] macs from l2gw device [{}]", elanName, hwvtepNodeId);
        }

        @Override
        public void onFailure(Throwable error) {
            LOG.warn("Failed during batch delete of elan {} macs from l2gw device {}. " + "Retrying with sequential deletes.", elanName, hwvtepNodeId, error);
            if (lstElanMacs != null && !lstElanMacs.isEmpty()) {
                for (MacAddress mac : lstElanMacs) {
                    HwvtepUtils.deleteRemoteUcastMac(broker, new NodeId(hwvtepNodeId), logicalSwitch, mac);
                }
            }
        }
    }, MoreExecutors.directExecutor());
    if (LOG.isDebugEnabled()) {
        List<String> elanMacs = lstElanMacs.stream().map(MacAddress::getValue).collect(Collectors.toList());
        LOG.debug("Deleting elan [{}] macs from node [{}]. Deleted macs = {}", elanName, hwvtepNodeId, elanMacs);
    }
    return future;
}
Also used : NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)

Example 20 with Batch

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.Batch in project openflowplugin by opendaylight.

the class SyncPlanPushStrategyFlatBatchImpl method decrementBatchFailuresCounters.

private static void decrementBatchFailuresCounters(final List<BatchFailure> batchFailures, final Map<Range<Integer>, Batch> batchMap, final SyncCrudCounters counters) {
    for (BatchFailure batchFailure : batchFailures) {
        for (Map.Entry<Range<Integer>, Batch> rangeBatchEntry : batchMap.entrySet()) {
            if (rangeBatchEntry.getKey().contains(batchFailure.getBatchOrder())) {
                // get type and decrease
                final BatchChoice batchChoice = rangeBatchEntry.getValue().getBatchChoice();
                decrementCounters(batchChoice, counters);
                break;
            }
        }
    }
}
Also used : BatchFailure(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailure) BatchChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.BatchChoice) Batch(org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.Batch) Range(com.google.common.collect.Range) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

ArrayList (java.util.ArrayList)18 Batch (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.Batch)13 VisibleForTesting (com.google.common.annotations.VisibleForTesting)12 BatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.BatchBuilder)8 LinkedHashMap (java.util.LinkedHashMap)5 Map (java.util.Map)5 ItemSyncBox (org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox)5 ProcessFlatBatchOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput)5 BatchFailure (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailure)5 Range (com.google.common.collect.Range)4 Nonnull (javax.annotation.Nonnull)4 FlatBatchAddFlow (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlow)4 FlatBatchAddMeter (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.meter._case.FlatBatchAddMeter)4 FlatBatchRemoveFlow (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.flow._case.FlatBatchRemoveFlow)4 FlatBatchRemoveGroup (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.group._case.FlatBatchRemoveGroup)4 FlatBatchRemoveMeter (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.meter._case.FlatBatchRemoveMeter)4 FlatBatchUpdateFlow (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.flow._case.FlatBatchUpdateFlow)4 FlatBatchUpdateMeter (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.meter._case.FlatBatchUpdateMeter)4 Test (org.junit.Test)3 BatchStepType (org.opendaylight.openflowplugin.impl.services.batch.BatchStepType)3