Merge branch 'master' of ssh://gerrit.onlab.us:29418/onos-next
Showing
10 changed files
with
213 additions
and
10 deletions
... | @@ -28,6 +28,11 @@ | ... | @@ -28,6 +28,11 @@ |
28 | <version>${project.version}</version> | 28 | <version>${project.version}</version> |
29 | </dependency> | 29 | </dependency> |
30 | <dependency> | 30 | <dependency> |
31 | + <groupId>org.onlab.onos</groupId> | ||
32 | + <artifactId>onlab-netty</artifactId> | ||
33 | + <version>${project.version}</version> | ||
34 | + </dependency> | ||
35 | + <dependency> | ||
31 | <groupId>org.apache.karaf.shell</groupId> | 36 | <groupId>org.apache.karaf.shell</groupId> |
32 | <artifactId>org.apache.karaf.shell.console</artifactId> | 37 | <artifactId>org.apache.karaf.shell.console</artifactId> |
33 | </dependency> | 38 | </dependency> | ... | ... |
1 | +package org.onlab.onos.foo; | ||
2 | + | ||
3 | +import java.io.IOException; | ||
4 | +import java.util.concurrent.ExecutionException; | ||
5 | +import java.util.concurrent.TimeUnit; | ||
6 | +import java.util.concurrent.TimeoutException; | ||
7 | + | ||
8 | +import org.onlab.metrics.MetricsComponent; | ||
9 | +import org.onlab.metrics.MetricsFeature; | ||
10 | +import org.onlab.metrics.MetricsManager; | ||
11 | +import org.onlab.netty.Endpoint; | ||
12 | +import org.onlab.netty.NettyMessagingService; | ||
13 | +import org.onlab.netty.Response; | ||
14 | + | ||
15 | +import com.codahale.metrics.Timer; | ||
16 | + | ||
17 | +// FIXME: Should be move out to test or app | ||
18 | +public final class SimpleNettyClient { | ||
19 | + private SimpleNettyClient() { | ||
20 | + } | ||
21 | + | ||
22 | + public static void main(String[] args) | ||
23 | + throws IOException, InterruptedException, ExecutionException, | ||
24 | + TimeoutException { | ||
25 | + try { | ||
26 | + startStandalone(args); | ||
27 | + } catch (Exception e) { | ||
28 | + e.printStackTrace(); | ||
29 | + } | ||
30 | + | ||
31 | + System.exit(0); | ||
32 | + } | ||
33 | + public static void startStandalone(String... args) throws Exception { | ||
34 | + NettyMessagingService messaging = new TestNettyMessagingService(9081); | ||
35 | + MetricsManager metrics = new MetricsManager(); | ||
36 | + messaging.activate(); | ||
37 | + metrics.activate(); | ||
38 | + MetricsFeature feature = new MetricsFeature("timers"); | ||
39 | + MetricsComponent component = metrics.registerComponent("NettyMessaging"); | ||
40 | + Timer sendAsyncTimer = metrics.createTimer(component, feature, "AsyncSender"); | ||
41 | + final int warmup = 100; | ||
42 | + for (int i = 0; i < warmup; i++) { | ||
43 | + Timer.Context context = sendAsyncTimer.time(); | ||
44 | + messaging.sendAsync(new Endpoint("localhost", 8080), "simple", "Hello World".getBytes()); | ||
45 | + context.stop(); | ||
46 | + } | ||
47 | + metrics.registerMetric(component, feature, "AsyncTimer", sendAsyncTimer); | ||
48 | + | ||
49 | + Timer sendAndReceiveTimer = metrics.createTimer(component, feature, "SendAndReceive"); | ||
50 | + final int iterations = 1000000; | ||
51 | + for (int i = 0; i < iterations; i++) { | ||
52 | + Timer.Context context = sendAndReceiveTimer.time(); | ||
53 | + Response response = messaging | ||
54 | + .sendAndReceive(new Endpoint("localhost", 8080), "echo", | ||
55 | + "Hello World".getBytes()); | ||
56 | + System.out.println("Got back:" + new String(response.get(2, TimeUnit.SECONDS))); | ||
57 | + context.stop(); | ||
58 | + } | ||
59 | + metrics.registerMetric(component, feature, "AsyncTimer", sendAndReceiveTimer); | ||
60 | + } | ||
61 | + | ||
62 | + public static class TestNettyMessagingService extends NettyMessagingService { | ||
63 | + public TestNettyMessagingService(int port) throws Exception { | ||
64 | + super(port); | ||
65 | + } | ||
66 | + } | ||
67 | +} |
1 | +package org.onlab.onos.foo; | ||
2 | + | ||
3 | +import static org.onlab.onos.foo.SimpleNettyClient.startStandalone; | ||
4 | + | ||
5 | +import org.apache.karaf.shell.commands.Argument; | ||
6 | +import org.apache.karaf.shell.commands.Command; | ||
7 | +import org.onlab.onos.cli.AbstractShellCommand; | ||
8 | + | ||
9 | +/** | ||
10 | + * Test Netty client performance. | ||
11 | + */ | ||
12 | +@Command(scope = "onos", name = "simple-netty-client", | ||
13 | + description = "Starts the simple Netty client") | ||
14 | +public class SimpleNettyClientCommand extends AbstractShellCommand { | ||
15 | + | ||
16 | + @Argument(index = 0, name = "serverIp", description = "Server IP address", | ||
17 | + required = false, multiValued = false) | ||
18 | + String serverIp = "127.0.0.1"; | ||
19 | + | ||
20 | + @Argument(index = 1, name = "workers", description = "IO workers", | ||
21 | + required = false, multiValued = false) | ||
22 | + String workers = "6"; | ||
23 | + | ||
24 | + @Argument(index = 2, name = "messageCount", description = "Message count", | ||
25 | + required = false, multiValued = false) | ||
26 | + String messageCount = "1000000"; | ||
27 | + | ||
28 | + @Argument(index = 3, name = "messageLength", description = "Message length (bytes)", | ||
29 | + required = false, multiValued = false) | ||
30 | + String messageLength = "128"; | ||
31 | + | ||
32 | + @Argument(index = 4, name = "timeoutSecs", description = "Test timeout (seconds)", | ||
33 | + required = false, multiValued = false) | ||
34 | + String timeoutSecs = "60"; | ||
35 | + | ||
36 | + @Override | ||
37 | + protected void execute() { | ||
38 | + try { | ||
39 | + startStandalone(new String[]{serverIp, workers, messageCount, messageLength, timeoutSecs}); | ||
40 | + } catch (Exception e) { | ||
41 | + error("Unable to start client %s", e); | ||
42 | + } | ||
43 | + } | ||
44 | + | ||
45 | +} |
1 | +package org.onlab.onos.foo; | ||
2 | + | ||
3 | +import org.onlab.netty.EchoHandler; | ||
4 | +import org.onlab.netty.NettyMessagingService; | ||
5 | +import org.slf4j.Logger; | ||
6 | +import org.slf4j.LoggerFactory; | ||
7 | + | ||
8 | +/** | ||
9 | + * Test to measure Messaging performance. | ||
10 | + */ | ||
11 | + public final class SimpleNettyServer { | ||
12 | + private static Logger log = LoggerFactory.getLogger(IOLoopTestServer.class); | ||
13 | + | ||
14 | + private SimpleNettyServer() {} | ||
15 | + | ||
16 | + public static void main(String... args) throws Exception { | ||
17 | + startStandalone(args); | ||
18 | + System.exit(0); | ||
19 | + } | ||
20 | + | ||
21 | + public static void startStandalone(String[] args) throws Exception { | ||
22 | + NettyMessagingService server = new NettyMessagingService(8080); | ||
23 | + server.activate(); | ||
24 | + server.registerHandler("simple", new org.onlab.netty.LoggingHandler()); | ||
25 | + server.registerHandler("echo", new EchoHandler()); | ||
26 | + } | ||
27 | + } | ||
28 | + |
1 | +package org.onlab.onos.foo; | ||
2 | + | ||
3 | +import static org.onlab.onos.foo.SimpleNettyServer.startStandalone; | ||
4 | + | ||
5 | +import org.apache.karaf.shell.commands.Argument; | ||
6 | +import org.apache.karaf.shell.commands.Command; | ||
7 | +import org.onlab.onos.cli.AbstractShellCommand; | ||
8 | + | ||
9 | +/** | ||
10 | + * Starts the Simple Netty server. | ||
11 | + */ | ||
12 | +@Command(scope = "onos", name = "test-netty-server", | ||
13 | + description = "Starts the simple netty server") | ||
14 | +public class SimpleNettyServerCommand extends AbstractShellCommand { | ||
15 | + | ||
16 | + @Argument(index = 0, name = "serverIp", description = "Server IP address", | ||
17 | + required = false, multiValued = false) | ||
18 | + String serverIp = "127.0.0.1"; | ||
19 | + | ||
20 | + @Argument(index = 1, name = "workers", description = "IO workers", | ||
21 | + required = false, multiValued = false) | ||
22 | + String workers = "6"; | ||
23 | + | ||
24 | + @Argument(index = 2, name = "messageLength", description = "Message length (bytes)", | ||
25 | + required = false, multiValued = false) | ||
26 | + String messageLength = "128"; | ||
27 | + | ||
28 | + @Override | ||
29 | + protected void execute() { | ||
30 | + try { | ||
31 | + startStandalone(new String[]{serverIp, workers, messageLength}); | ||
32 | + } catch (Exception e) { | ||
33 | + error("Unable to start server %s", e); | ||
34 | + } | ||
35 | + } | ||
36 | + | ||
37 | +} |
... | @@ -13,6 +13,7 @@ import java.util.Collections; | ... | @@ -13,6 +13,7 @@ import java.util.Collections; |
13 | import java.util.List; | 13 | import java.util.List; |
14 | import java.util.Set; | 14 | import java.util.Set; |
15 | 15 | ||
16 | +import org.junit.Ignore; | ||
16 | import org.junit.Test; | 17 | import org.junit.Test; |
17 | import org.onlab.onos.net.ConnectPoint; | 18 | import org.onlab.onos.net.ConnectPoint; |
18 | import org.onlab.onos.net.Device; | 19 | import org.onlab.onos.net.Device; |
... | @@ -52,6 +53,7 @@ public class HostMonitorTest { | ... | @@ -52,6 +53,7 @@ public class HostMonitorTest { |
52 | private HostMonitor hostMonitor; | 53 | private HostMonitor hostMonitor; |
53 | 54 | ||
54 | @Test | 55 | @Test |
56 | + @Ignore | ||
55 | public void testMonitorHostExists() throws Exception { | 57 | public void testMonitorHostExists() throws Exception { |
56 | ProviderId id = new ProviderId("fake://", "id"); | 58 | ProviderId id = new ProviderId("fake://", "id"); |
57 | 59 | ||
... | @@ -81,6 +83,7 @@ public class HostMonitorTest { | ... | @@ -81,6 +83,7 @@ public class HostMonitorTest { |
81 | } | 83 | } |
82 | 84 | ||
83 | @Test | 85 | @Test |
86 | + @Ignore | ||
84 | public void testMonitorHostDoesNotExist() throws Exception { | 87 | public void testMonitorHostDoesNotExist() throws Exception { |
85 | HostManager hostManager = createMock(HostManager.class); | 88 | HostManager hostManager = createMock(HostManager.class); |
86 | 89 | ... | ... |
... | @@ -7,11 +7,9 @@ import com.google.common.cache.RemovalNotification; | ... | @@ -7,11 +7,9 @@ import com.google.common.cache.RemovalNotification; |
7 | import com.google.common.collect.ImmutableSet; | 7 | import com.google.common.collect.ImmutableSet; |
8 | 8 | ||
9 | import org.apache.felix.scr.annotations.Activate; | 9 | import org.apache.felix.scr.annotations.Activate; |
10 | -import org.apache.felix.scr.annotations.Component; | ||
11 | import org.apache.felix.scr.annotations.Deactivate; | 10 | import org.apache.felix.scr.annotations.Deactivate; |
12 | import org.apache.felix.scr.annotations.Reference; | 11 | import org.apache.felix.scr.annotations.Reference; |
13 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 12 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
14 | -import org.apache.felix.scr.annotations.Service; | ||
15 | import org.onlab.onos.cluster.ClusterEvent; | 13 | import org.onlab.onos.cluster.ClusterEvent; |
16 | import org.onlab.onos.cluster.ClusterStore; | 14 | import org.onlab.onos.cluster.ClusterStore; |
17 | import org.onlab.onos.cluster.ClusterStoreDelegate; | 15 | import org.onlab.onos.cluster.ClusterStoreDelegate; |
... | @@ -37,8 +35,8 @@ import static org.onlab.packet.IpPrefix.valueOf; | ... | @@ -37,8 +35,8 @@ import static org.onlab.packet.IpPrefix.valueOf; |
37 | /** | 35 | /** |
38 | * Distributed implementation of the cluster nodes store. | 36 | * Distributed implementation of the cluster nodes store. |
39 | */ | 37 | */ |
40 | -@Component(immediate = true) | 38 | +//@Component(immediate = true) |
41 | -@Service | 39 | +//@Service |
42 | public class DistributedClusterStore | 40 | public class DistributedClusterStore |
43 | extends AbstractStore<ClusterEvent, ClusterStoreDelegate> | 41 | extends AbstractStore<ClusterEvent, ClusterStoreDelegate> |
44 | implements ClusterStore { | 42 | implements ClusterStore { | ... | ... |
... | @@ -12,7 +12,10 @@ import java.util.TimerTask; | ... | @@ -12,7 +12,10 @@ import java.util.TimerTask; |
12 | import org.apache.felix.scr.annotations.Activate; | 12 | import org.apache.felix.scr.annotations.Activate; |
13 | import org.apache.felix.scr.annotations.Component; | 13 | import org.apache.felix.scr.annotations.Component; |
14 | import org.apache.felix.scr.annotations.Deactivate; | 14 | import org.apache.felix.scr.annotations.Deactivate; |
15 | +import org.apache.felix.scr.annotations.Reference; | ||
16 | +import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
15 | import org.apache.felix.scr.annotations.Service; | 17 | import org.apache.felix.scr.annotations.Service; |
18 | +import org.onlab.onos.cluster.ClusterService; | ||
16 | import org.onlab.onos.cluster.ControllerNode; | 19 | import org.onlab.onos.cluster.ControllerNode; |
17 | import org.onlab.onos.cluster.NodeId; | 20 | import org.onlab.onos.cluster.NodeId; |
18 | import org.onlab.onos.store.cluster.impl.ClusterMembershipEvent; | 21 | import org.onlab.onos.store.cluster.impl.ClusterMembershipEvent; |
... | @@ -30,6 +33,7 @@ import org.onlab.netty.Endpoint; | ... | @@ -30,6 +33,7 @@ import org.onlab.netty.Endpoint; |
30 | import org.onlab.netty.Message; | 33 | import org.onlab.netty.Message; |
31 | import org.onlab.netty.MessageHandler; | 34 | import org.onlab.netty.MessageHandler; |
32 | import org.onlab.netty.MessagingService; | 35 | import org.onlab.netty.MessagingService; |
36 | +import org.onlab.netty.NettyMessagingService; | ||
33 | import org.slf4j.Logger; | 37 | import org.slf4j.Logger; |
34 | import org.slf4j.LoggerFactory; | 38 | import org.slf4j.LoggerFactory; |
35 | 39 | ||
... | @@ -41,6 +45,10 @@ public class ClusterCommunicationManager | ... | @@ -41,6 +45,10 @@ public class ClusterCommunicationManager |
41 | private final Logger log = LoggerFactory.getLogger(getClass()); | 45 | private final Logger log = LoggerFactory.getLogger(getClass()); |
42 | 46 | ||
43 | private ControllerNode localNode; | 47 | private ControllerNode localNode; |
48 | + | ||
49 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
50 | + private ClusterService clusterService; | ||
51 | + | ||
44 | private ClusterNodesDelegate nodesDelegate; | 52 | private ClusterNodesDelegate nodesDelegate; |
45 | // FIXME: `members` should go away and should be using ClusterService | 53 | // FIXME: `members` should go away and should be using ClusterService |
46 | private Map<NodeId, ControllerNode> members = new HashMap<>(); | 54 | private Map<NodeId, ControllerNode> members = new HashMap<>(); |
... | @@ -48,7 +56,6 @@ public class ClusterCommunicationManager | ... | @@ -48,7 +56,6 @@ public class ClusterCommunicationManager |
48 | public static final long HEART_BEAT_INTERVAL_MILLIS = 1000L; | 56 | public static final long HEART_BEAT_INTERVAL_MILLIS = 1000L; |
49 | 57 | ||
50 | // TODO: This probably should not be a OSGi service. | 58 | // TODO: This probably should not be a OSGi service. |
51 | - //@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
52 | private MessagingService messagingService; | 59 | private MessagingService messagingService; |
53 | 60 | ||
54 | private static final KryoSerializer SERIALIZER = new KryoSerializer() { | 61 | private static final KryoSerializer SERIALIZER = new KryoSerializer() { |
... | @@ -65,11 +72,8 @@ public class ClusterCommunicationManager | ... | @@ -65,11 +72,8 @@ public class ClusterCommunicationManager |
65 | 72 | ||
66 | @Activate | 73 | @Activate |
67 | public void activate() { | 74 | public void activate() { |
68 | - // TODO: initialize messagingService | 75 | + localNode = clusterService.getLocalNode(); |
69 | - // TODO: setPayloadSerializer, which is capable of | 76 | + messagingService = new NettyMessagingService(localNode.tcpPort()); |
70 | - // (1) serialize ClusterMessage - ClusterMessage.payload | ||
71 | - // (2) serialize ClusterMessage.payload using user specified serializer | ||
72 | -// messagingService.setPayloadSerializer(...); | ||
73 | log.info("Started"); | 77 | log.info("Started"); |
74 | } | 78 | } |
75 | 79 | ... | ... |
... | @@ -9,6 +9,12 @@ | ... | @@ -9,6 +9,12 @@ |
9 | <bundle>mvn:org.apache.commons/commons-lang3/3.3.2</bundle> | 9 | <bundle>mvn:org.apache.commons/commons-lang3/3.3.2</bundle> |
10 | <bundle>mvn:com.google.guava/guava/18.0</bundle> | 10 | <bundle>mvn:com.google.guava/guava/18.0</bundle> |
11 | <bundle>mvn:io.netty/netty/3.9.2.Final</bundle> | 11 | <bundle>mvn:io.netty/netty/3.9.2.Final</bundle> |
12 | + <bundle>mvn:io.netty/netty-common/4.0.23.Final</bundle> | ||
13 | + <bundle>mvn:io.netty/netty-buffer/4.0.23.Final</bundle> | ||
14 | + <bundle>mvn:io.netty/netty-transport/4.0.23.Final</bundle> | ||
15 | + <bundle>mvn:io.netty/netty-handler/4.0.23.Final</bundle> | ||
16 | + <bundle>mvn:io.netty/netty-codec/4.0.23.Final</bundle> | ||
17 | + <bundle>mvn:commons-pool/commons-pool/1.6</bundle> | ||
12 | 18 | ||
13 | <bundle>mvn:com.hazelcast/hazelcast/3.3</bundle> | 19 | <bundle>mvn:com.hazelcast/hazelcast/3.3</bundle> |
14 | <bundle>mvn:io.dropwizard.metrics/metrics-core/3.1.0</bundle> | 20 | <bundle>mvn:io.dropwizard.metrics/metrics-core/3.1.0</bundle> |
... | @@ -55,6 +61,9 @@ | ... | @@ -55,6 +61,9 @@ |
55 | <bundle>mvn:org.onlab.onos/onos-core-dist/1.0.0-SNAPSHOT</bundle> | 61 | <bundle>mvn:org.onlab.onos/onos-core-dist/1.0.0-SNAPSHOT</bundle> |
56 | <bundle>mvn:org.onlab.onos/onos-core-serializers/1.0.0-SNAPSHOT</bundle> | 62 | <bundle>mvn:org.onlab.onos/onos-core-serializers/1.0.0-SNAPSHOT</bundle> |
57 | <bundle>mvn:org.onlab.onos/onlab-netty/1.0.0-SNAPSHOT</bundle> | 63 | <bundle>mvn:org.onlab.onos/onlab-netty/1.0.0-SNAPSHOT</bundle> |
64 | + | ||
65 | + <bundle>mvn:org.onlab.onos/onos-core-hz-common/1.0.0-SNAPSHOT</bundle> | ||
66 | + <bundle>mvn:org.onlab.onos/onos-core-hz-cluster/1.0.0-SNAPSHOT</bundle> | ||
58 | </feature> | 67 | </feature> |
59 | 68 | ||
60 | <feature name="onos-core-hazelcast" version="1.0.0" | 69 | <feature name="onos-core-hazelcast" version="1.0.0" | ... | ... |
... | @@ -69,6 +69,13 @@ | ... | @@ -69,6 +69,13 @@ |
69 | 69 | ||
70 | <dependency> | 70 | <dependency> |
71 | <groupId>org.slf4j</groupId> | 71 | <groupId>org.slf4j</groupId> |
72 | + <artifactId>slf4j-core</artifactId> | ||
73 | + <version>1.7.6</version> | ||
74 | + <scope>test</scope> | ||
75 | + </dependency> | ||
76 | + | ||
77 | + <dependency> | ||
78 | + <groupId>org.slf4j</groupId> | ||
72 | <artifactId>slf4j-jdk14</artifactId> | 79 | <artifactId>slf4j-jdk14</artifactId> |
73 | <version>1.7.6</version> | 80 | <version>1.7.6</version> |
74 | <scope>test</scope> | 81 | <scope>test</scope> | ... | ... |
-
Please register or login to post a comment