com.sun.sgs.impl.service.data.store
Class DbUtilities

java.lang.Object
  extended by com.sun.sgs.impl.service.data.store.DbUtilities

public final class DbUtilities
extends Object

Utility methods for database operations needed to implement a DataStore using the com.sun.sgs.service.store.db package. This class should not be instantiated.


Nested Class Summary
static class DbUtilities.Databases
          Stores information about the databases that constitute the data store.
 
Method Summary
static int getClassId(DbEnvironment env, DbDatabase classesDb, byte[] classInfo, long timeout)
          Returns the class ID to represent classes with the specified class information.
static byte[] getClassInfo(DbEnvironment env, DbDatabase classesDb, int classId, long timeout)
          Returns the class information associated with the specified class ID.
static DbUtilities.Databases getDatabases(DbEnvironment env, DbTransaction dbTxn, LoggerWrapper logger)
          Opens or creates the Berkeley DB databases for a data store.
static long getNextNodeId(DbDatabase infoDb, DbTransaction dbTxn, int blockSize)
          Returns the next available node ID and increments the stored value by the specified amount.
static long getNextObjectId(DbDatabase infoDb, DbTransaction dbTxn, int blockSize)
          Returns the next available object ID and increments the stored value by the specified amount.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDatabases

public static DbUtilities.Databases getDatabases(DbEnvironment env,
                                                 DbTransaction dbTxn,
                                                 LoggerWrapper logger)
Opens or creates the Berkeley DB databases for a data store.

Parameters:
env - the database environment
dbTxn - the database transaction
logger - the logger for logging messages
Returns:
the databases

getNextObjectId

public static long getNextObjectId(DbDatabase infoDb,
                                   DbTransaction dbTxn,
                                   int blockSize)
Returns the next available object ID and increments the stored value by the specified amount.

Parameters:
infoDb - the info database
dbTxn - the transaction
blockSize - the number of items to allocate
Returns:
the next object ID

getNextNodeId

public static long getNextNodeId(DbDatabase infoDb,
                                 DbTransaction dbTxn,
                                 int blockSize)
Returns the next available node ID and increments the stored value by the specified amount.

Parameters:
infoDb - the info database
dbTxn - the transaction
blockSize - the number of node IDs to allocate
Returns:
the next node ID

getClassId

public static int getClassId(DbEnvironment env,
                             DbDatabase classesDb,
                             byte[] classInfo,
                             long timeout)
Returns the class ID to represent classes with the specified class information. Obtains an existing ID for the class information if present; otherwise, stores the information and returns the new ID associated with it. Class IDs are always greater than 0. The class information is the serialized form of the ObjectStreamClass instance that serialization uses to represent the class.

Parameters:
env - the database environment
classesDb - the classes database
classInfo - the class information
timeout - the timeout to use when creating a transaction
Returns:
the associated class ID

getClassInfo

public static byte[] getClassInfo(DbEnvironment env,
                                  DbDatabase classesDb,
                                  int classId,
                                  long timeout)
Returns the class information associated with the specified class ID. The class information is the serialized form of the ObjectStreamClass instance that serialization uses to represent the class.

Parameters:
env - the database environment
classesDb - the classes database
classId - the class ID
timeout - the transaction timeout for creating a transaction
Returns:
the associated class information or null if the ID is not found
Throws:
IllegalArgumentException - if classId is not greater than 0

RedDwarf, Version 0.10.1
2010-03-14 10:56:12

Copyright © 2010 The RedDwarf Authors. All rights reserved
Copyright © 2007-2010 Sun Microsystems, Inc. All rights reserved