/usr/include/arc/infosys/InfoRegister.h is in nordugrid-arc-dev 4.2.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | #ifndef __ARC_INFOSYS_REGISTER_H__
#define __ARC_INFOSYS_REGISTER_H__
#include <list>
#include <string>
#include <arc/ArcConfig.h>
#include <arc/XMLNode.h>
#include <arc/message/MCC.h>
#include <arc/message/Service.h>
#include <arc/Logger.h>
#include <arc/URL.h>
#include <arc/DateTime.h>
#define GLUE2_D42_NAMESPACE "http://schemas.ogf.org/glue/2008/05/spec_2.0_d42_r1"
#define REGISTRATION_NAMESPACE "http://www.nordugrid.org/schemas/registartion/2008/08"
#define ISIS_NAMESPACE "http://www.nordugrid.org/schemas/isis/2008/08"
#define REGISTRATION_CONFIG_NAMESPACE "http://www.nordugrid.org/schemas/InfoRegisterConfig/2008"
namespace Arc {
class InfoRegisterContainer;
/// Registration to Information Indexing Service
/** This class represents service registering to Information Indexing Service.
It does not perform registration itself. It only collects configuration
information. Configuration is as described in InfoRegisterConfig.xsd for
element InfoRegistration. */
class InfoRegister {
friend class InfoRegisterContainer;
private:
// Registration period
long int reg_period_;
// Registration information
std::string serviceid;
std::string expiration;
std::string endpoint;
// Associated service - it is used to fetch information document
Service *service_;
NS ns_;
public:
InfoRegister(XMLNode node, Service *service_);
~InfoRegister();
operator bool(void) { return service_; };
bool operator!(void) { return !service_; };
long int getPeriod(void) const { return reg_period_; };
std::string getServiceID(void) { if (serviceid.empty()) return ""; else return serviceid; };
std::string getEndpoint(void) { if (endpoint.empty()) return ""; else return endpoint; };
std::string getExpiration(void) { if (expiration.empty()) return ""; else return expiration; };
Service* getService(void) { return service_; };
};
/// Handling registrations to multiple Information Indexing Services
class InfoRegisters {
private:
std::list<InfoRegister*> registers_;
public:
/// Constructor creates InfoRegister objects according to configuration
/** Inside cfg elements InfoRegister elements are found and for each
corresponding InfoRegister object is created. Those objects
are destroyed in destructor of this class. */
InfoRegisters(XMLNode cfg, Service *service);
~InfoRegisters(void);
/// Dinamically add one more InfoRegister object
bool addRegister(XMLNode cfg, Service *service);
};
// Data stucture for the InfoRegistrar class.
struct Register_Info_Type{
// Necessary information for the registration
InfoRegister* p_register;
Period period;
Time next_registration;
// ServiceID extracted from the first provided registration message
std::string serviceid_;
// Registration information
std::string serviceid;
std::string expiration;
std::string endpoint;
};
// Data structure for describe a remote ISIS
struct ISIS_description {
std::string url;
std::string key;
std::string cert;
std::string proxy;
std::string cadir;
std::string cafile;
};
/// Registration process associated with particular ISIS
/** Instance of this class starts thread which takes care
passing information about associated services to ISIS
service defined in configuration. Configuration is as
described in InfoRegister.xsd for element InfoRegistrar. */
class InfoRegistrar {
friend class InfoRegisterContainer;
private:
/// Constructor creates object according to configuration.
/** This object can only be created by InfoRegisterContainer
which takes care of finding configuration elements in
configuration document. */
InfoRegistrar(XMLNode cfg);
// Configuration parameters
std::string id_;
// Type of the information system connected to (EMIREG, ISIS, etc.)
std::string infosys_type;
std::string path;
int retry;
// Security attributes
std::string key_;
std::string cert_;
std::string proxy_;
std::string cadir_;
std::string cafile_;
// Associated services
std::list<Register_Info_Type> reg_;
// Mutex protecting reg_ list
Glib::Mutex lock_;
// Condition signaled when thread has to exit
Glib::Cond cond_exit_;
// Condition signaled when thread exited
Glib::Cond cond_exited_;
// InfoRegistrar object creation time moment
Time creation_time;
// Time window providing some flexibility to avoid the casual slides
Period stretch_window;
// ISIS handle attributes & functions
ISIS_description defaultBootstrapISIS;
ISIS_description myISIS;
bool myISISList_initialized;
int originalISISCount;
int call_depth;
std::vector<ISIS_description> myISISList;
void initISIS(XMLNode cfg);
void removeISIS(ISIS_description isis);
void getISISList(ISIS_description isis);
ISIS_description getISIS(void);
// End of ISIS handle attributes & functions
// Sending functions
bool already_registered;
void sendRegistrationToISIS();
void sendRegistrationToEMIREG();
void sendDeleteToISIS(std::list<Register_Info_Type>::iterator r);
void sendDeleteToEMIREG(std::list<Register_Info_Type>::iterator r);
public:
~InfoRegistrar(void);
operator bool(void) { return !myISIS.url.empty(); };
bool operator!(void) { return myISIS.url.empty(); };
/// Performs registartion in a loop.
/** Never exits unless there is a critical error or
requested by destructor. Must be called only once. */
void registration(void);
/// Adds new service to list of handled services.
/** Service is described by it's InfoRegister object
which must be valid as long as this object is functional. */
bool addService(InfoRegister*, XMLNode);
/// Removes service from list of handled services.
bool removeService(InfoRegister*);
const std::string& id(void) { return id_; };
bool empty(void);
};
/// Singleton class for scanning configuration and storing
/// refernces to registration elements.
// TODO: Make it per chain, singleton solution reduces flexibility.
class InfoRegisterContainer {
private:
static InfoRegisterContainer* instance_;
//std::list<InfoRegister*> regs_;
std::list<InfoRegistrar*> regr_;
// Mutex protecting regr_ list
Glib::Mutex lock_;
InfoRegisterContainer(void);
InfoRegisterContainer(const InfoRegisterContainer&) {};
public:
~InfoRegisterContainer(void);
static InfoRegisterContainer& Instance(void);
/// Adds ISISes to list of handled services.
/** Supplied configuration document is scanned for InfoRegistrar
elements and those are turned into InfoRegistrar classes for
handling connection to ISIS service each. */
InfoRegistrar *addRegistrar(XMLNode doc);
/// Adds service to list of handled
/** This method must be called first time after last addRegistrar
was called - services will be only associated with ISISes
which are already added. Argument ids contains list of ISIS
identifiers to which service is associated. If ids is empty
then service is associated to all ISISes currently added.
If argument cfg is available and no ISISes are configured
then addRegistrars is called with cfg used as configuration
document. */
void addService(InfoRegister* reg,const std::list<std::string>& ids,XMLNode cfg = XMLNode());
// Disassociates service from all configured ISISes.
/** This method must be called if service being destroyed. */
void removeService(InfoRegister* reg);
};
} // namespace Arc
#endif
|