You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/10/19 05:34:05 UTC

[GitHub] [inlong] luchunliang opened a new pull request, #6219: [INLONG-6153][DataProxy]Optimize the sink architecture of DataProxy

luchunliang opened a new pull request, #6219:
URL: https://github.com/apache/inlong/pull/6219

   ### Prepare a Pull Request
   - Title: [INLONG-6153][DataProxy]Optimize the sink architecture of DataProxy
   - Fixes #6153 
   
   ### 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


[GitHub] [inlong] luchunliang commented on a diff in pull request #6219: [INLONG-6153][DataProxy]Optimize the sink architecture of DataProxy

Posted by GitBox <gi...@apache.org>.
luchunliang commented on code in PR #6219:
URL: https://github.com/apache/inlong/pull/6219#discussion_r1000207535


##########
inlong-dataproxy/dataproxy-source/src/main/java/org/apache/inlong/dataproxy/sink/common/SinkContext.java:
##########
@@ -0,0 +1,248 @@
+/*
+ * 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.dataproxy.sink.common;
+
+import org.apache.commons.lang.ClassUtils;
+import org.apache.flume.Channel;
+import org.apache.flume.Context;
+import org.apache.inlong.common.metric.MetricRegister;
+import org.apache.inlong.dataproxy.config.holder.CommonPropertiesHolder;
+import org.apache.inlong.dataproxy.config.pojo.CacheClusterConfig;
+import org.apache.inlong.dataproxy.metrics.DataProxyMetricItemSet;
+import org.apache.inlong.dataproxy.sink.mq.BatchPackProfile;
+import org.apache.inlong.dataproxy.sink.mq.MessageQueueHandler;
+import org.apache.inlong.dataproxy.sink.mq.pulsar.PulsarHandler;
+import org.apache.inlong.dataproxy.utils.BufferQueue;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Date;
+import java.util.Timer;
+import java.util.TimerTask;
+
+/**
+ * SinkContext
+ */
+public class SinkContext {
+
+    public static final Logger LOG = LoggerFactory.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_EVENT_HANDLER = "eventHandler";
+    public static final String KEY_MESSAGE_QUEUE_HANDLER = "messageQueueHandler";
+    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 sinkName;
+    protected final Context sinkContext;
+
+    protected final Channel channel;
+    //
+    protected final int maxThreads;
+    protected final long processInterval;
+    protected final long reloadInterval;
+    //
+    protected final DataProxyMetricItemSet metricItemSet;
+    protected Timer reloadTimer;
+
+    /**
+     * Constructor
+     */
+    public SinkContext(String sinkName, Context context, Channel channel) {
+        this.sinkName = sinkName;
+        this.sinkContext = context;
+        this.channel = channel;
+        this.clusterId = CommonPropertiesHolder.getString(CommonPropertiesHolder.KEY_PROXY_CLUSTER_NAME);
+        this.maxThreads = sinkContext.getInteger(KEY_MAX_THREADS, 10);
+        this.processInterval = sinkContext.getInteger(KEY_PROCESSINTERVAL, 100);
+        this.reloadInterval = sinkContext.getLong(KEY_RELOADINTERVAL, 60000L);
+        //
+        this.metricItemSet = new DataProxyMetricItemSet(sinkName);
+        MetricRegister.register(this.metricItemSet);
+    }
+
+    /**
+     * start
+     */
+    public void start() {
+        try {
+            this.reload();
+            this.setReloadTimer();
+        } catch (Exception e) {
+            LOG.error(e.getMessage(), e);
+        }
+    }
+
+    /**
+     * close
+     */
+    public void close() {
+        try {
+            this.reloadTimer.cancel();
+        } catch (Exception e) {
+            LOG.error(e.getMessage(), e);
+        }
+    }
+
+    /**
+     * setReloadTimer
+     */
+    protected void setReloadTimer() {
+        reloadTimer = new Timer(true);
+        TimerTask task = new TimerTask() {
+
+            public void run() {
+                reload();
+            }
+        };
+        reloadTimer.schedule(task, new Date(System.currentTimeMillis() + reloadInterval), reloadInterval);
+    }
+
+    /**
+     * reload
+     */
+    public void reload() {
+    }
+
+    /**
+     * get clusterId
+     * 
+     * @return the clusterId
+     */
+    public String getClusterId() {
+        return clusterId;
+    }
+
+    /**
+     * get sinkName
+     * 
+     * @return the sinkName
+     */
+    public String getSinkName() {
+        return sinkName;
+    }
+
+    /**
+     * get sinkContext
+     * 
+     * @return the sinkContext
+     */
+    public Context getSinkContext() {
+        return sinkContext;
+    }
+
+    /**
+     * get channel
+     * 
+     * @return the channel
+     */
+    public Channel getChannel() {
+        return channel;
+    }
+
+    /**
+     * get maxThreads
+     * 
+     * @return the maxThreads
+     */
+    public int getMaxThreads() {
+        return maxThreads;
+    }
+
+    /**
+     * get processInterval
+     * 
+     * @return the processInterval
+     */
+    public long getProcessInterval() {
+        return processInterval;
+    }
+
+    /**
+     * get reloadInterval
+     * 
+     * @return the reloadInterval
+     */
+    public long getReloadInterval() {
+        return reloadInterval;
+    }
+
+    /**
+     * get metricItemSet
+     * 
+     * @return the metricItemSet
+     */
+    public DataProxyMetricItemSet getMetricItemSet() {
+        return metricItemSet;
+    }
+
+    /**
+     * create createEventHandler

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


[GitHub] [inlong] vernedeng commented on a diff in pull request #6219: [INLONG-6153][DataProxy]Optimize the sink architecture of DataProxy

Posted by GitBox <gi...@apache.org>.
vernedeng commented on code in PR #6219:
URL: https://github.com/apache/inlong/pull/6219#discussion_r998988258


##########
inlong-dataproxy/dataproxy-source/src/main/java/org/apache/inlong/dataproxy/sink/mq/BatchPackManager.java:
##########
@@ -0,0 +1,209 @@
+/**
+ * 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.dataproxy.sink.mq;
+
+import org.apache.flume.Context;
+import org.apache.inlong.dataproxy.utils.BufferQueue;
+import org.apache.inlong.sdk.commons.protocol.ProxyEvent;
+import org.apache.inlong.sdk.commons.protocol.ProxyPackEvent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * DispatchManager

Review Comment:
   BatchPackManager



-- 
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


[GitHub] [inlong] luchunliang commented on a diff in pull request #6219: [INLONG-6153][DataProxy]Optimize the sink architecture of DataProxy

Posted by GitBox <gi...@apache.org>.
luchunliang commented on code in PR #6219:
URL: https://github.com/apache/inlong/pull/6219#discussion_r1000207370


##########
inlong-dataproxy/dataproxy-source/src/main/java/org/apache/inlong/dataproxy/sink/mq/BatchPackManager.java:
##########
@@ -0,0 +1,209 @@
+/**
+ * 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.dataproxy.sink.mq;
+
+import org.apache.flume.Context;
+import org.apache.inlong.dataproxy.utils.BufferQueue;
+import org.apache.inlong.sdk.commons.protocol.ProxyEvent;
+import org.apache.inlong.sdk.commons.protocol.ProxyPackEvent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * DispatchManager

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


[GitHub] [inlong] dockerzhang merged pull request #6219: [INLONG-6153][DataProxy] Optimize the sink architecture

Posted by GitBox <gi...@apache.org>.
dockerzhang merged PR #6219:
URL: https://github.com/apache/inlong/pull/6219


-- 
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


[GitHub] [inlong] vernedeng commented on a diff in pull request #6219: [INLONG-6153][DataProxy]Optimize the sink architecture of DataProxy

Posted by GitBox <gi...@apache.org>.
vernedeng commented on code in PR #6219:
URL: https://github.com/apache/inlong/pull/6219#discussion_r998987485


##########
inlong-dataproxy/dataproxy-source/src/main/java/org/apache/inlong/dataproxy/sink/common/SinkContext.java:
##########
@@ -0,0 +1,248 @@
+/*
+ * 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.dataproxy.sink.common;
+
+import org.apache.commons.lang.ClassUtils;
+import org.apache.flume.Channel;
+import org.apache.flume.Context;
+import org.apache.inlong.common.metric.MetricRegister;
+import org.apache.inlong.dataproxy.config.holder.CommonPropertiesHolder;
+import org.apache.inlong.dataproxy.config.pojo.CacheClusterConfig;
+import org.apache.inlong.dataproxy.metrics.DataProxyMetricItemSet;
+import org.apache.inlong.dataproxy.sink.mq.BatchPackProfile;
+import org.apache.inlong.dataproxy.sink.mq.MessageQueueHandler;
+import org.apache.inlong.dataproxy.sink.mq.pulsar.PulsarHandler;
+import org.apache.inlong.dataproxy.utils.BufferQueue;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Date;
+import java.util.Timer;
+import java.util.TimerTask;
+
+/**
+ * SinkContext
+ */
+public class SinkContext {
+
+    public static final Logger LOG = LoggerFactory.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_EVENT_HANDLER = "eventHandler";
+    public static final String KEY_MESSAGE_QUEUE_HANDLER = "messageQueueHandler";
+    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 sinkName;
+    protected final Context sinkContext;
+
+    protected final Channel channel;
+    //
+    protected final int maxThreads;
+    protected final long processInterval;
+    protected final long reloadInterval;
+    //
+    protected final DataProxyMetricItemSet metricItemSet;
+    protected Timer reloadTimer;
+
+    /**
+     * Constructor
+     */
+    public SinkContext(String sinkName, Context context, Channel channel) {
+        this.sinkName = sinkName;
+        this.sinkContext = context;
+        this.channel = channel;
+        this.clusterId = CommonPropertiesHolder.getString(CommonPropertiesHolder.KEY_PROXY_CLUSTER_NAME);
+        this.maxThreads = sinkContext.getInteger(KEY_MAX_THREADS, 10);
+        this.processInterval = sinkContext.getInteger(KEY_PROCESSINTERVAL, 100);
+        this.reloadInterval = sinkContext.getLong(KEY_RELOADINTERVAL, 60000L);
+        //
+        this.metricItemSet = new DataProxyMetricItemSet(sinkName);
+        MetricRegister.register(this.metricItemSet);
+    }
+
+    /**
+     * start
+     */
+    public void start() {
+        try {
+            this.reload();
+            this.setReloadTimer();
+        } catch (Exception e) {
+            LOG.error(e.getMessage(), e);
+        }
+    }
+
+    /**
+     * close
+     */
+    public void close() {
+        try {
+            this.reloadTimer.cancel();
+        } catch (Exception e) {
+            LOG.error(e.getMessage(), e);
+        }
+    }
+
+    /**
+     * setReloadTimer
+     */
+    protected void setReloadTimer() {
+        reloadTimer = new Timer(true);
+        TimerTask task = new TimerTask() {
+
+            public void run() {
+                reload();
+            }
+        };
+        reloadTimer.schedule(task, new Date(System.currentTimeMillis() + reloadInterval), reloadInterval);
+    }
+
+    /**
+     * reload
+     */
+    public void reload() {
+    }
+
+    /**
+     * get clusterId
+     * 
+     * @return the clusterId
+     */
+    public String getClusterId() {
+        return clusterId;
+    }
+
+    /**
+     * get sinkName
+     * 
+     * @return the sinkName
+     */
+    public String getSinkName() {
+        return sinkName;
+    }
+
+    /**
+     * get sinkContext
+     * 
+     * @return the sinkContext
+     */
+    public Context getSinkContext() {
+        return sinkContext;
+    }
+
+    /**
+     * get channel
+     * 
+     * @return the channel
+     */
+    public Channel getChannel() {
+        return channel;
+    }
+
+    /**
+     * get maxThreads
+     * 
+     * @return the maxThreads
+     */
+    public int getMaxThreads() {
+        return maxThreads;
+    }
+
+    /**
+     * get processInterval
+     * 
+     * @return the processInterval
+     */
+    public long getProcessInterval() {
+        return processInterval;
+    }
+
+    /**
+     * get reloadInterval
+     * 
+     * @return the reloadInterval
+     */
+    public long getReloadInterval() {
+        return reloadInterval;
+    }
+
+    /**
+     * get metricItemSet
+     * 
+     * @return the metricItemSet
+     */
+    public DataProxyMetricItemSet getMetricItemSet() {
+        return metricItemSet;
+    }
+
+    /**
+     * create createEventHandler

Review Comment:
   redundant comment



-- 
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