huanghuijie преди 4 години
родител
ревизия
458cbf2835

+ 0 - 1
src/main/java/org/holer/common/util/HolerUtil.java

@@ -121,7 +121,6 @@ public class HolerUtil {
         try {
             Runtime.getRuntime().exec(cmd);
         } catch (Exception e) {
-
             log.error("Failed to execute command: " + cmd, e);
         }
     }

+ 5 - 13
src/main/java/org/holer/server/container/ServerContainer.java

@@ -23,26 +23,19 @@ public class ServerContainer
 {
   private static final Logger log = LoggerFactory.getLogger(ServerContainer.class);
 
-  
   private static ServerContainer container = null;
+  private NioEventLoopGroup serverWorker;
+  private NioEventLoopGroup serverBoss;
+  private ServerBootstrap strap;
+
+
   public ServerContainer() {
     this.serverWorker = null;
-    
     this.serverBoss = null;
-    
     this.strap = null;
-    
     init();
   }
 
-  
-  private NioEventLoopGroup serverWorker;
-  
-  private NioEventLoopGroup serverBoss;
-  
-  private ServerBootstrap strap;
-
-  
   public static ServerContainer getContainer() {
     if (null == container) {
       container = new ServerContainer();
@@ -53,7 +46,6 @@ public class ServerContainer
   
   public ServerBootstrap getBootstrap() {
     if (null == this.strap) {
-      
       this.strap = new ServerBootstrap();
       ((ServerBootstrap)this.strap.group(this.serverBoss, this.serverWorker).channel(io.netty.channel.socket.nio.NioServerSocketChannel.class)).childHandler(new ExtraClientInitializer());
     } 

+ 8 - 10
src/main/java/org/holer/server/util/ServerMgr.java

@@ -318,11 +318,9 @@ public class ServerMgr {
         if (null == hc) {
             return;
         }
-
         if (null == hc.getPorts()) {
             hc.setPorts(new HashMap<>());
         }
-
         hc.getPorts().put(port.getPortNum(), port);
         addProxy(port);
         ServerContainer.getContainer().listenPort(port);
@@ -402,7 +400,7 @@ public class ServerMgr {
             return null;
         }
         InetSocketAddress addr = (InetSocketAddress) channel.localAddress();
-        return Integer.valueOf(addr.getPort());
+        return addr.getPort();
     }
 
 
@@ -499,7 +497,7 @@ public class ServerMgr {
 
         HolerMsg msg = new HolerMsg();
         if (null != serialNum) {
-            msg.setSerialNumber(serialNum.longValue());
+            msg.setSerialNumber(serialNum);
         }
         msg.setType(msgType);
         holerChannel.writeAndFlush(msg);
@@ -737,14 +735,14 @@ public class ServerMgr {
     public static Integer clientStatus(String key) {
         Channel ch = getHolerChannel(key);
         if (HolerUtil.isActive(ch)) {
-            return Integer.valueOf(1);
+            return 1;
         }
-        return Integer.valueOf(0);
+        return 0;
     }
 
 
     public static boolean isOnline(String key) {
-        int status = clientStatus(key).intValue();
+        int status = clientStatus(key);
         if (1 == status) {
             return true;
         }
@@ -753,7 +751,7 @@ public class ServerMgr {
 
 
     public static Long countOnlineClient() {
-        Long online = Long.valueOf(0L);
+        Long online = 0L;
         if (MapUtils.isEmpty(holerChannels)) {
             return online;
         }
@@ -761,9 +759,9 @@ public class ServerMgr {
         Set<Map.Entry<String, HolerChannel>> entries = holerChannels.entrySet();
         for (Map.Entry<String, HolerChannel> entry : entries) {
 
-            if (1 == clientStatus((String) entry.getKey()).intValue()) {
+            if (1 == clientStatus((String) entry.getKey())) {
 
-                Long long1, long2 = online = (long1 = online).valueOf(online.longValue() + 1L);
+                Long long1, long2 = online + 1L;
 //                long1;
             }
         }