Refactor debug logging into separate methods.

This commit is contained in:
Deklan Dieterly 2014-06-18 07:52:05 -06:00
parent 1b21a0ac5e
commit e49f06eeac
2 changed files with 72 additions and 56 deletions

View File

@ -98,18 +98,7 @@ public class InfluxDBAlarmRepository implements AlarmRepository {
serie.setColumns(this.colNamesStringArry);
if (logger.isDebugEnabled()) {
logger.debug("Added array of column names to serie");
StringBuffer sb = new StringBuffer();
boolean first = true;
for (String colName : serie.getColumns()) {
if (first) {
first = false;
} else {
sb.append(",");
}
sb.append(colName);
}
logger.debug("Array of column names: [" + sb.toString() + "]");
logColumnNames(serie);
}
Object[][] colValsObjectArry = new Object[this.alarmStateTransitionedEventList.size()][ALARM_STATE_HISTORY_NUM_COLUMNS];
@ -129,22 +118,7 @@ public class InfluxDBAlarmRepository implements AlarmRepository {
serie.setPoints(colValsObjectArry);
if (logger.isDebugEnabled()) {
logger.debug("Added array of array of column values to serie");
int outerIdx = 0;
for (Object[] colValArry : serie.getPoints()) {
StringBuffer sb = new StringBuffer();
boolean first = true;
for (Object colVal : colValArry) {
if (first) {
first = false;
} else {
sb.append(",");
}
sb.append(colVal);
}
logger.debug("Array of column values[{}]: [" + sb.toString() + "]", outerIdx);
outerIdx++;
}
logColValues(serie);
}
Serie[] series = {serie};
@ -161,4 +135,38 @@ public class InfluxDBAlarmRepository implements AlarmRepository {
this.alarmStateTransitionedEventList.clear();
}
private void logColValues(Serie serie) {
logger.debug("Added array of array of column values to serie");
int outerIdx = 0;
for (Object[] colValArry : serie.getPoints()) {
StringBuffer sb = new StringBuffer();
boolean first = true;
for (Object colVal : colValArry) {
if (first) {
first = false;
} else {
sb.append(",");
}
sb.append(colVal);
}
logger.debug("Array of column values[{}]: [" + sb.toString() + "]", outerIdx);
outerIdx++;
}
}
private void logColumnNames(Serie serie) {
logger.debug("Added array of column names to serie");
StringBuffer sb = new StringBuffer();
boolean first = true;
for (String colName : serie.getColumns()) {
if (first) {
first = false;
} else {
sb.append(",");
}
sb.append(colName);
}
logger.debug("Array of column names: [" + sb.toString() + "]");
}
}

View File

@ -151,18 +151,7 @@ public class InfluxDBMetricRepository implements MetricRepository {
serie.setColumns(colNameStringArry);
if (logger.isDebugEnabled()) {
logger.debug("Added array of column names to serie");
StringBuffer sb = new StringBuffer();
boolean first = true;
for (String colName : serie.getColumns()) {
if (first) {
first = false;
} else {
sb.append(",");
}
sb.append(colName);
}
logger.debug("Array of column names: [" + sb.toString() + "]");
logColNames(serie);
}
List<Point> pointList = dimNameSetMap.get(dimNameSet);
@ -199,22 +188,7 @@ public class InfluxDBMetricRepository implements MetricRepository {
serie.setPoints(colValsObjectArry);
if (logger.isDebugEnabled()) {
logger.debug("Added array of array of column values to serie");
int outerIdx = 0;
for (Object[] colValArry : serie.getPoints()) {
StringBuffer sb = new StringBuffer();
boolean first = true;
for (Object colVal : colValArry) {
if (first) {
first = false;
} else {
sb.append(",");
}
sb.append(colVal);
}
logger.debug("Array of column values[{}]: [" + sb.toString() + "]", outerIdx);
outerIdx++;
}
logColValues(serie);
}
}
@ -225,6 +199,40 @@ public class InfluxDBMetricRepository implements MetricRepository {
return series;
}
private void logColValues(Serie serie) {
logger.debug("Added array of array of column values to serie");
int outerIdx = 0;
for (Object[] colValArry : serie.getPoints()) {
StringBuffer sb = new StringBuffer();
boolean first = true;
for (Object colVal : colValArry) {
if (first) {
first = false;
} else {
sb.append(",");
}
sb.append(colVal);
}
logger.debug("Array of column values[{}]: [" + sb.toString() + "]", outerIdx);
outerIdx++;
}
}
private void logColNames(Serie serie) {
logger.debug("Added array of column names to serie");
StringBuffer sb = new StringBuffer();
boolean first = true;
for (String colName : serie.getColumns()) {
if (first) {
first = false;
} else {
sb.append(",");
}
sb.append(colName);
}
logger.debug("Array of column names: [" + sb.toString() + "]");
}
/**
* Group all measurements with the same dimension names into a list.
* Generate a map of definition id's to map of dimension name sets to list of points.