Browse Source

* [ci fw-only Java/baseio] update to 3.2.9.beta11 (#4643)

Kai Wang 6 years ago
parent
commit
5bacf63b6f

+ 1 - 0
frameworks/Java/baseio/baseio-http-lite.dockerfile

@@ -19,5 +19,6 @@ CMD java                       \
     -Dlevel=1                  \
     -Dlevel=1                  \
     -Dread=false               \
     -Dread=false               \
     -Depoll=true               \
     -Depoll=true               \
+    -Dnodelay=false            \
     -DunsafeBuf=true           \
     -DunsafeBuf=true           \
     -jar /baseio/target/baseio-example-0.1-jar-with-dependencies.jar
     -jar /baseio/target/baseio-example-0.1-jar-with-dependencies.jar

+ 1 - 0
frameworks/Java/baseio/baseio.dockerfile

@@ -19,5 +19,6 @@ CMD java                       \
     -Dlevel=1                  \
     -Dlevel=1                  \
     -Dread=false               \
     -Dread=false               \
     -Depoll=true               \
     -Depoll=true               \
+    -Dnodelay=false            \
     -DunsafeBuf=true           \
     -DunsafeBuf=true           \
     -jar /baseio/target/baseio-example-0.1-jar-with-dependencies.jar
     -jar /baseio/target/baseio-example-0.1-jar-with-dependencies.jar

+ 1 - 1
frameworks/Java/baseio/pom.xml

@@ -19,7 +19,7 @@
         <dependency>
         <dependency>
             <groupId>com.firenio</groupId>
             <groupId>com.firenio</groupId>
             <artifactId>baseio-all</artifactId>
             <artifactId>baseio-all</artifactId>
-            <version>3.2.9.beta10</version>
+            <version>3.2.9.beta11</version>
         </dependency>
         </dependency>
 
 
         <dependency>
         <dependency>

+ 38 - 30
frameworks/Java/baseio/src/main/java/hello/TestHttpLoadServer.java

@@ -1,12 +1,12 @@
 /*
 /*
  * Copyright 2015 The Baseio Project
  * Copyright 2015 The Baseio Project
- *  
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  * You may obtain a copy of the License at
- *  
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *      http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  * Unless required by applicable law or agreed to in writing, software
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,6 +25,7 @@ import com.firenio.baseio.codec.http11.HttpContentType;
 import com.firenio.baseio.codec.http11.HttpDateUtil;
 import com.firenio.baseio.codec.http11.HttpDateUtil;
 import com.firenio.baseio.codec.http11.HttpFrame;
 import com.firenio.baseio.codec.http11.HttpFrame;
 import com.firenio.baseio.codec.http11.HttpStatus;
 import com.firenio.baseio.codec.http11.HttpStatus;
+import com.firenio.baseio.collection.ByteTree;
 import com.firenio.baseio.common.Util;
 import com.firenio.baseio.common.Util;
 import com.firenio.baseio.component.Channel;
 import com.firenio.baseio.component.Channel;
 import com.firenio.baseio.component.ChannelAcceptor;
 import com.firenio.baseio.component.ChannelAcceptor;
@@ -58,17 +59,18 @@ public class TestHttpLoadServer {
     }
     }
 
 
     public static void main(String[] args) throws Exception {
     public static void main(String[] args) throws Exception {
-        boolean lite = Util.getBooleanProperty("lite");
-        boolean read = Util.getBooleanProperty("read");
-        boolean pool = Util.getBooleanProperty("pool");
-        boolean epoll = Util.getBooleanProperty("epoll");
-        boolean direct = Util.getBooleanProperty("direct");
-        boolean inline = Util.getBooleanProperty("inline");
+        boolean lite      = Util.getBooleanProperty("lite");
+        boolean read      = Util.getBooleanProperty("read");
+        boolean pool      = Util.getBooleanProperty("pool");
+        boolean epoll     = Util.getBooleanProperty("epoll");
+        boolean direct    = Util.getBooleanProperty("direct");
+        boolean inline    = Util.getBooleanProperty("inline");
+        boolean nodelay   = Util.getBooleanProperty("nodelay");
         boolean unsafeBuf = Util.getBooleanProperty("unsafeBuf");
         boolean unsafeBuf = Util.getBooleanProperty("unsafeBuf");
-        int core = Util.getIntProperty("core", 1);
-        int frame = Util.getIntProperty("frame", 16);
-        int level = Util.getIntProperty("level", 1);
-        int readBuf = Util.getIntProperty("readBuf", 16);
+        int     core      = Util.getIntProperty("core", 1);
+        int     frame     = Util.getIntProperty("frame", 16);
+        int     level     = Util.getIntProperty("level", 1);
+        int     readBuf   = Util.getIntProperty("readBuf", 16);
         LoggerFactory.setEnableSLF4JLogger(false);
         LoggerFactory.setEnableSLF4JLogger(false);
         LoggerFactory.setLogLevel(LoggerFactory.LEVEL_INFO);
         LoggerFactory.setLogLevel(LoggerFactory.LEVEL_INFO);
         Options.setBufAutoExpansion(false);
         Options.setBufAutoExpansion(false);
@@ -85,13 +87,14 @@ public class TestHttpLoadServer {
         DebugUtil.info("direct: {}", direct);
         DebugUtil.info("direct: {}", direct);
         DebugUtil.info("inline: {}", inline);
         DebugUtil.info("inline: {}", inline);
         DebugUtil.info("readBuf: {}", readBuf);
         DebugUtil.info("readBuf: {}", readBuf);
+        DebugUtil.info("nodelay: {}", nodelay);
 
 
         IoEventHandle eventHandle = new IoEventHandle() {
         IoEventHandle eventHandle = new IoEventHandle() {
 
 
             @Override
             @Override
             public void accept(Channel ch, Frame frame) throws Exception {
             public void accept(Channel ch, Frame frame) throws Exception {
-                HttpFrame f = (HttpFrame) frame;
-                String action = f.getRequestURL();
+                HttpFrame f      = (HttpFrame) frame;
+                String    action = f.getRequestURL();
                 if ("/plaintext".equals(action)) {
                 if ("/plaintext".equals(action)) {
                     f.setContent(STATIC_PLAINTEXT);
                     f.setContent(STATIC_PLAINTEXT);
                     f.setContentType(HttpContentType.text_plain);
                     f.setContentType(HttpContentType.text_plain);
@@ -112,17 +115,20 @@ public class TestHttpLoadServer {
             }
             }
 
 
         };
         };
-        
-        int fcache = 1024 * 16;
-        int pool_cap = 1024 * 128;
+
+        int fcache    = 1024 * 16;
+        int pool_cap  = 1024 * 128;
         int pool_unit = 256;
         int pool_unit = 256;
         if (inline) {
         if (inline) {
             pool_cap = 1024 * 8;
             pool_cap = 1024 * 8;
             pool_unit = 256 * 16;
             pool_unit = 256 * 16;
         }
         }
+        ByteTree<String> cachedUrls = new ByteTree<>();
+        cachedUrls.add("/plaintext");
+        cachedUrls.add("/json");
         HttpDateUtil.start();
         HttpDateUtil.start();
-        NioEventLoopGroup group = new NioEventLoopGroup();
-        ChannelAcceptor context = new ChannelAcceptor(group, 8080);
+        NioEventLoopGroup group   = new NioEventLoopGroup();
+        ChannelAcceptor   context = new ChannelAcceptor(group, 8080);
         group.setMemoryPoolCapacity(pool_cap);
         group.setMemoryPoolCapacity(pool_cap);
         group.setEnableMemoryPoolDirect(direct);
         group.setEnableMemoryPoolDirect(direct);
         group.setEnableMemoryPool(pool);
         group.setEnableMemoryPool(pool);
@@ -131,16 +137,18 @@ public class TestHttpLoadServer {
         group.setChannelReadBuffer(1024 * readBuf);
         group.setChannelReadBuffer(1024 * readBuf);
         group.setEventLoopSize(Util.availableProcessors() * core);
         group.setEventLoopSize(Util.availableProcessors() * core);
         group.setConcurrentFrameStack(false);
         group.setConcurrentFrameStack(false);
-        context.addProtocolCodec(new HttpCodec("baseio", fcache, lite, inline));
-        context.addChannelEventListener(new ChannelEventListenerAdapter() {
-
-            @Override
-            public void channelOpened(Channel ch) throws Exception {
-                ch.setOption(SocketOptions.TCP_NODELAY, 1);
-                ch.setOption(SocketOptions.TCP_QUICKACK, 1);
-                ch.setOption(SocketOptions.SO_KEEPALIVE, 0);
-            }
-        });
+        if (nodelay) {
+            context.addChannelEventListener(new ChannelEventListenerAdapter() {
+
+                @Override
+                public void channelOpened(Channel ch) throws Exception {
+                    ch.setOption(SocketOptions.TCP_NODELAY, 1);
+                    ch.setOption(SocketOptions.TCP_QUICKACK, 1);
+                    ch.setOption(SocketOptions.SO_KEEPALIVE, 0);
+                }
+            });
+        }
+        context.addProtocolCodec(new HttpCodec("baseio", fcache, lite, inline, cachedUrls));
         context.setIoEventHandle(eventHandle);
         context.setIoEventHandle(eventHandle);
         context.bind();
         context.bind();
     }
     }