Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Private Member Functions | Private Attributes | Friends
Arc::InfoRegistrar Class Reference

Registration process associated with particular ISIS. More...

#include <InfoRegister.h>

Collaboration diagram for Arc::InfoRegistrar:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ~InfoRegistrar (void)
 operator bool (void)
bool operator! (void)
void registration (void)
 Performs registartion in a loop.
bool addService (InfoRegister *, XMLNode &)
 Adds new service to list of handled services.
bool removeService (InfoRegister *)
 Removes service from list of handled services.
const std::string & id (void)

Private Member Functions

 InfoRegistrar (XMLNode cfg)
 Constructor creates object according to configuration.
void initISIS (XMLNode cfg)
void removeISIS (ISIS_description isis)
void getISISList (ISIS_description isis)
ISIS_description getISIS (void)

Private Attributes

std::string id_
int retry
std::string key_
std::string cert_
std::string proxy_
std::string cadir_
std::string cafile_
std::list< Register_Info_Typereg_
Glib::Mutex lock_
Glib::Cond cond_exit_
Glib::Cond cond_exited_
Time creation_time
Period stretch_window
ISIS_description defaultBootstrapISIS
ISIS_description myISIS
bool myISISList_initialized
int originalISISCount
std::vector< ISIS_descriptionmyISISList

Friends

class InfoRegisterContainer

Detailed Description

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.

Definition at line 94 of file InfoRegister.h.


Constructor & Destructor Documentation

Constructor creates object according to configuration.

This object can only be created by InfoRegisterContainer which takes care of finding configuration elements in configuration document.

Definition at line 152 of file InfoRegister.cpp.

                                       :stretch_window("PT20S") {
    id_=(std::string)cfg["URL"];

    if ((bool)cfg["Retry"]) {
        if (!((std::string)cfg["Retry"]).empty()) {
            if(EOF == sscanf(((std::string)cfg["Retry"]).c_str(), "%d", &retry) || retry < 0)
            {
                logger_.msg(ERROR, "Configuration error. Retry: \"%s\" is not a valid value. Default value will be used.",(std::string)cfg["Retry"]);
                retry = 5;
            }
        } else retry = 5;
    } else retry = 5;

    logger_.msg(VERBOSE, "Retry: %d", retry);

    // Parsing security attributes
    key_ = (std::string)cfg["KeyPath"];
    cert_ = (std::string)cfg["CertificatePath"];
    proxy_ = (std::string)cfg["ProxyPath"];
    cadir_ = (std::string)cfg["CACertificatesDir"];
    cafile_ = (std::string)cfg["CACertificatePath"];

    logger_.msg(VERBOSE, "Key: %s, cert: %s", key_, cert_);

    initISIS(cfg);

    time_t rawtime;
    time ( &rawtime );  //current time
    gmtime ( &rawtime );
    Time ctime(rawtime);
    creation_time = ctime;
}

Here is the call graph for this function:

Definition at line 337 of file InfoRegister.cpp.

                                  {
    // Registering thread must be stopped before destructor succeeds
    Glib::Mutex::Lock lock(lock_);
    cond_exit_.signal();
    cond_exited_.wait(lock_);
}

Member Function Documentation

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.

Definition at line 185 of file InfoRegister.cpp.

                                                              {
    if ( bool(cfg["NoRegister"]) || !bool(cfg["InfoRegister"])){
       logger_.msg(VERBOSE, "The service won't be registered.");
       return true;
    }

    if (!(bool)cfg["InfoRegister"]["Period"] ) {
       logger_.msg(ERROR, "Configuration error. Missing mandatory \"Period\" element.");
       return false;
    }

    if (!(bool)cfg["InfoRegister"]["Endpoint"] ) {
       logger_.msg(ERROR, "Configuration error. Missing mandatory \"Endpoint\" element.");
       return false;
    }

    if (!(bool)cfg["InfoRegister"]["Expiration"] ) {
       logger_.msg(ERROR, "Configuration error. Missing mandatory \"Expiration\" element.");
       return false;
    }
    Glib::Mutex::Lock lock(lock_);
    for(std::list<Register_Info_Type>::iterator r = reg_.begin();
                                           r!=reg_.end();++r) {
        if(reg == r->p_register) {
            logger_.msg(VERBOSE, "Service was already registered to the InfoRegistrar connecting to infosys %s.", myISIS.url);
            return false;
        }
    }
    Register_Info_Type reg_info;
    reg_info.p_register = reg;

    std::string current_serviceid = reg->getServiceID();
    std::string current_expiration = reg->getExpiration();
    std::string current_endpoint = reg->getEndpoint();
    Period period(reg->getPeriod());
    for(XMLNode node = cfg["InfoRegister"]["Registrar"];(bool)node;++node) {
        if ( (std::string)node["URL"] == id_ ) {
            if (! ((std::string)node["Period"]).empty() ) {
                Period current_period((std::string)node["Period"]);
                period = current_period;
            }
            if (! ((std::string)node["ServiceID"]).empty() ) {
                current_serviceid = (std::string)node["ServiceID"];
            }
            if (! ((std::string)node["Endpoint"]).empty() ) {
                current_endpoint = (std::string)node["Endpoint"];
            }
            if (! ((std::string)node["Expiration"]).empty() ) {
                current_expiration = (std::string)node["Expiration"];
            }
       }
    }

    reg_info.period = period;
    reg_info.serviceid = current_serviceid;
    reg_info.expiration = current_expiration;
    reg_info.endpoint = current_endpoint;

    reg_info.next_registration = creation_time.GetTime();
    reg_.push_back(reg_info);
    logger_.msg(VERBOSE, "Service is successfully added to the InfoRegistrar connecting to infosys %s.", myISIS.url);
    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 154 of file BootstrapISIS.cpp.

                                                {
        logger_.msg(VERBOSE, "Get ISIS from list of ISIS handler");
        if (myISISList.size() == 0) {
            if ( myISIS.url == defaultBootstrapISIS.url ) {
                logger_.msg(WARNING, "There is no more ISIS available. The list of ISIS's is already empty.");

                // Set up default values for the further tries
                myISIS = defaultBootstrapISIS;
                originalISISCount = 1;
                myISISList.push_back(myISIS);

                // If there is no available, return an empty ISIS
                ISIS_description temporary_ISIS;
                temporary_ISIS.url = "";
                return temporary_ISIS;
            } else {
                // Try to receive the "original" bootsrap informations, if the BootstrapISIS is already available.
                getISISList(defaultBootstrapISIS);
                return getISIS();
            }
        }
        if (myISISList.size() == 1) {
            // If there is only one known ISIS than force the check of availability of new cloud members.
            getISISList(myISIS);
            return myISIS;
        }
        if (myISISList.size() <= originalISISCount / 2) {
            // Select a new random isis from the list
            std::srand(time(NULL));
            ISIS_description rndISIS = myISISList[std::rand() % myISISList.size()];

            // Add the neighbors of the newly selected ISIS to the list and set myISIS to one of them
            getISISList(rndISIS);
        }
        //And finally...
        return myISIS;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 73 of file BootstrapISIS.cpp.

                                                         {
        logger_.msg(VERBOSE, "getISISList from %s", isis.url);
        logger_.msg(VERBOSE, "Key %s, Cert: %s, CA: %s", isis.key, isis.cert, isis.cadir);
        // Try to get ISISList from the actual ISIS
        // Compose getISISList request
        NS query_ns;
        query_ns[""] = "http://www.nordugrid.org/schemas/isis/2007/06";

        // Try to get ISIS.getISISList()
        PayloadSOAP request(query_ns);
        request.NewChild("GetISISList");

        // Send message
        PayloadSOAP *response;
        MCCConfig mcc_cfg;
        mcc_cfg.AddPrivateKey(isis.key);
        mcc_cfg.AddCertificate(isis.cert);
        mcc_cfg.AddProxy(isis.proxy);
        if (!isis.cadir.empty()) {
            mcc_cfg.AddCADir(isis.cadir);
        }
        if (!isis.cafile.empty()) {
            mcc_cfg.AddCAFile(isis.cafile);
        }

        int retry_ = retry;
        int reconnection = 0;
        while ( retry_ >= 1 ) {
            ClientSOAP cli(mcc_cfg,isis.url,60);
            MCC_Status status = cli.process(&request, &response);
            retry_--;
            reconnection++;
            // If the given ISIS wasn't available try reconnect
            if (!status.isOk() || !response || !bool((*response)["GetISISListResponse"])) {
                logger_.msg(VERBOSE, "ISIS (%s) is not available or not valid response. (%d. reconnection)", isis.url, reconnection);
            } else {
                logger_.msg(VERBOSE, "Connection to the ISIS (%s) is success and get the list of ISIS.", isis.url);
                break;
            }
        }

        // If the given ISIS wasn't available remove it and return
        if ( retry_ == 0 ) {
            removeISIS(isis);
            return;
        }

        // Merge result with the orignal list of known ISIS's
        int i = 0;
        while((bool)(*response)["GetISISListResponse"]["EPR"][i]) {
            bool ISIS_found = false;
            for (std::vector<ISIS_description>::iterator it = myISISList.begin();
                it < myISISList.end() && ((*it).url != (std::string) (*response)["GetISISListResponse"]["EPR"][i]
                || (ISIS_found = true)); it++);
            if ( !ISIS_found ) {
                ISIS_description new_ISIS;
                new_ISIS.url = (std::string)(*response)["GetISISListResponse"]["EPR"][i];
                new_ISIS.key = defaultBootstrapISIS.key;
                new_ISIS.cert = defaultBootstrapISIS.cert;
                new_ISIS.proxy = defaultBootstrapISIS.proxy;
                new_ISIS.cadir = defaultBootstrapISIS.cadir;
                new_ISIS.cafile = defaultBootstrapISIS.cafile;
                myISISList.push_back(new_ISIS);
                logger_.msg(VERBOSE, "GetISISList add this (%s) ISIS into the list.", new_ISIS.url);
            }
            i++;
        }

        // Update the original number of ISIS's variable
        originalISISCount = myISISList.size();

        // Select a new random isis from the list
        std::srand(time(NULL));
        ISIS_description rndISIS = myISISList[std::rand() % myISISList.size()];

        logger_.msg(VERBOSE, "Chosen ISIS for communication: %s", rndISIS.url);
        myISIS = rndISIS;

        if (response) delete response;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

const std::string& Arc::InfoRegistrar::id ( void  ) [inline]

Definition at line 151 of file InfoRegister.h.

{ return id_; };
void Arc::InfoRegistrar::initISIS ( XMLNode  cfg) [private]

Definition at line 28 of file BootstrapISIS.cpp.

                                            {
        logger_.msg(DEBUG, "Initialize ISIS handler");
        // Process configuration
        defaultBootstrapISIS.url   = (std::string)cfg["URL"];
        if(defaultBootstrapISIS.url.empty()) {
            logger_.msg(ERROR, "Can't recognize URL: %s",(std::string)cfg["URL"]);
        } else {
            //logger_.msg(VERBOSE, "InfoRegistrar created for URL: %s",(std::string)cfg["URL"]);
        }
        defaultBootstrapISIS.key = (std::string)cfg["KeyPath"];
        defaultBootstrapISIS.cert = (std::string)cfg["CertificatePath"];
        defaultBootstrapISIS.proxy = (std::string)cfg["ProxyPath"];
        defaultBootstrapISIS.cadir = (std::string)cfg["CACertificatesDir"];
        defaultBootstrapISIS.cafile = (std::string)cfg["CACertificatePath"];
               
        // Set up default values
        myISIS = defaultBootstrapISIS;
        originalISISCount = 1;
        myISISList.push_back(myISIS);

        //getISISList(myISIS);
        myISISList_initialized = false;
        logger_.msg(DEBUG, "Initialize ISIS handler succeeded");
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Arc::InfoRegistrar::operator bool ( void  ) [inline]

Definition at line 139 of file InfoRegister.h.

{ return !myISIS.url.empty(); };
bool Arc::InfoRegistrar::operator! ( void  ) [inline]

Definition at line 140 of file InfoRegister.h.

{ return myISIS.url.empty(); };

Performs registartion in a loop.

Never exits unless there is a critical error or requested by destructor.

Definition at line 352 of file InfoRegister.cpp.

                                     {
    Glib::Mutex::Lock lock(lock_);
    CondExit cond(cond_exited_);
    ISIS_description usedISIS;
    std::string isis_name;
    if(!myISISList_initialized) getISISList(myISIS);
    myISISList_initialized = true;
    while(reg_.size() > 0) {
        usedISIS = getISIS();
        isis_name = usedISIS.url;

        logger_.msg(VERBOSE, "Registration starts: %s",isis_name);
        logger_.msg(VERBOSE, "reg_.size(): %d",reg_.size());

        if(usedISIS.url.empty()) {
            logger_.msg(WARNING, "Registrant has no proper URL specified. Registration end.");
            return;
        }
        NS reg_ns;
        reg_ns["glue2"] = GLUE2_D42_NAMESPACE;
        reg_ns["isis"] = ISIS_NAMESPACE;

        // Registration algorithm is stupid and straightforward.
        // This part has to be redone to fit P2P network od ISISes

        time_t current_time;
        time ( &current_time );  //current time
        tm * ptm;
        ptm = gmtime ( &current_time );
        Time min_reg_time(-1);
        XMLNode send_doc(reg_ns, "");

        std::string mon_prefix = (ptm->tm_mon+1 < 10)?"0":"";
        std::string day_prefix = (ptm->tm_mday < 10)?"0":"";
        std::string hour_prefix = (ptm->tm_hour < 10)?"0":"";
        std::string min_prefix = (ptm->tm_min < 10)?"0":"";
        std::string sec_prefix = (ptm->tm_sec < 10)?"0":"";
        std::stringstream out;
        out << ptm->tm_year+1900<<"-"<<mon_prefix<<ptm->tm_mon+1<<"-"<<day_prefix<<ptm->tm_mday<<"T";
        out << hour_prefix<<ptm->tm_hour<<":"<<min_prefix<<ptm->tm_min<<":"<<sec_prefix<<ptm->tm_sec;
        out << "+0000";

        for(std::list<Register_Info_Type>::iterator r = reg_.begin();
                                               r!=reg_.end();++r) {
            if ( (r->next_registration).GetTime() <= current_time + stretch_window.GetPeriod() ){
                logger_.msg(VERBOSE,"Create RegEntry XML element");
                Time current(current_time);
                // set the next registration time
                r->next_registration = current + r->period;

                XMLNode services_doc(reg_ns,"RegEntry");
                if(!((r->p_register)->getService())) continue;
                (r->p_register)->getService()->RegistrationCollector(services_doc);

                // Fill attributes from InfoRegister configuration
                if (!((bool)services_doc["SrcAdv"]["EPR"]["Address"]) && !((r->endpoint).empty()) ) {
                    if (!(bool)services_doc["SrcAdv"]) services_doc.NewChild("SrcAdv");
                    if (!(bool)services_doc["SrcAdv"]["EPR"]) services_doc["SrcAdv"].NewChild("EPR");
                    if (!(bool)services_doc["SrcAdv"]["EPR"]["Address"]) services_doc["SrcAdv"]["EPR"].NewChild("Address");
                    services_doc["SrcAdv"]["EPR"]["Address"] = r->endpoint;
                }

                if (!((bool)services_doc["MetaSrcAdv"]["ServiceID"]) && !((r->serviceid).empty()) ) {
                    if (!(bool)services_doc["MetaSrcAdv"]) services_doc.NewChild("MetaSrcAdv");
                    if (!(bool)services_doc["MetaSrcAdv"]["ServiceID"]) services_doc["MetaSrcAdv"].NewChild("ServiceID");
                    services_doc["MetaSrcAdv"]["ServiceID"] = r->serviceid;
                }

                if (!((bool)services_doc["MetaSrcAdv"]["Expiration"]) && !((r->expiration).empty()) ) {
                    if (!(bool)services_doc["MetaSrcAdv"]) services_doc.NewChild("MetaSrcAdv");
                    if (!(bool)services_doc["MetaSrcAdv"]["Expiration"]) services_doc["MetaSrcAdv"].NewChild("Expiration");
                    services_doc["MetaSrcAdv"]["Expiration"] = r->expiration;
                }

                // Possible completion of the services_doc
                if (!((bool)services_doc["MetaSrcAdv"]["ServiceID"]) && ((bool)services_doc["SrcAdv"]["EPR"]["Address"])) {
                    services_doc["MetaSrcAdv"].NewChild("ServiceID") = (std::string) services_doc["SrcAdv"]["EPR"]["Address"];
                    logger_.msg(VERBOSE, "ServiceID attribute calculated from Endpoint Reference");
                }
                if (!(bool)services_doc["MetaSrcAdv"]["GenTime"]) {
                    services_doc["MetaSrcAdv"].NewChild("GenTime") = out.str();
                    logger_.msg(VERBOSE, "Generation Time attribute calculated from current time");
                }

                // Store the sent ServiceID for the clear shutdown RemoveRegistration operation, if necessary
                if ( (r->serviceid_).empty() &&
                     (bool)services_doc["MetaSrcAdv"]["ServiceID"]) {
                    r->serviceid_ = (std::string) services_doc["MetaSrcAdv"]["ServiceID"];
                    logger_.msg(VERBOSE,"ServiceID stored: %s", r->serviceid_);
                }

                // TODO check the received registration information
                bool valid_services_doc = true;
                if (!(services_doc.Name() == "RegEntry")) {
                    logger_.msg(ERROR,"Missing service document provided by the service %s", r->serviceid_);
                    valid_services_doc = false;
                }

                if (!((bool) services_doc["MetaSrcAdv"]) ||
                    !((bool) services_doc["MetaSrcAdv"]["Expiration"])) {
                    logger_.msg(ERROR,"Missing MetaServiceAdvertisment or Expiration values provided by the service %s",
                                r->serviceid_);
                    valid_services_doc = false;
                }

                if (!((bool) services_doc["SrcAdv"]) ||
                    !((bool) services_doc["SrcAdv"]["Type"])) {
                    logger_.msg(ERROR,"Missing Type value provided by the service %s",
                                r->serviceid_);
                    valid_services_doc = false;
                }

                if (!((bool) services_doc["SrcAdv"]) ||
                    !((bool) services_doc["SrcAdv"]["EPR"]) ||
                    !((bool) services_doc["SrcAdv"]["EPR"]["Address"])) {
                    logger_.msg(ERROR,"Missing Endpoint Reference value provided by the service %s",
                                r->serviceid_);
                    valid_services_doc = false;
                }

                if (valid_services_doc) send_doc.NewChild(services_doc);
            }
            // conditioned minimum search
            if ( min_reg_time.GetTime() == -1 ){
                min_reg_time = r->next_registration;
            }
            else if ( r->next_registration < min_reg_time ) {
                min_reg_time = r->next_registration;
            }
        }

        // prepare for sending to ISIS
        if ( min_reg_time.GetTime() != -1 ) {
            logger_.msg(VERBOSE, "Registering to %s ISIS", isis_name);
            PayloadSOAP request(reg_ns);
            XMLNode op = request.NewChild("isis:Register");
            XMLNode header = op.NewChild("isis:Header");
            header.NewChild("MessageGenerationTime") = out.str();

            // create body
            for(XMLNode node = send_doc["RegEntry"];(bool)node;++node) {
                op.NewChild(node);
            }

            // send
            PayloadSOAP *response;
            MCCConfig mcc_cfg;
            if (!key_.empty())
                mcc_cfg.AddPrivateKey(key_);
            if (!cert_.empty())
                mcc_cfg.AddCertificate(cert_);
            if (!proxy_.empty())
                mcc_cfg.AddProxy(proxy_);
            if (!cadir_.empty())
                mcc_cfg.AddCADir(cadir_);
            if (!cafile_.empty())
                mcc_cfg.AddCAFile(cafile_);
            logger_.msg(VERBOSE, "Key: %s, Cert: %s, Proxy: %s, CADir: %s, CAFile", key_, cert_, proxy_, cadir_, cafile_);

            {std::string services_document;
             op.GetDoc(services_document, true);
             logger_.msg(VERBOSE, "Sent RegEntries: %s", services_document);
            }
            //logger_.msg(VERBOSE, "Call the ISIS.process method.");

            int retry_ = retry;
            while ( retry_ >= 1 ) {
                ClientSOAP cli(mcc_cfg,Arc::URL(usedISIS.url),60);
                MCC_Status status = cli.process(&request, &response);

                // multiple tries
                if ((!status.isOk()) ||
                    (!response) ||
                    (!bool((*response)["RegisterResponse"]))) {
                    logger_.msg(ERROR, "Error during registration to %s ISIS", isis_name);
                } else {
                    XMLNode fault = (*response)["Fault"];

                    if(!fault)  {
                        std::string response_string;
                        (*response)["RegisterResponse"].GetDoc(response_string, true);
                        logger_.msg(VERBOSE, "Response from the ISIS: %s", response_string);

                        logger_.msg(VERBOSE, "Successful registration to ISIS (%s)", isis_name);
                        break;
                    } else {
                        logger_.msg(VERBOSE, "Failed to register to ISIS (%s) - %s", isis_name, std::string(fault["Description"]));
                    }
                }
                retry_--;
                logger_.msg(VERBOSE, "Retry connecting to the ISIS (%s) %d. time(s).", isis_name, retry-retry_);
            }
            if (response) delete response;

            if ( retry_ == 0 )
                removeISIS(usedISIS);
        } // end of the connection with the ISIS

        // Thread sleeping
        long int period_ = min_reg_time.GetTime() - current_time;

        logger_.msg(VERBOSE, "Registration ends: %s",isis_name);
        logger_.msg(VERBOSE, "Waiting period is %d second(s).",period_);
        // The next line is removed for infinite operation
        // if(period_ <= 0) break; // One time registration
        Glib::TimeVal etime;
        etime.assign_current_time();
        etime.add_milliseconds(period_*1000L);
        // Sleep and exit if interrupted by request to exit
        if(cond_exit_.timed_wait(lock_,etime)) break;
        //sleep(period_);
    }
    logger_.msg(VERBOSE, "Registration exit: %s",isis_name);
}

Here is the call graph for this function:

Definition at line 53 of file BootstrapISIS.cpp.

                                                        {
        logger_.msg(VERBOSE, "Remove ISIS (%s) from list", isis.url);
        // Remove isis from myISISList
        for (std::vector<ISIS_description>::iterator it = myISISList.begin();
             it < myISISList.end() && ((*it).url != myISIS.url || myISISList.erase(it) == it); it++);

        // If the 'isis' is the currently used (myISIS) isis
        if ( isis.url == myISIS.url && myISISList.size() != 0 ) {
            // Select a new random isis from the list
            std::srand(time(NULL));
            ISIS_description rndISIS = myISISList[std::rand() % myISISList.size()];

            // Add the neighbors of the newly selected ISIS to the list and set myISIS to one of them
            getISISList(rndISIS);
        }

        // Check if there is enough ISIS's left
        getISIS();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Removes service from list of handled services.

Definition at line 249 of file InfoRegister.cpp.

                                                   {
    Glib::Mutex::Lock lock(lock_);
    for(std::list<Register_Info_Type>::iterator r = reg_.begin();
                                           r!=reg_.end();++r) {
        if(reg == r->p_register) {

            NS reg_ns;
            reg_ns["glue2"] = GLUE2_D42_NAMESPACE;
            reg_ns["isis"] = ISIS_NAMESPACE;

            time_t current_time;
            time ( &current_time );  //current time
            tm * ptm;
            ptm = gmtime ( &current_time );

            std::string mon_prefix = (ptm->tm_mon+1 < 10)?"0":"";
            std::string day_prefix = (ptm->tm_mday < 10)?"0":"";
            std::string hour_prefix = (ptm->tm_hour < 10)?"0":"";
            std::string min_prefix = (ptm->tm_min < 10)?"0":"";
            std::string sec_prefix = (ptm->tm_sec < 10)?"0":"";
            std::stringstream out;
            out << ptm->tm_year+1900<<"-"<<mon_prefix<<ptm->tm_mon+1<<"-"<<day_prefix<<ptm->tm_mday<<"T";
            out << hour_prefix<<ptm->tm_hour<<":"<<min_prefix<<ptm->tm_min<<":"<<sec_prefix<<ptm->tm_sec;
            out << "+0000";

            PayloadSOAP request(reg_ns);
            XMLNode op = request.NewChild("isis:RemoveRegistrations");
            op.NewChild("ServiceID") = r->serviceid_;
            op.NewChild("MessageGenerationTime") = out.str();

            // send
            PayloadSOAP *response;
            MCCConfig mcc_cfg;
            ISIS_description usedISIS = getISIS();
            if (!key_.empty())
                mcc_cfg.AddPrivateKey(key_);
            if (!cert_.empty())
                mcc_cfg.AddCertificate(cert_);
            if (!proxy_.empty())
                mcc_cfg.AddProxy(proxy_);
            if (!cadir_.empty())
                mcc_cfg.AddCADir(cadir_);
            if (!cafile_.empty())
                mcc_cfg.AddCAFile(cafile_);
            logger_.msg(VERBOSE, "Key: %s, Cert: %s, Proxy: %s, CADir: %s CAPath", key_, cert_, proxy_, cadir_, cafile_);

            int retry_ = retry;
            while ( retry_ >= 1 ){
                ClientSOAP cli(mcc_cfg,Arc::URL(usedISIS.url),60);
                MCC_Status status = cli.process(&request, &response);

                std::string response_string;
                (*response).GetDoc(response_string, true);
                logger_.msg(VERBOSE, "Response from the ISIS: %s", response_string);

                if ((!status.isOk()) ||
                    (!response)) {
                    logger_.msg(ERROR, "Failed to remove registration from %s ISIS )", usedISIS.url);
                } else {
                    if(!(bool)(*response)["RemoveRegistrationResponseElement"])  {
                        logger_.msg(VERBOSE, "Successful removed registration from ISIS (%s)", usedISIS.url);
                        break;
                    } else {
                        int i=0;
                        while ((bool)(*response)["RemoveRegistrationResponseElement"][i]) {
                            logger_.msg(VERBOSE, "Failed to remove registration from ISIS (%s) - %s",
                                    usedISIS.url, std::string((*response)["RemoveRegistrationResponseElement"][i]["Fault"]));
                            i++;
                        }
                    }
                }
                retry_--;
                logger_.msg(VERBOSE, "Retry connecting to the ISIS (%s) %d. time(s).", usedISIS.url, retry-retry_);
            }

            if (retry_ == 0 )
               logger_.msg(VERBOSE, "ISIS (%s) is not available.", usedISIS.url);

            reg_.erase(r);

            logger_.msg(VERBOSE, "Service removed from InfoRegistrar connecting to infosys %s.", myISIS.url);
            return true;
        };
    };
    logger_.msg(VERBOSE, "Unregistred Service can not be removed.");
    return false;
}

Here is the call graph for this function:


Friends And Related Function Documentation

friend class InfoRegisterContainer [friend]

Definition at line 95 of file InfoRegister.h.


Member Data Documentation

std::string Arc::InfoRegistrar::cadir_ [private]

Definition at line 109 of file InfoRegister.h.

std::string Arc::InfoRegistrar::cafile_ [private]

Definition at line 110 of file InfoRegister.h.

std::string Arc::InfoRegistrar::cert_ [private]

Definition at line 107 of file InfoRegister.h.

Glib::Cond Arc::InfoRegistrar::cond_exit_ [private]

Definition at line 116 of file InfoRegister.h.

Glib::Cond Arc::InfoRegistrar::cond_exited_ [private]

Definition at line 118 of file InfoRegister.h.

Definition at line 120 of file InfoRegister.h.

Definition at line 125 of file InfoRegister.h.

std::string Arc::InfoRegistrar::id_ [private]

Definition at line 103 of file InfoRegister.h.

std::string Arc::InfoRegistrar::key_ [private]

Definition at line 106 of file InfoRegister.h.

Glib::Mutex Arc::InfoRegistrar::lock_ [private]

Definition at line 114 of file InfoRegister.h.

Definition at line 126 of file InfoRegister.h.

Definition at line 129 of file InfoRegister.h.

Definition at line 127 of file InfoRegister.h.

Definition at line 128 of file InfoRegister.h.

std::string Arc::InfoRegistrar::proxy_ [private]

Definition at line 108 of file InfoRegister.h.

Definition at line 112 of file InfoRegister.h.

Definition at line 104 of file InfoRegister.h.

Definition at line 122 of file InfoRegister.h.


The documentation for this class was generated from the following files: