logger.error(msg + ": " + e.getMessage(), e);
} else {
logger.error(msg + ": " + e.getMessage());
}
// scrubbing what client sees
throw new ResourceRequestDeniedException(msg);
}
// no casing necessary yet for pilot, only 0.2 supported now
final ArrayList pilotCommon;
try {
pilotCommon = this.pilot.constructCommon(false, false, true, null);
} catch (ManageException e) {
final String msg = "Problem with pilot argument construction";
if (logger.isDebugEnabled()) {
logger.error(msg + ": " + e.getMessage(), e);
} else {
logger.error(msg + ": " + e.getMessage());
}
// scrubbing what client sees
throw new ResourceRequestDeniedException(msg);
}
// same params sent to each pilot in a group job
final ArrayList pilotReserveSlot;
try {
final String notifyString;
if (this.httpNotifyString != null
&& this.sshNotifyString != null) {
notifyString = this.httpNotifyString + "+++" +
this.sshNotifyString;
} else if (this.httpNotifyString != null) {
notifyString = this.httpNotifyString;
} else if (this.sshNotifyString != null) {
notifyString = this.sshNotifyString;
} else {
final String msg = "No pilot-->service notification mechanism";
throw new ResourceRequestDeniedException(msg);
}
pilotReserveSlot = this.pilot.constructReserveSlot(memory,
dur,
this.grace,
uuid,
notifyString);
} catch (ManageException e) {
final String msg = "Problem with pilot argument construction";
if (logger.isDebugEnabled()) {
logger.error(msg + ": " + e.getMessage(), e);
} else {
logger.error(msg + ": " + e.getMessage());
}
// scrubbing what client sees
throw new ResourceRequestDeniedException(msg);
}
final StringBuffer pilotcmdbuf = new StringBuffer(256);
if (this.multiJobPrefix != null && vmids.length > 1) {
pilotcmdbuf.append(this.multiJobPrefix);
pilotcmdbuf.append(" ");
}
pilotcmdbuf.append(this.pilotPath);
Iterator iter = pilotCommon.iterator();
while (iter.hasNext()) {
pilotcmdbuf.append(" ");
pilotcmdbuf.append(iter.next());
}
iter = pilotReserveSlot.iterator();
while (iter.hasNext()) {
pilotcmdbuf.append(" ");
pilotcmdbuf.append(iter.next());
}
final String pilotcmd = pilotcmdbuf.toString();
logger.info("pilot command = " + pilotcmd);
final String[] cmd = (String[]) torquecmd.toArray(
new String[torquecmd.size()]);
String stdout;
try {
stdout = WorkspaceUtil.runCommand(cmd, true, pilotcmd,
this.lager.eventLog,
this.lager.traceLog);
} catch (WorkspaceException e) {
final String msg = "Problem calling Torque";
if (logger.isDebugEnabled()) {
logger.error(msg + ": " + e.getMessage(), e);
} else {
logger.error(msg + ": " + e.getMessage());
}
// scrubbing what client sees
throw new ResourceRequestDeniedException(msg);
} catch (ReturnException e) {
final String msg = "Problem calling Torque";
final StringBuffer buf = new StringBuffer(msg);
buf.append(": return code = ")
.append(e.retval);
if (e.stderr != null) {
buf.append(", stderr = '")
.append(e.stderr)
.append("'");
} else {
buf.append(", no stderr");
}
if (e.stdout != null) {
buf.append(", stdout = '")
.append(e.stdout)
.append("'");
} else {
buf.append(", no stdout");
}
logger.error(msg + ": " + buf.toString());
// scrubbing what client sees
throw new ResourceRequestDeniedException(msg);
}
if (stdout == null || stdout.length() == 0) {
final String msg = "Inexplicable problem receiving job ID from" +
" Torque (return == 0, but no stdout), aborting.";
logger.error(msg);
throw new ResourceRequestDeniedException(msg);
}
// TODO: analyze stdout here, should have no newlines or spaces
logger.debug("torque stdout = " + stdout);
stdout = stdout.trim();
if (stdout.indexOf('\n') >= 0) {
logger.warn("torque stdout has a new line");
// todo: throw exc? strip it?
}
try {
if (vmids.length == 1) {
this.db.newSlot(uuid, vmids[0], stdout, dur);
} else {
this.db.newSlotGroup(uuid, vmids, stdout, dur);
}
} catch (WorkspaceDatabaseException e) {
String msg = "Problem with service database, aborting pilot job.";
if (logger.isDebugEnabled()) {
logger.error(msg + ": " + e.getMessage(), e);
} else {
logger.error(msg + ": " + e.getMessage());
}
// we know it's torque for now, no casing
try {
WorkspaceUtil.runCommand(this.torque.constructQdel(stdout),
this.lager.eventLog,
this.lager.traceLog);
} catch (WorkspaceException e2) {
String msg2 = " (and problem with Torque qdel)";
msg += msg2;
if (logger.isDebugEnabled()) {
logger.error(msg2 + ": " + e2.getMessage(), e2);
} else {
logger.error(msg2 + ": " + e2.getMessage());
}
} catch (ReturnException e2) {
String msg2 = " (and problem calling Torque qdel)";
msg += msg2;
StringBuffer buf = new StringBuffer(msg2);
buf.append(": return code = ")
.append(e2.retval);
if (e2.stderr != null) {
buf.append(", stderr = '")
.append(e2.stderr)
.append("'");
} else {
buf.append(", no stderr");
}
if (e2.stdout != null) {
buf.append(", stdout = '")
.append(e2.stdout)
.append("'");
} else {
buf.append(", no stdout");
}
logger.error(buf.toString());
}
throw new ResourceRequestDeniedException(msg);
}
if (this.watcher != null) {
this.watcher.scheduleNotificationWatcher();
}