Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

support multiple listeners with multiple endpoints #742

Merged

Conversation

wangjialing218
Copy link
Contributor

Fixes #669
Fixes #574

To support multiple listeners with multiple protocols, we need to set follow configration, and deprecated kafkaAdvertisedListeners and kafkaListenerName.

kafkaListeners=internal:https://0.0.0.0:9092,internal_ssl:https://0.0.0.0:9093,external:https://0.0.0.0:19002,external_ssl:0.0.0.0:19003
kafkaProtocalMap=internal:PLAINTEXT,internal_ssl:SSL,external:PLAINTEXT,external_ssl:SSL
advertisedListeners={pulsar's listeners},internal:pulsar//192.168.1.10:9092,internal_ssl:pulsar//192.168.1.10:9093,external:pulsar//172.16.1.10:19002,external_ssl:pulsar:https://172.16.1.10:19003

  1. Define the listenerNames and port of each listenerName in kafkaListeners
  2. Define the listenerNames and protocol of each listenerName in kafkaProtocalMap
  3. Add listenerNames and advertised address of each listenerName into advertisedListeners

Kafka client should connect to the port of the listenerName according to KIP-103.

@wangjialing218
Copy link
Contributor Author

@BewareMyPower please have a look.
I'm not sure if KopBrokerLookupManager.findBroker need change, it seems only used in TransactionMarkerChannelManager. If the lookup result here is only used in kop (not for kafka client), we could just use buildin client to do lookup.

@BewareMyPower BewareMyPower added the type/feature Indicates new functionality label Sep 26, 2021
@BewareMyPower
Copy link
Collaborator

Could you solve the conflicts?

@BewareMyPower BewareMyPower added the doc-required This pr needs a document label Sep 26, 2021
@BewareMyPower
Copy link
Collaborator

I'm not sure if KopBrokerLookupManager.findBroker need change, it seems only used in TransactionMarkerChannelManager. If the lookup result here is only used in kop (not for kafka client), we could just use buildin client to do lookup.

Regarding to this question, I think we can ignore the transaction part in this PR.

@BewareMyPower BewareMyPower merged commit 49fb4df into streamnative:master Sep 26, 2021
BewareMyPower added a commit that referenced this pull request Sep 30, 2021
…760)

### Motivation

#690 supports non-partitioned topics and #742 supports multiple listeners and marks some configs as deprecated, so the current documents are outdated. 

### Modification
Even if KoP supports non-partitioned topics now, it's still better to configure `allowAutoTopicCreationType` with `partitioned` by default. This PR modified the explanation for the reason.

This PR also adds docs for how to enable multiple listeners and updates the related configuration docs.

In addition, #742 marks `kafkaListenerName` as deprecated, but it also makes this config not work anymore. So this PR removes the config and related tests.
BewareMyPower pushed a commit that referenced this pull request Sep 30, 2021
Fixes #669
Fixes #574

To support multiple listeners with multiple protocols, we need to set follow configration, and deprecated `kafkaAdvertisedListeners` and `kafkaListenerName`.

> kafkaListeners=internal:https://0.0.0.0:9092,internal_ssl:https://0.0.0.0:9093,external:https://0.0.0.0:19002,external_ssl:0.0.0.0:19003
> kafkaProtocalMap=internal:PLAINTEXT,internal_ssl:SSL,external:PLAINTEXT,external_ssl:SSL
> advertisedListeners={pulsar's listeners},internal:pulsar//192.168.1.10:9092,internal_ssl:pulsar//192.168.1.10:9093,external:pulsar//172.16.1.10:19002,external_ssl:pulsar:https://172.16.1.10:19003

1. Define the listenerNames and port of each listenerName in `kafkaListeners`
2. Define the listenerNames and protocol of each listenerName in `kafkaProtocalMap`
3. Add listenerNames and advertised address of each listenerName into `advertisedListeners`

Kafka client should connect to the port of the listenerName according to KIP-103.

Co-authored-by: wangjialing <[email protected]>
BewareMyPower added a commit that referenced this pull request Sep 30, 2021
…760)

### Motivation

#690 supports non-partitioned topics and #742 supports multiple listeners and marks some configs as deprecated, so the current documents are outdated. 

### Modification
Even if KoP supports non-partitioned topics now, it's still better to configure `allowAutoTopicCreationType` with `partitioned` by default. This PR modified the explanation for the reason.

This PR also adds docs for how to enable multiple listeners and updates the related configuration docs.

In addition, #742 marks `kafkaListenerName` as deprecated, but it also makes this config not work anymore. So this PR removes the config and related tests.
BewareMyPower added a commit that referenced this pull request Oct 29, 2021
…teners (#864)

Fixes #818

### Motivation

#742 adds the multiple listeners support for KoP 2.8.x. However, there're some flaws. 

First, the KoP advertised listeners must be added to `advertisedListeners` config. This config should be treated as the advertised listeners for broker, not protocol handlers. What `KafkaProtocolHandler#getProtocolDataToAdvertise` returns is not used though it has been written to ZK. It also makes `kafkaAdvertisedListeners` meaningless and it was marked as deprecated.

### Modification

Benefit by [PIP 95](apache/pulsar#12040), Pulsar client doesn't need to configure listener name for topic lookup. So this PR simplifies the implementation of `LookupClient` by using a shared `PulsarClient` without configuring listener name.

Then this PR uses the `MetadataStoreCacheLoader` introduced from #820 to get the `kafkaAdvertisedListeners` from ZK. Since it has already been cached, this PR removes the `KOP_ADDRESS_CACHE`.

To verify the feature, this PR adds a test `testMetadataRequestForMultiListeners`. The KoP config is like

```properties
kafkaListeners=PLAINTEXT:https://0.0.0.0:<port1>,GW:https://0.0.0.0:<port2>
kafkaProtocolMap=PLAINTEXT:PLAINTEXT,GW:PLAINTEXT
kafkaAdvertisedListeners=PLAINTEXT:https://192.168.0.1:<port3>,GW:https://192.168.0.1:<port4>
```

And verify that each `KafkaRequestHandler` can handle the METADATA requests well.
BewareMyPower added a commit that referenced this pull request Oct 29, 2021
…teners (#864)

Fixes #818

### Motivation

#742 adds the multiple listeners support for KoP 2.8.x. However, there're some flaws. 

First, the KoP advertised listeners must be added to `advertisedListeners` config. This config should be treated as the advertised listeners for broker, not protocol handlers. What `KafkaProtocolHandler#getProtocolDataToAdvertise` returns is not used though it has been written to ZK. It also makes `kafkaAdvertisedListeners` meaningless and it was marked as deprecated.

### Modification

Benefit by [PIP 95](apache/pulsar#12040), Pulsar client doesn't need to configure listener name for topic lookup. So this PR simplifies the implementation of `LookupClient` by using a shared `PulsarClient` without configuring listener name.

Then this PR uses the `MetadataStoreCacheLoader` introduced from #820 to get the `kafkaAdvertisedListeners` from ZK. Since it has already been cached, this PR removes the `KOP_ADDRESS_CACHE`.

To verify the feature, this PR adds a test `testMetadataRequestForMultiListeners`. The KoP config is like

```properties
kafkaListeners=PLAINTEXT:https://0.0.0.0:<port1>,GW:https://0.0.0.0:<port2>
kafkaProtocolMap=PLAINTEXT:PLAINTEXT,GW:PLAINTEXT
kafkaAdvertisedListeners=PLAINTEXT:https://192.168.0.1:<port3>,GW:https://192.168.0.1:<port4>
```

And verify that each `KafkaRequestHandler` can handle the METADATA requests well.
gaozhangmin pushed a commit to gaozhangmin/kop that referenced this pull request Nov 29, 2021
…teners (streamnative#864)

Fixes streamnative#818

### Motivation

streamnative#742 adds the multiple listeners support for KoP 2.8.x. However, there're some flaws.

First, the KoP advertised listeners must be added to `advertisedListeners` config. This config should be treated as the advertised listeners for broker, not protocol handlers. What `KafkaProtocolHandler#getProtocolDataToAdvertise` returns is not used though it has been written to ZK. It also makes `kafkaAdvertisedListeners` meaningless and it was marked as deprecated.

### Modification

Benefit by [PIP 95](apache/pulsar#12040), Pulsar client doesn't need to configure listener name for topic lookup. So this PR simplifies the implementation of `LookupClient` by using a shared `PulsarClient` without configuring listener name.

Then this PR uses the `MetadataStoreCacheLoader` introduced from streamnative#820 to get the `kafkaAdvertisedListeners` from ZK. Since it has already been cached, this PR removes the `KOP_ADDRESS_CACHE`.

To verify the feature, this PR adds a test `testMetadataRequestForMultiListeners`. The KoP config is like

```properties
kafkaListeners=PLAINTEXT:https://0.0.0.0:<port1>,GW:https://0.0.0.0:<port2>
kafkaProtocolMap=PLAINTEXT:PLAINTEXT,GW:PLAINTEXT
kafkaAdvertisedListeners=PLAINTEXT:https://192.168.0.1:<port3>,GW:https://192.168.0.1:<port4>
```

And verify that each `KafkaRequestHandler` can handle the METADATA requests well.

(cherry picked from commit 50699b3)
@BewareMyPower BewareMyPower removed the doc-required This pr needs a document label Jan 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/feature Indicates new functionality
Projects
None yet
2 participants