本文整理汇总了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();
}
示例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;
}
示例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);
}
示例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");
}
示例5: newNettyTimer
import io.netty.util.HashedWheelTimer; //导入方法依赖的package包/类
private Timer newNettyTimer() {
HashedWheelTimer timer = new HashedWheelTimer();
timer.start();
return timer;
}
示例6: setup
import io.netty.util.HashedWheelTimer; //导入方法依赖的package包/类
@Setup
public void setup() {
timer = new HashedWheelTimer(10L, TimeUnit.MILLISECONDS);
timer.start();
}