本文整理匯總了Java中io.netty.util.Timeout.cancel方法的典型用法代碼示例。如果您正苦於以下問題:Java Timeout.cancel方法的具體用法?Java Timeout.cancel怎麽用?Java Timeout.cancel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.netty.util.Timeout
的用法示例。
在下文中一共展示了Timeout.cancel方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: poll
import io.netty.util.Timeout; //導入方法依賴的package包/類
public T poll(int group)
{
LinkedList<T> q = _queues[group];
T result = null;
if (q != null)
{
result = q.poll();
if (result != null)
{
Timeout timer = _timers.remove(result);
if (timer != null)
timer.cancel();
}
}
return result;
}
示例2: newRefreshTask
import io.netty.util.Timeout; //導入方法依賴的package包/類
private void newRefreshTask() {
if (refreshTaskMap.containsKey(getName())) {
return;
}
Timeout task = commandExecutor.getConnectionManager().newTimeout(new TimerTask() {
@Override
public void run(Timeout timeout) throws Exception {
expire(internalLockLeaseTime, TimeUnit.MILLISECONDS);
refreshTaskMap.remove(getName());
newRefreshTask(); // reschedule itself
}
}, internalLockLeaseTime / 3, TimeUnit.MILLISECONDS);
if (refreshTaskMap.putIfAbsent(getName(), task) != null) {
task.cancel();
}
}
示例3: itemsReceived
import io.netty.util.Timeout; //導入方法依賴的package包/類
@Override
public void itemsReceived(CpfItem[] items) {
int connectionId = ((ConnectedAddressItem) items[0]).getConnectionId();
ByteBuf buffer = ((ConnectedDataItemResponse) items[1]).getData();
int sequenceNumber = buffer.readShort();
ByteBuf data = buffer.readSlice(buffer.readableBytes()).retain();
Timeout timeout = timeouts.remove(sequenceNumber);
if (timeout != null) timeout.cancel();
CompletableFuture<ByteBuf> future = pending.remove(sequenceNumber);
if (future != null) {
future.complete(data);
} else {
ReferenceCountUtil.release(data);
}
ReferenceCountUtil.release(buffer);
}
示例4: stop
import io.netty.util.Timeout; //導入方法依賴的package包/類
public void stop()
{
_stop = true;
Timeout timeout = _timeout;
_timeout = null;
timeout.cancel();
}
示例5: handleSession
import io.netty.util.Timeout; //導入方法依賴的package包/類
private void handleSession(ChannelHandlerContext ctx, Session session,
HandlerList pipeline)
{
_hasSession = true;
session.setClosed(false);
// if we have a session timeout set, cancel it.
Timeout timeOut = session.removeTimeout();
if (timeOut != null)
timeOut.cancel();
if (pipeline.hasChannel())
{
Constants.ahessianLogger.warn(ctx.channel()
+ " session already attached -> close connection");
pipeline.close();
}
// now that we have a session extend the pipeline
pipeline.mixin(ctx);
ctx.channel().attr(SESSION).set(session);
_channel = ctx.channel();
// first send session and wait until it has been transmitted
ctx.writeAndFlush(Unpooled.wrappedBuffer(session.getId().getBytes()))
.awaitUninterruptibly();
// only then inform the mixin pipeline that we are connected
ctx.fireChannelActive();
}
示例6: cancelTimeout
import io.netty.util.Timeout; //導入方法依賴的package包/類
private void cancelTimeout() {
final Timeout timeout = this.timeout;
if (timeout != null) {
timeout.cancel();
this.timeout = null;
}
}
示例7: cancelPeriodicTransmissionTimeout
import io.netty.util.Timeout; //導入方法依賴的package包/類
public void cancelPeriodicTransmissionTimeout(Timeout timeout) {
if (timeout != null) {
synchronized (timeout) {
if (!timeout.isExpired()) {
timeout.cancel();
}
}
}
}
示例8: secureChannelIssuedOrRenewed
import io.netty.util.Timeout; //導入方法依賴的package包/類
public void secureChannelIssuedOrRenewed(ServerSecureChannel secureChannel, long lifetimeMillis) {
long channelId = secureChannel.getChannelId();
/*
* Cancel any existing timeouts and start a new one.
*/
Timeout timeout = timeouts.remove(channelId);
boolean cancelled = (timeout == null || timeout.cancel());
if (cancelled) {
timeout = wheelTimer.newTimeout(t ->
closeSecureChannel(secureChannel), lifetimeMillis, TimeUnit.MILLISECONDS);
timeouts.put(channelId, timeout);
/*
* If this is a reconnect there might be responses queued, so drain those.
*/
Channel channel = secureChannel.attr(BoundChannelKey).get();
if (channel != null) {
List<ServiceResponse> responses = responseQueues.removeAll(channelId);
responses.forEach(channel::write);
channel.flush();
}
}
}
示例9: pingTxn
import io.netty.util.Timeout; //導入方法依賴的package包/類
@Override
public PingTxnStatus pingTxn(final String scope, final String stream, final UUID txnId, int version, long lease) {
if (!this.isRunning()) {
return PingTxnStatus.newBuilder().setStatus(PingTxnStatus.Status.DISCONNECTED).build();
}
final String key = getKey(scope, stream, txnId);
Preconditions.checkState(map.containsKey(key), "Stream not found in the map");
final TxnData txnData = map.get(key);
if (txnData == null) {
throw new IllegalStateException(String.format("Transaction %s not added to timerWheelTimeoutService", txnId));
}
if (lease > maxLeaseValue || lease > txnData.getScaleGracePeriod()) {
return PingTxnStatus.newBuilder().setStatus(PingTxnStatus.Status.LEASE_TOO_LARGE).build();
}
if (lease + System.currentTimeMillis() > txnData.getMaxExecutionTimeExpiry()) {
return PingTxnStatus.newBuilder().setStatus(PingTxnStatus.Status.MAX_EXECUTION_TIME_EXCEEDED).build();
} else {
Timeout timeout = txnData.getTimeout();
boolean cancelSucceeded = timeout.cancel();
if (cancelSucceeded) {
TxnData newTxnData = txnData.updateLease(scope, stream, txnId, version, lease);
map.replace(key, txnData, newTxnData);
return PingTxnStatus.newBuilder().setStatus(PingTxnStatus.Status.OK).build();
} else {
// Cancellation may fail because timeout task (1) may be scheduled for execution, or (2) is executing.
throw new IllegalStateException(String.format("Failed updating timeout for transaction %s", txnId));
}
}
}
示例10: createReleaseWriteListener
import io.netty.util.Timeout; //導入方法依賴的package包/類
@Override
public <T> FutureListener<T> createReleaseWriteListener(final int slot,
final RedisConnection conn, final Timeout timeout) {
return new FutureListener<T>() {
@Override
public void operationComplete(io.netty.util.concurrent.Future<T> future) throws Exception {
shutdownLatch.release();
timeout.cancel();
releaseWrite(slot, conn);
}
};
}
示例11: createReleaseReadListener
import io.netty.util.Timeout; //導入方法依賴的package包/類
@Override
public <T> FutureListener<T> createReleaseReadListener(final int slot,
final RedisConnection conn, final Timeout timeout) {
return new FutureListener<T>() {
@Override
public void operationComplete(io.netty.util.concurrent.Future<T> future) throws Exception {
shutdownLatch.release();
timeout.cancel();
releaseRead(slot, conn);
}
};
}
示例12: stopRefreshTask
import io.netty.util.Timeout; //導入方法依賴的package包/類
/**
* Stop refresh timer
* @return true if timer was stopped successfully
*/
private void stopRefreshTask() {
Timeout task = refreshTaskMap.remove(getName());
if (task != null) {
task.cancel();
}
}
示例13: receiveResponse
import io.netty.util.Timeout; //導入方法依賴的package包/類
private void receiveResponse(UaResponseMessage response) {
ResponseHeader header = response.getResponseHeader();
UInteger requestHandle = header.getRequestHandle();
CompletableFuture<UaResponseMessage> future = pending.remove(requestHandle);
if (future != null) {
if (header.getServiceResult().isGood()) {
future.complete(response);
} else {
ServiceFault serviceFault;
if (response instanceof ServiceFault) {
serviceFault = (ServiceFault) response;
} else {
serviceFault = new ServiceFault(header);
}
future.completeExceptionally(new UaServiceFaultException(serviceFault));
}
Timeout timeout = timeouts.remove(requestHandle);
if (timeout != null) timeout.cancel();
} else {
logger.warn("Received {} for unknown requestHandle: {}",
response.getClass().getSimpleName(), requestHandle);
}
}
示例14: secureChannelIssuedOrRenewed
import io.netty.util.Timeout; //導入方法依賴的package包/類
public void secureChannelIssuedOrRenewed(ServerSecureChannel secureChannel, long lifetimeMillis) {
long channelId = secureChannel.getChannelId();
/*
* Cancel any existing timeouts and start a new one.
*/
Timeout timeout = timeouts.remove(channelId);
boolean cancelled = (timeout == null || timeout.cancel());
if (cancelled) {
timeout = wheelTimer.newTimeout(t ->
closeSecureChannel(secureChannel), lifetimeMillis, TimeUnit.MILLISECONDS);
timeouts.put(channelId, timeout);
/*
* If this is a reconnect there might be responses queued, so drain those.
*/
Channel channel = secureChannel.attr(BoundChannelKey).get();
if (channel != null) {
List<ServiceResponse> responses = responseQueues.removeAll(channelId);
responses.forEach(channel::write);
channel.flush();
}
}
}
示例15: cancelExpirationRenewal
import io.netty.util.Timeout; //導入方法依賴的package包/類
void cancelExpirationRenewal() {
Timeout task = expirationRenewalMap.remove(getEntryName());
if (task != null) {
task.cancel();
}
}