This is an automated email from the ASF dual-hosted git repository.

yukon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-remoting.git

commit 7bf26e003644d9fa52e37a9b5796c617ba801e83
Author: yukon <[email protected]>
AuthorDate: Wed May 22 17:18:27 2019 +0800

    Remove ChannelStatistics
---
 .../remoting/impl/netty/NettyRemotingServer.java   |  8 ---
 .../impl/netty/handler/ChannelStatistics.java      | 61 ----------------------
 2 files changed, 69 deletions(-)

diff --git 
a/remoting-core/remoting-impl/src/main/java/org/apache/rocketmq/remoting/impl/netty/NettyRemotingServer.java
 
b/remoting-core/remoting-impl/src/main/java/org/apache/rocketmq/remoting/impl/netty/NettyRemotingServer.java
index 0d06336..55ce2d2 100644
--- 
a/remoting-core/remoting-impl/src/main/java/org/apache/rocketmq/remoting/impl/netty/NettyRemotingServer.java
+++ 
b/remoting-core/remoting-impl/src/main/java/org/apache/rocketmq/remoting/impl/netty/NettyRemotingServer.java
@@ -29,8 +29,6 @@ import io.netty.channel.ChannelPipeline;
 import io.netty.channel.EventLoopGroup;
 import io.netty.channel.epoll.EpollEventLoopGroup;
 import io.netty.channel.epoll.EpollServerSocketChannel;
-import io.netty.channel.group.ChannelGroup;
-import io.netty.channel.group.DefaultChannelGroup;
 import io.netty.channel.nio.NioEventLoopGroup;
 import io.netty.channel.socket.ServerSocketChannel;
 import io.netty.channel.socket.SocketChannel;
@@ -40,7 +38,6 @@ import io.netty.handler.timeout.IdleStateEvent;
 import io.netty.handler.timeout.IdleStateHandler;
 import io.netty.util.concurrent.DefaultEventExecutorGroup;
 import io.netty.util.concurrent.EventExecutorGroup;
-import io.netty.util.concurrent.GlobalEventExecutor;
 import java.net.InetSocketAddress;
 import java.util.concurrent.TimeUnit;
 import org.apache.rocketmq.remoting.api.AsyncHandler;
@@ -50,7 +47,6 @@ import 
org.apache.rocketmq.remoting.api.command.RemotingCommand;
 import org.apache.rocketmq.remoting.config.RemotingConfig;
 import org.apache.rocketmq.remoting.external.ThreadUtils;
 import org.apache.rocketmq.remoting.impl.channel.NettyChannelImpl;
-import org.apache.rocketmq.remoting.impl.netty.handler.ChannelStatistics;
 import org.apache.rocketmq.remoting.impl.netty.handler.Decoder;
 import org.apache.rocketmq.remoting.impl.netty.handler.Encoder;
 import org.apache.rocketmq.remoting.internal.JvmUtils;
@@ -98,16 +94,12 @@ public class NettyRemotingServer extends 
NettyRemotingAbstract implements Remoti
     public void start() {
         super.start();
 
-        final ChannelGroup channels = new 
DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
         this.serverBootstrap.group(this.bossGroup, this.ioGroup).
             channel(socketChannelClass).childHandler(new 
ChannelInitializer<SocketChannel>() {
             @Override
             public void initChannel(SocketChannel ch) throws Exception {
-                channels.add(ch);
-
                 ChannelPipeline cp = ch.pipeline();
 
-                cp.addLast(ChannelStatistics.NAME, new 
ChannelStatistics(channels));
                 cp.addLast(workerGroup,
                     new Encoder(),
                     new Decoder(),
diff --git 
a/remoting-core/remoting-impl/src/main/java/org/apache/rocketmq/remoting/impl/netty/handler/ChannelStatistics.java
 
b/remoting-core/remoting-impl/src/main/java/org/apache/rocketmq/remoting/impl/netty/handler/ChannelStatistics.java
deleted file mode 100755
index ff0f9c9..0000000
--- 
a/remoting-core/remoting-impl/src/main/java/org/apache/rocketmq/remoting/impl/netty/handler/ChannelStatistics.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.impl.netty.handler;
-
-import io.netty.channel.ChannelDuplexHandler;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.group.ChannelGroup;
-import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.rocketmq.remoting.common.metrics.ChannelMetrics;
-
-public class ChannelStatistics extends ChannelDuplexHandler implements 
ChannelMetrics {
-    public static final String NAME = ChannelStatistics.class.getSimpleName();
-    private final AtomicInteger channelCount = new AtomicInteger(0);
-    private final ChannelGroup allChannels;
-
-    public ChannelStatistics(ChannelGroup allChannels) {
-        this.allChannels = allChannels;
-    }
-
-    @Override
-    public void channelActive(ChannelHandlerContext ctx) throws Exception {
-        // connect
-        channelCount.incrementAndGet();
-        allChannels.add(ctx.channel());
-        super.channelActive(ctx);
-    }
-
-    @Override
-    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
-        // disconnect
-        channelCount.decrementAndGet();
-        allChannels.remove(ctx.channel());
-        super.channelInactive(ctx);
-    }
-
-    @Override
-    public Integer getChannelCount() {
-        return channelCount.get();
-    }
-
-    @Override
-    public ChannelGroup getChannels() {
-        return allChannels;
-    }
-
-}

Reply via email to