* {@inheritDoc}
*/
@Override
public void init(final Job job, final Cluster cluster) throws GenieException {
if (job == null) {
throw new GeniePreconditionException("No job entered.");
}
if (cluster == null) {
throw new GeniePreconditionException("No cluster entered.");
}
//TODO: Get rid of this circular dependency
this.jobMonitor.setJobManager(this);
this.job = job;
this.cluster = cluster;
this.attachments = this.job.getAttachments();
// save the cluster name and id
this.jobService.setClusterInfoForJob(this.job.getId(), this.cluster.getId(), this.cluster.getName());
// Find the command for the job
Command command = null;
for (final Command cmd : this.cluster.getCommands()) {
if (cmd.getTags().containsAll(this.job.getCommandCriteria())) {
command = cmd;
break;
}
}
//Avoiding NPE
if (command == null) {
final String msg = "No command found for params. Unable to continue.";
LOG.error(msg);
throw new GeniePreconditionException(msg);
}
// save the command name, application id and application name
this.jobService.setCommandInfoForJob(this.job.getId(), command.getId(), command.getName());