diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingClientFactory.java b/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingClientFactory.java index b5e5a91c93c7bd1d40f65b7e98550a3e0a929f9d..04534064d1f68f00fea5ac41e9a3f6b9515d0717 100644 --- a/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingClientFactory.java +++ b/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingClientFactory.java @@ -17,16 +17,13 @@ package org.apache.rocketmq.remoting; import java.util.Map; -import org.apache.rocketmq.logging.InternalLogger; -import org.apache.rocketmq.logging.InternalLoggerFactory; -import org.apache.rocketmq.remoting.common.RemotingHelper; import org.apache.rocketmq.remoting.common.RemotingUtil; import org.apache.rocketmq.remoting.util.ServiceProvider; public class RemotingClientFactory { private static RemotingClientFactory instance = new RemotingClientFactory(); - public static RemotingClientFactory getInstance(){ + public static RemotingClientFactory getInstance() { return instance; } diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingServerFactory.java b/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingServerFactory.java index 231e19a0e754bea2cc99a8e2f105d895d5db48b1..7c75e8a58f56fb79494e238e09801eed324d8fba 100644 --- a/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingServerFactory.java +++ b/remoting/src/main/java/org/apache/rocketmq/remoting/RemotingServerFactory.java @@ -17,9 +17,6 @@ package org.apache.rocketmq.remoting; import java.util.Map; -import org.apache.rocketmq.logging.InternalLogger; -import org.apache.rocketmq.logging.InternalLoggerFactory; -import org.apache.rocketmq.remoting.common.RemotingHelper; import org.apache.rocketmq.remoting.common.RemotingUtil; import org.apache.rocketmq.remoting.util.ServiceProvider; diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingHelper.java b/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingHelper.java index fd8aa1ed83aa427e2e00cb3fc6e94b4c8090485f..fab19239b2ee2856e90de32e258f6edb7c1e37c1 100644 --- a/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingHelper.java +++ b/remoting/src/main/java/org/apache/rocketmq/remoting/common/RemotingHelper.java @@ -17,18 +17,11 @@ package org.apache.rocketmq.remoting.common; import io.netty.channel.Channel; -import org.apache.rocketmq.remoting.exception.RemotingConnectException; -import org.apache.rocketmq.remoting.exception.RemotingSendRequestException; -import org.apache.rocketmq.remoting.exception.RemotingTimeoutException; import org.apache.rocketmq.logging.InternalLogger; import org.apache.rocketmq.logging.InternalLoggerFactory; -import org.apache.rocketmq.remoting.protocol.RemotingCommand; - -import java.io.IOException; import java.net.InetSocketAddress; import java.net.SocketAddress; -import java.nio.ByteBuffer; -import java.nio.channels.SocketChannel; + public class RemotingHelper { public static final String ROCKETMQ_REMOTING = "RocketmqRemoting"; diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/CodecHelper.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/CodecHelper.java index 193cd398d3310391d2d993ede4bd1a091f26349e..4ce5cd7abc14814957ee76a7ef9c9661ad5ad4bd 100644 --- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/CodecHelper.java +++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/CodecHelper.java @@ -1,3 +1,19 @@ +/* + * 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.rocketmq.remoting.netty; import java.lang.annotation.Annotation; @@ -10,8 +26,6 @@ import org.apache.rocketmq.remoting.CommandCustomHeader; import org.apache.rocketmq.remoting.annotation.CFNotNull; import org.apache.rocketmq.remoting.exception.RemotingCommandException; import org.apache.rocketmq.remoting.protocol.RemotingCommand; -import org.apache.rocketmq.remoting.serialize.RemotingSerializable; -import org.apache.rocketmq.remoting.serialize.RocketMQSerializable; import org.apache.rocketmq.remoting.serialize.SerializeType; import org.apache.rocketmq.remoting.serialize.Serializer; import org.apache.rocketmq.remoting.serialize.SerializerFactory; diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingAbstract.java b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingAbstract.java index 1555959b0d3fc91818778ae4a851bc18a8be6c7f..9adb1fc237afd92dded27398bebf474c2ea6d223 100644 --- a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingAbstract.java +++ b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingAbstract.java @@ -296,7 +296,7 @@ public abstract class NettyRemotingAbstract { responseFuture.release(); } } else { - log.warn("receive response, but not matched any request: {}, cmd: {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()), cmd); + log.warn("receive response, but not matched any request: {}, cmd: {}", RemotingHelper.parseChannelRemoteAddr(ctx.channel()), cmd); } } diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/transport/http2/Http2ClientImpl.java b/remoting/src/main/java/org/apache/rocketmq/remoting/transport/http2/Http2ClientImpl.java index fb9e3f8beec50bc7d043ed56d2243809cb1747c2..9b278245d95b68925321a0a58ba12d9dd0592cbb 100644 --- a/remoting/src/main/java/org/apache/rocketmq/remoting/transport/http2/Http2ClientImpl.java +++ b/remoting/src/main/java/org/apache/rocketmq/remoting/transport/http2/Http2ClientImpl.java @@ -75,7 +75,7 @@ public class Http2ClientImpl extends NettyRemotingClientAbstract implements Remo init(clientConfig, channelEventListener); } - public Http2ClientImpl(){ + public Http2ClientImpl() { super(); } diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/transport/http2/Http2ServerImpl.java b/remoting/src/main/java/org/apache/rocketmq/remoting/transport/http2/Http2ServerImpl.java index 3352127d1ce17f7ea6a17ca5a8eb3b56901b38a4..d1dbcf19278460ce2cdbe049444a3438b55bf0a6 100644 --- a/remoting/src/main/java/org/apache/rocketmq/remoting/transport/http2/Http2ServerImpl.java +++ b/remoting/src/main/java/org/apache/rocketmq/remoting/transport/http2/Http2ServerImpl.java @@ -208,26 +208,23 @@ public class Http2ServerImpl extends NettyRemotingServerAbstract implements Remo final ChannelGroup channels = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE); this.serverBootstrap.group(this.bossGroup, this.ioGroup). channel(socketChannelClass).childHandler(new ChannelInitializer() { - @Override - public void initChannel(SocketChannel ch) throws Exception { - channels.add(ch); - - ChannelPipeline cp = ch.pipeline(); - - cp.addLast(ChannelStatisticsHandler.NAME, new ChannelStatisticsHandler(channels)); - - cp.addLast(workerGroup, - Http2Handler.newHandler(true), - new NettyEncoder(), - new NettyDecoder(), - new IdleStateHandler(serverConfig.getConnectionChannelReaderIdleSeconds(), - serverConfig.getConnectionChannelWriterIdleSeconds(), - serverConfig.getServerChannelMaxIdleTimeSeconds()), - new NettyConnectManageHandler(), - new NettyServerHandler()); - } - }); + @Override + public void initChannel(SocketChannel ch) throws Exception { + channels.add(ch); + ChannelPipeline cp = ch.pipeline(); + cp.addLast(ChannelStatisticsHandler.NAME, new ChannelStatisticsHandler(channels)); + cp.addLast(workerGroup, + Http2Handler.newHandler(true), + new NettyEncoder(), + new NettyDecoder(), + new IdleStateHandler(serverConfig.getConnectionChannelReaderIdleSeconds(), + serverConfig.getConnectionChannelWriterIdleSeconds(), + serverConfig.getServerChannelMaxIdleTimeSeconds()), + new NettyConnectManageHandler(), + new NettyServerHandler()); + } + }); applyOptions(serverBootstrap); ChannelFuture channelFuture = this.serverBootstrap.bind(this.port).syncUninterruptibly(); diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/util/ServiceProvider.java b/remoting/src/main/java/org/apache/rocketmq/remoting/util/ServiceProvider.java index 586a846847a5343c7e70a59abf266b60bd4a1a01..cef31f244d1159465133d399080954cca6f8c920 100644 --- a/remoting/src/main/java/org/apache/rocketmq/remoting/util/ServiceProvider.java +++ b/remoting/src/main/java/org/apache/rocketmq/remoting/util/ServiceProvider.java @@ -19,7 +19,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; import org.apache.rocketmq.logging.InternalLogger; import org.apache.rocketmq.logging.InternalLoggerFactory; import org.apache.rocketmq.remoting.common.RemotingHelper;