org.abora.gold.snarf
Class TestPacker

java.lang.Object
  |
  +--org.abora.gold.java.AboraHeaper
        |
        +--org.abora.gold.xpp.basic.Heaper
              |
              +--org.abora.gold.snarf.DiskManager
                    |
                    +--org.abora.gold.snarf.TestPacker

public class TestPacker
extends DiskManager

Does not actually go to disk, but just tests that the protocol is being followed
correctly. Some of these tests may make it into the real SnarfPacker, but some of them
will remain debugging tools. Most operations only do enough real stuff to be able to check
that they work.
The TestPacker holds onto an IntegerTable of UInt8Arrays that contain the disk
representations of all the flocks. It also holds
myDisk contains a UInt8Array for every flock that made it to disk. They are assigned
sequential numbers.
myNewFlocks contains the flockInfos for new flocks, and thus contains the new flocks
wimpily.
myAlmostNewFlocks contains flocks that are under construction but have not yet finished.
myDestroyedFlocks contains flocks that will be destroyed upon exiting the current
consistent block.
myChangedFlocks points strongly at flocks that must be rewritten to disk.


Field Summary
protected  boolean amCommitting
           
protected  boolean blastOnError
           
protected  MuSet myAlmostNewFlocks
           
protected  Cookbook myBook
           
protected  IntegerTable myChangedFlocks
           
protected  IntegerVar myCountDown
           
protected  IntegerTable myDestroyedFlocks
           
protected  IntegerTable myDisk
           
protected  IntegerTable myFlocks
           
protected  Abraham myInitialFlock
           
protected  IntegerTable myNewFlocks
           
protected  int myNextHash
           
protected  IntegerVar myPersistInterval
           
protected  XcvrMaker myXcvrMaker
           
 
Fields inherited from class org.abora.gold.snarf.DiskManager
myFlockInfoTable, myFlockTable, myFluidSpace, SecretEmulsion
 
Fields inherited from class org.abora.gold.xpp.basic.Heaper
AllBlasts, BecomeMap, GarbageCount, InGC, InitializedClasses, InitializingClasses, LastMemory, NextClientRequestNumber, NotOneElementSignal, PackageTable, PromiseNameTable, StringHashSBoxes
 
Fields inherited from class org.abora.gold.java.AboraHeaper
ActiveClubs, CurrentAuthor, CurrentBertCanopyCache, CurrentBertCrum, CurrentChunk, CurrentGrandMap, CurrentKeyMaster, CurrentPacker, CurrentSensorCanopyCache, CurrentServer, CurrentSession, CurrentSessions, CurrentTrace, InitialEditClub, InitialOwner, InitialReadClub, InitialSponsor, InsideTransactionFlag
 
Constructor Summary
TestPacker(boolean blast, IntegerVar persistInterval)
           
 
Method Summary
 void assignSnarf(Abraham shep)
           
 void beginConsistent(IntegerVar dirty)
          This is called before entering consistent block.
static void bomb(TestPacker CHARGE)
           
 void checkNewFlockIndices()
           
 void committing(boolean flag)
           
 int computeHash(Abraham flock)
          Compute a hash on the contents
 int computeSize(Abraham flock)
          Send the snarf over a transmitter into a stream that just counts the bytes put into it.
 IntegerVar countDown()
          Decrement the countdown and return its new value
 void destroyFlock(FlockInfo info)
          Queue destroy of the given flock.
 void diskUpdate(FlockInfo info)
          The flock described by info is Dirty!! On the next commit, rewrite it to the disk.
 void dismantleFlock(FlockInfo info)
          The flock designated by info has completed all dismantling actions; throw it off the disk.
 void dropFlock(int token)
          The flock identified by token is being removed from memory.
 void endConsistent(IntegerVar dirty)
          This is called after exiting a consistent block.
 Abraham fetchCanonical(int hash, SnarfID snarfID, int index)
          If something is already imaged at that location, then return it.
 void flushChanges()
          Rewrite all flocks that have changed in this snarf.
 void forgetFlock(FlockInfo info)
          Remember that there are no more persistent pointers to the shepherd
described by info.
 Turtle getInitialFlock()
          Return the starting object for the entire backend.
 boolean insideCommit()
           
 boolean isFake()
           
static Heaper make(boolean blast, IntegerVar persistInterval)
           
 void makeConsistent()
          The virtual image in memory is now in a consistent state.
 void makePersistent()
           
 SpecialistRcvr makeRcvr(XnReadStream readStream)
           
 void makeReal(FlockInfo info)
          Retrieve from the disk the flock at index within the specified snarf.
 SpecialistXmtr makeXmtr(XnWriteStream writeStream)
           
 void mustBeInsideTransaction()
           
 void mustKnowShepherd(FlockInfo info)
          Check that I know about this shepherd
 void mustNotBeCommitting()
           
 int nextHashForEqual()
          Shepherds use a sequence number for their hash.
 void purge()
          Flush everything out to disk and remove all purgeable imaged objects from memory.
 void purgeClean()
           
 void purgeClean(boolean noneLocked)
          purge all shepherds that are currently clean, not locked, not dirty, and
purgeable.
 XnReadStream readStream(FlockInfo info)
          Get a read stream on the disk contents of the info
 void recordUpdate(FlockInfo info)
          The flock represented by info has changed.
 void refitFlocks()
          do nothing for now
 void registerStub(Abraham shep, SnarfID snarfID, int index)
          Called to register a newly created stub (by the diskSpecialist) in the internal
tables.
 void rememberFlock(FlockInfo info)
          There are now persistent pointers to the shepherd described by info.
 void resetCountDown()
           
 void storeAlmostNewShepherd(Abraham shep)
          Shep has been created, but is not consistent yet.
 void storeInitialFlock(Abraham turtle, XcvrMaker protocol, Cookbook cookbook)
          A turtle just got created!! Remember it as the initial flock.
 void storeNewFlock(Abraham shep)
          Shep just got created!! On some later commit, assign it to a snarf
and write it to the disk.
 XnWriteStream writeStream(FlockInfo info)
          Get a write stream on the disk contents of the info
 
Methods inherited from class org.abora.gold.snarf.DiskManager
actualHashForEqual, bomb, cleanupGarbage, consistent, consistent, consistent, consistentBlockAt, destruct, emulsion, exitTimeNonInherited, flockInfoTable, flockInfoTable, flockTable, flockTable, fluidSpace, fluidSpace, initializeDisk, insistent, insistent, insistent, linkTimeNonInherited, make, makeConsistentBegin, makeConsistentEnd, setHashCounter, staticTimeNonInherited
 
Methods inherited from class org.abora.gold.xpp.basic.Heaper
abstractDeclarationFor, abstractTypeFor, addMethodAttributeToInOf, addPackage, addPackageCategory, allClientProtocolOn, argumentTypesFor, arrow, blast, blast, BLAST, cachePromiseNameTable, cachePromiseNameTableIn, canYouBecome, cast, cleanPromiseClasses, clientClassesDo, clientFunctionsOn, clientMethodsOn, clientProtocol, clientProtocolDo, clientProtocolOn, clientProtocolOn, collectibleClasses, compare, compileClientSubclasses, compileConstantPromiseMethods, compileCreateFromRcvr, compileEQ, compileGeneratedClassMethod, compileGeneratedMethod, compileHook, compilePromise, compilePromiseDefaultMethods, compilePromiseFluidDeclarations, compilePromiseHandlers, compilePromiseMethods, compileRequestCreateMsgInArguments, compileRequestEvaluateMsgInReturningArguments, compileRPCSpecialistEvaluateMsgForReturningArguments, compileSendSelfTo, compileSendSelfToSendHook, compileStubbleMethods, compileSubclassStubbleMethods, computeMangle, computePreorder, constantTypeValue, convert, convertCopyDeclarations, convertDeferredDeclarations, convertProxyDeclarations, convertSubclassCopyDeclarations, convertSubclassDeferredDeclarations, convertSubclassProxyDeclarations, copyReferencesToType, create, create, create, create, create, create, create, create, create, create, createRequestClassArguments, definesProxyMethods, delete, deref, destroy, destructor, enum, enumFlags, equals, exportName, fetchAttribute, fetchPackage, fetchSuperCategory, fileOutClientProtocol, findCategory, findSenderAndReceiverMethods, findTailInto, flushPromiseNameTable, foo, freezeClientClasses, freezeClientProtocol, freezeStProtocol, frozenClasses, garbageCollect, garbageCollectFrom, gcOpportunity, gcOpportunity, generatedCategory, generatePromiseNames, getCategory, getOrMakePackage, getSuperCategory, handlerSignaturesFrom, hash, hashForEqual, hasProxyMethods, info_clientClasses, info_clientSideClasses, info_promiseClasses, info_stProtocol, inGC, initializedClasses, initializingClasses, initPackages, initStringHashSBoxes, inspectPieces, instanceSize, IntegerVar, isByProxy, isConstructed, isDestructed, isEqual, isEqualOrSubclassOf, isGenerated, isIntType, isKindOf, isRawType, isUnlocked, make, makeClassTable, makeFillTable, makeRequestTable, mangle, markChildren, markCount, markInstances, mayBecome, mayBecomeAnySubclassOf, new1, newX, nonCopyVariables, notWorking, pack, packageClasses, packagingCategory, parseExportName, passe, pointerToStaticMember, pointerToStaticMember, pointerToVirtualMember, preorderMax, preorderNumber, printOn, PROBLEM, problems, promiseClass, promiseDefaultValue, promiseName, promiseNameTable, promiseToAbstract, registerPackageCategory, removeGeneratedCode, removeStubbleMethods, removeSubclassGeneratedCode, removeSubclassStubbleMethods, requestProcedure, requestProceduresFrom, returnTypeFor, rootName, scheduleTermination, sendProxyTo, sendSelfTo, serverNameFor, setGC, signal, signals, smalltalkSelector, stClientProtocol, stubbleSelectorTokenReturnsArguments, subclassNonCopyVariables, takeOop, togglePromiseName, togglePromiseOfParse, unimplemented, unmangle, verifyFreeze, wipeStubble
 
Methods inherited from class org.abora.gold.java.AboraHeaper
asOop, basicInspect, displayString, error, hack, halt, inspect, knownBug, mightNotImplement, REQUIRES, shouldImplement, shouldNotImplement, stubbleForSubclassResponsibility, thingToDo, willNotImplement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myNextHash

protected int myNextHash

myInitialFlock

protected Abraham myInitialFlock

myFlocks

protected IntegerTable myFlocks

myChangedFlocks

protected IntegerTable myChangedFlocks

myDestroyedFlocks

protected IntegerTable myDestroyedFlocks

myAlmostNewFlocks

protected MuSet myAlmostNewFlocks

myNewFlocks

protected IntegerTable myNewFlocks

myXcvrMaker

protected XcvrMaker myXcvrMaker

myCountDown

protected IntegerVar myCountDown

myPersistInterval

protected IntegerVar myPersistInterval

myDisk

protected IntegerTable myDisk

myBook

protected Cookbook myBook

amCommitting

protected boolean amCommitting

blastOnError

protected boolean blastOnError
Constructor Detail

TestPacker

public TestPacker(boolean blast,
                  IntegerVar persistInterval)
Method Detail

destroyFlock

public void destroyFlock(FlockInfo info)
Queue destroy of the given flock. The destroy will probably happen later.

Overrides:
destroyFlock in class DiskManager

diskUpdate

public void diskUpdate(FlockInfo info)
Description copied from class: DiskManager
The flock described by info is Dirty!! On the next commit, rewrite it to the disk.

Overrides:
diskUpdate in class DiskManager

dismantleFlock

public void dismantleFlock(FlockInfo info)
The flock designated by info has completed all dismantling actions; throw it off the disk.

Overrides:
dismantleFlock in class DiskManager

dropFlock

public void dropFlock(int token)
Description copied from class: DiskManager
The flock identified by token is being removed from memory. For now, this is an
error if the flock has been updated. If the flock has been forgotten, then it will
be dismantled when next it comes in from disk.

Overrides:
dropFlock in class DiskManager

forgetFlock

public void forgetFlock(FlockInfo info)
Description copied from class: DiskManager
Remember that there are no more persistent pointers to the shepherd
described by info. If it gets garbage collected, remember to dismantle it
when it comes back in from the disk.

Overrides:
forgetFlock in class DiskManager

getInitialFlock

public Turtle getInitialFlock()
Description copied from class: DiskManager
Return the starting object for the entire backend. This will be the 0th
flock in the first snarf following the snarfInfo tables. This will eventually
always be a shepherd that describes the protocol of the rest of the disk.

Overrides:
getInitialFlock in class DiskManager

nextHashForEqual

public int nextHashForEqual()
Description copied from class: DiskManager
Shepherds use a sequence number for their hash. The most trivial (reasonable)
implementation just uses a BatchCounter. This will not be persistent till we get
Turtles.

Overrides:
nextHashForEqual in class DiskManager

rememberFlock

public void rememberFlock(FlockInfo info)
Description copied from class: DiskManager
There are now persistent pointers to the shepherd described by info. See forgetFlock.

Overrides:
rememberFlock in class DiskManager

storeAlmostNewShepherd

public void storeAlmostNewShepherd(Abraham shep)
Description copied from class: DiskManager
Shep has been created, but is not consistent yet. storeNewFlock must be called on it
before the next makeConsistent.

Overrides:
storeAlmostNewShepherd in class DiskManager

storeInitialFlock

public void storeInitialFlock(Abraham turtle,
                              XcvrMaker protocol,
                              Cookbook cookbook)
Description copied from class: DiskManager
A turtle just got created!! Remember it as the initial flock.

Overrides:
storeInitialFlock in class DiskManager

storeNewFlock

public void storeNewFlock(Abraham shep)
Shep just got created!! On some later commit, assign it to a snarf
and write it to the disk.

Overrides:
storeNewFlock in class DiskManager

checkNewFlockIndices

public void checkNewFlockIndices()

committing

public void committing(boolean flag)

countDown

public IntegerVar countDown()
Decrement the countdown and return its new value


mustBeInsideTransaction

public void mustBeInsideTransaction()

mustKnowShepherd

public void mustKnowShepherd(FlockInfo info)
Check that I know about this shepherd


mustNotBeCommitting

public void mustNotBeCommitting()

resetCountDown

public void resetCountDown()

fetchCanonical

public Abraham fetchCanonical(int hash,
                              SnarfID snarfID,
                              int index)
Description copied from class: DiskManager
If something is already imaged at that location, then return it. If there is already
an existing stub with the same hash at a different location, follow them both till we
know that they are actually different objects.

Overrides:
fetchCanonical in class DiskManager

makeReal

public void makeReal(FlockInfo info)
Description copied from class: DiskManager
Retrieve from the disk the flock at index within the specified snarf. Since
stubs are canonical, and this only gets called by stubs, the existing stub will
*become* the shepherd for the flock.

Overrides:
makeReal in class DiskManager

registerStub

public void registerStub(Abraham shep,
                         SnarfID snarfID,
                         int index)
Description copied from class: DiskManager
Called to register a newly created stub (by the diskSpecialist) in the internal
tables. The diskSpecialist in particular calls this when it couldn't find an
already existing stub (with fetchCacnonical) representing the flock at the
particular location.

Overrides:
registerStub in class DiskManager

computeSize

public int computeSize(Abraham flock)
Send the snarf over a transmitter into a stream that just counts the bytes put into it.


makeRcvr

public SpecialistRcvr makeRcvr(XnReadStream readStream)

makeXmtr

public SpecialistXmtr makeXmtr(XnWriteStream writeStream)

readStream

public XnReadStream readStream(FlockInfo info)
Get a read stream on the disk contents of the info


writeStream

public XnWriteStream writeStream(FlockInfo info)
Get a write stream on the disk contents of the info


assignSnarf

public void assignSnarf(Abraham shep)

flushChanges

public void flushChanges()
Rewrite all flocks that have changed in this snarf.


recordUpdate

public void recordUpdate(FlockInfo info)
The flock represented by info has changed. Record it in the
bookkeeping data-structures. This must be called by all things
that affect whether the flock gets rewritten to disk.


refitFlocks

public void refitFlocks()
do nothing for now


computeHash

public int computeHash(Abraham flock)
Compute a hash on the contents


purgeClean

public void purgeClean()

beginConsistent

public void beginConsistent(IntegerVar dirty)
Description copied from class: DiskManager
This is called before entering consistent block. 'dirty' is the block's declaration of
the maximum number of shepherds which it can dirty. If this is a top level consistent
block, the virtual image in memory is now in a consistent state. It may be written to the
disk if necessary.

Overrides:
beginConsistent in class DiskManager

endConsistent

public void endConsistent(IntegerVar dirty)
Description copied from class: DiskManager
This is called after exiting a consistent block.

Overrides:
endConsistent in class DiskManager

insideCommit

public boolean insideCommit()
Overrides:
insideCommit in class DiskManager

makePersistent

public void makePersistent()

purge

public void purge()
Description copied from class: DiskManager
Flush everything out to disk and remove all purgeable imaged objects from memory.

Overrides:
purge in class DiskManager

purgeClean

public void purgeClean(boolean noneLocked)
Description copied from class: DiskManager
purge all shepherds that are currently clean, not locked, not dirty, and
purgeable. Purging just turns them into stubs, freeing the rest of their flocks.
Garbage collection can clean up the flocks and any stubs no longer pointed to
by something in memory.

Overrides:
purgeClean in class DiskManager

makeConsistent

public void makeConsistent()
Description copied from class: DiskManager
The virtual image in memory is now in a consistent state. It may be written to
the disk if necessary.

Overrides:
makeConsistent in class DiskManager

isFake

public boolean isFake()
Overrides:
isFake in class DiskManager

bomb

public static void bomb(TestPacker CHARGE)

make

public static Heaper make(boolean blast,
                          IntegerVar persistInterval)


Translation - Copyright © 2003 David G Jones. All Rights Reserved.
Original Udanax-Gold - Copyright © 1979-1999 Udanax.com. All rights reserved.