Пример #1
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.
  }
Пример #2
0
  //////////////////////////////////////////////////////////////////////
  // inherited from the task interface
  void job_cpi_impl::sync_run (saga::impl::void_t & ret)
  {
    if ( state_ != saga::job::New )
    {
      SAGA_ADAPTOR_THROW ("can run only 'New' jobs", saga::IncorrectState);
    }

    jobid_   =  drmaa_->run_job(jd_);

    SAGA_LOG_INFO("Successfully submitted job: " + jobid_);;
  }
  // on destruction, umount all sshfs file systems - if keepalive is not set
  filesystem_adaptor::~filesystem_adaptor (void)
  {
    // release the sshfs shared_ptr.  On sshfs destruction, the file system
    // is umounted.
    //
    // Well, the above was theory.  In practice, the shared pointer do not seem
    // to get released even if we call mounted_.clear() here - other copies are
    // somewhere lingering.  So, we call umount directly (if keepalive is not
    // set), and rely on the session management to only call us when no
    // operations on the mounted filesystems are running anymore.
    
    // std::cout << " mounted_        dtor   :  " << this             << std::endl;
    // std::cout << " mounted_.size() dtor   :  " << mounted_.size () << std::endl;
    // std::cout << " tested__.size() dtor   :  " << tested__.size () << std::endl;

    if ( ini_.find ("keepalive") != ini_.end () &&
         ( ini_["keepalive"] == "yes"  ||
           ini_["keepalive"] == "true" )        )
    {
      // std::cout << " === keep stuff mounted" << std::endl;
      if ( mounted_.size () > 0 )
      {
        SAGA_LOG_INFO ("keeping sshfs filesystems mounted");
      }
    }
    else
    {
      std::map <std::string, TR1::shared_ptr <sshfs> > :: iterator begin = mounted_.begin ();
      std::map <std::string, TR1::shared_ptr <sshfs> > :: iterator end   = mounted_.end   ();
      std::map <std::string, TR1::shared_ptr <sshfs> > :: iterator it;

      for ( it = begin; it != end; it++ )
      {
        // std::cout << " umount for " << it->first << std::endl;
        (*it).second->umount ();
      }
    }
  }
Пример #4
0
  // destructor
  job_cpi_impl::~job_cpi_impl (void)
  {
	  //TODO: delete JT, drmaa_exit ?
	SAGA_LOG_INFO("releasing DRMAA singleton");
  }