D:\javaNettyAction\NettyA\src\main\java\com\test\HexDumpProxy.java

package com.test;

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler; public final class HexDumpProxy { static final int LOCAL_PORT = Integer.parseInt(System.getProperty("localPort", "8443"));
static final String REMOTE_HOST = System.getProperty("remoteHost", "11.21.1.2");
static final int REMOTE_PORT = Integer.parseInt(System.getProperty("remotePort", "50000")); public static void main(String[] args) throws Exception {
System.err.println("Proxying *:" + LOCAL_PORT + " to " + REMOTE_HOST + ':' + REMOTE_PORT + " ..."); // Configure the bootstrap.
EventLoopGroup bossGroup = new NioEventLoopGroup(1);
EventLoopGroup workerGroup = new NioEventLoopGroup();
try {
ServerBootstrap b = new ServerBootstrap();
b.group(bossGroup, workerGroup)
.channel(NioServerSocketChannel.class)
.handler(new LoggingHandler(LogLevel.INFO))
.childHandler(new HexDumpProxyInitializer(REMOTE_HOST, REMOTE_PORT))
.childOption(ChannelOption.AUTO_READ, false)
.bind(LOCAL_PORT).sync().channel().closeFuture().sync();
} finally {
bossGroup.shutdownGracefully();
workerGroup.shutdownGracefully();
}
}
} D:\javaNettyAction\NettyA\src\main\java\com\test\HexDumpProxyInitializer.java
package com.test;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler; public class HexDumpProxyInitializer extends ChannelInitializer<SocketChannel> { private final String remoteHost;
private final int remotePort; public HexDumpProxyInitializer(String remoteHost, int remotePort) {
this.remoteHost = remoteHost;
this.remotePort = remotePort;
} @Override
public void initChannel(SocketChannel ch) {
ch.pipeline().addLast(
new LoggingHandler(LogLevel.INFO),
new HexDumpProxyFrontendHandler(remoteHost, remotePort));
}
} D:\javaNettyAction\NettyA\src\main\java\com\test\HexDumpProxyBackendHandler.java
package com.test;

import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter; public class HexDumpProxyBackendHandler extends ChannelInboundHandlerAdapter { private final Channel inboundChannel; public HexDumpProxyBackendHandler(Channel inboundChannel) {
this.inboundChannel = inboundChannel;
} @Override
public void channelActive(ChannelHandlerContext ctx) {
ctx.read();
} @Override
public void channelRead(final ChannelHandlerContext ctx, Object msg) {
inboundChannel.writeAndFlush(msg).addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) {
if (future.isSuccess()) {
ctx.channel().read();
} else {
future.channel().close();
}
}
});
} @Override
public void channelInactive(ChannelHandlerContext ctx) {
HexDumpProxyFrontendHandler.closeOnFlush(inboundChannel);
} @Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
cause.printStackTrace();
HexDumpProxyFrontendHandler.closeOnFlush(ctx.channel());
}
} D:\javaNettyAction\NettyA\src\main\java\com\test\HexDumpProxyFrontendHandler.java
package com.test;

import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.ChannelOption; public class HexDumpProxyFrontendHandler extends ChannelInboundHandlerAdapter { private final String remoteHost;
private final int remotePort; // As we use inboundChannel.eventLoop() when building the Bootstrap this does not need to be volatile as
// the outboundChannel will use the same EventLoop (and therefore Thread) as the inboundChannel.
private Channel outboundChannel; public HexDumpProxyFrontendHandler(String remoteHost, int remotePort) {
this.remoteHost = remoteHost;
this.remotePort = remotePort;
} @Override
public void channelActive(ChannelHandlerContext ctx) {
final Channel inboundChannel = ctx.channel(); // Start the connection attempt.
Bootstrap b = new Bootstrap();
b.group(inboundChannel.eventLoop())
.channel(ctx.channel().getClass())
.handler(new HexDumpProxyBackendHandler(inboundChannel))
.option(ChannelOption.AUTO_READ, false);
ChannelFuture f = b.connect(remoteHost, remotePort);
outboundChannel = f.channel();
f.addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) {
if (future.isSuccess()) {
// connection complete start to read first data
inboundChannel.read();
} else {
// Close the connection if the connection attempt has failed.
inboundChannel.close();
}
}
});
} @Override
public void channelRead(final ChannelHandlerContext ctx, Object msg) {
if (outboundChannel.isActive()) {
outboundChannel.writeAndFlush(msg).addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) {
if (future.isSuccess()) {
// was able to flush out data, start to read the next chunk
ctx.channel().read();
} else {
future.channel().close();
}
}
});
}
} @Override
public void channelInactive(ChannelHandlerContext ctx) {
if (outboundChannel != null) {
closeOnFlush(outboundChannel);
}
} @Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
cause.printStackTrace();
closeOnFlush(ctx.channel());
} /**
* Closes the specified channel after all queued write requests are flushed.
*/
static void closeOnFlush(Channel ch) {
if (ch.isActive()) {
ch.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
}
}
}

十一月 15, 2018 2:24:16 下午 io.netty.handler.logging.LoggingHandler channelRead
信息: [id: 0x4236582a, L:/0:0:0:0:0:0:0:0:8443] READ: [id: 0x518036c2, L:/0:0:0:0:0:0:0:1:8443 - R:/0:0:0:0:0:0:0:1:64325]
十一月 15, 2018 2:24:16 下午 io.netty.handler.logging.LoggingHandler channelReadComplete
信息: [id: 0x4236582a, L:/0:0:0:0:0:0:0:0:8443] READ COMPLETE
十一月 15, 2018 2:24:16 下午 io.netty.handler.logging.LoggingHandler channelRegistered
信息: [id: 0x518036c2, L:/0:0:0:0:0:0:0:1:8443 - R:/0:0:0:0:0:0:0:1:64325] REGISTERED
十一月 15, 2018 2:24:16 下午 io.netty.handler.logging.LoggingHandler channelActive
信息: [id: 0x518036c2, L:/0:0:0:0:0:0:0:1:8443 - R:/0:0:0:0:0:0:0:1:64325] ACTIVE
十一月 15, 2018 2:24:16 下午 io.netty.handler.logging.LoggingHandler channelRead
信息: [id: 0x518036c2, L:/0:0:0:0:0:0:0:1:8443 - R:/0:0:0:0:0:0:0:1:64325] READ: 424B
+-------------------------------------------------+
| 0 1 2 3 4 5 6 7 8 9 a b c d e f |
+--------+-------------------------------------------------+----------------+
|00000000| 50 4f 53 54 20 2f 20 48 54 54 50 2f 31 2e 31 0d |POST / HTTP/1.1.|
|00000010| 0a 43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a 20 61 |.Content-Type: a|
|00000020| 70 70 6c 69 63 61 74 69 6f 6e 2f 6a 73 6f 6e 0d |pplication/json.|
|00000030| 0a 63 61 63 68 65 2d 63 6f 6e 74 72 6f 6c 3a 20 |.cache-control: |
|00000040| 6e 6f 2d 63 61 63 68 65 0d 0a 50 6f 73 74 6d 61 |no-cache..Postma|
|00000050| 6e 2d 54 6f 6b 65 6e 3a 20 38 66 30 32 34 37 64 |n-Token: 8f0247d|
|00000060| 30 2d 64 65 32 63 2d 34 66 38 35 2d 61 37 62 66 |0-de2c-4f85-a7bf|
|00000070| 2d 32 63 33 31 36 38 39 31 39 38 62 39 0d 0a 55 |-2c31689198b9..U|
|00000080| 73 65 72 2d 41 67 65 6e 74 3a 20 50 6f 73 74 6d |ser-Agent: Postm|
|00000090| 61 6e 52 75 6e 74 69 6d 65 2f 37 2e 34 2e 30 0d |anRuntime/7.4.0.|
|000000a0| 0a 41 63 63 65 70 74 3a 20 2a 2f 2a 0d 0a 48 6f |.Accept: */*..Ho|
|000000b0| 73 74 3a 20 6c 6f 63 61 6c 68 6f 73 74 3a 38 34 |st: localhost:84|
|000000c0| 34 33 0d 0a 61 63 63 65 70 74 2d 65 6e 63 6f 64 |43..accept-encod|
|000000d0| 69 6e 67 3a 20 67 7a 69 70 2c 20 64 65 66 6c 61 |ing: gzip, defla|
|000000e0| 74 65 0d 0a 63 6f 6e 74 65 6e 74 2d 6c 65 6e 67 |te..content-leng|
|000000f0| 74 68 3a 20 31 34 39 0d 0a 43 6f 6e 6e 65 63 74 |th: 149..Connect|
|00000100| 69 6f 6e 3a 20 6b 65 65 70 2d 61 6c 69 76 65 0d |ion: keep-alive.|
|00000110| 0a 0d 0a 5b 7b 0d 0a 20 20 22 68 65 61 64 65 72 |...[{.. "header|
|00000120| 73 22 20 3a 20 7b 0d 0a 20 20 20 20 20 20 20 20 |s" : {.. |
|00000130| 20 20 20 20 20 22 74 69 6d 65 73 74 61 6d 70 22 | "timestamp"|
|00000140| 20 3a 20 22 34 33 34 33 32 34 33 34 33 22 2c 0d | : "434324343",.|
|00000150| 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 22 68 |. "h|
|00000160| 6f 73 74 22 20 3a 20 22 72 61 6e 64 6f 6d 5f 68 |ost" : "random_h|
|00000170| 6f 73 74 2e 65 78 61 6d 70 6c 65 2e 63 6f 6d 22 |ost.example.com"|
|00000180| 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 7d |.. }|
|00000190| 2c 0d 0a 20 20 22 62 6f 64 79 22 20 3a 20 22 31 |,.. "body" : "1|
|000001a0| 32 33 64 22 0d 0a 7d 5d |23d"..}] |
+--------+-------------------------------------------------+----------------+
十一月 15, 2018 2:24:16 下午 io.netty.handler.logging.LoggingHandler channelReadComplete
信息: [id: 0x518036c2, L:/0:0:0:0:0:0:0:1:8443 - R:/0:0:0:0:0:0:0:1:64325] READ COMPLETE
十一月 15, 2018 2:24:16 下午 io.netty.handler.logging.LoggingHandler write
信息: [id: 0x518036c2, L:/0:0:0:0:0:0:0:1:8443 - R:/0:0:0:0:0:0:0:1:64325] WRITE: 70B
+-------------------------------------------------+
| 0 1 2 3 4 5 6 7 8 9 a b c d e f |
+--------+-------------------------------------------------+----------------+
|00000000| 48 54 54 50 2f 31 2e 31 20 32 30 30 20 4f 4b 0d |HTTP/1.1 200 OK.|
|00000010| 0a 54 72 61 6e 73 66 65 72 2d 45 6e 63 6f 64 69 |.Transfer-Encodi|
|00000020| 6e 67 3a 20 63 68 75 6e 6b 65 64 0d 0a 53 65 72 |ng: chunked..Ser|
|00000030| 76 65 72 3a 20 4a 65 74 74 79 28 36 2e 31 2e 32 |ver: Jetty(6.1.2|
|00000040| 36 29 0d 0a 0d 0a |6).... |
+--------+-------------------------------------------------+----------------+
十一月 15, 2018 2:24:16 下午 io.netty.handler.logging.LoggingHandler flush
信息: [id: 0x518036c2, L:/0:0:0:0:0:0:0:1:8443 - R:/0:0:0:0:0:0:0:1:64325] FLUSH
十一月 15, 2018 2:24:16 下午 io.netty.handler.logging.LoggingHandler write
信息: [id: 0x518036c2, L:/0:0:0:0:0:0:0:1:8443 - R:/0:0:0:0:0:0:0:1:64325] WRITE: 5B
+-------------------------------------------------+
| 0 1 2 3 4 5 6 7 8 9 a b c d e f |
+--------+-------------------------------------------------+----------------+
|00000000| 30 0d 0a 0d 0a |0.... |
+--------+-------------------------------------------------+----------------+
十一月 15, 2018 2:24:16 下午 io.netty.handler.logging.LoggingHandler flush
信息: [id: 0x518036c2, L:/0:0:0:0:0:0:0:1:8443 - R:/0:0:0:0:0:0:0:1:64325] FLUSH

root 32603 0.1 0.4 6000924 136720 pts/3 Sl+ 09:09 0:19 /usr/java/jdk1.8.0_101/bin/java -Xmx20m -Dflume.root.logger=INFO,console -Xms2048m -Xmx2048m -cp /data/UnifiedLog/flume/conf:/data/UnifiedLog/flume/lib/*:/lib/* -Djava.library.path= org.apache.flume.node.Application -f /data/UnifiedLog/flume/conf/httpSourceApp.conf -n a1

[root@d log]# cat /data/UnifiedLog/flume/conf/httpSourceApp.conf
a1.sources=r1
a1.sinks=k1
a1.channels=c1

a1.sources.r1.type=http
a1.sources.r1.bind=0.0.0.0
a1.sources.r1.port=50000
a1.sources.r1.channels=c1

a1.sinks.k1.channel=c1
#a1.sinks.k1.type = com.product.FlumeApp
a1.sinks.k1.type = file_roll
a1.sinks.k1.sink.directory = /data/UnifiedLog/log
a1.sinks.k1.batchSize=100
#a1.sinks.k1.pathManager=%y%m%d%H%M%S
a1.sinks.k1.pathManager=DEFAULT
a1.sinks.k1.pathManager.extension=log
a1.sinks.k1.pathManager.prefix=webTrack
a1.sinks.k1.rollInterval=30
#sink.rollInterval 30 Roll the file every 30 seconds. Specifying 0 will disable rolling and cause all events to be written to a single file.
a1.sinks.k1.sink.serializer = text
#capacity 100 The maximum number of events stored in the channel
#transactionCapacity 100 The maximum number of events the channel will take from a source or give to a sink per transaction

a1.channels.c1.type=memory
#a1.channels.c1.capacity=1000
#a1.channels.c1.transactionCapacity=100
a1.channels.c1.capacity=10000
a1.channels.c1.transactionCapacity=10000

[root@d log]#

去透明代理的思路

  • Transparent connections through HTTP proxies.

1、再netty框架内,操作channel-bytebuf;

2、引入新的http/udp-客户端服务,发送请求;

package com.test;

import org.apache.http.*;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.DefaultBHttpClientConnection;
import org.apache.http.impl.DefaultConnectionReuseStrategy;
import org.apache.http.message.BasicHttpEntityEnclosingRequest;
import org.apache.http.protocol.*; import java.net.Socket;
import java.util.UUID; public class ElementalHttpPost {
public static void main(String[] args) throws Exception {
String strBatch = "[";
String s = "http://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.java";
try {
for (int i = 0; i < 3000; i++) {
System.out.println(i); strBatch += ",{\"headers\":{\"timestamp\":\"434324343\",\"host\":\"random_host.example.com\"},\"body\":\"abc" + i + "---" + System.currentTimeMillis() + "-" + UUID.randomUUID() + "---" + s + "\"}";
}
strBatch += "]";
strBatch = strBatch.replace("[,", "[");
System.out.println(strBatch);
HttpEntity httpEntity = new StringEntity(strBatch, ContentType.create("application/json", Consts.UTF_8));
m(httpEntity);
Thread.sleep(1000);
System.out.println(Thread.currentThread());
} finally {
}
} static void m(HttpEntity httpEntity) throws Exception {
HttpProcessor processor = HttpProcessorBuilder.create()
.add(new RequestContent())
.add(new RequestTargetHost())
.add(new ResponseConnControl())
.add(new RequestUserAgent("Test/1.1"))
.add(new RequestExpectContinue(true))
.build();
HttpRequestExecutor requestExecutor = new HttpRequestExecutor();
HttpCoreContext coreContext = HttpCoreContext.create();
HttpHost host = new HttpHost("101.201.41.72", 50000);
coreContext.setTargetHost(host); DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(8 * 10254 * 1024);
ConnectionReuseStrategy reuseStrategy = DefaultConnectionReuseStrategy.INSTANCE;
Socket socket = new Socket(host.getHostName(), host.getPort());
conn.bind(socket);
try {
BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
request.setEntity(httpEntity);
requestExecutor.preProcess(request, processor, coreContext);
HttpResponse response = requestExecutor.execute(request, conn, coreContext);
requestExecutor.postProcess(response, processor, coreContext);
if (!reuseStrategy.keepAlive(response, coreContext)) {
conn.close();
} else {
System.out.println("Connection kept alive...");
}
} finally {
conn.close();
}
}
}

root 550 1.1 0.5 6000924 165824 pts/1 Sl+ 17:39 0:03 /usr/java/jdk1.8.0_101/bin/java -Xmx20m -Dflume.root.logger=INFO,console -Xms2048m -Xmx2048m -cp /data/UnifiedLog/flume/conf:/data/UnifiedLog/flume/lib/*:/lib/* -Djava.library.path= org.apache.flume.node.Application -f /data/UnifiedLog/flume/conf/httpSourceApp.conf -n a1

[root@d log]# ll -asth
total 4.0M
136K drwxr-xr-x 2 root root 132K Nov 15 17:44 .
0 -rw-r--r-- 1 root root 0 Nov 15 17:44 1542274748708-11
0 -rw-r--r-- 1 root root 0 Nov 15 17:43 1542274748708-10
0 -rw-r--r-- 1 root root 0 Nov 15 17:43 1542274748708-9
0 -rw-r--r-- 1 root root 0 Nov 15 17:42 1542274748708-8
0 -rw-r--r-- 1 root root 0 Nov 15 17:42 1542274748708-7
3.7M -rw-r--r-- 1 root root 3.7M Nov 15 17:42 1542274748708-6
0 -rw-r--r-- 1 root root 0 Nov 15 17:41 1542274748708-5
0 -rw-r--r-- 1 root root 0 Nov 15 17:40 1542274748708-4
180K -rw-r--r-- 1 root root 178K Nov 15 17:40 1542274748708-3
60K -rw-r--r-- 1 root root 59K Nov 15 17:39 1542274748708-2
8.0K -rw-r--r-- 1 root root 5.8K Nov 15 17:39 1542274748708-1
4.0K drwxr-xr-x 12 root root 4.0K Nov 12 15:15 ..

[root@d log]# cat 1542274748708-6 -n | head -3
1 abc0---1542274889548-e4b44a3a-ffef-467b-97e1-da216aacb353---http://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.java
2 abc1---1542274889680-8264f461-3421-473d-a2e2-310b45a0d356---http://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.java
3 abc2---1542274889680-44506b82-979c-47b7-ae36-85841e51f5b4---http://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.java
[root@d log]# cat 1542274748708-6 -n | tail -3
2998 abc2997---1542274902594-d01401f7-6e76-450d-831a-70806aede6d9---http://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.java
2999 abc2998---1542274902600-b7378bb5-f9ca-405a-8ce4-685c88502c8f---http://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.java
3000 abc2999---1542274902611-e3cc73c9-c117-4afa-b5c0-d1064ccf2cc3---http://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.javahttp://hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpPost.java
[root@d log]#

D:\javaNettyAction\NettyA\src\main\java\com\test\HostInfo.java

  获取节点信息

package com.test;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Properties; public class HostInfo { public static void main(String[] args) {
InetAddress netAddress = getLocalHost();
System.out.println("host ip:" + getHostAddress(netAddress));
System.out.println("host name:" + getHostName(netAddress)); } public static InetAddress getLocalHost() { try {
return InetAddress.getLocalHost();
} catch (UnknownHostException e) {
System.out.println("unknown host!");
}
return null; } public static String getHostAddress(InetAddress netAddress) {
if (null == netAddress) {
return null;
}
String ip = netAddress.getHostAddress(); //get the ip address
return ip;
} public static String getHostName(InetAddress netAddress) {
if (null == netAddress) {
return null;
}
String name = netAddress.getHostName(); //get the host address
return name;
} } D:\javaNettyAction\NettyA\src\main\java\com\test\NettyHttpServer.java
package com.test;

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpRequestDecoder;
import io.netty.handler.codec.http.HttpResponseEncoder;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;
import io.netty.handler.stream.ChunkedWriteHandler; public class NettyHttpServer {
private int port;
protected int flumerBatchSize = 100;
protected String[] flumerBatch; public NettyHttpServer(int port) {
this.port = port;
} public void init() throws Exception {
EventLoopGroup parentGroup = new NioEventLoopGroup();
EventLoopGroup childGroup = new NioEventLoopGroup();
try {
ServerBootstrap server = new ServerBootstrap();
server.group(parentGroup, childGroup)
.channel(NioServerSocketChannel.class)
.handler(new LoggingHandler(LogLevel.INFO))
.childHandler(new ChannelInitializer<SocketChannel>() {
/*
1、一个ChannelInitializer的实现被注册到了ServerBootstrap中。
2、当 ChannelInitializer.initChannel()方法被调用时, ChannelInitializer将在 ChannelPipeline 中安装一组自定义的 ChannelHandler。
3、ChannelInitializer 将它自己从 ChannelPipeline 中移除。
* */
@Override
protected void initChannel(SocketChannel socketChanel) throws Exception {
socketChanel.pipeline().addLast("http-decoder", new HttpRequestDecoder());
socketChanel.pipeline().addLast("http-aggregator", new HttpObjectAggregator(65535));
socketChanel.pipeline().addLast("http-encoder", new HttpResponseEncoder());
socketChanel.pipeline().addLast("http-chunked", new ChunkedWriteHandler());
socketChanel.pipeline().addLast("http-server", new NettyHttpServerHandler());
}
}
);
ChannelFuture future = server.bind(this.port).sync();
future.channel().closeFuture().sync();
} finally {
childGroup.shutdownGracefully();
parentGroup.shutdownGracefully();
}
} public static void main(String[] args) {
NettyHttpServer server = new NettyHttpServer(8080);
try {
server.init();
} catch (Exception e) {
e.printStackTrace();
System.err.println("exception: " + e.getMessage());
}
System.out.println("server close!");
}
} D:\javaNettyAction\NettyA\src\main\java\com\test\NettyHttpServerHandler.java
package com.test;

import com.alibaba.fastjson.JSONObject;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.codec.http.*;
import io.netty.handler.codec.http.multipart.*;
import io.netty.util.CharsetUtil;
import org.apache.http.ConnectionReuseStrategy;
import org.apache.http.Consts;
import org.apache.http.HttpEntity; import java.io.UnsupportedEncodingException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.net.Socket;
import java.util.HashMap;
import java.util.List;
import java.util.Map; import static io.netty.buffer.Unpooled.copiedBuffer; import org.apache.http.HttpHost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.DefaultBHttpClientConnection;
import org.apache.http.impl.DefaultConnectionReuseStrategy;
import org.apache.http.message.BasicHttpEntityEnclosingRequest;
import org.apache.http.protocol.*; public class NettyHttpServerHandler extends SimpleChannelInboundHandler<FullHttpRequest> {
private boolean frontendDataSendByUri = true; @Override
protected void channelRead0(ChannelHandlerContext channelHandlerContext, FullHttpRequest fullHttpRequest) throws Exception {
String responseContent;
HttpResponseStatus responseStatus = HttpResponseStatus.OK;
if (fullHttpRequest.method() == HttpMethod.GET) {
System.out.println(getGetParamasFromChannel(fullHttpRequest));
responseContent = "GET method over";
} else if (fullHttpRequest.method() == HttpMethod.POST) {
System.out.println(getPostParamsFromChannel(fullHttpRequest));
responseContent = "POST method data";
} else {
responseStatus = HttpResponseStatus.INTERNAL_SERVER_ERROR;
responseContent = "INTERNAL_SERVER_ERROR";
}
if (frontendDataSendByUri) {
try {
responseContent = sendToFlume(fullHttpRequest);
appacheHttpPost(responseContent);
} catch (Exception e) {
System.out.println(e);
e.printStackTrace();
}
}else {
}
FullHttpResponse response = responseHandler(responseStatus, responseContent);
channelHandlerContext.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
} private Map<String, Object> getGetParamasFromChannel(FullHttpRequest fullHttpRequest) {
Map<String, Object> params = new HashMap<String, Object>();
if (fullHttpRequest.method() == HttpMethod.GET) {
QueryStringDecoder decoder = new QueryStringDecoder(fullHttpRequest.uri());
Map<String, List<String>> paramList = decoder.parameters();
for (Map.Entry<String, List<String>> entry : paramList.entrySet()) {
params.put(entry.getKey(), entry.getValue().get(0));
}
return params;
} else {
return null;
}
} private Map<String, Object> getPostParamsFromChannel(FullHttpRequest fullHttpRequest) {
Map<String, Object> params = new HashMap<String, Object>();
if (fullHttpRequest.method() == HttpMethod.POST) {
String strContentType = fullHttpRequest.headers().get("Content-type").trim();
// if (strContentType.contains("x-www-form-urlencoded")) {
if (strContentType.contains("form")) {
params = getFormParams(fullHttpRequest);
} else if (strContentType.contains("application/json")) {
try {
params = getJSONParams(fullHttpRequest);
} catch (UnsupportedEncodingException e) {
return null;
}
} else {
return null;
}
return params;
}
return null;
} private Map<String, Object> getFormParams(FullHttpRequest fullHttpRequest) {
Map<String, Object> params = new HashMap<String, Object>();
// HttpPostMultipartRequestDecoder
HttpPostRequestDecoder decoder = new HttpPostRequestDecoder(new DefaultHttpDataFactory(false), fullHttpRequest);
List<InterfaceHttpData> postData = decoder.getBodyHttpDatas();
for (InterfaceHttpData data : postData) {
if (data.getHttpDataType() == InterfaceHttpData.HttpDataType.Attribute) {
MemoryAttribute attribute = (MemoryAttribute) data;
params.put(attribute.getName(), attribute.getValue());
}
}
return params;
} private Map<String, Object> getJSONParams(FullHttpRequest fullHttpRequest) throws UnsupportedEncodingException {
Map<String, Object> params = new HashMap<String, Object>();
ByteBuf content = fullHttpRequest.content();
byte[] reqContent = new byte[content.readableBytes()];
content.readBytes(reqContent);
String strContent = new String(reqContent, "UTF-8");
JSONObject jsonObject = JSONObject.parseObject(strContent);
for (String key : jsonObject.keySet()) {
params.put(key, jsonObject.get(key));
}
return params;
} private FullHttpResponse responseHandler(HttpResponseStatus status, String responseContent) {
ByteBuf content = copiedBuffer(responseContent, CharsetUtil.UTF_8);
FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, status, content);
response.headers().set("Content-Type", "text/plain;charset=UTF-8;");
response.headers().set("Content-Length", response.content().readableBytes());
return response;
} private String sendToFlume(FullHttpRequest fullHttpRequest) {
/*
*
Flume 1.8.0 User Guide — Apache Flume http://flume.apache.org/FlumeUserGuide.html
[{
"headers" : {
"timestamp" : "434324343",
"host" : "random_host.example.com"
},
"body" : "random_body"
},
{
"headers" : {
"namenode" : "namenode.example.com",
"datanode" : "random_datanode.example.com"
},
"body" : "really_random_body"
}]
To set the charset, the request must have content type specified as application/json; charset=UTF-8 (replace UTF-8 with UTF-16 or UTF-32 as required). One way to create an event in the format expected by this handler is to use JSONEvent provided in the Flume SDK and use Google Gson to create the JSON string using the Gson#fromJson(Object, Type) method. The type token to pass as the 2nd argument of this method for list of events can be created by: Type type = new TypeToken<List<JSONEvent>>() {}.getType();
*
*
* */
// Map<String, Object> params = new HashMap<String, Object>();
// if (fullHttpRequest.method() == HttpMethod.GET) {
// QueryStringDecoder decoder = new QueryStringDecoder(fullHttpRequest.uri());
// Map<String, List<String>> paramList = decoder.parameters();
// for (Map.Entry<String, List<String>> entry : paramList.entrySet()) {
// params.put(entry.getKey(), entry.getValue().get(0));
// }
// return params;
// } else {
// return null;
// }
// }
System.out.println(fullHttpRequest.uri());
// TODO 不被解析
// String s = "[{\"headers\":{\"timestamp\":\"" + System.currentTimeMillis() + "\",\"host\":\"random_host.example.com\"},\"body\":{\"uri\":\"" + fullHttpRequest.uri() + "\",\"headers\":\"" + fullHttpRequest.headers() + "\"}}]";
InetAddress inetAddress = HostInfo.getLocalHost();
String hostAddress = inetAddress.getHostAddress();
String hostName = inetAddress.getHostName(); String s = "[{\"headers\":{\"timestamp\":\"" + System.currentTimeMillis() + "\",\"host\":\"random_host.example.com\"},\"body\":\"uri{" + fullHttpRequest.uri() + "}headers{" + fullHttpRequest.headers() + "}hostAddress{" + hostAddress + "}hostName{" + hostName + "}\"}]";
// System.out.println(s);
return s;
} private void m(HttpEntity httpEntity) throws Exception {
try {
HttpProcessor processor = HttpProcessorBuilder.create()
.add(new RequestContent())
.add(new RequestTargetHost())
.add(new ResponseConnControl())
.add(new RequestUserAgent("Test/1.1"))
.add(new RequestExpectContinue(true))
.build();
HttpRequestExecutor requestExecutor = new HttpRequestExecutor();
HttpCoreContext coreContext = HttpCoreContext.create();
HttpHost host = new HttpHost("11.21.1.2", 50000);
coreContext.setTargetHost(host); DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(8 * 10254 * 1024);
ConnectionReuseStrategy reuseStrategy = DefaultConnectionReuseStrategy.INSTANCE;
Socket socket = new Socket(host.getHostName(), host.getPort());
conn.bind(socket);
BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST", "/");
request.setEntity(httpEntity);
requestExecutor.preProcess(request, processor, coreContext);
org.apache.http.HttpResponse response = requestExecutor.execute(request, conn, coreContext);
requestExecutor.postProcess(response, processor, coreContext);
if (!reuseStrategy.keepAlive(response, coreContext)) {
conn.close();
} else {
System.out.println("Connection kept alive...");
}
try {
conn.close();
} catch (Exception e) {
System.out.println(e);
e.printStackTrace();
} finally {
}
} catch (Exception e) {
System.out.println(e);
e.printStackTrace();
} finally {
}
} private HttpEntity getApacheHttpEntity(String string) {
return new StringEntity(string, ContentType.create("application/json", Consts.UTF_8));
} private void appacheHttpPost(String string) throws Exception {
HttpEntity httpEntity = getApacheHttpEntity(string);
m(httpEntity);
}
} 测试脚本:
import requests, random, time
from handTool.pythonTool import getNow c = 0
host = 'http://localhost:8080/?'
longStr = ''
for i in range(256):
longStr += 'abcd'
while True:
c += 1
url = host + 'millisecond=' + str(time.time()) + '&time=' + getNow(format_='%Y-%m-%d%H:%M:%S') + '&random=' + \
str(random.random()).split('.')[-1] + '&longStr=' + longStr
print(url)
r = requests.get(url)
print(r) flume日志处理结果:

-rw-r--r-- 1 root root 61K Nov 16 10:18 1542330514005-141
-rw-r--r-- 1 root root 81K Nov 16 10:19 1542330514005-142
-rw-r--r-- 1 root root 109K Nov 16 10:20 1542330514005-143
-rw-r--r-- 1 root root 0 Nov 16 10:20 1542330514005-144
-rw-r--r-- 1 root root 39K Nov 16 10:20 1542330514005-145
-rw-r--r-- 1 root root 25K Nov 16 10:21 1542330514005-146
-rw-r--r-- 1 root root 81K Nov 16 10:22 1542330514005-147
-rw-r--r-- 1 root root 0 Nov 16 10:22 1542330514005-148
drwxr-xr-x 2 root root 132K Nov 16 10:22 .
[root@d log]# ll -athr

60 uri{/?millisecond=1542334929.7500494&time=2018-11-1610:22:09&random=5971318131119786&longStr=abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd}headers{DefaultHttpHeaders[Host: localhost:8080, User-Agent: python-requests/2.18.4, Accept-Encoding: gzip, deflate, Accept: */*, Connection: keep-alive, content-length: 0]}hostAddress{192.168.181.2}hostName{DESKTOP-RVB6E5F}
61 uri{/?millisecond=1542334929.9922085&time=2018-11-1610:22:09&random=3046957077468374&longStr=abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd}headers{DefaultHttpHeaders[Host: localhost:8080, User-Agent: python-requests/2.18.4, Accept-Encoding: gzip, deflate, Accept: */*, Connection: keep-alive, content-length: 0]}hostAddress{192.168.181.2}hostName{DESKTOP-RVB6E5F}
[root@d log]# cat 1542330514005-147 -n | tail

异常信息:

java.net.ConnectException: Connection timed out: connect
java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at java.net.Socket.<init>(Socket.java:434)
at java.net.Socket.<init>(Socket.java:211)
at com.test.NettyHttpServerHandler.m(NettyHttpServerHandler.java:200)
at com.test.NettyHttpServerHandler.appacheHttpPost(NettyHttpServerHandler.java:232)
at com.test.NettyHttpServerHandler.channelRead0(NettyHttpServerHandler.java:53)
at com.test.NettyHttpServerHandler.channelRead0(NettyHttpServerHandler.java:33)
at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:323)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:297)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1434)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:965)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:644)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:579)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:496)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:458)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
十一月 16, 2018 10:24:21 上午 io.netty.handler.logging.LoggingHandler channelRead
信息: [id: 0x773eeaaa, L:/0:0:0:0:0:0:0:0:8080] READ: [id: 0xa492dc3a, L:/0:0:0:0:0:0:0:1:8080 - R:/0:0:0:0:0:0:0:1:62298]
十一月 16, 2018 10:24:21 上午 io.netty.handler.logging.LoggingHandler channelReadComplete
信息: [id: 0x773eeaaa, L:/0:0:0:0:0:0:0:0:8080] READ COMPLETE
{random=4171256019588896, millisecond=1542335061.7778149, time=2018-11-1610:24:21, longStr=abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd}
/?millisecond=1542335061.7778149&time=2018-11-1610:24:21&random=4171256019588896&longStr=abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd
java.net.ConnectException: Connection timed out: connect
java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at java.net.Socket.<init>(Socket.java:434)
at java.net.Socket.<init>(Socket.java:211)
at com.test.NettyHttpServerHandler.m(NettyHttpServerHandler.java:200)
at com.test.NettyHttpServerHandler.appacheHttpPost(NettyHttpServerHandler.java:232)
at com.test.NettyHttpServerHandler.channelRead0(NettyHttpServerHandler.java:53)
at com.test.NettyHttpServerHandler.channelRead0(NettyHttpServerHandler.java:33)
at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:323)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:297)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1434)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:965)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:644)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:579)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:496)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:458)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
十一月 16, 2018 10:24:42 上午 io.netty.handler.logging.LoggingHandler channelRead

TODO
对原始http请求的日志
对java执行异常的记录日志
对flume进程分析的日志
性能架构优化:对ApacheHttpClient的对Flume的POST请求修改:1、改为非阻塞式,NIO;2、用Netty的Channel替换掉该Htpp请求;
传参优化:
public static void main(String[] args) {
int serverPort = Integer.parseInt(args[0]);
System.setProperty("logServiceHost", args[1]);
System.setProperty("logServicePort", args[2]);
NettyHttpServer server = new NettyHttpServer(serverPort);
本地netty进程和云服务器netty进程
本地2个python进程分别对其发送前请求 查看云服务器flume处理结果:
   118  uri{/?millisecond=1542338525.8571148&time=2018-11-1611:22:05&random=8944829150787025&longStr=abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd}headers{DefaultHttpHeaders[Host: localhost:8080, User-Agent: python-requests/2.18.4, Accept-Encoding: gzip, deflate, Accept: */*, Connection: keep-alive, content-length: 0]}hostAddress{192.168.181.2}hostName{DESKTOP-RVB6E5F}
119 uri{/?millisecond=1542338524.6177826&time=2018-11-1611:22:04&random=12401051730872381&longStr=abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd}headers{DefaultHttpHeaders[Host: 101.201.41.72:8082, User-Agent: python-requests/2.18.4, Accept-Encoding: gzip, deflate, Accept: */*, Connection: keep-alive, content-length: 0]}hostAddress{10.10.10.10}hostName{testHost}
120 uri{/?millisecond=1542338526.0432465&time=2018-11-1611:22:06&random=7237938590337661&longStr=abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd}headers{DefaultHttpHeaders[Host: localhost:8080, User-Agent: python-requests/2.18.4, Accept-Encoding: gzip, deflate, Accept: */*, Connection: keep-alive, content-length: 0]}hostAddress{192.168.181.2}hostName{DESKTOP-RVB6E5F}
121 uri{/?millisecond=1542338526.2207797&time=2018-11-1611:22:06&random=013487555601044532&longStr=abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd}headers{DefaultHttpHeaders[Host: localhost:8080, User-Agent: python-requests/2.18.4, Accept-Encoding: gzip, deflate, Accept: */*, Connection: keep-alive, content-length: 0]}hostAddress{192.168.181.2}hostName{DESKTOP-RVB6E5F}
122 uri{/?millisecond=1542338526.4397554&time=2018-11-1611:22:06&random=9439076833726574&longStr=abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd}headers{DefaultHttpHeaders[Host: localhost:8080, User-Agent: python-requests/2.18.4, Accept-Encoding: gzip, deflate, Accept: */*, Connection: keep-alive, content-length: 0]}hostAddress{192.168.181.2}hostName{DESKTOP-RVB6E5F}
123 uri{/?millisecond=1542338526.5994527&time=2018-11-1611:22:06&random=5815109531812014&longStr=abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd}headers{DefaultHttpHeaders[Host: localhost:8080, User-Agent: python-requests/2.18.4, Accept-Encoding: gzip, deflate, Accept: */*, Connection: keep-alive, content-length: 0]}hostAddress{192.168.181.2}hostName{DESKTOP-RVB6E5F}
124 uri{/?millisecond=1542338526.7627056&time=2018-11-1611:22:06&random=6360552197745071&longStr=abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd}headers{DefaultHttpHeaders[Host: localhost:8080, User-Agent: python-requests/2.18.4, Accept-Encoding: gzip, deflate, Accept: */*, Connection: keep-alive, content-length: 0]}hostAddress{192.168.181.2}hostName{DESKTOP-RVB6E5F}
125 uri{/?millisecond=1542338526.9216535&time=2018-11-1611:22:06&random=35273700546823095&longStr=abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd}headers{DefaultHttpHeaders[Host: localhost:8080, User-Agent: python-requests/2.18.4, Accept-Encoding: gzip, deflate, Accept: */*, Connection: keep-alive, content-length: 0]}hostAddress{192.168.181.2}hostName{DESKTOP-RVB6E5F}
[root@testHost log]# cat 1542330514005-267 -n | tail^C
[root@testHost log]# ps -aux | grep java
root 8261 17.4 6.3 12654428 2071840 pts/9 Sl+ 11:20 1:03 java -jar /data/gateway/java/target/NettyA-1.0-SNAPSHOT-jar-with-dependencies.jar 8082 10.10.10.10 50000
root 9071 0.0 0.0 112708 964 pts/2 S+ 11:26 0:00 grep --color=auto java
root 21123 0.3 1.6 6134052 528108 pts/1 Sl+ 09:08 0:27 /usr/java/jdk1.8.0_101/bin/java -Xmx20m -Dflume.root.logger=INFO,console -Xms2048m -Xmx2048m -cp /data/UnifiedLog/flume/conf:/data/UnifiedLog/flume/lib/*:/lib/* -Djava.library.path= org.apache.flume.node.Application -f /data/UnifiedLog/flume/conf/httpSourceApp.conf -n a1
elsearch 22711 19.8 35.4 146437180 11625328 ? S<l Sep18 16813:24 /usr/java/jdk1.8.0_101/bin/java -Xms10g -Xmx10g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -XX:+DisableExplicitGC -Dfile.encoding=UTF-8 -Djna.nosys=true -Des.path.home=/usr/local/elasticsearch-2.4.1 -cp /usr/local/elasticsearch-2.4.1/lib/elasticsearch-2.4.1.jar:/usr/local/elasticsearch-2.4.1/lib/* org.elasticsearch.bootstrap.Elasticsearch start -d
root 24280 0.0 0.0 122092 1288 ? Sl Sep18 45:53 /usr/local/cloudmonitor/wrapper/bin/./wrapper /usr/local/cloudmonitor/wrapper/bin/../conf/wrapper.conf wrapper.syslog.ident=cloudmonitor wrapper.pidfile=/usr/local/cloudmonitor/wrapper/bin/./cloudmonitor.pid wrapper.daemonize=TRUE wrapper.name=cloudmonitor wrapper.displayname=cloudmonitor wrapper.statusfile=/usr/local/cloudmonitor/wrapper/bin/./cloudmonitor.status wrapper.java.statusfile=/usr/local/cloudmonitor/wrapper/bin/./cloudmonitor.java.status wrapper.lockfile=/var/lock/subsys/cloudmonitor wrapper.script.version=3.5.27
root 24282 0.5 0.2 2516408 67808 ? Sl Sep18 493:26 /usr/local/cloudmonitor/jre/bin/java -Djava.compiler=none -XX:-UseGCOverheadLimit -XX:NewRatio=1 -XX:SurvivorRatio=8 -XX:+UseSerialGC -Djava.io.tmpdir=../../tmp -Xms16m -Xmx32m -Djava.library.path=../lib:../../lib -classpath ../lib/wrappertest.jar:../lib/wrapper.jar:../../config:../../lib/agent-commons-1.2.11.jar:../../lib/agent-core-1.2.11.jar:../../lib/agent-model-1.2.11.jar:../../lib/aopalliance-1.0.jar:../../lib/commons-logging-1.2.jar:../../lib/commons-net-3.5.jar:../../lib/gson-2.4.jar:../../lib/jvm-plugin-1.2.11.jar:../../lib/log4j-1.2.16.jar:../../lib/metrics-core-3.0.2.jar:../../lib/sigar-1.6.5.132.jar:../../lib/slf4j-api-1.7.5.jar:../../lib/spring-aop-4.2.4.RELEASE.jar:../../lib/spring-beans-4.2.4.RELEASE.jar:../../lib/spring-context-4.2.4.RELEASE.jar:../../lib/spring-core-4.2.4.RELEASE.jar:../../lib/spring-expression-4.2.4.RELEASE.jar:../../lib/system-plugin-1.2.11.jar:../../lib/updater-1.2.11-jar-with-dependencies.jar -Dwrapper.key=vaz0l5Js_x6xfRzG -Dwrapper.port=32000 -Dwrapper.jvm.port.min=31000 -Dwrapper.jvm.port.max=31999 -Dwrapper.disable_console_input=TRUE -Dwrapper.pid=24280 -Dwrapper.version=3.5.27 -Dwrapper.native_library=wrapper -Dwrapper.arch=x86 -Dwrapper.service=TRUE -Dwrapper.cpu.timeout=10 -Dwrapper.jvmid=1 com.aliyun.tianji.cloudmonitor.Application
[root@testHost log]#

  

												

netty 网关 flume 提交数据 去除透明 批处理 批提交 cat head tail 结合 管道显示行号的更多相关文章

  1. SQL查询显示行号、随机查询、取指定行数据

    转自:walkingp 1.显示行号 如果数据没有删除的情况下主键与行号是一致的,但在删除某些数据,行号就与主键不一致了,这时需要查询行号就需要用新的方法,在SQL Server2005之前,需要使用 ...

  2. SQL随机查询,显示行号,查询数据段

    1.显示行号 如果数据没有删除的情况下主键与行号是一致的,但在删除某些数据,行号就与主键不一致了,这时需要查询行号就需要用新的方法,在SQL Server2005之前,需要使用临时表,但在SQL Se ...

  3. 提交数据url太长导致提交失败

    使用了dojo开发.在datagrid过滤的时候.为了让过滤好处理,直接设置为完全二叉树的方式来存查询条件.但是在提交数据的时候,默认是get?url的方式.结果导致条件选择一两个,url会特别长.然 ...

  4. django 使用form组件提交数据之form表单提交

    django的form组件可以减少后台在进行一些重复性的验证工作,极大降低开发效率. 最近遇到一个问题: 当使用form表单提交数据后,如果数据格式不符合后台定义的规则,需要重新在前端页面填写数据. ...

  5. html Js跨域提交数据方法,跨域提交数据后台获取不到数据

    MVC实现方式:(后台获取不到方法请参考下面js) [ActionAllowOrigin][HttpPost]public JsonResult Cooperation() { return json ...

  6. get和post提交数据的差别

    form表单提交,默认method = "get",所以你在提交数据的时候,最好将此參数指定为method = "post",否则你在提交大数据的时候,可能会出 ...

  7. Django—Form两种保留用户提交数据的方法

    用户在网页上进行表单填写时,有可能出现某项填写错误.一般情况下,用户在未发觉错误的情况下点击提交,则此表单的内容会清空,用户不得不再重新填写,这样的用户体验是及其糟糕的. 在此,我们有2种方法将用户的 ...

  8. from提交数据,高级选择器,伪类选择器,前端样式等

    1. form提交数据 get: 不安全的提交数据,高效 post: 安全的提交数据,低效 前台都可以给后台提交数据,后台一定会给前台一个反馈结果 2. 高级选择器 <!DOCTYPE html ...

  9. HttpURLConnection提交数据

    使用GET方式向服务器端提交数据 * 原理:把要提交的数据组拼到Url后面 * http协议规定数据长度不超过4kb,IE浏览器超过1kb就会丢弃掉后面的数据 * 缺点:数据不安全 * 优点:代码书写 ...

随机推荐

  1. jdom 插入 修改 删除

    创建XML文档 XML文件是一种典型的树形文件,每个文档元素都是一个document元素的子节点.而每个子元素都是一个Element对象,对象可以向下包含. 1 因此我们可以通过先创建元素再将元素添加 ...

  2. GPIO—位带操作

    GPIO—位带操作本章参考资料:< STM32F4xx 中文参考手册>存储器和总线构架章节. GPIO 章节,< Cortex®-M4 内核编程手册> 2.2.5 Bit-ba ...

  3. excel鼠标拖选慢shift选择快的问题

    今天遇到个惊天大坑,关于excel的,最近,一直在调查这个东西,刚开始真的是毫无头绪,反正现在就是excel的值的copy会偶尔慢,慢的情况也是不明白,就是稀里糊涂的调查. 刚开始连100%再现这个b ...

  4. PHP——0128练习相关2——js点击button按钮跳转到另一个新页面

    js点击button按钮跳转到另一个新页面 投稿:whsnow 字体:[增加 减小] 类型:转载 时间:2014-10-10我要评论 点击按钮怎么跳转到另外一个页面呢?点击图片要跳转到新的页面时,怎么 ...

  5. 第二百七十二节,Tornado框架-iframe标签框架伪造ajax

    Tornado框架-iframe标签框架伪造ajax html <!DOCTYPE html> <html> <head lang="en"> ...

  6. High-level NavMesh Building Components

    Here we introduce four high level components for the navigation system: //这里我们介绍四个高水平导航系统组件: NavMesh ...

  7. php -- strpos,stripos,strrpos,strripos,strstr,strchr,stristr,strrchr

    strpos() 函数 语法: mixed strpos ( string $haystack , mixed $needle [, int $offset = 0 ] ) 查找 needle 在 h ...

  8. php -- 魔术方法 之 序列化和反序列化的触发函数:__sleep(),__wakeup()

    __sleep():当对象被当做文件保存时会自动触发的方法. 该方法要做的事情,就是返回一个要保存的对象数据的数组 DB.class.php中修改 再次保存效果 读取db对象 因为没有连接数据,不能操 ...

  9. php如何判断两个时间的时间差

    $time1=2011-11-11 11:11:11$time2=2016-12-10 16:58:13 代码: if(abs(strtotime($time2)-strtotime($time1)) ...

  10. shell命令技巧——文本去重并保持原有顺序

    简单来说,这个技巧相应的是例如以下一种场景 假设有文本例如以下 cccc aaaa bbbb dddd bbbb cccc aaaa 如今须要对它进行去重处理.这个非常easy,sort -u就能够搞 ...