Most applications make use of the NameValueObjectArchive class. This class ensures that a default metadata entry is created for every data object stored, even if no metadata is explicitly provided at store time.
The NameValueObjectArchive object functions as a proxy for the 5800 system server. All access is enabled by invoking methods on this object.
The following key methods and classes are used with the NameValueObjectArchive class:
Initializes a new NameValueObjectArchive with the address or host name of a 5800 system server, using the provided port.
public NameValueObjectArchive(java.lang.String address) throws ArchiveException, java.io.IOException public NameValueObjectArchive(String address, int port) throws ArchiveException, IOException
The NameValueObjectArchive is instantiated by supplying the address of the 5800 system cluster in the constructor. The resulting data object can then be used to interact with that cluster.
Deletes the metadata record.
public void delete(ObjectIdentifier identifier) throws ArchiveException, java.io.IOException
Takes a NameValueRecord OID.
Deletes the metadata record. If it is the last metadata record referencing the underlying object data, the underlying object data will also be deleted.
Uploads a new data object with an associated name-value metadata record.
public SystemRecord storeObject(java.nio.channels.ReadableByteChannel dataChannel)
public SystemRecord storeObject(ReadableByteChannel dataChannel,NameValueRecord record) throws ArchiveException,IOException
Takes a ReadableByteChannel (and an optional NameValueRecord) and returns a SystemRecord instance containing the system metadata for the new object.
Creates a new metadata record in the name-value object archive linked to the data object identified by the OID.
public SystemRecord storeMetadata(ObjectIdentifier linkOID, NameValueRecord record); throws ArchiveException, java.io.IOException
Takes a NameValueRecord and OID and returns a SystemRecord instance containing the system metadata for the new metadata record.
Checks if the metadata for an object is present in the query engine, and inserts the metadata if it is not present.
Synopsis
public int checkIndexed(ObjectIdentifier identifier) throws ArchiveException, IOException
checkIndexed is intended as way to resolve a store index exception under program control (see The 5800 System Query Integrity Model for more information).
Once a store index exception occurs (as indicated by a SystemRecord.isIndexed value of false after a store operation) then archive.checkIndexed(oid) can be called repeatedly until it returns any non-zero value. This will ensure that the metadata for the object has been inserted into the query engine; the object should then start to show up in matching queries.
checkIndexed returns an int value that indicates if the metadata for this object has been inserted into the query engine. The value is -1 if the metadata was already inserted before this operation was called, 0 if the metadata has still not been inserted, or 1 if the metadata was just now inserted.
Writes all of the data for the specified object into the provided channel, returning the amount of data actually retrieved.
public long retrieveObject(ObjectIdentifier oid, WritableByteChannel dataChannel) throws ArchiveException, java.io.IOException public long retrieveObject(ObjectIdentifier oid, java.nio.channels.WritableByteChannel dataChannel,long firstByte, long lastByte) throws ArchiveException, java.io.IOException
Takes an OID and downloads the data object into a supplied WritableByteChannel.
Returns a NameValueRecord instance containing the system and name-value metadata for the metadata record identified by the OID.
public NameValueRecord retrieveMetadata(ObjectIdentifier oid) throws ArchiveException, java.io.IOException
Returns a NameValueRecord instance containing the system and name-value metadata for the metadata record identified by the OID.
Returns the runtime configuration of the name-value object archive as a NameValueSchema instance.
public NameValueSchema getSchema() throws ArchiveException, java.io.IOException
Returns the runtime configuration of the name-value object archive as a NameValueSchema instance.
Returns a ResultSet of SystemRecord instances containing MetadataRecord OIDs.
public QueryResultSet query(java.lang.String query,int resultsPerFetch) throws ArchiveException, java.io.IOException
Takes a where clause and returns a QueryResultSet of SystemRecord instances containing MetadataRecord OIDs.
The query parameter is a where clause in the 5800 system query syntax, which is a subset of SQL.
Returns a QueryResultSet. The results are stepped through by calling the next method and using the typed getXXX accessor methods.
For more information on the 5800 system query language, refer to Chapter 4, Sun StorageTek 5800 System Query Language.
Returns a ResultSet of NameValueRecord instances containing the selected values.
public QueryResultSet query(java.lang.String query, java.lang.String[] selectKeys,int maxResults) throws ArchiveException, java.io.IOException
Takes a where clause and a select clause and returns a QueryResultSet of NameValueRecord instances containing the selected values.
selectKeys identifies the values to be returned, functioning as an SQL select clause.
The query parameter is a where clause in the 5800 system query syntax, which is a subset of SQL.
Returns a QueryResultSet. The results are stepped through by calling the next method and using the getObjectIdentifier accessor.
For more information on the 5800 system query language, refer to Chapter 4, Sun StorageTek 5800 System Query Language.
Returns the OIDs of metadata records matching the query as a QueryResultSet instance.
public QueryResultSet query(PreparedStatement query, int resultsPerFetch)
Takes a PreparedStatement and returns a QueryResultSet of SystemRecord instances containing MetadataRecord OIDs.
The PreparedStatement parameter enables queries with dynamic parameters to pass typed data items to the query.
Returns a QueryResultSet. The results are stepped through by calling the next method and using the typed getXXX accessor methods.
For more information on the 5800 system query language, refer to Chapter 4, Sun StorageTek 5800 System Query Language.
Returns specified fields from metadata records matching the query as a QueryResultSet instance.
public QueryResultSet query(PreparedStatement query, java.lang.String[] selectKeys, int resultsPerFetch)
Takes a where clause and a select clause and returns a QueryResultSet of NameValueRecord instances containing the selected values.
selectKeys identifies the values to be returned, functioning as an SQL select clause.
The PreparedStatement parameter enables queries with dynamic parameters to pass typed data items to the query.
Returns a QueryResultSet. The results are stepped through by calling the next method and using the getObjectIdentifier accessor.
For more information on the 5800 system query language, refer to Chapter 4, Sun StorageTek 5800 System Query Language.
Extends com.sun.honeycomb.common.Encoding
public PreparedStatement(java.lang.String sql);
Used to implement queries with Dynamic Parameters, which is the preferred way to pass typed data items to a StorageTek 5800 query.
The number of bindParameter calls should match the number of question marks (?) in the query string in the prepared statement. Parameters are specified positionally. For example, a bindParameter call with index = 1 supplies a value for the first ? in the supplied query string. Once a value has been supplied for each of the dynamic parameters, then the PreparedStatement may be passed to the NameValueObjectArchive.query method to be executed, for example:
NameValueObjectArchive archive = new NameValueObjectArchive(hostname); Date date_value= new java.sql.Date(); PreparedStatement stmt = new PreparedStatement("date_field<?”); stmt.bindParameter(date_value,1); QueryResultSet qrs = archive.query(stmt);
The QueryResultSet class is used to page through OIDs and associated metadata returned by NameValueObjectArchive.query. See the javadoc for the getXXX methods for getting typed metadata.
Sets the QueryResultSet to point at the next record.
boolean next()
Sets the QueryResultSet to point at the next record. Returns true if there is a next record, false if not.
Gets the ObjectIdentifier of the current metadata record.
ObjectIdentifier getObjectIdentifier()
Gets the ObjectIdentifier of the current metadata record.
Returns whether the set of results constitutes a complete set
boolean isQueryComplete()
Returns whether the set of results constitutes a complete set. See The 5800 System Query Integrity Model.
Returns the most recent time at which all store index exceptions are known to have been resolved.
long getQueryIntegrityTime()
The query integrity time is a time such that all store index exceptions from before that time have been resolved. There is an ideal query integrity time, which is the time of the oldest still-unresolved store index exception: an ideal implementation when asked for the query integrity time would always report this ideal value. In actual implementation, the reported query integrity time might be hours or even days earlier than the ideal query integrity time, depending on how far the ongoing system healing has progressed.
Get detailed status on which store index exceptions might still be unresolved
QueryResultSet.isQueryComplete(), QueryResultSet.getQueryIntegrityTime();