org.jboss.netty.util.Timer Java Examples

The following examples show how to use org.jboss.netty.util.Timer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpanStatChannelFactoryProvider.java    From pinpoint with Apache License 2.0 6 votes vote down vote up
@Override
public ChannelFactory get() {
    int workerCount = 0;

    if ("TCP".equalsIgnoreCase(thriftTransportConfig.getSpanDataSenderTransportType())) {
        workerCount++;
    }
    if ("TCP".equalsIgnoreCase(thriftTransportConfig.getStatDataSenderTransportType())) {
        workerCount++;
    }

    if (workerCount == 0) {
        return null;
    } else {
        Timer timer = connectTimerProvider.get();

        final ClientChannelFactory clientChannelFactory = new ClientChannelFactory();
        return clientChannelFactory.createChannelFactory(1, workerCount, timer);
    }
}
 
Example #2
Source File: ThriftModuleLifeCycle.java    From pinpoint with Apache License 2.0 6 votes vote down vote up
@Inject
public ThriftModuleLifeCycle(
        Provider<CommandDispatcher> commandDispatcherProvider,
        @DefaultClientFactory Provider<PinpointClientFactory> clientFactoryProvider,
        @AgentDataSender Provider<EnhancedDataSender<Object>> tcpDataSenderProvider,
        @SpanStatConnectTimer Provider<Timer> spanStatConnectTimerProvider,
        @SpanStatChannelFactory Provider<ChannelFactory> spanStatChannelFactoryProvider,
        @SpanClientFactory Provider<PinpointClientFactory> spanClientFactoryProvider,
        @StatClientFactory Provider<PinpointClientFactory> statClientFactoryProvider,
        @SpanDataSender Provider<DataSender> spanDataSenderProvider,
        @StatDataSender Provider<DataSender> statDataSenderProvider
        ) {
    this.commandDispatcherProvider = Assert.requireNonNull(commandDispatcherProvider, "commandDispatcherProvider");
    this.clientFactoryProvider = Assert.requireNonNull(clientFactoryProvider, "clientFactoryProvider");
    this.tcpDataSenderProvider = Assert.requireNonNull(tcpDataSenderProvider, "tcpDataSenderProvider");

    this.spanStatConnectTimerProvider = Assert.requireNonNull(spanStatConnectTimerProvider, "spanStatConnectTimerProvider");

    this.spanStatChannelFactoryProvider = Assert.requireNonNull(spanStatChannelFactoryProvider, "spanStatChannelFactoryProvider");

    this.spanClientFactoryProvider = Assert.requireNonNull(spanClientFactoryProvider, "spanClientFactoryProvider");
    this.statClientFactoryProvider = Assert.requireNonNull(statClientFactoryProvider, "statClientFactoryProvider");

    this.spanDataSenderProvider = Assert.requireNonNull(spanDataSenderProvider, "spanDataSenderProvider");
    this.statDataSenderProvider = Assert.requireNonNull(statDataSenderProvider, "statDataSenderProvider");
}
 
Example #3
Source File: Connection.java    From pinpoint with Apache License 2.0 6 votes vote down vote up
void connect(SocketAddressProvider remoteAddressProvider, boolean reconnect, PipelineFactory pipelineFactory) {
    Assert.requireNonNull(remoteAddressProvider, "remoteAddress");

    final ChannelPipeline pipeline = pipelineFactory.newPipeline();

    Timer channelTimer = createTimer("Pinpoint-PinpointClientHandler-Timer");
    final ChannelHandler writeTimeout = new WriteTimeoutHandler(channelTimer, 3000, TimeUnit.MILLISECONDS);
    pipeline.addLast("writeTimeout", writeTimeout);

    this.pinpointClientHandler = this.clientHandlerFactory.newClientHandler(connectionFactory, remoteAddressProvider, channelTimer, reconnect);
    if (pinpointClientHandler instanceof SimpleChannelHandler) {
        pipeline.addLast("socketHandler", (SimpleChannelHandler) this.pinpointClientHandler);
    } else {
        throw new IllegalArgumentException("invalid pinpointClientHandler");
    }

    final SocketAddress remoteAddress = remoteAddressProvider.resolve();
    this.connectFuture  = connect0(remoteAddress, pipeline);
}
 
Example #4
Source File: ClientChannelFactory.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
public ChannelFactory createChannelFactory(int bossCount, int workerCount, Timer timer) {
    ExecutorService boss = newCachedThreadPool("Pinpoint-Client-Boss");
    BossPool bossPool = new NioClientBossPool(boss, bossCount, timer, ThreadNameDeterminer.CURRENT);

    ExecutorService worker = newCachedThreadPool("Pinpoint-Client-Worker");
    WorkerPool workerPool = new NioWorkerPool(worker, workerCount, ThreadNameDeterminer.CURRENT);
    return new NioClientSocketChannelFactory(bossPool, workerPool);
}
 
Example #5
Source File: ShuffleHandler.java    From tez with Apache License 2.0 5 votes vote down vote up
public HttpPipelineFactory(Configuration conf, Timer timer) throws Exception {
  SHUFFLE = getShuffle(conf);
  if (conf.getBoolean(SHUFFLE_SSL_ENABLED_KEY,
                      SHUFFLE_SSL_ENABLED_DEFAULT)) {
    LOG.info("Encrypted shuffle is enabled.");
    sslFactory = new SSLFactory(SSLFactory.Mode.SERVER, conf);
    sslFactory.init();
  }
  this.idleStateHandler = new IdleStateHandler(timer, 0, connectionKeepAliveTimeOut, 0);
}
 
Example #6
Source File: ControllerHandshakeTimeoutHandler.java    From FlowSpaceFirewall with Apache License 2.0 5 votes vote down vote up
public ControllerHandshakeTimeoutHandler(OFControllerChannelHandler channelHandler,
                               Timer timer,
                               long timeoutSeconds) {
    super();
    this.channelHandler = channelHandler;
    this.timer = timer;
    this.timeoutNanos = TimeUnit.SECONDS.toNanos(timeoutSeconds);

}
 
Example #7
Source File: TcpDataSender.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
private Timer createTimer(String name) {
    final String timerName = getTimerName(name);

    HashedWheelTimer timer = TimerFactory.createHashedWheelTimer(timerName, 100, TimeUnit.MILLISECONDS, 512);
    timer.start();
    return timer;
}
 
Example #8
Source File: SpanStatConnectTimerProvider.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
@Override
public Timer get() {
    if ("TCP".equalsIgnoreCase(thriftTransportConfig.getSpanDataSenderTransportType()) || "TCP".equalsIgnoreCase(thriftTransportConfig.getStatDataSenderTransportType())) {
        return createTimer("Pinpoint-SpanStatConnect-Timer");
    }
    return null;
}
 
Example #9
Source File: HealthCheckManager.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
public HealthCheckManager(Timer timer, long waitTimeMillis, ChannelGroup channelGroup) {
    Assert.requireNonNull(timer, "timer");
    Assert.isTrue(waitTimeMillis > 0, "waitTimeMillis is must greater than 0");
    Assert.requireNonNull(channelGroup, "channelGroup");

    this.timer = timer;
    this.waitTimeMillis = waitTimeMillis;

    this.channelGroup = channelGroup;
}
 
Example #10
Source File: DefaultPinpointClientFactory.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
public DefaultPinpointClientFactory(ChannelFactory channelFactory, Timer timer, ConnectionFactoryProvider connectionFactoryProvider) {
    this.channelFactory = Assert.requireNonNull(channelFactory, "channelFactory");
    this.timer = Assert.requireNonNull(timer, "timer");

    this.useExternalResource = true;
    this.socketOptionBuilder = new SocketOption.Builder();
    this.connectionFactoryProvider = Assert.requireNonNull(connectionFactoryProvider, "connectionFactoryProvider");
}
 
Example #11
Source File: PinpointClientHandshaker.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
public PinpointClientHandshaker(Map<String, Object> handshakeData, Timer handshakerTimer, long retryInterval, int maxHandshakeCount) {
    Assert.isTrue(retryInterval > 0, "retryInterval must greater than zero.");
    Assert.isTrue(maxHandshakeCount > 0, "maxHandshakeCount must greater than zero.");
    
    this.state = new AtomicInteger(STATE_INIT);
    this.handshakerTimer = Assert.requireNonNull(handshakerTimer, "handshakerTimer");
    this.handshakeData = Assert.requireNonNull(handshakeData, "handshakeData");

    this.retryInterval = retryInterval;
    this.maxHandshakeCount = maxHandshakeCount;

    this.handshakeCount = new AtomicInteger(0);
}
 
Example #12
Source File: NettyDispatcher.java    From ikasoa with MIT License 5 votes vote down vote up
public NettyDispatcher(NettyServerConfiguration configuration, Timer timer) {
	this.processorFactory = configuration.getProcessorFactory();
	this.protocolFactory = configuration.getProtocolFactory();
	this.queuedResponseLimit = configuration.getQueuedResponseLimit();
	this.taskTimeoutMillis = 0;
	this.taskTimeoutTimer = timer;
	this.queueTimeoutMillis = 0;
}
 
Example #13
Source File: DefaultPinpointClientHandlerFactory.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
@Override
public PinpointClientHandler newClientHandler(ConnectionFactory connectionFactory, SocketAddressProvider remoteAddressProvider, Timer channelTimer, boolean reconnect) {
    PinpointClientHandshaker handshaker = handshakerFactory.newHandShaker(channelTimer);
    final DefaultPinpointClientHandler clientHandler = new DefaultPinpointClientHandler(connectionFactory, remoteAddressProvider, handshaker,
            clusterOption, clientOption, channelTimer,
            messageListener,
            serverStreamChannelMessageHandler,
            stateChangeEventListeners
    );

    if (reconnect) {
        clientHandler.initReconnect();
    }
    return clientHandler;
}
 
Example #14
Source File: ConnectionFactory.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
ConnectionFactory(Timer connectTimer, Closed closed, ChannelFactory channelFactory,
                         SocketOption socketOption, ClientOption clientOption, ClientHandlerFactory clientHandlerFactory, PipelineFactory pipelineFactory) {

    this.connectTimer = Assert.requireNonNull(connectTimer, "connectTimer");
    this.closed = Assert.requireNonNull(closed, "release");

    this.channelFactory = Assert.requireNonNull(channelFactory, "channelFactory");

    this.socketOption = Assert.requireNonNull(socketOption, "option");
    this.clientOption = Assert.requireNonNull(clientOption, "connectTimer");
    this.clientHandlerFactory = Assert.requireNonNull(clientHandlerFactory, "clientHandlerFactory");
    this.pipelineFactory = Assert.requireNonNull(pipelineFactory, "pipelineFactory");
}
 
Example #15
Source File: RequestManager.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
public RequestManager(Timer timer, long defaultTimeoutMillis) {
    if (timer == null) {
        throw new NullPointerException("timer");
    }
    
    if (defaultTimeoutMillis <= 0) {
        throw new IllegalArgumentException("defaultTimeoutMillis must greater than zero.");
    }
    
    this.timer = timer;
    this.defaultTimeoutMillis = defaultTimeoutMillis;
}
 
Example #16
Source File: DefaultPinpointClientHandler.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
public DefaultPinpointClientHandler(ConnectionFactory connectionFactory, SocketAddressProvider socketAddressProvider, PinpointClientHandshaker handshaker,
                                    ClusterOption localClusterOption, ClientOption clientOption,
                                    Timer channelTimer,
                                    MessageListener messageListener,
                                    ServerStreamChannelMessageHandler serverStreamChannelMessageHandler,
                                    List<StateChangeEventListener> stateChangeEventListeners) {

    this.connectionFactory = Assert.requireNonNull(connectionFactory, "clientFactory");
    this.socketAddressProvider = Assert.requireNonNull(socketAddressProvider, "socketAddressProvider");

    this.channelTimer = Assert.requireNonNull(channelTimer, "channelTimer");
    this.requestManager = new RequestManager(channelTimer, clientOption.getRequestTimeoutMillis());
    this.clientOption = Assert.requireNonNull(clientOption, "clientOption");


    this.messageListener = Assert.requireNonNull(messageListener, "messageListener");
    this.serverStreamChannelMessageHandler = Assert.requireNonNull(serverStreamChannelMessageHandler, "serverStreamChannelMessageHandler");

    this.objectUniqName = ClassUtils.simpleClassNameAndHashCodeString(this);
    this.handshaker = Assert.requireNonNull(handshaker, "handshaker");

    this.pingIdGenerator = new AtomicInteger(0);
    this.state = new PinpointClientHandlerState(this.objectUniqName, this, stateChangeEventListeners);

    this.localClusterOption = Assert.requireNonNull(localClusterOption, "clusterOption");

}
 
Example #17
Source File: HandshakeTimeoutHandler.java    From floodlight_with_topoguard with Apache License 2.0 5 votes vote down vote up
public HandshakeTimeoutHandler(RPCChannelHandler handler,
                               Timer timer,
                               long timeoutSeconds) {
    super();
    this.handler = handler;
    this.timer = timer;
    this.timeoutNanos = TimeUnit.SECONDS.toNanos(timeoutSeconds);

}
 
Example #18
Source File: BootstrapTimeoutHandler.java    From floodlight_with_topoguard with Apache License 2.0 5 votes vote down vote up
public BootstrapTimeoutHandler(Timer timer,
                               long timeoutSeconds) {
    super();
    this.timer = timer;
    this.timeoutNanos = TimeUnit.SECONDS.toNanos(timeoutSeconds);

}
 
Example #19
Source File: RSHandshakeTimeoutHandler.java    From floodlight_with_topoguard with Apache License 2.0 5 votes vote down vote up
public RSHandshakeTimeoutHandler(RemoteSyncChannelHandler channelHandler,
                                 Timer timer,
                                 long timeoutSeconds) {
    super();
    this.channelHandler = channelHandler;
    this.timer = timer;
    this.timeoutNanos = TimeUnit.SECONDS.toNanos(timeoutSeconds);
}
 
Example #20
Source File: HandshakeTimeoutHandler.java    From floodlight_with_topoguard with Apache License 2.0 5 votes vote down vote up
public HandshakeTimeoutHandler(OFChannelHandler channelHandler,
                               Timer timer,
                               long timeoutSeconds) {
    super();
    this.channelHandler = channelHandler;
    this.timer = timer;
    this.timeoutNanos = TimeUnit.SECONDS.toNanos(timeoutSeconds);

}
 
Example #21
Source File: FlinkServerRegister.java    From pinpoint with Apache License 2.0 4 votes vote down vote up
private Timer createTimer() {
    HashedWheelTimer timer = TimerFactory.createHashedWheelTimer("Pinpoint-Flink-Cluster-Timer", 100, TimeUnit.MILLISECONDS, 512);
    timer.start();
    return timer;
}
 
Example #22
Source File: NettySend.java    From jlogstash-input-plugin with Apache License 2.0 4 votes vote down vote up
public NettyClientHandler(NettyClient client, Timer timer){
	this.client = client;
	this.timer = timer;
}
 
Example #23
Source File: CommonsConnectionPool.java    From zuul-netty with Apache License 2.0 4 votes vote down vote up
public CommonsConnectionPool(Timer timer, ChannelFactory channelFactory) {
    this.channelFactory = channelFactory;
    this.timer = timer;
}
 
Example #24
Source File: HttpOutboundPipeline.java    From zuul-netty with Apache License 2.0 4 votes vote down vote up
public HttpOutboundPipeline (Timer timer) {
    IDLE_STATE_HANDLER = new IdleStateHandler(timer, IDLE_TIMEOUT_READER, IDLE_TIMEOUT_WRITER, IDLE_TIMEOUT_BOTH);
}
 
Example #25
Source File: CommonHttpPipeline.java    From zuul-netty with Apache License 2.0 4 votes vote down vote up
public CommonHttpPipeline(Timer timer) {
    this.idleStateHandler = new IdleStateHandler(timer, IDLE_TIMEOUT_READER, IDLE_TIMEOUT_WRITER, IDLE_TIMEOUT_BOTH);
    this.outboundConnectionPool = new CommonsConnectionPool(timer, OUTBOUND_CHANNEL_FACTORY);
}
 
Example #26
Source File: NioClientBoss.java    From android-netty with Apache License 2.0 4 votes vote down vote up
NioClientBoss(Executor bossExecutor, Timer timer, ThreadNameDeterminer determiner) {
    super(bossExecutor, determiner);
    this.timer = timer;
}
 
Example #27
Source File: SpanClientFactoryProvider.java    From pinpoint with Apache License 2.0 4 votes vote down vote up
@Inject
public SpanClientFactoryProvider(ThriftTransportConfig thriftTransportConfig, @SpanStatChannelFactory Provider<ChannelFactory> channelFactoryProvider, @SpanStatConnectTimer Provider<Timer> spanStatConnectTimer) {
    this.thriftTransportConfig = Assert.requireNonNull(thriftTransportConfig, "thriftTransportConfig");
    this.channelFactoryProvider = Assert.requireNonNull(channelFactoryProvider, "channelFactoryProvider");
    this.spanStatConnectTimer = Assert.requireNonNull(spanStatConnectTimer, "spanStatConnectTimer");
}
 
Example #28
Source File: SpanStatConnectTimerProvider.java    From pinpoint with Apache License 2.0 4 votes vote down vote up
private static Timer createTimer(String timerName) {
    HashedWheelTimer timer = TimerFactory.createHashedWheelTimer(timerName, 100, TimeUnit.MILLISECONDS, 512);
    timer.start();
    return timer;
}
 
Example #29
Source File: SpanStatChannelFactoryProvider.java    From pinpoint with Apache License 2.0 4 votes vote down vote up
@Inject
public SpanStatChannelFactoryProvider(ThriftTransportConfig thriftTransportConfig, @SpanStatConnectTimer Provider<Timer> connectTimerProvider) {
    this.thriftTransportConfig = Assert.requireNonNull(thriftTransportConfig, "thriftTransportConfig");
    this.connectTimerProvider = Assert.requireNonNull(connectTimerProvider, "connectTimerProvider");
}
 
Example #30
Source File: StatClientFactoryProvider.java    From pinpoint with Apache License 2.0 4 votes vote down vote up
@Inject
public StatClientFactoryProvider(ThriftTransportConfig thriftTransportConfig, @SpanStatChannelFactory Provider<ChannelFactory> channelFactoryProvider, @SpanStatConnectTimer Provider<Timer> connectTimerProvider) {
    this.thriftTransportConfig = Assert.requireNonNull(thriftTransportConfig, "thriftTransportConfig");
    this.channelFactoryProvider = Assert.requireNonNull(channelFactoryProvider, "channelFactoryProvider");
    this.connectTimerProvider = Assert.requireNonNull(connectTimerProvider, "connectTimerProvider");
}