DIRECTORY YggEnvironment USING[PageCount, PageRun], YggInternal USING[Document, LogRecordID, TransHandle]; YggLogMap: CEDAR DEFINITIONS = BEGIN Error: ERROR [error: CallingErrorType]; CallingErrorType: TYPE = {alreadySet, exceedsFileSize}; FileDescription: TYPE = RECORD [ registered: BOOLEAN, -- registered in the YggLogMap. exists: BOOLEAN, -- file exists from this transaction's viewpoint; i.e., either it was created by this trans, or its creation has been committed and it has not been deleted by this trans. created: BOOLEAN, -- file was created by this transaction. deleted: BOOLEAN, -- file was deleted by this transaction. sizeChanged: BOOLEAN]; -- file's size was changed by this transaction. DescribeFile: PROCEDURE [file: YggInternal.Document, trans: YggInternal.TransHandle] RETURNS [fileDesc: FileDescription]; RegisterCreate: PROCEDURE [file: YggInternal.Document, trans: YggInternal.TransHandle]; RegisterDelete: PROCEDURE [file: YggInternal.Document, trans: YggInternal.TransHandle]; SetUncommittedSize: PROCEDURE [file: YggInternal.Document, trans: YggInternal.TransHandle, size: YggEnvironment.PageCount]; GetUncommittedSize: PROCEDURE [file: YggInternal.Document, trans: YggInternal.TransHandle] RETURNS [size: YggEnvironment.PageCount]; SetCommittedSize: PROCEDURE [file: YggInternal.Document, size: YggEnvironment.PageCount]; GetCommittedSize: PROCEDURE [file: YggInternal.Document] RETURNS [size: YggEnvironment.PageCount]; SetCommittedHighWaterMark: PROCEDURE [file: YggInternal.Document, highWaterMark: YggEnvironment.PageCount]; GetCommittedHighWaterMark: PROCEDURE [file: YggInternal.Document] RETURNS [highWaterMark: YggEnvironment.PageCount]; RegisterPages: PROCEDURE [file: YggInternal.Document, trans: YggInternal.TransHandle, pageRun: YggEnvironment.PageRun, logRecordID: YggInternal.LogRecordID]; UnregisterPages: PROCEDURE [file: YggInternal.Document, pageRun: YggEnvironment.PageRun]; MappedPageRun: TYPE = RECORD [ pageRun: YggEnvironment.PageRun, -- the interval which the caller is interested in. details: SELECT location: Location FROM base => NULL, log => [logRecordID: YggInternal.LogRecordID, -- loc of pageRun in the log. logMapPageRun: YggEnvironment.PageRun, -- describes YggLogMap entry, which is a subinterval of the pageRun in the log. checkedOut: BOOLEAN], -- the YggLogMap entry has been checked out to this caller. ENDCASE]; Location: TYPE = {base, log}; CheckOutOption: TYPE = {none, checkOut}; LocatePages: PROCEDURE [file: YggInternal.Document, trans: YggInternal.TransHandle, pageRun: YggEnvironment.PageRun, checkOut: CheckOutOption _ checkOut] RETURNS [mappedPageRun: MappedPageRun]; LocateAnyPagesForTrans: PROCEDURE [file: YggInternal.Document, trans: YggInternal.TransHandle] RETURNS [found: BOOLEAN, logRecordID: YggInternal.LogRecordID, logMapPageRun: YggEnvironment.PageRun]; UnregisterTrans: PROCEDURE [file: YggInternal.Document, trans: YggInternal.TransHandle]; END. ~YggLogMap.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Last edited by Taft on November 8, 1982 4:47 pm Kolling on November 18, 1982 4:25 pm Hauser, March 8, 1985 10:54:06 am PST Bob Hagmann May 4, 1988 5:35:34 pm PDT The YggLogMap is self-managing in the following sense: All procedures operate correctly even when the YggLogMapHandle for the given Document is NIL. In particular, the procedures that read from the YggLogMap return "nil" or "empty" results, while the procedures that write into the YggLogMap first cause a YggLogMapObject to be created and registered with the Document. Furthermore, when the YggLogMapObject ceases to contain any useful information, it automatically unregisters itself with the FileMap. (This needs to be done only at UnregisterTrans time.) In general, YggLogMap procedures should NOT be called while holding the file object monitor, because YggLogMap might need to register a new YggLogMapHandle with the object, and a deadlock would result. the remaining fields are defined only if registered = TRUE: non-fatal errors: none. non-fatal errors: none. A fatal error is raised if the YggLogMapObject createTrans field is not NIL. non-fatal errors: none. A fatal error is raised if the YggLogMapObject deleteTrans field is not NIL. non-fatal errors: none. Remembers the uncommitted size of the file and which trans is setting it. If trans # NIL and the previous trans that set the uncommitted size # NIL and these transactions do not match, a fatal error is raised. non-fatal errors: none. Returns the uncommitted size (LAST[PageCount] if it has never been set). If the previous trans that set the uncommitted size # NIL and if trans does not match the previous trans, then if the previous trans is committed a fatal error is raised else LAST[PageCount] is returned. non-fatal errors: none. Remembers the committed size of the file. non-fatal errors: none. Returns the committed size of the file (LAST[PageCount] if it has never been set). non-fatal errors: none. Remembers the committed high water mark for the file. non-fatal errors: none. Returns the committed high water mark for the file (LAST[PageCount] if it has never been set). For file pages, the YggLogMap remembers only the LogRecordID for the data written, rather than the actual data; it is the client's responsibility to subsequently read the log, if necessary. non-fatal errors: none. Registers a logged write of the pages identified by for transaction trans, identified in the log by logRecordID. The log record contains exactly this pageRun. If writes are already registered for any of those pages by the same transaction, the old writes are forgotten. If writes are already registered for a different transaction, a fatal error is raised. non-fatal errors: none. Forgets registered writes for the specified pageRun. If the does not exactly match a checked out entry in the YggLogMap, a fatal error is raised. A caller who checks out an entry is required to carry out the operation described by that entry and then Unregister the entry from the YggLogMap before proceeding further. Checking out an entry prevents other clients from checking out the same entry. If the entry is already checked out, the checkOut option waits until that entry has been unregistered (or, more likely, on something less specific) and then tries again. non-fatal errors: Error{exceedsFileSize}; Returns a MappedPageRun describing the initial interval of pageRun. If the YggLogMap knows the size of the file as seen by this transaction (precisely, if SetUncommittedSize has been done by this trans or, failing that, if SetCommittedSize has been done), exceedsFileSize is errored if any part of the pageRun is past the eof. No checking is done to see if the file exists. If the initial interval of pageRun is not represented in the YggLogMap or if it is represented but for an uncommitted different transaction, returns location = base. Otherwise, handles the CheckOutOption, and if it doesn't have to wait and retry, returns location = log and a MappedPageRun log field containing the data which describes the initial interval. The pageRun describes the initial interval available. non-fatal errors: none. Looks for registered writes for this trans in file. If there is an unchecked out one, checks it out, and returns it. Otherwise, if the only ones it can find are ones which have already been checked out, it waits until they all go away. When unable to find any, returns found = FALSE. non-fatal errors: none. Removes from the LogMap all information that was set by transaction trans for this file. If fields that were associated with this trans will persist, they are set to their default initial values. If the intentionsTable becomes empty and no trans fields in the LogMapObject contain references to other transactions, the LogMapObject is thrown away. Hauser, March 8, 1985 10:53:17 am PST Nodified, added copyright. ʘšœ™Icodešœ Ïmœ1™<—šœ™Jšœ ™ Jšœ$™$K™%K™&—J˜JšÏk ˜ ˜˜Jšžœ˜—˜ Jšžœ%˜*J˜J˜——Jšœ žœž œ˜J˜Jšž˜J˜J˜Jšœ±™±J˜JšœÉ™ÉJ˜J˜Jšœžœ˜'Jšœžœ!˜7J˜J˜šœžœžœ˜ Jšœ žœÏc˜5Jšœ;™;JšœžœŸ«˜½Jšœ žœŸ(˜;Jšœ žœŸ(˜;Jšœ žœŸ/˜GJ˜—šÏn œž œ=˜Tšžœ˜$Jšœ™J˜J˜——š œž œ?˜XJšœ™JšœL™LJ˜—š œž œ>˜WJšœ™JšœL™LJ˜J˜—Jš œž œ$˜A˜9Jšœ™JšœÒ™ÒJ˜—š œž œ$˜Ašœžœ"˜BJšœ™Jšœ•™•J˜——š œž œ#˜>˜Jšœ™Jšœ+™+J˜——š œž œžœ˜G˜Jšœ™JšœR™RJ˜J˜——š œž œ,˜P˜Jšœ™Jšœ5™5J˜——š œž œž˜I˜*Jšœ™Jšœ^™^J˜J˜——Jšœ¿™¿J˜š  œž œ=˜U˜GJšœ™Jšœ÷™÷J˜——š œž œ&˜@˜Jšœ™Jšœ¢™¢J˜J˜——šœžœžœ˜Jšœ!Ÿ2˜Sšœ žœž˜'Jšœžœ˜ šœ/Ÿ˜LJšœ(ŸO˜wJšœ žœŸ;˜R—Jšžœ˜ J˜——Jšœ žœ˜J˜šœžœ˜)Jšœ¦™¦J˜—š  œž œ=˜SJšœFž˜M˜Jšœ*™*Jšœ–™–J˜J˜——š œž œ$˜Ešœžœ žœ˜>J˜@Jšœ™Jšœž™žJ˜—J˜J˜—š œž œ$˜>J˜Jšœ™JšœÝ™ÝJ˜J˜J˜J˜—Jšžœ˜J˜J˜J˜J˜™%K™—K™—…— °#C