/** * Returns ordered intent key from network and two hosts. * * @param network network name * @param one host one * @param two host two * @return canonical intent string key */ protected Key generateKey(String network, HostId one, HostId two) { String hosts = one.toString().compareTo(two.toString()) < 0 ? format(HOST_FORMAT, one, two) : format(HOST_FORMAT, two, one); return Key.of(format(KEY_FORMAT, network, hosts), appId); }
/** * Uninstalls a single intent by Id. * * @param appId the Application ID * @param keyString the Intent key value to look up */ @DELETE @Path("{appId}/{key}") public void deleteIntentById( @PathParam("appId") String appId, @PathParam("key") String keyString) { final ApplicationId app = get(CoreService.class).getAppId(appId); Intent intent = get(IntentService.class).getIntent(Key.of(keyString, app)); IntentService service = get(IntentService.class); if (intent == null) { intent = service.getIntent(Key.of(Long.decode(keyString), app)); } if (intent == null) { // No such intent. REST standards recommend a positive status code // in this case. return; } Key key = intent.key(); // set up latch and listener to track uninstall progress CountDownLatch latch = new CountDownLatch(1); IntentListener listener = new DeleteListener(key, latch); service.addListener(listener); try { // request the withdraw service.withdraw(intent); try { latch.await(WITHDRAW_EVENT_TIMEOUT_SECONDS, TimeUnit.SECONDS); } catch (InterruptedException e) { log.info("REST Delete operation timed out waiting for intent {}", key); } // double check the state IntentState state = service.getIntentState(key); if (state == WITHDRAWN || state == FAILED) { service.purge(intent); } } finally { // clean up the listener service.removeListener(listener); } }
/** * Generates the list of the expected mp2sp intents for VLAN 2. * * @return the list of expected mp2sp intents for VLAN 2 */ private List<MultiPointToSinglePointIntent> generateVlanTwoUni() { Key key = null; List<MultiPointToSinglePointIntent> intents = Lists.newArrayList(); // Building mp2sp intent for H4 - VLAN2 key = Key.of((PREFIX_UNICAST + "-" + DID4 + "-" + P1 + "-" + VLAN2), APPID); intents.add(buildUniIntent(key, Sets.newHashSet(C5, C6), C4, VLAN2, MAC4)); // Building mp2sp intent for H5 - VLAN2 key = Key.of((PREFIX_UNICAST + "-" + DID5 + "-" + P1 + "-" + VLAN2), APPID); intents.add(buildUniIntent(key, Sets.newHashSet(C4, C6), C5, VLAN2, MAC5)); // Building mp2sp intent for H6 - VLAN2 key = Key.of((PREFIX_UNICAST + "-" + DID6 + "-" + P1 + "-" + VLAN2), APPID); intents.add(buildUniIntent(key, Sets.newHashSet(C4, C5), C6, VLAN2, MAC6)); return intents; }
/** * Generates the list of the expected sp2mp intents for VLAN 2. * * @return the list of expected sp2mp intents for VLAN 2 */ private List<SinglePointToMultiPointIntent> generateVlanTwoBrc() { Key key = null; List<SinglePointToMultiPointIntent> intents = Lists.newArrayList(); // Building sp2mp intent for H4 - VLAN2 key = Key.of((PREFIX_BROADCAST + "-" + DID4 + "-" + P1 + "-" + VLAN2), APPID); intents.add(buildBrcIntent(key, C4, Sets.newHashSet(C5, C6), VLAN2)); // Building sp2mp intent for H5 - VLAN2 key = Key.of((PREFIX_BROADCAST + "-" + DID5 + "-" + P1 + "-" + VLAN2), APPID); intents.add(buildBrcIntent(key, C5, Sets.newHashSet(C4, C6), VLAN2)); // Building sp2mp intent for H6 - VLAN2 key = Key.of((PREFIX_BROADCAST + "-" + DID6 + "-" + P1 + "-" + VLAN2), APPID); intents.add(buildBrcIntent(key, C6, Sets.newHashSet(C4, C5), VLAN2)); return intents; }
/** * Generates the list of the expected mp2sp intents for VLAN 1. * * @return the list of expected mp2sp intents for VLAN 1 */ private List<MultiPointToSinglePointIntent> generateVlanOneUni() { Key key = null; List<MultiPointToSinglePointIntent> intents = Lists.newArrayList(); // Building mp2sp intent for H1 - VLAN1 key = Key.of((PREFIX_UNICAST + "-" + DID1 + "-" + P1 + "-" + VLAN1), APPID); intents.add(buildUniIntent(key, Sets.newHashSet(C2, C3), C1, VLAN1, MAC1)); // Building mp2sp intent for H2 - VLAN1 key = Key.of((PREFIX_UNICAST + "-" + DID2 + "-" + P1 + "-" + VLAN1), APPID); intents.add(buildUniIntent(key, Sets.newHashSet(C1, C3), C2, VLAN1, MAC2)); // Building mp2sp intent for H3 - VLAN1 key = Key.of((PREFIX_UNICAST + "-" + DID3 + "-" + P1 + "-" + VLAN1), APPID); intents.add(buildUniIntent(key, Sets.newHashSet(C1, C2), C3, VLAN1, MAC3)); return intents; }
/** * Generates the list of the expected sp2mp intents for VLAN 1. * * @return the list of expected sp2mp intents for VLAN 1 */ private List<SinglePointToMultiPointIntent> generateVlanOneBrc() { Key key = null; List<SinglePointToMultiPointIntent> intents = Lists.newArrayList(); // Building sp2mp intent for H1 - VLAN1 key = Key.of((PREFIX_BROADCAST + "-" + DID1 + "-" + P1 + "-" + VLAN1), APPID); intents.add(buildBrcIntent(key, C1, Sets.newHashSet(C2, C3), VLAN1)); // Building sp2mp intent for H2 - VLAN1 key = Key.of((PREFIX_BROADCAST + "-" + DID2 + "-" + P1 + "-" + VLAN1), APPID); intents.add(buildBrcIntent(key, C2, Sets.newHashSet(C1, C3), VLAN1)); // Building sp2mp intent for H3 - VLAN1 key = Key.of((PREFIX_BROADCAST + "-" + DID3 + "-" + P1 + "-" + VLAN1), APPID); intents.add(buildBrcIntent(key, C3, Sets.newHashSet(C1, C2), VLAN1)); return intents; }
/** * Constructs a BGP intent and put it into the intentList. * * <p>The purpose of this method is too simplify the setUpBgpIntents() method, and to make the * setUpBgpIntents() easy to read. * * @param srcVlanId ingress VlanId * @param dstVlanId egress VlanId * @param srcPrefix source IP prefix to match * @param dstPrefix destination IP prefix to match * @param srcTcpPort source TCP port to match * @param dstTcpPort destination TCP port to match * @param srcConnectPoint source connect point for PointToPointIntent * @param dstConnectPoint destination connect point for PointToPointIntent */ private void bgpPathintentConstructor( VlanId srcVlanId, VlanId dstVlanId, String srcPrefix, String dstPrefix, Short srcTcpPort, Short dstTcpPort, ConnectPoint srcConnectPoint, ConnectPoint dstConnectPoint) { TrafficSelector.Builder builder = DefaultTrafficSelector.builder() .matchEthType(Ethernet.TYPE_IPV4) .matchIPProtocol(IPv4.PROTOCOL_TCP) .matchIPSrc(IpPrefix.valueOf(srcPrefix)) .matchIPDst(IpPrefix.valueOf(dstPrefix)); if (!srcVlanId.equals(VlanId.NONE)) { builder.matchVlanId(srcVlanId); } TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); if (!dstVlanId.equals(VlanId.NONE)) { treatment.setVlanId(dstVlanId); } if (srcTcpPort != null) { builder.matchTcpSrc(TpPort.tpPort(srcTcpPort)); } if (dstTcpPort != null) { builder.matchTcpDst(TpPort.tpPort(dstTcpPort)); } Key key = Key.of( srcPrefix.split("/")[0] + "-" + dstPrefix.split("/")[0] + "-" + ((srcTcpPort == null) ? "dst" : "src"), APPID); PointToPointIntent intent = PointToPointIntent.builder() .appId(APPID) .key(key) .selector(builder.build()) .treatment(treatment.build()) .ingressPoint(srcConnectPoint) .egressPoint(dstConnectPoint) .build(); intentList.add(intent); }
@Override protected void execute() { IntentService intentService = get(IntentService.class); CoreService coreService = get(CoreService.class); ApplicationId appId = appId(); if (!isNullOrEmpty(applicationIdString)) { appId = coreService.getAppId(applicationIdString); if (appId == null) { print("Cannot find application Id %s", applicationIdString); return; } } if (isNullOrEmpty(keyString)) { for (Intent intent : intentService.getIntents()) { if (intent.appId().equals(appId)) { removeIntent(intentService, intent); } } } else { final Key key; if (keyString.startsWith("0x")) { // The intent uses a LongKey keyString = keyString.replaceFirst("0x", ""); key = Key.of(new BigInteger(keyString, 16).longValue(), appId); } else { // The intent uses a StringKey key = Key.of(keyString, appId); } Intent intent = intentService.getIntent(key); if (intent != null) { removeIntent(intentService, intent); } } }
/** * Gets a single intent by Id. * * @param appId the Application ID * @param key the Intent key value to look up * @return intent data */ @GET @Produces(MediaType.APPLICATION_JSON) @Path("{appId}/{key}") public Response getIntentById(@PathParam("appId") String appId, @PathParam("key") String key) { final ApplicationId app = get(CoreService.class).getAppId(appId); Intent intent = get(IntentService.class).getIntent(Key.of(key, app)); if (intent == null) { long numericalKey = Long.decode(key); intent = get(IntentService.class).getIntent(Key.of(numericalKey, app)); } nullIsNotFound(intent, INTENT_NOT_FOUND); final ObjectNode root; if (intent instanceof HostToHostIntent) { root = codec(HostToHostIntent.class).encode((HostToHostIntent) intent, this); } else if (intent instanceof PointToPointIntent) { root = codec(PointToPointIntent.class).encode((PointToPointIntent) intent, this); } else { root = codec(Intent.class).encode(intent, this); } return ok(root).build(); }
public final class KryoNamespaces { public static final KryoNamespace BASIC = KryoNamespace.newBuilder() .nextId(KryoNamespace.FLOATING_ID) .register(byte[].class) .register(AtomicBoolean.class) .register(AtomicInteger.class) .register(AtomicLong.class) .register( new ImmutableListSerializer(), ImmutableList.class, ImmutableList.of(1).getClass(), ImmutableList.of(1, 2).getClass()) .register( new ImmutableSetSerializer(), ImmutableSet.class, ImmutableSet.of().getClass(), ImmutableSet.of(1).getClass(), ImmutableSet.of(1, 2).getClass()) .register( new ImmutableMapSerializer(), ImmutableMap.class, ImmutableMap.of().getClass(), ImmutableMap.of("a", 1).getClass(), ImmutableMap.of("R", 2, "D", 2).getClass()) .register(Collections.unmodifiableSet(Collections.emptySet()).getClass()) .register(HashMap.class) .register(ConcurrentHashMap.class) .register(CopyOnWriteArraySet.class) .register(ArrayList.class, LinkedList.class, HashSet.class, LinkedHashSet.class) .register(Maps.immutableEntry("a", "b").getClass()) .register(new ArraysAsListSerializer(), Arrays.asList().getClass()) .register(Collections.singletonList(1).getClass()) .register(Duration.class) .register(Collections.emptySet().getClass()) .register(Optional.class) .register(Collections.emptyList().getClass()) .register(Collections.singleton(Object.class).getClass()) .register(int[].class) .register(long[].class) .register(short[].class) .register(double[].class) .register(float[].class) .register(char[].class) .register(String[].class) .register(boolean[].class) .build("BASIC"); /** KryoNamespace which can serialize ON.lab misc classes. */ public static final KryoNamespace MISC = KryoNamespace.newBuilder() .nextId(KryoNamespace.FLOATING_ID) .register(new IpPrefixSerializer(), IpPrefix.class) .register(new Ip4PrefixSerializer(), Ip4Prefix.class) .register(new Ip6PrefixSerializer(), Ip6Prefix.class) .register(new IpAddressSerializer(), IpAddress.class) .register(new Ip4AddressSerializer(), Ip4Address.class) .register(new Ip6AddressSerializer(), Ip6Address.class) .register(new MacAddressSerializer(), MacAddress.class) .register(Match.class) .register(VlanId.class) .register(Frequency.class) .register(Bandwidth.class) .register(Bandwidth.bps(1L).getClass()) .register(Bandwidth.bps(1.0).getClass()) .build("MISC"); /** Kryo registration Id for user custom registration. */ public static final int BEGIN_USER_CUSTOM_ID = 500; // TODO: Populate other classes /** KryoNamespace which can serialize API bundle classes. */ public static final KryoNamespace API = KryoNamespace.newBuilder() .nextId(KryoNamespace.INITIAL_ID) .register(BASIC) .nextId(KryoNamespace.INITIAL_ID + 50) .register(MISC) .nextId(KryoNamespace.INITIAL_ID + 50 + 30) .register( Instructions.MeterInstruction.class, MeterId.class, Version.class, ControllerNode.State.class, ApplicationState.class, ApplicationRole.class, DefaultApplication.class, Permission.class, Device.Type.class, Port.Type.class, ChassisId.class, DefaultControllerNode.class, DefaultDevice.class, DefaultDeviceDescription.class, DefaultHost.class, DefaultLinkDescription.class, Port.class, DefaultPortDescription.class, Element.class, Link.Type.class, Link.State.class, Timestamp.class, Change.class, Leader.class, Leadership.class, LeadershipEvent.class, LeadershipEvent.Type.class, HostId.class, HostDescription.class, DefaultHostDescription.class, DefaultFlowEntry.class, StoredFlowEntry.class, DefaultFlowRule.class, DefaultPacketRequest.class, PacketPriority.class, FlowEntry.FlowEntryState.class, FlowId.class, DefaultTrafficSelector.class, PortCriterion.class, MetadataCriterion.class, EthCriterion.class, EthType.class, EthTypeCriterion.class, VlanIdCriterion.class, VlanPcpCriterion.class, IPDscpCriterion.class, IPEcnCriterion.class, IPProtocolCriterion.class, IPCriterion.class, TpPort.class, TcpPortCriterion.class, UdpPortCriterion.class, SctpPortCriterion.class, IcmpTypeCriterion.class, IcmpCodeCriterion.class, IPv6FlowLabelCriterion.class, Icmpv6TypeCriterion.class, Icmpv6CodeCriterion.class, IPv6NDTargetAddressCriterion.class, IPv6NDLinkLayerAddressCriterion.class, MplsCriterion.class, MplsBosCriterion.class, TunnelIdCriterion.class, IPv6ExthdrFlagsCriterion.class, LambdaCriterion.class, OchSignalCriterion.class, OchSignalTypeCriterion.class, OduSignalIdCriterion.class, OduSignalTypeCriterion.class, ArpOpCriterion.class, ArpHaCriterion.class, ArpPaCriterion.class, Criterion.class, Criterion.Type.class, DefaultTrafficTreatment.class, Instructions.NoActionInstruction.class, Instructions.OutputInstruction.class, Instructions.GroupInstruction.class, Instructions.TableTypeTransition.class, L0ModificationInstruction.class, L0ModificationInstruction.L0SubType.class, L0ModificationInstruction.ModOchSignalInstruction.class, L1ModificationInstruction.class, L1ModificationInstruction.L1SubType.class, L1ModificationInstruction.ModOduSignalIdInstruction.class, L2ModificationInstruction.class, L2ModificationInstruction.L2SubType.class, L2ModificationInstruction.ModEtherInstruction.class, L2ModificationInstruction.PushHeaderInstructions.class, L2ModificationInstruction.ModVlanIdInstruction.class, L2ModificationInstruction.ModVlanPcpInstruction.class, L2ModificationInstruction.PopVlanInstruction.class, L2ModificationInstruction.ModMplsLabelInstruction.class, L2ModificationInstruction.ModMplsBosInstruction.class, L2ModificationInstruction.ModMplsTtlInstruction.class, L2ModificationInstruction.ModTunnelIdInstruction.class, L3ModificationInstruction.class, L3ModificationInstruction.L3SubType.class, L3ModificationInstruction.ModIPInstruction.class, L3ModificationInstruction.ModIPv6FlowLabelInstruction.class, L3ModificationInstruction.ModTtlInstruction.class, L4ModificationInstruction.class, L4ModificationInstruction.L4SubType.class, L4ModificationInstruction.ModTransportPortInstruction.class, RoleInfo.class, FlowRuleBatchEvent.class, FlowRuleBatchEvent.Type.class, FlowRuleBatchRequest.class, FlowRuleBatchOperation.class, FlowRuleEvent.class, FlowRuleEvent.Type.class, CompletedBatchOperation.class, FlowRuleBatchEntry.class, FlowRuleBatchEntry.FlowRuleOperation.class, IntentId.class, IntentState.class, // Key.class, is abstract Key.of(1L, new DefaultApplicationId(0, "bar")).getClass(), // LongKey.class Key.of("foo", new DefaultApplicationId(0, "bar")).getClass(), // StringKey.class Intent.class, ConnectivityIntent.class, PathIntent.class, DefaultPath.class, DefaultEdgeLink.class, HostToHostIntent.class, PointToPointIntent.class, MultiPointToSinglePointIntent.class, SinglePointToMultiPointIntent.class, FlowRuleIntent.class, LinkCollectionIntent.class, OpticalConnectivityIntent.class, OpticalPathIntent.class, OpticalCircuitIntent.class, OpticalOduIntent.class, FlowObjectiveIntent.class, DiscreteResource.class, ContinuousResource.class, DiscreteResourceId.class, ContinuousResourceId.class, ResourceAllocation.class, ResourceConsumerId.class, // Constraints BandwidthConstraint.class, LinkTypeConstraint.class, LatencyConstraint.class, WaypointConstraint.class, ObstacleConstraint.class, AnnotationConstraint.class, BooleanConstraint.class, PartialFailureConstraint.class, IntentOperation.class, FlowRuleExtPayLoad.class, DefaultAnnotations.class, PortStatistics.class, DefaultPortStatistics.class, IntentDomainId.class, TableStatisticsEntry.class, DefaultTableStatisticsEntry.class, EncapsulationConstraint.class, EncapsulationType.class, // Flow Objectives DefaultForwardingObjective.class, ForwardingObjective.Flag.class, DefaultFilteringObjective.class, FilteringObjective.Type.class, DefaultNextObjective.class, NextObjective.Type.class, Objective.Operation.class) .register(new DefaultApplicationIdSerializer(), DefaultApplicationId.class) .register(new UriSerializer(), URI.class) .register(new NodeIdSerializer(), NodeId.class) .register(new ProviderIdSerializer(), ProviderId.class) .register(new DeviceIdSerializer(), DeviceId.class) .register(new PortNumberSerializer(), PortNumber.class) .register(new DefaultPortSerializer(), DefaultPort.class) .register(new LinkKeySerializer(), LinkKey.class) .register(new ConnectPointSerializer(), ConnectPoint.class) .register(new DefaultLinkSerializer(), DefaultLink.class) .register(new MastershipTermSerializer(), MastershipTerm.class) .register(new HostLocationSerializer(), HostLocation.class) .register(new DefaultOutboundPacketSerializer(), DefaultOutboundPacket.class) .register(new AnnotationsSerializer(), DefaultAnnotations.class) .register( new ExtensionInstructionSerializer(), Instructions.ExtensionInstructionWrapper.class) .register(new ExtensionCriterionSerializer(), ExtensionCriterion.class) .register(ExtensionSelectorType.class) .register(ExtensionTreatmentType.class) .register(TransactionId.class) .register(MapTransaction.class) .register(MapUpdate.class) .register(MapUpdate.Type.class) .register(Versioned.class) .register(MapEvent.class) .register(MapEvent.Type.class) .register(SetEvent.class) .register(SetEvent.Type.class) .register(DefaultGroupId.class) .register(Annotations.class) .register(OmsPort.class) .register(OchPort.class) .register(OduSignalType.class) .register(OchSignalType.class) .register(GridType.class) .register(ChannelSpacing.class) .register(OduCltPort.class) .register(CltSignalType.class) .register(OchSignal.class) .register(OduSignalId.class) .register(OduCltPortDescription.class) .register(OchPortDescription.class) .register(OmsPortDescription.class) .register(TributarySlot.class) .register(OtuPort.class) .register(OtuSignalType.class) .register(OtuPortDescription.class) .register( MplsIntent.class, MplsPathIntent.class, org.onlab.packet.MplsLabel.class, org.onlab.packet.MPLS.class) .register(ClosedOpenRange.class) .register(DiscreteResourceCodec.class) .register(new ImmutableByteSequenceSerializer(), ImmutableByteSequence.class) .build("API"); // not to be instantiated private KryoNamespaces() {} }
/** * Generates a route intent for a prefix, the next hop IP address, and the next hop MAC address. * * <p>This method will find the egress interface for the intent. Intent will match dst IP prefix * and rewrite dst MAC address at all other border switches, then forward packets according to dst * MAC address. * * @param prefix IP prefix of the route to add * @param nextHopIpAddress IP address of the next hop * @param nextHopMacAddress MAC address of the next hop * @return the generated intent, or null if no intent should be submitted */ private MultiPointToSinglePointIntent generateRouteIntent( IpPrefix prefix, IpAddress nextHopIpAddress, MacAddress nextHopMacAddress) { // Find the attachment point (egress interface) of the next hop Interface egressInterface = interfaceService.getMatchingInterface(nextHopIpAddress); if (egressInterface == null) { log.warn("No outgoing interface found for {}", nextHopIpAddress); return null; } // Generate the intent itself Set<ConnectPoint> ingressPorts = new HashSet<>(); ConnectPoint egressPort = egressInterface.connectPoint(); log.debug("Generating intent for prefix {}, next hop mac {}", prefix, nextHopMacAddress); for (Interface intf : interfaceService.getInterfaces()) { // TODO this should be only peering interfaces if (!intf.connectPoint().equals(egressInterface.connectPoint())) { ConnectPoint srcPort = intf.connectPoint(); ingressPorts.add(srcPort); } } // Match the destination IP prefix at the first hop TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); if (prefix.isIp4()) { selector.matchEthType(Ethernet.TYPE_IPV4); // if it is default route, then we do not need match destination // IP address if (prefix.prefixLength() != 0) { selector.matchIPDst(prefix); } } else { selector.matchEthType(Ethernet.TYPE_IPV6); // if it is default route, then we do not need match destination // IP address if (prefix.prefixLength() != 0) { selector.matchIPv6Dst(prefix); } } // Rewrite the destination MAC address TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder().setEthDst(nextHopMacAddress); if (!egressInterface.vlan().equals(VlanId.NONE)) { treatment.setVlanId(egressInterface.vlan()); // If we set VLAN ID, we have to make sure a VLAN tag exists. // TODO support no VLAN -> VLAN routing selector.matchVlanId(VlanId.ANY); } int priority = prefix.prefixLength() * PRIORITY_MULTIPLIER + PRIORITY_OFFSET; Key key = Key.of(prefix.toString(), appId); return MultiPointToSinglePointIntent.builder() .appId(appId) .key(key) .selector(selector.build()) .treatment(treatment.build()) .ingressPoints(ingressPorts) .egressPoint(egressPort) .priority(priority) .constraints(CONSTRAINTS) .build(); }
public final class KryoNamespaces { public static final KryoNamespace BASIC = KryoNamespace.newBuilder() .nextId(KryoNamespace.FLOATING_ID) .register(byte[].class) .register(AtomicBoolean.class) .register(AtomicInteger.class) .register(AtomicLong.class) .register( new ImmutableListSerializer(), ImmutableList.class, ImmutableList.of(1).getClass(), ImmutableList.of(1, 2).getClass()) .register( new ImmutableSetSerializer(), ImmutableSet.class, ImmutableSet.of().getClass(), ImmutableSet.of(1).getClass(), ImmutableSet.of(1, 2).getClass()) .register( new ImmutableMapSerializer(), ImmutableMap.class, ImmutableMap.of().getClass(), ImmutableMap.of("a", 1).getClass(), ImmutableMap.of("R", 2, "D", 2).getClass()) .register(HashMap.class) .register(ConcurrentHashMap.class) .register(CopyOnWriteArraySet.class) .register(ArrayList.class, LinkedList.class, HashSet.class) .register(new ArraysAsListSerializer(), Arrays.asList().getClass()) .register(Collections.singletonList(1).getClass()) .register(Duration.class) .register(Collections.emptySet().getClass()) .register(Optional.class) .register(Collections.emptyList().getClass()) .register(Collections.unmodifiableSet(Collections.emptySet()).getClass()) .register(Collections.singleton(Object.class).getClass()) .build(); /** KryoNamespace which can serialize ON.lab misc classes. */ public static final KryoNamespace MISC = KryoNamespace.newBuilder() .nextId(KryoNamespace.FLOATING_ID) .register(new IpPrefixSerializer(), IpPrefix.class) .register(new Ip4PrefixSerializer(), Ip4Prefix.class) .register(new Ip6PrefixSerializer(), Ip6Prefix.class) .register(new IpAddressSerializer(), IpAddress.class) .register(new Ip4AddressSerializer(), Ip4Address.class) .register(new Ip6AddressSerializer(), Ip6Address.class) .register(new MacAddressSerializer(), MacAddress.class) .register(VlanId.class) .register(Frequency.class) .register(Bandwidth.class) .build(); /** Kryo registration Id for user custom registration. */ public static final int BEGIN_USER_CUSTOM_ID = 300; // TODO: Populate other classes /** KryoNamespace which can serialize API bundle classes. */ public static final KryoNamespace API = KryoNamespace.newBuilder() .nextId(KryoNamespace.INITIAL_ID) .register(BASIC) .nextId(KryoNamespace.INITIAL_ID + 30) .register(MISC) .nextId(KryoNamespace.INITIAL_ID + 30 + 10) .register( Version.class, ControllerNode.State.class, ApplicationState.class, ApplicationRole.class, DefaultApplication.class, Device.Type.class, Port.Type.class, ChassisId.class, DefaultControllerNode.class, DefaultDevice.class, DefaultDeviceDescription.class, DefaultHost.class, DefaultLinkDescription.class, Port.class, DefaultPortDescription.class, Element.class, Link.Type.class, Link.State.class, Timestamp.class, Leadership.class, LeadershipEvent.class, LeadershipEvent.Type.class, HostId.class, HostDescription.class, DefaultHostDescription.class, DefaultFlowEntry.class, StoredFlowEntry.class, FlowRule.Type.class, DefaultFlowRule.class, DefaultFlowEntry.class, DefaultPacketRequest.class, PacketPriority.class, FlowEntry.FlowEntryState.class, FlowId.class, DefaultTrafficSelector.class, PortCriterion.class, MetadataCriterion.class, EthCriterion.class, EthType.class, EthTypeCriterion.class, VlanIdCriterion.class, VlanPcpCriterion.class, IPDscpCriterion.class, IPEcnCriterion.class, IPProtocolCriterion.class, IPCriterion.class, TcpPortCriterion.class, UdpPortCriterion.class, SctpPortCriterion.class, IcmpTypeCriterion.class, IcmpCodeCriterion.class, IPv6FlowLabelCriterion.class, Icmpv6TypeCriterion.class, Icmpv6CodeCriterion.class, IPv6NDTargetAddressCriterion.class, IPv6NDLinkLayerAddressCriterion.class, MplsCriterion.class, TunnelIdCriterion.class, IPv6ExthdrFlagsCriterion.class, LambdaCriterion.class, IndexedLambdaCriterion.class, OchSignalCriterion.class, OchSignalTypeCriterion.class, OpticalSignalTypeCriterion.class, Criterion.class, Criterion.Type.class, DefaultTrafficTreatment.class, Instructions.DropInstruction.class, Instructions.OutputInstruction.class, Instructions.GroupInstruction.class, Instructions.TableTypeTransition.class, L0ModificationInstruction.class, L0ModificationInstruction.L0SubType.class, L0ModificationInstruction.ModLambdaInstruction.class, L0ModificationInstruction.ModOchSignalInstruction.class, L2ModificationInstruction.class, L2ModificationInstruction.L2SubType.class, L2ModificationInstruction.ModEtherInstruction.class, L2ModificationInstruction.PushHeaderInstructions.class, L2ModificationInstruction.ModVlanIdInstruction.class, L2ModificationInstruction.ModVlanPcpInstruction.class, L2ModificationInstruction.PopVlanInstruction.class, L2ModificationInstruction.ModMplsLabelInstruction.class, L2ModificationInstruction.ModMplsTtlInstruction.class, L2ModificationInstruction.ModTunnelIdInstruction.class, L3ModificationInstruction.class, L3ModificationInstruction.L3SubType.class, L3ModificationInstruction.ModIPInstruction.class, L3ModificationInstruction.ModIPv6FlowLabelInstruction.class, L3ModificationInstruction.ModTtlInstruction.class, RoleInfo.class, FlowRuleBatchEvent.class, FlowRuleBatchEvent.Type.class, FlowRuleBatchRequest.class, FlowRuleBatchOperation.class, FlowRuleEvent.class, FlowRuleEvent.Type.class, CompletedBatchOperation.class, FlowRuleBatchEntry.class, FlowRuleBatchEntry.FlowRuleOperation.class, IntentId.class, IntentState.class, // Key.class, is abstract Key.of(1L, new DefaultApplicationId(0, "bar")).getClass(), // LongKey.class Key.of("foo", new DefaultApplicationId(0, "bar")).getClass(), // StringKey.class Intent.class, ConnectivityIntent.class, PathIntent.class, DefaultPath.class, DefaultEdgeLink.class, HostToHostIntent.class, PointToPointIntent.class, MultiPointToSinglePointIntent.class, SinglePointToMultiPointIntent.class, FlowRuleIntent.class, LinkCollectionIntent.class, OpticalConnectivityIntent.class, OpticalPathIntent.class, OpticalCircuitIntent.class, LinkResourceRequest.class, DefaultLinkResourceRequest.class, BandwidthResourceRequest.class, LambdaResourceRequest.class, LambdaResource.class, BandwidthResource.class, DefaultLinkResourceAllocations.class, BandwidthResourceAllocation.class, LambdaResourceAllocation.class, // Constraints LambdaConstraint.class, BandwidthConstraint.class, LinkTypeConstraint.class, LatencyConstraint.class, WaypointConstraint.class, ObstacleConstraint.class, AnnotationConstraint.class, BooleanConstraint.class, IntentOperation.class, FlowRuleExtPayLoad.class, Frequency.class, DefaultAnnotations.class, PortStatistics.class, DefaultPortStatistics.class) .register(new DefaultApplicationIdSerializer(), DefaultApplicationId.class) .register(new URISerializer(), URI.class) .register(new NodeIdSerializer(), NodeId.class) .register(new ProviderIdSerializer(), ProviderId.class) .register(new DeviceIdSerializer(), DeviceId.class) .register(new PortNumberSerializer(), PortNumber.class) .register(new DefaultPortSerializer(), DefaultPort.class) .register(new LinkKeySerializer(), LinkKey.class) .register(new ConnectPointSerializer(), ConnectPoint.class) .register(new DefaultLinkSerializer(), DefaultLink.class) .register(new MastershipTermSerializer(), MastershipTerm.class) .register(new HostLocationSerializer(), HostLocation.class) .register(new DefaultOutboundPacketSerializer(), DefaultOutboundPacket.class) .register(new AnnotationsSerializer(), DefaultAnnotations.class) .register(Versioned.class) .register(MapEvent.class) .register(MapEvent.Type.class) .register(SetEvent.class) .register(SetEvent.Type.class) .register(DefaultGroupId.class) .register(Annotations.class) .register(OmsPort.class) .register(OchPort.class) .register(OduSignalType.class) .register(OchSignalType.class) .register(GridType.class) .register(ChannelSpacing.class) .register(OduCltPort.class) .register(OduCltPort.SignalType.class) .register(IndexedLambda.class) .register(OchSignal.class) .register(OduCltPortDescription.class) .register(OchPortDescription.class) .register(OmsPortDescription.class) .register( MplsIntent.class, MplsPathIntent.class, MplsLabelResourceAllocation.class, MplsLabelResourceRequest.class, MplsLabel.class, org.onlab.packet.MplsLabel.class, org.onlab.packet.MPLS.class) .build(); // not to be instantiated private KryoNamespaces() {} }