@Override public String blobStoreInfoAsString() { return String.format("Uploads - size = %s, count = %d%nDownloads - size = %s, count = %d", humanReadableByteCount(getUploadTotalSize()), getUploadCount(), humanReadableByteCount(getDownloadTotalSize()), getDownloadCount() ); }
@Override public CompositeData getUploadSizeHistory() { return getTimeSeriesData(BLOB_UPLOADS, "Blob Uploads (bytes)"); }
/** * BlobStore which are created by builder might get wrapped. * So here we perform any configuration and also access any * service exposed by the store * * @param blobStore store to config */ private void configureBlobStore(BlobStore blobStore) { if (blobStore instanceof AbstractBlobStore){ this.blobStoreStats = new BlobStoreStats(statisticsProvider); ((AbstractBlobStore) blobStore).setStatsCollector(blobStoreStats); } if (blobStore instanceof CachingBlobStore){ blobStoreCacheStats = ((CachingBlobStore) blobStore).getCacheStats(); } } }
@Test public void upload() throws Exception{ stats.uploaded(103, TimeUnit.SECONDS, 1079); assertEquals(103, stats.getUploadTotalSeconds()); assertEquals(1079, stats.getUploadTotalSize()); assertEquals(0, stats.getUploadCount()); stats.uploadCompleted("foo"); assertEquals(1, stats.getUploadCount()); stats.uploaded(53, TimeUnit.SECONDS, 47); assertEquals(103 + 53, stats.getUploadTotalSeconds()); assertEquals(1079 + 47, stats.getUploadTotalSize()); stats.uploadCompleted("foo"); assertEquals(2, stats.getUploadCount()); }
@Test public void download() throws Exception{ stats.downloaded("foo", 103, TimeUnit.SECONDS, 1079); assertEquals(103, stats.getDownloadTotalSeconds()); assertEquals(1079, stats.getDownloadTotalSize()); assertEquals(0, stats.getDownloadCount()); stats.downloadCompleted("foo"); assertEquals(1, stats.getDownloadCount()); stats.downloaded("foo", 53, TimeUnit.SECONDS, 47); assertEquals(103 + 53, stats.getDownloadTotalSeconds()); assertEquals(1079 + 47, stats.getDownloadTotalSize()); stats.downloadCompleted("foo"); assertEquals(2, stats.getDownloadCount()); } }
private CompositeData getTimeSeriesData(String name, String desc){ return TimeSeriesStatsUtil.asCompositeData(getTimeSeries(name), desc); }
public BlobStoreStats(@NotNull StatisticsProvider sp) { super(BlobStoreStatsMBean.class); this.statisticsProvider = checkNotNull(sp); this.uploadHisto = sp.getHistogram(BLOB_UPLOADS, StatsOptions.DEFAULT); this.uploadCount = sp.getMeter(BLOB_UPLOAD_COUNT, StatsOptions.DEFAULT); this.uploadSizeSeries = sp.getMeter("BLOB_UPLOAD_SIZE", StatsOptions.TIME_SERIES_ONLY); this.uploadTimeSeries = sp.getMeter("BLOB_UPLOAD_TIME", StatsOptions.TIME_SERIES_ONLY); this.uploadRateSeries = getAvgTimeSeries("BLOB_UPLOAD_SIZE", "BLOB_UPLOAD_TIME"); this.downloadHisto = sp.getHistogram(BLOB_DOWNLOADS, StatsOptions.DEFAULT); this.downloadCount = sp.getMeter(BLOB_DOWNLOAD_COUNT, StatsOptions.DEFAULT); this.downloadSizeSeries = sp.getMeter("BLOB_DOWNLOAD_SIZE", StatsOptions.TIME_SERIES_ONLY); this.downloadTimeSeries = sp.getMeter("BLOB_DOWNLOAD_TIME", StatsOptions.TIME_SERIES_ONLY); this.downloadRateSeries = getAvgTimeSeries("BLOB_DOWNLOAD_SIZE", "BLOB_DOWNLOAD_TIME"); }
/** * BlobStore which are created by builder might get wrapped. * So here we perform any configuration and also access any * service exposed by the store * * @param blobStore store to config */ private void configureBlobStore(BlobStore blobStore) { if (blobStore instanceof AbstractBlobStore){ this.blobStoreStats = new BlobStoreStats(statisticsProvider); ((AbstractBlobStore) blobStore).setStatsCollector(blobStoreStats); } if (blobStore instanceof CachingBlobStore){ blobStoreCacheStats = ((CachingBlobStore) blobStore).getCacheStats(); } } }
private CompositeData getTimeSeriesData(String name, String desc){ return TimeSeriesStatsUtil.asCompositeData(getTimeSeries(name), desc); }
public BlobStoreStats(@Nonnull StatisticsProvider sp) { super(BlobStoreStatsMBean.class); this.statisticsProvider = checkNotNull(sp); this.uploadHisto = sp.getHistogram(BLOB_UPLOADS, StatsOptions.DEFAULT); this.uploadCount = sp.getMeter(BLOB_UPLOAD_COUNT, StatsOptions.DEFAULT); this.uploadSizeSeries = sp.getMeter("BLOB_UPLOAD_SIZE", StatsOptions.TIME_SERIES_ONLY); this.uploadTimeSeries = sp.getMeter("BLOB_UPLOAD_TIME", StatsOptions.TIME_SERIES_ONLY); this.uploadRateSeries = getAvgTimeSeries("BLOB_UPLOAD_SIZE", "BLOB_UPLOAD_TIME"); this.downloadHisto = sp.getHistogram(BLOB_DOWNLOADS, StatsOptions.DEFAULT); this.downloadCount = sp.getMeter(BLOB_DOWNLOAD_COUNT, StatsOptions.DEFAULT); this.downloadSizeSeries = sp.getMeter("BLOB_DOWNLOAD_SIZE", StatsOptions.TIME_SERIES_ONLY); this.downloadTimeSeries = sp.getMeter("BLOB_DOWNLOAD_TIME", StatsOptions.TIME_SERIES_ONLY); this.downloadRateSeries = getAvgTimeSeries("BLOB_DOWNLOAD_SIZE", "BLOB_DOWNLOAD_TIME"); }
@Override public String blobStoreInfoAsString() { return String.format("Uploads - size = %s, count = %d%nDownloads - size = %s, count = %d", humanReadableByteCount(getUploadTotalSize()), getUploadCount(), humanReadableByteCount(getDownloadTotalSize()), getDownloadCount() ); }
@Override public BlobStore setUp() { fds = new FileDataStore(); fds.setMinRecordLength(4092); storeDir = new File(basedir, unique); fds.init(storeDir.getAbsolutePath()); configure(fds); DataStoreBlobStore bs = new DataStoreBlobStore(fds, true, fdsCacheInMB); bs.setBlobStatsCollector(new BlobStoreStats(statisticsProvider)); configure(bs); return bs; }
@Override public CompositeData getUploadCountHistory() { return getTimeSeriesData(BLOB_UPLOAD_COUNT, "Blob Upload Counts"); }
private CompositeData getTimeSeriesData(String name, String desc){ return TimeSeriesStatsUtil.asCompositeData(getTimeSeries(name), desc); }
public BlobStoreStats(@NotNull StatisticsProvider sp) { super(BlobStoreStatsMBean.class); this.statisticsProvider = checkNotNull(sp); this.uploadHisto = sp.getHistogram(BLOB_UPLOADS, StatsOptions.DEFAULT); this.uploadCount = sp.getMeter(BLOB_UPLOAD_COUNT, StatsOptions.DEFAULT); this.uploadSizeSeries = sp.getMeter("BLOB_UPLOAD_SIZE", StatsOptions.TIME_SERIES_ONLY); this.uploadTimeSeries = sp.getMeter("BLOB_UPLOAD_TIME", StatsOptions.TIME_SERIES_ONLY); this.uploadRateSeries = getAvgTimeSeries("BLOB_UPLOAD_SIZE", "BLOB_UPLOAD_TIME"); this.downloadHisto = sp.getHistogram(BLOB_DOWNLOADS, StatsOptions.DEFAULT); this.downloadCount = sp.getMeter(BLOB_DOWNLOAD_COUNT, StatsOptions.DEFAULT); this.downloadSizeSeries = sp.getMeter("BLOB_DOWNLOAD_SIZE", StatsOptions.TIME_SERIES_ONLY); this.downloadTimeSeries = sp.getMeter("BLOB_DOWNLOAD_TIME", StatsOptions.TIME_SERIES_ONLY); this.downloadRateSeries = getAvgTimeSeries("BLOB_DOWNLOAD_SIZE", "BLOB_DOWNLOAD_TIME"); }
@Override public String blobStoreInfoAsString() { return String.format("Uploads - size = %s, count = %d%nDownloads - size = %s, count = %d", humanReadableByteCount(getUploadTotalSize()), getUploadCount(), humanReadableByteCount(getDownloadTotalSize()), getDownloadCount() ); }
@Override public BlobStore setUp() { fds = new FileDataStore(); fds.setMinRecordLength(4092); storeDir = new File(basedir, unique); fds.init(storeDir.getAbsolutePath()); configure(fds); DataStoreBlobStore bs = new DataStoreBlobStore(fds, true, fdsCacheInMB); bs.setBlobStatsCollector(new BlobStoreStats(statisticsProvider)); configure(bs); return bs; }
@Override public CompositeData getUploadSizeHistory() { return getTimeSeriesData(BLOB_UPLOADS, "Blob Uploads (bytes)"); }
private TimeSeries getAvgTimeSeries(String nameValue, String nameCounter){ return new TimeSeriesAverage(getTimeSeries(nameValue), new UnitConvertingTimeSeries(getTimeSeries(nameCounter), recordedTimeUnit, TimeUnit.SECONDS)); }
ds.init(homeDir); BlobStoreStats stats = new BlobStoreStats(getStatisticsProvider()); this.dataStore = new DataStoreBlobStore(ds, encodeLengthInId, cacheSizeInMB); this.dataStore.setBlobStatsCollector(stats);