int totalFreeNode = 0;
int totalUsedNode = 0;
int totalDownNode = 0;
String body = null;
ChukwaRecord record = null;
try {
String dStr = recordEntry.substring(0, 23);
int start = 24;
int idx = recordEntry.indexOf(' ', start);
// String level = recordEntry.substring(start, idx);
start = idx + 1;
idx = recordEntry.indexOf(' ', start);
// String className = recordEntry.substring(start, idx-1);
body = recordEntry.substring(idx + 1);
Date d = sdf.parse(dStr);
String[] lines = body.split("\n");
while (i < lines.length) {
while ((i < lines.length) && (lines[i].trim().length() > 0)) {
sb.append(lines[i].trim()).append("\n");
i++;
}
if ((i < lines.length) && (lines[i].trim().length() > 0)) {
throw new PbsInvalidEntry(recordEntry);
}
// Empty line
i++;
if (sb.length() > 0) {
body = sb.toString();
// Process all entries for a machine
// System.out.println("=========>>> Record [" + body+ "]");
record = new ChukwaRecord();
key = new ChukwaRecordKey();
buildGenericRecord(record, null, d.getTime(), machinePBSRecordType);
parsePbsRecord(body, record);
// Output PbsNode record for 1 machine
output.collect(key, record);
// log.info("PbsNodeProcessor output 1 sub-record");
// compute Node Activity information
nodeActivityStatus = record.getValue("state");
if (nodeActivityStatus != null) {
if (nodeActivityStatus.equals("free")) {
totalFreeNode++;
sbFreeMachines.append(record.getValue("Machine")).append(",");
} else if (nodeActivityStatus.equals("job-exclusive")) {
totalUsedNode++;
sbUsedMachines.append(record.getValue("Machine")).append(",");
} else {
totalDownNode++;
sbDownMachines.append(record.getValue("Machine")).append(",");
}
}
sb = new StringBuilder();
}
}
// End of parsing
record = new ChukwaRecord();
key = new ChukwaRecordKey();
buildGenericRecord(record, null, d.getTime(), "NodeActivity");
record.setTime(d.getTime());
record.add("used", "" + totalUsedNode);
record.add("free", "" + totalFreeNode);
record.add("down", "" + totalDownNode);
record.add("usedMachines", sbUsedMachines.toString());
record.add("freeMachines", sbFreeMachines.toString());
record.add("downMachines", sbDownMachines.toString());
output.collect(key, record);
// log.info("PbsNodeProcessor output 1 NodeActivity");
} catch (ParseException e) {
e.printStackTrace();