File: WalnutStatsMonitor.mesa
Contents: : monitor stats for walnut users
Created by: Jack Kent, September 3, 1986 6:36:03 pm PDT
DIRECTORY
DB, Rope, IO, Commander, CommandTool;
WalnutStatsMonitor: CEDAR PROGRAM
IMPORTS DB, Rope, IO, Commander, CommandTool =
BEGIN
INT: TYPE = LONG INTEGER;
ROPE: TYPE = Rope.ROPE;
CmdHandle: TYPE = Commander.Handle;
ArgumentVector: TYPE = CommandTool.ArgumentVector;
MonUser: Commander.CommandProc = {
argV: ArgumentVector = CommandTool.Parse[cmd];
rel: DB.Relation;
relshipSet: DB.RelshipSet;
rship: DB.Relship;
count: INT;
opName: ROPE;
msgSet1: ROPE;
msgSet2: ROPE;
msgCount: INT;
msgSetCount: INT;
transHandle: DB.TransactionHandle;
schemaInvalid: BOOLEAN;
userName: ROPE = argV[1];
serverFile: ROPE;
IF Rope.Equal["AlisonLee",userName] OR Rope.Equal["Tempero",userName] THEN
serverFile ← Rope.Cat[r1: "[ebbetts.alpine]<", r2: userName, r3: ".pa>Walnut.segment"]
ELSE
serverFile ← Rope.Cat[r1: "[luther.alpine]<", r2: userName, r3: ".pa>Walnut.segment"];
IO.PutF[cmd.out, "Stats for %g", IO.rope["userName"] ];
serverFile is userName concatenated with the usual garbage
DB.Initialize[nCachePages: 100];
DB.DeclareSegment[filePath: serverFile, segment: $Walnut, readonly: TRUE, nPagesInitial: 3000, createIfNotFound: FALSE, nPagesPerExtent: 256];
[trans: transHandle, schemaInvalid: schemaInvalid] ← DB.OpenTransaction[segment: $Walnut];
print out general stats about number of messages and number of message set
IO.PutChar[cmd.out, IO.CR];
IO.PutF[cmd.out, "---------------------------- "];
IO.PutChar[cmd.out, IO.CR];
IO.PutF[cmd.out, "Basic Stats"];
IO.PutChar[cmd.out, IO.CR];
rel ← DB.LookupRelation[name: "VersionInfo" , segment: $Walnut];
IO.PutChar[cmd.out, IO.CR];
Get the List of Key Indices from the relation
relshipSet ← DB.RelationSubset[r:rel,index:NIL,constraint:NIL];
rship ← DB.NextRelship[rs: relshipSet];
msgCount ← DB.V2I[DB.GetF[t: rship, field: 0]];
msgSetCount ← DB.V2I[DB.GetF[t: rship, field: 1]];
IO.PutF[cmd.out, "number of messages = %5g number of message sets = %5g", IO.int[msgCount], IO.int[msgSetCount]];
IO.PutChar[cmd.out, IO.CR];
print out general stats about number of messages and number of message set
IO.PutChar[cmd.out, IO.CR];
IO.PutF[cmd.out, "---------------------------- "];
IO.PutChar[cmd.out, IO.CR];
IO.PutF[cmd.out, "Size of Active And Deleted Message Sets"];
IO.PutChar[cmd.out, IO.CR];
{
print out number of messages in active and deleted
msgSetDomain: DB.Domain ← DB.LookupDomain[name: "MsgSet", segment: $Walnut];
activeEntity: DB.Entity ← DB.LookupEntity[d: msgSetDomain, name: "Active"];
deletedEntity: DB.Entity ← DB.LookupEntity[d: msgSetDomain, name: "Deleted"];
rel: DB.Relation ← DB.LookupRelation[name: "msBasicInfo", segment: $Walnut];
rship1: DB.Relship ← DB.LookupProperty[r: rel, e: activeEntity];
rship2: DB.Relship ← DB.LookupProperty[r: rel, e: deletedEntity];
delCount: INTDB.V2I[DB.GetF[t: rship, field: 0]];
actCount: INTDB.V2I[DB.GetF[t: rship, field: 0]];
IO.PutF[cmd.out, "%5g %5g", IO.int[delCount], IO.int[actCount]];
IO.PutChar[cmd.out, IO.CR];
};
IO.PutChar[cmd.out, IO.CR];
IO.PutF[cmd.out, "---------------------------- "];
IO.PutChar[cmd.out, IO.CR];
IO.PutF[cmd.out, "No Message Set Operations"];
IO.PutChar[cmd.out, IO.CR];
rel ← DB.LookupRelation[name: "noMsgSetsOperRelation" , segment: $Walnut];
IO.PutChar[cmd.out, IO.CR];
Get the List of Key Indices from the relation
relshipSet ← DB.RelationSubset[r:rel,index:NIL,constraint:NIL];
DO
rship ← DB.NextRelship[rs: relshipSet];
IF rship = NIL THEN EXIT;
count ← DB.V2I[DB.GetF[t: rship, field: 0]];
opName ← DB.V2S[DB.GetF[t: rship, field: 1]];
IO.PutF[cmd.out, "%10g %5g", IO.rope[opName], IO.int[count]];
IO.PutChar[cmd.out, IO.CR];
ENDLOOP;
IO.PutChar[cmd.out, IO.CR];
IO.PutChar[cmd.out, IO.CR];
IO.PutF[cmd.out, "---------------------------- "];
IO.PutChar[cmd.out, IO.CR];
IO.PutF[cmd.out, "Single Message Set Operations"];
IO.PutChar[cmd.out, IO.CR];
rel ← DB.LookupRelation[name: "oneMsgSetsOperRelation" , segment: $Walnut];
Get the List of Key Indices from the relation
relshipSet ← DB.RelationSubset[r:rel,index:NIL,constraint:NIL];
DO
rship ← DB.NextRelship[rs: relshipSet];
IF rship = NIL THEN EXIT;
count ← DB.V2I[DB.GetF[t: rship, field: 0]];
opName ← DB.V2S[DB.GetF[t: rship, field: 1]];
msgSet1 ← DB.V2S[DB.GetF[t: rship, field: 2]];
IO.PutF[cmd.out, "%10g %10g %5g", IO.rope[opName], IO.rope[msgSet1], IO.int[count]];
IO.PutChar[cmd.out, IO.CR];
ENDLOOP;
IO.PutChar[cmd.out, IO.CR];
IO.PutChar[cmd.out, IO.CR];
IO.PutF[cmd.out, "---------------------------- "];
IO.PutChar[cmd.out, IO.CR];
IO.PutF[cmd.out, "Double Message Set Operations"];
IO.PutChar[cmd.out, IO.CR];
rel ← DB.LookupRelation[name: "twoMsgSetsOperRelation" , segment: $Walnut];
Get the List of Key Indices from the relation
relshipSet ← DB.RelationSubset[r:rel,index:NIL,constraint:NIL];
DO
rship ← DB.NextRelship[rs: relshipSet];
IF rship = NIL THEN EXIT;
count ← DB.V2I[DB.GetF[t: rship, field: 0]];
opName ← DB.V2S[DB.GetF[t: rship, field: 1]];
msgSet1 ← DB.V2S[DB.GetF[t: rship, field: 2]];
msgSet2 ← DB.V2S[DB.GetF[t: rship, field: 3]];
IO.PutF[cmd.out, "%10g %10g %10g %5g", IO.rope[opName], IO.rope[msgSet1], IO.rope[msgSet1], IO.int[count]];
IO.PutChar[cmd.out, IO.CR];
ENDLOOP;
DB.CloseTransaction[trans: transHandle];
};
Commander.Register["MonUser", MonUser,
 "Monitor stats for a single walnut user"];
Commander.Register["MonAll", MonAll,
 "monitor stats for all test participants"];
END.