@Test public void testGetEntityFromMetricStats() { String timeStamp = new Long(new Date().getTime()).toString(); List<RecordKeys> recordKeys = new ArrayList<>(); RecordKeys recordKey = new RecordKeysBuilder() .setKeyName(TSDRConstants.FLOW_TABLE_KEY_NAME) .setKeyValue("table1").build(); recordKeys.add(recordKey); TSDRMetricRecordBuilder builder1 = new TSDRMetricRecordBuilder(); final TSDRMetricRecord tsdrMetric1 = builder1.setMetricName("PacketsMatched") .setMetricValue(new BigDecimal(Double.parseDouble("20000000"))).setNodeID("node1") .setRecordKeys(recordKeys).setTSDRDataCategory(DataCategory.FLOWTABLESTATS) .setTimeStamp(new Long(timeStamp)).build(); HBasePersistenceUtil.getEntityFromMetricStats(null, DataCategory.FLOWTABLESTATS); HBasePersistenceUtil.getEntityFromMetricStats( builder1.setMetricName("PMD").setMetricValue(null).setNodeID("node2").build(), DataCategory.FLOWTABLESTATS); HBasePersistenceUtil.getEntityFromMetricStats( builder1.setMetricName("PMD").setMetricValue(new BigDecimal(Double.parseDouble("20000000"))) .setNodeID("node2").setTimeStamp(null).build(), DataCategory.FLOWTABLESTATS); HBaseEntity entity = HBasePersistenceUtil.getEntityFromMetricStats(tsdrMetric1, DataCategory.FLOWTABLESTATS); assertTrue(entity != null); }
public static HBaseEntity getEntityFromMetricStats(TSDRMetric metricData, DataCategory dataCategory) { LOG.debug("Entering getEntityFromMetricStats(TSDRMetric)"); if (!validateMetricInput(metricData)) { return null; } HBaseEntity entity = new HBaseEntity(); long timeStamp; if (metricData.getTimeStamp() != null) { timeStamp = metricData.getTimeStamp().longValue(); } else { timeStamp = System.currentTimeMillis(); } entity.setTableName(dataCategory.name()); entity.setRowKey(FormatUtil.getTSDRMetricKeyWithTimeStamp(metricData)); HBaseColumn column = new HBaseColumn(); column.setColumnFamily(TsdrHBaseDataStoreConstants.COLUMN_FAMILY_NAME); column.setColumnQualifier(TsdrHBaseDataStoreConstants.COLUMN_QUALIFIER_NAME); column.setTimeStamp(timeStamp); column.setValue(metricData.getMetricValue().toString()); List<HBaseColumn> columnList = new ArrayList<>(); columnList.add(column); entity.setColumns(columnList); LOG.debug("Exiting getEntityFromMetricStats(TSDRMetric)"); return entity; }
HBasePersistenceUtil { public static HBaseEntity getEntityFromMetricStats(TSDRMetric metricData, DataCategory dataCategory) { LOG.debug("Entering getEntityFromMetricStats(TSDRMetric)"); if (!validateMetricInput(metricData)) { return null; } HBaseEntity entity = new HBaseEntity(); long timeStamp; if (metricData.getTimeStamp() != null) { timeStamp = metricData.getTimeStamp().longValue(); } else { timeStamp = System.currentTimeMillis(); } entity.setTableName(dataCategory.name()); entity.setRowKey(FormatUtil.getTSDRMetricKeyWithTimeStamp(metricData)); HBaseColumn column = new HBaseColumn(); column.setColumnFamily(TsdrHBaseDataStoreConstants.COLUMN_FAMILY_NAME); column.setColumnQualifier(TsdrHBaseDataStoreConstants.COLUMN_QUALIFIER_NAME); column.setTimeStamp(timeStamp); column.setValue(metricData.getMetricValue().toString()); List<HBaseColumn> columnList = new ArrayList<>(); columnList.add(column); entity.setColumns(columnList); LOG.debug("Exiting getEntityFromMetricStats(TSDRMetric)"); return entity; } }
HBasePersistenceUtil { public static HBaseEntity getEntityFromMetricStats(TSDRMetric metricData, DataCategory dataCategory) { LOG.debug("Entering getEntityFromMetricStats(TSDRMetric)"); if (!validateMetricInput(metricData)) { return null; } HBaseEntity entity = new HBaseEntity(); long timeStamp; if (metricData.getTimeStamp() != null) { timeStamp = metricData.getTimeStamp().longValue(); } else { timeStamp = System.currentTimeMillis(); } entity.setTableName(dataCategory.name()); entity.setRowKey(FormatUtil.getTSDRMetricKeyWithTimeStamp(metricData)); HBaseColumn column = new HBaseColumn(); column.setColumnFamily(TsdrHBaseDataStoreConstants.COLUMN_FAMILY_NAME); column.setColumnQualifier(TsdrHBaseDataStoreConstants.COLUMN_QUALIFIER_NAME); column.setTimeStamp(timeStamp); column.setValue(metricData.getMetricValue().toString()); List<HBaseColumn> columnList = new ArrayList<>(); columnList.add(column); entity.setColumns(columnList); LOG.debug("Exiting getEntityFromMetricStats(TSDRMetric)"); return entity; } private  HBasePersistenceUtil(); }
HBasePersistenceUtil { public static HBaseEntity getEntityFromMetricStats(TSDRMetric metricData, DataCategory dataCategory) { LOG.debug("Entering getEntityFromMetricStats(TSDRMetric)"); if (!validateMetricInput(metricData)) { return null; } HBaseEntity entity = new HBaseEntity(); long timeStamp; if (metricData.getTimeStamp() != null) { timeStamp = metricData.getTimeStamp().longValue(); } else { timeStamp = System.currentTimeMillis(); } entity.setTableName(dataCategory.name()); entity.setRowKey(FormatUtil.getTSDRMetricKeyWithTimeStamp(metricData)); HBaseColumn column = new HBaseColumn(); column.setColumnFamily(TsdrHBaseDataStoreConstants.COLUMN_FAMILY_NAME); column.setColumnQualifier(TsdrHBaseDataStoreConstants.COLUMN_QUALIFIER_NAME); column.setTimeStamp(timeStamp); column.setValue(metricData.getMetricValue().toString()); List<HBaseColumn> columnList = new ArrayList<>(); columnList.add(column); entity.setColumns(columnList); LOG.debug("Exiting getEntityFromMetricStats(TSDRMetric)"); return entity; } private  HBasePersistenceUtil(); static HBaseEntity getEntityFromMetricStats(TSDRMetric metricData, DataCategory dataCategory); static HBaseEntity getEntityFromLogRecord(TSDRLogRecord logRecord, DataCategory dataCategory); static List<String> getTsdrHBaseTables(); }
HBasePersistenceUtil { public static HBaseEntity getEntityFromMetricStats(TSDRMetric metricData, DataCategory dataCategory) { LOG.debug("Entering getEntityFromMetricStats(TSDRMetric)"); if (!validateMetricInput(metricData)) { return null; } HBaseEntity entity = new HBaseEntity(); long timeStamp; if (metricData.getTimeStamp() != null) { timeStamp = metricData.getTimeStamp().longValue(); } else { timeStamp = System.currentTimeMillis(); } entity.setTableName(dataCategory.name()); entity.setRowKey(FormatUtil.getTSDRMetricKeyWithTimeStamp(metricData)); HBaseColumn column = new HBaseColumn(); column.setColumnFamily(TsdrHBaseDataStoreConstants.COLUMN_FAMILY_NAME); column.setColumnQualifier(TsdrHBaseDataStoreConstants.COLUMN_QUALIFIER_NAME); column.setTimeStamp(timeStamp); column.setValue(metricData.getMetricValue().toString()); List<HBaseColumn> columnList = new ArrayList<>(); columnList.add(column); entity.setColumns(columnList); LOG.debug("Exiting getEntityFromMetricStats(TSDRMetric)"); return entity; } private  HBasePersistenceUtil(); static HBaseEntity getEntityFromMetricStats(TSDRMetric metricData, DataCategory dataCategory); static HBaseEntity getEntityFromLogRecord(TSDRLogRecord logRecord, DataCategory dataCategory); static List<String> getTsdrHBaseTables();  }