當前位置: 首頁>>代碼示例>>Java>>正文


Java HashedWheelTimer.stop方法代碼示例

本文整理匯總了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();
    }
}
 
開發者ID:masonmei,項目名稱:apm-agent,代碼行數:19,代碼來源:RequestManagerTest.java

示例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();
    }

}
 
開發者ID:masonmei,項目名稱:apm-agent,代碼行數:21,代碼來源:RequestManagerTest.java

示例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();
    }
}
 
開發者ID:naver,項目名稱:pinpoint,代碼行數:25,代碼來源:RequestManagerTest.java

示例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();
    }

}
 
開發者ID:naver,項目名稱:pinpoint,代碼行數:19,代碼來源:RequestManagerTest.java

示例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");

}
 
開發者ID:zhaoshiling1017,項目名稱:voyage,代碼行數:48,代碼來源:RpcServerBootstrap.java

示例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();
}
 
開發者ID:masonmei,項目名稱:apm-agent,代碼行數:6,代碼來源:RequestManagerTest.java


注:本文中的org.jboss.netty.util.HashedWheelTimer.stop方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。