try {
String command = prepareCommand(config, params, inputFile, outputFile, time);
IRunner runner = makeRunner(command, config);
RunInfo r = runner.run();
result.setSuccessful(r.isSuccess());
result.setReport(r.getReport());
byte[] migratedFile = new byte[]{};
try {
migratedFile = FileUtils.getBytesFromFile(new File(outputFile));
DigitalObject u = new DigitalObject();
u.getData().setData(migratedFile);
FormatInfo tFormat = new FormatInfo();
tFormat.setDefaultExtension(config.getOutEnding());
result.setTargetFormat(tFormat);
result.setMigratedObject(u);
} catch (Exception e) {
log.error("Could not get outputfile "+outputFile, e);
result.setReport(result.getReport() + "\r\n error: could not retrieve outputfile.");
result.setSuccessful(false);
}
collectData(config, time, result);
double length = migratedFile.length;
double elapsed = r.getElapsedTimeMS();
double elapsedPerMB = ((double)elapsed)/(getMByte(data));
Measurement me = new Measurement(MeasureConstants.ELAPSED_TIME_PER_OBJECT,elapsed);
result.getMeasurements().put(MeasureConstants.ELAPSED_TIME_PER_OBJECT, me);
for (Measure measure: getMeasures()) {
if (!measure.getUri().startsWith("machine:")) {
Measurement m = new Measurement();
m.setMeasureId(measure.getUri());
PositiveFloatValue v = new PositiveFloatValue();
if (measure.getUri().equals(MeasureConstants.ELAPSED_TIME_PER_OBJECT)) {
v.setValue(elapsed);
m.setValue(v);
result.getMeasurements().put(measure.getUri(), m);
} else if (measure.getUri().equals(MeasureConstants.ELAPSED_TIME_PER_MB)) {
v.setValue(elapsedPerMB);
m.setValue(v);
result.getMeasurements().put(measure.getUri(), m);
} else if (measure.getUri().equals(MeasureConstants.COMPARATIVE_FILE_SIZE)) {
v.setValue(((double)length)/data.length * 100);
m.setValue(v);
result.getMeasurements().put(measure.getUri(), m);
} else if (measure.getUri().equals(MigrationResult.MIGRES_RESULT_FILESIZE)) {
v.setValue((double)length);
m.setValue(v);
result.getMeasurements().put(measure.getUri(), m);
}
}
}
success = r.isSuccess();
} catch (Exception e) {
log.error(e.getMessage(),e);
return false;
} finally {
cleanup(time,inputFile,outputFile);