header

md_api.h File Reference

#include <string>
#include <list>
#include <vector>
#include <sys/types.h>
#include <dirent.h>

Go to the source code of this file.


Classes

class  AttributeList
class  EntryList
class  UploadHandle

Defines

#define _FILE_OFFSET_BITS   64
#define MD_ERR_OK   0
#define MD_ERR_NOENT   1
#define MD_ERR_ILCMD   3
#define MD_ERR_PERM   4
#define MD_ERR_INTERNAL   9
#define MD_ERR_NOKEY   7

Functions

int translateError (int amga)
int addAttr (const std::string &dir, const std::string &key, const std::string &type="varchar(256)")
 Adds a new attribute of a directory(collection).
int getAttr (const std::string &file, const std::string &key, std::string &attr)
 A simple interface to access the attributes of an entry.
int getAttr (MDClient &client, const std::string &file, const std::string &key, std::string &attr)
 getAttr with external handling of the connection
int amgaStat (MDClient &client, const std::string &file, struct stat *stbuf)
 Sets one ore more attributes of a file.
int amgaReadlink (MDClient &client, const char *path, char *buf, size_t size)
int setAttr (const std::string &file, const std::vector< std::string > &keys, const std::vector< std::string > &values)
 Sets one ore more attributes of a file.
int setAttr (MDClient &client, const std::string &file, const std::vector< std::string > &keys, const std::vector< std::string > &values)
 Version of setAttr with external client management.
int listAttr (MDClient &client, const std::string &file, std::list< std::string > &attrList, std::list< std::string > &types)
 Version of listAttr with external client management.
int listAttr (const std::string &file, std::list< std::string > &attrList, std::list< std::string > &types)
 Lists the attributes of a file.
int removeAttr (const std::string &file, const std::string &key)
 Version of removeAttr with external management of client.
int clearAttr (const std::string &file, const std::string &key)
 Resets the value of a given attribute of a file.
int createDir (const std::string &dir)
 Function to create a directory (collection).
int getAttr (const std::string &pattern, const std::list< std::string > &keys, AttributeList &attributes)
 More complex interface to getting atributes using an iterator.
int findEntries (const std::string &pattern, const std::string &query, EntryList &entries)
 Finds entries in the catalogue matching a query.
int link (const std::string &file, const std::string &URL)
 Creates a link to another entry or an entry pointing to an external location.
int upload (const std::string &dir, const std::vector< std::string > &keys, UploadHandle &handle)
 Bulk upload of entries and their attributes.
DIR * amgaOpendir (MDClient &client, const char *name)
dirent * amgaReaddir (MDClient &client, DIR *dir)
int amgaClosedir (MDClient &client, DIR *dir)

Define Documentation

#define _FILE_OFFSET_BITS   64

Definition at line 24 of file md_api.h.

#define MD_ERR_ILCMD   3

Definition at line 35 of file md_api.h.

#define MD_ERR_INTERNAL   9

Definition at line 37 of file md_api.h.

#define MD_ERR_NOENT   1

Definition at line 34 of file md_api.h.

#define MD_ERR_NOKEY   7

Definition at line 38 of file md_api.h.

#define MD_ERR_OK   0

Definition at line 33 of file md_api.h.

#define MD_ERR_PERM   4

Definition at line 36 of file md_api.h.


Function Documentation

int addAttr ( const std::string &  dir,
const std::string &  key,
const std::string &  type 
)

Adds a new attribute of a directory(collection).

Adds a new attribute to the list of attributes to a directory or collection, giving its name and type. If the type is not given, then currently "text" is use, which is an arbitrarily long ASCII text. Type is only used as the storage type in the backend. The communication between client and server is allways pure ASCII.

Parameters:
dir The directory(collection) affected
key The name of the attribute
type The storage type of the attribute in the backend
Returns:
Error code (Including errors returned by the addattr metadata interface command):
  • 0 OK
  • -1 Client-Server connection failed
  • MD_ERR_NOENT: Directory does not exist
  • MD_ERR_PERM: Permission denied. You need write permission on the directory

Definition at line 606 of file md_api.cc.

References MDClient::execute().

int amgaClosedir ( MDClient client,
DIR *  dir 
)

Definition at line 918 of file md_api.cc.

References MDClient::eot(), and MDClient::fetchRow().

DIR* amgaOpendir ( MDClient client,
const char *  name 
)

Definition at line 850 of file md_api.cc.

References MDClient::execute(), and translateError().

struct dirent* amgaReaddir ( MDClient client,
DIR *  dir 
)

Definition at line 874 of file md_api.cc.

References MDClient::eot(), MDClient::fetchRow(), and translateError().

int amgaReadlink ( MDClient client,
const char *  path,
char *  buf,
size_t  size 
)

Definition at line 262 of file md_api.cc.

References MDClient::eot(), MDClient::execute(), MDClient::fetchRow(), and translateError().

int amgaStat ( MDClient client,
const std::string &  file,
struct stat *  stbuf 
)

Sets one ore more attributes of a file.

The attributes are given by the caller as a list of strings, which needs to match the length of the values to be assigned. The keys need to be defined with addAttr() first.

Parameters:
file The file name of the entry
keys A list of keys
values The list of values which are assigend to the keys
Returns:
Error code (including errors returned by the setattr metadata interface command):
  • 0 OK
  • -1 Client-Server connection problems
  • MD_ERR_NOENT: No such file or directory
  • MD_ERR_ILCMD: Illegal command: keys and values size mismatch
  • MD_ERR_PERM: Permission denied. You need write permission on the entry

Definition at line 141 of file md_api.cc.

References MDClient::eot(), MDClient::execute(), MDClient::fetchRow(), and translateError().

int clearAttr ( const std::string &  file,
const std::string &  key 
)

Resets the value of a given attribute of a file.

Sets the attribute of a file to NULL. getAttr() will return this value as an empty string.

Parameters:
file Name of the entry
key Name of the attribute
Returns:
Error code (Including errors returned by the clearattr metadata interface command):
  • 0 OK
  • -1 Client-Server connection failed
  • MD_ERR_NOENT: Unknown directory
  • MD_ERR_PERM: Permission denied. You need write permission on the file

Definition at line 444 of file md_api.cc.

References MDClient::execute().

int createDir ( const std::string &  dir  ) 

Function to create a directory (collection).

Creates a new directory. You will need to have write permissions in the parent directory and the directory should not already exist.

Parameters:
dir The desired name of the directory
Returns:
Error code (Including errors returned by the createdir metadata interface command):
  • 0 OK
  • -1 Client-Server connection failed
  • MD_ERR_NOENT: Parent directory does not exist
  • MD_ERR_PERM: Permission denied. You need write permission on the parent directory

Definition at line 579 of file md_api.cc.

References MDClient::execute().

int findEntries ( const std::string &  pattern,
const std::string &  query,
EntryList entries 
)

Finds entries in the catalogue matching a query.

Finds all files in the catalogue matching a given filename pattern and SQL-like query. The matching entries are returned via an EntryList object.

Parameters:
pattern The pattern matching possible filenames(entries)
query The SQL-Like query which winds up in the WHERE clause of the SQL-SELECT statement
entries The returned EntryList object holding the streamed connection to the server (call getEntry on it to get hold of the entries).
Returns:
Error code (including errors returned by the find metadata interface command):
  • 0 OK
  • -1 Client-Server connection failed
  • MD_ERR_NOENT: No file matches pattern

Definition at line 661 of file md_api.cc.

References EntryList::connect(), and MDClient::execute().

int getAttr ( const std::string &  pattern,
const std::list< std::string > &  keys,
AttributeList attributes 
)

More complex interface to getting atributes using an iterator.

Returns an AttributeList object holding a streamed connection to the metadata server which allows to iteratively get the filenames and values of several attributes of multiple files matching a given pattern.

Parameters:
pattern The pattern the filenames need to match
keys The names of the attributes as a list of strings
attributes The AttributeList structure returned by the call
Returns:
Error code (Including errors returned by the getattr metadata interface command):
  • 0 OK
  • -1 Client-Server connection failed
  • MD_ERR_NOENT: Unknown directory
  • MD_ERR_PERM: Permission denied. You need read permission on the file

Definition at line 470 of file md_api.cc.

References AttributeList::connect(), and MDClient::execute().

int getAttr ( MDClient client,
const std::string &  file,
const std::string &  key,
std::string &  attr 
)

getAttr with external handling of the connection

Definition at line 93 of file md_api.cc.

References MDClient::execute(), and MDClient::fetchRow().

int getAttr ( const std::string &  file,
const std::string &  key,
std::string &  value 
)

A simple interface to access the attributes of an entry.

This command sends the getattr metadata interface command to a metadata server and returns the value of a single key for a given files.

Parameters:
file Name of the file
key The key name
value The value of the file which is filled
Returns:
Error value (including errors of the getattr interface command):
  • 0 in case of everything went OK,
  • -1 if something went wrong with the client-server connection
  • MD_ERR_NOENT: No such file or directory
  • MD_ERR_PERM: Permission denied. You need read permission on the file

Definition at line 83 of file md_api.cc.

References getAttr().

int link ( const std::string &  file,
const std::string &  URL 
)

Creates a link to another entry or an entry pointing to an external location.

Creates a link to another entry in the catalogue or lets the entry point to an external location. Note that metadata is associated with logical filenames and thus the implementation will not follow this link where metadata related queries of updates are concerned. Local links must have the protocol file: while everything else is considered to be a pointer to an external catalogue.

Parameters:
file The entry affected
URL The link location
Returns:
Error code (Including errors returned by the addattr metadata interface command):
  • 0 OK
  • -1 Client-Server connection failed
  • MD_ERR_NOENT: Parent directory does not exist
  • MD_ERR_PERM: Permission denied. You need write permission on the directory

Definition at line 635 of file md_api.cc.

References MDClient::execute().

int listAttr ( const std::string &  file,
std::list< std::string > &  attrList,
std::list< std::string > &  types 
)

Lists the attributes of a file.

For a given file this functioin returns a list of attributes of a directory and their types. Note that also attributes which are undefined (assigned to NULL) for the entry are listed.

Parameters:
file Entry name
attrList Returns the attributes' names as a list of strings
types Returns the list of associated types as strings
Returns:
Error value (including errors returned by the listattr metadata interface command):
  • 0 OK
  • -1 Client-Server connection failed
  • MD_ERR_NOENT: No such file or directory
  • MD_ERR_PERM: Permission denied. You need read permission for the entry.

Definition at line 365 of file md_api.cc.

References listAttr().

int listAttr ( MDClient client,
const std::string &  file,
std::list< std::string > &  attrList,
std::list< std::string > &  types 
)

Version of listAttr with external client management.

Definition at line 375 of file md_api.cc.

References MDClient::eot(), MDClient::execute(), and MDClient::fetchRow().

int removeAttr ( const std::string &  file,
const std::string &  key 
)

Version of removeAttr with external management of client.

Definition at line 424 of file md_api.cc.

References removeAttr().

int setAttr ( MDClient client,
const std::string &  file,
const std::vector< std::string > &  keys,
const std::vector< std::string > &  values 
)

Version of setAttr with external client management.

Definition at line 332 of file md_api.cc.

References MDClient::execute().

int setAttr ( const std::string &  file,
const std::vector< std::string > &  keys,
const std::vector< std::string > &  values 
)

Sets one ore more attributes of a file.

The attributes are given by the caller as a list of strings, which needs to match the length of the values to be assigned. The keys need to be defined with addAttr() first.

Parameters:
file The file name of the entry
keys A list of keys
values The list of values which are assigend to the keys
Returns:
Error code (including errors returned by the setattr metadata interface command):
  • 0 OK
  • -1 Client-Server connection problems
  • MD_ERR_NOENT: No such file or directory
  • MD_ERR_ILCMD: Illegal command: keys and values size mismatch
  • MD_ERR_PERM: Permission denied. You need write permission on the entry

Definition at line 321 of file md_api.cc.

References setAttr().

int translateError ( int  amga  ) 

Definition at line 51 of file md_api.cc.

References MD_ERR_ILCMD, MD_ERR_INTERNAL, MD_ERR_NOENT, MD_ERR_NOKEY, MD_ERR_OK, and MD_ERR_PERM.

Referenced by amgaOpendir(), amgaReaddir(), amgaReadlink(), and amgaStat().

int upload ( const std::string &  dir,
const std::vector< std::string > &  keys,
UploadHandle handle 
)

Bulk upload of entries and their attributes.

The attributes' names are given by the caller as a list of strings. They need to be defined with addAttr() first. Sets up UploadHandle so that it can be used to upload the entries, and finally commit the changes (or abort the transaction).

Parameters:
dir The name of the collection affected
keys A list of keys
handle Reference to the UploadHandle which is used afterwards to upload the entries.
Returns:
Error code (including errors returned by the upload metadata interface command):
  • 0 OK
  • -1 Client-Server connection problems
  • MD_ERR_NOENT: No such file or directory
  • MD_ERR_ILCMD: Illegal command: keys and values size mismatch
  • MD_ERR_PERM: Permission denied. You need write permission on the entry

Definition at line 825 of file md_api.cc.

References UploadHandle::connect(), and MDClient::execNoWait().


Generated on Mon Apr 16 13:59:18 2012 for AMGA by  doxygen 1.4.7