You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by "vernedeng (via GitHub)" <gi...@apache.org> on 2024/05/14 11:38:01 UTC
[PR] [INLONG-10208][Sort] ClsSink support unified configuration [inlong]
vernedeng opened a new pull request, #10220:
URL: https://github.com/apache/inlong/pull/10220
<!-- Prepare a Pull Request
Change the title of pull request refer to the following example:
[INLONG-XYZ][Component] Title of the pull request
-->
<!-- Specify the issue this pull request going to fix.
The following *XYZ* should be replaced by the actual [GitHub Issue](https://github.com/apache/inlong/issues) number)-->
Fixes #10208
### Motivation
<!--Explain here the context, and why you're making that change. What is the problem you're trying to solve.-->
### Modifications
<!--Describe the modifications you've done.-->
### Verifying this change
*(Please pick either of the following options)*
- [ ] This change is a trivial rework/code cleanup without any test coverage.
- [ ] This change is already covered by existing tests, such as:
*(please describe tests)*
- [ ] This change added tests and can be verified as follows:
*(example:)*
- *Added integration tests for end-to-end deployment with large payloads (10MB)*
- *Extended integration test for recovery after broker failure*
### 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 follow-up 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: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [INLONG-10208][Sort] ClsSink support unified configuration [inlong]
Posted by "vernedeng (via GitHub)" <gi...@apache.org>.
vernedeng commented on code in PR #10220:
URL: https://github.com/apache/inlong/pull/10220#discussion_r1600877809
##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/cls/ClsSink.java:
##########
@@ -57,13 +47,10 @@ public void start() {
worker.start();
}
} catch (Exception e) {
- LOG.error(e.getMessage(), e);
+ LOG.error("failed to start cls sink", e);
Review Comment:
It's an optimization of JVM, uses **-XX:-OmitStackTraceInFastThrow** to forbid this option
--
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: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [INLONG-10208][Sort] ClsSink support unified configuration [inlong]
Posted by "aloyszhang (via GitHub)" <gi...@apache.org>.
aloyszhang commented on code in PR #10220:
URL: https://github.com/apache/inlong/pull/10220#discussion_r1600891913
##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/source/sortsdk/v2/SortSdkSource.java:
##########
@@ -0,0 +1,202 @@
+/*
+ * 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.inlong.sort.standalone.source.sortsdk.v2;
+
+import org.apache.inlong.sdk.commons.admin.AdminServiceRegister;
+import org.apache.inlong.sdk.sort.api.QueryConsumeConfig;
+import org.apache.inlong.sdk.sort.api.SortClient;
+import org.apache.inlong.sdk.sort.api.SortClientConfig;
+import org.apache.inlong.sdk.sort.api.SortClientFactory;
+import org.apache.inlong.sort.standalone.admin.ConsumerServiceMBean;
+import org.apache.inlong.sort.standalone.config.holder.CommonPropertiesHolder;
+import org.apache.inlong.sort.standalone.config.holder.ManagerUrlHandler;
+import org.apache.inlong.sort.standalone.config.holder.SortClusterConfigType;
+import org.apache.inlong.sort.standalone.config.holder.SortSourceConfigType;
+import org.apache.inlong.sort.standalone.config.holder.v2.SortConfigHolder;
+import org.apache.inlong.sort.standalone.config.loader.ClassResourceQueryConsumeConfig;
+import org.apache.inlong.sort.standalone.source.sortsdk.DefaultTopicChangeListener;
+import org.apache.inlong.sort.standalone.source.sortsdk.FetchCallback;
+import org.apache.inlong.sort.standalone.source.sortsdk.SortSdkSourceContext;
+import org.apache.inlong.sort.standalone.utils.v2.FlumeConfigGenerator;
+
+import org.apache.commons.lang3.ClassUtils;
+import org.apache.flume.Context;
+import org.apache.flume.EventDrivenSource;
+import org.apache.flume.conf.Configurable;
+import org.apache.flume.source.AbstractSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Default Source implementation of InLong.
+ *
+ * <p>
+ * SortSdkSource acquired msg from different upstream data store by register {@link SortClient} for each sort task. The
+ * only things SortSdkSource should do is to get one client by the sort task id, or remove one client when the task is
+ * finished or schedule to other source instance.
+ * </p>
+ *
+ * <p>
+ * The Default Manager of InLong will schedule the partition and topic automatically.
+ * </p>
+ *
+ * <p>
+ * Because all sources should implement {@link Configurable}, the SortSdkSource should have default constructor
+ * <b>WITHOUT</b> any arguments, and parameters will be configured by {@link Configurable#configure(Context)}.
+ * </p>
+ */
+public final class SortSdkSource extends AbstractSource
+ implements
+ Configurable,
+ Runnable,
+ EventDrivenSource,
+ ConsumerServiceMBean {
+
+ private static final Logger LOG = LoggerFactory.getLogger(SortSdkSource.class);
+ public static final String SORT_SDK_PREFIX = "sortsdk.";
+ private static final int CORE_POOL_SIZE = 1;
+ private static final SortClientConfig.ConsumeStrategy defaultStrategy = SortClientConfig.ConsumeStrategy.lastest;
+ private static final String KEY_SORT_SDK_CLIENT_NUM = "sortSdkClientNum";
+ private static final int DEFAULT_SORT_SDK_CLIENT_NUM = 1;
+ private String taskName;
+ private SortSdkSourceContext context;
+ private String sortClusterName;
+ private long reloadInterval;
+ private ScheduledExecutorService pool;
+
+ private List<SortClient> sortClients = new ArrayList<>();
+
+ @Override
+ public synchronized void start() {
+ int sortSdkClientNum = CommonPropertiesHolder.getInteger(KEY_SORT_SDK_CLIENT_NUM, DEFAULT_SORT_SDK_CLIENT_NUM);
+ LOG.info("start to SortSdkSource:{}, client num is {}", taskName, sortSdkClientNum);
+ for (int i = 0; i < sortSdkClientNum; i++) {
+ this.sortClients.add(this.newClient(taskName));
Review Comment:
`newClient()` may return null, so NPE may happened when travase the `sortClients`
--
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: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [INLONG-10208][Sort] ClsSink support unified configuration [inlong]
Posted by "aloyszhang (via GitHub)" <gi...@apache.org>.
aloyszhang commented on code in PR #10220:
URL: https://github.com/apache/inlong/pull/10220#discussion_r1600891913
##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/source/sortsdk/v2/SortSdkSource.java:
##########
@@ -0,0 +1,202 @@
+/*
+ * 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.inlong.sort.standalone.source.sortsdk.v2;
+
+import org.apache.inlong.sdk.commons.admin.AdminServiceRegister;
+import org.apache.inlong.sdk.sort.api.QueryConsumeConfig;
+import org.apache.inlong.sdk.sort.api.SortClient;
+import org.apache.inlong.sdk.sort.api.SortClientConfig;
+import org.apache.inlong.sdk.sort.api.SortClientFactory;
+import org.apache.inlong.sort.standalone.admin.ConsumerServiceMBean;
+import org.apache.inlong.sort.standalone.config.holder.CommonPropertiesHolder;
+import org.apache.inlong.sort.standalone.config.holder.ManagerUrlHandler;
+import org.apache.inlong.sort.standalone.config.holder.SortClusterConfigType;
+import org.apache.inlong.sort.standalone.config.holder.SortSourceConfigType;
+import org.apache.inlong.sort.standalone.config.holder.v2.SortConfigHolder;
+import org.apache.inlong.sort.standalone.config.loader.ClassResourceQueryConsumeConfig;
+import org.apache.inlong.sort.standalone.source.sortsdk.DefaultTopicChangeListener;
+import org.apache.inlong.sort.standalone.source.sortsdk.FetchCallback;
+import org.apache.inlong.sort.standalone.source.sortsdk.SortSdkSourceContext;
+import org.apache.inlong.sort.standalone.utils.v2.FlumeConfigGenerator;
+
+import org.apache.commons.lang3.ClassUtils;
+import org.apache.flume.Context;
+import org.apache.flume.EventDrivenSource;
+import org.apache.flume.conf.Configurable;
+import org.apache.flume.source.AbstractSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Default Source implementation of InLong.
+ *
+ * <p>
+ * SortSdkSource acquired msg from different upstream data store by register {@link SortClient} for each sort task. The
+ * only things SortSdkSource should do is to get one client by the sort task id, or remove one client when the task is
+ * finished or schedule to other source instance.
+ * </p>
+ *
+ * <p>
+ * The Default Manager of InLong will schedule the partition and topic automatically.
+ * </p>
+ *
+ * <p>
+ * Because all sources should implement {@link Configurable}, the SortSdkSource should have default constructor
+ * <b>WITHOUT</b> any arguments, and parameters will be configured by {@link Configurable#configure(Context)}.
+ * </p>
+ */
+public final class SortSdkSource extends AbstractSource
+ implements
+ Configurable,
+ Runnable,
+ EventDrivenSource,
+ ConsumerServiceMBean {
+
+ private static final Logger LOG = LoggerFactory.getLogger(SortSdkSource.class);
+ public static final String SORT_SDK_PREFIX = "sortsdk.";
+ private static final int CORE_POOL_SIZE = 1;
+ private static final SortClientConfig.ConsumeStrategy defaultStrategy = SortClientConfig.ConsumeStrategy.lastest;
+ private static final String KEY_SORT_SDK_CLIENT_NUM = "sortSdkClientNum";
+ private static final int DEFAULT_SORT_SDK_CLIENT_NUM = 1;
+ private String taskName;
+ private SortSdkSourceContext context;
+ private String sortClusterName;
+ private long reloadInterval;
+ private ScheduledExecutorService pool;
+
+ private List<SortClient> sortClients = new ArrayList<>();
+
+ @Override
+ public synchronized void start() {
+ int sortSdkClientNum = CommonPropertiesHolder.getInteger(KEY_SORT_SDK_CLIENT_NUM, DEFAULT_SORT_SDK_CLIENT_NUM);
+ LOG.info("start to SortSdkSource:{}, client num is {}", taskName, sortSdkClientNum);
+ for (int i = 0; i < sortSdkClientNum; i++) {
+ this.sortClients.add(this.newClient(taskName));
Review Comment:
`newClient()` may return null, so NPE may happen when traverse the `sortClients`
--
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: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [INLONG-10208][Sort] ClsSink support unified configuration [inlong]
Posted by "luchunliang (via GitHub)" <gi...@apache.org>.
luchunliang commented on code in PR #10220:
URL: https://github.com/apache/inlong/pull/10220#discussion_r1600868202
##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/cls/ClsSinkContext.java:
##########
@@ -104,26 +97,25 @@ public void reload() {
}
});
- SortTaskConfig newSortTaskConfig = SortClusterConfigHolder.getTaskConfig(taskName);
+ SortTaskConfig newSortTaskConfig = SortConfigHolder.getTaskConfig(taskName);
if (newSortTaskConfig == null || newSortTaskConfig.equals(sortTaskConfig)) {
return;
}
LOG.info("get new SortTaskConfig:taskName:{}:config:{}", taskName,
new ObjectMapper().writeValueAsString(newSortTaskConfig));
this.sortTaskConfig = newSortTaskConfig;
Review Comment:
If requestNodeConfig.getVersion() < clsNodeConfig.getVersion(), reload function can directly return.
--
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: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [INLONG-10208][Sort] ClsSink support unified configuration [inlong]
Posted by "vernedeng (via GitHub)" <gi...@apache.org>.
vernedeng commented on code in PR #10220:
URL: https://github.com/apache/inlong/pull/10220#discussion_r1600100949
##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/source/sortsdk/v2/SortSdkSource.java:
##########
@@ -0,0 +1,224 @@
+/*
+ * 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.inlong.sort.standalone.source.sortsdk.v2;
+
+import org.apache.inlong.sdk.commons.admin.AdminServiceRegister;
+import org.apache.inlong.sdk.sort.api.QueryConsumeConfig;
+import org.apache.inlong.sdk.sort.api.SortClient;
+import org.apache.inlong.sdk.sort.api.SortClientConfig;
+import org.apache.inlong.sdk.sort.api.SortClientFactory;
+import org.apache.inlong.sort.standalone.admin.ConsumerServiceMBean;
+import org.apache.inlong.sort.standalone.config.holder.CommonPropertiesHolder;
+import org.apache.inlong.sort.standalone.config.holder.ManagerUrlHandler;
+import org.apache.inlong.sort.standalone.config.holder.SortClusterConfigType;
+import org.apache.inlong.sort.standalone.config.holder.SortSourceConfigType;
+import org.apache.inlong.sort.standalone.config.holder.v2.SortConfigHolder;
+import org.apache.inlong.sort.standalone.config.loader.ClassResourceQueryConsumeConfig;
+import org.apache.inlong.sort.standalone.source.sortsdk.DefaultTopicChangeListener;
+import org.apache.inlong.sort.standalone.source.sortsdk.FetchCallback;
+import org.apache.inlong.sort.standalone.source.sortsdk.SortSdkSourceContext;
+import org.apache.inlong.sort.standalone.utils.v2.FlumeConfigGenerator;
+
+import org.apache.commons.lang3.ClassUtils;
+import org.apache.flume.Context;
+import org.apache.flume.EventDrivenSource;
+import org.apache.flume.conf.Configurable;
+import org.apache.flume.source.AbstractSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Default Source implementation of InLong.
+ *
+ * <p>
+ * SortSdkSource acquired msg from different upstream data store by register {@link SortClient} for each sort task. The
+ * only things SortSdkSource should do is to get one client by the sort task id, or remove one client when the task is
+ * finished or schedule to other source instance.
+ * </p>
+ *
+ * <p>
+ * The Default Manager of InLong will schedule the partition and topic automatically.
+ * </p>
+ *
+ * <p>
+ * Because all sources should implement {@link Configurable}, the SortSdkSource should have default constructor
+ * <b>WITHOUT</b> any arguments, and parameters will be configured by {@link Configurable#configure(Context)}.
+ * </p>
+ */
+public final class SortSdkSource extends AbstractSource
+ implements
+ Configurable,
+ Runnable,
+ EventDrivenSource,
+ ConsumerServiceMBean {
+
+ // Log of {@link SortSdkSource}.
+ private static final Logger LOG = LoggerFactory.getLogger(SortSdkSource.class);
+
+ public static final String SORT_SDK_PREFIX = "sortsdk.";
+
+ // Default pool of {@link ScheduledExecutorService}.
+ private static final int CORE_POOL_SIZE = 1;
+
+ // Default consume strategy of {@link SortClient}.
+ private static final SortClientConfig.ConsumeStrategy defaultStrategy = SortClientConfig.ConsumeStrategy.lastest;
+
+ private static final String KEY_SORT_SDK_CLIENT_NUM = "sortSdkClientNum";
+ private static final int DEFAULT_SORT_SDK_CLIENT_NUM = 1;
+
+ private String taskName;
+
+ // Context of SortSdkSource.
+ private SortSdkSourceContext context;
+
+ // The cluster name of sort.
+ private String sortClusterName;
+
+ // Reload config interval.
+ private long reloadInterval;
+
+ // Executor for config reloading.
+ private ScheduledExecutorService pool;
+
+ private List<SortClient> sortClients = new ArrayList<>();
+
+ @Override
+ public synchronized void start() {
+ int sortSdkClientNum = CommonPropertiesHolder.getInteger(KEY_SORT_SDK_CLIENT_NUM, DEFAULT_SORT_SDK_CLIENT_NUM);
+ LOG.info("start to SortSdkSource:{}, client num is {}", taskName, sortSdkClientNum);
+ for (int i = 0; i < sortSdkClientNum; i++) {
+ this.sortClients.add(this.newClient(taskName));
+ }
+ }
+
+ @Override
+ public void stop() {
+ pool.shutdownNow();
+ LOG.info("close sort client {}.", taskName);
+ for (SortClient sortClient : sortClients) {
+ sortClient.getConfig().setStopConsume(true);
+ sortClient.close();
+ }
+ }
+
+ @Override
+ public void run() {
+ LOG.info("start to reload SortSdkSource:{}", taskName);
+ for (SortClient sortClient : sortClients) {
+ sortClient.getConfig().setManagerApiUrl(ManagerUrlHandler.getSortSourceConfigUrl());
+ }
+ }
+
+ @Override
+ public void configure(Context context) {
+ this.taskName = context.getString(FlumeConfigGenerator.KEY_TASK_NAME);
+ this.context = new SortSdkSourceContext(getName(), context);
+ this.sortClusterName = SortConfigHolder.getSortConfig().getSortClusterName();
+ this.reloadInterval = this.context.getReloadInterval();
+ this.initReloadExecutor();
+ // register
+ AdminServiceRegister.register(ConsumerServiceMBean.MBEAN_TYPE, taskName, this);
+ }
+
+ private void initReloadExecutor() {
+ this.pool = Executors.newScheduledThreadPool(CORE_POOL_SIZE);
+ pool.scheduleAtFixedRate(this, reloadInterval, reloadInterval, TimeUnit.SECONDS);
+ }
+
+ private SortClient newClient(final String sortTaskName) {
+ LOG.info("start to new sort client for task: {}", sortTaskName);
+ try {
+ final SortClientConfig clientConfig = new SortClientConfig(sortTaskName, this.sortClusterName,
+ new DefaultTopicChangeListener(),
+ SortSdkSource.defaultStrategy, InetAddress.getLocalHost().getHostAddress());
+ final FetchCallback callback = FetchCallback.Factory.create(sortTaskName, getChannelProcessor(), context);
+ clientConfig.setCallback(callback);
+ Map<String, String> sortSdkParams = this.getSortClientConfigParameters();
+ clientConfig.setParameters(sortSdkParams);
+
+ // create SortClient
+ String configType = CommonPropertiesHolder
+ .getString(SortSourceConfigType.KEY_TYPE, SortSourceConfigType.MANAGER.name());
+ SortClient client = null;
+ if (SortClusterConfigType.FILE.name().equalsIgnoreCase(configType)) {
+ LOG.info("create sort sdk client in file way:{}", configType);
+ ClassResourceQueryConsumeConfig queryConfig = new ClassResourceQueryConsumeConfig();
+ client = SortClientFactory.createSortClient(clientConfig, queryConfig);
+ } else if (SortClusterConfigType.MANAGER.name().equalsIgnoreCase(configType)) {
+ LOG.info("create sort sdk client in manager way:{}", configType);
+ clientConfig.setManagerApiUrl(ManagerUrlHandler.getSortSourceConfigUrl());
+ client = SortClientFactory.createSortClient(clientConfig);
+ } else {
+ LOG.info("create sort sdk client in custom way:{}", configType);
+ // user-defined
+ Class<?> loaderClass = ClassUtils.getClass(configType);
+ Object loaderObject = loaderClass.getDeclaredConstructor().newInstance();
+ if (loaderObject instanceof Configurable) {
+ ((Configurable) loaderObject).configure(new Context(CommonPropertiesHolder.get()));
+ }
+ if (!(loaderObject instanceof QueryConsumeConfig)) {
+ LOG.error("got exception when create QueryConsumeConfig instance,config key:{},config class:{}",
+ SortSourceConfigType.KEY_TYPE, configType);
+ return null;
+ }
+ // if it specifies the type of QueryConsumeConfig.
+ client = SortClientFactory.createSortClient(clientConfig, (QueryConsumeConfig) loaderObject);
+ }
+
+ // init
+ client.init();
+ // temporary use to ACK fetched msg.
+ callback.setClient(client);
+ return client;
+ } catch (UnknownHostException ex) {
+ LOG.error("got one UnknownHostException when init client of id:{}", sortTaskName, ex);
+ } catch (Throwable th) {
+ LOG.error("got one throwable when init client of id:{}", sortTaskName, th);
Review Comment:
fixed
--
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: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [INLONG-10208][Sort] ClsSink support unified configuration [inlong]
Posted by "vernedeng (via GitHub)" <gi...@apache.org>.
vernedeng merged PR #10220:
URL: https://github.com/apache/inlong/pull/10220
--
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: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [INLONG-10208][Sort] ClsSink support unified configuration [inlong]
Posted by "vernedeng (via GitHub)" <gi...@apache.org>.
vernedeng commented on code in PR #10220:
URL: https://github.com/apache/inlong/pull/10220#discussion_r1600105175
##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/source/sortsdk/v2/SortSdkSource.java:
##########
@@ -0,0 +1,224 @@
+/*
+ * 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.inlong.sort.standalone.source.sortsdk.v2;
+
+import org.apache.inlong.sdk.commons.admin.AdminServiceRegister;
+import org.apache.inlong.sdk.sort.api.QueryConsumeConfig;
+import org.apache.inlong.sdk.sort.api.SortClient;
+import org.apache.inlong.sdk.sort.api.SortClientConfig;
+import org.apache.inlong.sdk.sort.api.SortClientFactory;
+import org.apache.inlong.sort.standalone.admin.ConsumerServiceMBean;
+import org.apache.inlong.sort.standalone.config.holder.CommonPropertiesHolder;
+import org.apache.inlong.sort.standalone.config.holder.ManagerUrlHandler;
+import org.apache.inlong.sort.standalone.config.holder.SortClusterConfigType;
+import org.apache.inlong.sort.standalone.config.holder.SortSourceConfigType;
+import org.apache.inlong.sort.standalone.config.holder.v2.SortConfigHolder;
+import org.apache.inlong.sort.standalone.config.loader.ClassResourceQueryConsumeConfig;
+import org.apache.inlong.sort.standalone.source.sortsdk.DefaultTopicChangeListener;
+import org.apache.inlong.sort.standalone.source.sortsdk.FetchCallback;
+import org.apache.inlong.sort.standalone.source.sortsdk.SortSdkSourceContext;
+import org.apache.inlong.sort.standalone.utils.v2.FlumeConfigGenerator;
+
+import org.apache.commons.lang3.ClassUtils;
+import org.apache.flume.Context;
+import org.apache.flume.EventDrivenSource;
+import org.apache.flume.conf.Configurable;
+import org.apache.flume.source.AbstractSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Default Source implementation of InLong.
+ *
+ * <p>
+ * SortSdkSource acquired msg from different upstream data store by register {@link SortClient} for each sort task. The
+ * only things SortSdkSource should do is to get one client by the sort task id, or remove one client when the task is
+ * finished or schedule to other source instance.
+ * </p>
+ *
+ * <p>
+ * The Default Manager of InLong will schedule the partition and topic automatically.
+ * </p>
+ *
+ * <p>
+ * Because all sources should implement {@link Configurable}, the SortSdkSource should have default constructor
+ * <b>WITHOUT</b> any arguments, and parameters will be configured by {@link Configurable#configure(Context)}.
+ * </p>
+ */
+public final class SortSdkSource extends AbstractSource
+ implements
+ Configurable,
+ Runnable,
+ EventDrivenSource,
+ ConsumerServiceMBean {
+
+ // Log of {@link SortSdkSource}.
+ private static final Logger LOG = LoggerFactory.getLogger(SortSdkSource.class);
+
+ public static final String SORT_SDK_PREFIX = "sortsdk.";
+
+ // Default pool of {@link ScheduledExecutorService}.
+ private static final int CORE_POOL_SIZE = 1;
+
+ // Default consume strategy of {@link SortClient}.
+ private static final SortClientConfig.ConsumeStrategy defaultStrategy = SortClientConfig.ConsumeStrategy.lastest;
+
+ private static final String KEY_SORT_SDK_CLIENT_NUM = "sortSdkClientNum";
+ private static final int DEFAULT_SORT_SDK_CLIENT_NUM = 1;
+
+ private String taskName;
+
+ // Context of SortSdkSource.
+ private SortSdkSourceContext context;
+
+ // The cluster name of sort.
Review Comment:
fixed
##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/source/sortsdk/v2/SortSdkSource.java:
##########
@@ -0,0 +1,224 @@
+/*
+ * 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.inlong.sort.standalone.source.sortsdk.v2;
+
+import org.apache.inlong.sdk.commons.admin.AdminServiceRegister;
+import org.apache.inlong.sdk.sort.api.QueryConsumeConfig;
+import org.apache.inlong.sdk.sort.api.SortClient;
+import org.apache.inlong.sdk.sort.api.SortClientConfig;
+import org.apache.inlong.sdk.sort.api.SortClientFactory;
+import org.apache.inlong.sort.standalone.admin.ConsumerServiceMBean;
+import org.apache.inlong.sort.standalone.config.holder.CommonPropertiesHolder;
+import org.apache.inlong.sort.standalone.config.holder.ManagerUrlHandler;
+import org.apache.inlong.sort.standalone.config.holder.SortClusterConfigType;
+import org.apache.inlong.sort.standalone.config.holder.SortSourceConfigType;
+import org.apache.inlong.sort.standalone.config.holder.v2.SortConfigHolder;
+import org.apache.inlong.sort.standalone.config.loader.ClassResourceQueryConsumeConfig;
+import org.apache.inlong.sort.standalone.source.sortsdk.DefaultTopicChangeListener;
+import org.apache.inlong.sort.standalone.source.sortsdk.FetchCallback;
+import org.apache.inlong.sort.standalone.source.sortsdk.SortSdkSourceContext;
+import org.apache.inlong.sort.standalone.utils.v2.FlumeConfigGenerator;
+
+import org.apache.commons.lang3.ClassUtils;
+import org.apache.flume.Context;
+import org.apache.flume.EventDrivenSource;
+import org.apache.flume.conf.Configurable;
+import org.apache.flume.source.AbstractSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Default Source implementation of InLong.
+ *
+ * <p>
+ * SortSdkSource acquired msg from different upstream data store by register {@link SortClient} for each sort task. The
+ * only things SortSdkSource should do is to get one client by the sort task id, or remove one client when the task is
+ * finished or schedule to other source instance.
+ * </p>
+ *
+ * <p>
+ * The Default Manager of InLong will schedule the partition and topic automatically.
+ * </p>
+ *
+ * <p>
+ * Because all sources should implement {@link Configurable}, the SortSdkSource should have default constructor
+ * <b>WITHOUT</b> any arguments, and parameters will be configured by {@link Configurable#configure(Context)}.
+ * </p>
+ */
+public final class SortSdkSource extends AbstractSource
+ implements
+ Configurable,
+ Runnable,
+ EventDrivenSource,
+ ConsumerServiceMBean {
+
+ // Log of {@link SortSdkSource}.
+ private static final Logger LOG = LoggerFactory.getLogger(SortSdkSource.class);
+
+ public static final String SORT_SDK_PREFIX = "sortsdk.";
+
+ // Default pool of {@link ScheduledExecutorService}.
+ private static final int CORE_POOL_SIZE = 1;
+
+ // Default consume strategy of {@link SortClient}.
+ private static final SortClientConfig.ConsumeStrategy defaultStrategy = SortClientConfig.ConsumeStrategy.lastest;
+
+ private static final String KEY_SORT_SDK_CLIENT_NUM = "sortSdkClientNum";
+ private static final int DEFAULT_SORT_SDK_CLIENT_NUM = 1;
+
+ private String taskName;
+
+ // Context of SortSdkSource.
+ private SortSdkSourceContext context;
+
+ // The cluster name of sort.
+ private String sortClusterName;
+
+ // Reload config interval.
+ private long reloadInterval;
+
+ // Executor for config reloading.
Review Comment:
fixed
--
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: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [INLONG-10208][Sort] ClsSink support unified configuration [inlong]
Posted by "fuweng11 (via GitHub)" <gi...@apache.org>.
fuweng11 commented on code in PR #10220:
URL: https://github.com/apache/inlong/pull/10220#discussion_r1599909684
##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/v2/SinkContext.java:
##########
@@ -0,0 +1,171 @@
+/*
+ * 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.inlong.sort.standalone.sink.v2;
+
+import org.apache.inlong.common.metric.MetricRegister;
+import org.apache.inlong.common.pojo.sort.SortTaskConfig;
+import org.apache.inlong.sort.standalone.channel.ProfileEvent;
+import org.apache.inlong.sort.standalone.config.holder.CommonPropertiesHolder;
+import org.apache.inlong.sort.standalone.config.holder.v2.SortConfigHolder;
+import org.apache.inlong.sort.standalone.metrics.SortMetricItem;
+import org.apache.inlong.sort.standalone.metrics.SortMetricItemSet;
+import org.apache.inlong.sort.standalone.utils.BufferQueue;
+import org.apache.inlong.sort.standalone.utils.InlongLoggerFactory;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.flume.Channel;
+import org.apache.flume.Context;
+import org.slf4j.Logger;
+
+import java.util.Date;
+import java.util.Map;
+import java.util.Timer;
+import java.util.TimerTask;
+
+public class SinkContext {
+
+ public static final Logger LOG = InlongLoggerFactory.getLogger(SinkContext.class);
+
+ public static final String KEY_MAX_THREADS = "maxThreads";
+ public static final String KEY_PROCESSINTERVAL = "processInterval";
+ public static final String KEY_RELOADINTERVAL = "reloadInterval";
+ public static final String KEY_TASK_NAME = "taskName";
+ public static final String KEY_MAX_BUFFERQUEUE_SIZE_KB = "maxBufferQueueSizeKb";
+ public static final int DEFAULT_MAX_BUFFERQUEUE_SIZE_KB = 128 * 1024;
+
+ protected final String clusterId;
+ protected final String taskName;
+ protected final String sinkName;
+ protected final Context sinkContext;
+
+ protected SortTaskConfig sortTaskConfig;
+
+ protected final Channel channel;
+ //
Review Comment:
Remove it.
##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/v2/SinkContext.java:
##########
@@ -0,0 +1,171 @@
+/*
+ * 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.inlong.sort.standalone.sink.v2;
+
+import org.apache.inlong.common.metric.MetricRegister;
+import org.apache.inlong.common.pojo.sort.SortTaskConfig;
+import org.apache.inlong.sort.standalone.channel.ProfileEvent;
+import org.apache.inlong.sort.standalone.config.holder.CommonPropertiesHolder;
+import org.apache.inlong.sort.standalone.config.holder.v2.SortConfigHolder;
+import org.apache.inlong.sort.standalone.metrics.SortMetricItem;
+import org.apache.inlong.sort.standalone.metrics.SortMetricItemSet;
+import org.apache.inlong.sort.standalone.utils.BufferQueue;
+import org.apache.inlong.sort.standalone.utils.InlongLoggerFactory;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.flume.Channel;
+import org.apache.flume.Context;
+import org.slf4j.Logger;
+
+import java.util.Date;
+import java.util.Map;
+import java.util.Timer;
+import java.util.TimerTask;
+
+public class SinkContext {
+
+ public static final Logger LOG = InlongLoggerFactory.getLogger(SinkContext.class);
+
+ public static final String KEY_MAX_THREADS = "maxThreads";
+ public static final String KEY_PROCESSINTERVAL = "processInterval";
+ public static final String KEY_RELOADINTERVAL = "reloadInterval";
+ public static final String KEY_TASK_NAME = "taskName";
+ public static final String KEY_MAX_BUFFERQUEUE_SIZE_KB = "maxBufferQueueSizeKb";
+ public static final int DEFAULT_MAX_BUFFERQUEUE_SIZE_KB = 128 * 1024;
+
+ protected final String clusterId;
+ protected final String taskName;
+ protected final String sinkName;
+ protected final Context sinkContext;
+
+ protected SortTaskConfig sortTaskConfig;
+
+ protected final Channel channel;
+ //
+ protected final int maxThreads;
+ protected final long processInterval;
+ protected final long reloadInterval;
+ //
Review Comment:
Remove it.
--
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: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [INLONG-10208][Sort] ClsSink support unified configuration [inlong]
Posted by "vernedeng (via GitHub)" <gi...@apache.org>.
vernedeng commented on code in PR #10220:
URL: https://github.com/apache/inlong/pull/10220#discussion_r1600881454
##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/cls/ClsSinkContext.java:
##########
@@ -104,26 +97,25 @@ public void reload() {
}
});
- SortTaskConfig newSortTaskConfig = SortClusterConfigHolder.getTaskConfig(taskName);
+ SortTaskConfig newSortTaskConfig = SortConfigHolder.getTaskConfig(taskName);
if (newSortTaskConfig == null || newSortTaskConfig.equals(sortTaskConfig)) {
return;
}
LOG.info("get new SortTaskConfig:taskName:{}:config:{}", taskName,
new ObjectMapper().writeValueAsString(newSortTaskConfig));
this.sortTaskConfig = newSortTaskConfig;
Review Comment:
Both NodeConfig and DataflowConfig have their version. Must check all versions of dataflow and node.
--
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: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [INLONG-10208][Sort] ClsSink support unified configuration [inlong]
Posted by "fuweng11 (via GitHub)" <gi...@apache.org>.
fuweng11 commented on code in PR #10220:
URL: https://github.com/apache/inlong/pull/10220#discussion_r1599914002
##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/source/sortsdk/v2/SortSdkSource.java:
##########
@@ -0,0 +1,224 @@
+/*
+ * 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.inlong.sort.standalone.source.sortsdk.v2;
+
+import org.apache.inlong.sdk.commons.admin.AdminServiceRegister;
+import org.apache.inlong.sdk.sort.api.QueryConsumeConfig;
+import org.apache.inlong.sdk.sort.api.SortClient;
+import org.apache.inlong.sdk.sort.api.SortClientConfig;
+import org.apache.inlong.sdk.sort.api.SortClientFactory;
+import org.apache.inlong.sort.standalone.admin.ConsumerServiceMBean;
+import org.apache.inlong.sort.standalone.config.holder.CommonPropertiesHolder;
+import org.apache.inlong.sort.standalone.config.holder.ManagerUrlHandler;
+import org.apache.inlong.sort.standalone.config.holder.SortClusterConfigType;
+import org.apache.inlong.sort.standalone.config.holder.SortSourceConfigType;
+import org.apache.inlong.sort.standalone.config.holder.v2.SortConfigHolder;
+import org.apache.inlong.sort.standalone.config.loader.ClassResourceQueryConsumeConfig;
+import org.apache.inlong.sort.standalone.source.sortsdk.DefaultTopicChangeListener;
+import org.apache.inlong.sort.standalone.source.sortsdk.FetchCallback;
+import org.apache.inlong.sort.standalone.source.sortsdk.SortSdkSourceContext;
+import org.apache.inlong.sort.standalone.utils.v2.FlumeConfigGenerator;
+
+import org.apache.commons.lang3.ClassUtils;
+import org.apache.flume.Context;
+import org.apache.flume.EventDrivenSource;
+import org.apache.flume.conf.Configurable;
+import org.apache.flume.source.AbstractSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Default Source implementation of InLong.
+ *
+ * <p>
+ * SortSdkSource acquired msg from different upstream data store by register {@link SortClient} for each sort task. The
+ * only things SortSdkSource should do is to get one client by the sort task id, or remove one client when the task is
+ * finished or schedule to other source instance.
+ * </p>
+ *
+ * <p>
+ * The Default Manager of InLong will schedule the partition and topic automatically.
+ * </p>
+ *
+ * <p>
+ * Because all sources should implement {@link Configurable}, the SortSdkSource should have default constructor
+ * <b>WITHOUT</b> any arguments, and parameters will be configured by {@link Configurable#configure(Context)}.
+ * </p>
+ */
+public final class SortSdkSource extends AbstractSource
+ implements
+ Configurable,
+ Runnable,
+ EventDrivenSource,
+ ConsumerServiceMBean {
+
+ // Log of {@link SortSdkSource}.
+ private static final Logger LOG = LoggerFactory.getLogger(SortSdkSource.class);
+
+ public static final String SORT_SDK_PREFIX = "sortsdk.";
+
+ // Default pool of {@link ScheduledExecutorService}.
+ private static final int CORE_POOL_SIZE = 1;
+
+ // Default consume strategy of {@link SortClient}.
+ private static final SortClientConfig.ConsumeStrategy defaultStrategy = SortClientConfig.ConsumeStrategy.lastest;
+
+ private static final String KEY_SORT_SDK_CLIENT_NUM = "sortSdkClientNum";
+ private static final int DEFAULT_SORT_SDK_CLIENT_NUM = 1;
+
+ private String taskName;
+
+ // Context of SortSdkSource.
Review Comment:
Remove it.
##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/source/sortsdk/v2/SortSdkSource.java:
##########
@@ -0,0 +1,224 @@
+/*
+ * 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.inlong.sort.standalone.source.sortsdk.v2;
+
+import org.apache.inlong.sdk.commons.admin.AdminServiceRegister;
+import org.apache.inlong.sdk.sort.api.QueryConsumeConfig;
+import org.apache.inlong.sdk.sort.api.SortClient;
+import org.apache.inlong.sdk.sort.api.SortClientConfig;
+import org.apache.inlong.sdk.sort.api.SortClientFactory;
+import org.apache.inlong.sort.standalone.admin.ConsumerServiceMBean;
+import org.apache.inlong.sort.standalone.config.holder.CommonPropertiesHolder;
+import org.apache.inlong.sort.standalone.config.holder.ManagerUrlHandler;
+import org.apache.inlong.sort.standalone.config.holder.SortClusterConfigType;
+import org.apache.inlong.sort.standalone.config.holder.SortSourceConfigType;
+import org.apache.inlong.sort.standalone.config.holder.v2.SortConfigHolder;
+import org.apache.inlong.sort.standalone.config.loader.ClassResourceQueryConsumeConfig;
+import org.apache.inlong.sort.standalone.source.sortsdk.DefaultTopicChangeListener;
+import org.apache.inlong.sort.standalone.source.sortsdk.FetchCallback;
+import org.apache.inlong.sort.standalone.source.sortsdk.SortSdkSourceContext;
+import org.apache.inlong.sort.standalone.utils.v2.FlumeConfigGenerator;
+
+import org.apache.commons.lang3.ClassUtils;
+import org.apache.flume.Context;
+import org.apache.flume.EventDrivenSource;
+import org.apache.flume.conf.Configurable;
+import org.apache.flume.source.AbstractSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Default Source implementation of InLong.
+ *
+ * <p>
+ * SortSdkSource acquired msg from different upstream data store by register {@link SortClient} for each sort task. The
+ * only things SortSdkSource should do is to get one client by the sort task id, or remove one client when the task is
+ * finished or schedule to other source instance.
+ * </p>
+ *
+ * <p>
+ * The Default Manager of InLong will schedule the partition and topic automatically.
+ * </p>
+ *
+ * <p>
+ * Because all sources should implement {@link Configurable}, the SortSdkSource should have default constructor
+ * <b>WITHOUT</b> any arguments, and parameters will be configured by {@link Configurable#configure(Context)}.
+ * </p>
+ */
+public final class SortSdkSource extends AbstractSource
+ implements
+ Configurable,
+ Runnable,
+ EventDrivenSource,
+ ConsumerServiceMBean {
+
+ // Log of {@link SortSdkSource}.
+ private static final Logger LOG = LoggerFactory.getLogger(SortSdkSource.class);
+
+ public static final String SORT_SDK_PREFIX = "sortsdk.";
+
+ // Default pool of {@link ScheduledExecutorService}.
+ private static final int CORE_POOL_SIZE = 1;
+
+ // Default consume strategy of {@link SortClient}.
+ private static final SortClientConfig.ConsumeStrategy defaultStrategy = SortClientConfig.ConsumeStrategy.lastest;
+
+ private static final String KEY_SORT_SDK_CLIENT_NUM = "sortSdkClientNum";
+ private static final int DEFAULT_SORT_SDK_CLIENT_NUM = 1;
+
+ private String taskName;
+
+ // Context of SortSdkSource.
+ private SortSdkSourceContext context;
+
+ // The cluster name of sort.
+ private String sortClusterName;
+
+ // Reload config interval.
Review Comment:
Remove it.
##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/source/sortsdk/v2/SortSdkSource.java:
##########
@@ -0,0 +1,224 @@
+/*
+ * 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.inlong.sort.standalone.source.sortsdk.v2;
+
+import org.apache.inlong.sdk.commons.admin.AdminServiceRegister;
+import org.apache.inlong.sdk.sort.api.QueryConsumeConfig;
+import org.apache.inlong.sdk.sort.api.SortClient;
+import org.apache.inlong.sdk.sort.api.SortClientConfig;
+import org.apache.inlong.sdk.sort.api.SortClientFactory;
+import org.apache.inlong.sort.standalone.admin.ConsumerServiceMBean;
+import org.apache.inlong.sort.standalone.config.holder.CommonPropertiesHolder;
+import org.apache.inlong.sort.standalone.config.holder.ManagerUrlHandler;
+import org.apache.inlong.sort.standalone.config.holder.SortClusterConfigType;
+import org.apache.inlong.sort.standalone.config.holder.SortSourceConfigType;
+import org.apache.inlong.sort.standalone.config.holder.v2.SortConfigHolder;
+import org.apache.inlong.sort.standalone.config.loader.ClassResourceQueryConsumeConfig;
+import org.apache.inlong.sort.standalone.source.sortsdk.DefaultTopicChangeListener;
+import org.apache.inlong.sort.standalone.source.sortsdk.FetchCallback;
+import org.apache.inlong.sort.standalone.source.sortsdk.SortSdkSourceContext;
+import org.apache.inlong.sort.standalone.utils.v2.FlumeConfigGenerator;
+
+import org.apache.commons.lang3.ClassUtils;
+import org.apache.flume.Context;
+import org.apache.flume.EventDrivenSource;
+import org.apache.flume.conf.Configurable;
+import org.apache.flume.source.AbstractSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Default Source implementation of InLong.
+ *
+ * <p>
+ * SortSdkSource acquired msg from different upstream data store by register {@link SortClient} for each sort task. The
+ * only things SortSdkSource should do is to get one client by the sort task id, or remove one client when the task is
+ * finished or schedule to other source instance.
+ * </p>
+ *
+ * <p>
+ * The Default Manager of InLong will schedule the partition and topic automatically.
+ * </p>
+ *
+ * <p>
+ * Because all sources should implement {@link Configurable}, the SortSdkSource should have default constructor
+ * <b>WITHOUT</b> any arguments, and parameters will be configured by {@link Configurable#configure(Context)}.
+ * </p>
+ */
+public final class SortSdkSource extends AbstractSource
+ implements
+ Configurable,
+ Runnable,
+ EventDrivenSource,
+ ConsumerServiceMBean {
+
+ // Log of {@link SortSdkSource}.
+ private static final Logger LOG = LoggerFactory.getLogger(SortSdkSource.class);
+
+ public static final String SORT_SDK_PREFIX = "sortsdk.";
+
+ // Default pool of {@link ScheduledExecutorService}.
+ private static final int CORE_POOL_SIZE = 1;
+
+ // Default consume strategy of {@link SortClient}.
+ private static final SortClientConfig.ConsumeStrategy defaultStrategy = SortClientConfig.ConsumeStrategy.lastest;
+
+ private static final String KEY_SORT_SDK_CLIENT_NUM = "sortSdkClientNum";
+ private static final int DEFAULT_SORT_SDK_CLIENT_NUM = 1;
+
+ private String taskName;
+
+ // Context of SortSdkSource.
+ private SortSdkSourceContext context;
+
+ // The cluster name of sort.
+ private String sortClusterName;
+
+ // Reload config interval.
+ private long reloadInterval;
+
+ // Executor for config reloading.
+ private ScheduledExecutorService pool;
+
+ private List<SortClient> sortClients = new ArrayList<>();
+
+ @Override
+ public synchronized void start() {
+ int sortSdkClientNum = CommonPropertiesHolder.getInteger(KEY_SORT_SDK_CLIENT_NUM, DEFAULT_SORT_SDK_CLIENT_NUM);
+ LOG.info("start to SortSdkSource:{}, client num is {}", taskName, sortSdkClientNum);
+ for (int i = 0; i < sortSdkClientNum; i++) {
+ this.sortClients.add(this.newClient(taskName));
+ }
+ }
+
+ @Override
+ public void stop() {
+ pool.shutdownNow();
+ LOG.info("close sort client {}.", taskName);
+ for (SortClient sortClient : sortClients) {
+ sortClient.getConfig().setStopConsume(true);
+ sortClient.close();
+ }
+ }
+
+ @Override
+ public void run() {
+ LOG.info("start to reload SortSdkSource:{}", taskName);
+ for (SortClient sortClient : sortClients) {
+ sortClient.getConfig().setManagerApiUrl(ManagerUrlHandler.getSortSourceConfigUrl());
+ }
+ }
+
+ @Override
+ public void configure(Context context) {
+ this.taskName = context.getString(FlumeConfigGenerator.KEY_TASK_NAME);
+ this.context = new SortSdkSourceContext(getName(), context);
+ this.sortClusterName = SortConfigHolder.getSortConfig().getSortClusterName();
+ this.reloadInterval = this.context.getReloadInterval();
+ this.initReloadExecutor();
+ // register
+ AdminServiceRegister.register(ConsumerServiceMBean.MBEAN_TYPE, taskName, this);
+ }
+
+ private void initReloadExecutor() {
+ this.pool = Executors.newScheduledThreadPool(CORE_POOL_SIZE);
+ pool.scheduleAtFixedRate(this, reloadInterval, reloadInterval, TimeUnit.SECONDS);
+ }
+
+ private SortClient newClient(final String sortTaskName) {
+ LOG.info("start to new sort client for task: {}", sortTaskName);
+ try {
+ final SortClientConfig clientConfig = new SortClientConfig(sortTaskName, this.sortClusterName,
+ new DefaultTopicChangeListener(),
+ SortSdkSource.defaultStrategy, InetAddress.getLocalHost().getHostAddress());
+ final FetchCallback callback = FetchCallback.Factory.create(sortTaskName, getChannelProcessor(), context);
+ clientConfig.setCallback(callback);
+ Map<String, String> sortSdkParams = this.getSortClientConfigParameters();
+ clientConfig.setParameters(sortSdkParams);
+
+ // create SortClient
+ String configType = CommonPropertiesHolder
+ .getString(SortSourceConfigType.KEY_TYPE, SortSourceConfigType.MANAGER.name());
+ SortClient client = null;
+ if (SortClusterConfigType.FILE.name().equalsIgnoreCase(configType)) {
+ LOG.info("create sort sdk client in file way:{}", configType);
+ ClassResourceQueryConsumeConfig queryConfig = new ClassResourceQueryConsumeConfig();
+ client = SortClientFactory.createSortClient(clientConfig, queryConfig);
+ } else if (SortClusterConfigType.MANAGER.name().equalsIgnoreCase(configType)) {
+ LOG.info("create sort sdk client in manager way:{}", configType);
+ clientConfig.setManagerApiUrl(ManagerUrlHandler.getSortSourceConfigUrl());
+ client = SortClientFactory.createSortClient(clientConfig);
+ } else {
+ LOG.info("create sort sdk client in custom way:{}", configType);
+ // user-defined
+ Class<?> loaderClass = ClassUtils.getClass(configType);
+ Object loaderObject = loaderClass.getDeclaredConstructor().newInstance();
+ if (loaderObject instanceof Configurable) {
+ ((Configurable) loaderObject).configure(new Context(CommonPropertiesHolder.get()));
+ }
+ if (!(loaderObject instanceof QueryConsumeConfig)) {
+ LOG.error("got exception when create QueryConsumeConfig instance,config key:{},config class:{}",
+ SortSourceConfigType.KEY_TYPE, configType);
+ return null;
+ }
+ // if it specifies the type of QueryConsumeConfig.
+ client = SortClientFactory.createSortClient(clientConfig, (QueryConsumeConfig) loaderObject);
+ }
+
+ // init
+ client.init();
+ // temporary use to ACK fetched msg.
+ callback.setClient(client);
+ return client;
+ } catch (UnknownHostException ex) {
+ LOG.error("got one UnknownHostException when init client of id:{}", sortTaskName, ex);
+ } catch (Throwable th) {
+ LOG.error("got one throwable when init client of id:{}", sortTaskName, th);
Review Comment:
Remove it.
##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/source/sortsdk/v2/SortSdkSource.java:
##########
@@ -0,0 +1,224 @@
+/*
+ * 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.inlong.sort.standalone.source.sortsdk.v2;
+
+import org.apache.inlong.sdk.commons.admin.AdminServiceRegister;
+import org.apache.inlong.sdk.sort.api.QueryConsumeConfig;
+import org.apache.inlong.sdk.sort.api.SortClient;
+import org.apache.inlong.sdk.sort.api.SortClientConfig;
+import org.apache.inlong.sdk.sort.api.SortClientFactory;
+import org.apache.inlong.sort.standalone.admin.ConsumerServiceMBean;
+import org.apache.inlong.sort.standalone.config.holder.CommonPropertiesHolder;
+import org.apache.inlong.sort.standalone.config.holder.ManagerUrlHandler;
+import org.apache.inlong.sort.standalone.config.holder.SortClusterConfigType;
+import org.apache.inlong.sort.standalone.config.holder.SortSourceConfigType;
+import org.apache.inlong.sort.standalone.config.holder.v2.SortConfigHolder;
+import org.apache.inlong.sort.standalone.config.loader.ClassResourceQueryConsumeConfig;
+import org.apache.inlong.sort.standalone.source.sortsdk.DefaultTopicChangeListener;
+import org.apache.inlong.sort.standalone.source.sortsdk.FetchCallback;
+import org.apache.inlong.sort.standalone.source.sortsdk.SortSdkSourceContext;
+import org.apache.inlong.sort.standalone.utils.v2.FlumeConfigGenerator;
+
+import org.apache.commons.lang3.ClassUtils;
+import org.apache.flume.Context;
+import org.apache.flume.EventDrivenSource;
+import org.apache.flume.conf.Configurable;
+import org.apache.flume.source.AbstractSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Default Source implementation of InLong.
+ *
+ * <p>
+ * SortSdkSource acquired msg from different upstream data store by register {@link SortClient} for each sort task. The
+ * only things SortSdkSource should do is to get one client by the sort task id, or remove one client when the task is
+ * finished or schedule to other source instance.
+ * </p>
+ *
+ * <p>
+ * The Default Manager of InLong will schedule the partition and topic automatically.
+ * </p>
+ *
+ * <p>
+ * Because all sources should implement {@link Configurable}, the SortSdkSource should have default constructor
+ * <b>WITHOUT</b> any arguments, and parameters will be configured by {@link Configurable#configure(Context)}.
+ * </p>
+ */
+public final class SortSdkSource extends AbstractSource
+ implements
+ Configurable,
+ Runnable,
+ EventDrivenSource,
+ ConsumerServiceMBean {
+
+ // Log of {@link SortSdkSource}.
+ private static final Logger LOG = LoggerFactory.getLogger(SortSdkSource.class);
+
+ public static final String SORT_SDK_PREFIX = "sortsdk.";
+
+ // Default pool of {@link ScheduledExecutorService}.
+ private static final int CORE_POOL_SIZE = 1;
+
+ // Default consume strategy of {@link SortClient}.
+ private static final SortClientConfig.ConsumeStrategy defaultStrategy = SortClientConfig.ConsumeStrategy.lastest;
+
+ private static final String KEY_SORT_SDK_CLIENT_NUM = "sortSdkClientNum";
+ private static final int DEFAULT_SORT_SDK_CLIENT_NUM = 1;
+
+ private String taskName;
+
+ // Context of SortSdkSource.
+ private SortSdkSourceContext context;
+
+ // The cluster name of sort.
Review Comment:
Remove it.
##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/source/sortsdk/v2/SortSdkSource.java:
##########
@@ -0,0 +1,224 @@
+/*
+ * 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.inlong.sort.standalone.source.sortsdk.v2;
+
+import org.apache.inlong.sdk.commons.admin.AdminServiceRegister;
+import org.apache.inlong.sdk.sort.api.QueryConsumeConfig;
+import org.apache.inlong.sdk.sort.api.SortClient;
+import org.apache.inlong.sdk.sort.api.SortClientConfig;
+import org.apache.inlong.sdk.sort.api.SortClientFactory;
+import org.apache.inlong.sort.standalone.admin.ConsumerServiceMBean;
+import org.apache.inlong.sort.standalone.config.holder.CommonPropertiesHolder;
+import org.apache.inlong.sort.standalone.config.holder.ManagerUrlHandler;
+import org.apache.inlong.sort.standalone.config.holder.SortClusterConfigType;
+import org.apache.inlong.sort.standalone.config.holder.SortSourceConfigType;
+import org.apache.inlong.sort.standalone.config.holder.v2.SortConfigHolder;
+import org.apache.inlong.sort.standalone.config.loader.ClassResourceQueryConsumeConfig;
+import org.apache.inlong.sort.standalone.source.sortsdk.DefaultTopicChangeListener;
+import org.apache.inlong.sort.standalone.source.sortsdk.FetchCallback;
+import org.apache.inlong.sort.standalone.source.sortsdk.SortSdkSourceContext;
+import org.apache.inlong.sort.standalone.utils.v2.FlumeConfigGenerator;
+
+import org.apache.commons.lang3.ClassUtils;
+import org.apache.flume.Context;
+import org.apache.flume.EventDrivenSource;
+import org.apache.flume.conf.Configurable;
+import org.apache.flume.source.AbstractSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Default Source implementation of InLong.
+ *
+ * <p>
+ * SortSdkSource acquired msg from different upstream data store by register {@link SortClient} for each sort task. The
+ * only things SortSdkSource should do is to get one client by the sort task id, or remove one client when the task is
+ * finished or schedule to other source instance.
+ * </p>
+ *
+ * <p>
+ * The Default Manager of InLong will schedule the partition and topic automatically.
+ * </p>
+ *
+ * <p>
+ * Because all sources should implement {@link Configurable}, the SortSdkSource should have default constructor
+ * <b>WITHOUT</b> any arguments, and parameters will be configured by {@link Configurable#configure(Context)}.
+ * </p>
+ */
+public final class SortSdkSource extends AbstractSource
+ implements
+ Configurable,
+ Runnable,
+ EventDrivenSource,
+ ConsumerServiceMBean {
+
+ // Log of {@link SortSdkSource}.
+ private static final Logger LOG = LoggerFactory.getLogger(SortSdkSource.class);
+
+ public static final String SORT_SDK_PREFIX = "sortsdk.";
+
+ // Default pool of {@link ScheduledExecutorService}.
+ private static final int CORE_POOL_SIZE = 1;
+
+ // Default consume strategy of {@link SortClient}.
+ private static final SortClientConfig.ConsumeStrategy defaultStrategy = SortClientConfig.ConsumeStrategy.lastest;
+
+ private static final String KEY_SORT_SDK_CLIENT_NUM = "sortSdkClientNum";
+ private static final int DEFAULT_SORT_SDK_CLIENT_NUM = 1;
+
+ private String taskName;
+
+ // Context of SortSdkSource.
+ private SortSdkSourceContext context;
+
+ // The cluster name of sort.
+ private String sortClusterName;
+
+ // Reload config interval.
+ private long reloadInterval;
+
+ // Executor for config reloading.
+ private ScheduledExecutorService pool;
+
+ private List<SortClient> sortClients = new ArrayList<>();
+
+ @Override
+ public synchronized void start() {
+ int sortSdkClientNum = CommonPropertiesHolder.getInteger(KEY_SORT_SDK_CLIENT_NUM, DEFAULT_SORT_SDK_CLIENT_NUM);
+ LOG.info("start to SortSdkSource:{}, client num is {}", taskName, sortSdkClientNum);
+ for (int i = 0; i < sortSdkClientNum; i++) {
+ this.sortClients.add(this.newClient(taskName));
+ }
+ }
+
+ @Override
+ public void stop() {
+ pool.shutdownNow();
+ LOG.info("close sort client {}.", taskName);
+ for (SortClient sortClient : sortClients) {
+ sortClient.getConfig().setStopConsume(true);
+ sortClient.close();
+ }
+ }
+
+ @Override
+ public void run() {
+ LOG.info("start to reload SortSdkSource:{}", taskName);
+ for (SortClient sortClient : sortClients) {
+ sortClient.getConfig().setManagerApiUrl(ManagerUrlHandler.getSortSourceConfigUrl());
+ }
+ }
+
+ @Override
+ public void configure(Context context) {
+ this.taskName = context.getString(FlumeConfigGenerator.KEY_TASK_NAME);
+ this.context = new SortSdkSourceContext(getName(), context);
+ this.sortClusterName = SortConfigHolder.getSortConfig().getSortClusterName();
+ this.reloadInterval = this.context.getReloadInterval();
+ this.initReloadExecutor();
+ // register
+ AdminServiceRegister.register(ConsumerServiceMBean.MBEAN_TYPE, taskName, this);
+ }
+
+ private void initReloadExecutor() {
+ this.pool = Executors.newScheduledThreadPool(CORE_POOL_SIZE);
+ pool.scheduleAtFixedRate(this, reloadInterval, reloadInterval, TimeUnit.SECONDS);
+ }
+
+ private SortClient newClient(final String sortTaskName) {
+ LOG.info("start to new sort client for task: {}", sortTaskName);
+ try {
+ final SortClientConfig clientConfig = new SortClientConfig(sortTaskName, this.sortClusterName,
+ new DefaultTopicChangeListener(),
+ SortSdkSource.defaultStrategy, InetAddress.getLocalHost().getHostAddress());
+ final FetchCallback callback = FetchCallback.Factory.create(sortTaskName, getChannelProcessor(), context);
+ clientConfig.setCallback(callback);
+ Map<String, String> sortSdkParams = this.getSortClientConfigParameters();
+ clientConfig.setParameters(sortSdkParams);
+
+ // create SortClient
+ String configType = CommonPropertiesHolder
+ .getString(SortSourceConfigType.KEY_TYPE, SortSourceConfigType.MANAGER.name());
+ SortClient client = null;
+ if (SortClusterConfigType.FILE.name().equalsIgnoreCase(configType)) {
+ LOG.info("create sort sdk client in file way:{}", configType);
+ ClassResourceQueryConsumeConfig queryConfig = new ClassResourceQueryConsumeConfig();
+ client = SortClientFactory.createSortClient(clientConfig, queryConfig);
+ } else if (SortClusterConfigType.MANAGER.name().equalsIgnoreCase(configType)) {
+ LOG.info("create sort sdk client in manager way:{}", configType);
+ clientConfig.setManagerApiUrl(ManagerUrlHandler.getSortSourceConfigUrl());
+ client = SortClientFactory.createSortClient(clientConfig);
+ } else {
+ LOG.info("create sort sdk client in custom way:{}", configType);
+ // user-defined
Review Comment:
What is the purpose of this annotation?
##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/source/sortsdk/v2/SortSdkSource.java:
##########
@@ -0,0 +1,224 @@
+/*
+ * 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.inlong.sort.standalone.source.sortsdk.v2;
+
+import org.apache.inlong.sdk.commons.admin.AdminServiceRegister;
+import org.apache.inlong.sdk.sort.api.QueryConsumeConfig;
+import org.apache.inlong.sdk.sort.api.SortClient;
+import org.apache.inlong.sdk.sort.api.SortClientConfig;
+import org.apache.inlong.sdk.sort.api.SortClientFactory;
+import org.apache.inlong.sort.standalone.admin.ConsumerServiceMBean;
+import org.apache.inlong.sort.standalone.config.holder.CommonPropertiesHolder;
+import org.apache.inlong.sort.standalone.config.holder.ManagerUrlHandler;
+import org.apache.inlong.sort.standalone.config.holder.SortClusterConfigType;
+import org.apache.inlong.sort.standalone.config.holder.SortSourceConfigType;
+import org.apache.inlong.sort.standalone.config.holder.v2.SortConfigHolder;
+import org.apache.inlong.sort.standalone.config.loader.ClassResourceQueryConsumeConfig;
+import org.apache.inlong.sort.standalone.source.sortsdk.DefaultTopicChangeListener;
+import org.apache.inlong.sort.standalone.source.sortsdk.FetchCallback;
+import org.apache.inlong.sort.standalone.source.sortsdk.SortSdkSourceContext;
+import org.apache.inlong.sort.standalone.utils.v2.FlumeConfigGenerator;
+
+import org.apache.commons.lang3.ClassUtils;
+import org.apache.flume.Context;
+import org.apache.flume.EventDrivenSource;
+import org.apache.flume.conf.Configurable;
+import org.apache.flume.source.AbstractSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Default Source implementation of InLong.
+ *
+ * <p>
+ * SortSdkSource acquired msg from different upstream data store by register {@link SortClient} for each sort task. The
+ * only things SortSdkSource should do is to get one client by the sort task id, or remove one client when the task is
+ * finished or schedule to other source instance.
+ * </p>
+ *
+ * <p>
+ * The Default Manager of InLong will schedule the partition and topic automatically.
+ * </p>
+ *
+ * <p>
+ * Because all sources should implement {@link Configurable}, the SortSdkSource should have default constructor
+ * <b>WITHOUT</b> any arguments, and parameters will be configured by {@link Configurable#configure(Context)}.
+ * </p>
+ */
+public final class SortSdkSource extends AbstractSource
+ implements
+ Configurable,
+ Runnable,
+ EventDrivenSource,
+ ConsumerServiceMBean {
+
+ // Log of {@link SortSdkSource}.
+ private static final Logger LOG = LoggerFactory.getLogger(SortSdkSource.class);
+
+ public static final String SORT_SDK_PREFIX = "sortsdk.";
+
+ // Default pool of {@link ScheduledExecutorService}.
+ private static final int CORE_POOL_SIZE = 1;
+
+ // Default consume strategy of {@link SortClient}.
+ private static final SortClientConfig.ConsumeStrategy defaultStrategy = SortClientConfig.ConsumeStrategy.lastest;
+
+ private static final String KEY_SORT_SDK_CLIENT_NUM = "sortSdkClientNum";
+ private static final int DEFAULT_SORT_SDK_CLIENT_NUM = 1;
+
+ private String taskName;
+
+ // Context of SortSdkSource.
+ private SortSdkSourceContext context;
+
+ // The cluster name of sort.
+ private String sortClusterName;
+
+ // Reload config interval.
+ private long reloadInterval;
+
+ // Executor for config reloading.
Review Comment:
Remove it.
--
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: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [INLONG-10208][Sort] ClsSink support unified configuration [inlong]
Posted by "vernedeng (via GitHub)" <gi...@apache.org>.
vernedeng commented on code in PR #10220:
URL: https://github.com/apache/inlong/pull/10220#discussion_r1601063266
##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/cls/ClsSinkContext.java:
##########
@@ -104,26 +97,25 @@ public void reload() {
}
});
- SortTaskConfig newSortTaskConfig = SortClusterConfigHolder.getTaskConfig(taskName);
+ SortTaskConfig newSortTaskConfig = SortConfigHolder.getTaskConfig(taskName);
if (newSortTaskConfig == null || newSortTaskConfig.equals(sortTaskConfig)) {
return;
}
LOG.info("get new SortTaskConfig:taskName:{}:config:{}", taskName,
new ObjectMapper().writeValueAsString(newSortTaskConfig));
this.sortTaskConfig = newSortTaskConfig;
Review Comment:
The config update problem will be fixed in #10224
--
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: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [INLONG-10208][Sort] ClsSink support unified configuration [inlong]
Posted by "vernedeng (via GitHub)" <gi...@apache.org>.
vernedeng commented on code in PR #10220:
URL: https://github.com/apache/inlong/pull/10220#discussion_r1600107560
##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/v2/SinkContext.java:
##########
@@ -0,0 +1,171 @@
+/*
+ * 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.inlong.sort.standalone.sink.v2;
+
+import org.apache.inlong.common.metric.MetricRegister;
+import org.apache.inlong.common.pojo.sort.SortTaskConfig;
+import org.apache.inlong.sort.standalone.channel.ProfileEvent;
+import org.apache.inlong.sort.standalone.config.holder.CommonPropertiesHolder;
+import org.apache.inlong.sort.standalone.config.holder.v2.SortConfigHolder;
+import org.apache.inlong.sort.standalone.metrics.SortMetricItem;
+import org.apache.inlong.sort.standalone.metrics.SortMetricItemSet;
+import org.apache.inlong.sort.standalone.utils.BufferQueue;
+import org.apache.inlong.sort.standalone.utils.InlongLoggerFactory;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.flume.Channel;
+import org.apache.flume.Context;
+import org.slf4j.Logger;
+
+import java.util.Date;
+import java.util.Map;
+import java.util.Timer;
+import java.util.TimerTask;
+
Review Comment:
Not all fields need to be set or get
--
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: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [INLONG-10208][Sort] ClsSink support unified configuration [inlong]
Posted by "fuweng11 (via GitHub)" <gi...@apache.org>.
fuweng11 commented on code in PR #10220:
URL: https://github.com/apache/inlong/pull/10220#discussion_r1599916556
##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/v2/SinkContext.java:
##########
@@ -0,0 +1,171 @@
+/*
+ * 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.inlong.sort.standalone.sink.v2;
+
+import org.apache.inlong.common.metric.MetricRegister;
+import org.apache.inlong.common.pojo.sort.SortTaskConfig;
+import org.apache.inlong.sort.standalone.channel.ProfileEvent;
+import org.apache.inlong.sort.standalone.config.holder.CommonPropertiesHolder;
+import org.apache.inlong.sort.standalone.config.holder.v2.SortConfigHolder;
+import org.apache.inlong.sort.standalone.metrics.SortMetricItem;
+import org.apache.inlong.sort.standalone.metrics.SortMetricItemSet;
+import org.apache.inlong.sort.standalone.utils.BufferQueue;
+import org.apache.inlong.sort.standalone.utils.InlongLoggerFactory;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.flume.Channel;
+import org.apache.flume.Context;
+import org.slf4j.Logger;
+
+import java.util.Date;
+import java.util.Map;
+import java.util.Timer;
+import java.util.TimerTask;
+
Review Comment:
@Data
--
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: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [INLONG-10208][Sort] ClsSink support unified configuration [inlong]
Posted by "vernedeng (via GitHub)" <gi...@apache.org>.
vernedeng commented on code in PR #10220:
URL: https://github.com/apache/inlong/pull/10220#discussion_r1600103114
##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/source/sortsdk/v2/SortSdkSource.java:
##########
@@ -0,0 +1,224 @@
+/*
+ * 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.inlong.sort.standalone.source.sortsdk.v2;
+
+import org.apache.inlong.sdk.commons.admin.AdminServiceRegister;
+import org.apache.inlong.sdk.sort.api.QueryConsumeConfig;
+import org.apache.inlong.sdk.sort.api.SortClient;
+import org.apache.inlong.sdk.sort.api.SortClientConfig;
+import org.apache.inlong.sdk.sort.api.SortClientFactory;
+import org.apache.inlong.sort.standalone.admin.ConsumerServiceMBean;
+import org.apache.inlong.sort.standalone.config.holder.CommonPropertiesHolder;
+import org.apache.inlong.sort.standalone.config.holder.ManagerUrlHandler;
+import org.apache.inlong.sort.standalone.config.holder.SortClusterConfigType;
+import org.apache.inlong.sort.standalone.config.holder.SortSourceConfigType;
+import org.apache.inlong.sort.standalone.config.holder.v2.SortConfigHolder;
+import org.apache.inlong.sort.standalone.config.loader.ClassResourceQueryConsumeConfig;
+import org.apache.inlong.sort.standalone.source.sortsdk.DefaultTopicChangeListener;
+import org.apache.inlong.sort.standalone.source.sortsdk.FetchCallback;
+import org.apache.inlong.sort.standalone.source.sortsdk.SortSdkSourceContext;
+import org.apache.inlong.sort.standalone.utils.v2.FlumeConfigGenerator;
+
+import org.apache.commons.lang3.ClassUtils;
+import org.apache.flume.Context;
+import org.apache.flume.EventDrivenSource;
+import org.apache.flume.conf.Configurable;
+import org.apache.flume.source.AbstractSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Default Source implementation of InLong.
+ *
+ * <p>
+ * SortSdkSource acquired msg from different upstream data store by register {@link SortClient} for each sort task. The
+ * only things SortSdkSource should do is to get one client by the sort task id, or remove one client when the task is
+ * finished or schedule to other source instance.
+ * </p>
+ *
+ * <p>
+ * The Default Manager of InLong will schedule the partition and topic automatically.
+ * </p>
+ *
+ * <p>
+ * Because all sources should implement {@link Configurable}, the SortSdkSource should have default constructor
+ * <b>WITHOUT</b> any arguments, and parameters will be configured by {@link Configurable#configure(Context)}.
+ * </p>
+ */
+public final class SortSdkSource extends AbstractSource
+ implements
+ Configurable,
+ Runnable,
+ EventDrivenSource,
+ ConsumerServiceMBean {
+
+ // Log of {@link SortSdkSource}.
+ private static final Logger LOG = LoggerFactory.getLogger(SortSdkSource.class);
+
+ public static final String SORT_SDK_PREFIX = "sortsdk.";
+
+ // Default pool of {@link ScheduledExecutorService}.
+ private static final int CORE_POOL_SIZE = 1;
+
+ // Default consume strategy of {@link SortClient}.
+ private static final SortClientConfig.ConsumeStrategy defaultStrategy = SortClientConfig.ConsumeStrategy.lastest;
+
+ private static final String KEY_SORT_SDK_CLIENT_NUM = "sortSdkClientNum";
+ private static final int DEFAULT_SORT_SDK_CLIENT_NUM = 1;
+
+ private String taskName;
+
+ // Context of SortSdkSource.
+ private SortSdkSourceContext context;
+
+ // The cluster name of sort.
+ private String sortClusterName;
+
+ // Reload config interval.
+ private long reloadInterval;
+
+ // Executor for config reloading.
+ private ScheduledExecutorService pool;
+
+ private List<SortClient> sortClients = new ArrayList<>();
+
+ @Override
+ public synchronized void start() {
+ int sortSdkClientNum = CommonPropertiesHolder.getInteger(KEY_SORT_SDK_CLIENT_NUM, DEFAULT_SORT_SDK_CLIENT_NUM);
+ LOG.info("start to SortSdkSource:{}, client num is {}", taskName, sortSdkClientNum);
+ for (int i = 0; i < sortSdkClientNum; i++) {
+ this.sortClients.add(this.newClient(taskName));
+ }
+ }
+
+ @Override
+ public void stop() {
+ pool.shutdownNow();
+ LOG.info("close sort client {}.", taskName);
+ for (SortClient sortClient : sortClients) {
+ sortClient.getConfig().setStopConsume(true);
+ sortClient.close();
+ }
+ }
+
+ @Override
+ public void run() {
+ LOG.info("start to reload SortSdkSource:{}", taskName);
+ for (SortClient sortClient : sortClients) {
+ sortClient.getConfig().setManagerApiUrl(ManagerUrlHandler.getSortSourceConfigUrl());
+ }
+ }
+
+ @Override
+ public void configure(Context context) {
+ this.taskName = context.getString(FlumeConfigGenerator.KEY_TASK_NAME);
+ this.context = new SortSdkSourceContext(getName(), context);
+ this.sortClusterName = SortConfigHolder.getSortConfig().getSortClusterName();
+ this.reloadInterval = this.context.getReloadInterval();
+ this.initReloadExecutor();
+ // register
+ AdminServiceRegister.register(ConsumerServiceMBean.MBEAN_TYPE, taskName, this);
+ }
+
+ private void initReloadExecutor() {
+ this.pool = Executors.newScheduledThreadPool(CORE_POOL_SIZE);
+ pool.scheduleAtFixedRate(this, reloadInterval, reloadInterval, TimeUnit.SECONDS);
+ }
+
+ private SortClient newClient(final String sortTaskName) {
+ LOG.info("start to new sort client for task: {}", sortTaskName);
+ try {
+ final SortClientConfig clientConfig = new SortClientConfig(sortTaskName, this.sortClusterName,
+ new DefaultTopicChangeListener(),
+ SortSdkSource.defaultStrategy, InetAddress.getLocalHost().getHostAddress());
+ final FetchCallback callback = FetchCallback.Factory.create(sortTaskName, getChannelProcessor(), context);
+ clientConfig.setCallback(callback);
+ Map<String, String> sortSdkParams = this.getSortClientConfigParameters();
+ clientConfig.setParameters(sortSdkParams);
+
+ // create SortClient
+ String configType = CommonPropertiesHolder
+ .getString(SortSourceConfigType.KEY_TYPE, SortSourceConfigType.MANAGER.name());
+ SortClient client = null;
+ if (SortClusterConfigType.FILE.name().equalsIgnoreCase(configType)) {
+ LOG.info("create sort sdk client in file way:{}", configType);
+ ClassResourceQueryConsumeConfig queryConfig = new ClassResourceQueryConsumeConfig();
+ client = SortClientFactory.createSortClient(clientConfig, queryConfig);
+ } else if (SortClusterConfigType.MANAGER.name().equalsIgnoreCase(configType)) {
+ LOG.info("create sort sdk client in manager way:{}", configType);
+ clientConfig.setManagerApiUrl(ManagerUrlHandler.getSortSourceConfigUrl());
+ client = SortClientFactory.createSortClient(clientConfig);
+ } else {
+ LOG.info("create sort sdk client in custom way:{}", configType);
+ // user-defined
Review Comment:
fixed
##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/source/sortsdk/v2/SortSdkSource.java:
##########
@@ -0,0 +1,224 @@
+/*
+ * 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.inlong.sort.standalone.source.sortsdk.v2;
+
+import org.apache.inlong.sdk.commons.admin.AdminServiceRegister;
+import org.apache.inlong.sdk.sort.api.QueryConsumeConfig;
+import org.apache.inlong.sdk.sort.api.SortClient;
+import org.apache.inlong.sdk.sort.api.SortClientConfig;
+import org.apache.inlong.sdk.sort.api.SortClientFactory;
+import org.apache.inlong.sort.standalone.admin.ConsumerServiceMBean;
+import org.apache.inlong.sort.standalone.config.holder.CommonPropertiesHolder;
+import org.apache.inlong.sort.standalone.config.holder.ManagerUrlHandler;
+import org.apache.inlong.sort.standalone.config.holder.SortClusterConfigType;
+import org.apache.inlong.sort.standalone.config.holder.SortSourceConfigType;
+import org.apache.inlong.sort.standalone.config.holder.v2.SortConfigHolder;
+import org.apache.inlong.sort.standalone.config.loader.ClassResourceQueryConsumeConfig;
+import org.apache.inlong.sort.standalone.source.sortsdk.DefaultTopicChangeListener;
+import org.apache.inlong.sort.standalone.source.sortsdk.FetchCallback;
+import org.apache.inlong.sort.standalone.source.sortsdk.SortSdkSourceContext;
+import org.apache.inlong.sort.standalone.utils.v2.FlumeConfigGenerator;
+
+import org.apache.commons.lang3.ClassUtils;
+import org.apache.flume.Context;
+import org.apache.flume.EventDrivenSource;
+import org.apache.flume.conf.Configurable;
+import org.apache.flume.source.AbstractSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Default Source implementation of InLong.
+ *
+ * <p>
+ * SortSdkSource acquired msg from different upstream data store by register {@link SortClient} for each sort task. The
+ * only things SortSdkSource should do is to get one client by the sort task id, or remove one client when the task is
+ * finished or schedule to other source instance.
+ * </p>
+ *
+ * <p>
+ * The Default Manager of InLong will schedule the partition and topic automatically.
+ * </p>
+ *
+ * <p>
+ * Because all sources should implement {@link Configurable}, the SortSdkSource should have default constructor
+ * <b>WITHOUT</b> any arguments, and parameters will be configured by {@link Configurable#configure(Context)}.
+ * </p>
+ */
+public final class SortSdkSource extends AbstractSource
+ implements
+ Configurable,
+ Runnable,
+ EventDrivenSource,
+ ConsumerServiceMBean {
+
+ // Log of {@link SortSdkSource}.
+ private static final Logger LOG = LoggerFactory.getLogger(SortSdkSource.class);
+
+ public static final String SORT_SDK_PREFIX = "sortsdk.";
+
+ // Default pool of {@link ScheduledExecutorService}.
+ private static final int CORE_POOL_SIZE = 1;
+
+ // Default consume strategy of {@link SortClient}.
+ private static final SortClientConfig.ConsumeStrategy defaultStrategy = SortClientConfig.ConsumeStrategy.lastest;
+
+ private static final String KEY_SORT_SDK_CLIENT_NUM = "sortSdkClientNum";
+ private static final int DEFAULT_SORT_SDK_CLIENT_NUM = 1;
+
+ private String taskName;
+
+ // Context of SortSdkSource.
Review Comment:
fixed
--
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: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [INLONG-10208][Sort] ClsSink support unified configuration [inlong]
Posted by "vernedeng (via GitHub)" <gi...@apache.org>.
vernedeng commented on code in PR #10220:
URL: https://github.com/apache/inlong/pull/10220#discussion_r1600099943
##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/v2/SinkContext.java:
##########
@@ -0,0 +1,171 @@
+/*
+ * 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.inlong.sort.standalone.sink.v2;
+
+import org.apache.inlong.common.metric.MetricRegister;
+import org.apache.inlong.common.pojo.sort.SortTaskConfig;
+import org.apache.inlong.sort.standalone.channel.ProfileEvent;
+import org.apache.inlong.sort.standalone.config.holder.CommonPropertiesHolder;
+import org.apache.inlong.sort.standalone.config.holder.v2.SortConfigHolder;
+import org.apache.inlong.sort.standalone.metrics.SortMetricItem;
+import org.apache.inlong.sort.standalone.metrics.SortMetricItemSet;
+import org.apache.inlong.sort.standalone.utils.BufferQueue;
+import org.apache.inlong.sort.standalone.utils.InlongLoggerFactory;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.flume.Channel;
+import org.apache.flume.Context;
+import org.slf4j.Logger;
+
+import java.util.Date;
+import java.util.Map;
+import java.util.Timer;
+import java.util.TimerTask;
+
+public class SinkContext {
+
+ public static final Logger LOG = InlongLoggerFactory.getLogger(SinkContext.class);
+
+ public static final String KEY_MAX_THREADS = "maxThreads";
+ public static final String KEY_PROCESSINTERVAL = "processInterval";
+ public static final String KEY_RELOADINTERVAL = "reloadInterval";
+ public static final String KEY_TASK_NAME = "taskName";
+ public static final String KEY_MAX_BUFFERQUEUE_SIZE_KB = "maxBufferQueueSizeKb";
+ public static final int DEFAULT_MAX_BUFFERQUEUE_SIZE_KB = 128 * 1024;
+
+ protected final String clusterId;
+ protected final String taskName;
+ protected final String sinkName;
+ protected final Context sinkContext;
+
+ protected SortTaskConfig sortTaskConfig;
+
+ protected final Channel channel;
+ //
+ protected final int maxThreads;
+ protected final long processInterval;
+ protected final long reloadInterval;
+ //
Review Comment:
fixed
##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/v2/SinkContext.java:
##########
@@ -0,0 +1,171 @@
+/*
+ * 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.inlong.sort.standalone.sink.v2;
+
+import org.apache.inlong.common.metric.MetricRegister;
+import org.apache.inlong.common.pojo.sort.SortTaskConfig;
+import org.apache.inlong.sort.standalone.channel.ProfileEvent;
+import org.apache.inlong.sort.standalone.config.holder.CommonPropertiesHolder;
+import org.apache.inlong.sort.standalone.config.holder.v2.SortConfigHolder;
+import org.apache.inlong.sort.standalone.metrics.SortMetricItem;
+import org.apache.inlong.sort.standalone.metrics.SortMetricItemSet;
+import org.apache.inlong.sort.standalone.utils.BufferQueue;
+import org.apache.inlong.sort.standalone.utils.InlongLoggerFactory;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.flume.Channel;
+import org.apache.flume.Context;
+import org.slf4j.Logger;
+
+import java.util.Date;
+import java.util.Map;
+import java.util.Timer;
+import java.util.TimerTask;
+
+public class SinkContext {
+
+ public static final Logger LOG = InlongLoggerFactory.getLogger(SinkContext.class);
+
+ public static final String KEY_MAX_THREADS = "maxThreads";
+ public static final String KEY_PROCESSINTERVAL = "processInterval";
+ public static final String KEY_RELOADINTERVAL = "reloadInterval";
+ public static final String KEY_TASK_NAME = "taskName";
+ public static final String KEY_MAX_BUFFERQUEUE_SIZE_KB = "maxBufferQueueSizeKb";
+ public static final int DEFAULT_MAX_BUFFERQUEUE_SIZE_KB = 128 * 1024;
+
+ protected final String clusterId;
+ protected final String taskName;
+ protected final String sinkName;
+ protected final Context sinkContext;
+
+ protected SortTaskConfig sortTaskConfig;
+
+ protected final Channel channel;
+ //
Review Comment:
fixed
--
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: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [INLONG-10208][Sort] ClsSink support unified configuration [inlong]
Posted by "luchunliang (via GitHub)" <gi...@apache.org>.
luchunliang commented on code in PR #10220:
URL: https://github.com/apache/inlong/pull/10220#discussion_r1600864850
##########
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/cls/ClsSink.java:
##########
@@ -57,13 +47,10 @@ public void start() {
worker.start();
}
} catch (Exception e) {
- LOG.error(e.getMessage(), e);
+ LOG.error("failed to start cls sink", e);
Review Comment:
It's better "LOG.error("failed to start cls sink,error:{}", e.getMessage(), e);".
Log4j will skip exception message in repeat exception.
--
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: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org