use of org.jboss.netty.bootstrap.ConnectionlessBootstrap in project traccar by traccar.
the class AtrackProtocol method initTrackerServers.
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("frameDecoder", new AtrackFrameDecoder());
pipeline.addLast("objectEncoder", new AtrackProtocolEncoder());
pipeline.addLast("objectDecoder", new AtrackProtocolDecoder(AtrackProtocol.this));
}
});
serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("objectEncoder", new AtrackProtocolEncoder());
pipeline.addLast("objectDecoder", new AtrackProtocolDecoder(AtrackProtocol.this));
}
});
}
use of org.jboss.netty.bootstrap.ConnectionlessBootstrap in project traccar by traccar.
the class Tr900Protocol method initTrackerServers.
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("objectDecoder", new Tr900ProtocolDecoder(Tr900Protocol.this));
}
});
serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("objectDecoder", new Tr900ProtocolDecoder(Tr900Protocol.this));
}
});
}
use of org.jboss.netty.bootstrap.ConnectionlessBootstrap in project feeyo-hlsserver by variflight.
the class UdpServer method startup.
public void startup(int port) {
ChannelFactory channelFactory = new NioDatagramChannelFactory(Executors.newCachedThreadPool());
bootstrap = new ConnectionlessBootstrap(channelFactory);
bootstrap.setOption("reuseAddress", false);
bootstrap.setOption("child.reuseAddress", false);
// 15M
bootstrap.setOption("readBufferSize", 1024 * 1024 * 15);
bootstrap.setOption("writeBufferSize", 1024 * 20);
bootstrap.setOption("receiveBufferSizePredictor", new FixedReceiveBufferSizePredictor(1024 * 3));
bootstrap.setOption("receiveBufferSizePredictorFactory", new FixedReceiveBufferSizePredictorFactory(1024 * 3));
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
@Override
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = Channels.pipeline();
pipeline.addLast("handler", new UdpServerChannelHandler());
return pipeline;
}
});
datagramChannel = (DatagramChannel) bootstrap.bind(new InetSocketAddress(port));
}
use of org.jboss.netty.bootstrap.ConnectionlessBootstrap in project hadoop by apache.
the class SimpleUdpServer method run.
public void run() {
// Configure the client.
DatagramChannelFactory f = new NioDatagramChannelFactory(Executors.newCachedThreadPool(), workerCount);
server = new ConnectionlessBootstrap(f);
server.setPipeline(Channels.pipeline(RpcUtil.STAGE_RPC_MESSAGE_PARSER, rpcProgram, RpcUtil.STAGE_RPC_UDP_RESPONSE));
server.setOption("broadcast", "false");
server.setOption("sendBufferSize", SEND_BUFFER_SIZE);
server.setOption("receiveBufferSize", RECEIVE_BUFFER_SIZE);
server.setOption("reuseAddress", true);
// Listen to the UDP port
ch = server.bind(new InetSocketAddress(port));
InetSocketAddress socketAddr = (InetSocketAddress) ch.getLocalAddress();
boundPort = socketAddr.getPort();
LOG.info("Started listening to UDP requests at port " + boundPort + " for " + rpcProgram + " with workerCount " + workerCount);
}
use of org.jboss.netty.bootstrap.ConnectionlessBootstrap in project pinpoint by naver.
the class NettyUdpReceiverTest method server.
/*
* netty io thread is single-threaded even for udp.
* this is for running multiple workers.
* */
@Test
public void server() throws IOException, InterruptedException {
final ConnectionlessBootstrap udpServer = createUdpServer();
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
udpServer.bind(new InetSocketAddress("127.0.0.1", PORT));
try {
logger.debug("server-await");
latch.await();
} catch (InterruptedException ignored) {
}
logger.debug("server-shutdown");
udpServer.shutdown();
}
});
thread.start();
Thread.sleep(1000);
logger.debug("start--------");
// ExecutorService executorService = Executors.newFixedThreadPool(10);
// for (int i =0; i< 10; i++) {
// executorService.execute(new Runnable() {
// @Override
// public void run() {
// try {
start();
// } catch (IOException e) {
// e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
// }
// }
// });
// }
// executorService.awaitTermination(120, TimeUnit.SECONDS) ;
latch.countDown();
}
Aggregations