本文整理匯總了Java中org.apache.cassandra.utils.Throttle類的典型用法代碼示例。如果您正苦於以下問題:Java Throttle類的具體用法?Java Throttle怎麽用?Java Throttle使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Throttle類屬於org.apache.cassandra.utils包,在下文中一共展示了Throttle類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: FileStreamTask
import org.apache.cassandra.utils.Throttle; //導入依賴的package包/類
public FileStreamTask(StreamHeader header, InetAddress to)
{
this.header = header;
this.to = to;
this.throttle = new Throttle(toString(), new Throttle.ThroughputFunction()
{
/** @return Instantaneous throughput target in bytes per millisecond. */
public int targetThroughput()
{
if (DatabaseDescriptor.getStreamThroughputOutboundMegabitsPerSec() < 1)
// throttling disabled
return 0;
// total throughput
int totalBytesPerMS = DatabaseDescriptor.getStreamThroughputOutboundMegabitsPerSec() * 1024 * 1024 / 8 / 1000;
// per stream throughput (target bytes per MS)
return totalBytesPerMS / Math.max(1, (int)StreamingMetrics.activeStreamsOutbound.count());
}
});
metrics = StreamingMetrics.get(to);
}