1 /*****************************************************************************\
2  *  fed_mgr.h - functions for federations
3  *****************************************************************************
4  *  Copyright (C) 2016 SchedMD LLC.
5  *  Written by Brian Christiansen <brian@schedmd.com>
6  *
7  *  This file is part of Slurm, a resource management program.
8  *  For details, see <https://slurm.schedmd.com/>.
9  *  Please also read the included file: DISCLAIMER.
10  *
11  *  Slurm is free software; you can redistribute it and/or modify it under
12  *  the terms of the GNU General Public License as published by the Free
13  *  Software Foundation; either version 2 of the License, or (at your option)
14  *  any later version.
15  *
16  *  In addition, as a special exception, the copyright holders give permission
17  *  to link the code of portions of this program with the OpenSSL library under
18  *  certain conditions as described in each individual source file, and
19  *  distribute linked combinations including the two. You must obey the GNU
20  *  General Public License in all respects for all of the code used other than
21  *  OpenSSL. If you modify file(s) with this exception, you may extend this
22  *  exception to your version of the file(s), but you are not obligated to do
23  *  so. If you do not wish to do so, delete this exception statement from your
24  *  version.  If you delete this exception statement from all source files in
25  *  the program, then also delete it here.
26  *
27  *  Slurm is distributed in the hope that it will be useful, but WITHOUT ANY
28  *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
29  *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
30  *  details.
31  *
32  *  You should have received a copy of the GNU General Public License along
33  *  with Slurm; if not, write to the Free Software Foundation, Inc.,
34  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
35 \*****************************************************************************/
36 
37 #ifndef _SLURM_FED_MGR_H
38 #define _SLURM_FED_MGR_H
39 
40 #include "slurm/slurm.h"
41 #include "slurm/slurmdb.h"
42 
43 extern slurmdb_federation_rec_t *fed_mgr_fed_rec;
44 extern slurmdb_cluster_rec_t    *fed_mgr_cluster_rec;
45 
46 extern void      add_fed_job_info(job_record_t *job_ptr);
47 extern int       fed_mgr_add_sibling_conn(slurm_persist_conn_t *persist_conn,
48 					  char **out_buffer);
49 extern char     *fed_mgr_cluster_ids_to_names(uint64_t cluster_ids);
50 extern int       fed_mgr_fini(void);
51 extern uint32_t  fed_mgr_get_cluster_id(uint32_t id);
52 extern char     *fed_mgr_get_cluster_name(uint32_t id);
53 extern slurmdb_cluster_rec_t *fed_mgr_get_cluster_by_id(uint32_t id);
54 extern slurmdb_cluster_rec_t *fed_mgr_get_cluster_by_name(char *sib_name);
55 extern uint32_t  fed_mgr_get_job_id(uint32_t orig);
56 extern uint32_t  fed_mgr_get_local_id(uint32_t id);
57 extern int       fed_mgr_init(void *db_conn);
58 extern void      fed_mgr_init_depend_policy(void);
59 extern bool      fed_mgr_is_job_id_in_fed(uint32_t job_id);
60 extern int       fed_mgr_is_origin_job(job_record_t *job_ptr);
61 extern bool      fed_mgr_is_origin_job_id(uint32_t job_id);
62 extern bool      fed_mgr_is_singleton_satisfied(job_record_t *job_ptr,
63 						depend_spec_t *dep_ptr,
64 						bool set_cluster_bit);
65 extern bool      fed_mgr_is_tracker_only_job(job_record_t *job_ptr);
66 extern int       fed_mgr_job_allocate(slurm_msg_t *msg,
67 				      job_desc_msg_t *job_desc, bool alloc_only,
68 				      uid_t uid, uint16_t protocol_version,
69 				      uint32_t *job_id_ptr, int *alloc_code,
70 				      char **err_msg);
71 extern int       fed_mgr_job_cancel(job_record_t *job_ptr, uint16_t signal,
72 				    uint16_t flags, uid_t uid,
73 				    bool kill_viable);
74 extern int       fed_mgr_job_complete(job_record_t *job_ptr,
75 				      uint32_t return_code, time_t start_time);
76 extern bool      fed_mgr_job_is_locked(job_record_t *job_ptr);
77 extern bool      fed_mgr_job_is_self_owned(job_record_t *job_ptr);
78 extern int       fed_mgr_job_lock(job_record_t *job_ptr);
79 extern int       fed_mgr_job_lock_set(uint32_t job_id, uint32_t cluster_id);
80 extern int       fed_mgr_job_lock_unset(uint32_t job_id, uint32_t cluster_id);
81 extern bool      fed_mgr_job_started_on_sib(job_record_t *job_ptr);
82 extern int       fed_mgr_job_unlock(job_record_t *job_ptr);
83 extern int       fed_mgr_job_requeue(job_record_t *job_ptr);
84 extern int       fed_mgr_job_requeue_test(job_record_t *job_ptr,
85 					  uint32_t flags);
86 extern int       fed_mgr_job_revoke(job_record_t *job_ptr, bool job_complete,
87 				    uint32_t completed_state,
88 				    uint32_t exit_code, time_t start_time);
89 extern int       fed_mgr_job_revoke_sibs(job_record_t *job_ptr);
90 extern int       fed_mgr_job_start(job_record_t *job_ptr, time_t start_time);
91 extern int       fed_mgr_q_dep_msg(slurm_msg_t *msg);
92 extern int       fed_mgr_q_sib_msg(slurm_msg_t *sib_msg, uint32_t rpc_uid);
93 extern int       fed_mgr_q_update_origin_dep_msg(slurm_msg_t *msg);
94 extern int       fed_mgr_remove_active_sibling(uint32_t job_id, char *sib_name);
95 extern void      fed_mgr_remove_fed_job_info(uint32_t job_id);
96 extern void      fed_mgr_remove_remote_dependencies(job_record_t *job_ptr);
97 extern bool      fed_mgr_sibs_synced();
98 extern int       fed_mgr_state_save(char *state_save_location);
99 extern void      fed_mgr_test_remote_dependencies(void);
100 extern int       fed_mgr_state_save(char *state_save_location);
101 extern int       fed_mgr_submit_remote_dependencies(job_record_t *job_ptr,
102 						    bool send_all_sibs,
103 						    bool clear_dependencies);
104 extern int       fed_mgr_update_job(uint32_t job_id, job_desc_msg_t *job_specs,
105 				    uint64_t update_sibs, uid_t uid);
106 extern int       fed_mgr_update_job_clusters(job_record_t *job_ptr,
107 					     char *spec_clusters);
108 extern int       fed_mgr_update_job_cluster_features(job_record_t *job_ptr,
109 						     char *req_features);
110 extern int       fed_mgr_update_feds(slurmdb_update_object_t *update);
111 #endif /* _SLURM_FED_MGR_H */
112