当前位置: 首页>>代码示例>>Java>>正文


Java HashedWheelTimer.start方法代码示例

本文整理汇总了Java中io.netty.util.HashedWheelTimer.start方法的典型用法代码示例。如果您正苦于以下问题:Java HashedWheelTimer.start方法的具体用法?Java HashedWheelTimer.start怎么用?Java HashedWheelTimer.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.netty.util.HashedWheelTimer的用法示例。


在下文中一共展示了HashedWheelTimer.start方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createConfig

import io.netty.util.HashedWheelTimer; //导入方法依赖的package包/类
/**
 * 生成默认的httpclient config
 *
 * @return the config
 */
public static AsyncHttpClientConfig createConfig(int connectTimeout, int requestTimeout) {
    HashedWheelTimer timer = new HashedWheelTimer();
    timer.start();
    DefaultChannelPool channelPool = new DefaultChannelPool(60000,
            -1,
            DefaultChannelPool.PoolLeaseStrategy.LIFO,
            timer,
            3000);

    return new DefaultAsyncHttpClientConfig.Builder()
            .setConnectTimeout(connectTimeout)
            .setRequestTimeout(requestTimeout)
            .setMaxConnectionsPerHost(10000)
            .setValidateResponseHeaders(false)
            .setMaxRequestRetry(0)
            .setChannelPool(channelPool)
            .build();
}
 
开发者ID:darren-fu,项目名称:RestyPass,代码行数:24,代码来源:AsyncHttpConfigFactory.java

示例2: HashedWheelGatherer

import io.netty.util.HashedWheelTimer; //导入方法依赖的package包/类
/**
 *
 * @param handler Called with a request when all parts are received or it expires.
 * @param numParts number of parts for each request
 * @param timeoutDuration Expiration time for incomplete requests
 * @param unit time unit for timeoutDuration
 * @param timeoutMaxError a value in range (0 and 1], where the timeout might happen at time timeoutDuration + timeoutMaxError*timeoutDuration. A larger value means a more efficient data structure.
 */
public HashedWheelGatherer(RequestHandler<T> handler, int numParts, long timeoutDuration, TimeUnit unit, double timeoutMaxError) {

	if (timeoutMaxError <= 0 || timeoutMaxError > 1) {
		throw new IllegalArgumentException(String.format("timeoutMaxError must be in range (0, 1] (got %f)", timeoutMaxError));
	}

	timeoutDurationNs = unit.toNanos(timeoutDuration);
	inflightRequests = new ConcurrentHashMap<>();

	// create the wheel timer
	int numSteps = (int)Math.round(1. / timeoutMaxError);
	long tickDurationNs = Math.max(unit.toNanos(timeoutDuration) / numSteps, 1);

	hashedWheelTimer = new HashedWheelTimer(r -> {
		// Use daemon threads
		Thread t = Executors.defaultThreadFactory().newThread(r);
		t.setDaemon(true);
		return t;
	}, tickDurationNs, TimeUnit.NANOSECONDS, numSteps);

	hashedWheelTimer.start();

	this.numParts = numParts;
	this.handler = handler;
}
 
开发者ID:turn,项目名称:gatherer,代码行数:34,代码来源:HashedWheelGatherer.java

示例3: start

import io.netty.util.HashedWheelTimer; //导入方法依赖的package包/类
/**
 * Starts Socket.IO server with current configuration settings.
 *
 * @throws IllegalStateException
 *             if server already started
 */
public synchronized void start() {
  if (isStarted()) {
    throw new IllegalStateException("Failed to start Socket.IO server: server already started");
  }

  log.info("Socket.IO server starting");

  // Configure heartbeat scheduler
  timer = new HashedWheelTimer();
  timer.start();
  SocketIOHeartbeatScheduler.setHashedWheelTimer(timer);
  SocketIOHeartbeatScheduler.setHeartbeatInterval(configuration.getHeartbeatInterval());
  SocketIOHeartbeatScheduler.setHeartbeatTimeout(configuration.getHeartbeatTimeout());

  // Configure and bind server
  ServerBootstrapFactory bootstrapFactory = serverBootstrapFactory != null
      ? serverBootstrapFactory
      : new DefaultServerBootstrapFactory(configuration);
  bootstrap = bootstrapFactory.createServerBootstrap();
  bootstrap.childHandler(new SocketIOChannelInitializer(configuration, listener, pipelineModifier));
  bootstrap.bind(configuration.getPort()).syncUninterruptibly();

  state = State.STARTED;
  log.info("Socket.IO server started: {}", configuration);
}
 
开发者ID:scalecube,项目名称:socketio,代码行数:32,代码来源:SocketIOServer.java

示例4: TimeoutService

import io.netty.util.HashedWheelTimer; //导入方法依赖的package包/类
private TimeoutService() {
	tickDuration = ConfigurationHelper.getLongSystemThenEnvProperty(CONFIG_TICK_DURATION, DEFAULT_TICK_DURATION);
	tickCount = ConfigurationHelper.getIntSystemThenEnvProperty(CONFIG_TICK_COUNT, DEFAULT_TICK_COUNT);
	timer = new HashedWheelTimer(this, tickDuration, TimeUnit.MILLISECONDS, tickCount);
	timer.start();
	JMXHelper.registerMBean(this, OBJECT_NAME);
	log.info("TimeoutService started");
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:9,代码来源:TimeoutService.java

示例5: newNettyTimer

import io.netty.util.HashedWheelTimer; //导入方法依赖的package包/类
private Timer newNettyTimer() {
    HashedWheelTimer timer = new HashedWheelTimer();
    timer.start();
    return timer;
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:6,代码来源:DefaultAsyncHttpClient.java

示例6: setup

import io.netty.util.HashedWheelTimer; //导入方法依赖的package包/类
@Setup
public void setup() {
  timer = new HashedWheelTimer(10L, TimeUnit.MILLISECONDS);
  timer.start();
}
 
开发者ID:ifesdjeen,项目名称:hashed-wheel-timer,代码行数:6,代码来源:NettyTimerBenchmark.java


注:本文中的io.netty.util.HashedWheelTimer.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。