header

MDClient Class Reference

#include <MDClient.h>

List of all members.


Public Member Functions

 MDClient (const std::string &host="", int port=0, bool persistent=false, const std::string &configFile="", bool dbg=false)
 Constructor of the MDClient class.
 ~MDClient ()
 Destructor of MDClient.
void useServer (const std::string &ipAddr, int port=0)
 Sets server for next connectToServer() call.
int nextServer ()
 Picks next configured server from list of BDII and configuration file.
int connectToServer ()
 Establishes the actual connection to the server.
bool isConnected () const
 Returns true if the MDClient holds a TCP connection an AMGA server.
int disconnect (bool saveSession=false)
 Disconnects from the AMGA server.
int setTimeout (int seconds)
 This does not work!
int execute (const std::string &command)
 Executes an AMGA command.
int execNoWait (const std::string &command)
 Execute an AMGA command without waiting for the server error status.
int fetchRow (std::string &row, bool readAhead=true)
std::string getError ()
bool eot ()
 Checks whether the reply to a query was recieved fully.
const std::string & getGreeting ()
 Returns the greeting string the server sent on connecting.
void setSendBuffer (unsigned int s)
 Sets the send-buffer when streaming data to the server.
void setSessionNumber (int n)
 Sets the session number to allow several sessions for a user.
int getSessionNumber ()
 Gets the session number of the user.
int cancel ()
 Sends an out-of-band cancel message to the server.
const std::string & serverName () const
int serverPort () const
std::string currentServiceName () const
bool getDebug ()
void setDebug (bool d)
int fetchData ()
void setError (std::string err)

Public Attributes

bool endOfTransmission
int resultCols
MDFedmdfed

Static Public Attributes

static char certKey [256]

Friends

void int_sig_handler (int)
MDClientregisterClient (MDClient *)
void pthreads_locking_callback (int, int, const char *, int)

Classes

class  MDClientLock

Detailed Description

Definition at line 52 of file MDClient.h.


Constructor & Destructor Documentation

MDClient::MDClient ( const std::string &  host = "",
int  port = 0,
bool  persistent = false,
const std::string &  configFile = "",
bool  dbg = false 
)

Constructor of the MDClient class.

Construct an MDClient which is configured to connect to

Parameters:
host at
port . If
persistent is true, a peristent session will be created. The configuration file is read from the current directory, ~/.mdclient.config or the file on
configFile if given. The constructor does not itself connect to the server, instead you need to call connectToServer() afterwards which also makes it possible to return error codes. MDClient is not thread-safe. Instead instantiate an MDClient per thread. The client will ensure thread-safe access to all global resources like the openssl library.

Definition at line 159 of file MDClient.cc.

References MDFed::configF, ConfigParser::getString(), ConfigParser::init(), mdfed, MDFed::proxyState, MDFed::setParentMDClient(), and ConfigParser::toLower().

MDClient::~MDClient (  ) 

Destructor of MDClient.

This destructor releases all resources held by the MDClient class after disconnecting from the server and saving the session if so configured. You do not need to do this manually.

Definition at line 608 of file MDClient.cc.

References disconnect(), MDFed::disconnectFed(), execute(), and mdfed.


Member Function Documentation

int MDClient::cancel (  ) 

Sends an out-of-band cancel message to the server.

Send a cancel request to the server. Note that this can be honoured by the server if results are streamed back to the client. You need to continue to call fetchRow() until eot() returns true.

Definition at line 1262 of file MDClient.cc.

References endOfTransmission, fetchData(), and setError().

Referenced by EntryList::cancel(), and fetchData().

int MDClient::connectToServer (  ) 

Establishes the actual connection to the server.

This method can be called to establish the connection to the AMGA server for the first time or restablish it after a disconnect. Returns 0 on success or -1 if something went wrong. A description of the error is returned by the getError() method.

Definition at line 548 of file MDClient.cc.

References initConnection(), and setError().

Referenced by execNoWait(), execute(), and MDFed::initNextFedHosts().

std::string MDClient::currentServiceName (  )  const [inline]

Definition at line 116 of file MDClient.h.

int MDClient::disconnect ( bool  saveSession = false  ) 

Disconnects from the AMGA server.

Disconnects from the AMGA server and stores all data necessary to resume the session in a session file

Definition at line 820 of file MDClient.cc.

Referenced by MDFed::disconnectFed(), fetchData(), and ~MDClient().

bool MDClient::eot (  ) 

Checks whether the reply to a query was recieved fully.

Returns true if the entire reply to a quey issued by execute() was recieved. As long as eot() returns false you need to call fetchRow(), even after a cancel() has been sent to flush the send-buffer of the server.

Definition at line 1228 of file MDClient.cc.

References endOfTransmission, MDFed::eot(), fetchData(), mdfed, and MDFed::proxyState.

Referenced by amgaClosedir(), amgaReaddir(), amgaReadlink(), amgaStat(), MDFed::eot(), EntryList::lastEntry(), AttributeList::lastRow(), listAttr(), and MDFed::retrieveFedHosts().

int MDClient::execNoWait ( const std::string &  command  ) 

Execute an AMGA command without waiting for the server error status.

Executes an AMGA command without waiting for a server response which contains the error status. This is important for commands which stream data to the server where a response is only sent at the time when the command is commited like the upload command. The method returns 0 on success, a positive AMGA error code when the command execution failed or a negative error code if the MDClient had problems contacting the server or something went wrong internally. The command is given as a string in

Parameters:
command .

Definition at line 873 of file MDClient.cc.

References connectToServer().

Referenced by UploadHandle::put(), and upload().

int MDClient::execute ( const std::string &  command  ) 

Executes an AMGA command.

Executes an AMGA command

Parameters:
command and returns the error code from the AMGA server (positive values). A negative return code means problems with the connection or internal problems.

Definition at line 986 of file MDClient.cc.

References connectToServer(), MDFed::failureCode, MDFed::lastCommand, mdfed, and MDFed::proxyState.

Referenced by UploadHandle::abort(), addAttr(), amgaOpendir(), amgaReadlink(), amgaStat(), clearAttr(), UploadHandle::commit(), createDir(), findEntries(), getAttr(), MDFed::initNextFedHosts(), link(), listAttr(), removeAttr(), setAttr(), and ~MDClient().

int MDClient::fetchData (  ) 

Fetches more data from the server until a full line is in the buffer or an EOT is detected.

Definition at line 1154 of file MDClient.cc.

References cancel(), disconnect(), endOfTransmission, and setError().

Referenced by cancel(), eot(), fetchRow(), and MDFed::initNextFedHosts().

int MDClient::fetchRow ( std::string &  line,
bool  readAhead = true 
)

The line is a reference to a string which gets filled with the row read from the buffer or if necessary from the network. The readAhead option which defaults to true makes sure that a subsequent call to eot() is meaningful. Only if the caller knows that no EOT character can be at the end of the line read this option can be set to false. This is done internally during the handshaking where empty lines are EOT delimiters.

Definition at line 1064 of file MDClient.cc.

References endOfTransmission, fetchData(), MDFed::fetchRow(), mdfed, and MDFed::proxyState.

Referenced by amgaClosedir(), amgaReaddir(), amgaReadlink(), amgaStat(), MDFed::fetchRow(), getAttr(), EntryList::getEntry(), AttributeList::getRow(), listAttr(), and MDFed::retrieveFedHosts().

bool MDClient::getDebug (  )  [inline]

Definition at line 122 of file MDClient.h.

std::string MDClient::getError (  )  [inline]

Definition at line 85 of file MDClient.h.

Referenced by MDFed::initNextFedHosts(), and MDFed::retrieveFedHosts().

const std::string & MDClient::getGreeting (  ) 

Returns the greeting string the server sent on connecting.

Definition at line 1372 of file MDClient.cc.

int MDClient::getSessionNumber (  )  [inline]

Gets the session number of the user.

Definition at line 100 of file MDClient.h.

bool MDClient::isConnected (  )  const [inline]

Returns true if the MDClient holds a TCP connection an AMGA server.

Definition at line 73 of file MDClient.h.

int MDClient::nextServer (  ) 

Picks next configured server from list of BDII and configuration file.

Picks the next server from the list of servers in via BDII or the configuration file. Returns 0 if wraparound to first server occourred Returns 1 another server was found Return -1 if there are no servers

Definition at line 513 of file MDClient.cc.

const std::string& MDClient::serverName (  )  const [inline]

Returns the name of the server the client is connected to (in this session)

Definition at line 106 of file MDClient.h.

int MDClient::serverPort (  )  const [inline]

Returns port number of the server the client is connected to (in this session)

Definition at line 112 of file MDClient.h.

void MDClient::setDebug ( bool  d  )  [inline]

Definition at line 123 of file MDClient.h.

void MDClient::setError ( std::string  err  ) 

Definition at line 1115 of file MDClient.cc.

Referenced by cancel(), connectToServer(), fetchData(), and MDFed::initFed().

void MDClient::setSendBuffer ( unsigned int  s  )  [inline]

Sets the send-buffer when streaming data to the server.

Definition at line 94 of file MDClient.h.

void MDClient::setSessionNumber ( int  n  )  [inline]

Sets the session number to allow several sessions for a user.

Definition at line 97 of file MDClient.h.

int MDClient::setTimeout ( int  seconds  ) 

This does not work!

Definition at line 853 of file MDClient.cc.

void MDClient::useServer ( const std::string &  ipAddr,
int  port = 0 
)

Sets server for next connectToServer() call.

Definition at line 532 of file MDClient.cc.

References MD_DEFAULT_PORT.


Friends And Related Function Documentation

void int_sig_handler ( int   )  [friend]

Signal handler for SIGINT

Definition at line 67 of file MDClient.cc.

void pthreads_locking_callback ( int  mode,
int  type,
const char *  file,
int  line 
) [friend]

Definition at line 133 of file MDClient.cc.

MDClient* registerClient ( MDClient  )  [friend]

Definition at line 76 of file MDClient.cc.


Member Data Documentation

char MDClient::certKey [static]

Definition at line 123 of file MDClient.h.

bool MDClient::endOfTransmission

Definition at line 127 of file MDClient.h.

Referenced by cancel(), eot(), fetchData(), fetchRow(), and MDFed::initNextFedHosts().

MDFed* MDClient::mdfed

Definition at line 133 of file MDClient.h.

Referenced by eot(), execute(), fetchRow(), MDClient(), and ~MDClient().

int MDClient::resultCols

Definition at line 128 of file MDClient.h.

Referenced by MDFed::initNextFedHosts().


The documentation for this class was generated from the following files:
Generated on Mon Apr 16 13:59:19 2012 for AMGA by  doxygen 1.4.7