myxce/src/worker/include/controller_connector.h
2025-11-24 15:53:31 +08:00

62 lines
2 KiB
C

#ifndef CONTROL_CONNECTOR_H
#define CONTROL_CONNECTOR_H
#include "thread_pool.h"
#include "xcecd_utils.h"
#include "client.h"
#include "xcectx.h"
#include "controller.capnp.h"
typedef struct {
xce_client_config_t* conf;
endpoint_t ep;
xce_ctx_t ctx;
} api_ctx_t;
typedef struct controller_connector_ctx_s {
void *thread_pool;
void *process_manager;
char *remote_host;
char *virtual_name;
void **worker_list;
int remote_port;
int join_interval;
bool running;
} controller_connector_ctx_t;
extern controller_connector_ctx_t *cc_ctx;
typedef struct {
int (*job_finished)(xcecd_job_t *job);
int (*job_stopped)(uint64_t jobid);
int (*job_resumed)(uint64_t jobid);
int (*job_start_error)(uint64_t jobid);
int (*job_status_error)(uint64_t jobid);
int (*job_ckpted)(uint64_t jobid, int status, const char *info);
int (*job_remote_start)(uint64_t jobid, const char *hostname, const char *command);
bool (*reply_startjob)(xcecd_job_t *job);
} cc_callbacks_t;
extern void xcecd_process_command(void* arg);
int start_controller_connector_thread(task_func_t function, void* arg);
int xcecd_join_cluster(hostattrs_t* attrs);
bool controller_connector_start(void);
bool xcecd_reply_startjob(xcecd_job_t *job);
int xcecd_job_finished(xcecd_job_t *job);
int xcecd_job_stopped(uint64_t jobid);
int xcecd_job_resumed(uint64_t jobid);
int checking_connection();
int xcecd_job_start_error(uint64_t jobid);
int xcecd_job_status_error(uint64_t jobid);
int xcecd_job_ckpted(uint64_t jobid, int status, const char *info);
int xcecd_job_remote_start(uint64_t jobid,
const char *hostname,
const char *command);
const cc_callbacks_t* get_cc_callbacks(void);
int xcecd_task_fail(uint64_t jobid, int clientidx,
int taskidx, int code);
int xcecd_jobpost_done(uint64_t jobid);
int xcecd_notify_job_fail(uint64_t jobid,
int stage,
int code);
#endif // CONTROL_CONNECTOR_H