real application ids
Change-Id: Ia24f1de6ccff614769727ab261002520dfd8506f
Showing
15 changed files
with
151 additions
and
69 deletions
| ... | @@ -10,6 +10,7 @@ import org.apache.felix.scr.annotations.Deactivate; | ... | @@ -10,6 +10,7 @@ import org.apache.felix.scr.annotations.Deactivate; |
| 10 | import org.apache.felix.scr.annotations.Reference; | 10 | import org.apache.felix.scr.annotations.Reference; |
| 11 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 11 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 12 | import org.onlab.onos.ApplicationId; | 12 | import org.onlab.onos.ApplicationId; |
| 13 | +import org.onlab.onos.CoreService; | ||
| 13 | import org.onlab.onos.net.Host; | 14 | import org.onlab.onos.net.Host; |
| 14 | import org.onlab.onos.net.HostId; | 15 | import org.onlab.onos.net.HostId; |
| 15 | import org.onlab.onos.net.Path; | 16 | import org.onlab.onos.net.Path; |
| ... | @@ -53,13 +54,16 @@ public class ReactiveForwarding { | ... | @@ -53,13 +54,16 @@ public class ReactiveForwarding { |
| 53 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 54 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 54 | protected FlowRuleService flowRuleService; | 55 | protected FlowRuleService flowRuleService; |
| 55 | 56 | ||
| 57 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 58 | + protected CoreService coreService; | ||
| 59 | + | ||
| 56 | private ReactivePacketProcessor processor = new ReactivePacketProcessor(); | 60 | private ReactivePacketProcessor processor = new ReactivePacketProcessor(); |
| 57 | 61 | ||
| 58 | private ApplicationId appId; | 62 | private ApplicationId appId; |
| 59 | 63 | ||
| 60 | @Activate | 64 | @Activate |
| 61 | public void activate() { | 65 | public void activate() { |
| 62 | - appId = ApplicationId.getAppId(); | 66 | + appId = coreService.registerApplication("org.onlab.onos.fwd"); |
| 63 | packetService.addProcessor(processor, PacketProcessor.ADVISOR_MAX + 2); | 67 | packetService.addProcessor(processor, PacketProcessor.ADVISOR_MAX + 2); |
| 64 | log.info("Started with Application ID {}", appId.id()); | 68 | log.info("Started with Application ID {}", appId.id()); |
| 65 | } | 69 | } | ... | ... |
| ... | @@ -10,6 +10,7 @@ import org.apache.felix.scr.annotations.Deactivate; | ... | @@ -10,6 +10,7 @@ import org.apache.felix.scr.annotations.Deactivate; |
| 10 | import org.apache.felix.scr.annotations.Reference; | 10 | import org.apache.felix.scr.annotations.Reference; |
| 11 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 11 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 12 | import org.onlab.onos.ApplicationId; | 12 | import org.onlab.onos.ApplicationId; |
| 13 | +import org.onlab.onos.CoreService; | ||
| 13 | import org.onlab.onos.net.Device; | 14 | import org.onlab.onos.net.Device; |
| 14 | import org.onlab.onos.net.Host; | 15 | import org.onlab.onos.net.Host; |
| 15 | import org.onlab.onos.net.device.DeviceService; | 16 | import org.onlab.onos.net.device.DeviceService; |
| ... | @@ -44,11 +45,14 @@ public class HostMobility { | ... | @@ -44,11 +45,14 @@ public class HostMobility { |
| 44 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 45 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 45 | protected DeviceService deviceService; | 46 | protected DeviceService deviceService; |
| 46 | 47 | ||
| 48 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 49 | + protected CoreService coreService; | ||
| 50 | + | ||
| 47 | private ApplicationId appId; | 51 | private ApplicationId appId; |
| 48 | 52 | ||
| 49 | @Activate | 53 | @Activate |
| 50 | public void activate() { | 54 | public void activate() { |
| 51 | - appId = ApplicationId.getAppId(); | 55 | + appId = coreService.registerApplication("org.onlab.onos.mobility"); |
| 52 | hostService.addListener(new InternalHostListener()); | 56 | hostService.addListener(new InternalHostListener()); |
| 53 | log.info("Started with Application ID {}", appId.id()); | 57 | log.info("Started with Application ID {}", appId.id()); |
| 54 | } | 58 | } | ... | ... |
| ... | @@ -8,6 +8,7 @@ import org.apache.felix.scr.annotations.Deactivate; | ... | @@ -8,6 +8,7 @@ import org.apache.felix.scr.annotations.Deactivate; |
| 8 | import org.apache.felix.scr.annotations.Reference; | 8 | import org.apache.felix.scr.annotations.Reference; |
| 9 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 9 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 10 | import org.onlab.onos.ApplicationId; | 10 | import org.onlab.onos.ApplicationId; |
| 11 | +import org.onlab.onos.CoreService; | ||
| 11 | import org.onlab.onos.net.packet.PacketContext; | 12 | import org.onlab.onos.net.packet.PacketContext; |
| 12 | import org.onlab.onos.net.packet.PacketProcessor; | 13 | import org.onlab.onos.net.packet.PacketProcessor; |
| 13 | import org.onlab.onos.net.packet.PacketService; | 14 | import org.onlab.onos.net.packet.PacketService; |
| ... | @@ -31,11 +32,14 @@ public class ProxyArp { | ... | @@ -31,11 +32,14 @@ public class ProxyArp { |
| 31 | 32 | ||
| 32 | private ProxyArpProcessor processor = new ProxyArpProcessor(); | 33 | private ProxyArpProcessor processor = new ProxyArpProcessor(); |
| 33 | 34 | ||
| 35 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 36 | + protected CoreService coreService; | ||
| 37 | + | ||
| 34 | private ApplicationId appId; | 38 | private ApplicationId appId; |
| 35 | 39 | ||
| 36 | @Activate | 40 | @Activate |
| 37 | public void activate() { | 41 | public void activate() { |
| 38 | - appId = ApplicationId.getAppId(); | 42 | + appId = coreService.registerApplication("org.onlab.onos.proxyarp"); |
| 39 | packetService.addProcessor(processor, PacketProcessor.ADVISOR_MAX + 1); | 43 | packetService.addProcessor(processor, PacketProcessor.ADVISOR_MAX + 1); |
| 40 | log.info("Started with Application ID {}", appId.id()); | 44 | log.info("Started with Application ID {}", appId.id()); |
| 41 | } | 45 | } | ... | ... |
| 1 | package org.onlab.onos; | 1 | package org.onlab.onos; |
| 2 | 2 | ||
| 3 | -import java.util.Objects; | ||
| 4 | -import java.util.concurrent.atomic.AtomicInteger; | ||
| 5 | 3 | ||
| 6 | /** | 4 | /** |
| 7 | - * Application id generator class. | 5 | + * Application identifier. |
| 8 | */ | 6 | */ |
| 9 | -public final class ApplicationId { | 7 | +public interface ApplicationId { |
| 10 | 8 | ||
| 11 | - private static final AtomicInteger ID_DISPENCER = new AtomicInteger(1); | 9 | + /** |
| 12 | - private final Integer id; | 10 | + * Returns the application id. |
| 13 | - | 11 | + * @return a short value |
| 14 | - // Ban public construction | 12 | + */ |
| 15 | - private ApplicationId(Integer id) { | 13 | + short id(); |
| 16 | - this.id = id; | ||
| 17 | - } | ||
| 18 | - | ||
| 19 | - public Integer id() { | ||
| 20 | - return id; | ||
| 21 | - } | ||
| 22 | - | ||
| 23 | - public static ApplicationId valueOf(Integer id) { | ||
| 24 | - return new ApplicationId(id); | ||
| 25 | - } | ||
| 26 | - | ||
| 27 | - @Override | ||
| 28 | - public int hashCode() { | ||
| 29 | - return Objects.hash(id); | ||
| 30 | - } | ||
| 31 | - | ||
| 32 | - @Override | ||
| 33 | - public boolean equals(Object obj) { | ||
| 34 | - if (this == obj) { | ||
| 35 | - return true; | ||
| 36 | - } | ||
| 37 | - if (obj == null) { | ||
| 38 | - return false; | ||
| 39 | - } | ||
| 40 | - if (!(obj instanceof ApplicationId)) { | ||
| 41 | - return false; | ||
| 42 | - } | ||
| 43 | - ApplicationId other = (ApplicationId) obj; | ||
| 44 | - return Objects.equals(this.id, other.id); | ||
| 45 | - } | ||
| 46 | 14 | ||
| 47 | /** | 15 | /** |
| 48 | - * Returns a new application id. | 16 | + * Returns the applications supplied identifier. |
| 49 | - * | 17 | + * @return a string identifier |
| 50 | - * @return app id | ||
| 51 | */ | 18 | */ |
| 52 | - public static ApplicationId getAppId() { | 19 | + String name(); |
| 53 | - return new ApplicationId(ApplicationId.ID_DISPENCER.getAndIncrement()); | ||
| 54 | - } | ||
| 55 | 20 | ||
| 56 | } | 21 | } | ... | ... |
| ... | @@ -12,4 +12,21 @@ public interface CoreService { | ... | @@ -12,4 +12,21 @@ public interface CoreService { |
| 12 | */ | 12 | */ |
| 13 | Version version(); | 13 | Version version(); |
| 14 | 14 | ||
| 15 | + /** | ||
| 16 | + * Registers a new application by its name, which is expected | ||
| 17 | + * to follow the reverse DNS convention, e.g. | ||
| 18 | + * {@code org.flying.circus.app} | ||
| 19 | + * | ||
| 20 | + * @param identifier string identifier | ||
| 21 | + * @return the application id | ||
| 22 | + */ | ||
| 23 | + ApplicationId registerApplication(String identifier); | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * Returns an existing application id from a given id. | ||
| 27 | + * @param id the short value of the id | ||
| 28 | + * @return an application id | ||
| 29 | + */ | ||
| 30 | + ApplicationId getAppId(Short id); | ||
| 31 | + | ||
| 15 | } | 32 | } | ... | ... |
| ... | @@ -21,7 +21,7 @@ public class DefaultFlowRule implements FlowRule { | ... | @@ -21,7 +21,7 @@ public class DefaultFlowRule implements FlowRule { |
| 21 | 21 | ||
| 22 | private final FlowId id; | 22 | private final FlowId id; |
| 23 | 23 | ||
| 24 | - private final ApplicationId appId; | 24 | + private final short appId; |
| 25 | 25 | ||
| 26 | private final int timeout; | 26 | private final int timeout; |
| 27 | 27 | ||
| ... | @@ -36,7 +36,7 @@ public class DefaultFlowRule implements FlowRule { | ... | @@ -36,7 +36,7 @@ public class DefaultFlowRule implements FlowRule { |
| 36 | this.timeout = timeout; | 36 | this.timeout = timeout; |
| 37 | this.created = System.currentTimeMillis(); | 37 | this.created = System.currentTimeMillis(); |
| 38 | 38 | ||
| 39 | - this.appId = ApplicationId.valueOf((int) (flowId >> 32)); | 39 | + this.appId = (short) (flowId >>> 48); |
| 40 | this.id = FlowId.valueOf(flowId); | 40 | this.id = FlowId.valueOf(flowId); |
| 41 | } | 41 | } |
| 42 | 42 | ||
| ... | @@ -52,11 +52,11 @@ public class DefaultFlowRule implements FlowRule { | ... | @@ -52,11 +52,11 @@ public class DefaultFlowRule implements FlowRule { |
| 52 | this.priority = priority; | 52 | this.priority = priority; |
| 53 | this.selector = selector; | 53 | this.selector = selector; |
| 54 | this.treatment = treatement; | 54 | this.treatment = treatement; |
| 55 | - this.appId = appId; | 55 | + this.appId = appId.id(); |
| 56 | this.timeout = timeout; | 56 | this.timeout = timeout; |
| 57 | this.created = System.currentTimeMillis(); | 57 | this.created = System.currentTimeMillis(); |
| 58 | 58 | ||
| 59 | - this.id = FlowId.valueOf((((long) appId().id()) << 32) | (this.hash() & 0xffffffffL)); | 59 | + this.id = FlowId.valueOf((((long) this.appId) << 48) | (this.hash() & 0x0000ffffffffL)); |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | public DefaultFlowRule(FlowRule rule) { | 62 | public DefaultFlowRule(FlowRule rule) { |
| ... | @@ -78,7 +78,7 @@ public class DefaultFlowRule implements FlowRule { | ... | @@ -78,7 +78,7 @@ public class DefaultFlowRule implements FlowRule { |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | @Override | 80 | @Override |
| 81 | - public ApplicationId appId() { | 81 | + public short appId() { |
| 82 | return appId; | 82 | return appId; |
| 83 | } | 83 | } |
| 84 | 84 | ... | ... |
| 1 | package org.onlab.onos.net.flow; | 1 | package org.onlab.onos.net.flow; |
| 2 | 2 | ||
| 3 | -import org.onlab.onos.ApplicationId; | ||
| 4 | import org.onlab.onos.net.DeviceId; | 3 | import org.onlab.onos.net.DeviceId; |
| 5 | import org.onlab.onos.net.intent.BatchOperationTarget; | 4 | import org.onlab.onos.net.intent.BatchOperationTarget; |
| 6 | 5 | ||
| ... | @@ -26,7 +25,7 @@ public interface FlowRule extends BatchOperationTarget { | ... | @@ -26,7 +25,7 @@ public interface FlowRule extends BatchOperationTarget { |
| 26 | * | 25 | * |
| 27 | * @return an applicationId | 26 | * @return an applicationId |
| 28 | */ | 27 | */ |
| 29 | - ApplicationId appId(); | 28 | + short appId(); |
| 30 | 29 | ||
| 31 | /** | 30 | /** |
| 32 | * Returns the flow rule priority given in natural order; higher numbers | 31 | * Returns the flow rule priority given in natural order; higher numbers | ... | ... |
| 1 | -package org.onlab.onos.cluster.impl; | 1 | +package org.onlab.onos.impl; |
| 2 | + | ||
| 3 | +import java.io.File; | ||
| 4 | +import java.util.List; | ||
| 5 | +import java.util.Map; | ||
| 6 | +import java.util.concurrent.ConcurrentHashMap; | ||
| 7 | +import java.util.concurrent.atomic.AtomicInteger; | ||
| 2 | 8 | ||
| 3 | import org.apache.felix.scr.annotations.Activate; | 9 | import org.apache.felix.scr.annotations.Activate; |
| 4 | import org.apache.felix.scr.annotations.Component; | 10 | import org.apache.felix.scr.annotations.Component; |
| 5 | import org.apache.felix.scr.annotations.Service; | 11 | import org.apache.felix.scr.annotations.Service; |
| 12 | +import org.onlab.onos.ApplicationId; | ||
| 6 | import org.onlab.onos.CoreService; | 13 | import org.onlab.onos.CoreService; |
| 7 | import org.onlab.onos.Version; | 14 | import org.onlab.onos.Version; |
| 8 | import org.onlab.util.Tools; | 15 | import org.onlab.util.Tools; |
| 9 | 16 | ||
| 10 | -import java.io.File; | ||
| 11 | -import java.util.List; | ||
| 12 | 17 | ||
| 13 | /** | 18 | /** |
| 14 | * Core service implementation. | 19 | * Core service implementation. |
| ... | @@ -17,9 +22,12 @@ import java.util.List; | ... | @@ -17,9 +22,12 @@ import java.util.List; |
| 17 | @Service | 22 | @Service |
| 18 | public class CoreManager implements CoreService { | 23 | public class CoreManager implements CoreService { |
| 19 | 24 | ||
| 25 | + private static final AtomicInteger ID_DISPENSER = new AtomicInteger(1); | ||
| 20 | private static final File VERSION_FILE = new File("../VERSION"); | 26 | private static final File VERSION_FILE = new File("../VERSION"); |
| 21 | private static Version version = Version.version("1.0.0-SNAPSHOT"); | 27 | private static Version version = Version.version("1.0.0-SNAPSHOT"); |
| 22 | 28 | ||
| 29 | + private final Map<Short, DefaultApplicationId> ids = new ConcurrentHashMap<>(); | ||
| 30 | + | ||
| 23 | // TODO: work in progress | 31 | // TODO: work in progress |
| 24 | 32 | ||
| 25 | @Activate | 33 | @Activate |
| ... | @@ -35,4 +43,14 @@ public class CoreManager implements CoreService { | ... | @@ -35,4 +43,14 @@ public class CoreManager implements CoreService { |
| 35 | return version; | 43 | return version; |
| 36 | } | 44 | } |
| 37 | 45 | ||
| 46 | + @Override | ||
| 47 | + public ApplicationId getAppId(Short id) { | ||
| 48 | + return ids.get(id); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + @Override | ||
| 52 | + public ApplicationId registerApplication(String name) { | ||
| 53 | + return new DefaultApplicationId((short) ID_DISPENSER.getAndIncrement(), name); | ||
| 54 | + } | ||
| 55 | + | ||
| 38 | } | 56 | } | ... | ... |
| 1 | +package org.onlab.onos.impl; | ||
| 2 | + | ||
| 3 | +import java.util.Objects; | ||
| 4 | + | ||
| 5 | +import org.onlab.onos.ApplicationId; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * Application id generator class. | ||
| 9 | + */ | ||
| 10 | +public class DefaultApplicationId implements ApplicationId { | ||
| 11 | + | ||
| 12 | + | ||
| 13 | + private final short id; | ||
| 14 | + private final String name; | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + // Ban public construction | ||
| 18 | + protected DefaultApplicationId(Short id, String identifier) { | ||
| 19 | + this.id = id; | ||
| 20 | + this.name = identifier; | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + @Override | ||
| 24 | + public short id() { | ||
| 25 | + return id; | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + @Override | ||
| 29 | + public String name() { | ||
| 30 | + return name; | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + @Override | ||
| 34 | + public int hashCode() { | ||
| 35 | + return Objects.hash(id); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + @Override | ||
| 39 | + public boolean equals(Object obj) { | ||
| 40 | + if (this == obj) { | ||
| 41 | + return true; | ||
| 42 | + } | ||
| 43 | + if (obj == null) { | ||
| 44 | + return false; | ||
| 45 | + } | ||
| 46 | + if (!(obj instanceof DefaultApplicationId)) { | ||
| 47 | + return false; | ||
| 48 | + } | ||
| 49 | + DefaultApplicationId other = (DefaultApplicationId) obj; | ||
| 50 | + return Objects.equals(this.id, other.id); | ||
| 51 | + } | ||
| 52 | +} |
| ... | @@ -13,6 +13,7 @@ import org.apache.felix.scr.annotations.Deactivate; | ... | @@ -13,6 +13,7 @@ import org.apache.felix.scr.annotations.Deactivate; |
| 13 | import org.apache.felix.scr.annotations.Reference; | 13 | import org.apache.felix.scr.annotations.Reference; |
| 14 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 14 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 15 | import org.onlab.onos.ApplicationId; | 15 | import org.onlab.onos.ApplicationId; |
| 16 | +import org.onlab.onos.CoreService; | ||
| 16 | import org.onlab.onos.net.ConnectPoint; | 17 | import org.onlab.onos.net.ConnectPoint; |
| 17 | import org.onlab.onos.net.Link; | 18 | import org.onlab.onos.net.Link; |
| 18 | import org.onlab.onos.net.flow.CompletedBatchOperation; | 19 | import org.onlab.onos.net.flow.CompletedBatchOperation; |
| ... | @@ -46,10 +47,14 @@ public class PathIntentInstaller implements IntentInstaller<PathIntent> { | ... | @@ -46,10 +47,14 @@ public class PathIntentInstaller implements IntentInstaller<PathIntent> { |
| 46 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 47 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 47 | protected FlowRuleService flowRuleService; | 48 | protected FlowRuleService flowRuleService; |
| 48 | 49 | ||
| 49 | - private final ApplicationId appId = ApplicationId.getAppId(); | 50 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 51 | + protected CoreService coreService; | ||
| 52 | + | ||
| 53 | + private ApplicationId appId; | ||
| 50 | 54 | ||
| 51 | @Activate | 55 | @Activate |
| 52 | public void activate() { | 56 | public void activate() { |
| 57 | + appId = coreService.registerApplication("org.onlab.onos.net.intent"); | ||
| 53 | intentManager.registerInstaller(PathIntent.class, this); | 58 | intentManager.registerInstaller(PathIntent.class, this); |
| 54 | } | 59 | } |
| 55 | 60 | ... | ... |
| ... | @@ -19,6 +19,7 @@ import org.junit.Before; | ... | @@ -19,6 +19,7 @@ import org.junit.Before; |
| 19 | import org.junit.Test; | 19 | import org.junit.Test; |
| 20 | import org.onlab.onos.ApplicationId; | 20 | import org.onlab.onos.ApplicationId; |
| 21 | import org.onlab.onos.event.impl.TestEventDispatcher; | 21 | import org.onlab.onos.event.impl.TestEventDispatcher; |
| 22 | +import org.onlab.onos.impl.DefaultApplicationId; | ||
| 22 | import org.onlab.onos.net.DefaultDevice; | 23 | import org.onlab.onos.net.DefaultDevice; |
| 23 | import org.onlab.onos.net.Device; | 24 | import org.onlab.onos.net.Device; |
| 24 | import org.onlab.onos.net.Device.Type; | 25 | import org.onlab.onos.net.Device.Type; |
| ... | @@ -59,6 +60,8 @@ import com.google.common.collect.Sets; | ... | @@ -59,6 +60,8 @@ import com.google.common.collect.Sets; |
| 59 | */ | 60 | */ |
| 60 | public class FlowRuleManagerTest { | 61 | public class FlowRuleManagerTest { |
| 61 | 62 | ||
| 63 | + | ||
| 64 | + | ||
| 62 | private static final ProviderId PID = new ProviderId("of", "foo"); | 65 | private static final ProviderId PID = new ProviderId("of", "foo"); |
| 63 | private static final DeviceId DID = DeviceId.deviceId("of:001"); | 66 | private static final DeviceId DID = DeviceId.deviceId("of:001"); |
| 64 | private static final int TIMEOUT = 10; | 67 | private static final int TIMEOUT = 10; |
| ... | @@ -87,7 +90,7 @@ public class FlowRuleManagerTest { | ... | @@ -87,7 +90,7 @@ public class FlowRuleManagerTest { |
| 87 | mgr.addListener(listener); | 90 | mgr.addListener(listener); |
| 88 | provider = new TestProvider(PID); | 91 | provider = new TestProvider(PID); |
| 89 | providerService = registry.register(provider); | 92 | providerService = registry.register(provider); |
| 90 | - appId = ApplicationId.getAppId(); | 93 | + appId = new TestApplicationId((short) 0, "FlowRuleManagerTest"); |
| 91 | assertTrue("provider should be registered", | 94 | assertTrue("provider should be registered", |
| 92 | registry.getProviders().contains(provider.id())); | 95 | registry.getProviders().contains(provider.id())); |
| 93 | } | 96 | } |
| ... | @@ -475,4 +478,11 @@ public class FlowRuleManagerTest { | ... | @@ -475,4 +478,11 @@ public class FlowRuleManagerTest { |
| 475 | 478 | ||
| 476 | } | 479 | } |
| 477 | 480 | ||
| 481 | + public class TestApplicationId extends DefaultApplicationId { | ||
| 482 | + | ||
| 483 | + public TestApplicationId(short id, String name) { | ||
| 484 | + super(id, name); | ||
| 485 | + } | ||
| 486 | + } | ||
| 487 | + | ||
| 478 | } | 488 | } | ... | ... |
| ... | @@ -43,8 +43,8 @@ public class DistributedFlowRuleStore | ... | @@ -43,8 +43,8 @@ public class DistributedFlowRuleStore |
| 43 | private final Multimap<DeviceId, FlowEntry> flowEntries = | 43 | private final Multimap<DeviceId, FlowEntry> flowEntries = |
| 44 | ArrayListMultimap.<DeviceId, FlowEntry>create(); | 44 | ArrayListMultimap.<DeviceId, FlowEntry>create(); |
| 45 | 45 | ||
| 46 | - private final Multimap<ApplicationId, FlowRule> flowEntriesById = | 46 | + private final Multimap<Short, FlowRule> flowEntriesById = |
| 47 | - ArrayListMultimap.<ApplicationId, FlowRule>create(); | 47 | + ArrayListMultimap.<Short, FlowRule>create(); |
| 48 | 48 | ||
| 49 | @Activate | 49 | @Activate |
| 50 | public void activate() { | 50 | public void activate() { |
| ... | @@ -83,7 +83,7 @@ public class DistributedFlowRuleStore | ... | @@ -83,7 +83,7 @@ public class DistributedFlowRuleStore |
| 83 | 83 | ||
| 84 | @Override | 84 | @Override |
| 85 | public synchronized Iterable<FlowRule> getFlowRulesByAppId(ApplicationId appId) { | 85 | public synchronized Iterable<FlowRule> getFlowRulesByAppId(ApplicationId appId) { |
| 86 | - Collection<FlowRule> rules = flowEntriesById.get(appId); | 86 | + Collection<FlowRule> rules = flowEntriesById.get(appId.id()); |
| 87 | if (rules == null) { | 87 | if (rules == null) { |
| 88 | return Collections.emptyList(); | 88 | return Collections.emptyList(); |
| 89 | } | 89 | } | ... | ... |
| ... | @@ -43,8 +43,8 @@ public class DistributedFlowRuleStore | ... | @@ -43,8 +43,8 @@ public class DistributedFlowRuleStore |
| 43 | private final Multimap<DeviceId, FlowEntry> flowEntries = | 43 | private final Multimap<DeviceId, FlowEntry> flowEntries = |
| 44 | ArrayListMultimap.<DeviceId, FlowEntry>create(); | 44 | ArrayListMultimap.<DeviceId, FlowEntry>create(); |
| 45 | 45 | ||
| 46 | - private final Multimap<ApplicationId, FlowRule> flowEntriesById = | 46 | + private final Multimap<Short, FlowRule> flowEntriesById = |
| 47 | - ArrayListMultimap.<ApplicationId, FlowRule>create(); | 47 | + ArrayListMultimap.<Short, FlowRule>create(); |
| 48 | 48 | ||
| 49 | @Activate | 49 | @Activate |
| 50 | public void activate() { | 50 | public void activate() { |
| ... | @@ -83,7 +83,7 @@ public class DistributedFlowRuleStore | ... | @@ -83,7 +83,7 @@ public class DistributedFlowRuleStore |
| 83 | 83 | ||
| 84 | @Override | 84 | @Override |
| 85 | public synchronized Iterable<FlowRule> getFlowRulesByAppId(ApplicationId appId) { | 85 | public synchronized Iterable<FlowRule> getFlowRulesByAppId(ApplicationId appId) { |
| 86 | - Collection<FlowRule> rules = flowEntriesById.get(appId); | 86 | + Collection<FlowRule> rules = flowEntriesById.get(appId.id()); |
| 87 | if (rules == null) { | 87 | if (rules == null) { |
| 88 | return Collections.emptyList(); | 88 | return Collections.emptyList(); |
| 89 | } | 89 | } | ... | ... |
| ... | @@ -42,8 +42,8 @@ public class SimpleFlowRuleStore | ... | @@ -42,8 +42,8 @@ public class SimpleFlowRuleStore |
| 42 | private final Multimap<DeviceId, FlowEntry> flowEntries = | 42 | private final Multimap<DeviceId, FlowEntry> flowEntries = |
| 43 | ArrayListMultimap.<DeviceId, FlowEntry>create(); | 43 | ArrayListMultimap.<DeviceId, FlowEntry>create(); |
| 44 | 44 | ||
| 45 | - private final Multimap<ApplicationId, FlowRule> flowEntriesById = | 45 | + private final Multimap<Short, FlowRule> flowEntriesById = |
| 46 | - ArrayListMultimap.<ApplicationId, FlowRule>create(); | 46 | + ArrayListMultimap.<Short, FlowRule>create(); |
| 47 | 47 | ||
| 48 | @Activate | 48 | @Activate |
| 49 | public void activate() { | 49 | public void activate() { |
| ... | @@ -82,7 +82,7 @@ public class SimpleFlowRuleStore | ... | @@ -82,7 +82,7 @@ public class SimpleFlowRuleStore |
| 82 | 82 | ||
| 83 | @Override | 83 | @Override |
| 84 | public synchronized Iterable<FlowRule> getFlowRulesByAppId(ApplicationId appId) { | 84 | public synchronized Iterable<FlowRule> getFlowRulesByAppId(ApplicationId appId) { |
| 85 | - Collection<FlowRule> rules = flowEntriesById.get(appId); | 85 | + Collection<FlowRule> rules = flowEntriesById.get(appId.id()); |
| 86 | if (rules == null) { | 86 | if (rules == null) { |
| 87 | return Collections.emptyList(); | 87 | return Collections.emptyList(); |
| 88 | } | 88 | } | ... | ... |
-
Please register or login to post a comment