/** * Process message from the grid engine itself. In case the process failed, we keep the work * packet around so the developer can reproduce the error. * * @param w Work packet whose state changed */ @Override public void stateChanged(final GridWorkPacket w) { if (w == null) { return; } // We report state change just once. if (!reported) { try { if (w.getPassed()) { // This is the last response we will send - request is completed. // There might have been an error from RMI, check that if (allocatorListener.getLastThrowable() == null) { sendResponse( request, new DaemonProgressMessage(DaemonProgress.RequestCompleted), true); } else { sendResponse( request, new DaemonException(allocatorListener.getLastThrowable()), true); } } else if (w.getFailed()) { // This is the last response we will send - request failed if (allocatorListener.getLastThrowable() == null) { sendResponse(request, new DaemonException(w.getErrorMessage()), true); } else { sendResponse( request, new DaemonException(w.getErrorMessage(), allocatorListener.getLastThrowable()), true); } } reported = true; } finally { if (!w.getFailed()) { // Delete workPacket file LOGGER.debug("Deleting sge packet file: " + sgePacketFile.getAbsolutePath()); FileUtilities.quietDelete(sgePacketFile); } else { LOGGER.warn("Retaining sge packet file: " + sgePacketFile.getAbsolutePath()); } } } }