ComputeClientInitAndStatusImpl.mesa
Client side of the interface implementation.
Last Edited by: Bob Hagmann, October 8, 1985 1:37:59 pm PDT
Spreitzer, September 3, 1985 3:40:52 pm PDT
Copyright © 1984 by Xerox Corporation. All rights reserved.
DIRECTORY
AMBridge,
AMTypes,
Atom,
Basics,
BasicTime,
Commander,
ComputeClientInternal,
ComputeServer,
ComputeServerClient,
ComputeServerUser,
ComputeServerControllerRpcControl,
ComputeServerRpcControl,
GVBasics,
GVNames,
Interpreter,
IO,
PrincOps,
Process,
PupDefs,
PupErrors,
PupTypes,
Rope,
RPC;
ComputeClientInitAndStatusImpl: CEDAR MONITOR
IMPORTS AMBridge, Commander, ComputeClientInternal, ComputeServerControllerRpcControl, GVNames, IO, Interpreter, Process, PupDefs, PupErrors, Rope, RPC
EXPORTS ComputeClientInternal
= BEGIN
Declarations
ROPE: TYPE = Rope.ROPE;
STREAM: TYPE = IO.STREAM;
NoOfGetControllerInterfaceProcesses: INT ← 0 ;
FirstTryToGetController: BOOLTRUE;
Service Initialization and Status
GetControllerInterfaceProcess: PUBLIC PROC [forceImport: BOOLFALSE] = {
MakeSureThereIsOne: ENTRY PROC RETURNS [exit: BOOLFALSE] = {
IF NoOfGetControllerInterfaceProcesses = 0 THEN NoOfGetControllerInterfaceProcesses ← 1
ELSE RETURN[TRUE];
};
NowWeAreGone: ENTRY PROC = { NoOfGetControllerInterfaceProcesses ← 0};
importedControllerInterface: ComputeServerControllerRpcControl.InterfaceRecord ← NIL;
IF forceImport THEN {
DO
IF ~MakeSureThereIsOne[] THEN EXIT;
Process.Pause[5];
ENDLOOP;
}
ELSE {IF MakeSureThereIsOne[] THEN RETURN;};
FirstTryToGetController ← TRUE;
WHILE importedControllerInterface = NIL DO
info: GVNames.ConnectInfo;
connect: GVBasics.Connect;
localImportWorked: BOOLFALSE;
[info: info, connect: connect ] ← GVNames.GetConnect[ComputeClientInternal.ControllerGVName];
IF (info = individual OR info = group) AND Rope.Equal[connect, ComputeClientInternal.myNetAddressRope] THEN TRUSTED {
result: AMTypes.TV;
localImportWorked ← TRUE;
importedControllerInterface ← NEW[ComputeServerControllerRpcControl.InterfaceRecordObject];
result ← Interpreter.Evaluate["ComputeControllerImpl.FindService"].result;
IF result = NIL THEN localImportWorked ← FALSE;
importedControllerInterface.clientStubFindService ← lFindService;
MyFindService ← LOOPHOLE[AMBridge.TVToProc[result]];
result ← Interpreter.Evaluate["ComputeControllerImpl.FindServiceWithQueueing"].result;
IF result = NIL THEN localImportWorked ← FALSE;
importedControllerInterface.clientStubFindServiceWithQueueing ← lMyFindServiceWithQueueing;
MyFindServiceWithQueueing ← LOOPHOLE[AMBridge.TVToProc[result]];
result ← Interpreter.Evaluate["ComputeControllerImpl.NewStats"].result;
IF result = NIL THEN localImportWorked ← FALSE;
importedControllerInterface.clientStubNewStats ← lNewStats;
MyNewStats ← LOOPHOLE[AMBridge.TVToProc[result]];
result ← Interpreter.Evaluate["ComputeControllerImpl.BestServerStats"].result;
IF result = NIL THEN localImportWorked ← FALSE;
importedControllerInterface.clientStubBestServerStats ← lBestServerStats;
MyBestServerStats ← LOOPHOLE[AMBridge.TVToProc[result]];
result ← Interpreter.Evaluate["ComputeControllerPackagesImpl.NoticeNewPackage"].result;
IF result = NIL THEN localImportWorked ← FALSE;
importedControllerInterface.clientStubNoticeNewPackage ← lNoticeNewPackage;
MyNoticeNewPackage ← LOOPHOLE[AMBridge.TVToProc[result]];
result ← Interpreter.Evaluate["ComputeControllerPackagesImpl.RemoveOldPackage"].result;
IF result = NIL THEN localImportWorked ← FALSE;
importedControllerInterface.clientStubRemoveOldPackage ← lRemoveOldPackage;
MyRemoveOldPackage ← LOOPHOLE[AMBridge.TVToProc[result]];
result ← Interpreter.Evaluate["ComputeControllerImpl.GetSomeInfo"].result;
IF result = NIL THEN localImportWorked ← FALSE;
importedControllerInterface.clientStubGetSomeInfo ← lGetSomeInfo;
MyGetSomeInfo ← LOOPHOLE[AMBridge.TVToProc[result]];
result ← Interpreter.Evaluate["ComputeControllerImpl.CommandUnavailable"].result;
IF result = NIL THEN localImportWorked ← FALSE;
importedControllerInterface.clientStubCommandUnavailable ← lCommandUnavailable;
MyCommandUnavailable ← LOOPHOLE[AMBridge.TVToProc[result]];
result ← Interpreter.Evaluate["ComputeControllerImpl.ExtraCommandAvailable"].result;
IF result = NIL THEN localImportWorked ← FALSE;
importedControllerInterface.clientStubExtraCommandAvailable ← lExtraCommandAvailable;
MyExtraCommandAvailable ← LOOPHOLE[AMBridge.TVToProc[result]];
result ← Interpreter.Evaluate[ "ComputeControllerImpl.MightAcceptQueuedCommand"].result;
IF result = NIL THEN localImportWorked ← FALSE;
importedControllerInterface.clientStubMightAcceptQueuedCommand ← lMightAcceptQueuedCommand;
MyMightAcceptQueuedCommand ← LOOPHOLE[AMBridge.TVToProc[result]];
};
IF ~localImportWorked THEN {
importedControllerInterface ← NIL;
importedControllerInterface ← ComputeServerControllerRpcControl.ImportNewInterface[interfaceName: [ type: "ComputeServerController.summoner", instance: ComputeClientInternal.ControllerGVName, version: [1,1]]
! RPC.ImportFailed => {
Process.Pause[Process.SecondsToTicks[13]];
CONTINUE;
};
];
};
FirstTryToGetController ← FALSE;
ENDLOOP;
ComputeClientInternal.ControllerInterface ← importedControllerInterface;
NowWeAreGone[];
};
TryToImportController: PUBLIC PROC = {
IF NoOfGetControllerInterfaceProcesses = 1 THEN RETURN;
TRUSTED {Process.Detach[FORK GetControllerInterfaceProcess[]]; };
Process.Pause[Process.SecondsToTicks[1]];
WHILE NoOfGetControllerInterfaceProcesses = 1 AND FirstTryToGetController DO
Process.Pause[Process.SecondsToTicks[1]];
ENDLOOP;
};
Dummies to strip off an arg for the local call
MyFindService: PROC [service: Rope.ROPE] RETURNS [found: BOOL, instance: RPC.ShortROPE];
MyFindServiceWithQueueing: PROC [service: Rope.ROPE, version: RPC.ShortROPE, timeToWait: INT, clientMachineName: RPC.ShortROPE, streamPupAddress: PupDefs.PupAddress, needListener: BOOL] RETURNS [found: ComputeServer.AskResponce, instance: RPC.ShortROPE, serverPupAddress: PupDefs.PupAddress, errMsg: Rope.ROPE];
MyNewStats: PROC [serverMachineName: RPC.ShortROPE, serverMachinePupAddress: RPC.ShortROPE, serverUP: BOOL, firstCall: BOOL, machineType: PrincOps.MachineType, mainMemory: CARDINAL, numberCPUs: CARDINAL, diskPartionSize: INT, freePagesOnDisk: INT, freeboard: INT, freeGFI: CARDINAL, freeMDS: CARDINAL, freeVM: CARDINAL, oldestLRUFileDate: BasicTime.GMT, CPULoad: REAL, reclamationRate: REAL, freeProcesses: CARDINAL] RETURNS [terminateService, newPackage: BOOL, queueingCommands: LIST OF Rope.ROPE];
MyBestServerStats: PROC RETURNS[instance: RPC.ShortROPE, FOM: REAL] ;
MyNoticeNewPackage: PROC [package: RPC.ShortROPE] RETURNS [error: BOOL, tryDifferentController: BOOL, msg: Rope.ROPE];
MyRemoveOldPackage: PROC [package: RPC.ShortROPE] RETURNS [error: BOOL, tryDifferentController: BOOL, msg: Rope.ROPE];
MyGetSomeInfo: PROC RETURNS [error: BOOL, tryDifferentController: BOOL, msg: Rope.ROPE, serverList: LIST OF Rope.ROPE, bestFOM: REAL];
MyCommandUnavailable: PROC [serverMachineName: RPC.ShortROPE, commandName: Rope.ROPE, version: RPC.ShortROPE];
MyExtraCommandAvailable: PROC [serverMachineName: RPC.ShortROPE, commandName: Rope.ROPE, version: RPC.ShortROPE];
MyMightAcceptQueuedCommand: PROC [serverMachineAddress: RPC.ShortROPE, commandName: Rope.ROPE];
lFindService: PROC [interface: ComputeServerControllerRpcControl.InterfaceRecord, service: Rope.ROPE] RETURNS [found: BOOL, instance: RPC.ShortROPE] = {
RETURN MyFindService[service];
};
lMyFindServiceWithQueueing: PROC [interface: ComputeServerControllerRpcControl.InterfaceRecord, service: Rope.ROPE, version: RPC.ShortROPE, timeToWait: INT, clientMachineName: RPC.ShortROPE, streamPupAddress: PupDefs.PupAddress, needListener: BOOL] RETURNS [found: ComputeServer.AskResponce, instance: RPC.ShortROPE, serverPupAddress: PupDefs.PupAddress, errMsg: Rope.ROPE] = {
RETURN MyFindServiceWithQueueing[service, version, timeToWait, clientMachineName, streamPupAddress, needListener];
};
lNewStats: PROC [interface: ComputeServerControllerRpcControl.InterfaceRecord, serverMachineName: RPC.ShortROPE, serverMachinePupAddress: RPC.ShortROPE, serverUP: BOOL, firstCall: BOOL, machineType: PrincOps.MachineType, mainMemory: CARDINAL, numberCPUs: CARDINAL, diskPartionSize: INT, freePagesOnDisk: INT, freeboard: INT, freeGFI: CARDINAL, freeMDS: CARDINAL, freeVM: CARDINAL, oldestLRUFileDate: BasicTime.GMT, CPULoad: REAL, reclamationRate: REAL, freeProcesses: CARDINAL] RETURNS [terminateService, newPackage: BOOL, queueingCommands: LIST OF Rope.ROPE] = {
RETURN MyNewStats[serverMachineName, serverMachinePupAddress, serverUP, firstCall, machineType, mainMemory, numberCPUs, diskPartionSize, freePagesOnDisk, freeboard, freeGFI, freeMDS, freeVM, oldestLRUFileDate, CPULoad, reclamationRate, freeProcesses];
};
lBestServerStats: PROC [interface: ComputeServerControllerRpcControl.InterfaceRecord] RETURNS[instance: RPC.ShortROPE, FOM: REAL] = {
RETURN MyBestServerStats[];
};
lNoticeNewPackage: PROC [interface: ComputeServerControllerRpcControl.InterfaceRecord, package: RPC.ShortROPE] RETURNS [error: BOOL, tryDifferentController: BOOL, msg: Rope.ROPE] = {
RETURN MyNoticeNewPackage[package];
};
lRemoveOldPackage: PROC [interface: ComputeServerControllerRpcControl.InterfaceRecord, package: RPC.ShortROPE] RETURNS [error: BOOL, tryDifferentController: BOOL, msg: Rope.ROPE] = {
RETURN MyRemoveOldPackage [package];
};
lGetSomeInfo: PROC [interface: ComputeServerControllerRpcControl.InterfaceRecord] RETURNS [error: BOOL, tryDifferentController: BOOL, msg: Rope.ROPE, serverList: LIST OF Rope.ROPE, bestFOM: REAL] = {
RETURN MyGetSomeInfo[];
};
lCommandUnavailable: PROC [interface: ComputeServerControllerRpcControl.InterfaceRecord, serverMachineName: RPC.ShortROPE, commandName: Rope.ROPE, version: RPC.ShortROPE] = {
MyCommandUnavailable[serverMachineName, commandName, version];
};
lExtraCommandAvailable: PROC [interface: ComputeServerControllerRpcControl.InterfaceRecord, serverMachineName: RPC.ShortROPE, commandName: Rope.ROPE, version: RPC.ShortROPE] = {
MyExtraCommandAvailable[serverMachineName, commandName, version];
};
lMightAcceptQueuedCommand: PROC [interface: ComputeServerControllerRpcControl.InterfaceRecord, serverMachineAddress: RPC.ShortROPE, commandName: Rope.ROPE] = {
MyMightAcceptQueuedCommand[serverMachineAddress, commandName];
};
Revalidate Controller Interface cache
PokeTheController: PUBLIC PROC = {
seventeenSecondsInTicks: Process.Ticks = Process.SecondsToTicks[17];
DO
tempControllerInterface: ComputeServerControllerRpcControl.InterfaceRecord ← ComputeClientInternal.ControllerInterface;
tryDifferentController: BOOLFALSE;
IF tempControllerInterface = NIL THEN TryToImportController[]
ELSE {
[tryDifferentController: tryDifferentController] ← tempControllerInterface.GetSomeInfo[ ! RPC.CallFailed => {
ComputeClientInternal.ControllerInterface ← NIL;
TryToImportController[];
CONTINUE;
};
];
};
IF tryDifferentController THEN {
TryToImportController[];
};
Process.Pause[seventeenSecondsInTicks];
ENDLOOP;
};
Print all active requests
ClientRequests: Commander.CommandProc = {
serviceList: LIST OF REF ComputeClientInternal.ServiceListObject;
serviceList ← ComputeClientInternal.GetCurrentServices[];
WHILE serviceList # NIL DO
serverName: ROPE ← serviceList.first.serverInstance;
serverName ← PupDefs.GetHostName[serviceList.first.listenerPupAddress];
IF msg # NIL THEN msg ← Rope.Concat[msg, "\n"];
msg ← Rope.Concat[msg,
IO.PutFR[" %g running on %g (%g) ", IO.rope[serviceList.first.command], IO.rope[serverName], IO.rope[serviceList.first.serverInstance]]];
serviceList ← serviceList.rest;
ENDLOOP;
};
Initialization
Commander.Register[key: "///Commands/SummonerClientRequests", proc: ClientRequests, doc: "Print all active requests"];
END.
Bob Hagmann March 10, 1985 12:14:31 pm PST
changes to: ClientMachineName, StreamPupAddress, myNetAddressRope, StartService, name, clientMachineName, StreamPupAddress, myNetAddressRope
Bob Hagmann June 20, 1985 7:35:44 am PDT
added retries to BestServerStats