@Override public void run() { updater.blockDownloaded(new Date(), new Date(), 10); updater.blockDownloaded(new Date(0), new Date(0), 10); } });
@Override public void close() { if (bandwidthGaugeUpdater != null) { bandwidthGaugeUpdater.close(); bandwidthGaugeUpdater = null; } }
@Override public void run() { try { while (true) { Thread.sleep(windowSizeMs); if (!suppressAutoUpdate) { triggerUpdate(true); triggerUpdate(false); } } } catch (InterruptedException e) { } } }
@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(); } }
getBandwidthGaugeUpdater().suppressAutoUpdate(); getBandwidthGaugeUpdater().triggerUpdate(true); long totalBytesWritten = AzureMetricsTestUtil.getCurrentTotalBytesWritten(getInstrumentation()); assertTrue("The total bytes written " + totalBytesWritten + getBandwidthGaugeUpdater().triggerUpdate(false); long totalBytesRead = AzureMetricsTestUtil.getCurrentTotalBytesRead(getInstrumentation()); assertEquals(FILE_SIZE, totalBytesRead);
blockUploadGaugeUpdater.blockUploaded( currentResult.getStartDate(), currentResult.getStopDate(), blockUploadGaugeUpdater.blockDownloaded( currentResult.getStartDate(), currentResult.getStopDate(),
if (updateWrite && !allBlocksWritten.isEmpty()) { toProcess = allBlocksWritten; allBlocksWritten = createNewToProcessQueue(); } else if (!updateWrite && !allBlocksRead.isEmpty()) { toProcess = allBlocksRead; allBlocksRead = createNewToProcessQueue(); updateBytesTransferred(updateWrite, 0); updateBytesTransferRate(updateWrite, 0); return; Math.max(maxSingleBlockTransferRate, currentBlockTransferRate); updateBytesTransferred(updateWrite, bytesInLastSecond); long maxObservedTransferRate = Math.max(aggregateTransferRate, maxSingleBlockTransferRate); updateBytesTransferRate(updateWrite, maxObservedTransferRate);
NativeAzureFileSystem.SKIP_AZURE_METRICS_PROPERTY_NAME, false)) { this.bandwidthGaugeUpdater = new BandwidthGaugeUpdater(instrumentation);
@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(); } }
getBandwidthGaugeUpdater().suppressAutoUpdate(); getBandwidthGaugeUpdater().triggerUpdate(true); long bytesWritten = AzureMetricsTestUtil.getCurrentBytesWritten(getInstrumentation()); assertTrue("The bytes written in the last second " + bytesWritten + getBandwidthGaugeUpdater().triggerUpdate(false); long totalBytesRead = AzureMetricsTestUtil.getCurrentTotalBytesRead(getInstrumentation()); assertEquals(FILE_SIZE, totalBytesRead);
blockUploadGaugeUpdater.blockUploaded( currentResult.getStartDate(), currentResult.getStopDate(), blockUploadGaugeUpdater.blockDownloaded( currentResult.getStartDate(), currentResult.getStopDate(),
if (updateWrite && !allBlocksWritten.isEmpty()) { toProcess = allBlocksWritten; allBlocksWritten = createNewToProcessQueue(); } else if (!updateWrite && !allBlocksRead.isEmpty()) { toProcess = allBlocksRead; allBlocksRead = createNewToProcessQueue(); updateBytesTransferred(updateWrite, 0); updateBytesTransferRate(updateWrite, 0); return; Math.max(maxSingleBlockTransferRate, currentBlockTransferRate); updateBytesTransferred(updateWrite, bytesInLastSecond); long maxObservedTransferRate = Math.max(aggregateTransferRate, maxSingleBlockTransferRate); updateBytesTransferRate(updateWrite, maxObservedTransferRate);
NativeAzureFileSystem.SKIP_AZURE_METRICS_PROPERTY_NAME, false)) { this.bandwidthGaugeUpdater = new BandwidthGaugeUpdater(instrumentation);
getBandwidthGaugeUpdater().suppressAutoUpdate(); getBandwidthGaugeUpdater().triggerUpdate(true); long totalBytesWritten = AzureMetricsTestUtil.getCurrentTotalBytesWritten(getInstrumentation()); assertTrue("The total bytes written " + totalBytesWritten + getBandwidthGaugeUpdater().triggerUpdate(false); long totalBytesRead = AzureMetricsTestUtil.getCurrentTotalBytesRead(getInstrumentation()); assertEquals(FILE_SIZE, totalBytesRead);
@Override public void close() { if(bandwidthGaugeUpdater != null) { bandwidthGaugeUpdater.close(); bandwidthGaugeUpdater = null; } }
@Override public void run() { updater.blockDownloaded(new Date(), new Date(), 10); updater.blockDownloaded(new Date(0), new Date(0), 10); } });
@Override public void run() { try { while (true) { Thread.sleep(windowSizeMs); if (!suppressAutoUpdate) { triggerUpdate(true); triggerUpdate(false); } } } catch (InterruptedException e) { } } }
getBandwidthGaugeUpdater().suppressAutoUpdate(); getBandwidthGaugeUpdater().triggerUpdate(true); long bytesWritten = AzureMetricsTestUtil.getCurrentBytesWritten(getInstrumentation()); assertTrue("The bytes written in the last second " + bytesWritten + getBandwidthGaugeUpdater().triggerUpdate(false); long totalBytesRead = AzureMetricsTestUtil.getCurrentTotalBytesRead(getInstrumentation()); assertEquals(FILE_SIZE, totalBytesRead);