ozone core API

org.ozoneDB.core.storage.magicStore
Class MagicObjectContainer

java.lang.Object
  extended byorg.ozoneDB.core.AbstractObjectContainer
      extended byorg.ozoneDB.core.storage.StorageObjectContainer
          extended byorg.ozoneDB.core.storage.wizardStore.WizardObjectContainer
              extended byorg.ozoneDB.core.wizardStore.WizardObjectContainer
                  extended byorg.ozoneDB.core.storage.magicStore.MagicObjectContainer
All Implemented Interfaces:
java.io.Externalizable, Lockable, ObjectContainer, java.io.Serializable

public final class MagicObjectContainer
extends WizardObjectContainer
implements java.io.Externalizable

The "Wizard" implementation of the ObjectContainer interface. Much of the lock functionality is implemented in the MagicCluster class. Note: only the join/commit/abort methods are synchronized. All other methods are guaranteed to run exclusively through the explicite locks

Version:
$Revision$Date$ We need to extend WizardObjectContainer to be compatible with wizardStore note: if we drop backward compatibility it should extend StorageObjectContainer
Author:
SMB, Medium.net, Leo Mekenkamp, Per Nyfelt
See Also:
Serialized Form

Field Summary
protected  int garbageCollectionLevel
          The garbage collection level of this ObjectContainer.
protected  int invokeCount
           
protected  long modTime
           
protected  java.lang.String name
           
protected  ObjectID objID
           
protected static long serialVersionUID
           
protected static byte subSerialVersionUID
           
protected  org.ozoneDB.OzoneCompatible target
          The currently commited target object of the container.
 
Fields inherited from class org.ozoneDB.core.storage.StorageObjectContainer
cluster
 
Fields inherited from class org.ozoneDB.core.AbstractObjectContainer
shouldCallOnActivate, shouldCallOnPassivate, state
 
Fields inherited from interface org.ozoneDB.core.ObjectContainer
IMPLNAME_POSTFIX, PROXYNAME_POSTFIX, STATE_CLEAN, STATE_CREATED, STATE_DELETED, STATE_MODIFIED, STATE_READ
 
Constructor Summary
MagicObjectContainer()
          Constructor for object serialization via Externalizable.
MagicObjectContainer(ObjectID _objID)
           
 
Method Summary
 DxCollection allLockers()
          Returns a collection of Locker objects that currently lock this Lockable object.
 void deleteTarget()
           
 int ensureGarbageCollectionLevel(int newGarbageCollectionLevel)
          Ensures that the garbageCollectionLevel is at least the given currentGarbageCollectionLevel.
 int getGarbageCollectionLevel()
          Returns the garbageCollectionLevel this ObjectContainer has reached due to (not) calling ensureGarbageCollectionLevel(int).
 boolean hasSameClusterAs(MagicObjectContainer container)
           
 ObjectID id()
           
 void invokeOnActivate()
           
 java.lang.Object invokeTarget(Env env, java.lang.String methodName, java.lang.String sig, java.lang.Object[] args)
           
protected  boolean isCreated()
           
 boolean isDeleted()
           
 boolean isInvoked()
           
 boolean isPinned()
          Returns wether this ObjectContainer is pinned.
 Lock lock()
           
 int lockLevel(Transaction ta)
           
 long modTime()
          Returns the time when the container was last commited with lock level greater than Lock.LEVEL_READ.
 java.lang.String name()
           
 void nameTarget(java.lang.String _name)
           
 void notifyAllTAs(Transaction ta)
           
 Permissions permissions()
           
 void pin()
          Pins this ObjectContainer.
 void readExternal(java.io.ObjectInput in)
           
 void setName(java.lang.String _name)
           
 void setTarget(org.ozoneDB.OzoneCompatible _target)
           
 org.ozoneDB.OzoneCompatible target()
           
 java.lang.Class targetClass()
          Returns the Class for the target object.
 java.lang.String toString()
           
 void touch()
           
 void unpin()
          Unpins this ObjectContainer.
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class org.ozoneDB.core.storage.wizardStore.WizardObjectContainer
getCluster, hasSameClusterAs, setCluster
 
Methods inherited from class org.ozoneDB.core.storage.StorageObjectContainer
equals, updateLockLevel
 
Methods inherited from class org.ozoneDB.core.AbstractObjectContainer
clearState, constructorFor, createTarget, database, flushMethodCache, getCurrentDatabase, getCurrrentTransaction, getEnv, invokeOnPassivate, invokeTarget, methodFor, ozoneProxy, raiseState, requireWriteLocking, setShouldCallOnActivate, setShouldCallOnPassivate, shouldOnActivateBeCalled, shouldOnPassivateBeCalled, state, targetClone
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

protected static final long serialVersionUID
See Also:
Constant Field Values

subSerialVersionUID

protected static final byte subSerialVersionUID
See Also:
Constant Field Values

target

protected org.ozoneDB.OzoneCompatible target
The currently commited target object of the container.


objID

protected ObjectID objID

name

protected java.lang.String name

invokeCount

protected transient int invokeCount

modTime

protected long modTime

garbageCollectionLevel

protected int garbageCollectionLevel
The garbage collection level of this ObjectContainer. This number is compared to the currentGarbageCollectionLevel of the database. Is this number smaller, then this object may be reachable. Is it equal, then this object is reachable, but it's descendants are not yet considered. Is it greater, then this object is reachable and this object is processed, it's descendants have been considered. At the end of the mark-process, every object which still is not reachable must be unreachable, so at this and, a smaller garbageCollectionLevel than currentGarbageCollectionLevel means that this object may be deleted.

Constructor Detail

MagicObjectContainer

public MagicObjectContainer()
Constructor for object serialization via Externalizable.


MagicObjectContainer

public MagicObjectContainer(ObjectID _objID)
Method Detail

modTime

public long modTime()
Description copied from interface: ObjectContainer
Returns the time when the container was last commited with lock level greater than Lock.LEVEL_READ. The value returned by this method should only be compared against return values of this method.

Specified by:
modTime in interface ObjectContainer
Overrides:
modTime in class WizardObjectContainer

isDeleted

public boolean isDeleted()
Overrides:
isDeleted in class WizardObjectContainer

isCreated

protected boolean isCreated()
Overrides:
isCreated in class WizardObjectContainer

targetClass

public java.lang.Class targetClass()
Returns the Class for the target object. This method is used by AbstractObjectContainer.

Specified by:
targetClass in interface ObjectContainer
Overrides:
targetClass in class WizardObjectContainer

setTarget

public void setTarget(org.ozoneDB.OzoneCompatible _target)
Specified by:
setTarget in interface ObjectContainer
Overrides:
setTarget in class WizardObjectContainer

target

public org.ozoneDB.OzoneCompatible target()
Specified by:
target in interface ObjectContainer
Overrides:
target in class WizardObjectContainer

touch

public void touch()
Specified by:
touch in interface ObjectContainer
Overrides:
touch in class WizardObjectContainer

lock

public Lock lock()
Specified by:
lock in interface ObjectContainer
Overrides:
lock in class WizardObjectContainer

notifyAllTAs

public void notifyAllTAs(Transaction ta)
Overrides:
notifyAllTAs in class WizardObjectContainer

permissions

public Permissions permissions()
Specified by:
permissions in interface ObjectContainer
Overrides:
permissions in class WizardObjectContainer

lockLevel

public int lockLevel(Transaction ta)
Overrides:
lockLevel in class WizardObjectContainer

isInvoked

public boolean isInvoked()
Overrides:
isInvoked in class WizardObjectContainer

invokeTarget

public java.lang.Object invokeTarget(Env env,
                                     java.lang.String methodName,
                                     java.lang.String sig,
                                     java.lang.Object[] args)
                              throws java.lang.Exception
Specified by:
invokeTarget in interface ObjectContainer
Overrides:
invokeTarget in class WizardObjectContainer
Throws:
java.lang.Exception

invokeOnActivate

public void invokeOnActivate()
Specified by:
invokeOnActivate in interface ObjectContainer
Overrides:
invokeOnActivate in class WizardObjectContainer

deleteTarget

public void deleteTarget()
Specified by:
deleteTarget in interface ObjectContainer
Overrides:
deleteTarget in class WizardObjectContainer

nameTarget

public void nameTarget(java.lang.String _name)
Specified by:
nameTarget in interface ObjectContainer
Overrides:
nameTarget in class WizardObjectContainer

allLockers

public DxCollection allLockers()
Description copied from interface: Lockable
Returns a collection of Locker objects that currently lock this Lockable object.

Specified by:
allLockers in interface Lockable
Overrides:
allLockers in class WizardObjectContainer

id

public ObjectID id()
Specified by:
id in interface ObjectContainer
Overrides:
id in class WizardObjectContainer

name

public java.lang.String name()
Specified by:
name in interface ObjectContainer
Overrides:
name in class WizardObjectContainer

setName

public void setName(java.lang.String _name)
Specified by:
setName in interface ObjectContainer
Overrides:
setName in class WizardObjectContainer

writeExternal

public final void writeExternal(java.io.ObjectOutput out)
                         throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Overrides:
writeExternal in class WizardObjectContainer
Throws:
java.io.IOException

readExternal

public final void readExternal(java.io.ObjectInput in)
                        throws java.io.IOException,
                               java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Overrides:
readExternal in class WizardObjectContainer
Throws:
java.io.IOException
java.lang.ClassNotFoundException

ensureGarbageCollectionLevel

public int ensureGarbageCollectionLevel(int newGarbageCollectionLevel)
Ensures that the garbageCollectionLevel is at least the given currentGarbageCollectionLevel. The return value is meaningful if the supplied newGarbageCollectionLevel is the currentGarbageCollectionLevel

Specified by:
ensureGarbageCollectionLevel in interface ObjectContainer
Overrides:
ensureGarbageCollectionLevel in class WizardObjectContainer
Returns:
<=0 if this object still has to be processed. This is the case if it belongs to the surelyReachable set but not to the processedReachable set > otherwise <0 if this object has been updated =0 if this object has not been updated, it is surelyReachable >0 if this object has not been updated, it is processedReachable

getGarbageCollectionLevel

public int getGarbageCollectionLevel()
Returns the garbageCollectionLevel this ObjectContainer has reached due to (not) calling ensureGarbageCollectionLevel(int).

Specified by:
getGarbageCollectionLevel in interface ObjectContainer
Overrides:
getGarbageCollectionLevel in class WizardObjectContainer

hasSameClusterAs

public boolean hasSameClusterAs(MagicObjectContainer container)

toString

public java.lang.String toString()
Overrides:
toString in class WizardObjectContainer

isPinned

public boolean isPinned()
Description copied from class: WizardObjectContainer
Returns wether this ObjectContainer is pinned.

Specified by:
isPinned in interface ObjectContainer
Overrides:
isPinned in class WizardObjectContainer

pin

public void pin()
Description copied from class: WizardObjectContainer
Pins this ObjectContainer. Every caller of this method must pair this call with a call to WizardObjectContainer.unpin(). An ObjectContainer remains in main memory at least as long as it is pinned.

Specified by:
pin in interface ObjectContainer
Overrides:
pin in class WizardObjectContainer

unpin

public void unpin()
Description copied from class: WizardObjectContainer
Unpins this ObjectContainer. This method must be called exactly once for every call to WizardObjectContainer.pin().

Specified by:
unpin in interface ObjectContainer
Overrides:
unpin in class WizardObjectContainer

ozone core API

Copyright (C) The Ozone Database Project - www.ozone-db.org. All rights reserved.