当前位置: 首页>>代码示例>>Java>>正文


Java Exchange.getCurrentTimeout方法代码示例

本文整理汇总了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);
}
 
开发者ID:iotoasis,项目名称:SI,代码行数:31,代码来源:ReliabilityLayer.java

示例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);	
}
 
开发者ID:iotoasis,项目名称:SI,代码行数:33,代码来源:CongestionControlLayer.java


注:本文中的org.eclipse.californium.core.network.Exchange.getCurrentTimeout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。