简体   繁体   English

编年史队列复制错误:收到主机 ID 的处理程序:1,我的主机 ID 是:2 这可能是配置错误

[英]Chronicle-queue replication error: Received a handler for host ID: 1, my host ID is: 2 this is probably a configuration error

I am currently testing and learning chronicle-queue enterprise replication using the documentation below:我目前正在使用以下文档测试和学习编年史队列企业复制:

https://github.com/OpenHFT/Chronicle-Queue/blob/ea/docs/replication.adoc#the-mechanics-of-chronicle-queue-replication https://github.com/OpenHFT/Chronicle-Queue/blob/ea/docs/replication.adoc#the-mechanics-of-chronicle-queue-replication

https://github.com/OpenHFT/Chronicle-Queue/blob/ea/docs/queue-replication-message-protocol-overview.adoc#sinkreplicationhandler https://github.com/OpenHFT/Chronicle-Queue/blob/ea/docs/queue-replication-message-protocol-overview.adoc#sinkreplicationhandler

However, I am getting the error below:但是,我收到以下错误:

java.lang.IllegalArgumentException : Received a handler for host ID: 1, my host ID is: 2 this is probably a configuration error. java.lang.IllegalArgumentException :收到主机 ID 的处理程序:1,我的主机 ID 是:2 这可能是配置错误。

My replication configuration is as below, what am I missing?我的复制配置如下,我缺少什么? Below is my replication configuration.下面是我的复制配置。

!ChronicleQueueReplicationCfg {
  eventId: "",
  serviceId: "",
  replicaSets: {
    global: !!set [
      host1,
      host2
    ]
  },
  allowSinkToSource: false,
  context: {
    networkContextFactory: !software.chronicle.enterprise.queue.replication.QueueClusterNetworkContext$Factory INSTANCE,
    heartbeatTimeoutMs: 500000,
    heartbeatIntervalMs: 300000,
    pauserSupplier: !PauserMode busy,
    replicationPauserSupplier: !!null "",
    affinityCPU: !!null "",
    wireType: BINARY_LIGHT,
    localIdentifier: 1,
    localName: host1,
    serverThreadingStrategy: SINGLE_THREADED,
    retryInterval: 1000,
    procPrefix: !!null "",
    baseSourcePath: source,
    baseSinkPath: replica,
    backfillTimeoutListener: !software.chronicle.enterprise.queue.replication.NoopBackfillListener INSTANCE,
    tcpBias: !!null ""
  },
  hosts: {
    host1: { hostId: 1, tcpBufferSize: 0, connectUri: "localhost:5001" },
    host2: { hostId: 2, tcpBufferSize: 0, connectUri: "localhost:5002" }
  },
  queues: {
    queue1: {
      name: queue1,
      path: queue1,
      replicaSets: [
        global
      ],
      masterId: 1,
      waitForSinks: 0
    }
  }
}

chronicle-queue-enterprise-all-2.23ea26编年史队列企业所有 2.23ea26

I'm posting this as an answer since I need to share some configuration.我将其发布为答案,因为我需要共享一些配置。

Your configuration seems correct, however, there might be an issue with the code that is utilizing it.您的配置似乎正确,但是,使用它的代码可能存在问题。 Within chronicle-queue-enterprise there are many tests that showcase how to use the replication features.chronicle-queue-enterprise中有许多测试展示了如何使用复制功能。

The simplest one you can apply your configuration to is called ReplicationTest.shouldReplicate .您可以应用配置的最简单的方法称为ReplicationTest.shouldReplicate This test simply writes two messages to the source and verifies that it can read the same messages from the sink (which would mean that replication worked).该测试只是将两条消息写入source并验证它是否可以从接收sink读取相同的消息(这意味着复制工作)。

I applied your configuration in this test with minor changes.我在此测试中应用了您的配置,并进行了细微更改。

!ChronicleQueueReplicationCfg {
  eventId: "",
  serviceId: "",
  replicaSets: {
    global: !!set [
      host1,
      host2
    ]
  },
  allowSinkToSource: false,
  context: {
    networkContextFactory: !software.chronicle.enterprise.queue.replication.QueueClusterNetworkContext$Factory INSTANCE,
    heartbeatTimeoutMs: 500000,
    heartbeatIntervalMs: 300000,
    pauserSupplier: !PauserMode busy,
    replicationPauserSupplier: !!null "",
    affinityCPU: !!null "",
    wireType: BINARY_LIGHT,
    localIdentifier: 1,
    localName: host1,
    serverThreadingStrategy: SINGLE_THREADED,
    retryInterval: 1000,
    procPrefix: !!null "",
    baseSourcePath: "replica/source",
    baseSinkPath: "replica/sink$hostId",
    backfillTimeoutListener: !software.chronicle.enterprise.queue.replication.NoopBackfillListener INSTANCE,
    tcpBias: !!null ""
  },
  hosts: {
    host1: { hostId: 1, tcpBufferSize: 0, connectUri: host.port1 },
    host2: { hostId: 2, tcpBufferSize: 0, connectUri: host.port2 }
  },
  queues: {
    queue1: {
      name: queue1,
      path: queue1,
      acknowledge: true,
      allowUnknownSinks: true,
      replicaSets: [
        global
      ],
      masterId: 1,
      waitForSinks: 0
    }
  }
}

I could not replicate the same IllegalArgumentException you were having, please share the code that uses your configuration and I'm sure we will find out what's wrong and update this answer.我无法复制您遇到的相同IllegalArgumentException ,请分享使用您的配置的代码,我相信我们会找出问题所在并更新此答案。

I am going to answer my own question based on the feedback given.我将根据给出的反馈回答我自己的问题。 The issue was caused by me passing the same instance of the ChronicleQueueReplicationCfg to each side of the replication when I was creating the ReplicatedQueue objects.该问题是由于我在创建 ReplicatedQueue 对象时将相同的 ChronicleQueueReplicationCfg 实例传递到复制的每一侧引起的。 I had missed that the ChronicleQueueReplicationCfg objects were stateful when the replication starts up.我错过了 ChronicleQueueReplicationCfg 对象在复制启动时是有状态的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM