本文整理汇总了Java中org.jboss.netty.util.HashedWheelTimer.stop方法的典型用法代码示例。如果您正苦于以下问题:Java HashedWheelTimer.stop方法的具体用法?Java HashedWheelTimer.stop怎么用?Java HashedWheelTimer.stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.netty.util.HashedWheelTimer
的用法示例。
在下文中一共展示了HashedWheelTimer.stop方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRegisterRequest
import org.jboss.netty.util.HashedWheelTimer; //导入方法依赖的package包/类
@Test
public void testRegisterRequest() throws Exception {
HashedWheelTimer timer = getTimer();
RequestManager requestManager = new RequestManager(timer);
try {
RequestPacket packet = new RequestPacket(new byte[0]);
Future future = requestManager.register(packet, 50);
Thread.sleep(200);
Assert.assertTrue(future.isReady());
Assert.assertFalse(future.isSuccess());
Assert.assertTrue(future.getCause().getMessage().contains("timeout"));
logger.debug(future.getCause().getMessage());
} finally {
requestManager.close();
timer.stop();
}
}
示例2: testRemoveMessageFuture
import org.jboss.netty.util.HashedWheelTimer; //导入方法依赖的package包/类
@Test
public void testRemoveMessageFuture() throws Exception {
HashedWheelTimer timer = getTimer();
RequestManager requestManager = new RequestManager(timer);
try {
RequestPacket packet = new RequestPacket(1, new byte[0]);
DefaultFuture future = requestManager.register(packet, 2000);
future.setFailure(new RuntimeException());
Future nullFuture = requestManager.removeMessageFuture(packet.getRequestId());
Assert.assertNull(nullFuture);
} finally {
requestManager.close();
timer.stop();
}
}
示例3: testRegisterRequest
import org.jboss.netty.util.HashedWheelTimer; //导入方法依赖的package包/类
@Test
public void testRegisterRequest() throws Exception {
HashedWheelTimer timer = getTimer();
RequestManager requestManager = new RequestManager(timer, 3000);
try {
RequestPacket packet = new RequestPacket(new byte[0]);
final Future future = requestManager.register(packet, 50);
TestAwaitUtils.await(new TestAwaitTaskUtils() {
@Override
public boolean checkCompleted() {
return future.isReady();
}
}, 10, 200);
Assert.assertTrue(future.isReady());
Assert.assertFalse(future.isSuccess());
Assert.assertTrue(future.getCause().getMessage().contains("timeout"));
logger.debug(future.getCause().getMessage());
} finally {
requestManager.close();
timer.stop();
}
}
示例4: testRemoveMessageFuture
import org.jboss.netty.util.HashedWheelTimer; //导入方法依赖的package包/类
@Test
public void testRemoveMessageFuture() throws Exception {
HashedWheelTimer timer = getTimer();
RequestManager requestManager = new RequestManager(timer, 3000);
try {
RequestPacket packet = new RequestPacket(1, new byte[0]);
DefaultFuture future = requestManager.register(packet, 2000);
future.setFailure(new RuntimeException());
Future nullFuture = requestManager.removeMessageFuture(packet.getRequestId());
Assert.assertNull(nullFuture);
} finally {
requestManager.close();
timer.stop();
}
}
示例5: initHttpBootstrap
import org.jboss.netty.util.HashedWheelTimer; //导入方法依赖的package包/类
private void initHttpBootstrap(int myport) {
logger.info("initHttpBootstrap...........");
final ServerConfig serverConfig = new ServerConfig(myport);
final ChannelGroup channelGroup = new DefaultChannelGroup(getClass().getName());
bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(
//建议用ThreadPoolExecutor代替
Executors.newCachedThreadPool(),
Executors.newCachedThreadPool(), serverConfig.getThreadCnt()));
//设置常见参数
bootstrap.setOption("tcpNoDelay","true");//禁用nagle算法
bootstrap.setOption("reuseAddress", "true");
bootstrap.setOption("SO_RCVBUF",1024*128);
bootstrap.setOption("SO_SNDBUF",1024*128);
timer = new HashedWheelTimer();
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = Channels.pipeline();
int readTimeout = serverConfig.getReadTimeout();
if (readTimeout > 0) {
pipeline.addLast("timeout", new ReadTimeoutHandler(timer, readTimeout, TimeUnit.MILLISECONDS));
}
pipeline.addLast("decoder", new RpcRequestDecode());
pipeline.addLast("encoder", new RpcResponseEncode());
pipeline.addLast("handler", new NettyRpcServerHandler(channelGroup));
return pipeline;
}
});
int port = serverConfig.getPort();
if (!checkPortConfig(port)) {
throw new IllegalStateException("port: " + port + " already in use!");
}
Channel channel = bootstrap.bind(new InetSocketAddress(port));
channelGroup.add(channel);
logger.info("voyage server started");
waitForShutdownCommand();
ChannelGroupFuture future = channelGroup.close();
future.awaitUninterruptibly();
bootstrap.releaseExternalResources();
timer.stop();
timer = null;
logger.info("voyage server stoped");
}
示例6: testTimerStartTiming
import org.jboss.netty.util.HashedWheelTimer; //导入方法依赖的package包/类
public void testTimerStartTiming() throws InterruptedException {
HashedWheelTimer timer = new HashedWheelTimer(1000, TimeUnit.MILLISECONDS);
timer.start();
timer.stop();
}