org.jboss.netty.util.HashedWheelTimer Java Examples

The following examples show how to use org.jboss.netty.util.HashedWheelTimer. 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: BookKeeperClient.java    From distributedlog with Apache License 2.0 6 votes vote down vote up
BookKeeperClient(DistributedLogConfiguration conf,
                 String name,
                 String zkServers,
                 ZooKeeperClient zkc,
                 String ledgersPath,
                 ClientSocketChannelFactory channelFactory,
                 HashedWheelTimer requestTimer,
                 StatsLogger statsLogger,
                 Optional<FeatureProvider> featureProvider) {
    this.conf = conf;
    this.name = name;
    this.zkServers = zkServers;
    this.ledgersPath = ledgersPath;
    this.passwd = conf.getBKDigestPW().getBytes(UTF_8);
    this.channelFactory = channelFactory;
    this.requestTimer = requestTimer;
    this.statsLogger = statsLogger;
    this.featureProvider = featureProvider;
    this.ownZK = null == zkc;
    if (null != zkc) {
        // reference the passing zookeeper client
        this.zkc = zkc;
    }
}
 
Example #2
Source File: StreamFactoryImpl.java    From distributedlog with Apache License 2.0 6 votes vote down vote up
public StreamFactoryImpl(String clientId,
    StreamOpStats streamOpStats,
    ServerConfiguration serverConfig,
    DistributedLogConfiguration dlConfig,
    FeatureProvider featureProvider,
    StreamConfigProvider streamConfigProvider,
    StreamPartitionConverter streamPartitionConverter,
    DistributedLogNamespace dlNamespace,
    OrderedScheduler scheduler,
    FatalErrorHandler fatalErrorHandler,
    HashedWheelTimer requestTimer) {

    this.clientId = clientId;
    this.streamOpStats = streamOpStats;
    this.serverConfig = serverConfig;
    this.dlConfig = dlConfig;
    this.featureProvider = featureProvider;
    this.streamConfigProvider = streamConfigProvider;
    this.streamPartitionConverter = streamPartitionConverter;
    this.dlNamespace = dlNamespace;
    this.scheduler = scheduler;
    this.fatalErrorHandler = fatalErrorHandler;
    this.requestTimer = requestTimer;
}
 
Example #3
Source File: StreamFactoryImpl.java    From distributedlog with Apache License 2.0 6 votes vote down vote up
public StreamFactoryImpl(String clientId,
    StreamOpStats streamOpStats,
    ServerConfiguration serverConfig,
    DistributedLogConfiguration dlConfig,
    FeatureProvider featureProvider,
    StreamConfigProvider streamConfigProvider,
    StreamPartitionConverter streamPartitionConverter,
    Namespace dlNamespace,
    OrderedScheduler scheduler,
    FatalErrorHandler fatalErrorHandler,
    HashedWheelTimer requestTimer) {

    this.clientId = clientId;
    this.streamOpStats = streamOpStats;
    this.serverConfig = serverConfig;
    this.dlConfig = dlConfig;
    this.featureProvider = featureProvider;
    this.streamConfigProvider = streamConfigProvider;
    this.streamPartitionConverter = streamPartitionConverter;
    this.dlNamespace = dlNamespace;
    this.scheduler = scheduler;
    this.fatalErrorHandler = fatalErrorHandler;
    this.requestTimer = requestTimer;
    this.futureTimer = new com.twitter.finagle.util.HashedWheelTimer(requestTimer);
}
 
Example #4
Source File: SMTPServerTest.java    From james-project with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {

    domainList = new MemoryDomainList(new InMemoryDNSService()
        .registerMxRecord(Domain.LOCALHOST.asString(), "127.0.0.1")
        .registerMxRecord(LOCAL_DOMAIN, "127.0.0.1")
        .registerMxRecord("examplebis.local", "127.0.0.1")
        .registerMxRecord("127.0.0.1", "127.0.0.1"));
    domainList.setAutoDetect(false);
    domainList.setAutoDetectIP(false);

    domainList.addDomain(Domain.LOCALHOST);
    domainList.addDomain(Domain.of(LOCAL_DOMAIN));
    domainList.addDomain(Domain.of("examplebis.local"));
    usersRepository = MemoryUsersRepository.withVirtualHosting(domainList);

    createMailRepositoryStore();

    setUpFakeLoader();
    // slf4j can't set programmatically any log level. It's just a facade
    // log.setLevel(SimpleLog.LOG_LEVEL_ALL);
    smtpConfiguration = new SMTPTestConfiguration();
    hashedWheelTimer = new HashedWheelTimer();
    setUpSMTPServer();
}
 
Example #5
Source File: RpcChannelFactory.java    From incubator-tajo with Apache License 2.0 6 votes vote down vote up
public static synchronized ClientSocketChannelFactory createClientChannelFactory(String name, int workerNum) {
  name = name + "-" + clientCount.incrementAndGet();
  if(LOG.isDebugEnabled()){
    LOG.debug("Create " + name + " ClientSocketChannelFactory. Worker:" + workerNum);
  }

  ThreadFactoryBuilder builder = new ThreadFactoryBuilder();
  ThreadFactory bossFactory = builder.setNameFormat(name + " Boss #%d").build();
  ThreadFactory workerFactory = builder.setNameFormat(name + " Worker #%d").build();

  NioClientBossPool bossPool = new NioClientBossPool(Executors.newCachedThreadPool(bossFactory), 1,
      new HashedWheelTimer(), ThreadNameDeterminer.CURRENT);
  NioWorkerPool workerPool = new NioWorkerPool(Executors.newCachedThreadPool(workerFactory), workerNum,
      ThreadNameDeterminer.CURRENT);

  return new NioClientSocketChannelFactory(bossPool, workerPool);
}
 
Example #6
Source File: TestProxyClientManager.java    From distributedlog with Apache License 2.0 5 votes vote down vote up
private static ProxyClientManager createProxyClientManager(ProxyClient.Builder builder,
                                                           HostProvider hostProvider,
                                                           long periodicHandshakeIntervalMs) {
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setPeriodicHandshakeIntervalMs(periodicHandshakeIntervalMs);
    clientConfig.setPeriodicOwnershipSyncIntervalMs(-1);
    HashedWheelTimer dlTimer = new HashedWheelTimer(
            new ThreadFactoryBuilder().setNameFormat("TestProxyClientManager-timer-%d").build(),
            clientConfig.getRedirectBackoffStartMs(),
            TimeUnit.MILLISECONDS);
    return new ProxyClientManager(clientConfig, builder, dlTimer, hostProvider,
            new ClientStats(NullStatsReceiver.get(), false, new DefaultRegionResolver()));
}
 
Example #7
Source File: AbstractSSLAwareChannelPipelineFactory.java    From james-project with Apache License 2.0 5 votes vote down vote up
public AbstractSSLAwareChannelPipelineFactory(int timeout,
        int maxConnections, int maxConnectsPerIp, ChannelGroup group, String[] enabledCipherSuites, ExecutionHandler eHandler,
        ChannelHandlerFactory frameHandlerFactory, HashedWheelTimer hashedWheelTimer) {
    this(timeout, maxConnections, maxConnectsPerIp, group, eHandler, frameHandlerFactory, hashedWheelTimer);
    
    // We need to copy the String array because of possible security issues.
    // See https://issues.apache.org/jira/browse/PROTOCOLS-18
    this.enabledCipherSuites = ArrayUtils.clone(enabledCipherSuites);
}
 
Example #8
Source File: OpenflowPipelineFactory.java    From floodlight_with_topoguard with Apache License 2.0 5 votes vote down vote up
public OpenflowPipelineFactory(Controller controller,
                               ThreadPoolExecutor pipelineExecutor) {
    super();
    this.controller = controller;
    this.pipelineExecutor = pipelineExecutor;
    this.timer = new HashedWheelTimer();
    this.idleHandler = new IdleStateHandler(timer, 20, 25, 0);
    this.readTimeoutHandler = new ReadTimeoutHandler(timer, 30);
}
 
Example #9
Source File: RPCPipelineFactory.java    From floodlight_with_topoguard with Apache License 2.0 5 votes vote down vote up
public RPCPipelineFactory(SyncManager syncManager,
                          RPCService rpcService) {
    super();
    this.syncManager = syncManager;
    this.rpcService = rpcService;

    this.timer = new HashedWheelTimer();
}
 
Example #10
Source File: NettyAsyncHttpProvider.java    From ck with Apache License 2.0 5 votes vote down vote up
public NettyAsyncHttpProvider(AsyncHttpClientConfig config) {
	super(new HashedWheelTimer(), 0, 0, config.getIdleConnectionTimeoutInMs(), TimeUnit.MILLISECONDS) ;
	socketChannelFactory = new NioClientSocketChannelFactory(
			Executors.newCachedThreadPool(),
			config.executorService());
	bootstrap = new ClientBootstrap(socketChannelFactory);
	this.config = config;
}
 
Example #11
Source File: POP3ServerTest.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    hashedWheelTimer = new HashedWheelTimer();
    setUpServiceManager();
    setUpPOP3Server();
    pop3Configuration = new POP3TestConfiguration();
}
 
Example #12
Source File: ConsistentHashRoutingService.java    From distributedlog with Apache License 2.0 5 votes vote down vote up
ConsistentHashRoutingService(ServerSetWatcher serverSetWatcher,
                             int numReplicas,
                             int blackoutSeconds,
                             StatsReceiver statsReceiver) {
    super(serverSetWatcher);
    this.circle = new ConsistentHash(hashFunction, numReplicas, statsReceiver.scope("ring"));
    this.hashedWheelTimer = new HashedWheelTimer(new ThreadFactoryBuilder()
            .setNameFormat("ConsistentHashRoutingService-Timer-%d").build());
    this.blackoutSeconds = blackoutSeconds;
    // stats
    this.statsReceiver = statsReceiver;
    this.numBlackoutHosts = new AtomicInteger(0);
    this.numBlackoutHostsGauge = this.statsReceiver.addGauge(gaugeName("num_blackout_hosts"),
            new Function0<Object>() {
                @Override
                public Object apply() {
                    return (float) numBlackoutHosts.get();
                }
            });
    this.numHostsGauge = this.statsReceiver.addGauge(gaugeName("num_hosts"),
            new Function0<Object>() {
                @Override
                public Object apply() {
                    return (float) address2ShardId.size();
                }
            });
}
 
Example #13
Source File: ProxyClientManager.java    From distributedlog with Apache License 2.0 5 votes vote down vote up
public ProxyClientManager(ClientConfig clientConfig,
                          ProxyClient.Builder clientBuilder,
                          HashedWheelTimer timer,
                          HostProvider hostProvider,
                          ClientStats clientStats) {
    this.clientConfig = clientConfig;
    this.clientBuilder = clientBuilder;
    this.timer = timer;
    this.hostProvider = hostProvider;
    this.handshakeStats = clientStats.getOpStats("handshake");
    scheduleHandshake();
    this.lastOwnershipSyncStopwatch = Stopwatch.createStarted();
}
 
Example #14
Source File: ConsistentHashRoutingService.java    From distributedlog with Apache License 2.0 5 votes vote down vote up
ConsistentHashRoutingService(ServerSetWatcher serverSetWatcher,
                             int numReplicas,
                             int blackoutSeconds,
                             StatsReceiver statsReceiver) {
    super(serverSetWatcher);
    this.circle = new ConsistentHash(hashFunction, numReplicas, statsReceiver.scope("ring"));
    this.hashedWheelTimer = new HashedWheelTimer(new ThreadFactoryBuilder()
            .setNameFormat("ConsistentHashRoutingService-Timer-%d").build());
    this.blackoutSeconds = blackoutSeconds;
    // stats
    this.statsReceiver = statsReceiver;
    this.numBlackoutHosts = new AtomicInteger(0);
    this.numBlackoutHostsGauge = this.statsReceiver.addGauge(gaugeName("num_blackout_hosts"),
            new Function0<Object>() {
                @Override
                public Object apply() {
                    return (float) numBlackoutHosts.get();
                }
            });
    this.numHostsGauge = this.statsReceiver.addGauge(gaugeName("num_hosts"),
            new Function0<Object>() {
                @Override
                public Object apply() {
                    return (float) address2ShardId.size();
                }
            });
}
 
Example #15
Source File: OwnershipCache.java    From distributedlog with Apache License 2.0 5 votes vote down vote up
public OwnershipCache(ClientConfig clientConfig,
                      HashedWheelTimer timer,
                      StatsReceiver statsReceiver,
                      StatsReceiver streamStatsReceiver) {
    this.clientConfig = clientConfig;
    this.timer = timer;
    this.ownershipStatsLogger = new OwnershipStatsLogger(statsReceiver, streamStatsReceiver);
    scheduleDumpOwnershipCache();
}
 
Example #16
Source File: ProxyClientManager.java    From distributedlog with Apache License 2.0 5 votes vote down vote up
public ProxyClientManager(ClientConfig clientConfig,
                          ProxyClient.Builder clientBuilder,
                          HashedWheelTimer timer,
                          HostProvider hostProvider,
                          ClientStats clientStats) {
    this.clientConfig = clientConfig;
    this.clientBuilder = clientBuilder;
    this.timer = timer;
    this.hostProvider = hostProvider;
    this.handshakeStats = clientStats.getOpStats("handshake");
    scheduleHandshake();
    this.lastOwnershipSyncStopwatch = Stopwatch.createStarted();
}
 
Example #17
Source File: OwnershipCache.java    From distributedlog with Apache License 2.0 5 votes vote down vote up
public OwnershipCache(ClientConfig clientConfig,
                      HashedWheelTimer timer,
                      StatsReceiver statsReceiver,
                      StatsReceiver streamStatsReceiver) {
    this.clientConfig = clientConfig;
    this.timer = timer;
    this.ownershipStatsLogger = new OwnershipStatsLogger(statsReceiver, streamStatsReceiver);
    scheduleDumpOwnershipCache();
}
 
Example #18
Source File: AbstractChannelPipelineFactory.java    From james-project with Apache License 2.0 5 votes vote down vote up
public AbstractChannelPipelineFactory(int timeout, int maxConnections, int maxConnectsPerIp, ChannelGroup channels,
                                      ExecutionHandler eHandler, ChannelHandlerFactory frameHandlerFactory,
                                      HashedWheelTimer hashedWheelTimer) {
    this.connectionLimitHandler = new ConnectionLimitUpstreamHandler(maxConnections);
    this.connectionPerIpLimitHandler = new ConnectionPerIpLimitUpstreamHandler(maxConnectsPerIp);
    this.groupHandler = new ChannelGroupHandler(channels);
    this.timeout = timeout;
    this.eHandler = eHandler;
    this.frameHandlerFactory = frameHandlerFactory;
    this.timer = hashedWheelTimer;
}
 
Example #19
Source File: Portmap.java    From hadoop with Apache License 2.0 5 votes vote down vote up
void start(final int idleTimeMilliSeconds, final SocketAddress tcpAddress,
    final SocketAddress udpAddress) {

  tcpServer = new ServerBootstrap(new NioServerSocketChannelFactory(
      Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));
  tcpServer.setPipelineFactory(new ChannelPipelineFactory() {
    private final HashedWheelTimer timer = new HashedWheelTimer();
    private final IdleStateHandler idleStateHandler = new IdleStateHandler(
        timer, 0, 0, idleTimeMilliSeconds, TimeUnit.MILLISECONDS);

    @Override
    public ChannelPipeline getPipeline() throws Exception {
      return Channels.pipeline(RpcUtil.constructRpcFrameDecoder(),
          RpcUtil.STAGE_RPC_MESSAGE_PARSER, idleStateHandler, handler,
          RpcUtil.STAGE_RPC_TCP_RESPONSE);
    }
  });

  udpServer = new ConnectionlessBootstrap(new NioDatagramChannelFactory(
      Executors.newCachedThreadPool()));

  udpServer.setPipeline(Channels.pipeline(RpcUtil.STAGE_RPC_MESSAGE_PARSER,
      handler, RpcUtil.STAGE_RPC_UDP_RESPONSE));

  tcpChannel = tcpServer.bind(tcpAddress);
  udpChannel = udpServer.bind(udpAddress);
  allChannels.add(tcpChannel);
  allChannels.add(udpChannel);

  LOG.info("Portmap server started at tcp://" + tcpChannel.getLocalAddress()
      + ", udp://" + udpChannel.getLocalAddress());
}
 
Example #20
Source File: IMAPServerFactory.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Inject
public IMAPServerFactory(FileSystem fileSystem, ImapDecoder decoder, ImapEncoder encoder, ImapProcessor processor,
                         MetricFactory metricFactory, HashedWheelTimer hashedWheelTimer) {
    this.fileSystem = fileSystem;
    this.decoder = decoder;
    this.encoder = encoder;
    this.processor = processor;
    this.imapMetrics = new ImapMetrics(metricFactory);
    this.hashedWheelTimer = hashedWheelTimer;
}
 
Example #21
Source File: LMTPServerFactory.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Inject
public LMTPServerFactory(ProtocolHandlerLoader loader, FileSystem fileSystem, MetricFactory metricFactory,
                         HashedWheelTimer hashedWheelTimer) {
    this.loader = loader;
    this.fileSystem = fileSystem;
    this.lmtpMetrics = new LMTPMetricsImpl(metricFactory);
    this.hashedWheelTimer = hashedWheelTimer;
}
 
Example #22
Source File: SMTPServerFactory.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Inject
public SMTPServerFactory(DNSService dns, ProtocolHandlerLoader loader, FileSystem fileSystem,
                         MetricFactory metricFactory, HashedWheelTimer hashedWheelTimer) {
    this.dns = dns;
    this.loader = loader;
    this.fileSystem = fileSystem;
    this.smtpMetrics = new SmtpMetricsImpl(metricFactory);
    this.hashedWheelTimer = hashedWheelTimer;
}
 
Example #23
Source File: HashedWheelTimerTaskScheduler.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
/**
 * Instantiates a new instance of {@link HashedWheelTimerTask}.
 *
 * @param timer the {@link HashedWheelTimer} that the {@link HashedWheelTimerTask} is associated to.
 * @param task the {@link ScheduledTask} to run.
 * @param period the period between successive executions of the task
 * @param unit the time unit of the period parameter
 */
HashedWheelTimerTask(HashedWheelTimer timer, T2 task, long period, TimeUnit unit) {
  super(task);
  this.timer = timer;
  this.task = task;
  this.period = period;
  this.unit = unit;
  this.context = MDC.getCopyOfContextMap();
  this.future = this.timer.newTimeout(this, this.period, this.unit);
}
 
Example #24
Source File: HttpClient.java    From ob1k with Apache License 2.0 5 votes vote down vote up
private static NettyAsyncHttpProviderConfig createConfig() {

      final NettyAsyncHttpProviderConfig nettyConfig = new NettyAsyncHttpProviderConfig();
      final NioClientSocketChannelFactory channelFactory = new NioClientSocketChannelFactory();

      nettyConfig.setSocketChannelFactory(channelFactory);
      nettyConfig.setChunkedFileChunkSize(CHUNKED_FILE_CHUNK_SIZE);

      final HashedWheelTimer timer = new HashedWheelTimer();
      timer.start();
      nettyConfig.setNettyTimer(timer);

      registerShutdownHook(channelFactory, timer);
      return nettyConfig;
    }
 
Example #25
Source File: HttpClient.java    From ob1k with Apache License 2.0 5 votes vote down vote up
private static void registerShutdownHook(final NioClientSocketChannelFactory channelFactory,
                                         final HashedWheelTimer hashedWheelTimer) {

  Runtime.getRuntime().addShutdownHook(new Thread() {
    @Override
    public void run() {
      channelFactory.shutdown();
      channelFactory.releaseExternalResources();
      hashedWheelTimer.stop();
    }
  });
}
 
Example #26
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 #27
Source File: ControllerConnector.java    From FlowSpaceFirewall with Apache License 2.0 5 votes vote down vote up
public ControllerConnector(){
	proxies = new HashMap<Long, List<Proxy>>();

	channelCreator = new NioClientSocketChannelFactory(
               Executors.newCachedThreadPool(),
               Executors.newCachedThreadPool(), workerThreads);
	timer = new HashedWheelTimer();
	
}
 
Example #28
Source File: FpmManager.java    From onos with Apache License 2.0 5 votes vote down vote up
private void startServer() {
    HashedWheelTimer timer = new HashedWheelTimer(
            groupedThreads("onos/fpm", "fpm-timer-%d", log));

    ChannelFactory channelFactory = new NioServerSocketChannelFactory(
            newCachedThreadPool(groupedThreads("onos/fpm", "sm-boss-%d", log)),
            newCachedThreadPool(groupedThreads("onos/fpm", "sm-worker-%d", log)));
    ChannelPipelineFactory pipelineFactory = () -> {
        // Allocate a new session per connection
        IdleStateHandler idleHandler =
                new IdleStateHandler(timer, IDLE_TIMEOUT_SECS, 0, 0);
        FpmSessionHandler fpmSessionHandler =
                new FpmSessionHandler(this, new InternalFpmListener());
        FpmFrameDecoder fpmFrameDecoder = new FpmFrameDecoder();

        // Setup the processing pipeline
        ChannelPipeline pipeline = Channels.pipeline();
        pipeline.addLast("FpmFrameDecoder", fpmFrameDecoder);
        pipeline.addLast("idle", idleHandler);
        pipeline.addLast("FpmSession", fpmSessionHandler);
        return pipeline;
    };

    InetSocketAddress listenAddress = new InetSocketAddress(FPM_PORT);

    serverBootstrap = new ServerBootstrap(channelFactory);
    serverBootstrap.setOption("child.reuseAddr", true);
    serverBootstrap.setOption("child.keepAlive", true);
    serverBootstrap.setOption("child.tcpNoDelay", true);
    serverBootstrap.setPipelineFactory(pipelineFactory);
    try {
        serverChannel = serverBootstrap.bind(listenAddress);
        allChannels.add(serverChannel);
    } catch (ChannelException e) {
        log.debug("Exception binding to FPM port {}: ",
                listenAddress.getPort(), e);
        stopServer();
    }
}
 
Example #29
Source File: TimestampClient.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
public TimestampClient(int timeoutMillis,TimestampHostProvider timestampHostProvider) {
    this.timeoutMillis = timeoutMillis;
    this.timestampHostProvider = timestampHostProvider;
    clientCallbacks = new ConcurrentHashMap<>();
    
    ExecutorService workerExecutor = Executors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("timestampClient-worker-%d").setDaemon(true).build());
    ExecutorService bossExecutor = Executors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("timestampClient-boss-%d").setDaemon(true).build());

    HashedWheelTimer hwt = new HashedWheelTimer(new ThreadFactoryBuilder().setNameFormat("timestampClient-hashedWheelTimer-%d").setDaemon(true).build());
    factory = new NioClientSocketChannelFactory(bossExecutor, NETTY_BOSS_THREAD_COUNT, new NioWorkerPool(workerExecutor, NETTY_WORKER_THREAD_COUNT), hwt);

    bootstrap = new ClientBootstrap(factory);

    // If we end up needing to use one of the memory aware executors,
    // do so with code like this (leave commented out for reference).
    //
    // bootstrap.getPipeline().addLast("executor", new ExecutionHandler(
    // 	   new OrderedMemoryAwareThreadPoolExecutor(10 /* threads */, 1024*1024, 4*1024*1024)));

    bootstrap.getPipeline().addLast("decoder", new FixedLengthFrameDecoder(FIXED_MSG_RECEIVED_LENGTH));
    bootstrap.getPipeline().addLast("handler", this);

    bootstrap.setOption("tcpNoDelay", true);
    bootstrap.setOption("keepAlive", true);
    bootstrap.setOption("reuseAddress", true);
    // bootstrap.setOption("connectTimeoutMillis", 120000);

    // Would be nice to try connecting here, but not sure if this works right. connectIfNeeded();

    try {
        registerJMX();
    } catch (Exception e) {
        SpliceLogUtils.error(LOG, "Unable to register TimestampClient with JMX. Timestamps will still be generated but metrics will not be available.");
    }
}
 
Example #30
Source File: ShuffleHandler.java    From tez with Apache License 2.0 5 votes vote down vote up
@Override
protected void serviceStart() throws Exception {
  Configuration conf = getConfig();
  userRsrc = new ConcurrentHashMap<String,String>();
  secretManager = new JobTokenSecretManager();
  recoverState(conf);
  ServerBootstrap bootstrap = new ServerBootstrap(selector);
  // Timer is shared across entire factory and must be released separately
  timer = new HashedWheelTimer();
  try {
    pipelineFact = new HttpPipelineFactory(conf, timer);
  } catch (Exception ex) {
    throw new RuntimeException(ex);
  }
  bootstrap.setOption("backlog", conf.getInt(SHUFFLE_LISTEN_QUEUE_SIZE,
      DEFAULT_SHUFFLE_LISTEN_QUEUE_SIZE));
  bootstrap.setOption("child.keepAlive", true);
  bootstrap.setPipelineFactory(pipelineFact);
  port = conf.getInt(SHUFFLE_PORT_CONFIG_KEY, DEFAULT_SHUFFLE_PORT);
  Channel ch = bootstrap.bind(new InetSocketAddress(port));
  accepted.add(ch);
  port = ((InetSocketAddress)ch.getLocalAddress()).getPort();
  conf.set(SHUFFLE_PORT_CONFIG_KEY, Integer.toString(port));
  pipelineFact.SHUFFLE.setPort(port);
  LOG.info(getName() + " listening on port " + port);
  super.serviceStart();

  sslFileBufferSize = conf.getInt(SUFFLE_SSL_FILE_BUFFER_SIZE_KEY,
                                  DEFAULT_SUFFLE_SSL_FILE_BUFFER_SIZE);
  connectionKeepAliveEnabled =
      conf.getBoolean(SHUFFLE_CONNECTION_KEEP_ALIVE_ENABLED,
        DEFAULT_SHUFFLE_CONNECTION_KEEP_ALIVE_ENABLED);
  connectionKeepAliveTimeOut =
      Math.max(1, conf.getInt(SHUFFLE_CONNECTION_KEEP_ALIVE_TIME_OUT,
        DEFAULT_SHUFFLE_CONNECTION_KEEP_ALIVE_TIME_OUT));
  mapOutputMetaInfoCacheSize =
      Math.max(1, conf.getInt(SHUFFLE_MAPOUTPUT_META_INFO_CACHE_SIZE,
        DEFAULT_SHUFFLE_MAPOUTPUT_META_INFO_CACHE_SIZE));
}