本文整理汇总了Java中org.jboss.netty.bootstrap.ConnectionlessBootstrap类的典型用法代码示例。如果您正苦于以下问题:Java ConnectionlessBootstrap类的具体用法?Java ConnectionlessBootstrap怎么用?Java ConnectionlessBootstrap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConnectionlessBootstrap类属于org.jboss.netty.bootstrap包,在下文中一共展示了ConnectionlessBootstrap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initTrackerServers
import org.jboss.netty.bootstrap.ConnectionlessBootstrap; //导入依赖的package包/类
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("frameDecoder", new CellocatorFrameDecoder());
pipeline.addLast("objectEncoder", new CellocatorProtocolEncoder());
pipeline.addLast("objectDecoder", new CellocatorProtocolDecoder(CellocatorProtocol.this));
}
};
server.setEndianness(ByteOrder.LITTLE_ENDIAN);
serverList.add(server);
server = new TrackerServer(new ConnectionlessBootstrap(), getName()) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("objectEncoder", new CellocatorProtocolEncoder());
pipeline.addLast("objectDecoder", new CellocatorProtocolDecoder(CellocatorProtocol.this));
}
};
server.setEndianness(ByteOrder.LITTLE_ENDIAN);
serverList.add(server);
}
示例2: initTrackerServers
import org.jboss.netty.bootstrap.ConnectionlessBootstrap; //导入依赖的package包/类
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("frameDecoder", new MeitrackFrameDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectEncoder", new MeitrackProtocolEncoder());
pipeline.addLast("objectDecoder", new MeitrackProtocolDecoder(MeitrackProtocol.this));
}
};
server.setEndianness(ByteOrder.LITTLE_ENDIAN);
serverList.add(server);
server = new TrackerServer(new ConnectionlessBootstrap(), getName()) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectEncoder", new MeitrackProtocolEncoder());
pipeline.addLast("objectDecoder", new MeitrackProtocolDecoder(MeitrackProtocol.this));
}
};
server.setEndianness(ByteOrder.LITTLE_ENDIAN);
serverList.add(server);
}
示例3: initTrackerServers
import org.jboss.netty.bootstrap.ConnectionlessBootstrap; //导入依赖的package包/类
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 2, -4, 0));
pipeline.addLast("objectDecoder", new CastelProtocolDecoder(CastelProtocol.this));
}
};
server.setEndianness(ByteOrder.LITTLE_ENDIAN);
serverList.add(server);
server = new TrackerServer(new ConnectionlessBootstrap(), getName()) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("objectDecoder", new CastelProtocolDecoder(CastelProtocol.this));
}
};
server.setEndianness(ByteOrder.LITTLE_ENDIAN);
serverList.add(server);
}
示例4: TrackerServer
import org.jboss.netty.bootstrap.ConnectionlessBootstrap; //导入依赖的package包/类
public TrackerServer(Bootstrap bootstrap, String protocol) {
this.bootstrap = bootstrap;
this.protocol = protocol;
if (bootstrap instanceof ServerBootstrap) {
bootstrap.setFactory(GlobalChannelFactory.getFactory());
} else if (bootstrap instanceof ConnectionlessBootstrap) {
bootstrap.setFactory(GlobalChannelFactory.getDatagramFactory());
}
address = Context.getConfig().getString(protocol + ".address");
port = Context.getConfig().getInteger(protocol + ".port");
bootstrap.setPipelineFactory(new BasePipelineFactory(this, protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
TrackerServer.this.addSpecificHandlers(pipeline);
}
});
}
示例5: run
import org.jboss.netty.bootstrap.ConnectionlessBootstrap; //导入依赖的package包/类
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);
// 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);
}
示例6: run
import org.jboss.netty.bootstrap.ConnectionlessBootstrap; //导入依赖的package包/类
public void run() {
// Configure the client.
DatagramChannelFactory f = new NioDatagramChannelFactory(
Executors.newCachedThreadPool(), workerCount);
ConnectionlessBootstrap b = new ConnectionlessBootstrap(f);
b.setPipeline(Channels.pipeline(
RpcUtil.STAGE_RPC_MESSAGE_PARSER, rpcProgram,
RpcUtil.STAGE_RPC_UDP_RESPONSE));
b.setOption("broadcast", "false");
b.setOption("sendBufferSize", SEND_BUFFER_SIZE);
b.setOption("receiveBufferSize", RECEIVE_BUFFER_SIZE);
// Listen to the UDP port
Channel ch = b.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);
}
示例7: run
import org.jboss.netty.bootstrap.ConnectionlessBootstrap; //导入依赖的package包/类
public void run() {
// Configure the client.
DatagramChannelFactory f = new NioDatagramChannelFactory(
Executors.newCachedThreadPool(), workerCount);
ConnectionlessBootstrap b = new ConnectionlessBootstrap(f);
ChannelPipeline p = b.getPipeline();
p.addLast("handler", new SimpleUdpServerHandler(rpcProgram));
b.setOption("broadcast", "false");
b.setOption("sendBufferSize", SEND_BUFFER_SIZE);
b.setOption("receiveBufferSize", RECEIVE_BUFFER_SIZE);
// Listen to the UDP port
b.bind(new InetSocketAddress(port));
LOG.info("Started listening to UDP requests at port " + port + " for "
+ rpcProgram + " with workerCount " + workerCount);
}
示例8: TrackerServer
import org.jboss.netty.bootstrap.ConnectionlessBootstrap; //导入依赖的package包/类
public TrackerServer(ServerManager serverManager, Bootstrap bootstrap, String protocol) {
this.serverManager = serverManager;
this.bootstrap = bootstrap;
this.protocol = protocol;
// Set appropriate channel factory
if (bootstrap instanceof ServerBootstrap) {
bootstrap.setFactory(GlobalChannelFactory.getFactory());
} else if (bootstrap instanceof ConnectionlessBootstrap) {
bootstrap.setFactory(GlobalChannelFactory.getDatagramFactory());
}
address = serverManager.getProperties().getProperty(protocol + ".address");
String portProperty = serverManager.getProperties().getProperty(protocol + ".port");
port = (portProperty != null) ? Integer.valueOf(portProperty) : 5000;
bootstrap.setPipelineFactory(new BasePipelineFactory(serverManager, this, protocol) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
TrackerServer.this.addSpecificHandlers(pipeline);
}
});
}
示例9: start
import org.jboss.netty.bootstrap.ConnectionlessBootstrap; //导入依赖的package包/类
/**
* Start server
*/
public void start() {
InetSocketAddress endpoint;
if (address == null) {
endpoint = new InetSocketAddress(port);
} else {
endpoint = new InetSocketAddress(address, port);
}
Channel channel = null;
if (bootstrap instanceof ServerBootstrap) {
channel = ((ServerBootstrap) bootstrap).bind(endpoint);
} else if (bootstrap instanceof ConnectionlessBootstrap) {
channel = ((ConnectionlessBootstrap) bootstrap).bind(endpoint);
}
if (channel != null) {
getChannelGroup().add(channel);
}
}
示例10: run
import org.jboss.netty.bootstrap.ConnectionlessBootstrap; //导入依赖的package包/类
public void run() {
// Configure the client.
DatagramChannelFactory f = new NioDatagramChannelFactory(
Executors.newCachedThreadPool(), workerCount);
ConnectionlessBootstrap b = new ConnectionlessBootstrap(f);
b.setPipeline(Channels.pipeline(
RpcUtil.STAGE_RPC_MESSAGE_PARSER, rpcProgram,
RpcUtil.STAGE_RPC_UDP_RESPONSE));
b.setOption("broadcast", "false");
b.setOption("sendBufferSize", SEND_BUFFER_SIZE);
b.setOption("receiveBufferSize", RECEIVE_BUFFER_SIZE);
// Listen to the UDP port
b.bind(new InetSocketAddress(port));
LOG.info("Started listening to UDP requests at port " + port + " for "
+ rpcProgram + " with workerCount " + workerCount);
}
示例11: createUdpServer
import org.jboss.netty.bootstrap.ConnectionlessBootstrap; //导入依赖的package包/类
private ConnectionlessBootstrap createUdpServer() {
DatagramChannelFactory udpFactory = new NioDatagramChannelFactory(Executors.newCachedThreadPool(), 4);
ChannelPipelineFactory pipelineFactory = new ChannelPipelineFactory() {
@Override
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = Channels.pipeline();
pipeline.addLast("test", new SimpleChannelHandler() {
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
String name = Thread.currentThread().getName();
logger.debug("sleep:{}", name);
Thread.sleep(10000);
// if (!name.equals("New I/O worker #1")) {
logger.debug("messageReceived thread-{} message:", Thread.currentThread().getName());
// }
}
});
return pipeline;
}
};
ConnectionlessBootstrap udpBootstrap = new ConnectionlessBootstrap(udpFactory);
udpBootstrap.setPipelineFactory(pipelineFactory);
return udpBootstrap;
}
示例12: start
import org.jboss.netty.bootstrap.ConnectionlessBootstrap; //导入依赖的package包/类
@Override
public void start() {
// setup Netty server
ConnectionlessBootstrap serverBootstrap = new ConnectionlessBootstrap(
new OioDatagramChannelFactory(Executors.newCachedThreadPool()));
final syslogHandler handler = new syslogHandler();
handler.setFormater(formaterProp);
handler.setKeepFields(keepFields);
serverBootstrap.setOption("receiveBufferSizePredictorFactory",
new AdaptiveReceiveBufferSizePredictorFactory(DEFAULT_MIN_SIZE,
DEFAULT_INITIAL_SIZE, maxsize));
serverBootstrap.setPipelineFactory(new ChannelPipelineFactory() {
@Override
public ChannelPipeline getPipeline() {
return Channels.pipeline(handler);
}
});
if (host == null) {
nettyChannel = serverBootstrap.bind(new InetSocketAddress(port));
} else {
nettyChannel = serverBootstrap.bind(new InetSocketAddress(host, port));
}
sourceCounter.start();
super.start();
}
示例13: initTrackerServers
import org.jboss.netty.bootstrap.ConnectionlessBootstrap; //导入依赖的package包/类
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("objectDecoder", new SkypatrolProtocolDecoder(SkypatrolProtocol.this));
}
});
}
示例14: initTrackerServers
import org.jboss.netty.bootstrap.ConnectionlessBootstrap; //导入依赖的package包/类
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectDecoder", new HomtecsProtocolDecoder(HomtecsProtocol.this));
}
});
}
示例15: initTrackerServers
import org.jboss.netty.bootstrap.ConnectionlessBootstrap; //导入依赖的package包/类
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("objectDecoder", new Xt2400ProtocolDecoder(Xt2400Protocol.this));
}
});
}