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/02/14 02:14:31 UTC

[GitHub] [incubator-inlong] luchunliang commented on a change in pull request #2395: [INLONG-2377] DataProxy support PB compression protocol format source.

luchunliang commented on a change in pull request #2395:
URL: https://github.com/apache/incubator-inlong/pull/2395#discussion_r805461853



##########
File path: inlong-dataproxy/dataproxy-source/src/main/java/org/apache/inlong/dataproxy/source/tcp/InlongTcpChannelPipelineFactory.java
##########
@@ -0,0 +1,108 @@
+/**
+ * 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.source.tcp;
+
+import java.lang.reflect.Constructor;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.flume.Context;
+import org.apache.flume.conf.Configurable;
+import org.apache.inlong.dataproxy.consts.ConfigConstants;
+import org.apache.inlong.dataproxy.source.SourceContext;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.channel.ChannelPipelineFactory;
+import org.jboss.netty.channel.Channels;
+import org.jboss.netty.channel.SimpleChannelHandler;
+import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import org.jboss.netty.handler.timeout.ReadTimeoutHandler;
+import org.jboss.netty.util.HashedWheelTimer;
+import org.jboss.netty.util.Timer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * InlongTcpChannelPipelineFactory
+ */
+public class InlongTcpChannelPipelineFactory implements ChannelPipelineFactory, Configurable {
+
+    public static final Logger LOG = LoggerFactory.getLogger(InlongTcpChannelPipelineFactory.class);
+    private static final int DEFAULT_READ_IDLE_TIME = 70 * 60 * 1000;
+    private SourceContext sourceContext;
+    private String messageHandlerName;
+    private Timer timer = new HashedWheelTimer();
+
+    /**
+     * get server factory
+     *
+     * @param sourceContext
+     */
+    public InlongTcpChannelPipelineFactory(SourceContext sourceContext) {
+        this.sourceContext = sourceContext;
+    }
+
+    @Override
+    public ChannelPipeline getPipeline() throws Exception {
+        ChannelPipeline cp = Channels.pipeline();
+        return addMessageHandlersTo(cp);
+    }
+
+    /**
+     * get message handlers
+     * 
+     * @param  cp
+     * @return
+     */
+    @SuppressWarnings("unchecked")
+    public ChannelPipeline addMessageHandlersTo(ChannelPipeline cp) {
+        cp.addLast("messageDecoder", new LengthFieldBasedFrameDecoder(
+                sourceContext.getMaxMsgLength(), 0, 4, -4, 0, true));

Review comment:
       fixed 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