Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
pulsar
提交
18332962
pulsar
项目概览
apache
/
pulsar
通知
129
Star
40
Fork
3
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Wiki
1
Wiki
分析
仓库
DevOps
项目成员
Pages
pulsar
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
Wiki
1
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
体验新版 GitCode,发现更多精彩内容 >>
提交
18332962
编写于
10月 17, 2016
作者:
R
Rajan
提交者:
Matteo Merli
10月 17, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
avoid synchronization for method that blocks while fetching zero-queue message (#61)
上级
5b7b9109
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
19 addition
and
7 deletion
+19
-7
pulsar-client/src/main/java/com/yahoo/pulsar/client/impl/ConsumerImpl.java
.../main/java/com/yahoo/pulsar/client/impl/ConsumerImpl.java
+19
-7
未找到文件。
pulsar-client/src/main/java/com/yahoo/pulsar/client/impl/ConsumerImpl.java
浏览文件 @
18332962
...
...
@@ -23,8 +23,6 @@ import java.io.IOException;
import
java.util.BitSet
;
import
java.util.NavigableMap
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentMap
;
import
java.util.concurrent.ConcurrentSkipListMap
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.TimeUnit
;
...
...
@@ -60,7 +58,6 @@ import io.netty.util.concurrent.GenericFutureListener;
import
static
com
.
yahoo
.
pulsar
.
common
.
api
.
Commands
.
readChecksum
;
import
static
com
.
yahoo
.
pulsar
.
checksum
.
utils
.
Crc32cChecksum
.
computeChecksum
;
import
static
com
.
yahoo
.
pulsar
.
common
.
api
.
Commands
.
hasChecksum
;
import
static
com
.
yahoo
.
pulsar
.
common
.
api
.
Commands
.
readChecksum
;
public
class
ConsumerImpl
extends
ConsumerBase
{
...
...
@@ -80,6 +77,8 @@ public class ConsumerImpl extends ConsumerBase {
private
final
ReadWriteLock
lock
=
new
ReentrantReadWriteLock
();
private
final
ReadWriteLock
zeroQueueLock
;
private
final
ConcurrentSkipListMap
<
MessageIdImpl
,
BitSet
>
batchMessageAckTracker
;
private
final
ConsumerStats
stats
;
...
...
@@ -104,6 +103,11 @@ public class ConsumerImpl extends ConsumerBase {
}
else
{
stats
=
ConsumerStats
.
CONSUMER_STATS_DISABLED
;
}
if
(
conf
.
getReceiverQueueSize
()
<=
1
)
{
zeroQueueLock
=
new
ReentrantReadWriteLock
();
}
else
{
zeroQueueLock
=
null
;
}
grabCnx
();
}
...
...
@@ -142,7 +146,13 @@ public class ConsumerImpl extends ConsumerBase {
@Override
protected
Message
internalReceive
()
throws
PulsarClientException
{
if
(
conf
.
getReceiverQueueSize
()
==
0
)
{
checkArgument
(
zeroQueueLock
!=
null
,
"Receiver queue size can't be modified"
);
zeroQueueLock
.
writeLock
().
lock
();
try
{
return
fetchSingleMessageFromBroker
();
}
finally
{
zeroQueueLock
.
writeLock
().
unlock
();
}
}
Message
message
;
try
{
...
...
@@ -190,7 +200,7 @@ public class ConsumerImpl extends ConsumerBase {
return
result
;
}
private
synchronized
Message
fetchSingleMessageFromBroker
()
throws
PulsarClientException
{
private
Message
fetchSingleMessageFromBroker
()
throws
PulsarClientException
{
checkArgument
(
conf
.
getReceiverQueueSize
()
==
0
);
// Just being cautious
...
...
@@ -203,9 +213,11 @@ public class ConsumerImpl extends ConsumerBase {
try
{
// is cnx is null or if the connection breaks the connectionOpened function will send the flow again
waitingOnReceiveForZeroQueueSize
=
true
;
synchronized
(
this
)
{
if
(
isConnected
())
{
receiveMessages
(
cnx
(),
1
);
}
}
do
{
message
=
incomingMessages
.
take
();
ClientCnx
msgCnx
=
((
MessageImpl
)
message
).
getCnx
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录