@Override
public void resultsReady(GatewayProcess process)
{
LOG.debug("Remote process is initialised.");
Errors errors = new Errors();
try
{
errors = process.getErrors();
}
catch (ClientException e)
{
LOG.error("Failed to read errors from gateway process.", e);
}
if (errors.getCompiletime() == null
&& errors.getRuntime() == null
&& errors.getSystem() == null)
{
LOG.debug("Trying results...");
Map<String, Result> results = process.getResults();
LOG.debug("Results are ready: " + results);
for (Entry<String, Result> entry : results.entrySet())
{
LOG.debug("resultName = " + entry.getKey() + "; address = " + entry.getValue().getAddress());
mResults.put(entry.getKey(), entry.getValue().getAddress());
}
Map<String, String> transfers = getManagedTransfers(process);
mManagedTransfers.putAll(transfers);
mExternalTransfers.putAll(transfers);
mDone.countDown();
LOG.debug("Waiting for " + mDone.getCount() + " processor(s)...");
}
else
{
LOG.debug("An error occurred while waiting for remote process to complete:\n"
+ ErrorHelper.getAsString(errors));
if (errors.getCompiletime() != null)
{
ErrorHelper.getCompiletimeInstance(mErrors).getError().addAll(
errors.getCompiletime().getError());
}
if (errors.getRuntime() != null)
{
RuntimeErrorType runtime = ErrorHelper.getRuntimeInstance(mErrors);
runtime.getError().addAll(errors.getRuntime().getError());
runtime.getProcessingElement().addAll(
errors.getRuntime().getProcessingElement());
}
if (errors.getSystem() != null)
{
mErrors.setSystem(errors.getSystem());
}
// TODO stop other processes?
mFail = true;
mDone.countDown();
}