Search in sources :

Example 21 with Key

use of org.onosproject.net.intent.Key in project onos by opennetworkinglab.

the class SimpleFabricForwarding method buildBrcIntents.

// Build Boadcast Intents for a L2 Network.
private Set<SinglePointToMultiPointIntent> buildBrcIntents(FabricNetwork fabricNetwork) {
    Set<Interface> interfaces = fabricNetwork.interfaces();
    if (interfaces.size() < 2 || !fabricNetwork.isForward() || !fabricNetwork.isBroadcast()) {
        return ImmutableSet.of();
    }
    Set<SinglePointToMultiPointIntent> brcIntents = Sets.newHashSet();
    ResourceGroup resourceGroup = ResourceGroup.of(fabricNetwork.name());
    // Generates broadcast Intents from any network interface to other
    // network interface from the L2 Network.
    interfaces.forEach(src -> {
        FilteredConnectPoint srcFcp = buildFilteredConnectedPoint(src);
        Set<FilteredConnectPoint> dstFcps = interfaces.stream().filter(iface -> !iface.equals(src)).map(this::buildFilteredConnectedPoint).collect(Collectors.toSet());
        Key key = buildKey(fabricNetwork.name(), "BCAST", srcFcp.connectPoint(), MacAddress.BROADCAST);
        TrafficSelector selector = DefaultTrafficSelector.builder().matchEthDst(MacAddress.BROADCAST).build();
        SinglePointToMultiPointIntent.Builder intentBuilder = SinglePointToMultiPointIntent.builder().appId(appId).key(key).selector(selector).filteredIngressPoint(srcFcp).filteredEgressPoints(dstFcps).constraints(buildConstraints(L2NETWORK_CONSTRAINTS, fabricNetwork.encapsulation())).priority(PRI_L2NETWORK_BROADCAST).resourceGroup(resourceGroup);
        brcIntents.add(intentBuilder.build());
    });
    return brcIntents;
}
Also used : SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Interface(org.onosproject.net.intf.Interface) ResourceGroup(org.onosproject.net.ResourceGroup) Key(org.onosproject.net.intent.Key) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 22 with Key

use of org.onosproject.net.intent.Key in project onos by opennetworkinglab.

the class GossipIntentStore method getPeerNodes.

private Collection<NodeId> getPeerNodes(Key key, IntentData data) {
    NodeId master = partitionService.getLeader(key, Key::hash);
    NodeId origin = (data != null) ? data.origin() : null;
    if (data != null && (master == null || origin == null)) {
        log.debug("Intent {} missing master and/or origin; master = {}, origin = {}", key, master, origin);
    }
    NodeId me = clusterService.getLocalNode().id();
    boolean isMaster = Objects.equals(master, me);
    boolean isOrigin = Objects.equals(origin, me);
    if (isMaster && isOrigin) {
        return getRandomNode();
    } else if (isMaster) {
        return origin != null ? ImmutableList.of(origin) : getRandomNode();
    } else if (isOrigin) {
        return master != null ? ImmutableList.of(master) : getRandomNode();
    } else {
        log.warn("No master or origin for intent {}", key);
        return master != null ? ImmutableList.of(master) : getRandomNode();
    }
}
Also used : NodeId(org.onosproject.cluster.NodeId) Key(org.onosproject.net.intent.Key)

Example 23 with Key

use of org.onosproject.net.intent.Key in project onos by opennetworkinglab.

the class GossipIntentStore method activate.

@Activate
public void activate(ComponentContext context) {
    configService.registerProperties(getClass());
    modified(context);
    // TODO persistent intents must be reevaluated and the appropriate
    // processing done here, current implementation is not functional
    // and is for performance evaluation only
    initiallyPersistent = persistenceEnabled;
    KryoNamespace.Builder intentSerializer = KryoNamespace.newBuilder().register(KryoNamespaces.API).register(IntentData.class).register(MultiValuedTimestamp.class);
    EventuallyConsistentMapBuilder currentECMapBuilder = storageService.<Key, IntentData>eventuallyConsistentMapBuilder().withName("intent-current").withSerializer(intentSerializer).withTimestampProvider(this::currentTimestampProvider).withPeerUpdateFunction((key, intentData) -> getPeerNodes(key, intentData));
    EventuallyConsistentMapBuilder pendingECMapBuilder = storageService.<Key, IntentData>eventuallyConsistentMapBuilder().withName("intent-pending").withSerializer(intentSerializer).withTimestampProvider((key, intentData) -> new MultiValuedTimestamp<>(new WallClockTimestamp(), System.nanoTime())).withPeerUpdateFunction((key, intentData) -> getPeerNodes(key, intentData));
    if (initiallyPersistent) {
        currentECMapBuilder = currentECMapBuilder.withPersistence();
        pendingECMapBuilder = pendingECMapBuilder.withPersistence();
    }
    currentMap = currentECMapBuilder.build();
    pendingMap = pendingECMapBuilder.build();
    currentMap.addListener(mapCurrentListener);
    pendingMap.addListener(mapPendingListener);
    log.info("Started");
}
Also used : IntentState(org.onosproject.net.intent.IntentState) EventuallyConsistentMapBuilder(org.onosproject.store.service.EventuallyConsistentMapBuilder) Backtrace(org.onlab.util.Backtrace) RandomUtils(org.apache.commons.lang.math.RandomUtils) StorageService(org.onosproject.store.service.StorageService) PURGE_REQ(org.onosproject.net.intent.IntentState.PURGE_REQ) KryoNamespaces(org.onosproject.store.serializers.KryoNamespaces) WorkPartitionService(org.onosproject.net.intent.WorkPartitionService) NodeId(org.onosproject.cluster.NodeId) Tools.get(org.onlab.util.Tools.get) EventuallyConsistentMapEvent(org.onosproject.store.service.EventuallyConsistentMapEvent) Deactivate(org.osgi.service.component.annotations.Deactivate) Collection(java.util.Collection) WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) Key(org.onosproject.net.intent.Key) List(java.util.List) GIS_PERSISTENCE_ENABLED_DEFAULT(org.onosproject.store.OsgiPropertyConstants.GIS_PERSISTENCE_ENABLED_DEFAULT) Optional(java.util.Optional) ClusterService(org.onosproject.cluster.ClusterService) GIS_PERSISTENCE_ENABLED(org.onosproject.store.OsgiPropertyConstants.GIS_PERSISTENCE_ENABLED) Dictionary(java.util.Dictionary) IntentEvent(org.onosproject.net.intent.IntentEvent) ComponentContext(org.osgi.service.component.ComponentContext) Strings.isNullOrEmpty(com.google.common.base.Strings.isNullOrEmpty) KryoNamespace(org.onlab.util.KryoNamespace) IntentData(org.onosproject.net.intent.IntentData) ControllerNode(org.onosproject.cluster.ControllerNode) Component(org.osgi.service.component.annotations.Component) ImmutableList(com.google.common.collect.ImmutableList) Intent(org.onosproject.net.intent.Intent) Timestamp(org.onosproject.store.Timestamp) Activate(org.osgi.service.component.annotations.Activate) EventuallyConsistentMap(org.onosproject.store.service.EventuallyConsistentMap) EventuallyConsistentMapListener(org.onosproject.store.service.EventuallyConsistentMapListener) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) Logger(org.slf4j.Logger) Properties(java.util.Properties) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) AtomicLong(java.util.concurrent.atomic.AtomicLong) IntentStoreDelegate(org.onosproject.net.intent.IntentStoreDelegate) MultiValuedTimestamp(org.onosproject.store.service.MultiValuedTimestamp) IntentStore(org.onosproject.net.intent.IntentStore) AbstractStore(org.onosproject.store.AbstractStore) Modified(org.osgi.service.component.annotations.Modified) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) Reference(org.osgi.service.component.annotations.Reference) WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) IntentData(org.onosproject.net.intent.IntentData) EventuallyConsistentMapBuilder(org.onosproject.store.service.EventuallyConsistentMapBuilder) KryoNamespace(org.onlab.util.KryoNamespace) MultiValuedTimestamp(org.onosproject.store.service.MultiValuedTimestamp) Key(org.onosproject.net.intent.Key) Activate(org.osgi.service.component.annotations.Activate)

Example 24 with Key

use of org.onosproject.net.intent.Key in project onos by opennetworkinglab.

the class SinglePointToMultiPointIntentCompilerTest method testBandwidthConstrainedIntentAllocation.

/**
 * Tests if bandwidth resources get allocated correctly.
 */
@Test
public void testBandwidthConstrainedIntentAllocation() {
    final double bpsTotal = 1000.0;
    final double bpsToReserve = 100.0;
    ContinuousResource resourceSw1P1 = Resources.continuous(DID_1, PORT_1, Bandwidth.class).resource(bpsToReserve);
    ContinuousResource resourceSw1P2 = Resources.continuous(DID_1, PORT_2, Bandwidth.class).resource(bpsToReserve);
    ContinuousResource resourceSw2P1 = Resources.continuous(DID_2, PORT_1, Bandwidth.class).resource(bpsToReserve);
    ContinuousResource resourceSw2P2 = Resources.continuous(DID_2, PORT_2, Bandwidth.class).resource(bpsToReserve);
    ContinuousResource resourceSw3P1 = Resources.continuous(DID_3, PORT_1, Bandwidth.class).resource(bpsToReserve);
    ContinuousResource resourceSw3P2 = Resources.continuous(DID_3, PORT_2, Bandwidth.class).resource(bpsToReserve);
    ContinuousResource resourceSw3P3 = Resources.continuous(DID_3, PORT_3, Bandwidth.class).resource(bpsToReserve);
    ContinuousResource resourceSw4P1 = Resources.continuous(DID_4, PORT_1, Bandwidth.class).resource(bpsToReserve);
    ContinuousResource resourceSw4P2 = Resources.continuous(DID_4, PORT_2, Bandwidth.class).resource(bpsToReserve);
    String[] hops = { DID_3.toString() };
    final ResourceService resourceService = MockResourceService.makeCustomBandwidthResourceService(bpsTotal);
    final List<Constraint> constraints = Collections.singletonList(new BandwidthConstraint(Bandwidth.bps(bpsToReserve)));
    FilteredConnectPoint ingress = new FilteredConnectPoint(new ConnectPoint(DID_4, PORT_1));
    Set<FilteredConnectPoint> egress = ImmutableSet.of(new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_2)), new FilteredConnectPoint(new ConnectPoint(DID_2, PORT_2)));
    TrafficSelector ipPrefixSelector = DefaultTrafficSelector.builder().matchIPDst(IpPrefix.valueOf("192.168.100.0/24")).build();
    SinglePointToMultiPointIntent intent = makeIntent(ingress, egress, ipPrefixSelector, constraints);
    SinglePointToMultiPointIntentCompiler compiler = makeCompiler(null, new IntentTestsMocks.FixedMP2MPMockPathService(hops), resourceService);
    compiler.compile(intent, null);
    Key intentKey = intent.key();
    ResourceAllocation rA1 = new ResourceAllocation(resourceSw1P1, intentKey);
    ResourceAllocation rA2 = new ResourceAllocation(resourceSw1P2, intentKey);
    ResourceAllocation rA3 = new ResourceAllocation(resourceSw2P1, intentKey);
    ResourceAllocation rA4 = new ResourceAllocation(resourceSw2P2, intentKey);
    ResourceAllocation rA5 = new ResourceAllocation(resourceSw3P1, intentKey);
    ResourceAllocation rA6 = new ResourceAllocation(resourceSw3P2, intentKey);
    ResourceAllocation rA7 = new ResourceAllocation(resourceSw3P3, intentKey);
    ResourceAllocation rA8 = new ResourceAllocation(resourceSw4P1, intentKey);
    ResourceAllocation rA9 = new ResourceAllocation(resourceSw4P2, intentKey);
    Set<ResourceAllocation> expectedResourceAllocations = ImmutableSet.of(rA1, rA2, rA3, rA4, rA5, rA6, rA7, rA8, rA9);
    Set<ResourceAllocation> resourceAllocations = ImmutableSet.copyOf(resourceService.getResourceAllocations(intentKey));
    assertThat(resourceAllocations, hasSize(9));
    assertEquals(expectedResourceAllocations, resourceAllocations);
}
Also used : PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) Constraint(org.onosproject.net.intent.Constraint) BandwidthConstraint(org.onosproject.net.intent.constraint.BandwidthConstraint) ResourceService(org.onosproject.net.resource.ResourceService) MockResourceService(org.onosproject.net.resource.MockResourceService) IntentTestsMocks(org.onosproject.net.intent.IntentTestsMocks) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) ResourceAllocation(org.onosproject.net.resource.ResourceAllocation) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) Bandwidth(org.onlab.util.Bandwidth) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Key(org.onosproject.net.intent.Key) ContinuousResource(org.onosproject.net.resource.ContinuousResource) BandwidthConstraint(org.onosproject.net.intent.constraint.BandwidthConstraint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 25 with Key

use of org.onosproject.net.intent.Key in project onos by opennetworkinglab.

the class IntentsListCommand method fullFormat.

/*
     * Prints information about the intent state, given an intent.
     */
private StringBuilder fullFormat(Intent intent, IntentState state) {
    StringBuilder builder = new StringBuilder();
    NodeId nodeId = workPartitionService.getLeader(intent.key(), Key::hash);
    builder.append(format(ID, intent.id()));
    if (state != null) {
        builder.append('\n').append(format(STATE, state));
    }
    builder.append('\n').append(format(KEY, intent.key()));
    builder.append('\n').append(format(TYPE, intent.getClass().getSimpleName()));
    builder.append('\n').append(format(APP_ID, intent.appId().name()));
    builder.append('\n').append(nodeId == null ? NONE : format(LEADER_ID, nodeId.id()));
    return builder;
}
Also used : NodeId(org.onosproject.cluster.NodeId) Key(org.onosproject.net.intent.Key)

Aggregations

Key (org.onosproject.net.intent.Key)63 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)25 Intent (org.onosproject.net.intent.Intent)22 ConnectPoint (org.onosproject.net.ConnectPoint)20 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)19 TrafficSelector (org.onosproject.net.flow.TrafficSelector)19 MultiPointToSinglePointIntent (org.onosproject.net.intent.MultiPointToSinglePointIntent)19 Test (org.junit.Test)15 Constraint (org.onosproject.net.intent.Constraint)15 PointToPointIntent (org.onosproject.net.intent.PointToPointIntent)14 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)12 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)12 IntentService (org.onosproject.net.intent.IntentService)11 SinglePointToMultiPointIntent (org.onosproject.net.intent.SinglePointToMultiPointIntent)11 ApplicationId (org.onosproject.core.ApplicationId)10 ArrayList (java.util.ArrayList)9 HashSet (java.util.HashSet)9 Interface (org.onosproject.net.intf.Interface)9 Set (java.util.Set)8 MacAddress (org.onlab.packet.MacAddress)8