-- TransactionDebugImpl.mesa
-- Procs for printing state of transaction maps, manual abort of transaction, etc.
-- Last edited by
-- MBrown on March 29, 1983 8:58 pm
DIRECTORY
AlpineEnvironment,
AlpineIdentity,
AlpineInternal,
AlpineTransaction,
Coordinator,
CoordinatorMap,
IO,
Rope,
TransactionMap,
UserExec,
Worker;
TransactionDebugImpl: PROGRAM
IMPORTS
AlpineIdentity,
AlpineTransaction,
CoordinatorMap,
IO,
TransactionMap,
UserExec
EXPORTS
AlpineInternal
= BEGIN
ROPE: TYPE = Rope.ROPE;
STREAM: TYPE = IO.STREAM;
Handle: TYPE = Worker.Handle;
nullHandle: Handle = Worker.nullHandle;
TransObject: PUBLIC TYPE = Worker.Object;
-- AlpineInternal.TransObject
PrintWorkers: PROC [to: STREAM] = {
PrintWorker: PROC [self: Handle] RETURNS [stop: BOOL] = {
Rec9: TYPE = RECORD [a, b, c, d, e, f, g, h, i: CARDINAL];
id: CARDINAL = LOOPHOLE[self.transID, Rec9].c;
to.PutF[" trans: %g, beginRecord: [%g, %g], cost: %g, last active: %g\n",
IO.card[id], IO.card[self.beginRecord.highBits], IO.card[self.beginRecord.lowBits],
IO.int[self.estimatedUpdateCost], IO.time[self.timeOfLastStartWork]];
RETURN [stop: FALSE];
};
to.PutRope["Workers:\n"];
TransactionMap.UnlockedEnumerate[PrintWorker];
to.PutChar['\n];
};
PrintCoordinators: PROC [to: STREAM] = {
PrintCoordinator: PROC [self: Coordinator.Handle] RETURNS [stop: BOOL] = {
Rec9: TYPE = RECORD [a, b, c, d, e, f, g, h, i: CARDINAL];
id: CARDINAL = LOOPHOLE[self.transID, Rec9].c;
to.PutF[" trans: %g, beginRecord: [%g, %g]\n",
IO.card[id], IO.card[self.beginRecord.highBits], IO.card[self.beginRecord.lowBits]];
RETURN [stop: FALSE];
};
to.PutRope["Coordinators:\n"];
CoordinatorMap.UnlockedEnumerate[PrintCoordinator];
to.PutChar['\n];
};
PrintTransactions: PROC [] = {
to: STREAM = UserExec.GetStreams[].out;
PrintCoordinators[to];
PrintWorkers[to];
};
AbortCoordinator: PROC [coordinatorID: CARDINAL] = {
c: Coordinator.Handle ← NIL;
FindCoordinator: PROC [self: Coordinator.Handle] RETURNS [stop: BOOL] = {
Rec9: TYPE = RECORD [a, b, c, d, e, f, g, h, i: CARDINAL];
id: CARDINAL = LOOPHOLE[self.transID, Rec9].c;
IF id = coordinatorID THEN {
c ← self;
RETURN [stop: TRUE]
};
RETURN [stop: FALSE];
};
CoordinatorMap.UnlockedEnumerate[FindCoordinator];
IF c # NIL THEN [] ← AlpineTransaction.Finish[
AlpineIdentity.myLocalConversation, c.transID, abort, FALSE];
};
AbortWorker: PROC [workerID: CARDINAL] = {
w: Handle ← NIL;
FindWorker: PROC [self: Handle] RETURNS [stop: BOOL] = {
Rec9: TYPE = RECORD [a, b, c, d, e, f, g, h, i: CARDINAL];
id: CARDINAL = LOOPHOLE[self.transID, Rec9].c;
IF id = workerID THEN {
w ← self;
RETURN [stop: TRUE]
};
RETURN [stop: FALSE];
};
TransactionMap.UnlockedEnumerate[FindWorker];
IF w # NIL THEN TransactionMap.AbortUnilaterally[w, oldUncommittedUpdates];
};
END.--TransactionDebugImpl
CHANGE LOG
Changed by MBrown on February 9, 1983 11:54 am
-- Change CommitWorker to set continueWorker ← nullHandle. (This was happening,
--unsynchronized, from the checkpoint process!)
Changed by MBrown on March 2, 1983 2:53 pm
-- Change sanity check in StartWork.