This section provides detailed information on the C example applications provided with the 5800 system client SDK.
Included with the 5800 system SDK are several command-line example applications that demonstrate the use of the C API. The example applications are located in the SDK under c/examples. Appropriate libraries are supplied for Solaris SPARC, Solaris x86, Red Hat Linux, and Windows.
Make sure you configure your software environment before using the C example applications.
In Solaris and Linux, set the LD_LIBRARY_PATH environment variable to SDK directory name/c/OS/lib where SDK directory name is the root directory of the unzipped 5800 system SDK archive and OS is either Solaris or Linux. For example:
StorageTek500_SDK_1_1-20/c/Solaris/lib
In Microsoft Windows 2003:
The example programs will run if they are run as installed in the default build directory. However, if you have moved them elsewhere, the location of the library files (DLLs) must be added to the PATH environment variable as follows:
C:\StorageTek500_SDK_1_1_82\c\Win32\lib
To edit the windows PATH environment variable:
Click the Start button.
Right-click My Computer and select properties to launch System Properties.
Click the Advanced tab.
Click Environment Variables.
Under System Variables, scroll down and click Path.
Click Edit to launch Edit System Variable.
Add the full path name of the SDK lib directory to the PATH environment variable. Make certain each path name is separated by a semicolon (;).
Click OK to close each window.
Also see Software Requirements.
To build the C example applications, go to the c/examples directory and run make. This will build the example applications and put them in the c/examples/OS/build directory.
Each C example application can be built separately by running make program_name.
Once you have built the C example applications, go to the c/examples/<OS>/build directory and execute the binary file with the appropriate command line. The examples depend on libhoneycomb.so.
First, the function parseCommandline is called to parse the command line and store the information in a struct called Commandline. Next, any files that contain data to be sent to the 5800 system server are opened. The appropriate 5800 system C API is then called. Finally, output is delivered back to either standard output, a file, or both. Refer to the comments in the sample code for further details.
The following C example applications are included with the 5800 system client SDK:
Stores a file and associated metadata on a 5800 system server.
StoreFile <IP | HOST> <FILE> [OPTIONS]
Stores a file and its associated metadata record. If no -m options are specified, a metadata record without user content is generated. The OID of the metadata record is printed to stdout.
-m <name>=<value>
Any number of -m options can be specified. Each option specifies a single (name,value) pair.
<name> should be specified in the format <namespace>.<attribute>. Use double quotes if <value> is a string containing spaces.
-h
Print this message.
StoreFile server /var/log/messages StoreFile server ~/journal StoreFile server myfile.jpg -m filesystem.mimetype="image/jpeg" StoreFile 10.152.0.12 myfile -m system.test.type_char="do re mi" StoreFile 10.152.0.12 myfile -m system.test.type_string="fa so la" StoreFile 10.152.0.12 myfile -m system.test.type_long=123 StoreFile 10.152.0.12 myfile -m system.test.type_double=1.23 StoreFile 10.152.0.12 myfile -m system.test.type_binary=0789abcdef StoreFile 10.152.0.12 myfile -m system.test.type_date=2010-10-20 StoreFile 10.152.0.12 myfile -m system.test.type_time=23:30:29 StoreFile 10.152.0.12 myfile \ -m system.test.type_timestamp="2010-10-20T23:30:29.999" StoreFile 10.152.0.12 myfile -m name1=value1 -m name2="value 2"
c/examples/StoreFile.c
Ensure an object is queryable. Checks if the metadata for an object is present in the query engine, and inserts the metadata if it is not present.
CheckIndexed <IP | HOST> <OID> [OPTIONS]
Check with the 5800 systemserver to determine if the specified OID has become queryable. If not, attempt to make it queryable.
A short message about the supplied OID is printed to stdout:
Object OID was already queryable. Object OID not yet queryable. Object OID has now been made queryable. |
-h
Print this message.
CheckIndexed archivehost \ 0200004f75ee01094cc13e11dbbad000e08159832d000024d40200000000 CheckIndexed 10.152.0.12 \ 0200004f75ee01094cc13e11dbbad000e08159832d000024d40200000000
c/examples/CheckIndexed.c
Retrieves a data object from a 5800 system server.
RetrieveData <IP | HOST> <OID> <FILE> [OPTIONS]
Retrieves data from the 5800 system. The OID specifies what data to retrieve. Data is written to FILE, if specified, otherwise to stdout.
-h
Print this message.
RetrieveData storagetek \ 0200004f75ee01094cc13e11dbbad000e08159832d000024d40200000000 \ /archive/log.1
c/examples/RetrieveData.c
Retrieves a metadata record from a specified 5800 system server.
RetrieveMetadata <IP | HOST> <OID> [OPTIONS]
Retrieves metadata from the 5800 system. The OID specifies what data to retrieve. Metadata is printed to stdout.
-h
Print this message.
RetrieveMetadata archivehost \ 0200004f75ee01094cc13e11dbbad000e08159832d000024d40200000000 RetrieveMetadata 10.152.0.12 \ 0200004f75ee01094cc13e11dbbad000e08159832d000024d40200000000
c/examples/RetrieveMetadata.c
Adds a metadata record to an already stored object.
AddMetadata <IP | HOST> <OID> [OPTIONS]
Adds a new metadata record to an existing data object.
-m <name>=<value>
Any number of -m options can be specified. Each option specifies a single (name, value) pair.
<name> should be specified in the format <namespace>.<attribute>. Use double quotes if <value> is a string containing spaces.
-h
Print this message.
AddMetadata server \ 0200004f75ee01094cc13e11dbbad000e08159832d000024d40200000000 \ -m filesystem.mimetype="image/jpeg" AddMetadata server \ 0200004f75ee01094cc13e11dbbad000e08159832d000024d40200000000 \ -m system.test.type_char="do re mi" AddMetadata server \ 0200004f75ee01094cc13e11dbbad000e08159832d000024d40200000000 \ -m system.test.type_string="fa so la" AddMetadata server \ 0200004f75ee01094cc13e11dbbad000e08159832d000024d40200000000 \ -m system.test.type_long=123 AddMetadata server \ 0200004f75ee01094cc13e11dbbad000e08159832d000024d40200000000 \ -m system.test.type_double=1.23 AddMetadata server \ 0200004f75ee01094cc13e11dbbad000e08159832d000024d40200000000 \ -m system.test.type_date=1992-10-27 AddMetadata server \ 0200004f75ee01094cc13e11dbbad000e08159832d000024d40200000000 \ -m system.test.type_time=23:30:29 AddMetadata server \ 0200004f75ee01094cc13e11dbbad000e08159832d000024d40200000000 \ -m system.test.type_timestamp="1992-10-27T23:30:29" AddMetadata server \ 0200004f75ee01094cc13e11dbbad000e08159832d000024d40200000000 \ -m name1=value1 -m name2="value 2"
c/examples/AddMetadata.c
Deletes a record associated with an OID.
DeleteRecord <IP | HOST> <OID> [OPTIONS]
Deletes a record associated with an OID. The OID specifies which record to delete. The record consists of all metadata associated with the OID, or the data if it is a data OID. The OID itself becomes inaccessible. If this OID is the last OID associated with the data, the data is also deleted.
-v
Print deleted OID to stdout.
-h
Print this message.
DeleteRecord server 0200004f75ee01094cc13e11dbbad000e08159832d000024d40200000000
c/examples/DeleteRecord.c
Queries a 5800 system server for metadata records that match the query string passed on the command line.
Query requires the T..Z UTC format. For example, 1952-10-27T00:30:29.999Z.
Query <IP | HOST> <QUERY> [OPTIONS]
Queries for metadata records. QUERY is of the form:
<name1>=’<value1>’ AND <name2>=’<value2>’ OR ...
See the examples below for formatting of various types of values. The OID and any specified fields of metadata records that match the query are printed to stdout.
<name> should be specified in the format <namespace>.<attribute>.
Note that names that are keywords need to be enclosed in escaped double quotes (for example, with the bash shell, use "\"<name>\"=’<value>’"). Refer to the list of keywords in Chapter 4, Sun StorageTek 5800 System Query Language, in Sun StorageTek 5800 SystemClient API Reference Manual.
-s <FIELD>
Print out results as metadata name-value records. Use as many -s switches as needed to define all fields that will be printed to stdout.
-n <number of results>
The maximum number of metadata records or OIDs that will be returned. The default is 1000.
-h
Print this message.
In the following examples, “first” is a keyword.
Query archivehost "book.author=’King’" Query archivehost "\"first\"=’a’" Query archivehost system.test.type_char="’do re mi’" Query archivehost system.test.type_string="’fa so la’" Query archivehost system.test.type_long=123 Query archivehost system.test.type_double=1.23 Query archivehost system.test.type_binary="x’0789abcdef’" Query archivehost system.test.type_date="’2010-10-20’" Query archivehost system.test.type_time="’22:10:29’" Query archivehost system.test.type_timestamp="{timestamp’2010-10-20T23:30:29.123Z’}" Query 10.152.0.12 "mp3.artist=’The Beatles’ AND mp3.album=’Abbey Road’" Query 10.152.0.12 "mp3.artist=’The Beatles’" -s mp3.album -s mp3.title Query 10.152.0.12 "system.test.type_timestamp={timestamp ’1952-10-27T08:30:29.999Z’}"
c/examples/Query.c
Prints metadata attributes to stdout.
RetrieveSchema <IP | HOST> [OPTIONS]
Retrieves the schema from a 5800 system server, printing it to stdout.
-h
Print this message.
RetrieveSchema archivehost
c/examples/RetrieveSchema.c