Search in sources :

Example 1 with WriteSettings

use of io.pravega.segmentstore.storage.WriteSettings in project pravega by pravega.

the class ThrottlerCalculatorTests method testDurableDataLog.

/**
 * Tests the ability to properly calculate DurableDataLog-related delays.
 */
@Test
public void testDurableDataLog() {
    val halfRatio = 0.5;
    val maxWriteSize = 12345;
    val maxQueueCount = 123;
    val maxOutstandingBytes = maxWriteSize * maxQueueCount;
    val minThrottleThreshold = (int) (maxOutstandingBytes * ThrottlerPolicy.DURABLE_DATALOG_THROTTLE_THRESHOLD_FRACTION / maxWriteSize);
    val maxThrottleThreshold = (int) ((double) maxOutstandingBytes / maxWriteSize);
    val writeSettings = new WriteSettings(maxWriteSize, Duration.ofMillis(1234), maxOutstandingBytes);
    val thresholdMillis = (int) (writeSettings.getMaxWriteTimeout().toMillis() * ThrottlerPolicy.DURABLE_DATALOG_THROTTLE_THRESHOLD_FRACTION);
    val queueStats = new AtomicReference<QueueStats>(null);
    val tc = ThrottlerCalculator.builder().maxDelayMillis(DurableLogConfig.MAX_DELAY_MILLIS.getDefaultValue()).durableDataLogThrottler(writeSettings, queueStats::get, DurableLogConfig.MAX_DELAY_MILLIS.getDefaultValue()).build();
    val noThrottling = new QueueStats[] { createStats(1, halfRatio, thresholdMillis - 1), createStats(minThrottleThreshold + 1, 1.0, thresholdMillis), createStats(maxThrottleThreshold * 2, 1.0, thresholdMillis) };
    val gradualThrottling = new QueueStats[] { createStats((int) (minThrottleThreshold / halfRatio) + 2, halfRatio, thresholdMillis + 1), createStats((int) (minThrottleThreshold / halfRatio) + 10, halfRatio, thresholdMillis + 1), createStats((int) (maxOutstandingBytes / halfRatio), halfRatio, thresholdMillis + 1) };
    val maxThrottling = new QueueStats[] { createStats((int) (maxOutstandingBytes / halfRatio) + 1, halfRatio, thresholdMillis + 1), createStats((int) (maxOutstandingBytes / halfRatio) * 2, halfRatio, thresholdMillis + 1) };
    testThrottling(tc, queueStats, noThrottling, gradualThrottling, maxThrottling);
}
Also used : lombok.val(lombok.val) WriteSettings(io.pravega.segmentstore.storage.WriteSettings) AtomicReference(java.util.concurrent.atomic.AtomicReference) QueueStats(io.pravega.segmentstore.storage.QueueStats) Test(org.junit.Test)

Aggregations

QueueStats (io.pravega.segmentstore.storage.QueueStats)1 WriteSettings (io.pravega.segmentstore.storage.WriteSettings)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 lombok.val (lombok.val)1 Test (org.junit.Test)1