try {\r
Object typeName = jobRuntime.popFromStack();\r
if (typeName == null)\r
- throw new Exception(jobRuntime.toString() + " illegal execution state detected: executor name is null.");\r
+ throw new Exception(\r
+ jobRuntime.toString() + " illegal execution state detected: executor name is null.");\r
String executorName = String.valueOf(typeName);\r
if (!jobEngineConfiguration.getExecutors().containsKey(executorName))\r
throw new Exception(jobRuntime.toString() + " executor is unavailable: " + executorName);\r
private void closeSessionLog(IJobRuntime jobRuntime) {\r
if (!jobRuntime.isService() && jobRuntime.getParentJobId() == 0) {\r
if (JobStatus.FINISHED.equals(jobRuntime.getStatus()))\r
- logger.info(jobRuntime.getFinishMarker(), "A(z) '{}' folyamat futása sikeresen véget ért.", jobRuntime.getName());\r
+ logger.info(jobRuntime.getFinishMarker(), "A(z) '{}' folyamat futása sikeresen véget ért.",\r
+ jobRuntime.getName());\r
else\r
- logger.error(jobRuntime.getFinishMarker(), "A(z) '{}' folyamat futása megszakadt.", jobRuntime.getName());\r
+ logger.error(jobRuntime.getFinishMarker(), "A(z) '{}' folyamat futása megszakadt.",\r
+ jobRuntime.getName());\r
}\r
}\r
\r
continue;\r
\r
// 'EXECUTING', 'WAIT_EXECUTOR', 'WAIT_SUSPEND', 'RUNNABLE'\r
- if (runtime.isExecuting() || runtime.isRunnable() || runtime.isWaitingSuspend() || runtime.isWaitingExecutor())\r
- throw new JobEngineException(String.format("Can not submit job. Job with %s.%s already running", template.getFileName(), template.getName()));\r
+ if (runtime.isExecuting() || runtime.isRunnable() || runtime.isWaitingSuspend()\r
+ || runtime.isWaitingExecutor())\r
+ throw new JobEngineException(String.format("Can not submit job. Job with %s.%s already running",\r
+ template.getFileName(), template.getName()));\r
}\r
/*\r
* List<Job> runningJobs = itemManager.getRunningJobs(template.getFileName());\r
List<Long> removeId = new ArrayList<>();\r
for (Long id : submittedJobs.keySet()) {\r
IJobRuntime runtime = submittedJobs.get(id);\r
- if (runtime != null && (JobStatus.SUSPENDED.equals(runtime.getStatus()) || JobStatus.CANCELED.equals(runtime.getStatus())))\r
+ if (runtime != null && (JobStatus.SUSPENDED.equals(runtime.getStatus())\r
+ || JobStatus.CANCELED.equals(runtime.getStatus())))\r
removeId.add(id);\r
}\r
for (Long id : removeId)\r
}\r
\r
@Override\r
- public IJobRuntime submit(IJobRuntime parent, IJobStatusChangedListener statusListener, String template, String name, int priority, String owner,\r
- Map<String, Object> parameters) throws JobEngineException {\r
+ public IJobRuntime submit(IJobRuntime parent, IJobStatusChangedListener statusListener, String template,\r
+ String name, int priority, String owner, Map<String, Object> parameters) throws JobEngineException {\r
IJobRuntime result = null;\r
IProgram program = getProgram(template);\r
if (program != null) {\r
}\r
\r
@Override\r
- public IJobRuntime submit(IJobRuntime parent, IJobStatusChangedListener statusListener, String template, String name, Map<String, Object> parameters)\r
- throws JobEngineException {\r
+ public IJobRuntime submit(IJobRuntime parent, IJobStatusChangedListener statusListener, String template,\r
+ String name, Map<String, Object> parameters) throws JobEngineException {\r
IJobRuntime result = null;\r
result = submit(parent, statusListener, template, name, 0, DEFAULT_OWNER, parameters);\r
return result;\r
}\r
\r
@Override\r
- public IJobRuntime submit(IJobRuntime parent, String template, String name, int priority, Map<String, Object> parameters) throws JobEngineException {\r
+ public IJobRuntime submit(IJobRuntime parent, String template, String name, int priority,\r
+ Map<String, Object> parameters) throws JobEngineException {\r
IJobRuntime result = null;\r
result = submit(parent, null, template, name, 0, DEFAULT_OWNER, parameters);\r
return result;\r
}\r
IJobRuntime result = null;\r
IProgram program = getProgram(template);\r
- result = submit(null, null, template, name == null ? program.getTemplate().getName() : name, 0, DEFAULT_OWNER, parameters);\r
+ result = submit(null, null, template, name == null ? program.getTemplate().getName() : name, 0, DEFAULT_OWNER,\r
+ parameters);\r
return result;\r
}\r
\r
@Override\r
- public IJobRuntime submit(String template, String name, Map<String, Object> parameters, String owner) throws JobEngineException {\r
+ public IJobRuntime submit(String template, String name, Map<String, Object> parameters, String owner)\r
+ throws JobEngineException {\r
IJobRuntime result = null;\r
result = submit(null, null, template, name, 0, owner, parameters);\r
return result;\r
import groovy.lang.GroovyClassLoader;\r
import user.commons.configuration.IConfiguration;\r
import user.commons.nosql.NoSQLUtils;\r
+import user.jobengine.server.ast.Encoder;\r
import user.jobengine.server.ast.JSONEncoder;\r
import user.jobengine.server.ast.JobTemplate;\r
import user.jobengine.server.ast.Parser;\r
stepClass = (Class<IJobStep>) stepsClassLoader.loadClass(stepUnitName);\r
\r
if (stepClass == null)\r
- throw new Exception("Cant load " + stepUnitName);\r
+ throw new Exception("Can't load " + stepUnitName);\r
\r
result = stepClass.newInstance();\r
logger.info("Class for step {} successfully created", stepUnitName);\r
String xml = loadTemplateXml(template);\r
j.put("xml", xml);\r
\r
+ loadProgram(Paths.get(template));\r
+\r
JobTemplate jobTemplate = loadTemplate(Paths.get(template));\r
JSONEncoder jsonEncoder = new JSONEncoder();\r
- BasicDBObject program = (BasicDBObject) jsonEncoder.visitJobTemplate(jobTemplate, null);\r
- if (program != null) {\r
- j.put("program", program);\r
+ BasicDBObject flowchartData = (BasicDBObject) jsonEncoder.visitJobTemplate(jobTemplate, null);\r
+ if (flowchartData != null) {\r
+ j.put("program", flowchartData);\r
} else {\r
- logger.info("program {} is null!");\r
+ logger.info("flowchartData {} is null!", flowchartData);\r
}\r
\r
schedules.add(new SimpleEntry<String, BasicDBObject>(template, j));\r
});\r
}\r
\r
+ private void loadProgram(Path config) {\r
+ InputStream stream = null;\r
+ Path templatesPath = null;\r
+ String fileName = null;\r
+ try {\r
+ templatesPath = Paths.get(systemConfig.getConfig(DIR_TEMPLATES));\r
+ if (!templatesPath.toFile().isDirectory())\r
+ throw new FileNotFoundException(templatesPath + " is not directory!");\r
+ stream = Files.newInputStream(Paths.get(templatesPath.toString(), config.toString()));\r
+ fileName = config.getFileName().toString();\r
+ Parser parser = new Parser(stream);\r
+ JobTemplate template = parser.parse();\r
+ template.validate();\r
+ template.setFileName(fileName);\r
+\r
+ Encoder encoder = new Encoder();\r
+ IProgram program = (IProgram) encoder.visitJobTemplate(template, null);\r
+ programs.put(fileName, program);\r
+ logger.info("Job template loaded {}", fileName);\r
+ } catch (FileNotFoundException e) {\r
+ logger.error("Fájl nem található: {}", fileName);\r
+ } catch (IOException e) {\r
+ logger.error("Inputstream nem nyitható meg: {}", e.getMessage());\r
+ } catch (Exception e) {\r
+ logger.error("{} compile error: {}", config, e.getMessage());\r
+ } finally {\r
+ try {\r
+ if (stream != null)\r
+ stream.close();\r
+ } catch (IOException e) {\r
+ }\r
+ }\r
+ }\r
+\r
private JobTemplate loadTemplate(Path templateName) {\r
Path templatesPath = null;\r
InputStream stream = null;\r