private void report(Map<TableId, HBaseTableUtil.TableStats> tableStats) throws IOException { Map<String, String> reverseNamespaceMap = hBaseTableUtil.getHBaseToCDAPNamespaceMap(); for (Map.Entry<TableId, HBaseTableUtil.TableStats> statEntry : tableStats.entrySet()) { String hbaseNamespace = statEntry.getKey().getNamespace(); String cdapNamespace = reverseNamespaceMap.get(hbaseNamespace); // emit metrics for only user datasets, namespaces in system and // tableNames that doesn't start with user are ignored if (NamespaceId.SYSTEM.getNamespace().equals(cdapNamespace)) { continue; } String tableName = statEntry.getKey().getTableName(); try { Collection<DatasetSpecificationSummary> instances = dsFramework.getInstances(new NamespaceId(cdapNamespace)); for (DatasetSpecificationSummary spec : instances) { DatasetSpecification specification = dsFramework.getDatasetSpec(new DatasetId(cdapNamespace, spec.getName())); if (specification.isParent(tableName)) { MetricsContext collector = metricsService.getContext(ImmutableMap.of(Constants.Metrics.Tag.NAMESPACE, cdapNamespace, Constants.Metrics.Tag.DATASET, spec.getName())); collector.gauge("dataset.size.mb", statEntry.getValue().getTotalSizeMB()); break; } } } catch (DatasetManagementException | ServiceUnavailableException e) { // No op } } } }
TableStats stat = datasetStat.get(tableId); if (stat == null) { stat = new TableStats(regionLoad.getStorefileSizeMB(), regionLoad.getMemStoreSizeMB()); datasetStat.put(tableId, stat); } else { stat.incStoreFileSizeMB(regionLoad.getStorefileSizeMB()); stat.incMemStoreSizeMB(regionLoad.getMemStoreSizeMB());
TableStats stat = datasetStat.get(tableId); if (stat == null) { stat = new TableStats(regionLoad.getStorefileSizeMB(), regionLoad.getMemStoreSizeMB()); datasetStat.put(tableId, stat); } else { stat.incStoreFileSizeMB(regionLoad.getStorefileSizeMB()); stat.incMemStoreSizeMB(regionLoad.getMemStoreSizeMB());
private void report(Map<TableId, HBaseTableUtil.TableStats> tableStats) throws IOException { Map<String, String> reverseNamespaceMap = hBaseTableUtil.getHBaseToCDAPNamespaceMap(); for (Map.Entry<TableId, HBaseTableUtil.TableStats> statEntry : tableStats.entrySet()) { String hbaseNamespace = statEntry.getKey().getNamespace(); String cdapNamespace = reverseNamespaceMap.get(hbaseNamespace); // emit metrics for only user datasets, namespaces in system and // tableNames that doesn't start with user are ignored if (NamespaceId.SYSTEM.getNamespace().equals(cdapNamespace)) { continue; } String tableName = statEntry.getKey().getTableName(); try { Collection<DatasetSpecificationSummary> instances = dsFramework.getInstances(new NamespaceId(cdapNamespace)); for (DatasetSpecificationSummary spec : instances) { DatasetSpecification specification = dsFramework.getDatasetSpec(new DatasetId(cdapNamespace, spec.getName())); if (specification.isParent(tableName)) { MetricsContext collector = metricsService.getContext(ImmutableMap.of(Constants.Metrics.Tag.NAMESPACE, cdapNamespace, Constants.Metrics.Tag.DATASET, spec.getName())); collector.gauge("dataset.size.mb", statEntry.getValue().getTotalSizeMB()); break; } } } catch (DatasetManagementException | ServiceUnavailableException e) { // No op } } } }
@Override public Boolean call() throws Exception { try { Assert.assertEquals(0, getTableStats("namespace", "table1").getTotalSizeMB()); Assert.assertTrue(getTableStats("namespace2", "table1").getTotalSizeMB() > 0); Assert.assertTrue(getTableStats("namespace", "table2").getTotalSizeMB() > 0); Assert.assertTrue(getTableStats("namespace", "table3").getTotalSizeMB() > 0); return true; } catch (Throwable t) { return false; } } }, 5, TimeUnit.SECONDS, 100, TimeUnit.MILLISECONDS);
@Override public Boolean call() throws Exception { try { Assert.assertEquals(0, getTableStats("namespace", "table1").getTotalSizeMB()); Assert.assertEquals(0, getTableStats("namespace2", "table1").getTotalSizeMB()); Assert.assertEquals(0, getTableStats("namespace", "table2").getTotalSizeMB()); Assert.assertEquals(0, getTableStats("namespace", "table3").getTotalSizeMB()); return true; } catch (Throwable t) { return false; } } }, 5, TimeUnit.SECONDS, 100, TimeUnit.MILLISECONDS);
@Override public Boolean call() throws Exception { try { Assert.assertNull(getTableStats("namespace", "table1")); Assert.assertTrue(getTableStats("namespace", "table2").getTotalSizeMB() > 0); Assert.assertTrue(getTableStats("namespace", "table2").getStoreFileSizeMB() > 0); Assert.assertEquals(0, getTableStats("namespace", "table3").getTotalSizeMB()); return true; } catch (Throwable t) { return false; } } }, 5, TimeUnit.SECONDS, 100, TimeUnit.MILLISECONDS);