Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
pulsar
提交
6ea847cc
pulsar
项目概览
apache
/
pulsar
通知
129
Star
40
Fork
3
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Wiki
1
Wiki
分析
仓库
DevOps
项目成员
Pages
pulsar
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
Wiki
1
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
6ea847cc
编写于
12月 02, 2016
作者:
Y
yush1ga
提交者:
Matteo Merli
12月 01, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Replaced Json Library (#130)
上级
5af7d3fe
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
102 addition
and
98 deletion
+102
-98
pom.xml
pom.xml
+1
-7
pulsar-broker/pom.xml
pulsar-broker/pom.xml
+2
-2
pulsar-broker/src/test/java/com/yahoo/pulsar/broker/service/AdvertisedAddressTest.java
...om/yahoo/pulsar/broker/service/AdvertisedAddressTest.java
+5
-4
pulsar-broker/src/test/java/com/yahoo/pulsar/broker/service/BrokerServiceTest.java
...va/com/yahoo/pulsar/broker/service/BrokerServiceTest.java
+14
-15
pulsar-broker/src/test/java/com/yahoo/pulsar/discovery/service/web/DiscoveryServiceWebTest.java
...pulsar/discovery/service/web/DiscoveryServiceWebTest.java
+6
-5
pulsar-broker/src/test/java/com/yahoo/pulsar/websocket/proxy/SimpleConsumerSocket.java
...om/yahoo/pulsar/websocket/proxy/SimpleConsumerSocket.java
+9
-7
pulsar-broker/src/test/java/com/yahoo/pulsar/websocket/proxy/SimpleProducerSocket.java
...om/yahoo/pulsar/websocket/proxy/SimpleProducerSocket.java
+7
-6
pulsar-client-admin/pom.xml
pulsar-client-admin/pom.xml
+2
-7
pulsar-client-admin/src/main/java/com/yahoo/pulsar/client/admin/BrokerStats.java
.../main/java/com/yahoo/pulsar/client/admin/BrokerStats.java
+6
-6
pulsar-client-admin/src/main/java/com/yahoo/pulsar/client/admin/internal/BrokerStatsImpl.java
...m/yahoo/pulsar/client/admin/internal/BrokerStatsImpl.java
+15
-14
pulsar-client-tools/src/main/java/com/yahoo/pulsar/admin/cli/CmdBrokerStats.java
.../main/java/com/yahoo/pulsar/admin/cli/CmdBrokerStats.java
+25
-11
pulsar-client/pom.xml
pulsar-client/pom.xml
+0
-5
pulsar-websocket/pom.xml
pulsar-websocket/pom.xml
+2
-2
pulsar-websocket/src/test/java/com/yahoo/pulsar/proxy/socket/client/SimpleTestProducerSocket.java
.../pulsar/proxy/socket/client/SimpleTestProducerSocket.java
+8
-7
未找到文件。
pom.xml
浏览文件 @
6ea847cc
...
...
@@ -227,16 +227,10 @@ flexible messaging model and an intuitive client API.</description>
<version>
3.10.1.Final
</version>
</dependency>
<dependency>
<groupId>
org.json
</groupId>
<artifactId>
json
</artifactId>
<version>
20090211
</version>
</dependency>
<dependency>
<groupId>
com.google.code.gson
</groupId>
<artifactId>
gson
</artifactId>
<version>
2.
7
</version>
<version>
2.
8.0
</version>
</dependency>
<dependency>
...
...
pulsar-broker/pom.xml
浏览文件 @
6ea847cc
...
...
@@ -194,8 +194,8 @@
</dependency>
<dependency>
<groupId>
org.j
son
</groupId>
<artifactId>
j
son
</artifactId>
<groupId>
com.google.code.g
son
</groupId>
<artifactId>
g
son
</artifactId>
</dependency>
<dependency>
...
...
pulsar-broker/src/test/java/com/yahoo/pulsar/broker/service/AdvertisedAddressTest.java
浏览文件 @
6ea847cc
...
...
@@ -19,7 +19,8 @@ import com.yahoo.pulsar.broker.PulsarService;
import
com.yahoo.pulsar.broker.ServiceConfiguration
;
import
com.yahoo.pulsar.zookeeper.LocalBookkeeperEnsemble
;
import
org.apache.zookeeper.data.Stat
;
import
org.json.JSONObject
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonObject
;
import
org.junit.After
;
import
org.junit.Assert
;
import
org.junit.Before
;
...
...
@@ -67,9 +68,9 @@ public class AdvertisedAddressTest {
Assert
.
assertEquals
(
pulsar
.
getWebServiceAddress
(),
String
.
format
(
"http://%s:%d"
,
advertisedAddress
,
BROKER_WEBSERVICE_PORT
)
);
String
brokerZkPath
=
String
.
format
(
"/loadbalance/brokers/%s:%d"
,
pulsar
.
getAdvertisedAddress
(),
BROKER_WEBSERVICE_PORT
);
String
bkBrokerData
=
new
String
(
bkEnsemble
.
getZkClient
().
getData
(
brokerZkPath
,
false
,
new
Stat
()),
StandardCharsets
.
UTF_8
);
J
SONObject
jsonBkBrokerData
=
new
JSONObject
(
bkBrokerData
);
Assert
.
assertEquals
(
jsonBkBrokerData
.
get
(
"pulsarServiceUrl"
),
pulsar
.
getBrokerServiceUrl
()
);
Assert
.
assertEquals
(
jsonBkBrokerData
.
get
(
"webServiceUrl"
),
pulsar
.
getWebServiceAddress
()
);
J
sonObject
jsonBkBrokerData
=
new
Gson
().
fromJson
(
bkBrokerData
,
JsonObject
.
class
);
Assert
.
assertEquals
(
jsonBkBrokerData
.
get
(
"pulsarServiceUrl"
)
.
getAsString
()
,
pulsar
.
getBrokerServiceUrl
()
);
Assert
.
assertEquals
(
jsonBkBrokerData
.
get
(
"webServiceUrl"
)
.
getAsString
()
,
pulsar
.
getWebServiceAddress
()
);
}
}
pulsar-broker/src/test/java/com/yahoo/pulsar/broker/service/BrokerServiceTest.java
浏览文件 @
6ea847cc
...
...
@@ -30,9 +30,8 @@ import java.util.concurrent.CountDownLatch;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
org.testng.annotations.AfterClass
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.Test
;
...
...
@@ -301,23 +300,23 @@ public class BrokerServiceTest extends BrokerTestBase {
}
consumer
.
close
();
Thread
.
sleep
(
ASYNC_EVENT_COMPLETION_WAIT
);
J
SON
Array
metrics
=
brokerStatsClient
.
getMetrics
();
assertEquals
(
metrics
.
length
(),
4
,
metrics
.
toString
());
J
son
Array
metrics
=
brokerStatsClient
.
getMetrics
();
assertEquals
(
metrics
.
size
(),
4
,
metrics
.
toString
());
// these metrics seem to be arriving in different order at different times...
// is the order really relevant here?
boolean
namespaceDimensionFound
=
false
;
boolean
topicLoadTimesDimensionFound
=
false
;
for
(
int
i
=
0
;
i
<
metrics
.
length
();
i
++
)
{
for
(
int
i
=
0
;
i
<
metrics
.
size
();
i
++
)
{
try
{
String
data
=
metrics
.
get
JSONObject
(
i
).
getString
(
"dimensions"
);
String
data
=
metrics
.
get
(
i
).
getAsJsonObject
().
get
(
"dimensions"
).
toString
(
);
if
(!
namespaceDimensionFound
&&
data
.
contains
(
"prop/use/ns-abc"
))
{
namespaceDimensionFound
=
true
;
}
if
(!
topicLoadTimesDimensionFound
&&
data
.
contains
(
"prop/use/ns-abc"
))
{
topicLoadTimesDimensionFound
=
true
;
}
}
catch
(
JSON
Exception
e
)
{
/* it's possible there's no dimensions */
}
}
catch
(
Exception
e
)
{
/* it's possible there's no dimensions */
}
}
assertTrue
(
namespaceDimensionFound
&&
topicLoadTimesDimensionFound
);
...
...
@@ -346,20 +345,20 @@ public class BrokerServiceTest extends BrokerTestBase {
}
rolloverPerIntervalStats
();
J
SON
Object
destinationStats
=
brokerStatsClient
.
getDestinations
();
assertEquals
(
destinationStats
.
length
(),
2
,
destinationStats
.
toString
());
J
son
Object
destinationStats
=
brokerStatsClient
.
getDestinations
();
assertEquals
(
destinationStats
.
size
(),
2
,
destinationStats
.
toString
());
for
(
String
ns
:
nsList
)
{
J
SONObject
nsObject
=
destinationStats
.
getJSON
Object
(
ns
);
J
sonObject
nsObject
=
destinationStats
.
getAsJson
Object
(
ns
);
List
<
String
>
topicList
=
admin
.
namespaces
().
getDestinations
(
ns
);
for
(
String
topic
:
topicList
)
{
NamespaceBundle
bundle
=
(
NamespaceBundle
)
pulsar
.
getNamespaceService
()
.
getBundle
(
DestinationName
.
get
(
topic
));
J
SONObject
bundleObject
=
nsObject
.
getJSON
Object
(
bundle
.
getBundleRange
());
J
SONObject
topicObject
=
bundleObject
.
getJSON
Object
(
"persistent"
);
J
sonObject
bundleObject
=
nsObject
.
getAsJson
Object
(
bundle
.
getBundleRange
());
J
sonObject
topicObject
=
bundleObject
.
getAsJson
Object
(
"persistent"
);
AtomicBoolean
topicPresent
=
new
AtomicBoolean
();
topicObject
.
keys
().
forEachRemaining
(
persistentTopic
->
{
if
(
persistentTopic
.
equals
(
topic
))
{
topicObject
.
entrySet
().
iterator
().
forEachRemaining
(
persistentTopic
->
{
if
(
persistentTopic
.
getKey
().
equals
(
topic
))
{
topicPresent
.
set
(
true
);
}
});
...
...
pulsar-broker/src/test/java/com/yahoo/pulsar/discovery/service/web/DiscoveryServiceWebTest.java
浏览文件 @
6ea847cc
...
...
@@ -35,8 +35,9 @@ import org.apache.bookkeeper.test.PortManager;
import
org.apache.zookeeper.ZooKeeper
;
import
org.glassfish.jersey.client.ClientConfig
;
import
org.glassfish.jersey.filter.LoggingFilter
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonParseException
;
import
com.google.gson.JsonObject
;
import
org.testng.annotations.AfterMethod
;
import
org.testng.annotations.BeforeMethod
;
import
org.testng.annotations.Test
;
...
...
@@ -103,7 +104,7 @@ public class DiscoveryServiceWebTest extends ProducerConsumerBase {
}
public
String
hitBrokerService
(
String
method
,
String
url
,
Object
data
)
throws
J
SON
Exception
{
public
String
hitBrokerService
(
String
method
,
String
url
,
Object
data
)
throws
J
sonParse
Exception
{
Response
response
=
null
;
try
{
...
...
@@ -123,8 +124,8 @@ public class DiscoveryServiceWebTest extends ProducerConsumerBase {
fail
();
}
J
SONObject
jsonObject
=
new
JSONObject
(
response
.
readEntity
(
String
.
class
)
);
String
serviceResponse
=
jsonObject
.
get
String
(
"reason"
);
J
sonObject
jsonObject
=
new
Gson
().
fromJson
(
response
.
readEntity
(
String
.
class
),
JsonObject
.
class
);
String
serviceResponse
=
jsonObject
.
get
(
"reason"
).
getAsString
(
);
return
serviceResponse
;
}
...
...
pulsar-broker/src/test/java/com/yahoo/pulsar/websocket/proxy/SimpleConsumerSocket.java
浏览文件 @
6ea847cc
...
...
@@ -26,8 +26,10 @@ import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose;
import
org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect
;
import
org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage
;
import
org.eclipse.jetty.websocket.api.annotations.WebSocket
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonParseException
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonPrimitive
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -63,12 +65,12 @@ public class SimpleConsumerSocket {
}
@OnWebSocketMessage
public
void
onMessage
(
String
msg
)
throws
J
SON
Exception
,
IOException
{
J
SONObject
message
=
new
JSONObject
(
msg
);
J
SONObject
ack
=
new
JSON
Object
();
String
messageId
=
message
.
get
String
(
X_PULSAR_MESSAGE_ID
).
to
String
();
public
void
onMessage
(
String
msg
)
throws
J
sonParse
Exception
,
IOException
{
J
sonObject
message
=
new
Gson
().
fromJson
(
msg
,
JsonObject
.
class
);
J
sonObject
ack
=
new
Json
Object
();
String
messageId
=
message
.
get
(
X_PULSAR_MESSAGE_ID
).
getAs
String
();
consumerBuffer
.
add
(
messageId
);
ack
.
put
(
"messageId"
,
messageId
);
ack
.
add
(
"messageId"
,
new
JsonPrimitive
(
messageId
)
);
// Acking the proxy
this
.
getRemote
().
sendString
(
ack
.
toString
());
}
...
...
pulsar-broker/src/test/java/com/yahoo/pulsar/websocket/proxy/SimpleProducerSocket.java
浏览文件 @
6ea847cc
...
...
@@ -27,8 +27,9 @@ import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose;
import
org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect
;
import
org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage
;
import
org.eclipse.jetty.websocket.api.annotations.WebSocket
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonParseException
;
import
com.google.gson.JsonObject
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -67,7 +68,7 @@ public class SimpleProducerSocket {
}
@OnWebSocketConnect
public
void
onConnect
(
Session
session
)
throws
InterruptedException
,
IOException
,
J
SON
Exception
{
public
void
onConnect
(
Session
session
)
throws
InterruptedException
,
IOException
,
J
sonParse
Exception
{
log
.
info
(
"Got connect: {}"
,
session
);
this
.
session
=
session
;
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
...
...
@@ -77,9 +78,9 @@ public class SimpleProducerSocket {
}
@OnWebSocketMessage
public
void
onMessage
(
String
msg
)
throws
J
SON
Exception
{
J
SONObject
ack
=
new
JSONObject
(
msg
);
producerBuffer
.
add
(
(
String
)
ack
.
get
(
"messageId"
));
public
void
onMessage
(
String
msg
)
throws
J
sonParse
Exception
{
J
sonObject
ack
=
new
Gson
().
fromJson
(
msg
,
JsonObject
.
class
);
producerBuffer
.
add
(
ack
.
get
(
"messageId"
).
getAsString
(
));
}
public
RemoteEndpoint
getRemote
()
{
...
...
pulsar-client-admin/pom.xml
浏览文件 @
6ea847cc
...
...
@@ -69,8 +69,8 @@
</dependency>
<dependency>
<groupId>
org.j
son
</groupId>
<artifactId>
j
son
</artifactId>
<groupId>
com.google.code.g
son
</groupId>
<artifactId>
g
son
</artifactId>
</dependency>
</dependencies>
<build>
...
...
@@ -99,7 +99,6 @@
<include>
com.google.protobuf:protobuf-java
</include>
<include>
com.google.guava:guava
</include>
<include>
com.google.code.gson:gson
</include>
<include>
org.json:json
</include>
<include>
io.netty:netty
</include>
<include>
io.netty:netty-all
</include>
</includes>
...
...
@@ -117,10 +116,6 @@
<pattern>
com.google
</pattern>
<shadedPattern>
pulsar-admin-shade.com.google
</shadedPattern>
</relocation>
<relocation>
<pattern>
org.json
</pattern>
<shadedPattern>
pulsar-admin-shade.org.json
</shadedPattern>
</relocation>
<relocation>
<pattern>
org.jboss.netty
</pattern>
<shadedPattern>
pulsar-admin-shade.org.jboss.netty
</shadedPattern>
...
...
pulsar-client-admin/src/main/java/com/yahoo/pulsar/client/admin/BrokerStats.java
浏览文件 @
6ea847cc
...
...
@@ -15,8 +15,8 @@
*/
package
com.yahoo.pulsar.client.admin
;
import
org.json.JSON
Array
;
import
org.json.JSON
Object
;
import
com.google.gson.Json
Array
;
import
com.google.gson.Json
Object
;
import
com.yahoo.pulsar.common.stats.AllocatorStats
;
...
...
@@ -32,7 +32,7 @@ public interface BrokerStats {
* @throws PulsarAdminException
*/
J
SON
Array
getMetrics
()
throws
PulsarAdminException
;
J
son
Array
getMetrics
()
throws
PulsarAdminException
;
/**
* Requests JSON string server mbean dump
...
...
@@ -42,7 +42,7 @@ public interface BrokerStats {
* @return
* @throws PulsarAdminException
*/
J
SON
Array
getMBeans
()
throws
PulsarAdminException
;
J
son
Array
getMBeans
()
throws
PulsarAdminException
;
/**
* Returns JSON string destination stats
...
...
@@ -52,9 +52,9 @@ public interface BrokerStats {
* @return
* @throws PulsarAdminException
*/
J
SON
Object
getDestinations
()
throws
PulsarAdminException
;
J
son
Object
getDestinations
()
throws
PulsarAdminException
;
J
SON
Object
getPendingBookieOpsStats
()
throws
PulsarAdminException
;
J
son
Object
getPendingBookieOpsStats
()
throws
PulsarAdminException
;
AllocatorStats
getAllocatorStats
(
String
allocatorName
)
throws
PulsarAdminException
;
}
pulsar-client-admin/src/main/java/com/yahoo/pulsar/client/admin/internal/BrokerStatsImpl.java
浏览文件 @
6ea847cc
...
...
@@ -17,8 +17,9 @@ package com.yahoo.pulsar.client.admin.internal;
import
javax.ws.rs.client.WebTarget
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
com.yahoo.pulsar.client.admin.BrokerStats
;
import
com.yahoo.pulsar.client.admin.PulsarAdminException
;
...
...
@@ -40,10 +41,10 @@ public class BrokerStatsImpl extends BaseResource implements BrokerStats {
}
@Override
public
J
SON
Array
getMetrics
()
throws
PulsarAdminException
{
public
J
son
Array
getMetrics
()
throws
PulsarAdminException
{
try
{
String
json
=
request
(
brokerStats
.
path
(
"/metrics"
)).
get
(
String
.
class
);
return
new
JSONArray
(
json
);
return
new
Gson
().
fromJson
(
json
,
JsonArray
.
class
);
}
catch
(
Exception
e
)
{
throw
getApiException
(
e
);
}
...
...
@@ -59,51 +60,51 @@ public class BrokerStatsImpl extends BaseResource implements BrokerStats {
}
@Override
public
J
SON
Array
getMBeans
()
throws
PulsarAdminException
{
public
J
son
Array
getMBeans
()
throws
PulsarAdminException
{
try
{
String
json
=
request
(
brokerStats
.
path
(
"/mbeans"
)).
get
(
String
.
class
);
return
new
JSONArray
(
json
);
return
new
Gson
().
fromJson
(
json
,
JsonArray
.
class
);
}
catch
(
Exception
e
)
{
throw
getApiException
(
e
);
}
}
@Override
public
J
SON
Object
getDestinations
()
throws
PulsarAdminException
{
public
J
son
Object
getDestinations
()
throws
PulsarAdminException
{
try
{
String
json
=
request
(
brokerStats
.
path
(
"/destinations"
)).
get
(
String
.
class
);
return
new
JSONObject
(
json
);
return
new
Gson
().
fromJson
(
json
,
JsonObject
.
class
);
}
catch
(
Exception
e
)
{
throw
getApiException
(
e
);
}
}
public
J
SON
Object
getLoadReport
()
throws
PulsarAdminException
{
public
J
son
Object
getLoadReport
()
throws
PulsarAdminException
{
try
{
String
json
=
request
(
brokerStats
.
path
(
"/load-report"
)).
get
(
String
.
class
);
return
new
JSONObject
(
json
);
return
new
Gson
().
fromJson
(
json
,
JsonObject
.
class
);
}
catch
(
Exception
e
)
{
throw
getApiException
(
e
);
}
}
@Override
public
J
SON
Object
getPendingBookieOpsStats
()
throws
PulsarAdminException
{
public
J
son
Object
getPendingBookieOpsStats
()
throws
PulsarAdminException
{
try
{
String
json
=
request
(
brokerStats
.
path
(
"/bookieops"
)).
get
(
String
.
class
);
return
new
JSONObject
(
json
);
return
new
Gson
().
fromJson
(
json
,
JsonObject
.
class
);
}
catch
(
Exception
e
)
{
throw
getApiException
(
e
);
}
}
public
J
SON
Object
getBrokerResourceAvailability
(
String
property
,
String
cluster
,
String
namespace
)
public
J
son
Object
getBrokerResourceAvailability
(
String
property
,
String
cluster
,
String
namespace
)
throws
PulsarAdminException
{
try
{
String
json
=
request
(
brokerStats
.
path
(
"/broker-resource-availability"
).
path
(
property
).
path
(
cluster
).
path
(
namespace
))
.
get
(
String
.
class
);
return
new
JSONObject
(
json
);
return
new
Gson
().
fromJson
(
json
,
JsonObject
.
class
);
}
catch
(
Exception
e
)
{
throw
getApiException
(
e
);
}
...
...
pulsar-client-tools/src/main/java/com/yahoo/pulsar/admin/cli/CmdBrokerStats.java
浏览文件 @
6ea847cc
...
...
@@ -20,8 +20,10 @@ import java.io.Writer;
import
java.nio.charset.Charset
;
import
java.util.List
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
com.google.gson.stream.JsonWriter
;
import
com.beust.jcommander.Parameter
;
import
com.beust.jcommander.Parameters
;
...
...
@@ -33,7 +35,7 @@ import com.yahoo.pulsar.common.util.ObjectMapperFactory;
@Parameters
(
commandDescription
=
"Operations to collect broker statistics"
)
public
class
CmdBrokerStats
extends
CmdBase
{
public
static
final
int
DEFAULT_INDENTATION
=
4
;
public
static
final
String
DEFAULT_INDENTATION
=
" "
;
public
static
final
Charset
UTF_8
=
Charset
.
forName
(
"UTF-8"
);
public
static
Writer
out
=
new
OutputStreamWriter
(
System
.
out
,
UTF_8
);
...
...
@@ -44,14 +46,18 @@ public class CmdBrokerStats extends CmdBase {
@Override
void
run
()
throws
Exception
{
J
SON
Array
metrics
=
admin
.
brokerStats
().
getMetrics
();
J
son
Array
metrics
=
admin
.
brokerStats
().
getMetrics
();
for
(
int
i
=
0
;
i
<
metrics
.
length
();
i
++)
{
J
SONObject
m
=
(
JSON
Object
)
metrics
.
get
(
i
);
out
.
write
(
indent
?
m
.
toString
(
DEFAULT_INDENTATION
)
:
m
.
toString
()
);
for
(
int
i
=
0
;
i
<
metrics
.
size
();
i
++)
{
J
sonObject
m
=
(
Json
Object
)
metrics
.
get
(
i
);
JsonWriter
jsonWriter
=
new
JsonWriter
(
out
);
if
(
indent
)
{
jsonWriter
.
setIndent
(
DEFAULT_INDENTATION
);
new
Gson
().
toJson
(
m
,
jsonWriter
);
out
.
write
(
'\n'
);
out
.
write
(
'\n'
);
}
else
{
new
Gson
().
toJson
(
m
,
jsonWriter
);
}
out
.
flush
();
}
...
...
@@ -65,8 +71,12 @@ public class CmdBrokerStats extends CmdBase {
@Override
void
run
()
throws
Exception
{
JSONArray
result
=
admin
.
brokerStats
().
getMBeans
();
out
.
write
(
indent
?
result
.
toString
(
DEFAULT_INDENTATION
)
:
result
.
toString
());
JsonArray
result
=
admin
.
brokerStats
().
getMBeans
();
JsonWriter
jsonWriter
=
new
JsonWriter
(
out
);
if
(
indent
)
{
jsonWriter
.
setIndent
(
DEFAULT_INDENTATION
);
}
new
Gson
().
toJson
(
result
,
jsonWriter
);
out
.
flush
();
}
...
...
@@ -79,8 +89,12 @@ public class CmdBrokerStats extends CmdBase {
@Override
void
run
()
throws
Exception
{
JSONObject
result
=
admin
.
brokerStats
().
getDestinations
();
out
.
write
(
indent
?
result
.
toString
(
DEFAULT_INDENTATION
)
:
result
.
toString
());
JsonObject
result
=
admin
.
brokerStats
().
getDestinations
();
JsonWriter
jsonWriter
=
new
JsonWriter
(
out
);
if
(
indent
)
{
jsonWriter
.
setIndent
(
DEFAULT_INDENTATION
);
}
new
Gson
().
toJson
(
result
,
jsonWriter
);
out
.
flush
();
}
...
...
pulsar-client/pom.xml
浏览文件 @
6ea847cc
...
...
@@ -120,7 +120,6 @@
<include>
com.google.protobuf:protobuf-java
</include>
<include>
com.google.guava:guava
</include>
<include>
com.google.code.gson:gson
</include>
<include>
org.json:json
</include>
<include>
com.fasterxml.jackson.core
</include>
<include>
io.netty:netty
</include>
<include>
io.netty:netty-all
</include>
...
...
@@ -147,10 +146,6 @@
<pattern>
com.google
</pattern>
<shadedPattern>
com.yahoo.pulsar.shade.com.google
</shadedPattern>
</relocation>
<relocation>
<pattern>
org.json
</pattern>
<shadedPattern>
com.yahoo.pulsar.shade.org.json
</shadedPattern>
</relocation>
<relocation>
<pattern>
com.fasterxml.jackson
</pattern>
<shadedPattern>
com.yahoo.pulsar.shade.com.fasterxml.jackson
</shadedPattern>
...
...
pulsar-websocket/pom.xml
浏览文件 @
6ea847cc
...
...
@@ -67,8 +67,8 @@
</dependency>
<dependency>
<groupId>
org.j
son
</groupId>
<artifactId>
j
son
</artifactId>
<groupId>
com.google.code.g
son
</groupId>
<artifactId>
g
son
</artifactId>
</dependency>
<dependency>
...
...
pulsar-websocket/src/test/java/com/yahoo/pulsar/proxy/socket/client/SimpleTestProducerSocket.java
浏览文件 @
6ea847cc
...
...
@@ -32,8 +32,9 @@ import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect;
import
org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage
;
import
org.eclipse.jetty.websocket.api.annotations.WebSocket
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonParseException
;
import
com.google.gson.JsonObject
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -63,14 +64,14 @@ public class SimpleTestProducerSocket {
}
@OnWebSocketConnect
public
void
onConnect
(
Session
session
)
throws
InterruptedException
,
IOException
,
J
SON
Exception
{
public
void
onConnect
(
Session
session
)
throws
InterruptedException
,
IOException
,
J
sonParse
Exception
{
log
.
info
(
"Got conneceted to the proxy"
);
this
.
session
=
session
;
}
@OnWebSocketMessage
public
void
onMessage
(
String
msg
)
throws
J
SON
Exception
{
J
SONObject
json
=
new
JSONObject
(
msg
);
public
void
onMessage
(
String
msg
)
throws
J
sonParse
Exception
{
J
sonObject
json
=
new
Gson
().
fromJson
(
msg
,
JsonObject
.
class
);
long
endTimeNs
=
System
.
nanoTime
();
long
startTime
=
endTimeNs
;
if
(
startTimeMap
.
get
(
json
.
get
(
CONTEXT
))
!=
null
)
...
...
@@ -88,12 +89,12 @@ public class SimpleTestProducerSocket {
}
public
void
sendMsg
(
String
context
,
int
sizeOfMessage
)
throws
IOException
,
J
SON
Exception
,
InterruptedException
,
ExecutionException
{
throws
IOException
,
J
sonParse
Exception
,
InterruptedException
,
ExecutionException
{
byte
[]
payload
=
new
byte
[
sizeOfMessage
];
String
message
=
getEncoder
().
encodeToString
(
payload
);
String
timeStamp
=
"{\"content\": \""
+
message
+
"\",\"context\": \""
+
context
+
"\", \"pulsar-properties\" : {\"test\" :[\"test\"]}}"
;
String
sampleMsg
=
new
JSONObject
(
timeStamp
).
toString
();
String
sampleMsg
=
new
Gson
().
fromJson
(
timeStamp
,
JsonObject
.
class
).
toString
();
if
(
this
.
session
!=
null
&&
this
.
session
.
isOpen
()
&&
this
.
session
.
getRemote
()
!=
null
)
{
startTimeMap
.
put
(
context
,
System
.
nanoTime
());
this
.
session
.
getRemote
().
sendStringByFuture
(
sampleMsg
).
get
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录