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


Java TimerTask類代碼示例

本文整理匯總了Java中org.jboss.netty.util.TimerTask的典型用法代碼示例。如果您正苦於以下問題:Java TimerTask類的具體用法?Java TimerTask怎麽用?Java TimerTask使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TimerTask類屬於org.jboss.netty.util包,在下文中一共展示了TimerTask類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setUp

import org.jboss.netty.util.TimerTask; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
    switchManager = createMock(IOFSwitchManager.class);
    roleManager = createMock(RoleManager.class);
    sw = createMock(IOFSwitchBackend.class);
    timer = createMock(Timer.class);
    expect(timer.newTimeout(anyObject(TimerTask.class), anyLong(), anyObject(TimeUnit.class))).andReturn(EasyMock.createNiceMock(Timeout.class));
    replay(timer);
    seenXids = null;

    // TODO: should mock IDebugCounterService and make sure
    // the expected counters are updated.
    debugCounterService = new DebugCounterServiceImpl();
    SwitchManagerCounters counters =
            new SwitchManagerCounters(debugCounterService);
    expect(switchManager.getCounters()).andReturn(counters).anyTimes();
    replay(switchManager);
    connection = new MockOFConnection(featuresReply.getDatapathId(), OFAuxId.MAIN);
    switchHandler = new OFSwitchHandshakeHandler(connection, featuresReply, switchManager, roleManager, timer);
    
    // replay sw. Reset it if you need more specific behavior
    replay(sw);
}
 
開發者ID:nsg-ethz,項目名稱:iTAP-controller,代碼行數:24,代碼來源:OFSwitchHandlerTestBase.java

示例2: setUp

import org.jboss.netty.util.TimerTask; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
	switchManager = createMock(IOFSwitchManager.class);
	roleManager = createMock(RoleManager.class);
	sw = createMock(IOFSwitchBackend.class);
	timer = createMock(Timer.class);
	expect(timer.newTimeout(anyObject(TimerTask.class), anyLong(), anyObject(TimeUnit.class))).andReturn(EasyMock.createNiceMock(Timeout.class));
	replay(timer);
	seenXids = null;

	// TODO: should mock IDebugCounterService and make sure
	// the expected counters are updated.
	debugCounterService = new DebugCounterServiceImpl();
	SwitchManagerCounters counters =
			new SwitchManagerCounters(debugCounterService);
	expect(switchManager.getCounters()).andReturn(counters).anyTimes();
	replay(switchManager);
	connection = new MockOFConnection(featuresReply.getDatapathId(), OFAuxId.MAIN);
	switchHandler = new OFSwitchHandshakeHandler(connection, featuresReply, switchManager, roleManager, timer);

	// replay sw. Reset it if you need more specific behavior
	replay(sw);
}
 
開發者ID:rizard,項目名稱:fast-failover-demo,代碼行數:24,代碼來源:OFSwitchHandlerTestBase.java

示例3: setUp

import org.jboss.netty.util.TimerTask; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
    switchManager = createMock(IOFSwitchManager.class);
    roleManager = createMock(RoleManager.class);
    sw = createMock(IOFSwitchBackend.class);
    timer = createMock(Timer.class);
    expect(timer.newTimeout(anyObject(TimerTask.class), anyLong(), anyObject(TimeUnit.class))).andReturn(EasyMock.createNiceMock(Timeout.class));
    replay(timer);
    seenXids = null;

    // TODO: should mock IDebugCounterService and make sure
    // the expected counters are updated.
    debugCounterService = new DebugCounterServiceImpl();
    SwitchManagerCounters counters =
            new SwitchManagerCounters(debugCounterService);
    expect(switchManager.getCounters()).andReturn(counters).anyTimes();
    replay(switchManager);
    connection = new MockOFConnection(featuresReply.getDatapathId(), OFAuxId.MAIN);
    switchHandler = new OFSwitchHandshakeHandler(connection, featuresReply, switchManager, roleManager, timer,null);
    
    // replay sw. Reset it if you need more specific behavior
    replay(sw);
}
 
開發者ID:DaiDongLiang,項目名稱:DSC,代碼行數:24,代碼來源:OFSwitchHandlerTestBase.java

示例4: reconnect

import org.jboss.netty.util.TimerTask; //導入依賴的package包/類
private void reconnect() {
  if (!reconnecting.get()) {
    reconnecting.set(true);
    timer.newTimeout(new TimerTask() {
      @Override public void run(Timeout timeout) throws Exception {
        reconnecting.set(false);
        int port = uri.getPort();
        if (port == -1) {
          port = (uri.getScheme().equals("https")) ? 443 : 80;
        }
        bootstrap.setOption("remoteAddress", new InetSocketAddress(uri.getHost(), port));
        bootstrap.connect().await();
      }
    }, reconnectionTimeMillis, TimeUnit.MILLISECONDS);
  }
}
 
開發者ID:tylerjroach,項目名稱:eventsource-android,代碼行數:17,代碼來源:EventSourceChannelHandler.java

示例5: reconnect

import org.jboss.netty.util.TimerTask; //導入依賴的package包/類
private void reconnect() {
    if (!reconnecting.get()) {
        reconnecting.set(true);
        data = new StringBuffer();
        lastEventId = null;
        status = null;
        eventStreamOk = false;
        headerDone = false;
        timer.newTimeout(new TimerTask() {
            @Override
            public void run(Timeout timeout) throws Exception {
                reconnecting.set(false);
                int port = uri.getPort();
                if (port == -1) {
                    port = (uri.getScheme().equals("https")) ? 443 : 80;
                }
                bootstrap.setOption("remoteAddress", new InetSocketAddress(uri.getHost(), port));
                bootstrap.connect().await();
            }
        }, reconnectionTimeMillis, TimeUnit.MILLISECONDS);
    }
}
 
開發者ID:streamdataio,項目名稱:streamdataio-android,代碼行數:23,代碼來源:EventSourceChannelHandler.java

示例6: fireNext

import org.jboss.netty.util.TimerTask; //導入依賴的package包/類
public void fireNext(final Channel channel, final long delay) {
    final Event readyForNext = new Event(currentConversationId);
    if(delay > timerTickSize) {
        timer.newTimeout(new TimerTask() {
            @Override public void run(Timeout timeout) {
                if(logger.isDebugEnabled()) {
                    logger.debug("running after delay: {}", delay);
                }
                if(readyForNext.conversationId != currentConversationId) {
                    logger.debug("pending 'next' event found obsolete, aborting");
                    return;
                }
                Channels.fireMessageReceived(channel, readyForNext);
            }
        }, delay, TimeUnit.MILLISECONDS);
    } else {
        Channels.fireMessageReceived(channel, readyForNext);
    }
}
 
開發者ID:bruni68510,項目名稱:flazr,代碼行數:20,代碼來源:RtmpPublisher.java

示例7: newTimeout

import org.jboss.netty.util.TimerTask; //導入依賴的package包/類
private Timeout newTimeout() {
    if (requestTimeoutInMs > 0) {
        return timeoutExecutor.newTimeout(new TimerTask() {
            @Override
            public void run(Timeout timeout) {
                fsm.sendEvent(new HandshakeTimeoutEvent());
            }
        }, 30, TimeUnit.SECONDS);
    } else {
        return null;
    }
}
 
開發者ID:apache,項目名稱:incubator-omid,代碼行數:13,代碼來源:TSOClient.java

示例8: ConnectionFailedState

import org.jboss.netty.util.TimerTask; //導入依賴的package包/類
ConnectionFailedState(final StateMachine.Fsm fsm, final Throwable exception) {
    super(fsm);
    LOG.debug("NEW STATE: CONNECTION FAILED [RE-CONNECTION BACKOFF]");
    this.exception = exception;
    reconnectionTimeoutExecutor.newTimeout(new TimerTask() {
        @Override
        public void run(Timeout timeout) {
            fsm.sendEvent(new ReconnectEvent());
        }
    }, tsoReconnectionDelayInSecs, TimeUnit.SECONDS);
}
 
開發者ID:apache,項目名稱:incubator-omid,代碼行數:12,代碼來源:TSOClient.java

示例9: channelClosed

import org.jboss.netty.util.TimerTask; //導入依賴的package包/類
@Override
public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e)
		throws Exception {
	logger.warn("channel closed.do connect after:{} seconds.", CONN_DELAY);
	//重連
	timer.newTimeout(new TimerTask() {
		
		@Override
		public void run(Timeout timeout) throws Exception {
			ChannelFuture channelfuture = client.getBootstrap().connect();
			client.setChannel(channelfuture);
		}
	}, CONN_DELAY, TimeUnit.SECONDS);
}
 
開發者ID:DTStack,項目名稱:jlogstash-output-plugin,代碼行數:15,代碼來源:Netty.java

示例10: channelClosed

import org.jboss.netty.util.TimerTask; //導入依賴的package包/類
@Override
public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e)
		throws Exception {
	logger.warn("channel closed.do connect after:{} seconds.", CONN_DELAY);
	//重連
	timer.newTimeout(	new TimerTask() {
		
		@Override
		public void run(Timeout timeout) throws Exception {
			ChannelFuture channelfuture = client.getBootstrap().connect();
			client.setChannel(channelfuture);
		}
	}, CONN_DELAY, TimeUnit.SECONDS);
}
 
開發者ID:DTStack,項目名稱:jlogstash-input-plugin,代碼行數:15,代碼來源:NettySend.java

示例11: newTimeout

import org.jboss.netty.util.TimerTask; //導入依賴的package包/類
@Override
public synchronized Timeout newTimeout(final TimerTask task,
                                       final long delay,
                                       final TimeUnit unit) {
  if (pausedTask == null) {
    pausedTask = task;
  }  else if (newPausedTask == null) {
    newPausedTask = task;
  } else {
    throw new IllegalStateException("Cannot Pause Two Timer Tasks");
  }
  return null;
}
 
開發者ID:OpenTSDB,項目名稱:asyncbigtable,代碼行數:14,代碼來源:TestNSREs.java

示例12: setUp

import org.jboss.netty.util.TimerTask; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
	/*
	 * This needs to be called explicitly to ensure the featuresReply is not null.
	 * Otherwise, there is no guarantee @Before will for setUpFeaturesReply() will
	 * call that function before our @Before setUp() here.
	 */
	setUpFeaturesReply(); 
	switchManager = createMock(IOFSwitchManager.class);
	roleManager = createMock(RoleManager.class);
	sw = createMock(IOFSwitchBackend.class);
	timer = createMock(Timer.class);
	expect(timer.newTimeout(anyObject(TimerTask.class), anyLong(), anyObject(TimeUnit.class))).andReturn(EasyMock.createNiceMock(Timeout.class));
	replay(timer);
	seenXids = null;

	// TODO: should mock IDebugCounterService and make sure
	// the expected counters are updated.
	debugCounterService = new DebugCounterServiceImpl();
	SwitchManagerCounters counters =
			new SwitchManagerCounters(debugCounterService);
	expect(switchManager.getCounters()).andReturn(counters).anyTimes();
	replay(switchManager);
	connection = new MockOFConnection(featuresReply.getDatapathId(), OFAuxId.MAIN);
	switchHandler = new OFSwitchHandshakeHandler(connection, featuresReply, switchManager, roleManager, timer);

	// replay sw. Reset it if you need more specific behavior
	replay(sw);
}
 
開發者ID:rhoybeen,項目名稱:floodlightLB,代碼行數:30,代碼來源:OFSwitchHandlerTestBase.java

示例13: sendPing

import org.jboss.netty.util.TimerTask; //導入依賴的package包/類
private void sendPing() {
    logger.debug("sendPing");
    final TimerTask pintTask = new TimerTask() {
        @Override
        public void run(Timeout timeout) throws Exception {
            if (timeout.isCancelled()) {
                newPingTimeout(this);
                return;
            }

            final ChannelGroupFuture write = channelGroup.write(PingPacket.PING_PACKET);
            if (logger.isWarnEnabled()) {
                write.addListener(new ChannelGroupFutureListener() {
                    private final ChannelFutureListener listener = new WriteFailFutureListener(logger, "ping write fail", "ping write success");

                    @Override
                    public void operationComplete(ChannelGroupFuture future) throws Exception {

                        if (logger.isWarnEnabled()) {
                            for (ChannelFuture channelFuture : future) {
                                channelFuture.addListener(listener);
                            }
                        }
                    }
                });
            }
            newPingTimeout(this);
        }
    };
    newPingTimeout(pintTask);
}
 
開發者ID:masonmei,項目名稱:apm-agent,代碼行數:32,代碼來源:PinpointServerSocket.java

示例14: newPingTimeout

import org.jboss.netty.util.TimerTask; //導入依賴的package包/類
private void newPingTimeout(TimerTask pintTask) {
    try {
        logger.debug("newPingTimeout");
        pingTimer.newTimeout(pintTask, 1000 * 60 * 5, TimeUnit.MILLISECONDS);
    } catch (IllegalStateException e) {
        // stop in case of timer stopped
        logger.debug("timer stopped. Caused:{}", e.getMessage());
    }
}
 
開發者ID:masonmei,項目名稱:apm-agent,代碼行數:10,代碼來源:PinpointServerSocket.java

示例15: newTimer

import org.jboss.netty.util.TimerTask; //導入依賴的package包/類
private TimerTask newTimer() {
    return new TimerTask() {
        @Override
        public void run(Timeout timeout) throws Exception {
            onTimeout(System.nanoTime() - startTime);
        }
    };
}
 
開發者ID:odiszapc,項目名稱:stem,代碼行數:9,代碼來源:RequestFuture.java


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