public AzureFileSystemInstrumentation(Configuration conf) { fileSystemInstanceId = UUID.randomUUID(); registry.tag("wasbFileSystemId", "A unique identifier for the file ", fileSystemInstanceId.toString()); final int rollingWindowSizeInSeconds = conf.getInt(KEY_ROLLING_WINDOW_SIZE, DEFAULT_LATENCY_ROLLING_AVERAGE_WINDOW); averageBlockUploadLatencyMs = registry.newGauge( WASB_UPLOAD_LATENCY, String.format("The average latency in milliseconds of uploading a single block" + ". The average latency is calculated over a %d-second rolling" + " window.", rollingWindowSizeInSeconds), 0L); averageBlockDownloadLatencyMs = registry.newGauge( WASB_DOWNLOAD_LATENCY, String.format("The average latency in milliseconds of downloading a single block" + ". The average latency is calculated over a %d-second rolling" + " window.", rollingWindowSizeInSeconds), 0L); currentBlockUploadLatency = new RollingWindowAverage(rollingWindowSizeInSeconds * 1000); currentBlockDownloadLatency = new RollingWindowAverage(rollingWindowSizeInSeconds * 1000); }
public AzureFileSystemInstrumentation(Configuration conf) { fileSystemInstanceId = UUID.randomUUID(); registry.tag("wasbFileSystemId", "A unique identifier for the file ", fileSystemInstanceId.toString()); final int rollingWindowSizeInSeconds = conf.getInt(KEY_ROLLING_WINDOW_SIZE, DEFAULT_LATENCY_ROLLING_AVERAGE_WINDOW); averageBlockUploadLatencyMs = registry.newGauge( WASB_UPLOAD_LATENCY, String.format("The average latency in milliseconds of uploading a single block" + ". The average latency is calculated over a %d-second rolling" + " window.", rollingWindowSizeInSeconds), 0L); averageBlockDownloadLatencyMs = registry.newGauge( WASB_DOWNLOAD_LATENCY, String.format("The average latency in milliseconds of downloading a single block" + ". The average latency is calculated over a %d-second rolling" + " window.", rollingWindowSizeInSeconds), 0L); currentBlockUploadLatency = new RollingWindowAverage(rollingWindowSizeInSeconds * 1000); currentBlockDownloadLatency = new RollingWindowAverage(rollingWindowSizeInSeconds * 1000); }
/** * Tests the basic functionality of the class. */ @Test public void testBasicFunctionality() throws Exception { RollingWindowAverage average = new RollingWindowAverage(100); assertEquals(0, average.getCurrentAverage()); // Nothing there yet. average.addPoint(5); assertEquals(5, average.getCurrentAverage()); // One point in there. Thread.sleep(50); average.addPoint(15); assertEquals(10, average.getCurrentAverage()); // Two points in there. Thread.sleep(60); assertEquals(15, average.getCurrentAverage()); // One point retired. Thread.sleep(50); assertEquals(0, average.getCurrentAverage()); // Both points retired. } }
/** * Tests the basic functionality of the class. */ @Test public void testBasicFunctionality() throws Exception { RollingWindowAverage average = new RollingWindowAverage(100); assertEquals(0, average.getCurrentAverage()); // Nothing there yet. average.addPoint(5); assertEquals(5, average.getCurrentAverage()); // One point in there. Thread.sleep(50); average.addPoint(15); assertEquals(10, average.getCurrentAverage()); // Two points in there. Thread.sleep(60); assertEquals(15, average.getCurrentAverage()); // One point retired. Thread.sleep(50); assertEquals(0, average.getCurrentAverage()); // Both points retired. } }