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();
}
}
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");
}
use of org.onosproject.net.intent.Key in project onos by opennetworkinglab.
the class SimpleFabricForwarding method deactivate.
@Deactivate
public void deactivate() {
log.info("simple fabric forwarding stopping");
simpleFabric.removeListener(simpleFabricListener);
for (Intent intent : bctIntentsMap.values()) {
intentService.withdraw(intent);
toBePurgedIntentKeys.add(intent.key());
}
for (Intent intent : uniIntentsMap.values()) {
intentService.withdraw(intent);
toBePurgedIntentKeys.add(intent.key());
}
for (Key key : toBePurgedIntentKeys) {
Intent intentToPurge = intentService.getIntent(key);
if (intentToPurge != null) {
intentService.purge(intentToPurge);
}
}
// do not set clear for switch compatibility
// bctIntentsMap.clear();
// uniIntentsMap.clear();
log.info("simple fabric forwarding stopped");
}
use of org.onosproject.net.intent.Key in project onos by opennetworkinglab.
the class SimpleFabricForwarding method dump.
// Dump command handler
private void dump(String subject, PrintStream out) {
if ("intents".equals(subject)) {
out.println("Forwarding Broadcast Intents:\n");
for (SinglePointToMultiPointIntent intent : bctIntentsMap.values()) {
out.println(" " + intent.key().toString() + ": " + intent.selector().criteria() + ", [" + intent.filteredIngressPoint().connectPoint() + "] -> " + intent.filteredEgressPoints().stream().map(FilteredConnectPoint::connectPoint).collect(Collectors.toSet()));
}
out.println("");
out.println("Forwarding Unicast Intents:\n");
for (MultiPointToSinglePointIntent intent : uniIntentsMap.values()) {
out.println(" " + intent.key().toString() + ": " + intent.selector().criteria() + ", [" + intent.filteredIngressPoints().stream().map(FilteredConnectPoint::connectPoint).collect(Collectors.toSet()) + "] -> " + intent.filteredEgressPoint().connectPoint());
}
out.println("");
out.println("Forwarding Intents to Be Purged:\n");
for (Key key : toBePurgedIntentKeys) {
out.println(" " + key.toString());
}
out.println("");
}
}
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;
}
Aggregations