Showing
6 changed files
with
152 additions
and
24 deletions
| ... | @@ -30,6 +30,10 @@ public final class SimpleNettyClient { | ... | @@ -30,6 +30,10 @@ public final class SimpleNettyClient { |
| 30 | System.exit(0); | 30 | System.exit(0); |
| 31 | } | 31 | } |
| 32 | public static void startStandalone(String... args) throws Exception { | 32 | public static void startStandalone(String... args) throws Exception { |
| 33 | + String host = args.length > 0 ? args[0] : "localhost"; | ||
| 34 | + int port = args.length > 1 ? Integer.parseInt(args[1]) : 8081; | ||
| 35 | + int warmup = args.length > 2 ? Integer.parseInt(args[2]) : 1000; | ||
| 36 | + int iterations = args.length > 3 ? Integer.parseInt(args[3]) : 50 * 100000; | ||
| 33 | NettyMessagingService messaging = new TestNettyMessagingService(9081); | 37 | NettyMessagingService messaging = new TestNettyMessagingService(9081); |
| 34 | MetricsManager metrics = new MetricsManager(); | 38 | MetricsManager metrics = new MetricsManager(); |
| 35 | messaging.activate(); | 39 | messaging.activate(); |
| ... | @@ -37,28 +41,26 @@ public final class SimpleNettyClient { | ... | @@ -37,28 +41,26 @@ public final class SimpleNettyClient { |
| 37 | MetricsFeature feature = new MetricsFeature("latency"); | 41 | MetricsFeature feature = new MetricsFeature("latency"); |
| 38 | MetricsComponent component = metrics.registerComponent("NettyMessaging"); | 42 | MetricsComponent component = metrics.registerComponent("NettyMessaging"); |
| 39 | 43 | ||
| 40 | - final int warmup = 10000; | ||
| 41 | for (int i = 0; i < warmup; i++) { | 44 | for (int i = 0; i < warmup; i++) { |
| 42 | - messaging.sendAsync(new Endpoint("localhost", 8081), "simple", "Hello World".getBytes()); | 45 | + messaging.sendAsync(new Endpoint(host, port), "simple", "Hello World".getBytes()); |
| 43 | Response response = messaging | 46 | Response response = messaging |
| 44 | - .sendAndReceive(new Endpoint("localhost", 8081), "echo", | 47 | + .sendAndReceive(new Endpoint(host, port), "echo", |
| 45 | "Hello World".getBytes()); | 48 | "Hello World".getBytes()); |
| 46 | } | 49 | } |
| 47 | 50 | ||
| 48 | Timer sendAsyncTimer = metrics.createTimer(component, feature, "AsyncSender"); | 51 | Timer sendAsyncTimer = metrics.createTimer(component, feature, "AsyncSender"); |
| 49 | - Timer sendAndReceiveTimer = metrics.createTimer(component, feature, "SendAndReceive"); | ||
| 50 | 52 | ||
| 51 | - final int iterations = 10000000; | ||
| 52 | for (int i = 0; i < iterations; i++) { | 53 | for (int i = 0; i < iterations; i++) { |
| 53 | Timer.Context context = sendAsyncTimer.time(); | 54 | Timer.Context context = sendAsyncTimer.time(); |
| 54 | - messaging.sendAsync(new Endpoint("localhost", 8081), "simple", "Hello World".getBytes()); | 55 | + messaging.sendAsync(new Endpoint(host, port), "simple", "Hello World".getBytes()); |
| 55 | context.stop(); | 56 | context.stop(); |
| 56 | } | 57 | } |
| 57 | 58 | ||
| 59 | + Timer sendAndReceiveTimer = metrics.createTimer(component, feature, "SendAndReceive"); | ||
| 58 | for (int i = 0; i < iterations; i++) { | 60 | for (int i = 0; i < iterations; i++) { |
| 59 | Timer.Context context = sendAndReceiveTimer.time(); | 61 | Timer.Context context = sendAndReceiveTimer.time(); |
| 60 | Response response = messaging | 62 | Response response = messaging |
| 61 | - .sendAndReceive(new Endpoint("localhost", 8081), "echo", | 63 | + .sendAndReceive(new Endpoint(host, port), "echo", |
| 62 | "Hello World".getBytes()); | 64 | "Hello World".getBytes()); |
| 63 | // System.out.println("Got back:" + new String(response.get(2, TimeUnit.SECONDS))); | 65 | // System.out.println("Got back:" + new String(response.get(2, TimeUnit.SECONDS))); |
| 64 | context.stop(); | 66 | context.stop(); | ... | ... |
| ... | @@ -14,30 +14,26 @@ import org.onlab.onos.cli.AbstractShellCommand; | ... | @@ -14,30 +14,26 @@ import org.onlab.onos.cli.AbstractShellCommand; |
| 14 | public class SimpleNettyClientCommand extends AbstractShellCommand { | 14 | public class SimpleNettyClientCommand extends AbstractShellCommand { |
| 15 | 15 | ||
| 16 | //FIXME: replace these arguments with proper ones needed for the test. | 16 | //FIXME: replace these arguments with proper ones needed for the test. |
| 17 | - @Argument(index = 0, name = "serverIp", description = "Server IP address", | 17 | + @Argument(index = 0, name = "hostname", description = "Server Hostname", |
| 18 | required = false, multiValued = false) | 18 | required = false, multiValued = false) |
| 19 | - String serverIp = "127.0.0.1"; | 19 | + String host = "localhost"; |
| 20 | 20 | ||
| 21 | - @Argument(index = 1, name = "workers", description = "IO workers", | 21 | + @Argument(index = 3, name = "port", description = "Port", |
| 22 | required = false, multiValued = false) | 22 | required = false, multiValued = false) |
| 23 | - String workers = "6"; | 23 | + String port = "8081"; |
| 24 | 24 | ||
| 25 | - @Argument(index = 2, name = "messageCount", description = "Message count", | 25 | + @Argument(index = 1, name = "warmupCount", description = "Warm-up count", |
| 26 | - required = false, multiValued = false) | ||
| 27 | - String messageCount = "1000000"; | ||
| 28 | - | ||
| 29 | - @Argument(index = 3, name = "messageLength", description = "Message length (bytes)", | ||
| 30 | required = false, multiValued = false) | 26 | required = false, multiValued = false) |
| 31 | - String messageLength = "128"; | 27 | + String warmup = "10000"; |
| 32 | 28 | ||
| 33 | - @Argument(index = 4, name = "timeoutSecs", description = "Test timeout (seconds)", | 29 | + @Argument(index = 2, name = "messageCount", description = "Message count", |
| 34 | required = false, multiValued = false) | 30 | required = false, multiValued = false) |
| 35 | - String timeoutSecs = "60"; | 31 | + String messageCount = "5000000"; |
| 36 | 32 | ||
| 37 | @Override | 33 | @Override |
| 38 | protected void execute() { | 34 | protected void execute() { |
| 39 | try { | 35 | try { |
| 40 | - startStandalone(new String[]{serverIp, workers, messageCount, messageLength, timeoutSecs}); | 36 | + startStandalone(new String[]{host, port, warmup, messageCount}); |
| 41 | } catch (Exception e) { | 37 | } catch (Exception e) { |
| 42 | error("Unable to start client %s", e); | 38 | error("Unable to start client %s", e); |
| 43 | } | 39 | } | ... | ... |
| ... | @@ -42,6 +42,7 @@ import org.onlab.onos.store.common.impl.MastershipBasedTimestamp; | ... | @@ -42,6 +42,7 @@ import org.onlab.onos.store.common.impl.MastershipBasedTimestamp; |
| 42 | import org.onlab.onos.store.common.impl.Timestamped; | 42 | import org.onlab.onos.store.common.impl.Timestamped; |
| 43 | import org.onlab.onos.store.serializers.KryoPoolUtil; | 43 | import org.onlab.onos.store.serializers.KryoPoolUtil; |
| 44 | import org.onlab.onos.store.serializers.KryoSerializer; | 44 | import org.onlab.onos.store.serializers.KryoSerializer; |
| 45 | +import org.onlab.onos.store.serializers.MastershipBasedTimestampSerializer; | ||
| 45 | import org.onlab.util.KryoPool; | 46 | import org.onlab.util.KryoPool; |
| 46 | import org.onlab.util.NewConcurrentHashMap; | 47 | import org.onlab.util.NewConcurrentHashMap; |
| 47 | import org.slf4j.Logger; | 48 | import org.slf4j.Logger; |
| ... | @@ -117,11 +118,11 @@ public class GossipDeviceStore | ... | @@ -117,11 +118,11 @@ public class GossipDeviceStore |
| 117 | protected void setupKryoPool() { | 118 | protected void setupKryoPool() { |
| 118 | serializerPool = KryoPool.newBuilder() | 119 | serializerPool = KryoPool.newBuilder() |
| 119 | .register(KryoPoolUtil.API) | 120 | .register(KryoPoolUtil.API) |
| 120 | - .register(InternalDeviceEvent.class) | 121 | + .register(InternalDeviceEvent.class, new InternalDeviceEventSerializer()) |
| 121 | - .register(InternalPortEvent.class) | 122 | + .register(InternalPortEvent.class, new InternalPortEventSerializer()) |
| 122 | - .register(InternalPortStatusEvent.class) | 123 | + .register(InternalPortStatusEvent.class, new InternalPortStatusEventSerializer()) |
| 123 | .register(Timestamped.class) | 124 | .register(Timestamped.class) |
| 124 | - .register(MastershipBasedTimestamp.class) | 125 | + .register(MastershipBasedTimestamp.class, new MastershipBasedTimestampSerializer()) |
| 125 | .build() | 126 | .build() |
| 126 | .populate(1); | 127 | .populate(1); |
| 127 | } | 128 | } | ... | ... |
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceEventSerializer.java
0 → 100644
| 1 | +package org.onlab.onos.store.device.impl; | ||
| 2 | + | ||
| 3 | +import org.onlab.onos.net.DeviceId; | ||
| 4 | +import org.onlab.onos.net.device.DeviceDescription; | ||
| 5 | +import org.onlab.onos.net.provider.ProviderId; | ||
| 6 | +import org.onlab.onos.store.common.impl.Timestamped; | ||
| 7 | + | ||
| 8 | +import com.esotericsoftware.kryo.Kryo; | ||
| 9 | +import com.esotericsoftware.kryo.Serializer; | ||
| 10 | +import com.esotericsoftware.kryo.io.Input; | ||
| 11 | +import com.esotericsoftware.kryo.io.Output; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * Kryo Serializer for {@link InternalDeviceEvent}. | ||
| 15 | + */ | ||
| 16 | +public class InternalDeviceEventSerializer extends Serializer<InternalDeviceEvent> { | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * Creates a serializer for {@link InternalDeviceEvent}. | ||
| 20 | + */ | ||
| 21 | + public InternalDeviceEventSerializer() { | ||
| 22 | + // does not accept null | ||
| 23 | + super(false); | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + @Override | ||
| 27 | + public void write(Kryo kryo, Output output, InternalDeviceEvent event) { | ||
| 28 | + kryo.writeClassAndObject(output, event.providerId()); | ||
| 29 | + kryo.writeClassAndObject(output, event.deviceId()); | ||
| 30 | + kryo.writeClassAndObject(output, event.deviceDescription()); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + @Override | ||
| 34 | + public InternalDeviceEvent read(Kryo kryo, Input input, | ||
| 35 | + Class<InternalDeviceEvent> type) { | ||
| 36 | + ProviderId providerId = (ProviderId) kryo.readClassAndObject(input); | ||
| 37 | + DeviceId deviceId = (DeviceId) kryo.readClassAndObject(input); | ||
| 38 | + Timestamped<DeviceDescription> deviceDescription = (Timestamped<DeviceDescription>) kryo.readClassAndObject(input); | ||
| 39 | + | ||
| 40 | + return new InternalDeviceEvent(providerId, deviceId, deviceDescription); | ||
| 41 | + } | ||
| 42 | +} |
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalPortEventSerializer.java
0 → 100644
| 1 | +package org.onlab.onos.store.device.impl; | ||
| 2 | + | ||
| 3 | +import java.util.List; | ||
| 4 | + | ||
| 5 | +import org.onlab.onos.net.DeviceId; | ||
| 6 | +import org.onlab.onos.net.device.DeviceDescription; | ||
| 7 | +import org.onlab.onos.net.device.PortDescription; | ||
| 8 | +import org.onlab.onos.net.provider.ProviderId; | ||
| 9 | +import org.onlab.onos.store.common.impl.Timestamped; | ||
| 10 | + | ||
| 11 | +import com.esotericsoftware.kryo.Kryo; | ||
| 12 | +import com.esotericsoftware.kryo.Serializer; | ||
| 13 | +import com.esotericsoftware.kryo.io.Input; | ||
| 14 | +import com.esotericsoftware.kryo.io.Output; | ||
| 15 | + | ||
| 16 | +/** | ||
| 17 | + * Kryo Serializer for {@link InternalPortEvent}. | ||
| 18 | + */ | ||
| 19 | +public class InternalPortEventSerializer extends Serializer<InternalPortEvent> { | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * Creates a serializer for {@link InternalPortEvent}. | ||
| 23 | + */ | ||
| 24 | + public InternalPortEventSerializer() { | ||
| 25 | + // does not accept null | ||
| 26 | + super(false); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + @Override | ||
| 30 | + public void write(Kryo kryo, Output output, InternalPortEvent event) { | ||
| 31 | + kryo.writeClassAndObject(output, event.providerId()); | ||
| 32 | + kryo.writeClassAndObject(output, event.deviceId()); | ||
| 33 | + kryo.writeClassAndObject(output, event.portDescriptions()); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + @Override | ||
| 37 | + public InternalPortEvent read(Kryo kryo, Input input, | ||
| 38 | + Class<InternalPortEvent> type) { | ||
| 39 | + ProviderId providerId = (ProviderId) kryo.readClassAndObject(input); | ||
| 40 | + DeviceId deviceId = (DeviceId) kryo.readClassAndObject(input); | ||
| 41 | + Timestamped<List<PortDescription>> portDescriptions = (Timestamped<List<PortDescription>>) kryo.readClassAndObject(input); | ||
| 42 | + | ||
| 43 | + return new InternalPortEvent(providerId, deviceId, portDescriptions); | ||
| 44 | + } | ||
| 45 | +} |
| 1 | +package org.onlab.onos.store.device.impl; | ||
| 2 | + | ||
| 3 | +import org.onlab.onos.net.DeviceId; | ||
| 4 | +import org.onlab.onos.net.device.PortDescription; | ||
| 5 | +import org.onlab.onos.net.provider.ProviderId; | ||
| 6 | +import org.onlab.onos.store.common.impl.Timestamped; | ||
| 7 | + | ||
| 8 | +import com.esotericsoftware.kryo.Kryo; | ||
| 9 | +import com.esotericsoftware.kryo.Serializer; | ||
| 10 | +import com.esotericsoftware.kryo.io.Input; | ||
| 11 | +import com.esotericsoftware.kryo.io.Output; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * Kryo Serializer for {@link InternalPortStatusEvent}. | ||
| 15 | + */ | ||
| 16 | +public class InternalPortStatusEventSerializer extends Serializer<InternalPortStatusEvent> { | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * Creates a serializer for {@link InternalPortStatusEvent}. | ||
| 20 | + */ | ||
| 21 | + public InternalPortStatusEventSerializer() { | ||
| 22 | + // does not accept null | ||
| 23 | + super(false); | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + @Override | ||
| 27 | + public void write(Kryo kryo, Output output, InternalPortStatusEvent event) { | ||
| 28 | + kryo.writeClassAndObject(output, event.providerId()); | ||
| 29 | + kryo.writeClassAndObject(output, event.deviceId()); | ||
| 30 | + kryo.writeClassAndObject(output, event.portDescription()); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + @Override | ||
| 34 | + public InternalPortStatusEvent read(Kryo kryo, Input input, | ||
| 35 | + Class<InternalPortStatusEvent> type) { | ||
| 36 | + ProviderId providerId = (ProviderId) kryo.readClassAndObject(input); | ||
| 37 | + DeviceId deviceId = (DeviceId) kryo.readClassAndObject(input); | ||
| 38 | + Timestamped<PortDescription> portDescription = (Timestamped<PortDescription>) kryo.readClassAndObject(input); | ||
| 39 | + | ||
| 40 | + return new InternalPortStatusEvent(providerId, deviceId, portDescription); | ||
| 41 | + } | ||
| 42 | +} |
-
Please register or login to post a comment