Java 类io.netty.util.Timer 实例源码

项目:simulacron    文件:Server.java   
Server(
    AddressResolver addressResolver,
    EventLoopGroup eventLoopGroup,
    boolean customEventLoop,
    Timer timer,
    boolean customTimer,
    long bindTimeoutInNanos,
    StubStore stubStore,
    boolean activityLogging,
    ServerBootstrap serverBootstrap) {
  // custom constructor onyl made to help facilitate testing with a custom bootstrap.
  this.addressResolver = addressResolver;
  this.timer = timer;
  this.customTimer = customTimer;
  this.eventLoopGroup = eventLoopGroup;
  this.customEventLoop = customEventLoop;
  this.serverBootstrap = serverBootstrap;
  this.bindTimeoutInNanos = bindTimeoutInNanos;
  this.stubStore = stubStore;
  this.activityLogging = activityLogging;
}
项目:simulacron    文件:Server.java   
private Server(
    AddressResolver addressResolver,
    EventLoopGroup eventLoopGroup,
    Class<? extends ServerChannel> channelClass,
    boolean customEventLoop,
    Timer timer,
    boolean customTimer,
    long bindTimeoutInNanos,
    StubStore stubStore,
    boolean activityLogging) {
  this(
      addressResolver,
      eventLoopGroup,
      customEventLoop,
      timer,
      customTimer,
      bindTimeoutInNanos,
      stubStore,
      activityLogging,
      new ServerBootstrap()
          .group(eventLoopGroup)
          .channel(channelClass)
          .childHandler(new Initializer()));
}
项目:simulacron    文件:ServerTest.java   
@Test
public void testTryWithResourcesShouldCloseAllClustersButNotTimerIfProvided() throws Exception {
  EventLoopGroup eventLoop;
  Timer timer = new HashedWheelTimer();

  try (Server server = Server.builder().withTimer(timer).build()) {
    // Do nothing here, since this is a unit test, we don't want to create any inet sockets
    // which is what Server does by default.
    eventLoop = server.eventLoopGroup;
  }

  // event loop should have been closed since a custom one was not provided.
  assertThat(eventLoop.isShutdown()).isTrue();
  // timer should not have been closed since a custom one was provided.
  timer.newTimeout(
      timeout -> {
        // noop
      },
      1,
      TimeUnit.SECONDS);
  timer.stop();
}
项目:JRediClients    文件:RedisClient.java   
@Deprecated
public RedisClient(final Timer timer, ExecutorService executor, EventLoopGroup group, Class<? extends SocketChannel> socketChannelClass, String host, int port, 
                    int connectTimeout, int commandTimeout) {
    RedisClientConfig config = new RedisClientConfig();
    config.setTimer(timer).setExecutor(executor).setGroup(group).setSocketChannelClass(socketChannelClass)
    .setAddress(host, port).setConnectTimeout(connectTimeout).setCommandTimeout(commandTimeout);

    this.config = config;
    this.executor = config.getExecutor();
    this.timer = config.getTimer();

    addr = new InetSocketAddress(config.getAddress().getHost(), config.getAddress().getPort());

    channels = new DefaultChannelGroup(config.getGroup().next());
    bootstrap = createBootstrap(config, Type.PLAIN);
    pubSubBootstrap = createBootstrap(config, Type.PUBSUB);

    this.commandTimeout = config.getCommandTimeout();
}
项目:fresco_floodlight    文件:OFChannelInitializer.java   
public OFChannelInitializer(IOFSwitchManager switchManager,
        INewOFConnectionListener connectionListener,
        IDebugCounterService debugCounters,
        Timer timer,
        List<U32> ofBitmaps,
        OFFactory defaultFactory,
        String keyStore, 
        String keyStorePassword) {
    super();
    this.switchManager = switchManager;
    this.connectionListener = connectionListener;
    this.timer = timer;
    this.debugCounters = debugCounters;
    this.defaultFactory = defaultFactory;
    this.ofBitmaps = ofBitmaps;
    this.keyStore = keyStore;
    this.keyStorePassword = keyStorePassword;
}
项目:fresco_floodlight    文件:OFConnection.java   
public OFConnection(@Nonnull DatapathId dpid,
        @Nonnull OFFactory factory,
        @Nonnull Channel channel,
        @Nonnull OFAuxId auxId,
        @Nonnull IDebugCounterService debugCounters,
        @Nonnull Timer timer) {
    Preconditions.checkNotNull(dpid, "dpid");
    Preconditions.checkNotNull(factory, "factory");
    Preconditions.checkNotNull(channel, "channel");
    Preconditions.checkNotNull(timer, "timer");
    Preconditions.checkNotNull(debugCounters);

    this.listener = NullConnectionListener.INSTANCE;
    this.dpid = dpid;
    this.factory = factory;
    this.channel = channel;
    this.auxId = auxId;
    this.connectedSince = new Date();
    this.xidDeliverableMap = new ConcurrentHashMap<>();
    this.counters = new OFConnectionCounters(debugCounters, dpid, this.auxId);
    this.timer = timer;
    this.latency = U64.ZERO;
}
项目:fresco_floodlight    文件:OFChannelHandler.java   
/**
 * Creates a handler for interacting with the switch channel
 *
 * @param controller
 *            the controller
 * @param newConnectionListener
 *            the class that listens for new OF connections (switchManager)
 * @param pipeline
 *            the channel pipeline
 * @param threadPool
 *            the thread pool
 * @param idleTimer
 *            the hash wheeled timer used to send idle messages (echo).
 *            passed to constructor to modify in case of aux connection.
 * @param debugCounters
 */
OFChannelHandler(@Nonnull IOFSwitchManager switchManager,
        @Nonnull INewOFConnectionListener newConnectionListener,
        @Nonnull ChannelPipeline pipeline,
        @Nonnull IDebugCounterService debugCounters,
        @Nonnull Timer timer,
        @Nonnull List<U32> ofBitmaps,
        @Nonnull OFFactory defaultFactory) {

    Preconditions.checkNotNull(switchManager, "switchManager");
    Preconditions.checkNotNull(newConnectionListener, "connectionOpenedListener");
    Preconditions.checkNotNull(pipeline, "pipeline");
    Preconditions.checkNotNull(timer, "timer");
    Preconditions.checkNotNull(debugCounters, "debugCounters");

    this.pipeline = pipeline;
    this.debugCounters = debugCounters;
    this.newConnectionListener = newConnectionListener;
    this.counters = switchManager.getCounters();
    this.state = new InitState();
    this.timer = timer;
    this.ofBitmaps = ofBitmaps;
    this.factory = defaultFactory;

    log.debug("constructor on OFChannelHandler {}", String.format("%08x", System.identityHashCode(this)));
}
项目:hashsdn-controller    文件:HashedWheelTimerModule.java   
@Override
public AutoCloseable createInstance() {
    // The service is provided via blueprint so wait for and return it here for backwards compatibility.
    final WaitingServiceTracker<Timer> tracker = WaitingServiceTracker.create(
            Timer.class, bundleContext, "(type=global-timer)");
    final Timer timer = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);

    return Reflection.newProxy(AutoCloseableTimerInterface.class, new AbstractInvocationHandler() {
        @Override
        protected Object handleInvocation(final Object proxy, final Method method, final Object[] args) throws Throwable {
            if (method.getName().equals("close")) {
                tracker.close();
                return null;
            } else {
                return method.invoke(timer, args);
            }
        }
    });
}
项目:SDN-Multicast    文件:OFChannelInitializer.java   
public OFChannelInitializer(IOFSwitchManager switchManager,
        INewOFConnectionListener connectionListener,
        IDebugCounterService debugCounters,
        Timer timer,
        List<U32> ofBitmaps,
        OFFactory defaultFactory,
        String keyStore, 
        String keyStorePassword) {
    super();
    this.switchManager = switchManager;
    this.connectionListener = connectionListener;
    this.timer = timer;
    this.debugCounters = debugCounters;
    this.defaultFactory = defaultFactory;
    this.ofBitmaps = ofBitmaps;
    this.keyStore = keyStore;
    this.keyStorePassword = keyStorePassword;
}
项目:SDN-Multicast    文件:OFConnection.java   
public OFConnection(@Nonnull DatapathId dpid,
        @Nonnull OFFactory factory,
        @Nonnull Channel channel,
        @Nonnull OFAuxId auxId,
        @Nonnull IDebugCounterService debugCounters,
        @Nonnull Timer timer) {
    Preconditions.checkNotNull(dpid, "dpid");
    Preconditions.checkNotNull(factory, "factory");
    Preconditions.checkNotNull(channel, "channel");
    Preconditions.checkNotNull(timer, "timer");
    Preconditions.checkNotNull(debugCounters);

    this.listener = NullConnectionListener.INSTANCE;
    this.dpid = dpid;
    this.factory = factory;
    this.channel = channel;
    this.auxId = auxId;
    this.connectedSince = new Date();
    this.xidDeliverableMap = new ConcurrentHashMap<>();
    this.counters = new OFConnectionCounters(debugCounters, dpid, this.auxId);
    this.timer = timer;
    this.latency = U64.ZERO;
}
项目:SDN-Multicast    文件:OFChannelHandler.java   
/**
 * Creates a handler for interacting with the switch channel
 *
 * @param controller
 *            the controller
 * @param newConnectionListener
 *            the class that listens for new OF connections (switchManager)
 * @param pipeline
 *            the channel pipeline
 * @param threadPool
 *            the thread pool
 * @param idleTimer
 *            the hash wheeled timer used to send idle messages (echo).
 *            passed to constructor to modify in case of aux connection.
 * @param debugCounters
 */
OFChannelHandler(@Nonnull IOFSwitchManager switchManager,
        @Nonnull INewOFConnectionListener newConnectionListener,
        @Nonnull ChannelPipeline pipeline,
        @Nonnull IDebugCounterService debugCounters,
        @Nonnull Timer timer,
        @Nonnull List<U32> ofBitmaps,
        @Nonnull OFFactory defaultFactory) {

    Preconditions.checkNotNull(switchManager, "switchManager");
    Preconditions.checkNotNull(newConnectionListener, "connectionOpenedListener");
    Preconditions.checkNotNull(pipeline, "pipeline");
    Preconditions.checkNotNull(timer, "timer");
    Preconditions.checkNotNull(debugCounters, "debugCounters");

    this.pipeline = pipeline;
    this.debugCounters = debugCounters;
    this.newConnectionListener = newConnectionListener;
    this.counters = switchManager.getCounters();
    this.state = new InitState();
    this.timer = timer;
    this.ofBitmaps = ofBitmaps;
    this.factory = defaultFactory;

    log.debug("constructor on OFChannelHandler {}", String.format("%08x", System.identityHashCode(this)));
}
项目:ACAMPController    文件:OFChannelHandler.java   
/**
 * Creates a handler for interacting with the switch channel
 *
 * @param controller
 *            the controller
 * @param newConnectionListener
 *            the class that listens for new OF connections (switchManager)
 * @param pipeline
 *            the channel pipeline
 * @param threadPool
 *            the thread pool
 * @param idleTimer
 *            the hash wheeled timer used to send idle messages (echo).
 *            passed to constructor to modify in case of aux connection.
 * @param debugCounters
 */
OFChannelHandler(@Nonnull IOFSwitchManager switchManager,
        @Nonnull INewOFConnectionListener newConnectionListener,
        @Nonnull ChannelPipeline pipeline,
        @Nonnull IDebugCounterService debugCounters,
        @Nonnull Timer timer,
        @Nonnull List<U32> ofBitmaps,
        @Nonnull OFFactory defaultFactory) {

    Preconditions.checkNotNull(switchManager, "switchManager");
    Preconditions.checkNotNull(newConnectionListener, "connectionOpenedListener");
    Preconditions.checkNotNull(pipeline, "pipeline");
    Preconditions.checkNotNull(timer, "timer");
    Preconditions.checkNotNull(debugCounters, "debugCounters");

    this.pipeline = pipeline;
    this.debugCounters = debugCounters;
    this.newConnectionListener = newConnectionListener;
    this.counters = switchManager.getCounters();
    this.state = new InitState();
    this.timer = timer;
    this.ofBitmaps = ofBitmaps;
    this.factory = defaultFactory;

    log.debug("constructor on OFChannelHandler {}", String.format("%08x", System.identityHashCode(this)));
}
项目:ACAMPController    文件:OFChannelInitializer.java   
public OFChannelInitializer(IOFSwitchManager switchManager,
        INewOFConnectionListener connectionListener,
        IDebugCounterService debugCounters,
        Timer timer,
        List<U32> ofBitmaps,
        OFFactory defaultFactory,
        String keyStore, 
        String keyStorePassword) {
    super();
    this.switchManager = switchManager;
    this.connectionListener = connectionListener;
    this.timer = timer;
    this.debugCounters = debugCounters;
    this.defaultFactory = defaultFactory;
    this.ofBitmaps = ofBitmaps;
    this.keyStore = keyStore;
    this.keyStorePassword = keyStorePassword;
}
项目:arscheduler    文件:OFChannelInitializer.java   
public OFChannelInitializer(IOFSwitchManager switchManager,
        INewOFConnectionListener connectionListener,
        IDebugCounterService debugCounters,
        Timer timer,
        List<U32> ofBitmaps,
        OFFactory defaultFactory,
        String keyStore, 
        String keyStorePassword) {
    super();
    this.switchManager = switchManager;
    this.connectionListener = connectionListener;
    this.timer = timer;
    this.debugCounters = debugCounters;
    this.defaultFactory = defaultFactory;
    this.ofBitmaps = ofBitmaps;
    this.keyStore = keyStore;
    this.keyStorePassword = keyStorePassword;
}
项目:ACAMPController    文件:OFConnection.java   
public OFConnection(@Nonnull DatapathId dpid,
        @Nonnull OFFactory factory,
        @Nonnull Channel channel,
        @Nonnull OFAuxId auxId,
        @Nonnull IDebugCounterService debugCounters,
        @Nonnull Timer timer) {
    Preconditions.checkNotNull(dpid, "dpid");
    Preconditions.checkNotNull(factory, "factory");
    Preconditions.checkNotNull(channel, "channel");
    Preconditions.checkNotNull(timer, "timer");
    Preconditions.checkNotNull(debugCounters);

    this.listener = NullConnectionListener.INSTANCE;
    this.dpid = dpid;
    this.factory = factory;
    this.channel = channel;
    this.auxId = auxId;
    this.connectedSince = new Date();
    this.xidDeliverableMap = new ConcurrentHashMap<>();
    this.counters = new OFConnectionCounters(debugCounters, dpid, this.auxId);
    this.timer = timer;
    this.latency = U64.ZERO;
}
项目:arscheduler    文件:OFChannelHandler.java   
/**
 * Creates a handler for interacting with the switch channel
 *
 * @param controller
 *            the controller
 * @param newConnectionListener
 *            the class that listens for new OF connections (switchManager)
 * @param pipeline
 *            the channel pipeline
 * @param threadPool
 *            the thread pool
 * @param idleTimer
 *            the hash wheeled timer used to send idle messages (echo).
 *            passed to constructor to modify in case of aux connection.
 * @param debugCounters
 */
OFChannelHandler(@Nonnull IOFSwitchManager switchManager,
        @Nonnull INewOFConnectionListener newConnectionListener,
        @Nonnull ChannelPipeline pipeline,
        @Nonnull IDebugCounterService debugCounters,
        @Nonnull Timer timer,
        @Nonnull List<U32> ofBitmaps,
        @Nonnull OFFactory defaultFactory) {

    Preconditions.checkNotNull(switchManager, "switchManager");
    Preconditions.checkNotNull(newConnectionListener, "connectionOpenedListener");
    Preconditions.checkNotNull(pipeline, "pipeline");
    Preconditions.checkNotNull(timer, "timer");
    Preconditions.checkNotNull(debugCounters, "debugCounters");

    this.pipeline = pipeline;
    this.debugCounters = debugCounters;
    this.newConnectionListener = newConnectionListener;
    this.counters = switchManager.getCounters();
    this.state = new InitState();
    this.timer = timer;
    this.ofBitmaps = ofBitmaps;
    this.factory = defaultFactory;

    log.debug("constructor on OFChannelHandler {}", String.format("%08x", System.identityHashCode(this)));
}
项目:floodlight1.2-delay    文件:OFChannelInitializer.java   
public OFChannelInitializer(IOFSwitchManager switchManager,
        INewOFConnectionListener connectionListener,
        IDebugCounterService debugCounters,
        Timer timer,
        List<U32> ofBitmaps,
        OFFactory defaultFactory,
        String keyStore, 
        String keyStorePassword) {
    super();
    this.switchManager = switchManager;
    this.connectionListener = connectionListener;
    this.timer = timer;
    this.debugCounters = debugCounters;
    this.defaultFactory = defaultFactory;
    this.ofBitmaps = ofBitmaps;
    this.keyStore = keyStore;
    this.keyStorePassword = keyStorePassword;
}
项目:floodlight1.2-delay    文件:OFConnection.java   
public OFConnection(@Nonnull DatapathId dpid,
        @Nonnull OFFactory factory,
        @Nonnull Channel channel,
        @Nonnull OFAuxId auxId,
        @Nonnull IDebugCounterService debugCounters,
        @Nonnull Timer timer) {
    Preconditions.checkNotNull(dpid, "dpid");
    Preconditions.checkNotNull(factory, "factory");
    Preconditions.checkNotNull(channel, "channel");
    Preconditions.checkNotNull(timer, "timer");
    Preconditions.checkNotNull(debugCounters);

    this.listener = NullConnectionListener.INSTANCE;
    this.dpid = dpid;
    this.factory = factory;
    this.channel = channel;
    this.auxId = auxId;
    this.connectedSince = new Date();
    this.xidDeliverableMap = new ConcurrentHashMap<>();
    this.counters = new OFConnectionCounters(debugCounters, dpid, this.auxId);
    this.timer = timer;
    this.latency = U64.ZERO;
}
项目:megaphone    文件:TimeoutsHolder.java   
public TimeoutsHolder(Timer nettyTimer, NettyResponseFuture<?> nettyResponseFuture, NettyRequestSender requestSender, AsyncHttpClientConfig config) {
    this.nettyTimer = nettyTimer;
    this.nettyResponseFuture = nettyResponseFuture;
    this.requestSender = requestSender;
    this.readTimeoutValue = config.getReadTimeout();

    int requestTimeoutInMs = nettyResponseFuture.getTargetRequest().getRequestTimeout();
    if (requestTimeoutInMs == 0) {
        requestTimeoutInMs = config.getRequestTimeout();
    }

    if (requestTimeoutInMs != -1) {
        requestTimeoutMillisTime = millisTime() + requestTimeoutInMs;
        requestTimeout = newTimeout(new RequestTimeoutTimerTask(nettyResponseFuture, requestSender, this, requestTimeoutInMs), requestTimeoutInMs);
    } else {
        requestTimeoutMillisTime = -1L;
        requestTimeout = null;
    }
}
项目:floodlight-hardware    文件:OFChannelInitializer.java   
public OFChannelInitializer(IOFSwitchManager switchManager,
        INewOFConnectionListener connectionListener,
        IDebugCounterService debugCounters,
        Timer timer,
        List<U32> ofBitmaps,
        OFFactory defaultFactory,
        String keyStore,
        String keyStorePassword) {
    super();
    this.switchManager = switchManager;
    this.connectionListener = connectionListener;
    this.timer = timer;
    this.debugCounters = debugCounters;
    this.defaultFactory = defaultFactory;
    this.ofBitmaps = ofBitmaps;
    this.keyStore = keyStore;
    this.keyStorePassword = keyStorePassword;
}
项目:jannel    文件:TimedDeferredRequest.java   
/**
 * Intentional private local constructor
 * @param key the request key
 * @param request the request object
 * @param window the window
 * @param timeoutMillis the time after which this future will be cancelled
 * @param timer the timer used to implement the timeout functionality
 */
private TimedDeferredRequest(final K key,
                             final R request,
                             final Window<K, R, D> window,
                             final Timer timer,
                             final long timeoutMillis) {
    super(key, request, window);
    this.timeout = checkNotNull(timer).newTimeout(new TimerTask() {
                                                      @Override
                                                      public void run(Timeout timerTask) throws Exception {
                                                          window.fail(checkNotNull(key),
                                                                      new TimeoutException("The operation timed out (Window full)"));
                                                      }
                                                  },
                                                  timeoutMillis,
                                                  TimeUnit.MILLISECONDS);
}
项目:floodlight-hardware    文件:OFChannelHandler.java   
/**
 * Creates a handler for interacting with the switch channel
 *
 * @param controller
 *            the controller
 * @param newConnectionListener
 *            the class that listens for new OF connections (switchManager)
 * @param pipeline
 *            the channel pipeline
 * @param threadPool
 *            the thread pool
 * @param idleTimer
 *            the hash wheeled timer used to send idle messages (echo).
 *            passed to constructor to modify in case of aux connection.
 * @param debugCounters
 */
OFChannelHandler(@Nonnull IOFSwitchManager switchManager,
        @Nonnull INewOFConnectionListener newConnectionListener,
        @Nonnull ChannelPipeline pipeline,
        @Nonnull IDebugCounterService debugCounters,
        @Nonnull Timer timer,
        @Nonnull List<U32> ofBitmaps,
        @Nonnull OFFactory defaultFactory) {

    Preconditions.checkNotNull(switchManager, "switchManager");
    Preconditions.checkNotNull(newConnectionListener, "connectionOpenedListener");
    Preconditions.checkNotNull(pipeline, "pipeline");
    Preconditions.checkNotNull(timer, "timer");
    Preconditions.checkNotNull(debugCounters, "debugCounters");

    this.pipeline = pipeline;
    this.debugCounters = debugCounters;
    this.newConnectionListener = newConnectionListener;
    this.counters = switchManager.getCounters();
    this.state = new InitState();
    this.timer = timer;
    this.ofBitmaps = ofBitmaps;
    this.factory = defaultFactory;

    log.debug("constructor on OFChannelHandler {}", String.format("%08x", System.identityHashCode(this)));
}
项目:simulacron    文件:BoundNode.java   
BoundNode(
    SocketAddress address,
    NodeSpec delegate,
    Map<String, Object> peerInfo,
    BoundCluster cluster,
    BoundDataCenter parent,
    Server server,
    Timer timer,
    Channel channel,
    boolean activityLogging) {
  super(
      address,
      delegate.getName(),
      delegate.getId() != null ? delegate.getId() : 0,
      delegate.getCassandraVersion(),
      delegate.getDSEVersion(),
      peerInfo,
      parent);
  this.cluster = cluster;
  this.server = server;
  // for test purposes server may be null.
  this.bootstrap = server != null ? server.serverBootstrap : null;
  this.timer = timer;
  this.channel = new AtomicReference<>(channel);
  this.stubStore = new StubStore();
  this.activityLogging = activityLogging;
  this.frameCodec = buildFrameCodec(delegate).orElse(parent.getFrameCodec());
}
项目:simulacron    文件:ServerTest.java   
@Test
public void testTryWithResourcesShouldCloseAllResources() throws Exception {
  EventLoopGroup eventLoop;
  Timer timer;

  try (Server server = Server.builder().build()) {
    // Do nothing here, since this is a unit test, we don't want to create any inet sockets
    // which is what Server does by default.
    eventLoop = server.eventLoopGroup;
    timer = server.timer;
  }

  // event loop should have been closed since a custom one was not provided.
  assertThat(eventLoop.isShutdown()).isTrue();
  // timer should have since a custom one was not provided.
  try {
    timer.newTimeout(
        timeout -> {
          // noop
        },
        1,
        TimeUnit.SECONDS);
    fail("Expected IllegalStateException");
  } catch (IllegalStateException ise) {
    // expected
  }
}
项目:simulacron    文件:ServerTest.java   
@Test
public void testTryWithResourcesShouldCloseAllClustersButNotEventLoopAndTimerIfProvided()
    throws Exception {
  EventLoopGroup eventLoop = new DefaultEventLoopGroup();
  Timer timer = new HashedWheelTimer();
  BoundCluster cluster;
  MockClient client;

  try (Server server =
      Server.builder()
          .withAddressResolver(localAddressResolver)
          .withTimer(timer)
          .withEventLoopGroup(eventLoop, LocalServerChannel.class)
          .build()) {

    cluster = server.register(ClusterSpec.builder().withNodes(5));
    BoundNode node = cluster.node(0);
    SocketAddress address = node.getAddress();
    client = new MockClient(eventLoop);
    client.connect(address);
  }

  // event loop should not have been closed.
  assertThat(eventLoop.isShutdown()).isFalse();
  // timer should not have since a custom one was not provided.
  cluster
      .getServer()
      .timer
      .newTimeout(
          timeout -> {
            // noop
          },
          1,
          TimeUnit.SECONDS);

  eventLoop.shutdownGracefully(0, 0, TimeUnit.SECONDS);
  timer.stop();
}
项目:netty-dovakin-android-client    文件:ConnectionWatcher.java   
public ConnectionWatcher(Bootstrap bootstrap, Timer timer, String host, int port, boolean reconnect){
    this.bootstrap = bootstrap;
    this.timer = timer;
    this.host = host;
    this.port = port;
    this.reconnect = reconnect;
}
项目:fresco_floodlight    文件:HandshakeTimeoutHandler.java   
public HandshakeTimeoutHandler(RPCChannelHandler handler,
                               Timer timer,
                               long timeoutSeconds) {
    super();
    this.handler = handler;
    this.timer = timer;
    this.timeoutNanos = TimeUnit.SECONDS.toNanos(timeoutSeconds);

}
项目:fresco_floodlight    文件:RPCChannelInitializer.java   
public RPCChannelInitializer(SyncManager syncManager,
                          RPCService rpcService,
                          Timer timer) {
    super();
    this.syncManager = syncManager;
    this.rpcService = rpcService;
    this.timer = timer;
}
项目:fresco_floodlight    文件:RPCService.java   
public RPCService(SyncManager syncManager, 
                  IDebugCounterService debugCounter,
                  Timer timer) {
    super();
    this.syncManager = syncManager;
    this.debugCounter = debugCounter;
    this.timer = timer;

    messageWindows = new ConcurrentHashMap<Short, MessageWindow>();
}
项目:fresco_floodlight    文件:BootstrapTimeoutHandler.java   
public BootstrapTimeoutHandler(Timer timer,
                               long timeoutSeconds) {
    super();
    this.timer = timer;
    this.timeoutNanos = TimeUnit.SECONDS.toNanos(timeoutSeconds);

}
项目:fresco_floodlight    文件:RSHandshakeTimeoutHandler.java   
public RSHandshakeTimeoutHandler(RemoteSyncChannelHandler channelHandler,
                                 Timer timer,
                                 long timeoutSeconds) {
    super();
    this.channelHandler = channelHandler;
    this.timer = timer;
    this.timeoutNanos = TimeUnit.SECONDS.toNanos(timeoutSeconds);
}
项目:fresco_floodlight    文件:OFSwitchHandshakeHandler.java   
/**
 * Create a new unconnected OFChannelHandler.
 * @param controller
 * @param broker
 * @throws SwitchHandshakeHandlerException
 */
OFSwitchHandshakeHandler(@Nonnull IOFConnectionBackend connection,
        @Nonnull OFFeaturesReply featuresReply,
        @Nonnull IOFSwitchManager switchManager,
        @Nonnull RoleManager roleManager,
        @Nonnull Timer timer) {
    Preconditions.checkNotNull(connection, "connection");
    Preconditions.checkNotNull(featuresReply, "featuresReply");
    Preconditions.checkNotNull(switchManager, "switchManager");
    Preconditions.checkNotNull(roleManager, "roleManager");
    Preconditions.checkNotNull(timer, "timer");
    Preconditions.checkArgument(connection.getAuxId().equals(OFAuxId.MAIN),
            "connection must be MAIN connection but is %s", connection);

    this.switchManager = switchManager;
    this.roleManager = roleManager;
    this.mainConnection = connection;
    this.auxConnections = new ConcurrentHashMap<OFAuxId, IOFConnectionBackend>();
    this.featuresReply = featuresReply;
    this.timer = timer;
    this.switchManagerCounters = switchManager.getCounters();
    this.factory = OFFactories.getFactory(featuresReply.getVersion());
    this.roleChanger = new RoleChanger(DEFAULT_ROLE_TIMEOUT_NS);
    setState(new InitState());
    this.pendingPortStatusMsg = new ArrayList<OFPortStatus>();

    connection.setListener(this);
}
项目:fresco_floodlight    文件:HandshakeTimeoutHandler.java   
public HandshakeTimeoutHandler(OFChannelHandler handshakeHandler,
                               Timer timer,
                               long timeoutSeconds) {
    super();
    this.handshakeHandler = handshakeHandler;
    this.timer = timer;
    this.timeoutNanos = TimeUnit.SECONDS.toNanos(timeoutSeconds);

}
项目:fresco_floodlight    文件:OFSwitchManagerTest.java   
@Test
public void testRegisterCategory() {

    // Must be in INIT state
    Timer timer = createMock(Timer.class);
    replay(timer);
    switchManager = new OFSwitchManager();
    switchManager.loadLogicalCategories();
    assertTrue("Connections should be empty", switchManager.getNumRequiredConnections() == 0);

    // Add initial category
    switchManager = new OFSwitchManager();
    LogicalOFMessageCategory category = new LogicalOFMessageCategory("aux1", 1);
    switchManager.registerLogicalOFMessageCategory(category);
    switchManager.loadLogicalCategories();

    assertTrue("Required connections should be 1", switchManager.getNumRequiredConnections() == 1);

    // Multiple categories on the same auxId should produce one required connection
    switchManager = new OFSwitchManager();
    switchManager.registerLogicalOFMessageCategory(new LogicalOFMessageCategory("aux1", 1));
    switchManager.registerLogicalOFMessageCategory(new LogicalOFMessageCategory("aux1-2", 1));
    switchManager.loadLogicalCategories();

    assertTrue("Required connections should be 1", switchManager.getNumRequiredConnections() == 1);

    // Adding a category on a different aux ID should increase the required connection count
    switchManager = new OFSwitchManager();
    switchManager.registerLogicalOFMessageCategory(new LogicalOFMessageCategory("aux1", 1));
    switchManager.registerLogicalOFMessageCategory(new LogicalOFMessageCategory("aux2", 2));
    switchManager.loadLogicalCategories();
    assertTrue("Required connections should be 2", switchManager.getNumRequiredConnections() == 2);
}
项目:fresco_floodlight    文件:OFSwitchHandlerTestBase.java   
@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);
}
项目:SDN-Multicast    文件:HandshakeTimeoutHandler.java   
public HandshakeTimeoutHandler(RPCChannelHandler handler,
                               Timer timer,
                               long timeoutSeconds) {
    super();
    this.handler = handler;
    this.timer = timer;
    this.timeoutNanos = TimeUnit.SECONDS.toNanos(timeoutSeconds);

}
项目:SDN-Multicast    文件:RPCChannelInitializer.java   
public RPCChannelInitializer(SyncManager syncManager,
                          RPCService rpcService,
                          Timer timer) {
    super();
    this.syncManager = syncManager;
    this.rpcService = rpcService;
    this.timer = timer;
}
项目:SDN-Multicast    文件:RPCService.java   
public RPCService(SyncManager syncManager, 
                  IDebugCounterService debugCounter,
                  Timer timer) {
    super();
    this.syncManager = syncManager;
    this.debugCounter = debugCounter;
    this.timer = timer;

    messageWindows = new ConcurrentHashMap<Short, MessageWindow>();
}
项目:SDN-Multicast    文件:BootstrapTimeoutHandler.java   
public BootstrapTimeoutHandler(Timer timer,
                               long timeoutSeconds) {
    super();
    this.timer = timer;
    this.timeoutNanos = TimeUnit.SECONDS.toNanos(timeoutSeconds);

}
项目:SDN-Multicast    文件:RSHandshakeTimeoutHandler.java   
public RSHandshakeTimeoutHandler(RemoteSyncChannelHandler channelHandler,
                                 Timer timer,
                                 long timeoutSeconds) {
    super();
    this.channelHandler = channelHandler;
    this.timer = timer;
    this.timeoutNanos = TimeUnit.SECONDS.toNanos(timeoutSeconds);
}