本文整理汇总了Java中org.jboss.netty.util.HashedWheelTimer类的典型用法代码示例。如果您正苦于以下问题:Java HashedWheelTimer类的具体用法?Java HashedWheelTimer怎么用?Java HashedWheelTimer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HashedWheelTimer类属于org.jboss.netty.util包,在下文中一共展示了HashedWheelTimer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.jboss.netty.util.HashedWheelTimer; //导入依赖的package包/类
/**
* Initialize internal data structures
*/
public void init(Map<String, String> configParams) throws FloodlightModuleException {
this.moduleLoaderState = ModuleLoaderState.INIT;
// These data structures are initialized here because other
// module's startUp() might be called before ours
this.messageListeners = new ConcurrentHashMap<OFType, ListenerDispatcher<OFType, IOFMessageListener>>();
this.haListeners = new ListenerDispatcher<HAListenerTypeMarker, IHAListener>();
this.controllerNodeIPsCache = new HashMap<String, String>();
this.updates = new LinkedBlockingQueue<IUpdate>();
this.providerMap = new HashMap<String, List<IInfoProvider>>();
setConfigParams(configParams);
HARole initialRole = getInitialRole(configParams);
this.notifiedRole = initialRole;
this.shutdownService = new ShutdownServiceImpl();
this.roleManager = new RoleManager(this, this.shutdownService,
this.notifiedRole,
INITIAL_ROLE_CHANGE_DESCRIPTION);
this.timer = new HashedWheelTimer();
// Switch Service Startup
this.switchService.registerLogicalOFMessageCategory(LogicalOFMessageCategory.MAIN);
this.switchService.addOFSwitchListener(new NotificationSwitchListener());
this.counters = new ControllerCounters(debugCounterService);
}
示例2: newNettyAsyncHttpClient
import org.jboss.netty.util.HashedWheelTimer; //导入依赖的package包/类
public static AsyncHttpClient newNettyAsyncHttpClient(final int timeout, final PoolConfig poolConfig) {
final NettyConnectionsPool pool = new NettyConnectionsPool( //
poolConfig.getMaxTotalConnections(), //
poolConfig.getMaxNrConnectionsPerHost(), //
poolConfig.getMaxIdleTime(), //
poolConfig.getMaxConnectionLifetime(), //
false, //
new HashedWheelTimer());
final AsyncHttpClientConfig config =
new AsyncHttpClientConfig.Builder().setConnectionTimeoutInMs(timeout) //
.setRequestTimeoutInMs(timeout) //
.setMaximumConnectionsPerHost(poolConfig.getMaxNrConnectionsPerHost()) //
.setConnectionsPool(pool) //
.build();
return new AsyncHttpClient(config);
}
示例3: BookKeeperClient
import org.jboss.netty.util.HashedWheelTimer; //导入依赖的package包/类
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;
}
}
示例4: StreamFactoryImpl
import org.jboss.netty.util.HashedWheelTimer; //导入依赖的package包/类
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;
}
示例5: doStart
import org.jboss.netty.util.HashedWheelTimer; //导入依赖的package包/类
@Override
protected void doStart() throws Exception {
if (timer == null) {
HashedWheelTimer hashedWheelTimer = new HashedWheelTimer();
hashedWheelTimer.start();
timer = hashedWheelTimer;
}
if (configuration == null) {
configuration = new NettyConfiguration();
}
if (configuration.isOrderedThreadPoolExecutor()) {
executorService = createExecutorService();
}
super.doStart();
}
示例6: testRegisterRequest
import org.jboss.netty.util.HashedWheelTimer; //导入依赖的package包/类
@Test
public void testRegisterRequest() throws Exception {
HashedWheelTimer timer = getTimer();
RequestManager requestManager = new RequestManager(timer);
try {
RequestPacket packet = new RequestPacket(new byte[0]);
Future future = requestManager.register(packet, 50);
Thread.sleep(200);
Assert.assertTrue(future.isReady());
Assert.assertFalse(future.isSuccess());
Assert.assertTrue(future.getCause().getMessage().contains("timeout"));
logger.debug(future.getCause().getMessage());
} finally {
requestManager.close();
timer.stop();
}
}
示例7: testRemoveMessageFuture
import org.jboss.netty.util.HashedWheelTimer; //导入依赖的package包/类
@Test
public void testRemoveMessageFuture() throws Exception {
HashedWheelTimer timer = getTimer();
RequestManager requestManager = new RequestManager(timer);
try {
RequestPacket packet = new RequestPacket(1, new byte[0]);
DefaultFuture future = requestManager.register(packet, 2000);
future.setFailure(new RuntimeException());
Future nullFuture = requestManager.removeMessageFuture(packet.getRequestId());
Assert.assertNull(nullFuture);
} finally {
requestManager.close();
timer.stop();
}
}
示例8: createClientChannelFactory
import org.jboss.netty.util.HashedWheelTimer; //导入依赖的package包/类
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);
}
示例9: DefaultPinpointClientHandler
import org.jboss.netty.util.HashedWheelTimer; //导入依赖的package包/类
public DefaultPinpointClientHandler(DefaultPinpointClientFactory clientFactory, long pingDelay, long handshakeRetryInterval, long timeoutMillis) {
if (clientFactory == null) {
throw new NullPointerException("pinpointClientFactory must not be null");
}
HashedWheelTimer timer = TimerFactory.createHashedWheelTimer("Pinpoint-PinpointClientHandler-Timer", 100, TimeUnit.MILLISECONDS, 512);
timer.start();
this.channelTimer = timer;
this.clientFactory = clientFactory;
this.requestManager = new RequestManager(timer, timeoutMillis);
this.pingDelay = pingDelay;
this.timeoutMillis = timeoutMillis;
this.messageListener = clientFactory.getMessageListener(SimpleMessageListener.INSTANCE);
this.serverStreamChannelMessageListener = clientFactory.getServerStreamChannelMessageListener(DisabledServerStreamChannelMessageListener.INSTANCE);
this.objectUniqName = ClassUtils.simpleClassNameAndHashCodeString(this);
this.handshaker = new PinpointClientHandshaker(channelTimer, (int) handshakeRetryInterval, maxHandshakeCount);
this.socketId = clientFactory.issueNewSocketId();
this.pingIdGenerator = new AtomicInteger(0);
this.state = new PinpointClientHandlerState(this, clientFactory.getStateChangeEventListeners());
this.localClusterOption = clientFactory.getClusterOption();
}
示例10: testRegisterRequest
import org.jboss.netty.util.HashedWheelTimer; //导入依赖的package包/类
@Test
public void testRegisterRequest() throws Exception {
HashedWheelTimer timer = getTimer();
RequestManager requestManager = new RequestManager(timer, 3000);
try {
RequestPacket packet = new RequestPacket(new byte[0]);
final Future future = requestManager.register(packet, 50);
TestAwaitUtils.await(new TestAwaitTaskUtils() {
@Override
public boolean checkCompleted() {
return future.isReady();
}
}, 10, 200);
Assert.assertTrue(future.isReady());
Assert.assertFalse(future.isSuccess());
Assert.assertTrue(future.getCause().getMessage().contains("timeout"));
logger.debug(future.getCause().getMessage());
} finally {
requestManager.close();
timer.stop();
}
}
示例11: testRemoveMessageFuture
import org.jboss.netty.util.HashedWheelTimer; //导入依赖的package包/类
@Test
public void testRemoveMessageFuture() throws Exception {
HashedWheelTimer timer = getTimer();
RequestManager requestManager = new RequestManager(timer, 3000);
try {
RequestPacket packet = new RequestPacket(1, new byte[0]);
DefaultFuture future = requestManager.register(packet, 2000);
future.setFailure(new RuntimeException());
Future nullFuture = requestManager.removeMessageFuture(packet.getRequestId());
Assert.assertNull(nullFuture);
} finally {
requestManager.close();
timer.stop();
}
}
示例12: RedisClient
import org.jboss.netty.util.HashedWheelTimer; //导入依赖的package包/类
/**
* Create a new client that connects to the supplied host and port. Connection
* attempts and non-blocking commands will {@link #setDefaultTimeout timeout}
* after 60 seconds.
*
* @param host Server hostname.
* @param port Server port.
*/
public RedisClient(String host, int port) {
ExecutorService connectors = Executors.newFixedThreadPool(1);
ExecutorService workers = Executors.newCachedThreadPool();
ClientSocketChannelFactory factory = new NioClientSocketChannelFactory(connectors, workers);
InetSocketAddress addr = new InetSocketAddress(host, port);
bootstrap = new ClientBootstrap(factory);
bootstrap.setOption("remoteAddress", addr);
setDefaultTimeout(60, TimeUnit.SECONDS);
channels = new DefaultChannelGroup();
timer = new HashedWheelTimer();
}
示例13: start
import org.jboss.netty.util.HashedWheelTimer; //导入依赖的package包/类
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());
}
示例14: OpenflowPipelineFactory
import org.jboss.netty.util.HashedWheelTimer; //导入依赖的package包/类
public OpenflowPipelineFactory(Controller controller,
ThreadPoolExecutor pipelineExecutor,
SSLContext sslContext) {
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);
this.sslContext = sslContext;
}
示例15: getTimer
import org.jboss.netty.util.HashedWheelTimer; //导入依赖的package包/类
/**
* Returns the singleton hashed-wheel timer.
*
* @return hashed-wheel timer
*/
public static HashedWheelTimer getTimer() {
if (Timer.timer == null) {
initTimer();
}
return Timer.timer;
}