WalnutDBInfoImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Willie-Sue, August 1, 1985 9:57:19 am PDT
DIRECTORY
BasicTime USING [GMT],
DB
USING [
Attribute, AttributeValueList, Entity, EntitySet, GMT, Relship, Transaction, Value,
DeclareEntity, DeclareRelship, DomainSubset, FlushCache, GetF, GetSegmentInfo,
NameOf, NextEntity, ReleaseEntitySet, SetF,
V2B, V2I, V2T],
Rope,
WalnutDefs USING [Error, ServerInfo],
WalnutKernelDefs USING [LogExpungePhase],
WalnutDB,
WalnutDBInternal USING [CarefullyApply],
WalnutSchema;
Types
ROPE: TYPE = Rope.ROPE;
GMT: TYPE = BasicTime.GMT;
Msg: TYPE = ROPE;
Entity: TYPE = DB.Entity;
Relship: TYPE = DB.Relship;
ServerInfo: TYPE = WalnutDefs.ServerInfo;
Variables
DBIntValue: REF INT ← NEW[INT];
DBBoolValue: REF BOOL ← NEW[BOOL];
DBGmtValue: REF DB.GMT ← NEW[DB.GMT];
Operations used during Expunge, NewMail and reading Archive files
GetExpungeInfo:
PUBLIC PROC
RETURNS[
firstDestroyedMsgPos, bytesInDestroyedMsgs:
INT] = {
Gei:
PROC = {
firstDestroyedMsgPos← DB.V2I[DB.GetF[rLogInfo, gFirstDestroyedMsgPos]];
bytesInDestroyedMsgs← DB.V2I[DB.GetF[rLogInfo, gBytesInDestroyedMsgs]]
};
WalnutDBInternal.CarefullyApply[Gei];
};
SetExpungeInfo:
PUBLIC PROC[firstDestroyedMsgPos, bytesInDestroyedMsgs:
INT] = {
Sei:
PROC = {
DBIntValue^ ← firstDestroyedMsgPos;
DB.SetF[rLogInfo, gFirstDestroyedMsgPos, DBIntValue];
DBIntValue^ ← bytesInDestroyedMsgs;
DB.SetF[rLogInfo, gBytesInDestroyedMsgs, DBIntValue];
};
WalnutDBInternal.CarefullyApply[Sei];
};
GetLogExpungePhase:
PUBLIC PROC
RETURNS[exp: WalnutKernelDefs.LogExpungePhase] = {
Gep:
PROC = {
ph: INT← DB.V2I[DB.GetF[rExpungeInfo, gLogExpungePhase]];
SELECT ph
FROM
0 => exp← idle;
1 => exp← initializingExpungeLog;
2 => exp← writingExpungeLog;
3 => exp← swappingLogs;
ENDCASE => {
SIGNAL WalnutDefs.Error[$db, $Bug, "Bad expungePhase value"];
exp← idle
};
};
WalnutDBInternal.CarefullyApply[Gep];
};
SetLogExpungePhase:
PUBLIC PROC[exp: WalnutKernelDefs.LogExpungePhase] = {
Sep:
PROC = {
SELECT exp
FROM
idle => DBIntValue^ ← 0;
initializingExpungeLog => DBIntValue^ ← 1;
writingExpungeLog => DBIntValue^ ← 2;
swappingLogs => DBIntValue^ ← 3;
ENDCASE => {
SIGNAL WalnutDefs.Error[$db, $Bug, "Bad expungePhase value"];
DBIntValue^ ← 0;
};
DB.SetF[rExpungeInfo, gLogExpungePhase, DBIntValue];
DB.FlushCache[DB.GetSegmentInfo[WalnutDB.walnutSegment].trans];
};
WalnutDBInternal.CarefullyApply[Sep];
};
GetExpungeProgressInfo:
PUBLIC
PROC
RETURNS[currentLogPos, expungeLogPos:
INT] = {
Gepi:
PROC = {
currentLogPos← DB.V2I[DB.GetF[rExpungeInfo, gCurrentLogPos]];
expungeLogPos← DB.V2I[DB.GetF[rExpungeInfo, gExpungeLogPos]];
};
WalnutDBInternal.CarefullyApply[Gepi];
};
SetExpungeProgressInfo:
PUBLIC
PROC[currentLogPos, expungeLogPos:
INT] = {
Sepi:
PROC = {
DBIntValue^ ← currentLogPos;
DB.SetF[rExpungeInfo, gCurrentLogPos, DBIntValue];
DBIntValue^ ← expungeLogPos;
DB.SetF[rExpungeInfo, gExpungeLogPos, DBIntValue];
DB.FlushCache[DB.GetSegmentInfo[WalnutDB.walnutSegment].trans];
};
WalnutDBInternal.CarefullyApply[Sepi];
};
GetExpungeFileID:
PUBLIC
PROC
RETURNS[expungeFileID:
INT] = {
Gefi: PROC = { expungeFileID← DB.V2I[DB.GetF[rExpungeInfo, gExpungeFileID]] };
WalnutDBInternal.CarefullyApply[Gefi];
};
SetExpungeFileID:
PUBLIC
PROC[expungeFileID:
INT] = {
Sefi:
PROC = {
DBIntValue^ ← expungeFileID;
DB.SetF[rExpungeInfo, gExpungeFileID, DBIntValue]
};
WalnutDBInternal.CarefullyApply[Sefi];
};
SetAcceptNewMailPos:
PUBLIC
PROC[pos:
INT] = {
Sanmp:
PROC = {
DBIntValue^ ← pos;
DB.SetF[rNewMailInfo, gAcceptNewMailLogPos, DBIntValue]
};
WalnutDBInternal.CarefullyApply[Sanmp];
};
GetAcceptNewMailPos:
PUBLIC
PROC
RETURNS[pos:
INT] = {
Ganmp:
PROC =
{ pos ← DB.V2I[DB.GetF[rNewMailInfo, gAcceptNewMailLogPos]] };
WalnutDBInternal.CarefullyApply[Ganmp];
};
SetAddingServerMsgs:
PUBLIC
PROC[addingServerMsgs:
BOOL] = {
Sasm:
PROC = {
DBBoolValue^ ← addingServerMsgs;
DB.SetF[rNewMailInfo, gAddingServerMsgs, DBBoolValue]
};
WalnutDBInternal.CarefullyApply[Sasm];
};
GetAddingServerMsgs:
PUBLIC
PROC
RETURNS[addingServerMsgs:
BOOL] = {
Sasm:
PROC =
{ addingServerMsgs← DB.V2B[DB.GetF[rNewMailInfo, gAddingServerMsgs]] };
WalnutDBInternal.CarefullyApply[Sasm];
};
EnumerateServers:
PUBLIC
PROC
RETURNS[serverList:
LIST
OF ServerInfo] = {
Gsi:
PROC = {
enum: DB.EntitySet ← DB.DomainSubset[ServerDomain];
se: Entity;
FOR se←
DB.NextEntity[enum],
DB.NextEntity[enum]
UNTIL se =
NIL
DO
rel: Relship = DB.DeclareRelship[sBasicInfo, LIST[[sBIOf, se]]];
si: ServerInfo;
si.server ← DB.NameOf[se];
si.num ← DB.V2I[DB.GetF[rel, sBINum]];
serverList ← CONS[si, serverList];
ENDLOOP;
DB.ReleaseEntitySet[enum];
};
WalnutDBInternal.CarefullyApply[Gsi];
};
GetServerInfo:
PUBLIC
PROC[server:
ROPE]
RETURNS[num:
INT] = {
Gsr:
PROC = {
se: Entity = DB.DeclareEntity[ServerDomain, server, OldOnly];
IF se #
NIL
THEN {
rel: Relship = DB.DeclareRelship[sBasicInfo, LIST[[sBIOf, se]]];
num ← DB.V2I[DB.GetF[rel, sBINum]]
}
ELSE num ← 0;
};
WalnutDBInternal.CarefullyApply[Gsr];
};
SetNewMailInfo:
PUBLIC
PROC[logLen:
INT, when:
GMT, server:
ROPE, num:
INT] = {
Snmi:
PROC = {
IF server #
NIL
THEN {
se: Entity = DB.DeclareEntity[ServerDomain, server];
rel: Relship = DB.DeclareRelship[sBasicInfo, LIST[[sBIOf, se]]];
DBIntValue^ ← num;
DB.SetF[rel, sBINum, DBIntValue];
};
DBIntValue^ ← logLen;
DB.SetF[rNewMailInfo, gNewMailLogLength, DBIntValue];
DBGmtValue^ ← [when];
DB.SetF[rNewMailInfo, gLastNewMailTimeStamp, DBGmtValue]
};
WalnutDBInternal.CarefullyApply[Snmi];
};
SetNewMailLogLength:
PUBLIC
PROC[logLen:
INT] = {
Gnml:
PROC = {
DBIntValue^ ← logLen;
DB.SetF[rNewMailInfo, gNewMailLogLength, DBIntValue];
};
WalnutDBInternal.CarefullyApply[Gnml];
};
GetNewMailLogLength:
PUBLIC
PROC
RETURNS[logLen:
INT] = {
Gnml:
PROC =
{ logLen ← DB.V2I[DB.GetF[rNewMailInfo, gNewMailLogLength]] };
WalnutDBInternal.CarefullyApply[Gnml];
};
GetLastNewMailTimeStamp:
PUBLIC
PROC
RETURNS[when:
GMT] = {
Glnmts: PROC = { when ← DB.V2T[DB.GetF[rNewMailInfo, gLastNewMailTimeStamp]] };
WalnutDBInternal.CarefullyApply[Glnmts];
};
SetCopyMailLogPos:
PUBLIC
PROC[pos:
INT] = {
Scml:
PROC = {
DBIntValue^ ← pos;
DB.SetF[rNewMailInfo, gCopyNewMailLogPos, DBIntValue]
};
WalnutDBInternal.CarefullyApply[Scml];
};
GetCopyMailLogPos:
PUBLIC
PROC
RETURNS[pos:
INT] = {
Gcml: PROC = { pos ← DB.V2I[DB.GetF[rNewMailInfo, gCopyNewMailLogPos]] };
WalnutDBInternal.CarefullyApply[Gcml];
};
SetReadArchivePos:
PUBLIC
PROC[pos:
INT] = {
Srap:
PROC = {
DBIntValue^ ← pos;
DB.SetF[rReadArchiveInfo, gReadArchiveLogPos, DBIntValue]
};
WalnutDBInternal.CarefullyApply[Srap];
};
GetReadArchivePos:
PUBLIC
PROC
RETURNS[pos:
INT] = {
Grap: PROC = { pos ← DB.V2I[DB.GetF[rReadArchiveInfo, gReadArchiveLogPos]] };
WalnutDBInternal.CarefullyApply[Grap];
};
SetCopyReadArchivePos:
PUBLIC
PROC[pos:
INT] = {
Scra:
PROC = {
DBIntValue^ ← pos;
DB.SetF[rReadArchiveInfo, gCopyReadArchiveLogPos, DBIntValue]
};
WalnutDBInternal.CarefullyApply[Scra];
};
GetCopyReadArchivePos:
PUBLIC
PROC
RETURNS[pos:
INT] = {
Gcra: PROC = { pos ← DB.V2I[DB.GetF[rReadArchiveInfo, gCopyReadArchiveLogPos]] };
WalnutDBInternal.CarefullyApply[Gcra];
};