private static final Logger logger = LoggerFactory.getLogger(AppDescriptorCheckHandler.class);
public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException {
logger.info("Invoking ApplicationDescriptorCheckHandler ...");
ApplicationDescription app = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription();
ApplicationDeploymentDescriptionType appDesc = app.getType();
if (appDesc.getScratchWorkingDirectory() == null) {
appDesc.setScratchWorkingDirectory("/tmp");
}
/*
* Working dir
*/
if (appDesc.getStaticWorkingDirectory() == null || "null".equals(appDesc.getStaticWorkingDirectory())) {
String date = new Date().toString();
date = date.replaceAll(" ", "_");
date = date.replaceAll(":", "_");
String tmpDir = appDesc.getScratchWorkingDirectory() + File.separator
+ jobExecutionContext.getServiceName() + "_" + date + "_" + UUID.randomUUID();
appDesc.setStaticWorkingDirectory(tmpDir);
}
/*
* Input and Output Directory
*/
if (appDesc.getInputDataDirectory() == null || "".equals(appDesc.getInputDataDirectory())) {
appDesc.setInputDataDirectory(appDesc.getStaticWorkingDirectory() + File.separator + "inputData");
}
if (appDesc.getOutputDataDirectory() == null || "".equals(appDesc.getOutputDataDirectory())) {
appDesc.setOutputDataDirectory(appDesc.getStaticWorkingDirectory() + File.separator + "outputData");
}
/*
* Stdout and Stderr for Shell
*/
if (appDesc.getStandardOutput() == null || "".equals(appDesc.getStandardOutput())) {
appDesc.setStandardOutput(appDesc.getStaticWorkingDirectory() + File.separator
+ appDesc.getApplicationName().getStringValue() + ".stdout");
}
if (appDesc.getStandardError() == null || "".equals(appDesc.getStandardError())) {
appDesc.setStandardError(appDesc.getStaticWorkingDirectory() + File.separator
+ appDesc.getApplicationName().getStringValue() + ".stderr");
}
jobExecutionContext.getApplicationContext().setApplicationDeploymentDescription(app);
}