RCClientImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Eric Nickell October 19, 1985 4:28:17 pm PDT
DIRECTORY
Commander USING [CommandProc, Register],
ComputeServerClient USING [RemoteSuccess, StartService],
Rope USING [Cat, IsEmpty, ROPE];
RCClientImpl: CEDAR PROGRAM
IMPORTS Commander, ComputeServerClient, Rope
~ BEGIN
ConvertSuccess: PROC [found: BOOL, success: ComputeServerClient.RemoteSuccess, msg: Rope.ROPE] RETURNS [newMsg: Rope.ROPE] ~ {
updateMSG: PROC [prefix, suffix: Rope.ROPE ] RETURNS [newMsg: Rope.ROPE] = {
IF suffix.IsEmpty[] THEN RETURN [prefix];
newMsg ← Rope.Cat[prefix, " (because ", suffix, ")"];
};
SELECT success FROM
true => {
};
false => {
IF ~found THEN msg ← updateMSG["compute server command not found", msg]
ELSE msg ← updateMSG["compute server success was false (Computer Server bug?)", msg];
};
aborted => {
msg ← updateMSG["compute server command aborted", msg];
};
communicationFailure => {
msg ← updateMSG["communicationFailure", msg];
};
cantImportController => {
msg ← updateMSG["cantImportController", msg];
};
cantImportServer => {
msg ← updateMSG["cantImportServer", msg];
};
serverTooBusy => {
msg ← updateMSG["serverTooBusy", msg];
};
ENDCASE => msg ← updateMSG["unknown error code", msg];
newMsg ← msg;
};
RemoteCommand: Commander.CommandProc ~ {
found: BOOL;
success: ComputeServerClient.RemoteSuccess;
[found: found, success: success, remoteMsg: msg] ← ComputeServerClient.StartService[service: "RemoteCommand", cmdLine: cmd.commandLine, in: cmd.in, out: cmd.out];
msg ← ConvertSuccess[found, success, msg];
};
Commander.Register[key: "RemoteCommand", proc: RemoteCommand, doc: "Execute a command on some compute server (RemoteCommand <command>)"];
END.