Back to index

nordugrid-arc-nox  1.1.0~rc6
Classes | Functions | Variables
ISIS Namespace Reference

Classes

class  Service_data
class  Thread_data
class  Soft_State
class  Neighbor_Container
class  ISIService
class  ISISSecAttr

Functions

std::string Current_Time (time_t parameter_time=time(NULL))
static void message_send_thread (void *arg)
void SendToNeighbors (Arc::XMLNode &node, std::vector< Arc::ISIS_description > neighbors_, Arc::Logger &logger_, Arc::ISIS_description isis_desc, Neighbor_Container *not_availables_neighbors, std::string endpoint, std::multimap< std::string, Arc::ISIS_description > &hash_table)
static void soft_state_thread (void *data)
static bool IsOwnID (Arc::XMLNode node, const std::string &path, const std::string &id)
static Arc::Pluginget_service (Arc::PluginArgument *arg)

Variables

static Arc::Logger thread_logger (Arc::Logger::rootLogger,"ISIS_Thread")

Class Documentation

class ISIS::Service_data

Definition at line 89 of file isis.cpp.

Collaboration diagram for ISIS::Service_data:
Class Members
string peerID
ISIS_description service
string serviceID
class ISIS::Thread_data

Definition at line 96 of file isis.cpp.

Collaboration diagram for ISIS::Thread_data:
Class Members
vector< ISIS_description > isis_list
XMLNode node
Neighbor_Container * not_av_neighbors
class ISIS::Soft_State

Definition at line 212 of file isis.cpp.

Collaboration diagram for ISIS::Soft_State:
Class Members
bool * available_provider_
XmlDatabase * database
string function
ISIService * isis
bool * kill_thread
bool * neighbors_update_needed_
vector< ISIS_description > * providers
string query
int sleep
int * threads_count

Function Documentation

std::string ISIS::Current_Time ( time_t  parameter_time = time(NULL))

Definition at line 64 of file isis.cpp.

                                                            {

    time_t rawtime;
    if ( parameter_time == time(NULL) ){
        time ( &rawtime );    //current time
    } else {
        rawtime = parameter_time;
    }
    tm * ptm;
    ptm = gmtime ( &rawtime );

    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;
    if ( parameter_time == time(NULL) ){
        out << ptm->tm_year+1900<<"-"<<mon_prefix<<ptm->tm_mon+1<<"-"<<day_prefix<<ptm->tm_mday<<"T"<<hour_prefix<<ptm->tm_hour<<":"<<min_prefix<<ptm->tm_min<<":"<<sec_prefix<<ptm->tm_sec<<"+0000";
    } else {
        out << ptm->tm_year+1900<<mon_prefix<<ptm->tm_mon+1<<day_prefix<<ptm->tm_mday<<"."<<hour_prefix<<ptm->tm_hour<<min_prefix<<ptm->tm_min<<sec_prefix<<ptm->tm_sec;
    }
    return out.str();
}

Here is the caller graph for this function:

static Arc::Plugin* ISIS::get_service ( Arc::PluginArgument arg) [static]

Definition at line 982 of file isis.cpp.

                                                          {
        Arc::ServicePluginArgument* srvarg = arg?dynamic_cast<Arc::ServicePluginArgument*>(arg):NULL;
        if(!srvarg) return NULL;
        return new ISIService((Arc::Config*)(*srvarg));
    }
static bool ISIS::IsOwnID ( Arc::XMLNode  node,
const std::string &  path,
const std::string &  id 
) [static]

Definition at line 823 of file isis.cpp.

                                                                                   {
        if(id.empty()) return false;
        Arc::XMLNodeList ids = node.Path(path);
        if(ids.empty()) return false;
        if(ids.size() > 1) return false;
        std::string node_id = *(ids.begin());
        if(node_id != id) return false;
        return true;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static void ISIS::message_send_thread ( void *  arg) [static]

Definition at line 103 of file isis.cpp.

                                           {
    Arc::AutoPointer<ISIS::Thread_data> data((ISIS::Thread_data*)arg);
    if(!data) {
        if (arg) delete (ISIS::Thread_data*)arg;
        return;
    }
    if ( data->isis_list.empty() ) {
       thread_logger.msg(Arc::ERROR, "Empty URL list add to the thread.");
       return;
    }
    if ( !bool(((ISIS::Thread_data *)data)->node) ) {
       thread_logger.msg(Arc::ERROR, "Empty message add to the thread.");
       return;
    }
    Neighbor_Container* not_availables_neighbors  = data->not_av_neighbors;

    for (unsigned int i=0; i<data->isis_list.size(); i++ ){
        std::string url = data->isis_list[i].url;
        //Send SOAP message to the neighbor.
        Arc::PayloadSOAP *response = NULL;
        Arc::MCCConfig mcc_cfg;
        mcc_cfg.AddPrivateKey(((ISIS::Thread_data *)data)->isis_list[i].key);
        mcc_cfg.AddCertificate(((ISIS::Thread_data *)data)->isis_list[i].cert);
        mcc_cfg.AddProxy(((ISIS::Thread_data *)data)->isis_list[i].proxy);
        mcc_cfg.AddCADir(((ISIS::Thread_data *)data)->isis_list[i].cadir);
        mcc_cfg.AddCAFile(((ISIS::Thread_data *)data)->isis_list[i].cafile);

        Arc::ClientSOAP client_entry(mcc_cfg, url, 60);

        // Create and send "Register/RemoveRegistrations" request
        Arc::NS message_ns;
        //message_ns[""] = "http://www.nordugrid.org/schemas/isis/2007/06";
        message_ns["wsa"] = "http://www.w3.org/2005/08/addressing";
        message_ns["glue2"] = GLUE2_D42_NAMESPACE;
        message_ns["isis"] = ISIS_NAMESPACE;
        Arc::PayloadSOAP req(message_ns);

        req.NewChild(((ISIS::Thread_data *)data)->node);
        Arc::MCC_Status status;
        thread_logger.msg(Arc::VERBOSE, "Sending \"Register/RemoveRegistrations\" message to %s and waiting for the response.", url );
        status= client_entry.process(&req,&response);

        if ( (!status.isOk()) || (!response) || (response->IsFault()) ) {
           if ( !not_availables_neighbors->contains(url) && i == 0)
              not_availables_neighbors->push(url);
           thread_logger.msg(Arc::ERROR, "Status (%s): Failed", url);
        } else {
           // Remove url just in case - implemented in the Neighbor_Container class
           not_availables_neighbors->remove(url);
           thread_logger.msg(Arc::VERBOSE, "Status (%s): OK",url );
           if(response) delete response;
           break;
        };
        if(response) delete response;
    }
    return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ISIS::SendToNeighbors ( Arc::XMLNode node,
std::vector< Arc::ISIS_description neighbors_,
Arc::Logger logger_,
Arc::ISIS_description  isis_desc,
Neighbor_Container *  not_availables_neighbors,
std::string  endpoint,
std::multimap< std::string, Arc::ISIS_description > &  hash_table 
)

Definition at line 161 of file isis.cpp.

                                                                                                 {
    if ( !bool(node) ) {
       logger_.msg(Arc::WARNING, "Empty message won't be send to the neighbors.");
       return;
    }

    for (std::vector<Arc::ISIS_description>::iterator it = neighbors_.begin(); it < neighbors_.end(); it++) {
        if ( isis_desc.url != (*it).url ) {
           //thread creation
           ISIS::Thread_data* data;
           // This data will be freed in the message_send_thread function after successful or
           // unsuccessful termination.
           data = new ISIS::Thread_data;
           std::string url = (*it).url;
           std::string next_url = endpoint;
           if ( it+1 < neighbors_.end() ) {
               next_url = (*(it+1)).url;
           }

           // find neighbor's place in the hash table
           std::multimap<std::string,Arc::ISIS_description>::const_iterator it_hash;
           for (it_hash = hash_table.begin(); it_hash!=hash_table.end(); it_hash++) {
               if ( (it_hash->second).url == url )
                   break;
           }
           // add isis into the list until the next neighbor
           while ( (it_hash->second).url != next_url ){
               if ( 0 < data->isis_list.size() && (it_hash->second).url == url)
                   break;
               Arc::ISIS_description isis(it_hash->second);
               isis.key = isis_desc.key;
               isis.cert = isis_desc.cert;
               isis.proxy = isis_desc.proxy;
               isis.cadir = isis_desc.cadir;
               isis.cafile = isis_desc.cafile;
               data->isis_list.push_back(isis);
               it_hash++;
               if ( it_hash == hash_table.end() )
                   it_hash = hash_table.begin();
           }
           node.New(data->node);
           data->not_av_neighbors = not_availables_neighbors;
           Arc::CreateThreadFunction(&message_send_thread, data);
        }
    }

    return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void ISIS::soft_state_thread ( void *  data) [static]

Definition at line 227 of file isis.cpp.

                                          {
    Arc::AutoPointer<Soft_State> self((Soft_State *)data);
    if(!self) {
        if (data) delete (Soft_State *)data;
        return;
    }
    std::string method = self->function;
    unsigned int sleep_time = self->sleep; //seconds
    std::string query_string = self->query;
    Arc::XmlDatabase* db_ = self->database;
    bool* available_providers = self->available_provider_;
    std::vector<Arc::ISIS_description>* providers_ = self->providers;

    (*(self->threads_count))++;

    // "sleep_period" is the time, when the thread wakes up and checks the "KillTread" variable's value and then sleep away.
    unsigned int sleep_period = 60;
    while (true){
        thread_logger.msg(Arc::VERBOSE, "%s: %d seconds to the next database cleaning.", method, sleep_time);

        // "sleep_time" is comminuted to some little period
        unsigned int tmp_sleep_time = sleep_time;
        while ( tmp_sleep_time > 0 ) {
            // Whether ISIS's destructor called or not
            if( *(self->kill_thread) ) {
               (*(self->threads_count))--;
               thread_logger.msg(Arc::VERBOSE, "%s: Soft-State thread is finished.", method);
               return;
            }

            if( tmp_sleep_time > sleep_period ) {
               tmp_sleep_time = tmp_sleep_time - sleep_period;
               sleep(sleep_period);
            }
            else {
               sleep(tmp_sleep_time);
               tmp_sleep_time = 0;
            }
        }

        time_t rawtime;
        time ( &rawtime );    //current time

        if ( method == "ETValid") {
            // Current this is the Query
            //"//RegEntry/MetaSrcAdv[count(Expiration)=1 and number(translate(GenTime,'TZ:-','.')) < number('20090420.082903')]/ServiceID"

            // This Query is better, but it is not working now
            //"//RegEntry/MetaSrcAdv[count(Expiration)=1 and ( (years-from-duration(Expiration)*1000) +(months-from-duration(Expiration)*10) + (days-from-duration(Expiration)) + (hours-from-duration(Expiration)*0.01) + (minutes-from-duration(Expiration)*0.0001) + (seconds-from-duration(Expiration)*0.000001) + number(translate(GenTime,'TZ:-','.'))) < number('20090420.132903')]/ServiceID"
            std::string valid_query("//RegEntry/MetaSrcAdv[count(Expiration)=1 and number(translate(GenTime,'TZ:-+','.')) < number(translate('");
            valid_query += Current_Time(rawtime);
            valid_query += "','TZ:-+','.'))]/ServiceID";

            query_string = valid_query;
        }
        if ( method == "ETRemove") {
            std::string remove_query("/RegEntry/MetaSrcAdv[count(Expiration)=0 and number(translate(GenTime,'TZ:-+','.')) < number(translate('");
            remove_query += Current_Time(rawtime);
            remove_query += "','TZ:-+','.'))]/ServiceID";
            query_string = remove_query;
        }

        // Database cleaning
        std::vector<std::string> service_ids;

        // Query from the database
        std::map<std::string, Arc::XMLNodeList> result;
        db_->queryAll(query_string, result);
        std::map<std::string, Arc::XMLNodeList>::iterator it;
        for (it = result.begin(); it != result.end(); it++) {
            if (it->second.size() == 0 || it->first == "" ) {
                continue;
            }

            // If add better XPath for ETValid, then this block can be remove
            if ( method == "ETValid" ){
               Arc::XMLNode data;
               //The next function calling is db_->get(ServiceID, RegistrationEntry);
               db_->get(it->first, data);
               Arc::Time gentime( (std::string)data["MetaSrcAdv"]["GenTime"]);
               Arc::Period expiration((std::string)data["MetaSrcAdv"]["Expiration"]);

               Arc::Time current_time(Current_Time());

                if ( (gentime.GetTime() + 2* expiration.GetPeriod()) > current_time.GetTime() ) {
                    // Now the information is not expired
                    continue;
                }

                std::string type = (std::string)data["SrcAdv"]["Type"];
                if ( type == "org.nordugrid.infosys.isis") {
                    *(self->neighbors_update_needed_) = true;
                    std::string isis_url = (std::string)data["SrcAdv"]["EPR"]["Address"];
                    // the remove service is my provider or not
                    for (unsigned int j=0; j < providers_->size(); j++ ) {
                        if ( (*providers_)[j].url == isis_url ) {
                            *available_providers = false;
                            break;
                        }
                    }
                }

            }
            // end of the block

            service_ids.push_back(it->first);
        }

        // Remove all old datas
        std::vector<std::string>::iterator id_it;
        for (id_it = service_ids.begin(); id_it != service_ids.end(); id_it++) {
            db_->del(*id_it);
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation