|
Objectivity for Java Reference | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.objy.db.app.ooAbstractObj | +--com.objy.db.app.ooFDObj
Represents an Objectivity/DB federated database.
API Summary |
A federated database is the top level in the Objectivity/DB storage hierarchy. It may contain a default database and one or more application-specific databases.
The federated database is physically maintained in a system database file, which stores a catalog of all the application-specific databases and the schema for the federated database. Each federated database has a system name, which is the name of its associated boot file. The boot file contains federated database configuration information, such as its lock-server hostname and integer-valued identifier. Both files are created with the oonewfd administration tool.
To obtain an instance of this class you must perform the following steps:
Connection.open
.
For ODMG compliance, you can create an ODMG transaction object instead of creating a session directly. When you create a transaction object, the transaction's session and that session's federated-database object are created automatically.
Note: A federated-database object belongs to the session that created it; Objectivity for Java does not allow it to interact with objects that belong to different sessions; see Object Isolation.
Once you have a federated database you can:
The session that owns the federated-database object must be in a transaction when you call methods defined in this class.
For additional information about using federated databases, see Federated Databases.
Constructor Summary | |
ooFDObj(PooFDObj persistor)
Reserved for internal use; to obtain a federated-database object, call the getFD method of a session. |
Method Summary | |
void |
addIndex(String name,
String className,
String fieldList)
Adds an index to this federated database. |
void |
addUniqueIndex(String name,
String className,
String fieldList)
Adds a unique index to this federated database. |
void |
bind(Object object,
String name)
Names the specified object with the specified root name in this federated database. |
Iterator |
containedAPs()
(FTO/DRO) Initializes an iterator to find the set of autonomous partitions contained by this federated database. |
Iterator |
containedDBs()
Initializes an iterator to find the databases contained by this federated database. |
void |
convertObjects()
Converts all basic objects in this federated database to be consistent with their current Java class definitions. |
void |
deleteReference(Object object)
Deletes the specified internal persistent object from this federated database. |
void |
dropIndex(String name)
Drops the specified index from this federated database. |
void |
dumpCatalog()
Prints federated database catalog information to the standard output device. |
void |
flush()
Transfers the data of all modified objects to this federated database. |
ooAPObj |
getBootAP()
(FTO) Gets the autonomous partition whose boot file is used by an application or tool to open this federated database. |
ooDBObj |
getDefaultDB()
Gets the default database for this federated database. |
String |
getLockServerName()
Gets the name of the host running the lock-server process for this federated database. |
String |
getName()
Gets the system name of this federated database. |
long |
getNumber()
Gets the identifier of this federated database. |
long |
getPageSize()
Gets the page size of this federated database. |
Session |
getSession()
Gets the session that created this federated-database object. |
boolean |
hasAP(String name)
(FTO/DRO) Tests whether an autonomous partition with the specified system name exists in this federated database. |
boolean |
hasDB(String name)
Tests whether the database with the specified system name exists in this federated database. |
boolean |
hasIndex(String name)
Tests whether this federated database has an index with the specified name. |
void |
lock(int mode)
Locks this federated database and everything contained in it with the specified lock mode. |
Object |
lookup(String name)
Retrieves the object with the specified root name in this federated database. |
ooAPObj |
lookupAP(String name)
(FTO/DRO) Retrieves the autonomous partition with the specified system name in this federated database. |
ooDBObj |
lookupDB(String name)
Retrieves the database with the specified system name in this federated database. |
Object |
lookupObj(String scopeName)
Retrieves the object with the specified scope name in the scope defined by this federated database. |
Object |
lookupObj(String scopeName,
int lockMode)
Retrieves the object with the specified scope name in the scope defined by this federated database, locking the retrieved object as specified. |
String |
lookupObjName(Object object)
Looks up the name of the specified object in the scope defined by this federated database. |
void |
moveReference(Object object,
Object nearObj)
Moves the specified internal persistent object from its current location and clusters it with the specified object. |
void |
nameObj(Object object,
String scopeName)
Names the specified object in the scope of this federated database. |
ooAPObj |
newAP(String name,
String lockServerHost,
String systemDBFileHost,
String systemDBFilePath)
(FTO/DRO) Creates an autonomous partition in this federated database with the specified system name, lock-server host, and location for its system database file. |
ooAPObj |
newAP(String name,
String lockServerHost,
String systemDBFileHost,
String systemDBFilePath,
String bootFileHost,
String bootFilePath,
String journalDirHost,
String journalDirPath)
(FTO/DRO) Creates an autonomous partition in this federated database with the specified system name, lock-server host, and file locations. |
ooDBObj |
newDB(String name)
Creates a database in this federated database with the specified system name. |
ooDBObj |
newDB(String name,
long defaultContainerInitialPages,
long defaultContainerGrowth,
String hostName,
String pathName,
long weight)
Creates a database in this federated database with the specified system name, properties for its default container, host and pathname for its database file, and image weight. |
ooDBObj |
newDB(String name,
long defaultContainerInitialPages,
long defaultContainerGrowth,
String hostName,
String pathName,
long weight,
long userDBID)
Creates a database in this federated database with the specified system name, properties for its default container, host and pathname for its database file, image weight, and database identifier. |
Object |
objectFrom(ooId oid)
Retrieves the object with the specified OID from this federated database. |
Object |
objectFrom(ooId oid,
int lockMode)
Retrieves the object with the specified OID from this federated database, locking the retrieved object as specified. |
Object |
objectFrom(String oidString)
Retrieves the object whose identifier has the specified string representation from this federated database. |
Object |
objectFrom(String oidString,
int lockMode)
Retrieves the object whose identifier has the specified string representation from this federated database, locking the retrieved object as specified. |
Iterator |
rootNames()
Initializes an iterator to find the root names maintained by this federated database. |
Iterator |
scan(String className)
Initializes an iterator to scan this federated database for objects of the specified class. |
Iterator |
scan(String className,
String predicate)
Initializes an iterator to scan this federated database for objects of the specified class that satisfy the specified predicate. |
Iterator |
scan(String className,
String predicate,
int access)
Deprecated. Use scan(String, String). |
void |
setPersistor(PooFDObj persistor)
Reserved for internal use; you should not call this method. |
void |
unbind(String name)
Removes a root name from this federated database. |
void |
unnameObj(Object object)
Removes the specified object's name from the name scope of this federated database. |
void |
upgradeObjects()
Performs object conversion on this federated database; used only in a special-purpose upgrade application. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ooFDObj(PooFDObj persistor)
You should not use this constructor directly.
Method Detail |
public Session getSession()
public long getNumber()
public String getLockServerName()
public String getName()
public long getPageSize()
public void lock(int mode)
The lock mode is limited by the open mode of the session.
If this federated database is already locked, you can call this method to upgrade a read lock to a write lock, but not to downgrade a write lock to a read lock.
mode
- The mode in which to lock this federated
database; one of the following constants defined in the oo interface:
ObjyRuntimeException
- If you try to set the lock mode to WRITE
when the session's open mode is openReadOnly.public void bind(Object object, String name) throws ObjectNameNotUniqueException
Giving an object a root name makes the object persistent. The named object is made persistent immediately; all transient objects reachable from the named object are made persistent on transaction commit.
object
- The object being named.name
- The root name for the object.
This name can be any valid Java string and must be unique
within the root dictionary of this federated database.ObjectNameNotUniqueException
- If the name already exists in the root
dictionary.unbind(java.lang.String)
public void unbind(String name) throws ObjectNameNotFoundException
name
- The root name to be removed.ObjectNameNotFoundException
- If the name doesn't exist in the root
dictionary.bind(java.lang.Object, java.lang.String)
public Object lookup(String name) throws ObjectNameNotFoundException
name
- The root name of the object.ObjectNameNotFoundException
- If the name doesn't exist in the root
dictionary.public Iterator rootNames()
public ooDBObj lookupDB(String name)
name
- The system name of the
database.ObjyRuntimeException
- If this federated database
does not have a database with the specified system name.bind(java.lang.Object, java.lang.String)
public ooDBObj newDB(String name)
This method creates a new database file in the same directory as the system database file for this federated database. The default container will initially have 4 pages and will grow by 10% when required. If Objectivity/DB Data Replication Option (DRO) is being used, the weight of the first database image will be 1. Objectivity/DB assigns a unique database identifier to new database.
The new database is locked in write mode.
name
- The system name of the database.
A valid system name follows the same rules as for naming files within
the operating system.ObjyRuntimeException
- If this federated
database already has a database named name. You can call
hasDB to test whether the specified
database exists.public ooDBObj newDB(String name, long defaultContainerInitialPages, long defaultContainerGrowth, String hostName, String pathName, long weight)
Objectivity/DB assigns a unique database identifier to new database. The new database is locked in write mode.
name
- The system name of the database.
A valid system name follows the same rules as for naming files within
the operating system.defaultContainerInitialPages
- The initial number of pages
to allocate for the default container. The value of this argument is limited to
a maximum of 65535. If equal to 0, a default value of 4 is used.defaultContainerGrowth
- The percentage by which the
default container
should grow when needed to accommodate more basic objects.
If equal to 0, a default value of 10% is used.hostName
- The name of the host where the database is
to be located. If you specify a hostname, you must also specify a
pathname. If hostName is an empty string or null, then the host is set to
the local host.pathName
- Path of the directory on host hostName
where the database file is to be located. If you specify a pathname,
you must also specify a hostname in hostName.
If pathName is an empty string or null, then the database file is created
in the same directory as the system database file for this
federated database.weight
- The weight of the first database image
if Objectivity/DB Data Replication Option is being used. If DRO is not
being used, you must specify 1.ObjyRuntimeException
- If this federated
database already has a database
named name. You can call hasAP
to test whether the specified
database exists.public ooDBObj newDB(String name, long defaultContainerInitialPages, long defaultContainerGrowth, String hostName, String pathName, long weight, long userDBID)
The new database is locked in write mode.
name
- The system name of the database.
A valid system name follows the same rules as for naming files within
the operating system.defaultContainerInitialPages
- The initial number of pages
to allocate for the default container. The value of this argument is limited to
a maximum of 65535. If equal to 0, a default value of 4 is used.defaultContainerGrowth
- The percentage by which the
default container
should grow when needed to accommodate more basic objects.
If equal to 0, a default value of 10% is used.hostName
- The name of the host where the database is
to be located. If you specify a hostname, you must also specify a
pathname. If hostName is an empty string or null, then the host is set to
the local host.pathName
- Path of the directory on host hostName
where the database file is to be located. If you specify a pathname,
you must also specify a hostname in hostName.
If pathName is an empty string or null, then the database file is created
in the same directory as the system database file for this
federated database.weight
- The weight of the first database image
if Objectivity/DB Data Replication Option is being used. If DRO is not
being used, you must specify 1.userDBID
- The application-assigned database
identifier, expressed as a single integer.ObjyRuntimeException
- If this federated
database already has a database
named name. You can call hasAP
to test whether the specified
database exists.public Iterator containedDBs()
public boolean hasDB(String name)
name
- The system name of the database.public ooDBObj getDefaultDB()
public Iterator scan(String className)
className
- The package-qualified name
of the class of the desired objects.public Iterator scan(String className, String predicate)
If predicate-scan autoflush is enabled for the connection object, this method will flush any modified objects to the federated database before performing the scan. Otherwise, the result of the scan may contain out-of-date information.
className
- The package-qualified name
of the class of the desired objects.predicate
- The condition that each retrieved object must
satisfy, expressed in the Objectivity/DB
predicate query language.Connection.setPredicateScanAutoFlush(boolean)
,
Connection.isPredicateScanAutoFlush()
public Iterator scan(String className, String predicate, int access)
public void addIndex(String name, String className, String fieldList)
name
- The name of the index to be added; must be different from
the names of existing indexes in this federated database. You can call
hasIndex to test whether an index with the
specified name exists.className
- The package-qualified name of
the class whose instances are to be indexed.fieldList
- The key fields for the index, separated by commas.
Each key field must be the name of a valid persistent field
of className whose type is one of the Java types
supported by indexes.ObjyRuntimeException
- If Objectivity/DB is unable to
create the index.addUniqueIndex(java.lang.String, java.lang.String, java.lang.String)
,
dropIndex(java.lang.String)
public void addUniqueIndex(String name, String className, String fieldList)
The application is responsible for ensuring that every object indexed by a unique index has a unique combination of values in its key fields. If two or more objects have a given combination of key values, the index will contain only the first such object that is encountered when the index is created or updated.
name
- The name of the index to be added; must be different from
the names of existing indexes in this federated database. You can call
hasIndex to test whether an index with the
specified name exists.className
- The package-qualified name of
the class whose instances are to be indexed.fieldList
- The key fields for the index, separated by commas.
Each key field must be the name of a valid persistent field
of className whose type is one of the Java types
supported by indexes.ObjyRuntimeException
- If Objectivity/DB is unable to
create the index.addIndex(java.lang.String, java.lang.String, java.lang.String)
,
dropIndex(java.lang.String)
public void dropIndex(String name)
name
- The name of the index to be
dropped.ObjyRuntimeException
- If this federated database does not have an index named
name. You can call
hasIndex to test whether an index with the
specified name exists.addIndex(java.lang.String, java.lang.String, java.lang.String)
,
addUniqueIndex(java.lang.String, java.lang.String, java.lang.String)
public boolean hasIndex(String name)
name
- The name of the index.public void nameObj(Object object, String scopeName)
If the specified object is transient, this method makes it persistent. If the specified object is already persistent, this method locks it for write.
This method locks this federated database for write.
object
- The object to be named.scopeName
- The name for the specified
object in the scope of this federated database.
This name can be any valid Java string and must be unique
within the name scope of this federated database.lookupObj(java.lang.String)
,
unnameObj(java.lang.Object)
public void unnameObj(Object object)
This method locks both this federated database and object for write.
object
- The object whose name is to be
removed.ObjyRuntimeException
- If object has no name
in the scope of this federated database.lookupObj(java.lang.String)
,
nameObj(java.lang.Object, java.lang.String)
public Object lookupObj(String scopeName)
scopeName
- The scope name to look
up.ObjyRuntimeException
- If there is no
object named scopeName in the scope of this federated
database.lookupObjName(java.lang.Object)
public Object lookupObj(String scopeName, int lockMode)
scopeName
- The scope name to look
up.lockMode
- The type of lock to obtain for the object;
one of the following constants defined in the oo interface:
ObjyRuntimeException
- If there is no
object named scopeName in the scope of this federated
database.lookupObjName(java.lang.Object)
public String lookupObjName(Object object)
object
- The object whose name is to be
looked up.ObjyRuntimeException
- If object has
no name in the scope of this federated database.lookupObj(java.lang.String)
public void dumpCatalog()
Performs the same function as the tool oodumpcatalog.
public void flush()
After the successful execution of this method, the objects are no longer marked as modified.
This method makes the data of modified objects available to the process that calls the method, but does not make the changes permanent and available to other processes. When you commit or checkpoint the transaction, the changes become permanent.
public void convertObjects()
You can call this method if the definitions of some Java classes are not consistent with the corresponding descriptions in the schema. This method updates all affected objects in this federated database. If any of the converted objects are indexed, the affected indexes will be updated.
Calling this method more than once has no effect; the objects are converted by the first call and are not changed by subsequent calls.
public void upgradeObjects()
This method is included for interoperability. Changes to Java class definitions never leave the federated database schema in a state that requires an upgrade application. However, changes to the schema made by the Objectivity/C++ DDL processor can require an upgrade application to convert objects of the modified class before any of those objects can be accessed. Typically, a C++ developer who makes such modifications to the schema also runs an Objectivity/C++ upgrade application. This method makes it possible to run an Objectivity for Java upgrade application instead.
To run an upgrade application, you open a read-write connection
to the federated database. You create a session and call its
upgrade
method before
beginning the first and only
transaction. That transaction must consist of a call to this method,
which initiates the upgrade process. Objectivity/DB
will issue an error if the federated database schema does not
include any pending changes that require an upgrade
application.
For additional information about upgrade applications, refer to the Objectivity/C++ product documentation.
public Object objectFrom(ooId oid)
oid
- The OID of the object to be retrieved.public Object objectFrom(ooId oid, int lockMode)
oid
- The OID of the object to be retrieved.lockMode
- The type of lock to obtain for the object;
one of the following constants defined in the oo interface:
public Object objectFrom(String oidString)
This method translates the string representation of the OID to an
object of class ooId
before looking up the
object.
oidString
- The string representation of the
object's OID. The string must be of the form returned by the
getStoreString
method of an OID.
If you obtain an OID string from getStoreString, you must not modify it before passing it as a parameter to this method. If you do modify the string, this method may not find the correct object.
public Object objectFrom(String oidString, int lockMode)
This method translates the string representation of the OID to an
object of class ooId
before looking up the
object.
oidString
- The string representation of the
object's OID. The string must be of the form returned by the
getStoreString
method of an OID.
If you obtain an OID string from getStoreString, you must not modify it before passing it as a parameter to this method. If you do modify the string, this method may not find the correct object.
lockMode
- The type of lock to obtain for the object;
one of the following constants defined in the oo interface:
public void deleteReference(Object object)
Note: It is better to call the
deleteReference
method
on the persistent object that references the internal
persistent object than to call this method on a federated database
object. Deadlocks can occur when you call this method in a
multithreaded application.
object
- The
internal persistent object to be deleted.ObjyRuntimeException
- If
object is not an array, a string element of an
array, or a scalar type that is stored in the
federated database as an internal persistent object
(java.util.Date, java.sql.Date, java.sql.Time,
java.sql.Timestamp).public void moveReference(Object object, Object nearObj)
object
- The
internal persistent object to be moved.nearObj
- The object with which to
cluster object; must be a database, a
persistent container, or a persistent basic object.
ObjyRuntimeException
- If
object is not an array, a string element of an
array, or a scalar type that is stored in the
federated database as an internal persistent object (
java.util.Date, java.sql.Date, java.sql.Time,
java.sql.Timestamp).public boolean hasAP(String name)
name
- The system name of the autonomous
partition.public ooAPObj lookupAP(String name)
name
- The system name of the
autonomous partition.ObjyRuntimeException
- If this federated database
does not have an autonomous partition with the specified system name.public ooAPObj newAP(String name, String lockServerHost, String systemDBFileHost, String systemDBFilePath)
The boot file (named name.boot) and journal file are created in the same directory as the system database file and on the host systemDBFileHost.
When you create a partition, Objectivity/DB needs access to all of the partitions in the federated database so that it can update the global catalog data.
The new autonomous partition is locked in write mode.
name
- The system name of the autonomous partition.
A valid system name follows the same rules as for naming files within
the operating system.lockServerHost
- The name of the host
where the lock-server process is located.systemDBFileHost
- The name of the host where the system database
is located. If systemDBFileHost is an
empty string or null, then the host is set to the local host.systemDBFilePath
- Path of the system database file on host
systemDBFileHost.ObjyRuntimeException
- If this federated database already has an
autonomous partition named name. You can call
hasAP to test whether the specified
partition exists.public ooAPObj newAP(String name, String lockServerHost, String systemDBFileHost, String systemDBFilePath, String bootFileHost, String bootFilePath, String journalDirHost, String journalDirPath)
The new autonomous partition is locked in write mode.
When you create a partition, Objectivity/DB needs access to all of the partitions in the federated database so that it can update the global catalog data.
name
- The system name of the autonomous partition.
A valid system name follows the same rules as for naming files within
the operating system.lockServerHost
- The name of the host
where the lock-server process is located.systemDBFileHost
- The name of the host where the system
database is located. If systemDBFileHost is an
empty string or null, then the host is set to the local host.systemDBFilePath
- Path of the system database file on host
systemDBFileHost.bootFileHost
- The name of the host
where the boot file is located.
If bootFileHost is an empty string or null, then the host is set
to the local host.
If the boot-file host and path both are empty strings or null, the
autonomous partition boot-file
name is of the form name.boot and is located in the same directory
as the autonomous partition system database file.bootFilePath
- Path of the boot file on host
bootFileHost, or null.journalDirHost
- The name of the host where the journal
directory is located. If journalDirHost is an
empty string or null, then the host is set to the local host.
If the journal-directory host and path both are empty strings or
null, the autonomous partition journal
directory is set to the directory of the autonomous partition system
database file.journalDirPath
- Path of the journal directory on host
journalDirHost, or null.ObjyRuntimeException
- If this federated database already has an
autonomous partition named name. You can call
hasAP to test whether the specified
partition exists.public Iterator containedAPs()
public ooAPObj getBootAP()
No single autonomous partition is statically defined as a boot autonomous partition. Instead, each process determines its boot autonomous partition based on the boot file it uses. If a process requests an object that is outside the control of its boot autonomous partition, the partition transparently locates the object through its global information file and accesses the object through the controlling autonomous partition.
public void setPersistor(PooFDObj persistor)
|
Objectivity for Java Reference | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2000 Objectivity, Inc. All rights reserved.