@Test public void testGetEntityFromLogRecord() { final String timeStamp = new Long(new Date().getTime()).toString(); List<RecordKeys> recordKeys = new ArrayList<>(); RecordKeys recordKey1 = new RecordKeysBuilder() .setKeyName(DataCategory.SYSLOG.name()) .setKeyValue("log1").build(); recordKeys.add(recordKey1); TSDRLogRecordBuilder builder1 = new TSDRLogRecordBuilder(); List<RecordAttributes> value = new ArrayList<>(); value.add(mock(RecordAttributes.class)); value.add(mock(RecordAttributes.class)); TSDRLogRecord tsdrLog1 = builder1.setIndex(1) .setRecordFullText("su root failed for lonvick") .setNodeID("node1.example.com") .setRecordKeys(recordKeys) .setTSDRDataCategory(DataCategory.SYSLOG) .setRecordAttributes(value) .setTimeStamp(new Long(timeStamp)).build(); HBasePersistenceUtil.getEntityFromLogRecord(null, DataCategory.SYSLOG); HBasePersistenceUtil.getEntityFromLogRecord(builder1.setNodeID("node1.example.com") .setTimeStamp(null).build(), DataCategory.SYSLOG); HBaseEntity entity = HBasePersistenceUtil.getEntityFromLogRecord(tsdrLog1, DataCategory.SYSLOG); assertTrue(entity != null); }
public static HBaseEntity getEntityFromLogRecord(TSDRLogRecord logRecord, DataCategory dataCategory) { LOG.debug("Entering getEntityFromLogRecord(TSDRLogRecord)"); if (!validateLogRecordInput(logRecord)) { return null; } HBaseEntity entity = new HBaseEntity(); long timeStamp; if (logRecord.getTimeStamp() != null) { timeStamp = logRecord.getTimeStamp().longValue(); } else { timeStamp = System.currentTimeMillis(); } entity.setTableName(dataCategory.name()); entity.setRowKey(FormatUtil.getTSDRLogKeyWithTimeStamp(logRecord)); List<HBaseColumn> columnList = new ArrayList<>(); List<RecordAttributes> attributes = logRecord.getRecordAttributes(); if (attributes != null && attributes.size() != 0) { for (RecordAttributes attribute : attributes) { HBaseColumn column = new HBaseColumn(); column.setColumnFamily(TsdrHBaseDataStoreConstants.COLUMN_FAMILY_NAME); column.setTimeStamp(timeStamp); column.setColumnQualifier(attribute.getName()); column.setValue(attribute.getValue()); columnList.add(column); } } HBaseColumn column = new HBaseColumn(); column.setColumnFamily(TsdrHBaseDataStoreConstants.COLUMN_FAMILY_NAME); column.setTimeStamp(timeStamp); column.setColumnQualifier(TsdrHBaseDataStoreConstants.LOGRECORD_FULL_TEXT); column.setValue(logRecord.getRecordFullText()); columnList.add(column); entity.setColumns(columnList); LOG.debug("Exiting getEntityFromLogRecord(TSDRLogRecord)"); return entity; }
HBasePersistenceUtil { public static HBaseEntity getEntityFromLogRecord(TSDRLogRecord logRecord, DataCategory dataCategory) { LOG.debug("Entering getEntityFromLogRecord(TSDRLogRecord)"); if (!validateLogRecordInput(logRecord)) { return null; } HBaseEntity entity = new HBaseEntity(); long timeStamp; if (logRecord.getTimeStamp() != null) { timeStamp = logRecord.getTimeStamp().longValue(); } else { timeStamp = System.currentTimeMillis(); } entity.setTableName(dataCategory.name()); entity.setRowKey(FormatUtil.getTSDRLogKeyWithTimeStamp(logRecord)); List<HBaseColumn> columnList = new ArrayList<>(); List<RecordAttributes> attributes = logRecord.getRecordAttributes(); if (attributes != null && attributes.size() != 0) { for (RecordAttributes attribute : attributes) { HBaseColumn column = new HBaseColumn(); column.setColumnFamily(TsdrHBaseDataStoreConstants.COLUMN_FAMILY_NAME); column.setTimeStamp(timeStamp); column.setColumnQualifier(attribute.getName()); column.setValue(attribute.getValue()); columnList.add(column); } } HBaseColumn column = new HBaseColumn(); column.setColumnFamily(TsdrHBaseDataStoreConstants.COLUMN_FAMILY_NAME); column.setTimeStamp(timeStamp); column.setColumnQualifier(TsdrHBaseDataStoreConstants.LOGRECORD_FULL_TEXT); column.setValue(logRecord.getRecordFullText()); columnList.add(column); entity.setColumns(columnList); LOG.debug("Exiting getEntityFromLogRecord(TSDRLogRecord)"); return entity; } }
HBasePersistenceUtil { public static HBaseEntity getEntityFromLogRecord(TSDRLogRecord logRecord, DataCategory dataCategory) { LOG.debug("Entering getEntityFromLogRecord(TSDRLogRecord)"); if (!validateLogRecordInput(logRecord)) { return null; } HBaseEntity entity = new HBaseEntity(); long timeStamp; if (logRecord.getTimeStamp() != null) { timeStamp = logRecord.getTimeStamp().longValue(); } else { timeStamp = System.currentTimeMillis(); } entity.setTableName(dataCategory.name()); entity.setRowKey(FormatUtil.getTSDRLogKeyWithTimeStamp(logRecord)); List<HBaseColumn> columnList = new ArrayList<>(); List<RecordAttributes> attributes = logRecord.getRecordAttributes(); if (attributes != null && attributes.size() != 0) { for (RecordAttributes attribute : attributes) { HBaseColumn column = new HBaseColumn(); column.setColumnFamily(TsdrHBaseDataStoreConstants.COLUMN_FAMILY_NAME); column.setTimeStamp(timeStamp); column.setColumnQualifier(attribute.getName()); column.setValue(attribute.getValue()); columnList.add(column); } } HBaseColumn column = new HBaseColumn(); column.setColumnFamily(TsdrHBaseDataStoreConstants.COLUMN_FAMILY_NAME); column.setTimeStamp(timeStamp); column.setColumnQualifier(TsdrHBaseDataStoreConstants.LOGRECORD_FULL_TEXT); column.setValue(logRecord.getRecordFullText()); columnList.add(column); entity.setColumns(columnList); LOG.debug("Exiting getEntityFromLogRecord(TSDRLogRecord)"); return entity; } private  HBasePersistenceUtil(); }
HBasePersistenceUtil { public static HBaseEntity getEntityFromLogRecord(TSDRLogRecord logRecord, DataCategory dataCategory) { LOG.debug("Entering getEntityFromLogRecord(TSDRLogRecord)"); if (!validateLogRecordInput(logRecord)) { return null; } HBaseEntity entity = new HBaseEntity(); long timeStamp; if (logRecord.getTimeStamp() != null) { timeStamp = logRecord.getTimeStamp().longValue(); } else { timeStamp = System.currentTimeMillis(); } entity.setTableName(dataCategory.name()); entity.setRowKey(FormatUtil.getTSDRLogKeyWithTimeStamp(logRecord)); List<HBaseColumn> columnList = new ArrayList<>(); List<RecordAttributes> attributes = logRecord.getRecordAttributes(); if (attributes != null && attributes.size() != 0) { for (RecordAttributes attribute : attributes) { HBaseColumn column = new HBaseColumn(); column.setColumnFamily(TsdrHBaseDataStoreConstants.COLUMN_FAMILY_NAME); column.setTimeStamp(timeStamp); column.setColumnQualifier(attribute.getName()); column.setValue(attribute.getValue()); columnList.add(column); } } HBaseColumn column = new HBaseColumn(); column.setColumnFamily(TsdrHBaseDataStoreConstants.COLUMN_FAMILY_NAME); column.setTimeStamp(timeStamp); column.setColumnQualifier(TsdrHBaseDataStoreConstants.LOGRECORD_FULL_TEXT); column.setValue(logRecord.getRecordFullText()); columnList.add(column); entity.setColumns(columnList); LOG.debug("Exiting getEntityFromLogRecord(TSDRLogRecord)"); 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 getEntityFromLogRecord(TSDRLogRecord logRecord, DataCategory dataCategory) { LOG.debug("Entering getEntityFromLogRecord(TSDRLogRecord)"); if (!validateLogRecordInput(logRecord)) { return null; } HBaseEntity entity = new HBaseEntity(); long timeStamp; if (logRecord.getTimeStamp() != null) { timeStamp = logRecord.getTimeStamp().longValue(); } else { timeStamp = System.currentTimeMillis(); } entity.setTableName(dataCategory.name()); entity.setRowKey(FormatUtil.getTSDRLogKeyWithTimeStamp(logRecord)); List<HBaseColumn> columnList = new ArrayList<>(); List<RecordAttributes> attributes = logRecord.getRecordAttributes(); if (attributes != null && attributes.size() != 0) { for (RecordAttributes attribute : attributes) { HBaseColumn column = new HBaseColumn(); column.setColumnFamily(TsdrHBaseDataStoreConstants.COLUMN_FAMILY_NAME); column.setTimeStamp(timeStamp); column.setColumnQualifier(attribute.getName()); column.setValue(attribute.getValue()); columnList.add(column); } } HBaseColumn column = new HBaseColumn(); column.setColumnFamily(TsdrHBaseDataStoreConstants.COLUMN_FAMILY_NAME); column.setTimeStamp(timeStamp); column.setColumnQualifier(TsdrHBaseDataStoreConstants.LOGRECORD_FULL_TEXT); column.setValue(logRecord.getRecordFullText()); columnList.add(column); entity.setColumns(columnList); LOG.debug("Exiting getEntityFromLogRecord(TSDRLogRecord)"); return entity; } private  HBasePersistenceUtil(); static HBaseEntity getEntityFromMetricStats(TSDRMetric metricData, DataCategory dataCategory); static HBaseEntity getEntityFromLogRecord(TSDRLogRecord logRecord, DataCategory dataCategory); static List<String> getTsdrHBaseTables();  }