本文整理汇总了Java中org.apache.cassandra.config.DatabaseDescriptor.setDiskOptimizationStrategy方法的典型用法代码示例。如果您正苦于以下问题:Java DatabaseDescriptor.setDiskOptimizationStrategy方法的具体用法?Java DatabaseDescriptor.setDiskOptimizationStrategy怎么用?Java DatabaseDescriptor.setDiskOptimizationStrategy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.config.DatabaseDescriptor
的用法示例。
在下文中一共展示了DatabaseDescriptor.setDiskOptimizationStrategy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBufferSize_ssd
import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
@Test
public void testBufferSize_ssd()
{
DatabaseDescriptor.setDiskOptimizationStrategy(Config.DiskOptimizationStrategy.ssd);
DatabaseDescriptor.setDiskOptimizationPageCrossChance(0.1);
assertEquals(4096, SegmentedFile.Builder.bufferSize(0));
assertEquals(4096, SegmentedFile.Builder.bufferSize(10));
assertEquals(4096, SegmentedFile.Builder.bufferSize(100));
assertEquals(4096, SegmentedFile.Builder.bufferSize(4096));
assertEquals(8192, SegmentedFile.Builder.bufferSize(4505)); // just < (4096 + 4096 * 0.1)
assertEquals(12288, SegmentedFile.Builder.bufferSize(4506)); // just > (4096 + 4096 * 0.1)
DatabaseDescriptor.setDiskOptimizationPageCrossChance(0.5);
assertEquals(8192, SegmentedFile.Builder.bufferSize(4506)); // just > (4096 + 4096 * 0.1)
assertEquals(8192, SegmentedFile.Builder.bufferSize(6143)); // < (4096 + 4096 * 0.5)
assertEquals(12288, SegmentedFile.Builder.bufferSize(6144)); // = (4096 + 4096 * 0.5)
assertEquals(12288, SegmentedFile.Builder.bufferSize(6145)); // > (4096 + 4096 * 0.5)
DatabaseDescriptor.setDiskOptimizationPageCrossChance(1.0); // never add a page
assertEquals(8192, SegmentedFile.Builder.bufferSize(8191));
assertEquals(8192, SegmentedFile.Builder.bufferSize(8192));
DatabaseDescriptor.setDiskOptimizationPageCrossChance(0.0); // always add a page
assertEquals(8192, SegmentedFile.Builder.bufferSize(10));
assertEquals(8192, SegmentedFile.Builder.bufferSize(4096));
}
示例2: testBufferSize_spinning
import org.apache.cassandra.config.DatabaseDescriptor; //导入方法依赖的package包/类
@Test
public void testBufferSize_spinning()
{
DatabaseDescriptor.setDiskOptimizationStrategy(Config.DiskOptimizationStrategy.spinning);
assertEquals(4096, SegmentedFile.Builder.bufferSize(0));
assertEquals(8192, SegmentedFile.Builder.bufferSize(10));
assertEquals(8192, SegmentedFile.Builder.bufferSize(100));
assertEquals(8192, SegmentedFile.Builder.bufferSize(4096));
assertEquals(12288, SegmentedFile.Builder.bufferSize(4097));
}