forked from I2P_Developers/i2p.i2p
handle corrupt files more gracefully
This commit is contained in:
@@ -33,57 +33,61 @@ class PeerSummaryReader {
|
|||||||
PeerSummary summary = null;
|
PeerSummary summary = null;
|
||||||
String curDescription = null;
|
String curDescription = null;
|
||||||
List curArgs = null;
|
List curArgs = null;
|
||||||
while ((line = reader.readLine()) != null) {
|
try {
|
||||||
if (line.startsWith("peer\t")) {
|
while ((line = reader.readLine()) != null) {
|
||||||
String name = line.substring("peer\t".length()).trim();
|
if (line.startsWith("peer\t")) {
|
||||||
summary = monitor.getSummary(name);
|
String name = line.substring("peer\t".length()).trim();
|
||||||
if (summary == null)
|
summary = monitor.getSummary(name);
|
||||||
summary = new PeerSummary(name);
|
if (summary == null)
|
||||||
} else if (line.startsWith("## ")) {
|
summary = new PeerSummary(name);
|
||||||
curDescription = line.substring("## ".length()).trim();
|
} else if (line.startsWith("## ")) {
|
||||||
curArgs = new ArrayList(4);
|
curDescription = line.substring("## ".length()).trim();
|
||||||
} else if (line.startsWith("# param ")) {
|
curArgs = new ArrayList(4);
|
||||||
int start = line.indexOf(':');
|
} else if (line.startsWith("# param ")) {
|
||||||
String arg = line.substring(start+1).trim();
|
int start = line.indexOf(':');
|
||||||
curArgs.add(arg);
|
String arg = line.substring(start+1).trim();
|
||||||
} else {
|
curArgs.add(arg);
|
||||||
StringTokenizer tok = new StringTokenizer(line);
|
} else {
|
||||||
String name = tok.nextToken();
|
StringTokenizer tok = new StringTokenizer(line);
|
||||||
try {
|
String name = tok.nextToken();
|
||||||
long when = getTime(tok.nextToken());
|
try {
|
||||||
boolean isDouble = false;
|
long when = getTime(tok.nextToken());
|
||||||
List argVals = new ArrayList(curArgs.size());
|
boolean isDouble = false;
|
||||||
while (tok.hasMoreTokens()) {
|
List argVals = new ArrayList(curArgs.size());
|
||||||
String val = (String)tok.nextToken();
|
while (tok.hasMoreTokens()) {
|
||||||
if (val.indexOf('.') >= 0) {
|
String val = (String)tok.nextToken();
|
||||||
argVals.add(new Double(val));
|
if (val.indexOf('.') >= 0) {
|
||||||
isDouble = true;
|
argVals.add(new Double(val));
|
||||||
} else {
|
isDouble = true;
|
||||||
argVals.add(new Long(val));
|
} else {
|
||||||
|
argVals.add(new Long(val));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
String valDescriptions[] = new String[curArgs.size()];
|
||||||
|
for (int i = 0; i < curArgs.size(); i++)
|
||||||
|
valDescriptions[i] = (String)curArgs.get(i);
|
||||||
|
if (isDouble) {
|
||||||
|
double values[] = new double[argVals.size()];
|
||||||
|
for (int i = 0; i < argVals.size(); i++)
|
||||||
|
values[i] = ((Double)argVals.get(i)).doubleValue();
|
||||||
|
summary.addData(name, curDescription, valDescriptions, when, values);
|
||||||
|
} else {
|
||||||
|
long values[] = new long[argVals.size()];
|
||||||
|
for (int i = 0; i < argVals.size(); i++)
|
||||||
|
values[i] = ((Long)argVals.get(i)).longValue();
|
||||||
|
summary.addData(name, curDescription, valDescriptions, when, values);
|
||||||
|
}
|
||||||
|
} catch (ParseException pe) {
|
||||||
|
_log.error("Error parsing the data line [" + line + "]", pe);
|
||||||
|
} catch (NumberFormatException nfe) {
|
||||||
|
_log.error("Error parsing the data line [" + line + "]", nfe);
|
||||||
}
|
}
|
||||||
String valDescriptions[] = new String[curArgs.size()];
|
|
||||||
for (int i = 0; i < curArgs.size(); i++)
|
|
||||||
valDescriptions[i] = (String)curArgs.get(i);
|
|
||||||
if (isDouble) {
|
|
||||||
double values[] = new double[argVals.size()];
|
|
||||||
for (int i = 0; i < argVals.size(); i++)
|
|
||||||
values[i] = ((Double)argVals.get(i)).doubleValue();
|
|
||||||
summary.addData(name, curDescription, valDescriptions, when, values);
|
|
||||||
} else {
|
|
||||||
long values[] = new long[argVals.size()];
|
|
||||||
for (int i = 0; i < argVals.size(); i++)
|
|
||||||
values[i] = ((Long)argVals.get(i)).longValue();
|
|
||||||
summary.addData(name, curDescription, valDescriptions, when, values);
|
|
||||||
}
|
|
||||||
} catch (ParseException pe) {
|
|
||||||
_log.error("Error parsing the data line [" + line + "]", pe);
|
|
||||||
} catch (NumberFormatException nfe) {
|
|
||||||
_log.error("Error parsing the data line [" + line + "]", nfe);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
_log.error("Error handling the data", e);
|
||||||
|
throw new IOException("Error parsing the data");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (summary == null)
|
if (summary == null)
|
||||||
return;
|
return;
|
||||||
summary.coallesceData(monitor.getSummaryDurationHours() * 60*60*1000);
|
summary.coallesceData(monitor.getSummaryDurationHours() * 60*60*1000);
|
||||||
|
Reference in New Issue
Block a user