DomNode DomNode::select_node(const DomString &xpath_expression) const { std::vector<DomNode> nodes = select_nodes(xpath_expression); if (nodes.empty()) throw Exception(string_format("Xpath did not match any node: %1", xpath_expression)); return nodes[0]; }
/* Try to start the job on any non-reserved nodes */ static int _start_job(struct job_record *job_ptr, bitstr_t *resv_bitmap) { int rc; bitstr_t *orig_exc_nodes = NULL; static uint32_t fail_jobid = 0; if (job_ptr->details->exc_node_bitmap) { orig_exc_nodes = bit_copy(job_ptr->details->exc_node_bitmap); bit_or(job_ptr->details->exc_node_bitmap, resv_bitmap); } else job_ptr->details->exc_node_bitmap = bit_copy(resv_bitmap); rc = select_nodes(job_ptr, false, NULL); if (job_ptr->details) { /* select_nodes() might cancel the job! */ FREE_NULL_BITMAP(job_ptr->details->exc_node_bitmap); job_ptr->details->exc_node_bitmap = orig_exc_nodes; } else FREE_NULL_BITMAP(orig_exc_nodes); if (rc == SLURM_SUCCESS) { /* job initiated */ last_job_update = time(NULL); info("backfill: Started JobId=%u on %s", job_ptr->job_id, job_ptr->nodes); if (job_ptr->batch_flag == 0) srun_allocate(job_ptr->job_id); else if ((job_ptr->details == NULL) || (job_ptr->details->prolog_running == 0)) launch_job(job_ptr); slurmctld_diag_stats.backfilled_jobs++; slurmctld_diag_stats.last_backfilled_jobs++; if (debug_flags & DEBUG_FLAG_BACKFILL) { info("backfill: Jobs backfilled since boot: %u", slurmctld_diag_stats.backfilled_jobs); } } else if ((job_ptr->job_id != fail_jobid) && (rc != ESLURM_ACCOUNTING_POLICY)) { char *node_list; bit_not(resv_bitmap); node_list = bitmap2node_name(resv_bitmap); /* This happens when a job has sharing disabled and * a selected node is still completing some job, * which should be a temporary situation. */ verbose("backfill: Failed to start JobId=%u on %s: %s", job_ptr->job_id, node_list, slurm_strerror(rc)); xfree(node_list); fail_jobid = job_ptr->job_id; } else { debug3("backfill: Failed to start JobId=%u: %s", job_ptr->job_id, slurm_strerror(rc)); } return rc; }
strings_t Client::list(std::string remote_directory) noexcept { auto clientImpl = GetImpl(this); bool is_existed = this->check(remote_directory); if (!is_existed) return strings_t(); bool is_directory = this->is_dir(remote_directory); if (!is_directory) return strings_t(); auto target_urn = Urn(clientImpl->webdav_root, true) + remote_directory; target_urn = Urn(target_urn.path(), true); Header header = { "Accept: */*", "Depth: 1" }; Data data = { 0, 0, 0 }; Request request(clientImpl->options()); auto url = clientImpl->webdav_hostname + target_urn.quote(request.handle); request.set(CURLOPT_CUSTOMREQUEST, "PROPFIND"); request.set(CURLOPT_URL, url.c_str()); request.set(CURLOPT_HTTPHEADER, (struct curl_slist *)header.handle); request.set(CURLOPT_HEADER, 0); request.set(CURLOPT_WRITEDATA, (size_t)&data); request.set(CURLOPT_WRITEFUNCTION, (size_t)Callback::Append::buffer); bool is_performed = request.perform(); if (!is_performed) return strings_t(); strings_t resources; pugi::xml_document document; document.load_buffer(data.buffer, (size_t)data.size); auto multistatus = document.select_single_node("d:multistatus").node(); auto responses = multistatus.select_nodes("d:response"); for(auto response : responses) { pugi::xml_node href = response.node().select_single_node("d:href").node(); std::string encode_file_name = href.first_child().value(); std::string resource_path = curl_unescape(encode_file_name.c_str(), (int) encode_file_name.length()); auto target_path = target_urn.path(); if (resource_path == target_path) continue; Urn resource_urn(resource_path); resources.push_back(resource_urn.name()); } return resources; }
dict_t Client::info(std::string remote_resource) noexcept { auto clientImpl = GetImpl(this); auto root_urn = Urn(clientImpl->webdav_root, true); auto target_urn = root_urn + remote_resource; Header header = { "Accept: */*", "Depth: 1" }; Data data = { 0, 0, 0 }; Request request(clientImpl->options()); auto url = clientImpl->webdav_hostname + target_urn.quote(request.handle); request.set(CURLOPT_CUSTOMREQUEST, "PROPFIND"); request.set(CURLOPT_URL, url.c_str()); request.set(CURLOPT_HTTPHEADER, (struct curl_slist *)header.handle); request.set(CURLOPT_WRITEDATA, (size_t)&data); request.set(CURLOPT_WRITEFUNCTION, (size_t)Callback::Append::buffer); bool is_performed = request.perform(); if (!is_performed) return dict_t(); pugi::xml_document document; document.load_buffer(data.buffer, (size_t)data.size); auto multistatus = document.select_single_node("d:multistatus").node(); auto responses = multistatus.select_nodes("d:response"); for (auto response : responses) { pugi::xml_node href = response.node().select_single_node("d:href").node(); std::string encode_file_name = href.first_child().value(); std::string resource_path = curl_unescape(encode_file_name.c_str(), (int)encode_file_name.length()); auto target_path = target_urn.path(); auto target_path_without_sep = std::string(target_path, 0, target_path.rfind("/")+1); auto resource_path_without_sep = std::string(resource_path, 0, resource_path.rfind("/")+1); if (resource_path_without_sep.compare(target_path_without_sep) == 0) { auto propstat = response.node().select_single_node("d:propstat").node(); auto prop = propstat.select_single_node("d:prop").node(); auto creation_date = prop.select_single_node("d:creationdate").node(); auto display_name = prop.select_single_node("d:displayname").node(); auto content_length = prop.select_single_node("d:getcontentlength").node(); auto modified_date = prop.select_single_node("d:getlastmodified").node(); auto resource_type = prop.select_single_node("d:resourcetype").node(); dict_t information = { {"created", creation_date.first_child().value()}, {"name", display_name.first_child().value()}, {"size", content_length.first_child().value()}, {"modified", modified_date.first_child().value()}, {"type", resource_type.first_child().name()} }; return information; } } return dict_t(); }