<> <> <> <> <> <<>> 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 <> ROPE: TYPE = Rope.ROPE; STREAM: TYPE = IO.STREAM; NoOfGetControllerInterfaceProcesses: INT _ 0 ; FirstTryToGetController: BOOL _ TRUE; <> GetControllerInterfaceProcess: PUBLIC PROC [forceImport: BOOL _ FALSE] = { MakeSureThereIsOne: ENTRY PROC RETURNS [exit: BOOL _ FALSE] = { 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: BOOL _ FALSE; [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; }; <> 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]; }; <> PokeTheController: PUBLIC PROC = { seventeenSecondsInTicks: Process.Ticks = Process.SecondsToTicks[17]; DO tempControllerInterface: ComputeServerControllerRpcControl.InterfaceRecord _ ComputeClientInternal.ControllerInterface; tryDifferentController: BOOL _ FALSE; 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; }; <> 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; }; <> Commander.Register[key: "///Commands/SummonerClientRequests", proc: ClientRequests, doc: "Print all active requests"]; END. <> <> <> <> <<>>