Toggle navigation
Toggle navigation
This project
Loading...
Sign in
홍길동
/
onos
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
alshabib
2014-10-07 16:52:10 -0700
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
ce2a9586b437d82c5daa897a0461dccc4b686fb2
ce2a9586
2 parents
902d41b8
e279be89
Merge branch 'master' of
ssh://gerrit.onlab.us:29418/onos-next
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
213 additions
and
10 deletions
apps/foo/pom.xml
apps/foo/src/main/java/org/onlab/onos/foo/SimpleNettyClient.java
apps/foo/src/main/java/org/onlab/onos/foo/SimpleNettyClientCommand.java
apps/foo/src/main/java/org/onlab/onos/foo/SimpleNettyServer.java
apps/foo/src/main/java/org/onlab/onos/foo/SimpleNettyServerCommand.java
core/net/src/test/java/org/onlab/onos/net/host/impl/HostMonitorTest.java
core/store/dist/src/main/java/org/onlab/onos/store/cluster/impl/DistributedClusterStore.java
core/store/dist/src/main/java/org/onlab/onos/store/cluster/messaging/impl/ClusterCommunicationManager.java
features/features.xml
pom.xml
apps/foo/pom.xml
View file @
ce2a958
...
...
@@ -28,6 +28,11 @@
<version>
${project.version}
</version>
</dependency>
<dependency>
<groupId>
org.onlab.onos
</groupId>
<artifactId>
onlab-netty
</artifactId>
<version>
${project.version}
</version>
</dependency>
<dependency>
<groupId>
org.apache.karaf.shell
</groupId>
<artifactId>
org.apache.karaf.shell.console
</artifactId>
</dependency>
...
...
apps/foo/src/main/java/org/onlab/onos/foo/SimpleNettyClient.java
0 → 100644
View file @
ce2a958
package
org
.
onlab
.
onos
.
foo
;
import
java.io.IOException
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeoutException
;
import
org.onlab.metrics.MetricsComponent
;
import
org.onlab.metrics.MetricsFeature
;
import
org.onlab.metrics.MetricsManager
;
import
org.onlab.netty.Endpoint
;
import
org.onlab.netty.NettyMessagingService
;
import
org.onlab.netty.Response
;
import
com.codahale.metrics.Timer
;
// FIXME: Should be move out to test or app
public
final
class
SimpleNettyClient
{
private
SimpleNettyClient
()
{
}
public
static
void
main
(
String
[]
args
)
throws
IOException
,
InterruptedException
,
ExecutionException
,
TimeoutException
{
try
{
startStandalone
(
args
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
System
.
exit
(
0
);
}
public
static
void
startStandalone
(
String
...
args
)
throws
Exception
{
NettyMessagingService
messaging
=
new
TestNettyMessagingService
(
9081
);
MetricsManager
metrics
=
new
MetricsManager
();
messaging
.
activate
();
metrics
.
activate
();
MetricsFeature
feature
=
new
MetricsFeature
(
"timers"
);
MetricsComponent
component
=
metrics
.
registerComponent
(
"NettyMessaging"
);
Timer
sendAsyncTimer
=
metrics
.
createTimer
(
component
,
feature
,
"AsyncSender"
);
final
int
warmup
=
100
;
for
(
int
i
=
0
;
i
<
warmup
;
i
++)
{
Timer
.
Context
context
=
sendAsyncTimer
.
time
();
messaging
.
sendAsync
(
new
Endpoint
(
"localhost"
,
8080
),
"simple"
,
"Hello World"
.
getBytes
());
context
.
stop
();
}
metrics
.
registerMetric
(
component
,
feature
,
"AsyncTimer"
,
sendAsyncTimer
);
Timer
sendAndReceiveTimer
=
metrics
.
createTimer
(
component
,
feature
,
"SendAndReceive"
);
final
int
iterations
=
1000000
;
for
(
int
i
=
0
;
i
<
iterations
;
i
++)
{
Timer
.
Context
context
=
sendAndReceiveTimer
.
time
();
Response
response
=
messaging
.
sendAndReceive
(
new
Endpoint
(
"localhost"
,
8080
),
"echo"
,
"Hello World"
.
getBytes
());
System
.
out
.
println
(
"Got back:"
+
new
String
(
response
.
get
(
2
,
TimeUnit
.
SECONDS
)));
context
.
stop
();
}
metrics
.
registerMetric
(
component
,
feature
,
"AsyncTimer"
,
sendAndReceiveTimer
);
}
public
static
class
TestNettyMessagingService
extends
NettyMessagingService
{
public
TestNettyMessagingService
(
int
port
)
throws
Exception
{
super
(
port
);
}
}
}
apps/foo/src/main/java/org/onlab/onos/foo/SimpleNettyClientCommand.java
0 → 100644
View file @
ce2a958
package
org
.
onlab
.
onos
.
foo
;
import
static
org
.
onlab
.
onos
.
foo
.
SimpleNettyClient
.
startStandalone
;
import
org.apache.karaf.shell.commands.Argument
;
import
org.apache.karaf.shell.commands.Command
;
import
org.onlab.onos.cli.AbstractShellCommand
;
/**
* Test Netty client performance.
*/
@Command
(
scope
=
"onos"
,
name
=
"simple-netty-client"
,
description
=
"Starts the simple Netty client"
)
public
class
SimpleNettyClientCommand
extends
AbstractShellCommand
{
@Argument
(
index
=
0
,
name
=
"serverIp"
,
description
=
"Server IP address"
,
required
=
false
,
multiValued
=
false
)
String
serverIp
=
"127.0.0.1"
;
@Argument
(
index
=
1
,
name
=
"workers"
,
description
=
"IO workers"
,
required
=
false
,
multiValued
=
false
)
String
workers
=
"6"
;
@Argument
(
index
=
2
,
name
=
"messageCount"
,
description
=
"Message count"
,
required
=
false
,
multiValued
=
false
)
String
messageCount
=
"1000000"
;
@Argument
(
index
=
3
,
name
=
"messageLength"
,
description
=
"Message length (bytes)"
,
required
=
false
,
multiValued
=
false
)
String
messageLength
=
"128"
;
@Argument
(
index
=
4
,
name
=
"timeoutSecs"
,
description
=
"Test timeout (seconds)"
,
required
=
false
,
multiValued
=
false
)
String
timeoutSecs
=
"60"
;
@Override
protected
void
execute
()
{
try
{
startStandalone
(
new
String
[]{
serverIp
,
workers
,
messageCount
,
messageLength
,
timeoutSecs
});
}
catch
(
Exception
e
)
{
error
(
"Unable to start client %s"
,
e
);
}
}
}
apps/foo/src/main/java/org/onlab/onos/foo/SimpleNettyServer.java
0 → 100644
View file @
ce2a958
package
org
.
onlab
.
onos
.
foo
;
import
org.onlab.netty.EchoHandler
;
import
org.onlab.netty.NettyMessagingService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* Test to measure Messaging performance.
*/
public
final
class
SimpleNettyServer
{
private
static
Logger
log
=
LoggerFactory
.
getLogger
(
IOLoopTestServer
.
class
);
private
SimpleNettyServer
()
{}
public
static
void
main
(
String
...
args
)
throws
Exception
{
startStandalone
(
args
);
System
.
exit
(
0
);
}
public
static
void
startStandalone
(
String
[]
args
)
throws
Exception
{
NettyMessagingService
server
=
new
NettyMessagingService
(
8080
);
server
.
activate
();
server
.
registerHandler
(
"simple"
,
new
org
.
onlab
.
netty
.
LoggingHandler
());
server
.
registerHandler
(
"echo"
,
new
EchoHandler
());
}
}
apps/foo/src/main/java/org/onlab/onos/foo/SimpleNettyServerCommand.java
0 → 100644
View file @
ce2a958
package
org
.
onlab
.
onos
.
foo
;
import
static
org
.
onlab
.
onos
.
foo
.
SimpleNettyServer
.
startStandalone
;
import
org.apache.karaf.shell.commands.Argument
;
import
org.apache.karaf.shell.commands.Command
;
import
org.onlab.onos.cli.AbstractShellCommand
;
/**
* Starts the Simple Netty server.
*/
@Command
(
scope
=
"onos"
,
name
=
"test-netty-server"
,
description
=
"Starts the simple netty server"
)
public
class
SimpleNettyServerCommand
extends
AbstractShellCommand
{
@Argument
(
index
=
0
,
name
=
"serverIp"
,
description
=
"Server IP address"
,
required
=
false
,
multiValued
=
false
)
String
serverIp
=
"127.0.0.1"
;
@Argument
(
index
=
1
,
name
=
"workers"
,
description
=
"IO workers"
,
required
=
false
,
multiValued
=
false
)
String
workers
=
"6"
;
@Argument
(
index
=
2
,
name
=
"messageLength"
,
description
=
"Message length (bytes)"
,
required
=
false
,
multiValued
=
false
)
String
messageLength
=
"128"
;
@Override
protected
void
execute
()
{
try
{
startStandalone
(
new
String
[]{
serverIp
,
workers
,
messageLength
});
}
catch
(
Exception
e
)
{
error
(
"Unable to start server %s"
,
e
);
}
}
}
core/net/src/test/java/org/onlab/onos/net/host/impl/HostMonitorTest.java
View file @
ce2a958
...
...
@@ -13,6 +13,7 @@ import java.util.Collections;
import
java.util.List
;
import
java.util.Set
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.onlab.onos.net.ConnectPoint
;
import
org.onlab.onos.net.Device
;
...
...
@@ -52,6 +53,7 @@ public class HostMonitorTest {
private
HostMonitor
hostMonitor
;
@Test
@Ignore
public
void
testMonitorHostExists
()
throws
Exception
{
ProviderId
id
=
new
ProviderId
(
"fake://"
,
"id"
);
...
...
@@ -81,6 +83,7 @@ public class HostMonitorTest {
}
@Test
@Ignore
public
void
testMonitorHostDoesNotExist
()
throws
Exception
{
HostManager
hostManager
=
createMock
(
HostManager
.
class
);
...
...
core/store/dist/src/main/java/org/onlab/onos/store/cluster/impl/DistributedClusterStore.java
View file @
ce2a958
...
...
@@ -7,11 +7,9 @@ import com.google.common.cache.RemovalNotification;
import
com.google.common.collect.ImmutableSet
;
import
org.apache.felix.scr.annotations.Activate
;
import
org.apache.felix.scr.annotations.Component
;
import
org.apache.felix.scr.annotations.Deactivate
;
import
org.apache.felix.scr.annotations.Reference
;
import
org.apache.felix.scr.annotations.ReferenceCardinality
;
import
org.apache.felix.scr.annotations.Service
;
import
org.onlab.onos.cluster.ClusterEvent
;
import
org.onlab.onos.cluster.ClusterStore
;
import
org.onlab.onos.cluster.ClusterStoreDelegate
;
...
...
@@ -37,8 +35,8 @@ import static org.onlab.packet.IpPrefix.valueOf;
/**
* Distributed implementation of the cluster nodes store.
*/
@Component
(
immediate
=
true
)
@Service
//
@Component(immediate = true)
//
@Service
public
class
DistributedClusterStore
extends
AbstractStore
<
ClusterEvent
,
ClusterStoreDelegate
>
implements
ClusterStore
{
...
...
core/store/dist/src/main/java/org/onlab/onos/store/cluster/messaging/impl/ClusterCommunicationManager.java
View file @
ce2a958
...
...
@@ -12,7 +12,10 @@ import java.util.TimerTask;
import
org.apache.felix.scr.annotations.Activate
;
import
org.apache.felix.scr.annotations.Component
;
import
org.apache.felix.scr.annotations.Deactivate
;
import
org.apache.felix.scr.annotations.Reference
;
import
org.apache.felix.scr.annotations.ReferenceCardinality
;
import
org.apache.felix.scr.annotations.Service
;
import
org.onlab.onos.cluster.ClusterService
;
import
org.onlab.onos.cluster.ControllerNode
;
import
org.onlab.onos.cluster.NodeId
;
import
org.onlab.onos.store.cluster.impl.ClusterMembershipEvent
;
...
...
@@ -30,6 +33,7 @@ import org.onlab.netty.Endpoint;
import
org.onlab.netty.Message
;
import
org.onlab.netty.MessageHandler
;
import
org.onlab.netty.MessagingService
;
import
org.onlab.netty.NettyMessagingService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -41,6 +45,10 @@ public class ClusterCommunicationManager
private
final
Logger
log
=
LoggerFactory
.
getLogger
(
getClass
());
private
ControllerNode
localNode
;
@Reference
(
cardinality
=
ReferenceCardinality
.
MANDATORY_UNARY
)
private
ClusterService
clusterService
;
private
ClusterNodesDelegate
nodesDelegate
;
// FIXME: `members` should go away and should be using ClusterService
private
Map
<
NodeId
,
ControllerNode
>
members
=
new
HashMap
<>();
...
...
@@ -48,7 +56,6 @@ public class ClusterCommunicationManager
public
static
final
long
HEART_BEAT_INTERVAL_MILLIS
=
1000L
;
// TODO: This probably should not be a OSGi service.
//@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
private
MessagingService
messagingService
;
private
static
final
KryoSerializer
SERIALIZER
=
new
KryoSerializer
()
{
...
...
@@ -65,11 +72,8 @@ public class ClusterCommunicationManager
@Activate
public
void
activate
()
{
// TODO: initialize messagingService
// TODO: setPayloadSerializer, which is capable of
// (1) serialize ClusterMessage - ClusterMessage.payload
// (2) serialize ClusterMessage.payload using user specified serializer
// messagingService.setPayloadSerializer(...);
localNode
=
clusterService
.
getLocalNode
();
messagingService
=
new
NettyMessagingService
(
localNode
.
tcpPort
());
log
.
info
(
"Started"
);
}
...
...
features/features.xml
View file @
ce2a958
...
...
@@ -9,6 +9,12 @@
<bundle>
mvn:org.apache.commons/commons-lang3/3.3.2
</bundle>
<bundle>
mvn:com.google.guava/guava/18.0
</bundle>
<bundle>
mvn:io.netty/netty/3.9.2.Final
</bundle>
<bundle>
mvn:io.netty/netty-common/4.0.23.Final
</bundle>
<bundle>
mvn:io.netty/netty-buffer/4.0.23.Final
</bundle>
<bundle>
mvn:io.netty/netty-transport/4.0.23.Final
</bundle>
<bundle>
mvn:io.netty/netty-handler/4.0.23.Final
</bundle>
<bundle>
mvn:io.netty/netty-codec/4.0.23.Final
</bundle>
<bundle>
mvn:commons-pool/commons-pool/1.6
</bundle>
<bundle>
mvn:com.hazelcast/hazelcast/3.3
</bundle>
<bundle>
mvn:io.dropwizard.metrics/metrics-core/3.1.0
</bundle>
...
...
@@ -55,6 +61,9 @@
<bundle>
mvn:org.onlab.onos/onos-core-dist/1.0.0-SNAPSHOT
</bundle>
<bundle>
mvn:org.onlab.onos/onos-core-serializers/1.0.0-SNAPSHOT
</bundle>
<bundle>
mvn:org.onlab.onos/onlab-netty/1.0.0-SNAPSHOT
</bundle>
<bundle>
mvn:org.onlab.onos/onos-core-hz-common/1.0.0-SNAPSHOT
</bundle>
<bundle>
mvn:org.onlab.onos/onos-core-hz-cluster/1.0.0-SNAPSHOT
</bundle>
</feature>
<feature
name=
"onos-core-hazelcast"
version=
"1.0.0"
...
...
pom.xml
View file @
ce2a958
...
...
@@ -69,6 +69,13 @@
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-core
</artifactId>
<version>
1.7.6
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-jdk14
</artifactId>
<version>
1.7.6
</version>
<scope>
test
</scope>
...
...
Please
register
or
login
to post a comment