Search in sources :

Example 1 with LoadBalancing

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.load.balancing.object.LoadBalancing in project netvirt by opendaylight.

the class VrfEntryListener method programRemoteFibWithLoadBalancingGroups.

// Allow deprecated TransactionRunner calls for now
@SuppressWarnings("ForbidCertainMethod")
private void programRemoteFibWithLoadBalancingGroups(final Uint64 remoteDpnId, final Uint32 vpnId, String rd, final VrfEntry vrfEntry, List<Routes> vpnExtraRoutes) {
    // create loadbalancing groups for extra routes only when the extra route is
    // present behind multiple VMs
    // Obtain the local routes for this particular dpn.
    java.util.Optional<Routes> routes = vpnExtraRoutes.stream().filter(route -> {
        Prefixes prefixToInterface = fibUtil.getPrefixToInterface(vpnId, FibUtil.getIpPrefix(route.getNexthopIpList().get(0)));
        if (prefixToInterface == null) {
            return false;
        }
        return remoteDpnId.equals(prefixToInterface.getDpnId());
    }).findFirst();
    long groupId = nextHopManager.createNextHopGroups(vpnId, rd, remoteDpnId, vrfEntry, routes.isPresent() ? routes.get() : null, vpnExtraRoutes);
    if (groupId == FibConstants.INVALID_GROUP_ID) {
        LOG.error("Unable to create Group for local prefix {} on rd {} on Node {}", vrfEntry.getDestPrefix(), rd, remoteDpnId);
        return;
    }
    List<ActionInfo> actionInfos = Collections.singletonList(new ActionGroup(groupId));
    List<InstructionInfo> instructions = Lists.newArrayList(new InstructionApplyActions(actionInfos));
    String jobKey = FibUtil.getCreateRemoteNextHopJobKey(vpnId, remoteDpnId, vrfEntry.getDestPrefix());
    jobCoordinator.enqueueJob(jobKey, () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(Datastore.CONFIGURATION, txn -> {
        baseVrfEntryHandler.makeConnectedRoute(remoteDpnId, vpnId, vrfEntry, rd, instructions, NwConstants.ADD_FLOW, TransactionAdapter.toWriteTransaction(txn), null);
    })));
    LOG.debug("Successfully added FIB entry for prefix {} in vpnId {}", vrfEntry.getDestPrefix(), vpnId);
}
Also used : Arrays(java.util.Arrays) Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table) ActionDrop(org.opendaylight.genius.mdsalutil.actions.ActionDrop) VpnInterfaceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry) InetAddress(java.net.InetAddress) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) Map(java.util.Map) Datastore(org.opendaylight.mdsal.binding.util.Datastore) BigInteger(java.math.BigInteger) LabelRouteInfoBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoBuilder) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) UpgradeState(org.opendaylight.serviceutils.upgrade.UpgradeState) MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) VpnHelper(org.opendaylight.netvirt.vpnmanager.api.VpnHelper) SubTransaction(org.opendaylight.genius.utils.batching.SubTransaction) TypedWriteTransaction(org.opendaylight.mdsal.binding.util.TypedWriteTransaction) TypedReadWriteTransaction(org.opendaylight.mdsal.binding.util.TypedReadWriteTransaction) NWUtil.isIpv4Address(org.opendaylight.genius.mdsalutil.NWUtil.isIpv4Address) NonNull(org.eclipse.jdt.annotation.NonNull) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) LabelRouteMap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.LabelRouteMap) RoutePathsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePathsKey) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency) Uint64(org.opendaylight.yangtools.yang.common.Uint64) ManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner) Callable(java.util.concurrent.Callable) IElanService(org.opendaylight.netvirt.elanmanager.api.IElanService) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) AdjacencyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.AdjacencyBuilder) ArrayList(java.util.ArrayList) MatchIpv4Destination(org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination) InstanceIdentifierBuilder(org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder) Lists(com.google.common.collect.Lists) LabelRouteInfoKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfoKey) ActionPopMpls(org.opendaylight.genius.mdsalutil.actions.ActionPopMpls) RouterInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.RouterInterface) ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) AbstractAsyncDataTreeChangeListener(org.opendaylight.serviceutils.tools.listener.AbstractAsyncDataTreeChangeListener) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables) UnknownHostException(java.net.UnknownHostException) FutureCallback(com.google.common.util.concurrent.FutureCallback) ExecutionException(java.util.concurrent.ExecutionException) Futures(com.google.common.util.concurrent.Futures) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) IMdsalApiManager(org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) InstructionGotoTable(org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable) MetaDataUtil(org.opendaylight.genius.mdsalutil.MetaDataUtil) FibHelper(org.opendaylight.netvirt.fibmanager.api.FibHelper) DataBroker(org.opendaylight.mdsal.binding.api.DataBroker) CONFIGURATION(org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION) SingleTransactionDataBroker(org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker) AdjacencyResult(org.opendaylight.netvirt.fibmanager.NexthopManager.AdjacencyResult) FibEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries) LoggerFactory(org.slf4j.LoggerFactory) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) Nullable(org.eclipse.jdt.annotation.Nullable) DataTreeEventCallbackRegistrar(org.opendaylight.genius.datastoreutils.listeners.DataTreeEventCallbackRegistrar) RetryingManagedNewTransactionRunner(org.opendaylight.mdsal.binding.util.RetryingManagedNewTransactionRunner) LoggingFutures(org.opendaylight.infrautils.utils.concurrent.LoggingFutures) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) VpnToDpnListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnListKey) LabelRouteInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.label.route.map.LabelRouteInfo) Configuration(org.opendaylight.mdsal.binding.util.Datastore.Configuration) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes) PrefixesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.PrefixesBuilder) Objects(java.util.Objects) List(java.util.List) ManagedNewTransactionRunnerImpl(org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl) RoutePaths(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths) VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) Optional(java.util.Optional) SubnetRoute(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.SubnetRoute) AdjacenciesOp(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesOp) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) NWUtil(org.opendaylight.genius.mdsalutil.NWUtil) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Executors(org.opendaylight.infrautils.utils.concurrent.Executors) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) Singleton(javax.inject.Singleton) InstructionWriteMetadata(org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata) TransactionAdapter(org.opendaylight.mdsal.binding.util.TransactionAdapter) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) Inject(javax.inject.Inject) MatchTunnelId(org.opendaylight.genius.mdsalutil.matches.MatchTunnelId) Objects.requireNonNull(java.util.Objects.requireNonNull) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) MatchEthernetType(org.opendaylight.genius.mdsalutil.matches.MatchEthernetType) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) VpnExtraRouteHelper(org.opendaylight.netvirt.vpnmanager.api.VpnExtraRouteHelper) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Logger(org.slf4j.Logger) ReentrantLock(java.util.concurrent.locks.ReentrantLock) RouteOrigin(org.opendaylight.netvirt.fibmanager.api.RouteOrigin) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) Operational(org.opendaylight.mdsal.binding.util.Datastore.Operational) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) MatchMplsLabel(org.opendaylight.genius.mdsalutil.matches.MatchMplsLabel) VrfEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntryKey) Collections(java.util.Collections) OPERATIONAL(org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL) JvmGlobalLocks(org.opendaylight.genius.utils.JvmGlobalLocks) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes) ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)

Example 2 with LoadBalancing

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.load.balancing.object.LoadBalancing in project bgpcep by opendaylight.

the class PCEPRequestMessageParser method insertObject.

private static State insertObject(final State state, final List<Object> objects, final List<VendorInformationObject> viObjects, final P2pBuilder builder, final List<Metrics> metrics, final List<Message> errors, final Rp rp) {
    final Object obj = objects.get(0);
    switch(state) {
        case INIT:
            if (obj instanceof Rro) {
                builder.setRro((Rro) obj);
                objects.remove(0);
                final Object nextObj = objects.get(0);
                if (nextObj instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reoptimization.bandwidth.object.ReoptimizationBandwidth) {
                    builder.setReoptimizationBandwidth((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reoptimization.bandwidth.object.ReoptimizationBandwidth) nextObj);
                }
                return State.REPORTED_IN;
            }
        case REPORTED_IN:
            if (obj instanceof VendorInformationObject) {
                viObjects.add((VendorInformationObject) obj);
                return State.REPORTED_IN;
            }
        case VENDOR_INFO_LIST:
            if (obj instanceof LoadBalancing) {
                builder.setLoadBalancing((LoadBalancing) obj);
                return State.LOAD_BIN;
            }
        case LOAD_BIN:
            if (obj instanceof Lspa) {
                builder.setLspa((Lspa) obj);
                return State.LSPA_IN;
            }
        case LSPA_IN:
            if (obj instanceof Bandwidth) {
                builder.setBandwidth((Bandwidth) obj);
                return State.BANDWIDTH_IN;
            }
        case BANDWIDTH_IN:
            if (obj instanceof Metric) {
                metrics.add(new MetricsBuilder().setMetric((Metric) obj).build());
                return State.BANDWIDTH_IN;
            }
        case METRIC_IN:
            if (obj instanceof Iro) {
                builder.setIro((Iro) obj);
                return State.IRO_IN;
            }
        case IRO_IN:
            if (obj instanceof Rro) {
                builder.setRro((Rro) obj);
                return State.RRO_IN;
            }
        case RRO_IN:
            if (obj instanceof Xro) {
                builder.setXro((Xro) obj);
                return State.XRO_IN;
            }
        case XRO_IN:
            if (obj instanceof Of) {
                builder.setOf((Of) obj);
                return State.OF_IN;
            }
        case OF_IN:
            if (obj instanceof ClassType) {
                final ClassType classType = (ClassType) obj;
                if (!classType.isProcessingRule()) {
                    errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.of(rp)));
                } else {
                    builder.setClassType(classType);
                }
                return State.CT_IN;
            }
        case CT_IN:
        case END:
            return State.END;
        default:
            return state;
    }
}
Also used : Preconditions(com.google.common.base.Preconditions) Iro(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.include.route.object.Iro) Rro(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.Rro) MetricsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.attributes.MetricsBuilder) Xro(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.Xro) Bandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.bandwidth.object.Bandwidth) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject) ClassType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.classtype.object.ClassType) LoadBalancing(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.load.balancing.object.LoadBalancing) Of(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.object.Of) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object) Metric(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.metric.object.Metric) Lspa(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.Lspa)

Example 3 with LoadBalancing

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.load.balancing.object.LoadBalancing in project bgpcep by opendaylight.

the class StatefulPCRequestMessageParser method insertP2PObject.

// Note: objects is expected to be non-empty and caller will remove the first object if non-empty
@SuppressWarnings("fallthrough")
private static P2PState insertP2PObject(final P2PState p2PState, final Queue<Object> objects, final List<VendorInformationObject> viObjects, final P2pBuilder builder, final List<Metrics> metrics, final List<Message> errors, final Rp rp) {
    final Object obj = objects.element();
    switch(p2PState) {
        case INIT:
            if (obj instanceof Rro) {
                builder.setRro((Rro) obj);
                objects.remove();
                // FIXME: should we guard against empty objects?
                final Object nextObj = objects.element();
                if (nextObj instanceof ReoptimizationBandwidth) {
                    builder.setReoptimizationBandwidth((ReoptimizationBandwidth) nextObj);
                }
                return P2PState.REPORTED_IN;
            }
        // fallthrough
        case REPORTED_IN:
            if (obj instanceof VendorInformationObject) {
                viObjects.add((VendorInformationObject) obj);
                return P2PState.REPORTED_IN;
            }
        // fallthrough
        case VENDOR_INFO_LIST:
            if (obj instanceof LoadBalancing) {
                builder.setLoadBalancing((LoadBalancing) obj);
                return P2PState.LOAD_BIN;
            }
        // fallthrough
        case LOAD_BIN:
            if (obj instanceof Lsp) {
                builder.addAugmentation(new P2p1Builder().setLsp((Lsp) obj).build());
                return P2PState.LSP_IN;
            }
        // fallthrough
        case LSP_IN:
            if (obj instanceof Lspa) {
                builder.setLspa((Lspa) obj);
                return P2PState.LSPA_IN;
            }
        // fallthrough
        case LSPA_IN:
            if (obj instanceof Bandwidth) {
                builder.setBandwidth((Bandwidth) obj);
                return P2PState.BANDWIDTH_IN;
            }
        // fallthrough
        case BANDWIDTH_IN:
            if (obj instanceof Metric) {
                metrics.add(new MetricsBuilder().setMetric((Metric) obj).build());
                return P2PState.BANDWIDTH_IN;
            }
        // fallthrough
        case METRIC_IN:
            if (obj instanceof Iro) {
                builder.setIro((Iro) obj);
                return P2PState.IRO_IN;
            }
        // fallthrough
        case IRO_IN:
            if (obj instanceof Rro) {
                builder.setRro((Rro) obj);
                return P2PState.RRO_IN;
            }
        // fallthrough
        case RRO_IN:
            if (obj instanceof Xro) {
                builder.setXro((Xro) obj);
                return P2PState.XRO_IN;
            }
        // fallthrough
        case XRO_IN:
            if (obj instanceof Of) {
                builder.setOf((Of) obj);
                return P2PState.OF_IN;
            }
        // fallthrough
        case OF_IN:
            if (obj instanceof ClassType) {
                final ClassType classType = (ClassType) obj;
                if (!classType.getProcessingRule()) {
                    errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.of(rp)));
                } else {
                    builder.setClassType(classType);
                }
                return P2PState.CT_IN;
            }
        // fallthrough
        case CT_IN:
        case END:
            return P2PState.END;
        default:
            return p2PState;
    }
}
Also used : Iro(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.Iro) Lsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.Lsp) ClassType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.classtype.object.ClassType) LoadBalancing(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.load.balancing.object.LoadBalancing) Rro(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.Rro) P2p1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.P2p1Builder) MetricsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.MetricsBuilder) Xro(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.exclude.route.object.Xro) Bandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.Bandwidth) ReoptimizationBandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reoptimization.bandwidth.object.ReoptimizationBandwidth) Of(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.object.Of) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject) Metric(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.metric.object.Metric) Lspa(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lspa.object.Lspa) ReoptimizationBandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reoptimization.bandwidth.object.ReoptimizationBandwidth)

Example 4 with LoadBalancing

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.load.balancing.object.LoadBalancing in project bgpcep by opendaylight.

the class PCEPRequestMessageParser method insertP2PObject.

// Note: objects is expected to be non-empty and caller will remove the first object if non-empty
private static P2PState insertP2PObject(final P2PState p2PState, final Queue<Object> objects, final List<VendorInformationObject> viObjects, final P2pBuilder builder, final List<Metrics> metrics, final List<Message> errors, final Rp rp) {
    final Object obj = objects.element();
    switch(p2PState) {
        case INIT:
            if (obj instanceof Rro) {
                builder.setRro((Rro) obj);
                objects.remove();
                // FIXME: should we guard against empty objects?
                final Object nextObj = objects.element();
                if (nextObj instanceof ReoptimizationBandwidth) {
                    builder.setReoptimizationBandwidth((ReoptimizationBandwidth) nextObj);
                }
                return P2PState.REPORTED_IN;
            }
        // fallthrough
        case REPORTED_IN:
            if (obj instanceof VendorInformationObject) {
                viObjects.add((VendorInformationObject) obj);
                return P2PState.REPORTED_IN;
            }
        // fallthrough
        case VENDOR_INFO_LIST:
            if (obj instanceof LoadBalancing) {
                builder.setLoadBalancing((LoadBalancing) obj);
                return P2PState.LOAD_BIN;
            }
        // fallthrough
        case LOAD_BIN:
            if (obj instanceof Lspa) {
                builder.setLspa((Lspa) obj);
                return P2PState.LSPA_IN;
            }
        // fallthrough
        case LSPA_IN:
            if (obj instanceof Bandwidth) {
                builder.setBandwidth((Bandwidth) obj);
                return P2PState.BANDWIDTH_IN;
            }
        // fallthrough
        case BANDWIDTH_IN:
            if (obj instanceof Metric) {
                metrics.add(new MetricsBuilder().setMetric((Metric) obj).build());
                return P2PState.BANDWIDTH_IN;
            }
        // fallthrough
        case METRIC_IN:
            if (obj instanceof Iro) {
                builder.setIro((Iro) obj);
                return P2PState.IRO_IN;
            }
        // fallthrough
        case IRO_IN:
            if (obj instanceof Rro) {
                builder.setRro((Rro) obj);
                return P2PState.RRO_IN;
            }
        // fallthrough
        case RRO_IN:
            if (obj instanceof Xro) {
                builder.setXro((Xro) obj);
                return P2PState.XRO_IN;
            }
        // fallthrough
        case XRO_IN:
            if (obj instanceof Of) {
                builder.setOf((Of) obj);
                return P2PState.OF_IN;
            }
        // fallthrough
        case OF_IN:
            if (obj instanceof ClassType) {
                final ClassType classType = (ClassType) obj;
                if (!classType.getProcessingRule()) {
                    errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.of(rp)));
                } else {
                    builder.setClassType(classType);
                }
                return P2PState.CT_IN;
            }
        // fallthrough
        case CT_IN:
        case END:
            return P2PState.END;
        default:
            return p2PState;
    }
}
Also used : Iro(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.Iro) ClassType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.classtype.object.ClassType) LoadBalancing(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.load.balancing.object.LoadBalancing) Rro(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.Rro) MetricsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.MetricsBuilder) Xro(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.exclude.route.object.Xro) Bandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.Bandwidth) ReoptimizationBandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reoptimization.bandwidth.object.ReoptimizationBandwidth) Of(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.object.Of) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object) Metric(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.metric.object.Metric) Lspa(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lspa.object.Lspa) ReoptimizationBandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reoptimization.bandwidth.object.ReoptimizationBandwidth)

Example 5 with LoadBalancing

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.load.balancing.object.LoadBalancing in project bgpcep by opendaylight.

the class PCEPRequestMessageParser method insertP2MPObject.

private static P2MPState insertP2MPObject(final P2MPState p2MPState, final Queue<Object> objects, final P2mpBuilder builder, final List<EndpointRroPair> epRros, final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.Metric> metrics, final List<Message> errors, final Rp rp) {
    final Object obj = objects.element();
    switch(p2MPState) {
        case RP:
            if (obj instanceof EndpointsObj) {
                final EndpointRroPairBuilder rroPairBuilder = new EndpointRroPairBuilder();
                if (obj.getProcessingRule()) {
                    rroPairBuilder.setEndpointsObj((EndpointsObj) obj);
                } else {
                    errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.of(rp)));
                }
                epRros.add(rroPairBuilder.setRros(new ArrayList<>()).build());
                return P2MPState.ENDPOINT;
            }
        // fallthrough
        case ENDPOINT:
            if (obj instanceof Rro || obj instanceof Srro) {
                if (obj.getProcessingRule()) {
                    final int lastIndex = epRros.size() - 1;
                    final EndpointRroPair endpointRroPair = epRros.get(lastIndex);
                    List<Rros> rros = endpointRroPair.getRros();
                    if (rros == null) {
                        rros = new ArrayList<>();
                    }
                    if (obj instanceof Rro) {
                        rros.add(new RrosBuilder().setRouteObject(new ReportedRouteObjectCaseBuilder().setRro((Rro) obj).build()).build());
                    } else {
                        rros.add(new RrosBuilder().setRouteObject(new SecondaryReportedRouteObjectCaseBuilder().setSrro((Srro) obj).build()).build());
                    }
                    epRros.remove(lastIndex);
                    epRros.add(lastIndex, new EndpointRroPairBuilder(endpointRroPair).setRros(rros).build());
                }
                return P2MPState.ENDPOINT;
            }
        // fallthrough
        case RRO_SRRO:
            if (obj instanceof ReoptimizationBandwidth) {
                final int lastIndex = epRros.size() - 1;
                final EndpointRroPair endpointRroPair = epRros.get(lastIndex);
                epRros.remove(lastIndex);
                epRros.add(lastIndex, new EndpointRroPairBuilder(endpointRroPair).setReoptimizationBandwidth((ReoptimizationBandwidth) obj).build());
                return P2MPState.BANDWIDTH;
            }
        // fallthrough
        case BANDWIDTH:
            if (obj instanceof EndpointsObj) {
                return P2MPState.RP;
            }
            if (obj instanceof Of) {
                builder.setOf((Of) obj);
                return P2MPState.OF_IN;
            }
        // fallthrough
        case OF_IN:
            if (obj instanceof Lspa) {
                builder.setLspa((Lspa) obj);
                return P2MPState.LSPA_IN;
            }
        // fallthrough
        case LSPA_IN:
            if (obj instanceof Bandwidth) {
                builder.setBandwidth((Bandwidth) obj);
                return P2MPState.BANDWIDTH_IN;
            }
        // fallthrough
        case BANDWIDTH_IN:
            if (obj instanceof Metric) {
                metrics.add(new MetricBuilder().setMetric((Metric) obj).build());
                return P2MPState.BANDWIDTH_IN;
            }
        // fallthrough
        case METRIC_IN:
            if (obj instanceof Iro) {
                builder.setIroBncChoice(new IroCaseBuilder().setIro((Iro) obj).build());
                return P2MPState.IRO_BNC_IN;
            }
            if (obj instanceof BranchNodeList) {
                builder.setIroBncChoice(new BncCaseBuilder().setBranchNodeType(new BranchNodeCaseBuilder().setBranchNodeList((BranchNodeList) obj).build()).build());
                return P2MPState.IRO_BNC_IN;
            }
            if (obj instanceof NonBranchNodeList) {
                builder.setIroBncChoice(new BncCaseBuilder().setBranchNodeType(new NonBranchNodeCaseBuilder().setNonBranchNodeList((NonBranchNodeList) obj).build()).build());
                return P2MPState.IRO_BNC_IN;
            }
        // fallthrough
        case IRO_BNC_IN:
            if (obj instanceof LoadBalancing) {
                builder.setLoadBalancing((LoadBalancing) obj);
                return P2MPState.LOAD_BIN;
            }
        // fallthrough
        case LOAD_BIN:
        case END:
        default:
            return P2MPState.END;
    }
}
Also used : Iro(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.Iro) Rro(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.Rro) EndpointRroPairBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.EndpointRroPairBuilder) NonBranchNodeList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.non.branch.node.object.NonBranchNodeList) NonBranchNodeCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bnc.object.branch.node.type.NonBranchNodeCaseBuilder) Bandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.Bandwidth) ReoptimizationBandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reoptimization.bandwidth.object.ReoptimizationBandwidth) Srro(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.reported.route.object.Srro) EndpointsObj(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObj) ReoptimizationBandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reoptimization.bandwidth.object.ReoptimizationBandwidth) MetricBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.MetricBuilder) Rros(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.endpoint.rro.pair.Rros) SecondaryReportedRouteObjectCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.endpoint.rro.pair.rros.route.object.SecondaryReportedRouteObjectCaseBuilder) SecondaryReportedRouteObjectCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.endpoint.rro.pair.rros.route.object.SecondaryReportedRouteObjectCaseBuilder) ReportedRouteObjectCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.endpoint.rro.pair.rros.route.object.ReportedRouteObjectCaseBuilder) EndpointRroPair(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.EndpointRroPair) LoadBalancing(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.load.balancing.object.LoadBalancing) RrosBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.endpoint.rro.pair.RrosBuilder) BranchNodeList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.branch.node.object.BranchNodeList) NonBranchNodeList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.non.branch.node.object.NonBranchNodeList) Of(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.object.Of) IroCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.iro.bnc.choice.IroCaseBuilder) BncCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.iro.bnc.choice.BncCaseBuilder) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object) Metric(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.metric.object.Metric) Lspa(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lspa.object.Lspa) BranchNodeCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bnc.object.branch.node.type.BranchNodeCaseBuilder) NonBranchNodeCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bnc.object.branch.node.type.NonBranchNodeCaseBuilder)

Aggregations

LoadBalancing (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.load.balancing.object.LoadBalancing)3 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object)2 Bandwidth (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.Bandwidth)2 Iro (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.Iro)2 Lspa (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lspa.object.Lspa)2 Metric (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.metric.object.Metric)2 Of (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.object.Of)2 ReoptimizationBandwidth (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reoptimization.bandwidth.object.ReoptimizationBandwidth)2 Rro (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.Rro)2 VendorInformationObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject)2 Preconditions (com.google.common.base.Preconditions)1 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 Lists (com.google.common.collect.Lists)1 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 Futures (com.google.common.util.concurrent.Futures)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 ByteBuf (io.netty.buffer.ByteBuf)1 BigInteger (java.math.BigInteger)1