ozone core API

org.ozoneDB.core.storage.wizardStore
Class WizardCluster

java.lang.Object
  extended byorg.ozoneDB.core.storage.AbstractCluster
      extended byorg.ozoneDB.core.storage.wizardStore.WizardCluster
All Implemented Interfaces:
Cluster, java.io.Externalizable, java.io.Serializable
Direct Known Subclasses:
Cluster, Cluster

public class WizardCluster
extends AbstractCluster
implements java.io.Externalizable

Version:
$Revision$Date$ TODO: add final modifier when backward compatibility for 1.1 does not have to be maintained
Author:
SMB, Medium.net
See Also:
Serialized Form

Field Summary
protected  int bytesPerContainer
           
protected  long lastTouched
           
protected  Lock lock
           
protected  long modTime
           
protected  int pinCount
          The count of users of this cluster which requested it to be pinned.
protected static long serialVersionUID
           
protected static byte subSerialVersionUID
           
 
Fields inherited from class org.ozoneDB.core.storage.AbstractCluster
clusterID, clusterStore, containers, env, permissions
 
Constructor Summary
WizardCluster()
          Constructor to be used for Externalizable object serialisation.
WizardCluster(ClusterID _clusterID, Permissions _permissions, Lock _lock, int _bpc)
           
 
Method Summary
 void abort(Transaction ta)
           
 void addPinCount(int what)
          Adds an amount to the pin count
 DxCollection allLockers()
           
 DxLong cachePriority()
          Priority of this cluster to stay in the cluster cache.
 int clearPinCount()
          Sets the pin count to zero and returns the former pin count.
 void commit(Transaction ta)
           
 void delete()
          Delete this cluster from the disk.
protected  void deleteShadow()
           
 boolean isInvoked()
           
 boolean isPinned()
          Returns wether this cluster is pinned.
 Lock lock()
           
 long modTime()
           
 void pin()
          Pins this WizardCluster.
 void prepareCommit(Transaction ta)
           
 void readExternal(java.io.ObjectInput in)
           
 void registerContainer(StorageObjectContainer container)
           
 void removeContainer(StorageObjectContainer container)
           
protected  void restoreShadow()
          Restore the saved shadow on disk.
protected  void saveShadow()
          Shadow files are contain the data of original cluster files.
 void setCurrentSize(int byteSize)
           
 void setLock(Lock to)
           
 int size()
           
 java.lang.String toString()
           
 void touch()
           
 void unpin()
          Unpins this WizardCluster.
 void updateLockLevel(Transaction ta)
          Note: This method must not be synchronized.
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class org.ozoneDB.core.storage.AbstractCluster
clusterID, containerForID, containers, env, permissions, setClusterStore, setEnv
 
Methods inherited from class java.lang.Object
clone, equals, 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

lock

protected transient Lock lock

lastTouched

protected transient long lastTouched

bytesPerContainer

protected transient int bytesPerContainer

modTime

protected long modTime

pinCount

protected transient int pinCount
The count of users of this cluster which requested it to be pinned. If a cluster is pinned, it may not be "passivated" (i.e. written to disk and forgotten), it has to stay in memory. This cluster is said to be pinned iff pinCount!=0. Access to this count is only allowed during synchronization on this WizardCluster.

Constructor Detail

WizardCluster

public WizardCluster()
Constructor to be used for Externalizable object serialisation.


WizardCluster

public WizardCluster(ClusterID _clusterID,
                     Permissions _permissions,
                     Lock _lock,
                     int _bpc)
Method Detail

modTime

public long modTime()
Specified by:
modTime in interface Cluster

cachePriority

public DxLong cachePriority()
Priority of this cluster to stay in the cluster cache. Low return value means low priority.

Specified by:
cachePriority in interface Cluster
Returns:
Cache priority of the cluster.

setCurrentSize

public void setCurrentSize(int byteSize)
Specified by:
setCurrentSize in interface Cluster

size

public int size()
Specified by:
size in interface Cluster

isInvoked

public boolean isInvoked()
Returns:
True if at least one container is currently invoked.

touch

public void touch()
Specified by:
touch in interface Cluster

registerContainer

public void registerContainer(StorageObjectContainer container)
Specified by:
registerContainer in interface Cluster
Overrides:
registerContainer in class AbstractCluster

removeContainer

public void removeContainer(StorageObjectContainer container)
Specified by:
removeContainer in interface Cluster
Overrides:
removeContainer in class AbstractCluster

updateLockLevel

public void updateLockLevel(Transaction ta)
                     throws java.io.IOException
Note: This method must not be synchronized.

Specified by:
updateLockLevel in interface Cluster
Parameters:
ta -
Throws:
java.io.IOException

prepareCommit

public void prepareCommit(Transaction ta)
Specified by:
prepareCommit in interface Cluster

commit

public void commit(Transaction ta)
            throws java.io.IOException
Specified by:
commit in interface Cluster
Throws:
java.io.IOException

abort

public void abort(Transaction ta)
           throws java.io.IOException
Specified by:
abort in interface Cluster
Throws:
java.io.IOException

allLockers

public DxCollection allLockers()
Specified by:
allLockers in interface Cluster

saveShadow

protected void saveShadow()
                   throws java.io.IOException
Shadow files are contain the data of original cluster files. If the transaction involving the cluster fails, the cluster file data can be restored because it resides in the shadow file.

Throws:
java.io.IOException

restoreShadow

protected void restoreShadow()
                      throws java.io.IOException
Restore the saved shadow on disk. The content of the receiver stays the same. The cluster needs to be re-loaded to reflect the changes.

Throws:
java.io.IOException

deleteShadow

protected void deleteShadow()
                     throws java.io.IOException
Throws:
java.io.IOException

delete

public void delete()
            throws java.lang.Exception
Delete this cluster from the disk.

Specified by:
delete in interface Cluster
Throws:
java.lang.Exception

toString

public java.lang.String toString()

lock

public Lock lock()
Specified by:
lock in interface Cluster

setLock

public void setLock(Lock to)
Specified by:
setLock in interface Cluster

writeExternal

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

readExternal

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

pin

public void pin()
Pins this WizardCluster. Every caller of this method must pair this call with a call to unpin(). A WizardCluster remains in main memory at least as long as it is pinned.


unpin

public void unpin()
Unpins this WizardCluster. This method must be called exactly once for every call to pin().


isPinned

public boolean isPinned()
Returns wether this cluster is pinned.


clearPinCount

public int clearPinCount()
Sets the pin count to zero and returns the former pin count.


addPinCount

public void addPinCount(int what)
Adds an amount to the pin count


ozone core API

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