Ejemplo n.º 1
0
omii_gridsam_job_service::omii_gridsam_job_service (proxy* p, 
        cpi_info const& info, saga::ini::ini const& glob_ini, 
        saga::ini::ini const& adap_ini, TR1::shared_ptr<saga::adaptor> adaptor)
    : base_cpi (p, info, adaptor, cpi::Noflags)
{
    // check if we can handle this request
    instance_data data(this);
    std::string rm(data->rm_.get_url());

    saga::url rm_url(rm);
    std::string scheme(rm_url.get_scheme());
    if (scheme.empty() || 
        (scheme != "gridsam" && scheme != "any" && scheme != "https"))
    {
      SAGA_OSSTREAM strm;
      strm << "Could not initialize job service for [" << data->rm_ << "]. " 
           << "Only any://, gridsam:// and https:// schemes are supported.";

        SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), 
            saga::adaptors::AdaptorDeclined);
    }
    if (rm_url.get_host().empty())
    {
      SAGA_OSSTREAM strm;
      strm << "Could not initialize job service for [" << data->rm_ << "]. " 
           << "No hostname given.";

        SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), 
            saga::BadParameter);
    }

    // use the rm as provided
    endpoint_ = rm;
}
Ejemplo n.º 2
0
/*
 * constructor
 */
rpc_cpi_impl::rpc_cpi_impl (proxy * p,
                            cpi_info       const & info,
                            saga::ini::ini const & glob_ini,
                            saga::ini::ini const & adap_ini,
                            TR1::shared_ptr <saga::adaptor> adaptor)
    :   base_cpi (p, info, adaptor, cpi::Noflags)
{
    grpc_error_t err;

    std::cout << "Initializing" << std::endl;

    /* gridrpc initialization */
    err = grpc_initialize(NULL);
    if (err != GRPC_NO_ERROR && err != GRPC_ALREADY_INITIALIZED) {
        SAGA_ADAPTOR_THROW ("Failed to invoke grpc_initialize().", saga::NoSuccess);
    }

    std::cout << "Creating an RPC handle" << std::endl;

    instance_data data (this);
    saga::url fn_url(data->funcname_);

    int port = fn_url.get_port();
    if (port == -1) {
        err = grpc_function_handle_init(&rpc_handle,
                                        const_cast<char *>(fn_url.get_host().c_str()),
                                        const_cast<char *>(fn_url.get_path().substr(1).c_str()));
    } else {
        if (port > 0 && port < 65536) {
            char host_plus_port[fn_url.get_host().length() + 8];
            sprintf(host_plus_port, "%s:%d", fn_url.get_host().c_str(), fn_url.get_port());
            err = grpc_function_handle_init(&rpc_handle,
                                            host_plus_port,
                                            const_cast<char *>(fn_url.get_path().substr(1).c_str()));
        } else {
            SAGA_ADAPTOR_THROW ("Invalid port number.", saga::NoSuccess);
        }
    }

    if (err != GRPC_NO_ERROR) {
        SAGA_ADAPTOR_THROW ("Failed to invoke grpc_function_handle_init().", saga::NoSuccess);
    }

    /* FIXEME: should support the following url conversion.
      host name
      host name:port number
      host name:port number/jobmanager
      host name/jobmanager
      host name:/jobmanager
      host name::subject
      host name:port number:subject
      host name/jobmanager:subject
      host name:/jobmanager:subject
      host name:port number/jobmanager:subject
    */

}
Ejemplo n.º 3
0
  // constructor
  job_cpi_impl::job_cpi_impl (proxy                           * p, 
                              cpi_info const                  & info,
                              saga::ini::ini const            & glob_ini, 
                              saga::ini::ini const            & adap_ini,
                              TR1::shared_ptr <saga::adaptor>   adaptor)
    : base_cpi (p, info, adaptor, cpi::Noflags)
    , session_ (p->get_session ())
    , state_   (saga::job::New)
  {
    instance_data     idata (this);
    adaptor_data_type adata (this);

    saga::url contact_url = idata->rm_;

    SAGA_LOG_INFO("url: " + contact_url.get_url ());

    // check if URL is usable
    if ( ! contact_url.get_scheme ().empty ()    &&
           contact_url.get_scheme () != "drmaa"    &&
           contact_url.get_scheme () != "any"    )
    {
      SAGA_OSSTREAM strm;
      strm << "Could not initialize job service for [" << contact_url << "]. "
           << "Only these schemas are supported: any://, drmaa://, or none.";

      SAGA_ADAPTOR_THROW (SAGA_OSSTREAM_GETSTRING (strm), 
                          saga::adaptors::AdaptorDeclined);
    }

    // TODO: load drmaa && drmaa_init
    SAGA_LOG_INFO("getting DRMAA singleton");

    drmaa_ = &(saga::adaptors::utils::get_singleton<psnc_drmaa::drmaa>());

    if ( idata->init_from_jobid_ )
    {
      jobid_ = idata->jobid_;
      state_ = drmaa_->get_state(jobid_);
    }
    else
    {
      // init from job description
      jd_ = idata->jd_;
      state_ = saga::job::New;
      
      if ( ! jd_.attribute_exists (sja::description_executable) )
      {
        SAGA_ADAPTOR_THROW ("job description misses executable", saga::BadParameter);
      }
    }

    // FIXME: register metrics etc.
  }
Ejemplo n.º 4
0
 void dir_cpi_impl::saga_hdfs_delete(hdfsFS fs, const char* path)
 {
    #if HADOOP_VERSION < 002100 
      if ( hdfsDelete(fs, path) != 0 )
      {
          SAGA_ADAPTOR_THROW("Could not delete", saga::NoSuccess);
      }
    #else
      if ( hdfsDelete(fs, path, true) != 0 )
      {   
          SAGA_ADAPTOR_THROW("Could not delete", saga::NoSuccess);
      }  
    #endif
 }
Ejemplo n.º 5
0
  void dir_cpi_impl::sync_remove (saga::impl::void_t & ret, 
                                  saga::url            url, 
                                  int                  flags)
  {
     instance_data idata (this);
     saga::url dir_url(idata->location_);
     boost::filesystem::path src_location (idata->location_.get_path(), boost::filesystem::native);
     // complete paths
     boost::filesystem::path src_path (url.get_path(), boost::filesystem::native);
     if ( ! src_path.has_root_path () )
         src_location /= src_path;
     else
         src_location = src_path;

     bool is_src_dir = false;
     if(hdfsExists(fs_, src_location.string().c_str()) != 0)
     {
         SAGA_ADAPTOR_THROW("directory::remove: Can't remove directory: "
           "Does not exist", saga::DoesNotExist);
     }
     else
     {
        hdfsFileInfo *info;
        info = hdfsGetPathInfo(fs_, src_location.string().c_str());
        if(info == NULL)
        {
           SAGA_ADAPTOR_THROW("file_cpi_impl::init failed",
                            saga::NoSuccess);
        }
        if(info->mKind == kObjectKindDirectory)
           is_src_dir = true;
        else
           is_src_dir = false;
        hdfsFreeFileInfo(info, 1);

     }
     if (is_src_dir) {
         if (saga::name_space::Recursive != flags)
         {
             SAGA_ADAPTOR_THROW("directory::remove: Can't remove directory. "
                 "Please use recursive mode!", saga::BadParameter);
         }
         else {
            saga_hdfs_delete(fs_, src_location.string().c_str()); 
         }
     }
     else {
        saga_hdfs_delete(fs_, src_location.string().c_str()); 
     }
  }
Ejemplo n.º 6
0
    ///////////////////////////////////////////////////////////////////////////////
    // logical_file functions
    void logical_file_cpi_impl::sync_list_locations(std::vector<saga::url>& locations)
    {

//        SAGA_ADAPTOR_THROW ("Not implemented! ", saga::NotImplemented);
    	SAGA_LOG_DEBUG("file sync_list_locations()");
    	check_state();

    	instance_data   instanceData (this);
        std::string rns_path = instanceData->location_.get_path();

    	std::vector <std::string> results;
    	std::vector <saga::url>   list_tmp;

    	try {
    		results = rns_lfile.list_locations(rns_path);
    		list_tmp.insert(list_tmp.begin(), results.begin(), results.end());
//    		for(unsigned int i=0; i< list_tmp.size(); i++){
//    			list_tmp[i].set_scheme(irods_url_org.get_scheme());
//    		}
    		locations = list_tmp;
    	}
    	catch (boost::system::system_error const& e) {
    		SAGA_ADAPTOR_THROW(e.what(), saga::NoSuccess);
    	}


    }
Ejemplo n.º 7
0
///////////////////////////////////////////////////////////////////////////////
// namespace_directory functions
///////////////////////////////////////////////////////////////////////////////
//
void logical_directory_cpi_impl::sync_change_dir(saga::impl::void_t&, saga::url name)
{

//    SAGA_ADAPTOR_THROW ("Not implemented! sync_change_dir", saga::NotImplemented);
	SAGA_LOG_DEBUG("dir, sync_change_dir()");
	check_state();

	saga::url irods_url_org;
	this->sync_get_cwd(irods_url_org); // to get rid of the /. at the end...

	std::string irods_path;
	boost::filesystem::path i_path(name.get_path());
	if (i_path.has_root_path()){
		irods_path = name.get_path();
	}
	else {
		irods_path = irods_url_org.get_path() + "/" + name.get_path();
	}

	try {
//		std::cout<< "irods_path    :" << irods_path << std::endl;
		irdsdir.change_dir(irods_path);
	}
	catch (boost::system::system_error const& e) {
		SAGA_ADAPTOR_THROW(e.what(), saga::NoSuccess);
	}

}
Ejemplo n.º 8
0
  file_cpi_impl::file_cpi_impl (proxy                * p, 
                                cpi_info       const & info,
                                saga::ini::ini const & glob_ini,
                                saga::ini::ini const & adap_ini,
                                boost::shared_ptr <saga::adaptor> adaptor)

      : file_cpi (p, info, adaptor, cpi::Noflags)
  {        
    adaptor_data_t       adata (this);
    file_instance_data_t idata (this);

    //SAGA_ADAPTOR_THROW ("Not Implemented (yet), but soon will be!", saga::NotImplemented);
  
    saga::url location(idata->location_);
    std::string host(location.get_host());
    std::string scheme(location.get_scheme());

    // make sure that we only allow globusonline:// URLs

    if (scheme != "globusonline")
    {
       SAGA_OSSTREAM strm;
       strm << "Could not initialize file object for [" << idata->location_ << "]. "
            << "Only globusonline:// schemes are supported.";
       SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), saga::adaptors::AdaptorDeclined);
    }
  }
Ejemplo n.º 9
0
 void dir_cpi_impl::sync_open_dir (saga::filesystem::directory & ret, 
                                   saga::url                     name_to_open,
                                   int                           openmode) {
     instance_data idata (this);
     bool exists = false; 
     bool is_dir = false; 
    
     saga::url file_url(idata->location_);
     boost::filesystem::path name (name_to_open.get_path(), boost::filesystem::native);
     boost::filesystem::path path (file_url.get_path(), boost::filesystem::native);
    
     if ( ! name.has_root_path () ) {
       path /= name;
       file_url.set_path(path.string());
     }
     else {
       path = name;
       file_url = saga::url(name.string());
     }
     if(fs_->Exists(path.string().c_str())) {
        exists = true;
        //Check to see if it is a directory
        if(fs_->IsDirectory(path.string().c_str()))
           is_dir = true;
     }
     if ( exists && !is_dir) {
       SAGA_ADAPTOR_THROW(path.string() + ": doesn't refer to a file object",
         saga::DoesNotExist);
     }
    
     ret = saga::filesystem::directory (this->get_proxy()->get_session(), file_url.get_url(),
                              openmode);
     //SAGA_ADAPTOR_THROW ("Not Implemented", saga::NotImplemented);
 }
Ejemplo n.º 10
0
 void file_cpi_impl::sync_permissions_deny  (saga::impl::void_t & ret, 
                                             std::string          id, 
                                             int                  perm, 
                                             int                  flags)
 {
   SAGA_ADAPTOR_THROW ("Not Implemented", saga::NotImplemented);
 }
Ejemplo n.º 11
0
 void 
   advertdirectory_cpi_impl::sync_find_attributes (std::vector <std::string> & ret, 
                                                   std::string                 pattern)
 {
   std::cerr << "==========!sync_find_attributes!=======" << std::endl;
   SAGA_ADAPTOR_THROW ("Not Implemented", saga::NotImplemented);
 }
Ejemplo n.º 12
0
 void 
   advertdirectory_cpi_impl::sync_get_vector_attribute (std::vector <std::string> & ret, 
                                                        std::string                 key)
 {
   std::cerr << "==========!sync_get_vector_attribute!========" << std::endl;
   SAGA_ADAPTOR_THROW ("Not Implemented", saga::NotImplemented);
 }
Ejemplo n.º 13
0
 void 
   advertdirectory_cpi_impl::sync_set_vector_attribute (saga::impl::void_t              & ret, 
                                                        std::string                 key, 
                                                        std::vector <std::string>   val)
 {
     SAGA_ADAPTOR_THROW ("Not Implemented", saga::NotImplemented);
 }
Ejemplo n.º 14
0
 void 
   advertdirectory_cpi_impl::sync_attribute_is_vector (bool        & ret, 
                                                       std::string   key)
 {
   std::cerr << "===========!sync_attribute_is_vector!=========" << std::endl;
   SAGA_ADAPTOR_THROW ("Not Implemented", saga::NotImplemented);
 }
Ejemplo n.º 15
0
void logical_directory_cpi_impl::sync_exists(bool& exists, saga::url url)
{
//    SAGA_ADAPTOR_THROW ("Not implemented! sync_exists", saga::NotImplemented);
	SAGA_LOG_DEBUG("sync_exists()");
	check_state();

	saga::url irods_url_org;
	this->sync_get_cwd(irods_url_org); // to get rid of the /. at the end...
	std::string irods_path = irods_url_org.get_path();

	std::string check_path;
	boost::filesystem::path i_path(url.get_path());
	if (i_path.has_root_path()){
		check_path = url.get_path();
	}
	else {
		check_path = irods_url_org.get_path() + "/" + url.get_path();
	}

	// to get rid of the / at the end the check_path
	if (check_path.substr(check_path.size()-1,1) == "/"){
		check_path.erase(check_path.size()-1);
//		std::cout << "check_path.erased:" << check_path << std::endl;
	}

	try {
		exists  = irdsdir.exists(check_path);
                std::string str_buf = "check_path:" + check_path;
                SAGA_LOG_CRITICAL(str_buf.c_str());
	}
	catch (boost::system::system_error const& e) {
		SAGA_ADAPTOR_THROW(e.what(), saga::NoSuccess);
	}
}
Ejemplo n.º 16
0
void logical_directory_cpi_impl::sync_list(std::vector<saga::url>& list,
                                           std::string pattern, int flags)
{
//    SAGA_ADAPTOR_THROW ("Not implemented! sync_list", saga::NotImplemented);
	SAGA_LOG_DEBUG("sync_list()");
	check_state();

	saga::url irods_url_org;
	this->sync_get_cwd(irods_url_org); // to get rid of the /. at the end...
	std::string irods_path = irods_url_org.get_path();

	std::vector <std::string> results;
	std::vector <saga::url>   list_tmp;

	try {
		results  = irdsdir.list(irods_path, pattern, flags);
		list_tmp.insert(list_tmp.begin(), results.begin(), results.end());
		for(unsigned int i=0; i< list_tmp.size(); i++){
			list_tmp[i].set_scheme(irods_url_org.get_scheme());
//			list_tmp[i].set_host(irods_url_org.get_host());
		}
		list = list_tmp;
	}
	catch (boost::system::system_error const& e) {
		SAGA_ADAPTOR_THROW(e.what(), saga::NoSuccess);
	}
}
Ejemplo n.º 17
0
void logical_directory_cpi_impl::sync_get_name(saga::url& name)
{
//    SAGA_ADAPTOR_THROW ("Not implemented! sync_get_name", saga::NotImplemented);
	SAGA_LOG_DEBUG("sync_get_name()");
	check_state();

	saga::url u;
    this->sync_get_cwd(u); // to get rid of the /. at the end...

    boost::filesystem::path path(u.get_path());
    std::string path_str(u.get_path());

    if (path.empty()) {
	  SAGA_ADAPTOR_THROW ("path is empty.", saga::NoSuccess);
	}

    if( !path.has_root_path() )
        path = boost::filesystem::path("/"+path_str);

    path_str = path.string();
    std::string::size_type idx = path_str.rfind("/");

    ( idx == 0 ) ? path = boost::filesystem::path(path_str.substr(1, path_str.size()-1)) :
    path = boost::filesystem::path(path_str.substr(idx+1, path_str.size()-1));

    if( path.string().size() == 0 ) path = boost::filesystem::path("/");

    name = path.string();
}
Ejemplo n.º 18
0
 void 
   advertdirectory_cpi_impl::sync_remove (saga::impl::void_t & ret, 
                                          int            flags)
 {
   std::cerr << "=============!remove!===============" << std::endl;
   SAGA_ADAPTOR_THROW ("Not Implemented", saga::NotImplemented);
 }
Ejemplo n.º 19
0
 void dir_cpi_impl::sync_link (saga::impl::void_t & ret, 
                               saga::url            source, 
                               saga::url            url, 
                               int                  flags)
 {
   SAGA_ADAPTOR_THROW ("Not Implemented", saga::NotImplemented);
 }
Ejemplo n.º 20
0
 void 
   advertdirectory_cpi_impl::sync_close (saga::impl::void_t & ret, 
                                         double         timeout)
 {
   std::cerr << "=============!close!===============" << std::endl;
   SAGA_ADAPTOR_THROW ("Not Implemented", saga::NotImplemented);
 }
Ejemplo n.º 21
0
 void dir_cpi_impl::sync_move_wildcard (saga::impl::void_t & ret, 
                                        std::string          source, 
                                        saga::url            dest, 
                                        int                  flags)
 {
   SAGA_ADAPTOR_THROW ("Not Implemented", saga::NotImplemented);
 }
Ejemplo n.º 22
0
 void 
   advertdirectory_cpi_impl::sync_is_link (bool      & ret, 
                                           saga::url   target)
 {
   std::cerr << "=============!is_link!===============" << std::endl;
   SAGA_ADAPTOR_THROW ("Not Implemented", saga::NotImplemented);
 }
Ejemplo n.º 23
0
 void dir_cpi_impl::sync_is_dir (bool    & is_dir, 
                                 saga::url url)
 {
    instance_data idata (this);
    is_dir = false;
   
    saga::url dir_url(idata->location_);
    boost::filesystem::path name (url.get_path(), boost::filesystem::native);
    boost::filesystem::path path (idata->location_.get_path(), boost::filesystem::native);
   
    if ( ! name.has_root_path () )
      path /= name;
    else
      path = name;
   
    if(hdfsExists(fs_, path.string().c_str()) == 0)
    {
       //Check to see if it is a directory
       hdfsFileInfo *info;
       instance_data idata(this);
    
       info = hdfsGetPathInfo(fs_, path.string().c_str());
       if(info == NULL)
       {
          SAGA_ADAPTOR_THROW("file_cpi_impl::init failed",
                           saga::NoSuccess);
       }
       if(info->mKind == kObjectKindDirectory)
          is_dir = true;
       hdfsFreeFileInfo(info, 1);
     }
 }
Ejemplo n.º 24
0
 void 
   advertdirectory_cpi_impl::sync_read_link (saga::url & url, 
                                             saga::url   target)
 {
   std::cerr << "=============!read_link!===============" << std::endl;
   SAGA_ADAPTOR_THROW ("Not Implemented", saga::NotImplemented);
 }
Ejemplo n.º 25
0
 ///////////////////////////////////////////////////////////////////////////////
 //  constructor
 cpr_checkpoint_cpi_impl::cpr_checkpoint_cpi_impl (proxy* p, 
                                                   cpi_info       const & info,
                                                   saga::ini::ini const & glob_ini, 
                                                   saga::ini::ini const & adap_ini,
                                                   TR1::shared_ptr<saga::adaptor> adaptor)
   :   base_cpi (p, info, adaptor, cpi::Noflags),
   thrd_          (NULL), 
   cond_          (NULL),
   thread_alive_  (false), 
   cancel_thread_ (false)
 {
     //check whether Migol has been initialized 
   std::string guid("");
   mutex_type::scoped_lock l(mtx_);
   {//scoped lock
         adaptor_data_t d(this);
         guid = d->migol_guid;
         if(guid==""){
             {
                 SAGA_ADAPTOR_THROW (std::string ("Migol infrastructure not correctly initialized."), 
                                     saga::IncorrectState);
             }
         }
         std::cout << "cpr_checkpoint_cpi_impl ctor: " << guid << std::endl;
   }
     
    // first usage of this adaptor
   instance_data data (this);
   saga::url cpr_url (data->location_);
   std::cout<< "checkpoint url: "<< cpr_url <<std::endl;
   //No action since Migol does not support checkpoint containers
     
 }
Ejemplo n.º 26
0
 void cpr_checkpoint_cpi_impl::sync_open_file_idx (saga::filesystem::file & ret,
                                               int                      idx, 
                                               int flags)
 {
     SAGA_ADAPTOR_THROW ("Not implemented.", 
                         saga::NotImplemented);
 }
Ejemplo n.º 27
0
  void
    job_service_cpi_impl::sync_list (std::vector <std::string> & ret)
  {
    std::vector<std::string> backend_list;

    std::ostringstream os;
	std::string bin_pth;
	adaptor_data_type ad(this);
    bin_pth = ad->get_binary_path();

    cli::qstat qstat(bin_pth);
    if (qstat.execute(backend_list, os) == false) {
      std::string msg = os.str();
      //saga::error e = cli::em.check(msg);
      //SAGA_ADAPTOR_THROW(msg, e);
      SAGA_ADAPTOR_THROW(msg, saga::NoSuccess);
    }
#if 0
    std::vector<std::string> adaptor_list;
    //instance_data data(this);
    transform(adaptor_list.begin(), adaptor_list.end(), adaptor_list.begin(),
	      boost::bind<std::string>(&helper::jobid_converter::convert_jobid,
				       &jobid_converter, _1));
#endif
    transform(backend_list.begin(), backend_list.end(), backend_list.begin(),

     boost::bind(&helper::jobid_converter::convert_jobid,
                 &jobid_converter, _1));


    ret = backend_list;
  }
Ejemplo n.º 28
0
 void 
   advertdirectory_cpi_impl::sync_change_dir (saga::impl::void_t & ret, 
                                              saga::url      dir)
 {
   std::cerr << "=============!change_dir!===============" << std::endl;
   SAGA_ADAPTOR_THROW ("Not Implemented", saga::NotImplemented);
 }
Ejemplo n.º 29
0
 void 
   advertdirectory_cpi_impl::sync_get_entry (saga::url    & entry, 
                                             std::size_t    idx)
 {
   std::cerr << "=============!get_entry!===============" << std::endl;
   SAGA_ADAPTOR_THROW ("Not Implemented", saga::NotImplemented);
 }
Ejemplo n.º 30
0
 void cpr_checkpoint_cpi_impl::sync_attribute_is_writable (bool      & ret, 
                                                           std::string key)
 {
       SAGA_ADAPTOR_THROW ("Not implemented.", 
                           saga::NotImplemented);
   //ret = lf_->attribute_is_writable (key);
 }