當前位置: 首頁>>代碼示例>>Java>>正文


Java Timeout.cancel方法代碼示例

本文整理匯總了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;
}
 
開發者ID:yajsw,項目名稱:yajsw,代碼行數:17,代碼來源:TimedBlockingPriorityQueue.java

示例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();
    }
}
 
開發者ID:rollenholt-SourceReading,項目名稱:redisson,代碼行數:19,代碼來源:RedissonLock.java

示例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);
}
 
開發者ID:digitalpetri,項目名稱:ethernet-ip,代碼行數:22,代碼來源:CipClient.java

示例4: stop

import io.netty.util.Timeout; //導入方法依賴的package包/類
public void stop()
{
	_stop = true;
	Timeout timeout = _timeout;
	_timeout = null;
	timeout.cancel();
}
 
開發者ID:yajsw,項目名稱:yajsw,代碼行數:8,代碼來源:ReconnectHandler.java

示例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();
}
 
開發者ID:yajsw,項目名稱:yajsw,代碼行數:29,代碼來源:ServerSessionFilter.java

示例6: cancelTimeout

import io.netty.util.Timeout; //導入方法依賴的package包/類
private void cancelTimeout() {
	final Timeout timeout = this.timeout;
	if (timeout != null) {
		timeout.cancel();
		this.timeout = null;
	}
}
 
開發者ID:O2O-Market,項目名稱:Market-monitor,代碼行數:8,代碼來源:DefaultFuture.java

示例7: cancelPeriodicTransmissionTimeout

import io.netty.util.Timeout; //導入方法依賴的package包/類
public void cancelPeriodicTransmissionTimeout(Timeout timeout) {
    if (timeout != null) {
        synchronized (timeout) {
            if (!timeout.isExpired()) {
                timeout.cancel();
            }
        }
    }
}
 
開發者ID:opendaylight,項目名稱:netvirt,代碼行數:10,代碼來源:Ipv6TimerWheel.java

示例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();
        }
    }
}
 
開發者ID:eclipse,項目名稱:milo,代碼行數:29,代碼來源:UaTcpStackServer.java

示例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));
        }
    }

}
 
開發者ID:pravega,項目名稱:pravega,代碼行數:37,代碼來源:TimerWheelTimeoutService.java

示例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);
        }
    };
}
 
開發者ID:rollenholt-SourceReading,項目名稱:redisson,代碼行數:13,代碼來源:MasterSlaveConnectionManager.java

示例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);
        }
    };
}
 
開發者ID:rollenholt-SourceReading,項目名稱:redisson,代碼行數:13,代碼來源:MasterSlaveConnectionManager.java

示例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();
    }
}
 
開發者ID:rollenholt-SourceReading,項目名稱:redisson,代碼行數:11,代碼來源:RedissonLock.java

示例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);
    }
}
 
開發者ID:digitalpetri,項目名稱:opc-ua-stack,代碼行數:29,代碼來源:UaTcpStackClient.java

示例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();
        }
    }
}
 
開發者ID:digitalpetri,項目名稱:opc-ua-stack,代碼行數:29,代碼來源:UaTcpStackServer.java

示例15: cancelExpirationRenewal

import io.netty.util.Timeout; //導入方法依賴的package包/類
void cancelExpirationRenewal() {
    Timeout task = expirationRenewalMap.remove(getEntryName());
    if (task != null) {
        task.cancel();
    }
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:7,代碼來源:RedissonLock.java


注:本文中的io.netty.util.Timeout.cancel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。