admin管理员组文章数量:1567012
本文整理匯總了Java中ioty.channel.EventLoop.schedule方法的典型用法代碼示例。如果您正苦於以下問題:Java EventLoop.schedule方法的具體用法?Java EventLoop.schedule怎麽用?Java EventLoop.schedule使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ioty.channel.EventLoop的用法示例。
在下文中一共展示了EventLoop.schedule方法的19個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。
示例1: scheduleTimeout
點讚 4
import ioty.channel.EventLoop; //導入方法依賴的package包/類
private void scheduleTimeout(CompletableFuture result, long timeoutMillis) {
pendingFutures.add(result);
if (isServerStopping()) {
pendingFutures.remove(result);
return;
}
final ScheduledFuture> timeoutFuture;
if (timeoutMillis > 0) {
final EventLoop eventLoop = RequestContext.current().eventLoop();
timeoutFuture = eventLoop.schedule(() -> resultpleteExceptionally(CANCELLATION_EXCEPTION),
timeoutMillis, TimeUnit.MILLISECONDS);
} else {
timeoutFuture = null;
}
result.whenComplete((revision, cause) -> {
if (timeoutFuture != null) {
timeoutFuture.cancel(true);
}
pendingFutures.remove(result);
});
}
開發者ID:line,項目名稱:centraldogma,代碼行數:24,
示例2: operationComplete
點讚 3
import ioty.channel.EventLoop; //導入方法依賴的package包/類
@Override
public void operationComplete(ChannelFuture channelFuture) throws Exception {
if (!channelFuture.isSuccess()) {
channelFuture.channel().close();
if (count.incrementAndGet() < MAX_RETRY) {
final EventLoop loop = channelFuture.channel().eventLoop();
loop.schedule(() -> {
controller.connectRetry(this.ip, this.port, this);
}, 1L, TimeUnit.SECONDS);
} else {
log.info("Connection to the ovsdb {}:{} failed",
this.ip.toString(), this.port.toString());
}
} else {
handleNewNodeConnection(channelFuture.channel());
}
}
開發者ID:shlee89,項目名稱:athena,代碼行數:20,
示例3: pauseChannelProxy
點讚 3
import ioty.channel.EventLoop; //導入方法依賴的package包/類
/**
* A Netty Channel is paused and don’t accept any command temporarily.
*
* @param channelProxy the specified channel proxy
*/
private void pauseChannelProxy(final ChannelProxy channelProxy) {
channelProxy.paused();
log.info("Pause a channel proxy from pool. channel proxy: {}", channelProxy);
if (false == channelProxy.hasWaitingRequests()) {
return;
}
final Channel channel = channelProxy.getChannel();
EventLoop eventLoop = channel.eventLoop();
eventLoop.schedule(new Runnable() {
@Override
public void run() {
// cancel all waiting requests belong to this channel
channelProxy.cancelWaitingRequests();
}
}, Constants.CANCEL_WAITING_REQUEST_DELAY, TimeUnit.SECONDS);
}
開發者ID:allan-huang,項目名稱:remote-procedure-call,代碼行數:24,
示例4: stopChannelProxy
點讚 3
import ioty.channel.EventLoop; //導入方法依賴的package包/類
/**
* Closes a Netty channel and stops accepting any command.
*
* @param channelProxy the specified channel proxy
*/
public void stopChannelProxy(final ChannelProxy channelProxy) {
channelProxy.setStopped(true);
final Channel channel = channelProxy.getChannel();
EventLoop eventLoop = channel.eventLoop();
eventLoop.schedule(new Runnable() {
@Override
public void run() {
if (channelProxy.hasWaitingRequests()) {
// cancel all waiting requests belong to this channel
channelProxy.cancelWaitingRequests();
}
// close this unused channel
channel.close();
}
}, Constants.CANCEL_WAITING_REQUEST_DELAY, TimeUnit.SECONDS);
log.info("Stop a channel proxy from pool. channel proxy: {}", channelProxy);
}
開發者ID:allan-huang,項目名稱:remote-procedure-call,代碼行數:25,
示例5: channelInactive
點讚 3
import ioty.channel.EventLoop; //導入方法依賴的package包/類
/**
* Handles an inactive channel and tries to reconnects original remote server
*/
@Override
public void channelInactive(final ChannelHandlerContext context) throws Exception {
log.info("Client is disconnected from server: {}", context.channel().remoteAddress());
ChannelProxy channelProxy = ClientChannelManager.getInstance().findChannelProxy(context.channel());
if (channelProxy == null || channelProxy.isStopped()) {
log.warn("Fail to find any matching proxy of client channel or this client channel had been stopped.");
return;
}
log.info("Reconnects to remote server after {} seconds.", Constants.RECONNECT_DELAY);
// delay several seconds to reconnect the original remote server
EventLoop eventLoop = context.channel().eventLoop();
eventLoop.schedule(new Runnable() {
@Override
public void run() {
reconnect(context);
}
}, Constants.RECONNECT_DELAY, TimeUnit.SECONDS);
}
開發者ID:allan-huang,項目名稱:remote-procedure-call,代碼行數:25,
示例6: operationComplete
點讚 3
import ioty.channel.EventLoop; //導入方法依賴的package包/類
@Override
public void operationComplete(final ChannelFuture future) throws Exception {
if (future.isCancelled()) {
LOG.debug("Connection {} cancelled!", future);
} else if (future.isSuccess()) {
LOG.debug("Connection {} succeeded!", future);
future.channel().closeFuture().addListener((ChannelFutureListener) channelFuture -> scheduleConnect());
} else {
if (this.delay > MAXIMUM_BACKOFF) {
LOG.warn("The time of maximum backoff has been exceeded. No further connection attempts with BMP "
+ "router {}.", this.remoteAddress);
future.cancel(false);
return;
}
final EventLoop loop = future.channel().eventLoop();
loop.schedule(() -> this.bootstrap.connect().addListener(this), this.delay, TimeUnit.MILLISECONDS);
LOG.info("The connection try to BMP router {} failed. Next reconnection attempt in {} milliseconds.",
this.remoteAddress, this.delay);
this.delay *= 2;
}
}
開發者ID:opendaylight,項目名稱:bgpcep,代碼行數:22,
示例7: reconnect
點讚 3
import ioty.channel.EventLoop; //導入方法依賴的package包/類
synchronized void reconnect() {
if (this.retryTimer == 0) {
LOG.debug("Retry timer value is 0. Reconnection will not be attempted");
this.setFailure(this.pending.cause());
return;
}
final EventLoop loop = this.pending.channel().eventLoop();
loop.schedule(() -> {
synchronized (BGPProtocolSessionPromise.this) {
if (BGPProtocolSessionPromise.this.peerSessionPresent) {
LOG.debug("Connection to {} already exists", BGPProtocolSessionPromise.this.address);
BGPProtocolSessionPromise.this.connectSkipped = true;
return;
}
BGPProtocolSessionPromise.this.connectSkipped = false;
LOG.debug("Attempting to connect to {}", BGPProtocolSessionPromise.this.address);
final ChannelFuture reconnectFuture = BGPProtocolSessionPromise.this.bootstrap.connect();
reconnectFuture.addListener(new BootstrapConnectListener());
BGPProtocolSessionPromise.this.pending = reconnectFuture;
}
}, this.retryTimer, TimeUnit.SECONDS);
LOG.debug("Next reconnection attempt in {}s", this.retryTimer);
}
開發者ID:opendaylight,項目名稱:bgpcep,代碼行數:26,
示例8: channelUnregistered
點讚 3
import ioty.channel.EventLoop; //導入方法依賴的package包/類
@Override
public void channelUnregistered(final ChannelHandlerContext ctx) throws Exception {
if(log.isInfoEnabled()) {
log.info("Sleeping for {}s before reconnect.", reconnectTimeUnit.toSeconds(reconnectDelay));
}
final ClientInfoClientHandler handler = this;
final EventLoop loop = ctx.channel().eventLoop();
loop.schedule(new Runnable() {
@Override
public void run() {
log.info("Reconnecting");
PeriodicConfigRetrievalClient.configureBootstrap(configServerChooser, handler, new Bootstrap(), loop,
idleReadTimeUnit,idleReadTimeout,connectionTimeoutInMillis);
}
}, reconnectDelay, reconnectTimeUnit);
}
開發者ID:tootedom,項目名稱:spray-cache-spymemcached,代碼行數:18,
示例9: operationComplete
點讚 3
import ioty.channel.EventLoop; //導入方法依賴的package包/類
@Override
public void operationComplete(ChannelFuture channelFuture) throws Exception {
if (!channelFuture.isSuccess()) {
channelFuture.channel().close();
if (count.incrementAndGet() < MAX_RETRY) {
final EventLoop loop = channelFuture.channel().eventLoop();
loop.schedule(() -> {
try {
controller.connectRetry(this.ip, this.port, this);
} catch (Exception e) {
log.warn("Connection to the ovsdb server {}:{} failed(cause: {})", ip, port, e);
}
}, 1L, TimeUnit.SECONDS);
} else {
failhandler.accept(new Exception("max connection retry(" + MAX_RETRY + ") exceeded"));
}
} else {
handleNewNodeConnection(channelFuture.channel());
}
}
開發者ID:opennetworkinglab,項目名稱:onos,代碼行數:23,
示例10: operationComplete
點讚 3
import ioty.channel.EventLoop; //導入方法依賴的package包/類
@Override
public void operationComplete(ChannelFuture future) throws Exception {
if (future.isSuccess()) {
log.info(String.format(MSG_STATE,
ofSwitch.dpid(),
MSG_CONNECTED,
controller.ip(),
controller.port()));
// FIXME add close future listener to handle connection lost
} else {
if (retryCount.getAndIncrement() > MAX_RETRY) {
log.warn(String.format(MSG_STATE,
ofSwitch.dpid(),
MSG_FAILED,
controller.ip(),
controller.port()));
} else {
final EventLoop loop = future.channel().eventLoop();
loop.schedule(this::connect, 1L, TimeUnit.SECONDS);
}
}
}
開發者ID:opennetworkinglab,項目名稱:onos,代碼行數:23,
示例11: channelUnregistered
點讚 2
import ioty.channel.EventLoop; //導入方法依賴的package包/類
@Override
public void channelUnregistered(final ChannelHandlerContext ctx) throws Exception {
println("Sleeping for: " + UptimeClient.RECONNECT_DELAY + 's');
final EventLoop loop = ctx.channel().eventLoop();
loop.schedule(new Runnable() {
@Override
public void run() {
println("Reconnecting to: " + UptimeClient.HOST + ':' + UptimeClient.PORT);
UptimeClient.connect(UptimeClient.configureBootstrap(new Bootstrap(), loop));
}
}, UptimeClient.RECONNECT_DELAY, TimeUnit.SECONDS);
}
開發者ID:cowthan,項目名稱:JavaAyo,代碼行數:14,
示例12: scheduleReconnect
點讚 2
import ioty.channel.EventLoop; //導入方法依賴的package包/類
private void scheduleReconnect(final ChannelFuture channelFuture) {
final EventLoop loop = channelFuture.channel().eventLoop();
loop.schedule(new Runnable() {
@Override
public void run() {
try {
LOG.trace("Re-connecting to {} if needed", configuration.getAddress());
doReconnectIfNeeded();
} catch (Exception e) {
LOG.warn("Error during re-connect to " + configuration.getAddress() + ". Will attempt again in "
+ configuration.getReconnectInterval() + " millis. This exception is ignored.", e);
}
}
}, configuration.getReconnectInterval(), TimeUnit.MILLISECONDS);
}
示例13: operationComplete
點讚 2
import ioty.channel.EventLoop; //導入方法依賴的package包/類
@Override
public void operationComplete(ChannelFuture future) throws Exception {
if (!future.isSuccess()) {
EventLoop eventLoop = future.channel().eventLoop();
eventLoop.schedule(client::start, 1L, TimeUnit.SECONDS);
}
}
開發者ID:tonivade,項目名稱:resp-server,代碼行數:8,
示例14: channelUnregistered
點讚 2
import ioty.channel.EventLoop; //導入方法依賴的package包/類
@Override
public void channelUnregistered(final ChannelHandlerContext ctx)
throws Exception {
println("Sleeping for: " + UptimeClient.RECONNECT_DELAY + 's');
final EventLoop loop = ctx.channel().eventLoop();
loop.schedule(new Runnable() {
@Override
public void run() {
println("Reconnecting to: " + ctx.channel().remoteAddress());
client.configureBootstrap(new Bootstrap(), loop).connect();
}
}, UptimeClient.RECONNECT_DELAY, TimeUnit.SECONDS);
}
開發者ID:kyle-liu,項目名稱:netty4study,代碼行數:15,
示例15: operationComplete
點讚 2
import ioty.channel.EventLoop; //導入方法依賴的package包/類
@Override
public void operationComplete(final ChannelFuture future) throws Exception {
if (future.isCancelled()) {
LOG.debug("Connection {} cancelled!", future);
} else if (future.isSuccess()) {
LOG.debug("Connection {} succeeded!", future);
future.channel().closeFuture().addListener((ChannelFutureListener) channelFuture -> scheduleConnect());
} else {
final EventLoop loop = future.channel().eventLoop();
loop.schedule(() -> this.bootstrap.connect().addListener(this), this.delay, TimeUnit.MILLISECONDS);
LOG.info("The connection try to BMP router {} failed. Next reconnection attempt in {} milliseconds.",
this.remoteAddress, this.delay);
}
}
開發者ID:opendaylight,項目名稱:bgpcep,代碼行數:15,
示例16: operationComplete
點讚 2
import ioty.channel.EventLoop; //導入方法依賴的package包/類
@Override
public void operationComplete(final ChannelFuture cf) throws Exception {
synchronized (this.lock) {
if (PCCReconnectPromise.this.isCancelled()) {
if (cf.isSuccess()) {
PCCReconnectPromise.LOG.debug("Closing channels for cancelled promise {}");
cf.channel().close();
}
} else if (cf.isSuccess()) {
PCCReconnectPromise.LOG.debug("Promise connection is successful.");
} else {
PCCReconnectPromise.LOG.debug("Attempt to connect to {} failed",
PCCReconnectPromise.this.address, cf.cause());
if (PCCReconnectPromise.this.retryTimer == 0) {
PCCReconnectPromise.LOG.debug("Retry timer value is 0. Reconnection will not be attempted");
PCCReconnectPromise.this.setFailure(cf.cause());
return;
}
final EventLoop loop = cf.channel().eventLoop();
loop.schedule(() -> {
synchronized (PCCReconnectPromise.this) {
PCCReconnectPromise.LOG.debug("Attempting to connect to {}",
PCCReconnectPromise.this.address);
final Future reconnectFuture = PCCReconnectPromise.this.bootstrap.connect();
reconnectFuture.addListener(this);
PCCReconnectPromise.this.pending = reconnectFuture;
}
}, PCCReconnectPromise.this.retryTimer, TimeUnit.SECONDS);
PCCReconnectPromise.LOG.debug("Next reconnection attempt in {}s",
PCCReconnectPromise.this.retryTimer);
}
}
}
開發者ID:opendaylight,項目名稱:bgpcep,代碼行數:36,
示例17: channelInactive
點讚 2
import ioty.channel.EventLoop; //導入方法依賴的package包/類
@Override
public void channelInactive(final ChannelHandlerContext ctx) throws Exception {
println("Disconnected from: " + ctx.channel().remoteAddress());
println("Sleeping for: " + UptimeClient.RECONNECT_DELAY + 's');
final EventLoop loop = ctx.channel().eventLoop();
loop.schedule(new Runnable() {
@Override
public void run() {
println("Reconnecting to: " + ctx.channel().remoteAddress());
client.configureBootstrap(new Bootstrap(), loop).connect();
}
}, UptimeClient.RECONNECT_DELAY, TimeUnit.SECONDS);
}
開發者ID:nathanchen,項目名稱:netty-netty-5.0.0.Alpha1,代碼行數:16,
示例18: scheduleReconnect
點讚 2
import ioty.channel.EventLoop; //導入方法依賴的package包/類
private void scheduleReconnect(final ChannelHandlerContext ctx) {
final EventLoop loop = ctx.channel().eventLoop();
loop.schedule(new Runnable() {
@Override
public void run() {
log.info("Reconnecting to {}", graphiteTarget);
client.connect();
}
}, RECONNECT_DELAY_SEC, TimeUnit.SECONDS);
}
開發者ID:outbrain,項目名稱:gruffalo,代碼行數:11,
示例19: operationComplete
點讚 2
import ioty.channel.EventLoop; //導入方法依賴的package包/類
@Override
public void operationComplete(final ChannelFuture cf) throws Exception {
synchronized (PCEPProtocolSessionPromise.this) {
PCEPProtocolSessionPromise.LOG.debug("Promise {} connection resolved",
PCEPProtocolSessionPromise.this);
Preconditions.checkState(PCEPProtocolSessionPromise.this.pending.equals(cf));
if (PCEPProtocolSessionPromise.this.isCancelled()) {
if (cf.isSuccess()) {
PCEPProtocolSessionPromise.LOG.debug("Closing channel for cancelled promise {}",
PCEPProtocolSessionPromise.this);
cf.channel().close();
}
} else if (cf.isSuccess()) {
PCEPProtocolSessionPromise.LOG.debug("Promise {} connection successful",
PCEPProtocolSessionPromise.this);
} else {
PCEPProtocolSessionPromise.LOG.debug("Attempt to connect to {} failed",
PCEPProtocolSessionPromise.this.address, cf.cause());
if (PCEPProtocolSessionPromise.this.retryTimer == 0) {
PCEPProtocolSessionPromise.LOG
.debug("Retry timer value is 0. Reconnection will not be attempted");
PCEPProtocolSessionPromise.this.setFailure(cf.cause());
return;
}
final EventLoop loop = cf.channel().eventLoop();
loop.schedule(() -> {
synchronized (PCEPProtocolSessionPromise.this) {
PCEPProtocolSessionPromise.LOG.debug("Attempting to connect to {}",
PCEPProtocolSessionPromise.this.address);
final Future reconnectFuture = PCEPProtocolSessionPromise.this.b.connect();
reconnectFuture.addListener(BootstrapConnectListener.this);
PCEPProtocolSessionPromise.this.pending = reconnectFuture;
}
}, PCEPProtocolSessionPromise.this.retryTimer, TimeUnit.SECONDS);
PCEPProtocolSessionPromise.LOG.debug("Next reconnection attempt in {}s",
PCEPProtocolSessionPromise.this.retryTimer);
}
}
}
開發者ID:opendaylight,項目名稱:bgpcep,代碼行數:42,
注:本文中的ioty.channel.EventLoop.schedule方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。
版权声明:本文标题:java event loop_Java EventLoop.schedule方法代碼示例 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/xitong/1725780375a1042175.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论