com.odi
Class Cluster

java.lang.Object
  extended bycom.odi.Placement
      extended bycom.odi.Cluster
All Implemented Interfaces:
ObjectStoreConstants

public abstract class Cluster
extends Placement
implements ObjectStoreConstants

PSE/PSE Pro uses the Cluster class to represent a cluster in a segment. Every cluster has a number that is unique in the segment. PSE/PSE Pro assigns this number and uses it as a Cluster ID, which identifies the cluster.

When you are using PSE or PSE Pro, a segment can have only one cluster.


Field Summary
 
Fields inherited from interface com.odi.ObjectStoreConstants
ALL_EXECUTE, ALL_READ, ALL_WRITE, DEFAULT, DISABLE_AUTO_OPEN, GROUP_EXECUTE, GROUP_READ, GROUP_WRITE, INSTALL_SCHEMA_BATCH, INSTALL_SCHEMA_INCREMENTAL, MULTI_DB_MVCC, MVCC, OBJECTSTORE, OTHER_EXECUTE, OTHER_READ, OTHER_WRITE, OWNER_EXECUTE, OWNER_READ, OWNER_WRITE, PSE, PSE_PRO, READONLY, READONLY_NON_BLOCKING, RETAIN_HOLLOW, RETAIN_READONLY, RETAIN_STALE, RETAIN_TRANSIENT, RETAIN_UPDATE, UPDATE, UPDATE_NON_BLOCKING, WAIT_FOREVER, XA_TRANSACTION
 
Method Summary
abstract  void acquireLock(int lockType, int timeoutMillis)
          Attempts to acquire a lock on a cluster
abstract  void destroy()
          Destroys a cluster (not available in PSE or PSE Pro)
abstract  int getClusterId()
          Obtains the Cluster ID of a cluster.
abstract  Iterator getObjects()
          Returns an iterator over the objects in the cluster.
abstract  Iterator getObjects(Class ofType)
          Returns an iterator over the objects that can be converted to the specified type in the cluster.
abstract  Segment getSegment()
          Obtains the Segment object associated with the segment that contains the cluster.
abstract  long getSizeInBytes()
          Obtains the number of bytes of storage occupied by the cluster.
abstract  boolean isDestroyed()
          Determines whether or not the cluster has been destroyed.
static Cluster of(Object object)
          Obtains the cluster that contains the object.
 
Methods inherited from class com.odi.Placement
getCluster, getDatabase, getSession
 

Method Detail

destroy

public abstract void destroy()
Destroys a cluster (not available in PSE or PSE Pro). This API is useful when you are using the Java interface to ObjectStore. When you are using PSE or PSE Pro there is never more than one cluster in a segment and you cannot destroy it.

Throws:
ClusterException - If the application is using PSE or PSE Pro.

isDestroyed

public abstract boolean isDestroyed()
Determines whether or not the cluster has been destroyed.

Returns:
The true constant if the cluster has been destroyed. The false constant if it has not been destroyed.

Throws:
DatabaseNotOpenException - If the database is not open.
NoTransactionInProgressException - If there is no transaction in progress.
ObjectStoreException - If the session implied by the cluster has been terminated or if the current thread is associated with a session other than the session implied by the cluster.

getClusterId

public abstract int getClusterId()
Obtains the Cluster ID of a cluster.

Returns:
The Cluster ID.

getSegment

public abstract Segment getSegment()
Obtains the Segment object associated with the segment that contains the cluster.

Specified by:
getSegment in class Placement
Returns:
The instance of Segment associated with the cluster.

Throws:
DatabaseNotOpenException - If the database is not open.
ObjectStoreException - If the session implied by the cluster has been terminated or if the current thread is associated with a session other than the session implied by the cluster.

getSizeInBytes

public abstract long getSizeInBytes()
Obtains the number of bytes of storage occupied by the cluster.

Returns:
The number of bytes of storage.

Throws:
DatabaseNotOpenException - If the database is not open.
NoTransactionInProgressException - If there is no transaction in progress.
ObjectStoreException - If the session implied by the cluster has been terminated or if the current thread is associated with a session other than the session implied by the cluster.
ClusterNotFoundException - If the cluster is not found.

of

public static Cluster of(Object object)
Obtains the cluster that contains the object.

Parameters:
object - A persistent object in the cluster you want to obtain.

Returns:
The instance of Cluster that represents the cluster that contains the specified object.

Throws:
IllegalArgumentException - If the object argument is null.
NoTransactionInProgressException - If there is no transaction in progress.
ObjectException - If the object is stale.
ObjectNotPersistentException - If the object is not persistent.
ObjectStoreException - If the session implied by the cluster has been terminated or if the current thread is associated with a session other than the session implied by the cluster.
ClusterNotFoundException - If the cluster is not found.

getObjects

public abstract Iterator getObjects()
Returns an iterator over the objects in the cluster. Use the Iterator methods to access each of the objects. If you add an object to the cluster after the call to getObjects(), the new object might or might not be in the iteration.

Returns:
The iterator over the objects in the Cluster. This iterator must be used within transactions. The iterator throw news StaleIteratorException if it is used after being used in a transaction that is aborted.
Throws:
DatabaseNotOpenException - If the database is not open.
NoTransactionInProgressException - If a transaction is not in progress.
ObjectStoreException - If the session implied by the cluster has been terminated or if the current thread is associated with a session other than the session implied by the cluster.
ClusterNotFoundException - If the cluster is not found.

getObjects

public abstract Iterator getObjects(Class ofType)
Returns an iterator over the objects that can be converted to the specified type in the cluster. Use the Iterator methods to access each of the objects. If you add an object to the cluster after the call to getObjects(), the new object might or might not be in the iteration.

The class type argument can be any class type, interface type, or array type. Because primitive types are stored using wrapper types, the type argument should not be a primitive type. For array types, the objects in the iteration are all arrays of the element type (or types that can be converted to this type) regardless of the dimension of the array.

Returns:
The iterator over the objects in the cluster. This iterator must be used within transactions. The iterator throws StaleIteratorException if it is used after being used in a transaction that is aborted.
Throws:
DatabaseNotOpenException - If the database is not open.
NoTransactionInProgressException - If a transaction is not in progress.
ObjectStoreException - If the session implied by the cluster has been terminated or if the current thread is associated with a session other than the session implied by the cluster.
ClusterNotFoundException - If the cluster is not found.
IllegalArgumentException - If ofType is null.

acquireLock

public abstract void acquireLock(int lockType,
                                 int timeoutMillis)
Attempts to acquire a lock on a cluster. This method does nothing in PSE and PSE Pro.



Copyright 2005 Progress Software Corporation. All rights reserved.