本文整理汇总了Java中org.eclipse.californium.core.network.Exchange.getCurrentTimeout方法的典型用法代码示例。如果您正苦于以下问题:Java Exchange.getCurrentTimeout方法的具体用法?Java Exchange.getCurrentTimeout怎么用?Java Exchange.getCurrentTimeout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.californium.core.network.Exchange
的用法示例。
在下文中一共展示了Exchange.getCurrentTimeout方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareRetransmission
import org.eclipse.californium.core.network.Exchange; //导入方法依赖的package包/类
/**
* Computes the back-off timer and schedules the specified retransmission
* task.
*
* @param exchange the exchange
* @param task the retransmission task
*/
protected void prepareRetransmission(Exchange exchange, RetransmissionTask task) {
// prevent RejectedExecutionException
if (executor.isShutdown()) {
LOGGER.info("Endpoint is being destroyed: skipping retransmission");
return;
}
/*
* For a new confirmable message, the initial timeout is set to a
* random number between ACK_TIMEOUT and (ACK_TIMEOUT *
* ACK_RANDOM_FACTOR)
*/
int timeout;
if (exchange.getFailedTransmissionCount() == 0) {
timeout = getRandomTimeout(ack_timeout, (int) (ack_timeout*ack_random_factor));
} else {
timeout = (int) (ack_timeout_scale * exchange.getCurrentTimeout());
}
exchange.setCurrentTimeout(timeout);
ScheduledFuture<?> f = executor.schedule(task , timeout, TimeUnit.MILLISECONDS);
exchange.setRetransmissionHandle(f);
}
示例2: prepareRetransmission
import org.eclipse.californium.core.network.Exchange; //导入方法依赖的package包/类
/**
* The following method overrides the method provided by the reliability layer to include the advanced RTO calculation values
* when determining the RTO.
*/
@Override
protected void prepareRetransmission(Exchange exchange, RetransmissionTask task) {
int timeout;
//System.out.println("TXCount: " + exchange.getFailedTransmissionCount());
if (exchange.getFailedTransmissionCount() == 0) {
timeout = (int)getRemoteEndpoint(exchange).getRTO();
if(appliesDithering()){
//TODO: Workaround to force CoCoA (-Strong) not to use the same RTO after backing off several times
//System.out.println("Applying dithering, matching RTO");
getRemoteEndpoint(exchange).matchCurrentRTO();
timeout = (int)getRemoteEndpoint(exchange).getRTO();
// Apply dithering by randomly choosing RTO from [RTO, RTO * 1.5]
float ack_random_factor = config.getFloat(NetworkConfig.Keys.ACK_RANDOM_FACTOR);
timeout = getRandomTimeout(timeout, (int) (timeout*ack_random_factor));
}
//System.out.println("meanrto:" + timeout + ";" + System.currentTimeMillis());
} else {
int tempTimeout= (int)(getRemoteEndpoint(exchange).getExchangeVBF(exchange) * exchange.getCurrentTimeout());
timeout = (tempTimeout < MAX_RTO) ? tempTimeout : MAX_RTO;
getRemoteEndpoint(exchange).setCurrentRTO(timeout);
//System.out.println("RTX");
}
exchange.setCurrentTimeout(timeout);
//expectedmaxduration = calculateMaxTransactionDuration(exchange); //FIXME what was this for?
//System.out.println("Sending MSG (timeout;timestamp:" + timeout + ";" + System.currentTimeMillis() + ")");
ScheduledFuture<?> f = executor.schedule(task , timeout, TimeUnit.MILLISECONDS);
exchange.setRetransmissionHandle(f);
}