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/08/25 15:26:41 UTC

[GitHub] [inlong] luchunliang opened a new pull request, #5709: [INLONG-5708][Feature][DataProxy] Provide single flume channel to reduce synchronized operation, and improve DataProxy performance

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

   ### Prepare a Pull Request
   - Title: [INLONG-5708][Feature][DataProxy] Provide single flume channel to reduce synchronized operation, and improve DataProxy performance
   - Fixes #5708 
   
   ### 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 #5709: [INLONG-5708][DataProxy] Provide single flume channel to reduce synchronized operation

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


##########
inlong-dataproxy/dataproxy-source/src/test/java/org/apache/inlong/dataproxy/channel/TestBufferQueueChannel.java:
##########
@@ -0,0 +1,126 @@
+/**
+ * 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.channel;
+
+import org.apache.flume.Channel;
+import org.apache.flume.Context;
+import org.apache.flume.Transaction;
+import org.apache.flume.channel.MemoryChannel;
+import org.apache.flume.event.SimpleEvent;
+import org.junit.Test;
+
+/**
+ * BufferQueueChannelTest
+ * 
+ */
+public class TestBufferQueueChannel {
+
+    /**
+     * testResult
+     * MemoryChannel,times:1000000,transactionSize:1,duration:1363<br>
+     * BufferQueueChannel,times:1000000,transactionSize:1,duration:84,gap:0.9383712399119589<br>
+     * MemoryChannel,times:1000000,transactionSize:10,duration:2818<br>
+     * BufferQueueChannel,times:1000000,transactionSize:10,duration:122,gap:0.9567068843151171<br>
+     * MemoryChannel,times:1000000,transactionSize:100,duration:19189<br>
+     * BufferQueueChannel,times:1000000,transactionSize:100,duration:687,gap:0.9641982385741831<br>
+     * @throws Exception
+     */
+    @Test
+    public void testResult() throws Exception {
+        // init
+        Context memoryContext = new Context();
+        memoryContext.put("capacity", "50000");
+        memoryContext.put("keep-alive", "0");
+        memoryContext.put("transactionCapacity", "200");
+        final MemoryChannel memoryChannel = new MemoryChannel();
+        memoryChannel.configure(memoryContext);
+        memoryChannel.start();
+        // init
+        Context bufferContext = new Context();
+        bufferContext.put("maxBufferQueueCount", "50000");
+        bufferContext.put("maxBufferQueueSizeKb", "50000");
+        final BufferQueueChannel bufferChannel = new BufferQueueChannel();
+        bufferChannel.configure(bufferContext);
+        bufferChannel.start();
+        // times
+        int times = 1000000;
+        // transactionSize=1
+        int transactionSize = 1;
+        long memoryDuration = runChannel(memoryChannel, times, transactionSize);
+        System.out.println(String.format("MemoryChannel,times:%d,transactionSize:%d,duration:%d", times,
+                transactionSize, memoryDuration));
+        long bufferDuration = runChannel(bufferChannel, times, transactionSize);
+        System.out.println(String.format("BufferQueueChannel,times:%d,transactionSize:%d,duration:%d,gap:%s", times,
+                transactionSize, bufferDuration,
+                String.valueOf((memoryDuration - bufferDuration) * 1.0 / memoryDuration)));
+        // transactionSize=10
+        transactionSize = 10;
+        memoryDuration = runChannel(memoryChannel, times, transactionSize);
+        System.out.println(String.format("MemoryChannel,times:%d,transactionSize:%d,duration:%d", times,
+                transactionSize, memoryDuration));
+        bufferDuration = runChannel(bufferChannel, times, transactionSize);
+        System.out.println(String.format("BufferQueueChannel,times:%d,transactionSize:%d,duration:%d,gap:%s", times,
+                transactionSize, bufferDuration,
+                String.valueOf((memoryDuration - bufferDuration) * 1.0 / memoryDuration)));
+        // transactionSize=100
+        transactionSize = 100;
+        memoryDuration = runChannel(memoryChannel, times, transactionSize);
+        System.out.println(String.format("MemoryChannel,times:%d,transactionSize:%d,duration:%d", times,
+                transactionSize, memoryDuration));
+        bufferDuration = runChannel(bufferChannel, times, transactionSize);
+        System.out.println(String.format("BufferQueueChannel,times:%d,transactionSize:%d,duration:%d,gap:%s", times,
+                transactionSize, bufferDuration,
+                String.valueOf((memoryDuration - bufferDuration) * 1.0 / memoryDuration)));
+    }
+
+    /**
+     * runChannel
+     * @param channel
+     * @param times
+     * @param transactionSize
+     * @return
+     */
+    private long runChannel(Channel channel, int times, int transactionSize) {
+        long startTime = System.currentTimeMillis();
+        try {
+            SimpleEvent event = new SimpleEvent();
+            for (int i = 0; i < times; i++) {
+                // put
+                Transaction putTx = channel.getTransaction();
+                putTx.begin();
+                for (int j = 0; j < transactionSize; j++) {
+                    channel.put(event);
+                }
+                putTx.commit();
+                putTx.close();
+                // take
+                Transaction takeTx = channel.getTransaction();
+                takeTx.begin();
+                for (int j = 0; j < transactionSize; j++) {
+                    channel.take();
+                }
+                takeTx.commit();
+                takeTx.close();
+            }
+        } catch (Exception e) {
+            e.printStackTrace();

Review Comment:
   fixed



##########
inlong-dataproxy/dataproxy-source/src/test/java/org/apache/inlong/dataproxy/channel/TestBufferQueueChannel.java:
##########
@@ -0,0 +1,126 @@
+/**
+ * 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.channel;
+
+import org.apache.flume.Channel;
+import org.apache.flume.Context;
+import org.apache.flume.Transaction;
+import org.apache.flume.channel.MemoryChannel;
+import org.apache.flume.event.SimpleEvent;
+import org.junit.Test;
+
+/**
+ * BufferQueueChannelTest
+ * 
+ */
+public class TestBufferQueueChannel {
+
+    /**
+     * testResult
+     * MemoryChannel,times:1000000,transactionSize:1,duration:1363<br>
+     * BufferQueueChannel,times:1000000,transactionSize:1,duration:84,gap:0.9383712399119589<br>
+     * MemoryChannel,times:1000000,transactionSize:10,duration:2818<br>
+     * BufferQueueChannel,times:1000000,transactionSize:10,duration:122,gap:0.9567068843151171<br>
+     * MemoryChannel,times:1000000,transactionSize:100,duration:19189<br>
+     * BufferQueueChannel,times:1000000,transactionSize:100,duration:687,gap:0.9641982385741831<br>
+     * @throws Exception
+     */
+    @Test
+    public void testResult() throws Exception {
+        // init
+        Context memoryContext = new Context();
+        memoryContext.put("capacity", "50000");
+        memoryContext.put("keep-alive", "0");
+        memoryContext.put("transactionCapacity", "200");
+        final MemoryChannel memoryChannel = new MemoryChannel();
+        memoryChannel.configure(memoryContext);
+        memoryChannel.start();
+        // init
+        Context bufferContext = new Context();
+        bufferContext.put("maxBufferQueueCount", "50000");
+        bufferContext.put("maxBufferQueueSizeKb", "50000");
+        final BufferQueueChannel bufferChannel = new BufferQueueChannel();
+        bufferChannel.configure(bufferContext);
+        bufferChannel.start();
+        // times
+        int times = 1000000;
+        // transactionSize=1
+        int transactionSize = 1;
+        long memoryDuration = runChannel(memoryChannel, times, transactionSize);
+        System.out.println(String.format("MemoryChannel,times:%d,transactionSize:%d,duration:%d", times,

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] luchunliang closed pull request #5709: [INLONG-5708][DataProxy] Provide single flume channel to reduce synchronized operation

Posted by GitBox <gi...@apache.org>.
luchunliang closed pull request #5709: [INLONG-5708][DataProxy] Provide single flume channel to reduce synchronized operation
URL: https://github.com/apache/inlong/pull/5709


-- 
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] healchow commented on a diff in pull request #5709: [INLONG-5708][DataProxy] Provide single flume channel to reduce synchronized operation

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


##########
inlong-dataproxy/dataproxy-source/src/test/java/org/apache/inlong/dataproxy/channel/TestBufferQueueChannel.java:
##########
@@ -0,0 +1,126 @@
+/**
+ * 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.channel;
+
+import org.apache.flume.Channel;
+import org.apache.flume.Context;
+import org.apache.flume.Transaction;
+import org.apache.flume.channel.MemoryChannel;
+import org.apache.flume.event.SimpleEvent;
+import org.junit.Test;
+
+/**
+ * BufferQueueChannelTest
+ * 
+ */
+public class TestBufferQueueChannel {
+
+    /**
+     * testResult
+     * MemoryChannel,times:1000000,transactionSize:1,duration:1363<br>
+     * BufferQueueChannel,times:1000000,transactionSize:1,duration:84,gap:0.9383712399119589<br>
+     * MemoryChannel,times:1000000,transactionSize:10,duration:2818<br>
+     * BufferQueueChannel,times:1000000,transactionSize:10,duration:122,gap:0.9567068843151171<br>
+     * MemoryChannel,times:1000000,transactionSize:100,duration:19189<br>
+     * BufferQueueChannel,times:1000000,transactionSize:100,duration:687,gap:0.9641982385741831<br>
+     * @throws Exception
+     */
+    @Test
+    public void testResult() throws Exception {
+        // init
+        Context memoryContext = new Context();
+        memoryContext.put("capacity", "50000");
+        memoryContext.put("keep-alive", "0");
+        memoryContext.put("transactionCapacity", "200");
+        final MemoryChannel memoryChannel = new MemoryChannel();
+        memoryChannel.configure(memoryContext);
+        memoryChannel.start();
+        // init
+        Context bufferContext = new Context();
+        bufferContext.put("maxBufferQueueCount", "50000");
+        bufferContext.put("maxBufferQueueSizeKb", "50000");
+        final BufferQueueChannel bufferChannel = new BufferQueueChannel();
+        bufferChannel.configure(bufferContext);
+        bufferChannel.start();
+        // times
+        int times = 1000000;
+        // transactionSize=1
+        int transactionSize = 1;
+        long memoryDuration = runChannel(memoryChannel, times, transactionSize);
+        System.out.println(String.format("MemoryChannel,times:%d,transactionSize:%d,duration:%d", times,
+                transactionSize, memoryDuration));
+        long bufferDuration = runChannel(bufferChannel, times, transactionSize);
+        System.out.println(String.format("BufferQueueChannel,times:%d,transactionSize:%d,duration:%d,gap:%s", times,
+                transactionSize, bufferDuration,
+                String.valueOf((memoryDuration - bufferDuration) * 1.0 / memoryDuration)));
+        // transactionSize=10
+        transactionSize = 10;
+        memoryDuration = runChannel(memoryChannel, times, transactionSize);
+        System.out.println(String.format("MemoryChannel,times:%d,transactionSize:%d,duration:%d", times,
+                transactionSize, memoryDuration));
+        bufferDuration = runChannel(bufferChannel, times, transactionSize);
+        System.out.println(String.format("BufferQueueChannel,times:%d,transactionSize:%d,duration:%d,gap:%s", times,
+                transactionSize, bufferDuration,
+                String.valueOf((memoryDuration - bufferDuration) * 1.0 / memoryDuration)));
+        // transactionSize=100
+        transactionSize = 100;
+        memoryDuration = runChannel(memoryChannel, times, transactionSize);
+        System.out.println(String.format("MemoryChannel,times:%d,transactionSize:%d,duration:%d", times,
+                transactionSize, memoryDuration));
+        bufferDuration = runChannel(bufferChannel, times, transactionSize);
+        System.out.println(String.format("BufferQueueChannel,times:%d,transactionSize:%d,duration:%d,gap:%s", times,
+                transactionSize, bufferDuration,
+                String.valueOf((memoryDuration - bufferDuration) * 1.0 / memoryDuration)));
+    }
+
+    /**
+     * runChannel
+     * @param channel
+     * @param times
+     * @param transactionSize
+     * @return
+     */
+    private long runChannel(Channel channel, int times, int transactionSize) {
+        long startTime = System.currentTimeMillis();
+        try {
+            SimpleEvent event = new SimpleEvent();
+            for (int i = 0; i < times; i++) {
+                // put
+                Transaction putTx = channel.getTransaction();
+                putTx.begin();
+                for (int j = 0; j < transactionSize; j++) {
+                    channel.put(event);
+                }
+                putTx.commit();
+                putTx.close();
+                // take
+                Transaction takeTx = channel.getTransaction();
+                takeTx.begin();
+                for (int j = 0; j < transactionSize; j++) {
+                    channel.take();
+                }
+                takeTx.commit();
+                takeTx.close();
+            }
+        } catch (Exception e) {
+            e.printStackTrace();

Review Comment:
   Changing to use log framework, thanks.



-- 
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 closed pull request #5709: [INLONG-5708][Feature][DataProxy] Provide single flume channel to reduce synchronized operation, and improve DataProxy performance

Posted by GitBox <gi...@apache.org>.
luchunliang closed pull request #5709: [INLONG-5708][Feature][DataProxy] Provide single flume channel to reduce synchronized operation, and improve DataProxy performance
URL: https://github.com/apache/inlong/pull/5709


-- 
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] healchow commented on a diff in pull request #5709: [INLONG-5708][DataProxy] Provide single flume channel to reduce synchronized operation

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


##########
inlong-dataproxy/dataproxy-source/src/test/java/org/apache/inlong/dataproxy/channel/TestBufferQueueChannel.java:
##########
@@ -0,0 +1,126 @@
+/**
+ * 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.channel;
+
+import org.apache.flume.Channel;
+import org.apache.flume.Context;
+import org.apache.flume.Transaction;
+import org.apache.flume.channel.MemoryChannel;
+import org.apache.flume.event.SimpleEvent;
+import org.junit.Test;
+
+/**
+ * BufferQueueChannelTest
+ * 
+ */
+public class TestBufferQueueChannel {
+
+    /**
+     * testResult
+     * MemoryChannel,times:1000000,transactionSize:1,duration:1363<br>
+     * BufferQueueChannel,times:1000000,transactionSize:1,duration:84,gap:0.9383712399119589<br>
+     * MemoryChannel,times:1000000,transactionSize:10,duration:2818<br>
+     * BufferQueueChannel,times:1000000,transactionSize:10,duration:122,gap:0.9567068843151171<br>
+     * MemoryChannel,times:1000000,transactionSize:100,duration:19189<br>
+     * BufferQueueChannel,times:1000000,transactionSize:100,duration:687,gap:0.9641982385741831<br>
+     * @throws Exception
+     */
+    @Test
+    public void testResult() throws Exception {
+        // init
+        Context memoryContext = new Context();
+        memoryContext.put("capacity", "50000");
+        memoryContext.put("keep-alive", "0");
+        memoryContext.put("transactionCapacity", "200");
+        final MemoryChannel memoryChannel = new MemoryChannel();
+        memoryChannel.configure(memoryContext);
+        memoryChannel.start();
+        // init
+        Context bufferContext = new Context();
+        bufferContext.put("maxBufferQueueCount", "50000");
+        bufferContext.put("maxBufferQueueSizeKb", "50000");
+        final BufferQueueChannel bufferChannel = new BufferQueueChannel();
+        bufferChannel.configure(bufferContext);
+        bufferChannel.start();
+        // times
+        int times = 1000000;
+        // transactionSize=1
+        int transactionSize = 1;
+        long memoryDuration = runChannel(memoryChannel, times, transactionSize);
+        System.out.println(String.format("MemoryChannel,times:%d,transactionSize:%d,duration:%d", times,

Review Comment:
   Suggested using log framework to print the log info.



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