Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
pulsar
提交
bd3fa562
pulsar
项目概览
apache
/
pulsar
通知
129
Star
40
Fork
3
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Wiki
1
Wiki
分析
仓库
DevOps
项目成员
Pages
pulsar
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
Wiki
1
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
体验新版 GitCode,发现更多精彩内容 >>
提交
bd3fa562
编写于
5月 12, 2017
作者:
J
jai1
提交者:
Matteo Merli
5月 12, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Removing blockIfQueueFull option from WebSocket Proxy Server (#396)
上级
7badf1ab
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
22 addition
and
11 deletion
+22
-11
pulsar-websocket/src/main/java/com/yahoo/pulsar/websocket/ProducerHandler.java
...main/java/com/yahoo/pulsar/websocket/ProducerHandler.java
+3
-4
pulsar-websocket/src/main/java/com/yahoo/pulsar/websocket/WebSocketService.java
...ain/java/com/yahoo/pulsar/websocket/WebSocketService.java
+6
-4
pulsar-websocket/src/main/java/com/yahoo/pulsar/websocket/service/ProxyServer.java
.../java/com/yahoo/pulsar/websocket/service/ProxyServer.java
+4
-3
pulsar-websocket/src/main/java/com/yahoo/pulsar/websocket/service/WebSocketProxyConfiguration.java
...pulsar/websocket/service/WebSocketProxyConfiguration.java
+9
-0
未找到文件。
pulsar-websocket/src/main/java/com/yahoo/pulsar/websocket/ProducerHandler.java
浏览文件 @
bd3fa562
...
...
@@ -138,10 +138,9 @@ public class ProducerHandler extends AbstractWebSocketHandler {
private
ProducerConfiguration
getProducerConfiguration
()
{
ProducerConfiguration
conf
=
new
ProducerConfiguration
();
if
(
queryParams
.
containsKey
(
"blockIfQueueFull"
))
{
conf
.
setBlockIfQueueFull
(
Boolean
.
parseBoolean
(
queryParams
.
get
(
"blockIfQueueFull"
)));
}
// Set to false to prevent the server thread from being blocked if a lot of messages are pending.
conf
.
setBlockIfQueueFull
(
false
);
if
(
queryParams
.
containsKey
(
"sendTimeoutMillis"
))
{
conf
.
setSendTimeout
(
Integer
.
parseInt
(
queryParams
.
get
(
"sendTimeoutMillis"
)),
TimeUnit
.
MILLISECONDS
);
}
...
...
pulsar-websocket/src/main/java/com/yahoo/pulsar/websocket/WebSocketService.java
浏览文件 @
bd3fa562
...
...
@@ -60,9 +60,10 @@ public class WebSocketService implements Closeable {
AuthorizationManager
authorizationManager
;
PulsarClient
pulsarClient
;
private
final
ScheduledExecutorService
executor
=
Executors
.
newScheduledThreadPool
(
20
,
new
DefaultThreadFactory
(
"pulsar-websocket"
));
private
final
OrderedSafeExecutor
orderedExecutor
=
new
OrderedSafeExecutor
(
8
,
"pulsar-websocket-ordered"
);
private
final
ScheduledExecutorService
executor
=
Executors
.
newScheduledThreadPool
(
WebSocketProxyConfiguration
.
WEBSOCKET_SERVICE_THREADS
,
new
DefaultThreadFactory
(
"pulsar-websocket"
));
private
final
OrderedSafeExecutor
orderedExecutor
=
new
OrderedSafeExecutor
(
WebSocketProxyConfiguration
.
GLOBAL_ZK_THREADS
,
"pulsar-websocket-ordered"
);
private
GlobalZooKeeperCache
globalZkCache
;
private
ZooKeeperClientFactory
zkClientFactory
;
private
ServiceConfiguration
config
;
...
...
@@ -162,6 +163,7 @@ public class WebSocketService implements Closeable {
clientConf
.
setUseTls
(
config
.
isTlsEnabled
());
clientConf
.
setTlsAllowInsecureConnection
(
config
.
isTlsAllowInsecureConnection
());
clientConf
.
setTlsTrustCertsFilePath
(
config
.
getTlsTrustCertsFilePath
());
clientConf
.
setIoThreads
(
WebSocketProxyConfiguration
.
PULSAR_CLIENT_IO_THREADS
);
if
(
config
.
isAuthenticationEnabled
())
{
clientConf
.
setAuthentication
(
config
.
getBrokerClientAuthenticationPlugin
(),
config
.
getBrokerClientAuthenticationParameters
());
...
...
@@ -189,7 +191,7 @@ public class WebSocketService implements Closeable {
return
null
;
}
}
private
static
ServiceConfiguration
createServiceConfiguration
(
WebSocketProxyConfiguration
config
)
{
ServiceConfiguration
serviceConfig
=
new
ServiceConfiguration
();
serviceConfig
.
setClusterName
(
config
.
getClusterName
());
...
...
pulsar-websocket/src/main/java/com/yahoo/pulsar/websocket/service/ProxyServer.java
浏览文件 @
bd3fa562
...
...
@@ -50,15 +50,15 @@ import com.yahoo.pulsar.common.util.SecurityUtility;
import
io.netty.util.concurrent.DefaultThreadFactory
;
public
class
ProxyServer
{
private
final
ExecutorService
executorService
;
private
final
Server
server
;
private
final
List
<
Handler
>
handlers
=
Lists
.
newArrayList
();
private
final
WebSocketProxyConfiguration
conf
;
private
final
ExecutorService
executorService
;
public
ProxyServer
(
WebSocketProxyConfiguration
config
)
throws
PulsarClientException
,
MalformedURLException
,
PulsarServerException
{
this
.
conf
=
config
;
this
.
executorService
=
Executors
.
newFixedThreadPool
(
2
*
Runtime
.
getRuntime
().
availableProcessors
()
,
executorService
=
Executors
.
newFixedThreadPool
(
WebSocketProxyConfiguration
.
PROXY_SERVER_EXECUTOR_THREADS
,
new
DefaultThreadFactory
(
"pulsar-websocket-web"
));
this
.
server
=
new
Server
(
new
ExecutorThreadPool
(
executorService
));
List
<
ServerConnector
>
connectors
=
new
ArrayList
<>();
...
...
@@ -129,6 +129,7 @@ public class ProxyServer {
public
void
stop
()
throws
Exception
{
server
.
stop
();
executorService
.
shutdown
();
}
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
ProxyServer
.
class
);
...
...
pulsar-websocket/src/main/java/com/yahoo/pulsar/websocket/service/WebSocketProxyConfiguration.java
浏览文件 @
bd3fa562
...
...
@@ -24,6 +24,15 @@ import com.yahoo.pulsar.common.configuration.PulsarConfiguration;
public
class
WebSocketProxyConfiguration
implements
PulsarConfiguration
{
// Number of threads used by Proxy server
public
static
final
int
PROXY_SERVER_EXECUTOR_THREADS
=
2
*
Runtime
.
getRuntime
().
availableProcessors
();
// Number of threads used by Websocket service
public
static
final
int
WEBSOCKET_SERVICE_THREADS
=
20
;
// Number of threads used by Global ZK
public
static
final
int
GLOBAL_ZK_THREADS
=
8
;
// Number of IO threads in Pulsar Client
public
static
final
int
PULSAR_CLIENT_IO_THREADS
=
Runtime
.
getRuntime
().
availableProcessors
();
// Name of the cluster to which this broker belongs to
@FieldContext
(
required
=
true
)
private
String
clusterName
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录