Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
pulsar
提交
5d14788e
pulsar
项目概览
apache
/
pulsar
通知
129
Star
40
Fork
3
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Wiki
1
Wiki
分析
仓库
DevOps
项目成员
Pages
pulsar
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
Wiki
1
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
5d14788e
编写于
2月 20, 2018
作者:
J
Jai Asher
提交者:
jai1
2月 20, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix in ServerCnx to prevent using recycled commands (#1264)
上级
44fd8265
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
10 addition
and
10 deletion
+10
-10
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
...main/java/org/apache/pulsar/broker/service/ServerCnx.java
+10
-10
未找到文件。
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
浏览文件 @
5d14788e
...
...
@@ -209,7 +209,7 @@ public class ServerCnx extends PulsarHandler {
@Override
protected
void
handleLookup
(
CommandLookupTopic
lookup
)
{
final
long
requestId
=
lookup
.
getRequestId
();
final
boolean
authoritative
=
lookup
.
getAuthoritative
();
if
(
log
.
isDebugEnabled
())
{
log
.
debug
(
"[{}] Received Lookup from {} for {}"
,
lookup
.
getTopic
(),
remoteAddress
,
requestId
);
}
...
...
@@ -254,9 +254,9 @@ public class ServerCnx extends PulsarHandler {
String
finalOriginalPrincipal
=
originalPrincipal
;
isProxyAuthorizedFuture
.
thenApply
(
isProxyAuthorized
->
{
if
(
isProxyAuthorized
)
{
lookupDestinationAsync
(
getBrokerService
().
pulsar
(),
topicName
,
lookup
.
getAuthoritative
()
,
lookupDestinationAsync
(
getBrokerService
().
pulsar
(),
topicName
,
authoritative
,
finalOriginalPrincipal
!=
null
?
finalOriginalPrincipal
:
authRole
,
authenticationData
,
lookup
.
getRequestId
()
).
handle
((
lookupResponse
,
ex
)
->
{
requestId
).
handle
((
lookupResponse
,
ex
)
->
{
if
(
ex
==
null
)
{
ctx
.
writeAndFlush
(
lookupResponse
);
}
else
{
...
...
@@ -550,7 +550,7 @@ public class ServerCnx extends PulsarHandler {
subscribe
.
getStartMessageId
().
getLedgerId
(),
subscribe
.
getStartMessageId
().
getEntryId
(),
subscribe
.
getStartMessageId
().
getPartition
(),
subscribe
.
getStartMessageId
().
getBatchIndex
())
:
null
;
final
String
subscription
=
subscribe
.
getSubscription
();
final
int
priorityLevel
=
subscribe
.
hasPriorityLevel
()
?
subscribe
.
getPriorityLevel
()
:
0
;
final
boolean
readCompacted
=
subscribe
.
getReadCompacted
();
final
Map
<
String
,
String
>
metadata
=
CommandUtils
.
metadataFromCommand
(
subscribe
);
...
...
@@ -568,7 +568,7 @@ public class ServerCnx extends PulsarHandler {
if
(
service
.
isAuthorizationEnabled
())
{
authorizationFuture
=
service
.
getAuthorizationService
().
canConsumeAsync
(
topicName
,
originalPrincipal
!=
null
?
originalPrincipal
:
authRole
,
authenticationData
,
subscri
be
.
getSubscription
()
);
subscri
ption
);
}
else
{
authorizationFuture
=
CompletableFuture
.
completedFuture
(
true
);
}
...
...
@@ -995,13 +995,13 @@ public class ServerCnx extends PulsarHandler {
@Override
protected
void
handleSeek
(
CommandSeek
seek
)
{
checkArgument
(
state
==
State
.
Connected
);
final
long
requestId
=
seek
.
getRequestId
();
CompletableFuture
<
Consumer
>
consumerFuture
=
consumers
.
get
(
seek
.
getConsumerId
());
// Currently only seeking on a message id is supported
if
(!
seek
.
hasMessageId
())
{
ctx
.
writeAndFlush
(
Commands
.
newError
(
seek
.
getRequestId
()
,
ServerError
.
MetadataError
,
"Message id was not present"
));
Commands
.
newError
(
requestId
,
ServerError
.
MetadataError
,
"Message id was not present"
));
return
;
}
...
...
@@ -1011,7 +1011,7 @@ public class ServerCnx extends PulsarHandler {
MessageIdData
msgIdData
=
seek
.
getMessageId
();
Position
position
=
new
PositionImpl
(
msgIdData
.
getLedgerId
(),
msgIdData
.
getEntryId
());
long
requestId
=
seek
.
getRequestId
();
subscription
.
resetCursor
(
position
).
thenRun
(()
->
{
log
.
info
(
"[{}] [{}][{}] Reset subscription to message id {}"
,
remoteAddress
,
...
...
@@ -1019,12 +1019,12 @@ public class ServerCnx extends PulsarHandler {
ctx
.
writeAndFlush
(
Commands
.
newSuccess
(
requestId
));
}).
exceptionally
(
ex
->
{
log
.
warn
(
"[{}][{}] Failed to reset subscription: {}"
,
remoteAddress
,
subscription
,
ex
.
getMessage
(),
ex
);
ctx
.
writeAndFlush
(
Commands
.
newError
(
seek
.
getRequestId
()
,
ServerError
.
UnknownError
,
ctx
.
writeAndFlush
(
Commands
.
newError
(
requestId
,
ServerError
.
UnknownError
,
"Error when resetting subscription: "
+
ex
.
getCause
().
getMessage
()));
return
null
;
});
}
else
{
ctx
.
writeAndFlush
(
Commands
.
newError
(
seek
.
getRequestId
()
,
ServerError
.
MetadataError
,
"Consumer not found"
));
ctx
.
writeAndFlush
(
Commands
.
newError
(
requestId
,
ServerError
.
MetadataError
,
"Consumer not found"
));
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录