/* * Copyright (C) 2008-2009 High Energy Accelerator Research Organization (KEK) * Copyright (C) 2008-2009 National Institute of Informatics in Japan. * Copyright (C) 2011 Ole Weidner, Louisiana State University * Copyright (C) 2011 Ole Weidner, Louisiana State University * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // Copyright (c) 2005-2007 Hartmut Kaiser // Copyright (c) 2005-2007 Andre Merzky (andre@merzky.net) // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE or copy at // http://www.boost.org/LICENSE_1_0.txt) // saga includes #include #include // saga adaptor includes #include #include // adaptor includes #include "torque_job_adaptor.hpp" #include "torque_job_service.hpp" #include "torque_job.hpp" SAGA_ADAPTOR_REGISTER (torque_job::adaptor); //////////////////////////////////////////////////////////////////////// namespace torque_job { // register function for the SAGA engine saga::impl::adaptor_selector::adaptor_info_list_type adaptor::adaptor_register (saga::impl::session * s) { // list of implemented cpi's saga::impl::adaptor_selector::adaptor_info_list_type list; // create empty preference list // these list should be filled with properties of the adaptor, // which can be used to select adaptors with specific preferences. // Example: // 'security' -> 'gsi' // 'logging' -> 'yes' // 'auditing' -> 'no' preference_type prefs; // create file adaptor infos (each adaptor instance gets its own uuid) // and add cpi_infos to list job_service_cpi_impl::register_cpi (list, prefs, adaptor_uuid_); job_cpi_impl::register_cpi (list, prefs, adaptor_uuid_); // and return list return (list); } //////////////////////////////////////////////////////////////////////// // initialize the adaptor using the preferences, return false to // cancel adaptor loading bool adaptor::init(saga::impl::session *session, saga::ini::ini const& glob_ini, saga::ini::ini const& adap_ini) { if (adap_ini.has_section("cli")) { saga::ini::section s = adap_ini.get_section("cli"); if (s.has_entry("binary_path")) { binary_path = s.get_entry("binary_path"); } else { SAGA_ADAPTOR_THROW_NO_CONTEXT("binary_path must be defined in .ini file.", saga::NoSuccess); } // disabled: 11/Apr/11 by Ole Weidner // this is not supported by all backends and leads to // errors and confusion! // /* if (s.has_section("description")) { saga::ini::section ss = s.get_section("description"); std::string v = ss.get_entry(sja::description_job_contact); saga::url mailto(v); if (mailto.get_scheme() != "mailto" || mailto.get_path().empty() // TODO mail address format check. ) { return false; } job_contact = v; }*/ } return true; } //////////////////////////////////////////////////////////////////////// // bool adaptor::register_job(pbsid_t pbsid, saga::job::description jd) { std::pair p = known_jobs_.insert(known_jobs_t::value_type(pbsid, jd)); return p.second; } //////////////////////////////////////////////////////////////////////// // bool adaptor::find_job(pbsid_t pbsid, saga::job::description& jd) { known_jobs_t::const_iterator i = find_if(known_jobs_.begin(), known_jobs_.end(), boost::bind(&helper::pbsid_match, _1, pbsid)); if(i == known_jobs_.end()) { return false; } jd = i->second; return true; } } // namespace torque_job ////////////////////////////////////////////////////////////////////////