Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
pulsar
提交
02f9fd3e
pulsar
项目概览
apache
/
pulsar
通知
129
Star
40
Fork
3
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Wiki
1
Wiki
分析
仓库
DevOps
项目成员
Pages
pulsar
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
Wiki
1
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
02f9fd3e
编写于
8月 11, 2019
作者:
R
Rajan Dhabalia
提交者:
Sijie Guo
8月 12, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[pulsar-client] Fix broken replication msg to specific cluster (#4930)
上级
bdfefc72
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
42 addition
and
0 deletion
+42
-0
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ReplicatorTest.java
...java/org/apache/pulsar/broker/service/ReplicatorTest.java
+39
-0
pulsar-common/src/main/java/org/apache/pulsar/common/protocol/Commands.java
...main/java/org/apache/pulsar/common/protocol/Commands.java
+3
-0
未找到文件。
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ReplicatorTest.java
浏览文件 @
02f9fd3e
...
...
@@ -54,12 +54,14 @@ import org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl;
import
org.apache.pulsar.broker.service.BrokerServiceException.NamingException
;
import
org.apache.pulsar.broker.service.persistent.PersistentReplicator
;
import
org.apache.pulsar.broker.service.persistent.PersistentTopic
;
import
org.apache.pulsar.client.api.Message
;
import
org.apache.pulsar.client.api.MessageRoutingMode
;
import
org.apache.pulsar.client.api.Producer
;
import
org.apache.pulsar.client.api.PulsarClient
;
import
org.apache.pulsar.client.api.RawMessage
;
import
org.apache.pulsar.client.api.RawReader
;
import
org.apache.pulsar.client.api.Schema
;
import
org.apache.pulsar.client.api.TypedMessageBuilder
;
import
org.apache.pulsar.client.impl.ProducerImpl
;
import
org.apache.pulsar.client.impl.PulsarClientImpl
;
import
org.apache.pulsar.client.impl.conf.ProducerConfigurationData
;
...
...
@@ -812,6 +814,43 @@ public class ReplicatorTest extends ReplicatorTestBase {
}
@Test
public
void
testReplicatedCluster
()
throws
Exception
{
log
.
info
(
"--- Starting ReplicatorTest::testReplicatedCluster ---"
);
final
String
namespace
=
"pulsar/global/repl"
;
final
String
topicName
=
String
.
format
(
"persistent://%s/topic1"
,
namespace
);
admin1
.
namespaces
().
createNamespace
(
namespace
);
admin1
.
namespaces
().
setNamespaceReplicationClusters
(
namespace
,
Sets
.
newHashSet
(
"r1"
,
"r2"
,
"r3"
));
admin1
.
topics
().
createPartitionedTopic
(
topicName
,
4
);
PulsarClient
client1
=
PulsarClient
.
builder
().
serviceUrl
(
url1
.
toString
()).
statsInterval
(
0
,
TimeUnit
.
SECONDS
)
.
build
();
PulsarClient
client2
=
PulsarClient
.
builder
().
serviceUrl
(
url2
.
toString
()).
statsInterval
(
0
,
TimeUnit
.
SECONDS
)
.
build
();
Producer
<
byte
[]>
producer1
=
client1
.
newProducer
().
topic
(
topicName
).
create
();
org
.
apache
.
pulsar
.
client
.
api
.
Consumer
<
byte
[]>
consumer1
=
client1
.
newConsumer
().
topic
(
topicName
).
subscriptionName
(
"s1"
).
subscribe
();
org
.
apache
.
pulsar
.
client
.
api
.
Consumer
<
byte
[]>
consumer2
=
client2
.
newConsumer
().
topic
(
topicName
).
subscriptionName
(
"s1"
).
subscribe
();
byte
[]
value
=
"test"
.
getBytes
();
// publish message local only
TypedMessageBuilder
<
byte
[]>
msg
=
producer1
.
newMessage
().
replicationClusters
(
Lists
.
newArrayList
(
"r1"
)).
value
(
value
);
msg
.
send
();
assertEquals
(
consumer1
.
receive
().
getValue
(),
value
);
Message
<
byte
[]>
msg2
=
consumer2
.
receive
(
1
,
TimeUnit
.
SECONDS
);
if
(
msg2
!=
null
)
{
fail
(
"msg should have not been replicated to remote cluster"
);
}
consumer1
.
close
();
consumer2
.
close
();
producer1
.
close
();
}
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
ReplicatorTest
.
class
);
}
pulsar-common/src/main/java/org/apache/pulsar/common/protocol/Commands.java
浏览文件 @
02f9fd3e
...
...
@@ -1420,6 +1420,9 @@ public class Commands {
if
(
builder
.
hasReplicatedFrom
())
{
messageMetadata
.
setReplicatedFrom
(
builder
.
getReplicatedFrom
());
}
if
(
builder
.
getReplicateToCount
()
>
0
)
{
messageMetadata
.
addAllReplicateTo
(
builder
.
getReplicateToList
());
}
if
(
builder
.
hasSchemaVersion
())
{
messageMetadata
.
setSchemaVersion
(
builder
.
getSchemaVersion
());
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录