/** * It then parses the JSON object and updates a central location for Chef Attributes. * * @param sshMachine * @throws se.kth.karamel.common.exception.KaramelException */ @Override public void collectResults(MachineInterface sshMachine) throws KaramelException { String remoteFile = Settings.RECIPE_RESULT_REMOTE_PATH(getRecipeCanonicalName()); String localResultsFile = Settings.RECIPE_RESULT_LOCAL_PATH( getRecipeCanonicalName(), getMachine().getGroup().getCluster().getName(), getMachine().getPublicIp()); try { sshMachine.downloadRemoteFile(remoteFile, localResultsFile, true); } catch (IOException ex) { logger.debug( String.format( "No return values for %s on %s", getRecipeCanonicalName(), getMachine().getPublicIp())); return; } JsonReader reader; try { reader = new JsonReader(new FileReader(localResultsFile)); } catch (FileNotFoundException ex) { String msg = String.format( "Cannot find the results file for %s on %s", getRecipeCanonicalName(), getMachine().getPublicIp()); throw new KaramelException(msg, ex); } JsonParser jsonParser = new JsonParser(); try { JsonElement el = jsonParser.parse(reader); DagParams.setGlobalParams(el); } catch (JsonIOException | JsonSyntaxException ex) { throw new KaramelException( String.format( "Invalid return value as Json object for %s on %s", getRecipeCanonicalName(), getMachine().getPublicIp()), ex); } }