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
pankaj
2014-10-02 18:08:48 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5eb26c6ccf6130bfe9a60fc3fbc74ccb630619e5
5eb26c6c
1 parent
0d237839
instrumented the simple client to register metrics
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
3 deletions
utils/netty/src/main/java/org/onlab/netty/SimpleClient.java
utils/netty/src/main/java/org/onlab/netty/SimpleClient.java
View file @
5eb26c6
...
...
@@ -2,16 +2,43 @@ package org.onlab.netty;
import
java.util.concurrent.TimeUnit
;
import
org.onlab.metrics.MetricsComponent
;
import
org.onlab.metrics.MetricsFeature
;
import
org.onlab.metrics.MetricsManager
;
import
com.codahale.metrics.Timer
;
public
final
class
SimpleClient
{
private
SimpleClient
()
{}
public
static
void
main
(
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"
);
context
.
stop
();
}
metrics
.
registerMetric
(
component
,
feature
,
"AsyncTimer"
,
sendAsyncTimer
);
Timer
sendAndRecieveTimer
=
metrics
.
createTimer
(
component
,
feature
,
"SendAndReceive"
);
final
int
iterations
=
1000000
;
for
(
int
i
=
0
;
i
<
iterations
;
i
++)
{
Timer
.
Context
context
=
sendAndRecieveTimer
.
time
();
Response
<
String
>
response
=
messaging
.
sendAndReceive
(
new
Endpoint
(
"localhost"
,
8080
),
"echo"
,
"Hello World"
);
System
.
out
.
println
(
"Got back:"
+
response
.
get
(
2
,
TimeUnit
.
SECONDS
));
context
.
stop
();
}
metrics
.
registerMetric
(
component
,
feature
,
"AsyncTimer"
,
sendAndRecieveTimer
);
messaging
.
sendAsync
(
new
Endpoint
(
"localhost"
,
8080
),
"simple"
,
"Hello World"
);
Response
<
String
>
response
=
messaging
.
sendAndReceive
(
new
Endpoint
(
"localhost"
,
8080
),
"echo"
,
"Hello World"
);
System
.
out
.
println
(
"Got back:"
+
response
.
get
(
2
,
TimeUnit
.
SECONDS
));
}
public
static
class
TestNettyMessagingService
extends
NettyMessagingService
{
...
...
Please
register
or
login
to post a comment