You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by "Pil0tXia (via GitHub)" <gi...@apache.org> on 2023/09/07 12:13:29 UTC
[PR] [ISSUE #4396] Realize the admin function for Kafka stroage-plugin (eventmesh)
Pil0tXia opened a new pull request, #4438:
URL: https://github.com/apache/eventmesh/pull/4438
<!--
### Contribution Checklist
- Name the pull request in the form "[ISSUE #XXXX] Title of the pull request",
where *XXXX* should be replaced by the actual issue number.
Skip *[ISSUE #XXXX]* if there is no associated github issue for this pull request.
- Fill out the template below to describe the changes contributed by the pull request.
That will give reviewers the context they need to do the review.
- Each pull request should address only one issue.
Please do not mix up code from multiple issues.
- Each commit in the pull request should have a meaningful commit message.
- Once all items of the checklist are addressed, remove the above text and this checklist,
leaving only the filled out template below.
(The sections below can be removed for hotfixes of typos)
-->
<!--
(If this PR fixes a GitHub issue, please add `Fixes #<XXX>` or `Closes #<XXX>`.)
-->
Fixes #4396.
### Motivation

### Modifications
- Supports configuring the number of partitions and ISR replicas to which the topic belongs.
- Has detailed error messages.
- Although `storage.admin` will be migrated to the `admin` module in the near future, this PR is already halfway done, so I finished it up.

### Documentation
- Does this pull request introduce a new feature? (yes / no)
- If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
- If a feature is not applicable for documentation, explain why?
- If a feature is not documented yet in this PR, please create a followup issue for adding the documentation
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org
Re: [PR] [ISSUE #4396] Realize the admin function for Kafka storage-plugin (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on PR #4438:
URL: https://github.com/apache/eventmesh/pull/4438#issuecomment-1711593786
Made a minor performance optimization by supporting topic batch listing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4396] Realize the admin function for Kafka storage-plugin (eventmesh)
Posted by "fabian4 (via GitHub)" <gi...@apache.org>.
fabian4 commented on code in PR #4438:
URL: https://github.com/apache/eventmesh/pull/4438#discussion_r1319405280
##########
eventmesh-storage-plugin/eventmesh-storage-kafka/src/main/java/org/apache/eventmesh/storage/kafka/admin/KafkaAdmin.java:
##########
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.storage.kafka.admin;
+
+import static org.apache.eventmesh.storage.kafka.common.EventMeshConstants.DEFAULT_TIMEOUT_IN_SECONDS;
+
+import org.apache.eventmesh.api.admin.AbstractAdmin;
+import org.apache.eventmesh.api.admin.TopicProperties;
+import org.apache.eventmesh.common.config.ConfigService;
+import org.apache.eventmesh.storage.kafka.config.ClientConfiguration;
+
+import org.apache.kafka.clients.admin.Admin;
+import org.apache.kafka.clients.admin.DescribeTopicsResult;
+import org.apache.kafka.clients.admin.ListOffsetsResult.ListOffsetsResultInfo;
+import org.apache.kafka.clients.admin.NewTopic;
+import org.apache.kafka.clients.admin.OffsetSpec;
+import org.apache.kafka.clients.admin.TopicDescription;
+import org.apache.kafka.clients.consumer.ConsumerConfig;
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.TopicPartitionInfo;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class KafkaAdmin extends AbstractAdmin {
+
+ // properties for kafka admin client
+ private static final Properties kafkaProps = new Properties();
+
+ // properties for topic management
+ private static final Map<String, Integer> topicProps = new HashMap<>();
+
+ public KafkaAdmin() {
+ super(new AtomicBoolean(false));
+
+ ConfigService configService = ConfigService.getInstance();
+ ClientConfiguration clientConfiguration = configService.buildConfigInstance(ClientConfiguration.class);
+
+ kafkaProps.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, clientConfiguration.getNamesrvAddr());
+ topicProps.put("partitionNum", clientConfiguration.getPartitions());
+ topicProps.put("replicationFactorNum", (int) clientConfiguration.getReplicationFactors());
+ }
+
+ @Override
+ public List<TopicProperties> getTopic() {
+ try (Admin client = Admin.create(kafkaProps)) {
Review Comment:
Can we create the client at the start once for all, instead of we do it each time calling the api.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4396] Realize the admin function for Kafka storage-plugin (eventmesh)
Posted by "fabian4 (via GitHub)" <gi...@apache.org>.
fabian4 commented on code in PR #4438:
URL: https://github.com/apache/eventmesh/pull/4438#discussion_r1320958535
##########
eventmesh-storage-plugin/eventmesh-storage-kafka/src/main/java/org/apache/eventmesh/storage/kafka/admin/KafkaAdmin.java:
##########
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.storage.kafka.admin;
+
+import static org.apache.eventmesh.storage.kafka.common.EventMeshConstants.DEFAULT_TIMEOUT_IN_SECONDS;
+
+import org.apache.eventmesh.api.admin.AbstractAdmin;
+import org.apache.eventmesh.api.admin.TopicProperties;
+import org.apache.eventmesh.common.config.ConfigService;
+import org.apache.eventmesh.storage.kafka.config.ClientConfiguration;
+
+import org.apache.kafka.clients.admin.Admin;
+import org.apache.kafka.clients.admin.DescribeTopicsResult;
+import org.apache.kafka.clients.admin.ListOffsetsResult.ListOffsetsResultInfo;
+import org.apache.kafka.clients.admin.NewTopic;
+import org.apache.kafka.clients.admin.OffsetSpec;
+import org.apache.kafka.clients.admin.TopicDescription;
+import org.apache.kafka.clients.consumer.ConsumerConfig;
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.TopicPartitionInfo;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class KafkaAdmin extends AbstractAdmin {
+
+ // properties for kafka admin client
+ private static final Properties kafkaProps = new Properties();
+
+ // properties for topic management
+ private static final Map<String, Integer> topicProps = new HashMap<>();
+
+ public KafkaAdmin() {
+ super(new AtomicBoolean(false));
+
+ ConfigService configService = ConfigService.getInstance();
+ ClientConfiguration clientConfiguration = configService.buildConfigInstance(ClientConfiguration.class);
+
+ kafkaProps.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, clientConfiguration.getNamesrvAddr());
+ topicProps.put("partitionNum", clientConfiguration.getPartitions());
+ topicProps.put("replicationFactorNum", (int) clientConfiguration.getReplicationFactors());
+ }
+
+ @Override
+ public List<TopicProperties> getTopic() {
+ try (Admin client = Admin.create(kafkaProps)) {
Review Comment:
Will the client handle it itself just like the producer and consumer cause we don't need to create a new producer each time we send the message. Or just admin client will behavior like this?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4396] Realize the admin function for Kafka stroage-plugin (eventmesh)
Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4438:
URL: https://github.com/apache/eventmesh/pull/4438#discussion_r1319234589
##########
eventmesh-storage-plugin/eventmesh-storage-kafka/src/main/resources/kafka-client.properties:
##########
@@ -14,13 +14,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-#######################kafka-client##################
-eventMesh.server.kafka.namesrvAddr=127.0.0.1:9092;127.0.0.1:9092
+
+############################# EventMesh Kafka Client #############################
+
+eventMesh.server.kafka.namesrvAddr=localhost:9092;localhost:9092
eventMesh.server.kafka.cluster=DefaultCluster
eventMesh.server.kafka.accessKey=********
eventMesh.server.kafka.secretKey=********
+# You may see kafka.server.KafkaConfig for additional details and default values
Review Comment:
There are still many parameters in `KafkaConfig` that are not supported by eventmesh, is it appropriate to write comment this way?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4396] Realize the admin function for Kafka storage-plugin (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on code in PR #4438:
URL: https://github.com/apache/eventmesh/pull/4438#discussion_r1319272768
##########
eventmesh-storage-plugin/eventmesh-storage-kafka/src/main/resources/kafka-client.properties:
##########
@@ -14,13 +14,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-#######################kafka-client##################
-eventMesh.server.kafka.namesrvAddr=127.0.0.1:9092;127.0.0.1:9092
+
+############################# EventMesh Kafka Client #############################
+
+eventMesh.server.kafka.namesrvAddr=localhost:9092;localhost:9092
eventMesh.server.kafka.cluster=DefaultCluster
eventMesh.server.kafka.accessKey=********
eventMesh.server.kafka.secretKey=********
+# You may see kafka.server.KafkaConfig for additional details and default values
Review Comment:

This comment is written by someone else and it comes from Kafka:
https://github.com/apache/kafka/blob/54ab5b29e47fd3f399e0575df2f490a33f12804b/config/server.properties#L17-L18
I think the reason he wrote it that way is that this config file comes from kafka, and there are a lot of configuration items that are specific to kafka, not eventmesh, so you need to refer to the handling of configurations in kafka to understand the configurations further.
I have moved this comment to a more suitable place.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4396] Realize the admin function for Kafka storage-plugin (eventmesh)
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #4438:
URL: https://github.com/apache/eventmesh/pull/4438#issuecomment-1711419185
## [Codecov](https://app.codecov.io/gh/apache/eventmesh/pull/4438?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
> Merging [#4438](https://app.codecov.io/gh/apache/eventmesh/pull/4438?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (e16cd55) into [master](https://app.codecov.io/gh/apache/eventmesh/commit/50d6113cec1cdbbb38825625c5b89dffa62f604f?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (50d6113) will **decrease** coverage by `0.96%`.
> Report is 42 commits behind head on master.
> The diff coverage is `8.87%`.
> :exclamation: Current head e16cd55 differs from pull request most recent head 044242f. Consider uploading reports for the commit 044242f to get more accurate results
```diff
@@ Coverage Diff @@
## master #4438 +/- ##
============================================
- Coverage 17.85% 16.89% -0.96%
+ Complexity 1514 1458 -56
============================================
Files 602 621 +19
Lines 25518 25816 +298
Branches 2400 2397 -3
============================================
- Hits 4555 4362 -193
- Misses 20524 21016 +492
+ Partials 439 438 -1
```
| [Files Changed](https://app.codecov.io/gh/apache/eventmesh/pull/4438?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [...otocol/catalog/protos/QueryOperationsResponse.java](https://app.codecov.io/gh/apache/eventmesh/pull/4438?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZXZlbnRtZXNoL2NvbW1vbi9wcm90b2NvbC9jYXRhbG9nL3Byb3Rvcy9RdWVyeU9wZXJhdGlvbnNSZXNwb25zZS5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...mmon/protocol/catalog/protos/RegistryResponse.java](https://app.codecov.io/gh/apache/eventmesh/pull/4438?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZXZlbnRtZXNoL2NvbW1vbi9wcm90b2NvbC9jYXRhbG9nL3Byb3Rvcy9SZWdpc3RyeVJlc3BvbnNlLmphdmE=) | `0.00% <0.00%> (ø)` | |
| [...pache/eventmesh/connector/jdbc/CatalogChanges.java](https://app.codecov.io/gh/apache/eventmesh/pull/4438?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLWNvbm5lY3RvcnMvZXZlbnRtZXNoLWNvbm5lY3Rvci1qZGJjL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9ldmVudG1lc2gvY29ubmVjdG9yL2pkYmMvQ2F0YWxvZ0NoYW5nZXMuamF2YQ==) | `0.00% <0.00%> (ø)` | |
| [...ava/org/apache/eventmesh/connector/jdbc/Field.java](https://app.codecov.io/gh/apache/eventmesh/pull/4438?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLWNvbm5lY3RvcnMvZXZlbnRtZXNoLWNvbm5lY3Rvci1qZGJjL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9ldmVudG1lc2gvY29ubmVjdG9yL2pkYmMvRmllbGQuamF2YQ==) | `0.00% <0.00%> (ø)` | |
| [...ache/eventmesh/connector/jdbc/JdbcConnectData.java](https://app.codecov.io/gh/apache/eventmesh/pull/4438?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLWNvbm5lY3RvcnMvZXZlbnRtZXNoLWNvbm5lY3Rvci1qZGJjL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9ldmVudG1lc2gvY29ubmVjdG9yL2pkYmMvSmRiY0Nvbm5lY3REYXRhLmphdmE=) | `0.00% <0.00%> (ø)` | |
| [...e/eventmesh/connector/jdbc/JdbcDriverMetaData.java](https://app.codecov.io/gh/apache/eventmesh/pull/4438?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLWNvbm5lY3RvcnMvZXZlbnRtZXNoLWNvbm5lY3Rvci1qZGJjL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9ldmVudG1lc2gvY29ubmVjdG9yL2pkYmMvSmRiY0RyaXZlck1ldGFEYXRhLmphdmE=) | `0.00% <0.00%> (ø)` | |
| [...a/org/apache/eventmesh/connector/jdbc/Payload.java](https://app.codecov.io/gh/apache/eventmesh/pull/4438?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLWNvbm5lY3RvcnMvZXZlbnRtZXNoLWNvbm5lY3Rvci1qZGJjL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9ldmVudG1lc2gvY29ubmVjdG9yL2pkYmMvUGF5bG9hZC5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...va/org/apache/eventmesh/connector/jdbc/Schema.java](https://app.codecov.io/gh/apache/eventmesh/pull/4438?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLWNvbm5lY3RvcnMvZXZlbnRtZXNoLWNvbm5lY3Rvci1qZGJjL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9ldmVudG1lc2gvY29ubmVjdG9yL2pkYmMvU2NoZW1hLmphdmE=) | `0.00% <0.00%> (ø)` | |
| [...he/eventmesh/connector/jdbc/config/JdbcConfig.java](https://app.codecov.io/gh/apache/eventmesh/pull/4438?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLWNvbm5lY3RvcnMvZXZlbnRtZXNoLWNvbm5lY3Rvci1qZGJjL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9ldmVudG1lc2gvY29ubmVjdG9yL2pkYmMvY29uZmlnL0pkYmNDb25maWcuamF2YQ==) | `0.00% <0.00%> (ø)` | |
| [...ntmesh/connector/jdbc/config/JdbcServerConfig.java](https://app.codecov.io/gh/apache/eventmesh/pull/4438?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLWNvbm5lY3RvcnMvZXZlbnRtZXNoLWNvbm5lY3Rvci1qZGJjL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9ldmVudG1lc2gvY29ubmVjdG9yL2pkYmMvY29uZmlnL0pkYmNTZXJ2ZXJDb25maWcuamF2YQ==) | `0.00% <0.00%> (ø)` | |
| ... and [124 more](https://app.codecov.io/gh/apache/eventmesh/pull/4438?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | |
... and [37 files with indirect coverage changes](https://app.codecov.io/gh/apache/eventmesh/pull/4438/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4396] Realize the admin function for Kafka storage-plugin (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on code in PR #4438:
URL: https://github.com/apache/eventmesh/pull/4438#discussion_r1319423718
##########
eventmesh-storage-plugin/eventmesh-storage-kafka/src/main/java/org/apache/eventmesh/storage/kafka/admin/KafkaAdmin.java:
##########
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.storage.kafka.admin;
+
+import static org.apache.eventmesh.storage.kafka.common.EventMeshConstants.DEFAULT_TIMEOUT_IN_SECONDS;
+
+import org.apache.eventmesh.api.admin.AbstractAdmin;
+import org.apache.eventmesh.api.admin.TopicProperties;
+import org.apache.eventmesh.common.config.ConfigService;
+import org.apache.eventmesh.storage.kafka.config.ClientConfiguration;
+
+import org.apache.kafka.clients.admin.Admin;
+import org.apache.kafka.clients.admin.DescribeTopicsResult;
+import org.apache.kafka.clients.admin.ListOffsetsResult.ListOffsetsResultInfo;
+import org.apache.kafka.clients.admin.NewTopic;
+import org.apache.kafka.clients.admin.OffsetSpec;
+import org.apache.kafka.clients.admin.TopicDescription;
+import org.apache.kafka.clients.consumer.ConsumerConfig;
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.TopicPartitionInfo;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class KafkaAdmin extends AbstractAdmin {
+
+ // properties for kafka admin client
+ private static final Properties kafkaProps = new Properties();
+
+ // properties for topic management
+ private static final Map<String, Integer> topicProps = new HashMap<>();
+
+ public KafkaAdmin() {
+ super(new AtomicBoolean(false));
+
+ ConfigService configService = ConfigService.getInstance();
+ ClientConfiguration clientConfiguration = configService.buildConfigInstance(ClientConfiguration.class);
+
+ kafkaProps.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, clientConfiguration.getNamesrvAddr());
+ topicProps.put("partitionNum", clientConfiguration.getPartitions());
+ topicProps.put("replicationFactorNum", (int) clientConfiguration.getReplicationFactors());
+ }
+
+ @Override
+ public List<TopicProperties> getTopic() {
+ try (Admin client = Admin.create(kafkaProps)) {
Review Comment:
If a shared client is used, then, once an exception occurs in one operation, blocking of this shared client will cause other operations to be blocked as well. After a client is closed, restarting the server is the only way to recreate a usable client, making it impossible to manage its lifecycle.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org
Re: [PR] [ISSUE #4396] Realize the admin function for Kafka storage-plugin (eventmesh)
Posted by "qqeasonchen (via GitHub)" <gi...@apache.org>.
qqeasonchen merged PR #4438:
URL: https://github.com/apache/eventmesh/pull/4438
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org
Re: [PR] [ISSUE #4396] Realize the admin function for Kafka storage-plugin (eventmesh)
Posted by "Pil0tXia (via GitHub)" <gi...@apache.org>.
Pil0tXia commented on code in PR #4438:
URL: https://github.com/apache/eventmesh/pull/4438#discussion_r1321039439
##########
eventmesh-storage-plugin/eventmesh-storage-kafka/src/main/java/org/apache/eventmesh/storage/kafka/admin/KafkaAdmin.java:
##########
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.storage.kafka.admin;
+
+import static org.apache.eventmesh.storage.kafka.common.EventMeshConstants.DEFAULT_TIMEOUT_IN_SECONDS;
+
+import org.apache.eventmesh.api.admin.AbstractAdmin;
+import org.apache.eventmesh.api.admin.TopicProperties;
+import org.apache.eventmesh.common.config.ConfigService;
+import org.apache.eventmesh.storage.kafka.config.ClientConfiguration;
+
+import org.apache.kafka.clients.admin.Admin;
+import org.apache.kafka.clients.admin.DescribeTopicsResult;
+import org.apache.kafka.clients.admin.ListOffsetsResult.ListOffsetsResultInfo;
+import org.apache.kafka.clients.admin.NewTopic;
+import org.apache.kafka.clients.admin.OffsetSpec;
+import org.apache.kafka.clients.admin.TopicDescription;
+import org.apache.kafka.clients.consumer.ConsumerConfig;
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.TopicPartitionInfo;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class KafkaAdmin extends AbstractAdmin {
+
+ // properties for kafka admin client
+ private static final Properties kafkaProps = new Properties();
+
+ // properties for topic management
+ private static final Map<String, Integer> topicProps = new HashMap<>();
+
+ public KafkaAdmin() {
+ super(new AtomicBoolean(false));
+
+ ConfigService configService = ConfigService.getInstance();
+ ClientConfiguration clientConfiguration = configService.buildConfigInstance(ClientConfiguration.class);
+
+ kafkaProps.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, clientConfiguration.getNamesrvAddr());
+ topicProps.put("partitionNum", clientConfiguration.getPartitions());
+ topicProps.put("replicationFactorNum", (int) clientConfiguration.getReplicationFactors());
+ }
+
+ @Override
+ public List<TopicProperties> getTopic() {
+ try (Admin client = Admin.create(kafkaProps)) {
Review Comment:
try-with-resource is the recommended usage of Kafka Admin API on the Kafka official documentation:
https://github.com/apache/kafka/blob/b72d92919f71f7360cd712741c0470759fc10239/clients/src/main/java/org/apache/kafka/clients/admin/Admin.java#L75-L93
You may check out `org.apache.eventmesh.storage.rocketmq.admin.RocketMQAdmin#createMQAdminExt` to find a similar treatment.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org