當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。