/** * Gets the current value of the wasb_web_responses counter. */ private long getCurrentWebResponses() { return AzureMetricsTestUtil.getCurrentWebResponses(getInstrumentation()); }
/** * Gets the current value of the wasb_raw_bytes_downloaded counter. */ public static long getCurrentTotalBytesRead( AzureFileSystemInstrumentation instrumentation) { return getLongCounterValue(instrumentation, WASB_RAW_BYTES_DOWNLOADED); }
/** * Gets the current value of the wasb_bytes_written_last_second counter. */ public static long getCurrentBytesWritten(AzureFileSystemInstrumentation instrumentation) { return getLongGaugeValue(instrumentation, WASB_BYTES_WRITTEN); }
long base = getBaseWebResponses(); assertEquals(0, AzureMetricsTestUtil.getCurrentBytesWritten(getInstrumentation())); base = assertWebResponsesInRange(base, 20, 50); getBandwidthGaugeUpdater().triggerUpdate(true); long totalBytesWritten = AzureMetricsTestUtil.getCurrentTotalBytesWritten(getInstrumentation()); assertTrue("The total bytes written " + totalBytesWritten + " is pretty far from the expected range of around " + FILE_SIZE + " bytes plus a little overhead.", totalBytesWritten >= FILE_SIZE && totalBytesWritten < (FILE_SIZE * 2)); long uploadRate = AzureMetricsTestUtil.getLongGaugeValue(getInstrumentation(), WASB_UPLOAD_RATE); System.out.println("Upload rate: " + uploadRate + " bytes/second."); long uploadLatency = AzureMetricsTestUtil.getLongGaugeValue(getInstrumentation(), WASB_UPLOAD_LATENCY); System.out.println("Upload latency: " + uploadLatency); base = assertWebResponsesInRange(base, 20, 40); getBandwidthGaugeUpdater().triggerUpdate(false); long totalBytesRead = AzureMetricsTestUtil.getCurrentTotalBytesRead(getInstrumentation()); assertEquals(FILE_SIZE, totalBytesRead); long downloadRate = AzureMetricsTestUtil.getLongGaugeValue(getInstrumentation(), WASB_DOWNLOAD_RATE); System.out.println("Download rate: " + downloadRate + " bytes/second."); long downloadLatency = AzureMetricsTestUtil.getLongGaugeValue(getInstrumentation(), WASB_DOWNLOAD_LATENCY); System.out.println("Download latency: " + downloadLatency);
@Test public void testSingleThreaded() throws Exception { AzureFileSystemInstrumentation instrumentation = new AzureFileSystemInstrumentation(new Configuration()); BandwidthGaugeUpdater updater = new BandwidthGaugeUpdater(instrumentation, 1000, true); updater.triggerUpdate(true); assertEquals(0, AzureMetricsTestUtil.getCurrentBytesWritten(instrumentation)); updater.blockUploaded(new Date(), new Date(), 150); updater.triggerUpdate(true); assertEquals(150, AzureMetricsTestUtil.getCurrentBytesWritten(instrumentation)); updater.blockUploaded(new Date(new Date().getTime() - 10000), new Date(), 200); updater.triggerUpdate(true); long currentBytes = AzureMetricsTestUtil.getCurrentBytesWritten(instrumentation); assertTrue( "We expect around (200/10 = 20) bytes written as the gauge value." + "Got " + currentBytes, currentBytes > 18 && currentBytes < 22); updater.close(); }
@Test public void testMultiThreaded() throws Exception { final AzureFileSystemInstrumentation instrumentation = new AzureFileSystemInstrumentation(new Configuration()); final BandwidthGaugeUpdater updater = new BandwidthGaugeUpdater(instrumentation, 1000, true); Thread[] threads = new Thread[10]; for (int i = 0; i < threads.length; i++) { threads[i] = new Thread(new Runnable() { @Override public void run() { updater.blockDownloaded(new Date(), new Date(), 10); updater.blockDownloaded(new Date(0), new Date(0), 10); } }); } for (Thread t : threads) { t.start(); } for (Thread t : threads) { t.join(); } updater.triggerUpdate(false); assertEquals(10 * threads.length, AzureMetricsTestUtil.getCurrentBytesRead(instrumentation)); updater.close(); } }
assertEquals(0, AzureMetricsTestUtil.getCurrentBytesWritten(getInstrumentation())); base = assertWebResponsesInRange(base, 2, 15); getBandwidthGaugeUpdater().triggerUpdate(true); long bytesWritten = AzureMetricsTestUtil.getCurrentBytesWritten(getInstrumentation()); assertTrue("The bytes written in the last second " + bytesWritten + " is pretty far from the expected range of around " + FILE_SIZE + " bytes plus a little overhead.", bytesWritten > (FILE_SIZE / 2) && bytesWritten < (FILE_SIZE * 2)); long totalBytesWritten = AzureMetricsTestUtil.getCurrentTotalBytesWritten(getInstrumentation()); assertTrue("The total bytes written " + totalBytesWritten + " is pretty far from the expected range of around " + FILE_SIZE + " bytes plus a little overhead.", totalBytesWritten >= FILE_SIZE && totalBytesWritten < (FILE_SIZE * 2)); long uploadRate = AzureMetricsTestUtil.getLongGaugeValue(getInstrumentation(), WASB_UPLOAD_RATE); System.out.println("Upload rate: " + uploadRate + " bytes/second."); long expectedRate = (FILE_SIZE * 1000L) / uploadDurationMs; " end-to-end time instead of just block upload time.", uploadRate >= expectedRate); long uploadLatency = AzureMetricsTestUtil.getLongGaugeValue(getInstrumentation(), WASB_UPLOAD_LATENCY); System.out.println("Upload latency: " + uploadLatency); base = assertWebResponsesInRange(base, 1, 10); getBandwidthGaugeUpdater().triggerUpdate(false); long totalBytesRead = AzureMetricsTestUtil.getCurrentTotalBytesRead(getInstrumentation()); assertEquals(FILE_SIZE, totalBytesRead); long bytesRead = AzureMetricsTestUtil.getCurrentBytesRead(getInstrumentation());
@Test public void testSingleThreaded() throws Exception { AzureFileSystemInstrumentation instrumentation = new AzureFileSystemInstrumentation(new Configuration()); BandwidthGaugeUpdater updater = new BandwidthGaugeUpdater(instrumentation, 1000, true); updater.triggerUpdate(true); assertEquals(0, AzureMetricsTestUtil.getCurrentBytesWritten(instrumentation)); updater.blockUploaded(new Date(), new Date(), 150); updater.triggerUpdate(true); assertEquals(150, AzureMetricsTestUtil.getCurrentBytesWritten(instrumentation)); updater.blockUploaded(new Date(new Date().getTime() - 10000), new Date(), 200); updater.triggerUpdate(true); long currentBytes = AzureMetricsTestUtil.getCurrentBytesWritten(instrumentation); assertTrue( "We expect around (200/10 = 20) bytes written as the gauge value." + "Got " + currentBytes, currentBytes > 18 && currentBytes < 22); updater.close(); }
@Test public void testMultiThreaded() throws Exception { final AzureFileSystemInstrumentation instrumentation = new AzureFileSystemInstrumentation(new Configuration()); final BandwidthGaugeUpdater updater = new BandwidthGaugeUpdater(instrumentation, 1000, true); Thread[] threads = new Thread[10]; for (int i = 0; i < threads.length; i++) { threads[i] = new Thread(new Runnable() { @Override public void run() { updater.blockDownloaded(new Date(), new Date(), 10); updater.blockDownloaded(new Date(0), new Date(0), 10); } }); } for (Thread t : threads) { t.start(); } for (Thread t : threads) { t.join(); } updater.triggerUpdate(false); assertEquals(10 * threads.length, AzureMetricsTestUtil.getCurrentBytesRead(instrumentation)); updater.close(); } }
long base = getBaseWebResponses(); assertEquals(0, AzureMetricsTestUtil.getCurrentBytesWritten(getInstrumentation())); base = assertWebResponsesInRange(base, 20, 50); getBandwidthGaugeUpdater().triggerUpdate(true); long totalBytesWritten = AzureMetricsTestUtil.getCurrentTotalBytesWritten(getInstrumentation()); assertTrue("The total bytes written " + totalBytesWritten + " is pretty far from the expected range of around " + FILE_SIZE + " bytes plus a little overhead.", totalBytesWritten >= FILE_SIZE && totalBytesWritten < (FILE_SIZE * 2)); long uploadRate = AzureMetricsTestUtil.getLongGaugeValue(getInstrumentation(), WASB_UPLOAD_RATE); LOG.info("Upload rate: " + uploadRate + " bytes/second."); long uploadLatency = AzureMetricsTestUtil.getLongGaugeValue(getInstrumentation(), WASB_UPLOAD_LATENCY); LOG.info("Upload latency: " + uploadLatency); base = assertWebResponsesInRange(base, 20, 40); getBandwidthGaugeUpdater().triggerUpdate(false); long totalBytesRead = AzureMetricsTestUtil.getCurrentTotalBytesRead(getInstrumentation()); assertEquals(FILE_SIZE, totalBytesRead); long downloadRate = AzureMetricsTestUtil.getLongGaugeValue(getInstrumentation(), WASB_DOWNLOAD_RATE); LOG.info("Download rate: " + downloadRate + " bytes/second."); long downloadLatency = AzureMetricsTestUtil.getLongGaugeValue(getInstrumentation(), WASB_DOWNLOAD_LATENCY); LOG.info("Download latency: " + downloadLatency);
/** * Gets the current value of the wasb_raw_bytes_downloaded counter. */ public static long getCurrentTotalBytesRead( AzureFileSystemInstrumentation instrumentation) { return getLongCounterValue(instrumentation, WASB_RAW_BYTES_DOWNLOADED); }
/** * Gets the current value of the wasb_bytes_written_last_second counter. */ public static long getCurrentBytesWritten(AzureFileSystemInstrumentation instrumentation) { return getLongGaugeValue(instrumentation, WASB_BYTES_WRITTEN); }
/** * Gets the current value of the wasb_web_responses counter. */ private long getCurrentWebResponses() { return AzureMetricsTestUtil.getCurrentWebResponses(getInstrumentation()); }
assertEquals(0, AzureMetricsTestUtil.getCurrentBytesWritten(getInstrumentation())); base = assertWebResponsesInRange(base, 2, 15); getBandwidthGaugeUpdater().triggerUpdate(true); long bytesWritten = AzureMetricsTestUtil.getCurrentBytesWritten(getInstrumentation()); assertTrue("The bytes written in the last second " + bytesWritten + " is pretty far from the expected range of around " + FILE_SIZE + " bytes plus a little overhead.", bytesWritten > (FILE_SIZE / 2) && bytesWritten < (FILE_SIZE * 2)); long totalBytesWritten = AzureMetricsTestUtil.getCurrentTotalBytesWritten(getInstrumentation()); assertTrue("The total bytes written " + totalBytesWritten + " is pretty far from the expected range of around " + FILE_SIZE + " bytes plus a little overhead.", totalBytesWritten >= FILE_SIZE && totalBytesWritten < (FILE_SIZE * 2)); long uploadRate = AzureMetricsTestUtil.getLongGaugeValue(getInstrumentation(), WASB_UPLOAD_RATE); LOG.info("Upload rate: " + uploadRate + " bytes/second."); long expectedRate = (FILE_SIZE * 1000L) / uploadDurationMs; " end-to-end time instead of just block upload time.", uploadRate >= expectedRate); long uploadLatency = AzureMetricsTestUtil.getLongGaugeValue(getInstrumentation(), WASB_UPLOAD_LATENCY); LOG.info("Upload latency: {}", uploadLatency); base = assertWebResponsesInRange(base, 1, 10); getBandwidthGaugeUpdater().triggerUpdate(false); long totalBytesRead = AzureMetricsTestUtil.getCurrentTotalBytesRead(getInstrumentation()); assertEquals(FILE_SIZE, totalBytesRead); long bytesRead = AzureMetricsTestUtil.getCurrentBytesRead(getInstrumentation());
/** * Gets the current value of the wasb_raw_bytes_uploaded counter. */ public static long getCurrentTotalBytesWritten( AzureFileSystemInstrumentation instrumentation) { return getLongCounterValue(instrumentation, WASB_RAW_BYTES_UPLOADED); }
/** * Gets the current value of the wasb_bytes_read_last_second counter. */ public static long getCurrentBytesRead(AzureFileSystemInstrumentation instrumentation) { return getLongGaugeValue(instrumentation, WASB_BYTES_READ); }
/** * Gets the current value of the wasb_raw_bytes_uploaded counter. */ public static long getCurrentTotalBytesWritten( AzureFileSystemInstrumentation instrumentation) { return getLongCounterValue(instrumentation, WASB_RAW_BYTES_UPLOADED); }
/** * Gets the current value of the wasb_bytes_read_last_second counter. */ public static long getCurrentBytesRead(AzureFileSystemInstrumentation instrumentation) { return getLongGaugeValue(instrumentation, WASB_BYTES_READ); }
private void assertNoErrors() { assertEquals(0, AzureMetricsTestUtil.getLongCounterValue(getInstrumentation(), WASB_CLIENT_ERRORS)); assertEquals(0, AzureMetricsTestUtil.getLongCounterValue(getInstrumentation(), WASB_SERVER_ERRORS)); }
private void assertNoErrors() { assertEquals(0, AzureMetricsTestUtil.getLongCounterValue(getInstrumentation(), WASB_CLIENT_ERRORS)); assertEquals(0, AzureMetricsTestUtil.getLongCounterValue(getInstrumentation(), WASB_SERVER_ERRORS)); }