本文整理汇总了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);
}