forked from lei.chen/myxce
- config_repl.c: add handle_repl_config_push — standby handler for OPCode_replConfigPush. Verifies SHA-256, saves blob to disk via conf_save_config, reloads via load_primary_config, ACKs primary. - config_repl.h: declare handle_repl_config_push. - cluster.c: dispatch OPCode_replConfigPush to handle_repl_config_push; populate c->myhost_info.name from myconf->name (ctrl-1/ctrl-2/ctrl-3) instead of the static "controller" placeholder. - ha.c: fix raft_cb_become_leader push_config_to_standbys call to pass real config bytes and tag read from disk (was NULL/0 — standbys got empty push and never saved config). - typemap.h: add raw_sha256/raw_bytes/raw_bytes_len fields to repl_config_push_req_t (mirrors upgrade_config_req_t pattern). - request.c: pre-extract List(UInt8) sha256/bytes from OPCode_replConfigPush before capn_free() in xce_decode(); free them in xce_free_request(). - helper.c: add all HA/replication opcode names to xce_request_op_name so "unknown opcode 30" becomes "replConfigPush" in logs. - cluster_def.h: add embedded myhost_info field to cluster_t struct. - ha.h: declare ha_start_primary_heartbeat; remove dead ha_find_and_connect_to_primary declaration.
146 lines
4.3 KiB
C
146 lines
4.3 KiB
C
#ifndef XCE_CLUSTER_DEF_H
|
|
#define XCE_CLUSTER_DEF_H
|
|
|
|
#include "config.h"
|
|
|
|
#include <pthread.h>
|
|
#include <rtti.h>
|
|
#include <stdint.h>
|
|
|
|
#include "delay.h"
|
|
#include "hook.h"
|
|
#include "htab.h"
|
|
#include "kvmgr.h"
|
|
#include "myconf.h"
|
|
#include "mylock.h"
|
|
#include "netio.h"
|
|
#include "persist.h"
|
|
#include "vtaskmgr.h"
|
|
|
|
/* ha.h forward-declares cluster_t; including it here is safe (no circular dep) */
|
|
#include "ha.h"
|
|
#include "xce/types.h"
|
|
#include "xlist.h"
|
|
#include "zarray.h"
|
|
|
|
#define N_CONTROLLER_MAX (16)
|
|
#define N_APISERVER_MAX (16)
|
|
|
|
enum {
|
|
XCE_CONTROLLER_HOOK_JOB = 0,
|
|
XCE_CONTROLLER_HOOK_WORKER,
|
|
XCE_CONTROLLER_HOOK_SCHEDULER,
|
|
XCE_CONTROLLER_HOOK_CLUSTER,
|
|
XCE_CONTROLLER_HOOK_RESOURCE,
|
|
XCE_CONTROLLER_HOOK_QUEUE,
|
|
XCE_CONTROLLER_HOOK_USERGROUP,
|
|
XCE_CONTROLLER_HOOK_HOSTGROUP,
|
|
XCE_CONTROLLER_HOOK_MAX /* keep this as the max */
|
|
};
|
|
|
|
enum {
|
|
HOOK_DETAIL_JOB_NEW = 0,
|
|
HOOK_DETAIL_JOB_START,
|
|
HOOK_DETAIL_JOB_EXIT,
|
|
HOOK_DETAIL_JOB_FAIL,
|
|
HOOK_DETAIL_JOB_UPDATE,
|
|
HOOK_DETAIL_JOB_CKPT,
|
|
HOOK_DETAIL_SETPREASON,
|
|
HOOK_DETAIL_CLRPREASON,
|
|
HOOK_DETAIL_WORKER_JOIN,
|
|
HOOK_DETAIL_WORKER_DEAD,
|
|
HOOK_DETAIL_WORKER_UPDATE,
|
|
HOOK_DETAIL_SCHEDULER_JOIN,
|
|
HOOK_DETAIL_SCHEDULER_DEAD,
|
|
HOOK_DETAIL_CLUSTER_INIT,
|
|
HOOK_DETAIL_CLUSTER_SHUTDOWN,
|
|
HOOK_DETAIL_RESOURCE_UPDATE,
|
|
HOOK_DETAIL_RESOURCE_LOC_UPDATE,
|
|
HOOK_DETAIL_QUEUE_UPDATE,
|
|
HOOK_DETAIL_USERGROUP_UPDATE,
|
|
HOOK_DETAIL_HOSTGROUP_UPDATE,
|
|
HOOK_DETAIL_JOB_RUSAGE_UPDATE,
|
|
HOOK_DETAIL_JOB_STOP,
|
|
HOOK_DETAIL_JOB_RESUME
|
|
};
|
|
|
|
#define XCE_NS_CONFIG (0)
|
|
#define XCE_NS_UGROUP (1)
|
|
#define XCE_NS_HGROUP (2)
|
|
#define XCE_NS_MAX (2)
|
|
|
|
typedef struct {
|
|
int role;
|
|
union {
|
|
int idx;
|
|
} u;
|
|
} ep_private_t;
|
|
|
|
typedef struct {
|
|
endpoint_t* ep;
|
|
} controller_t;
|
|
|
|
typedef struct {
|
|
} metrics_t;
|
|
|
|
typedef struct {
|
|
mylock_t lock;
|
|
endpoint_t* ep;
|
|
} scheduler_t;
|
|
|
|
typedef struct {
|
|
mylock_t lock;
|
|
char* name;
|
|
endpoint_t* ep;
|
|
} cluster_apiserver_t;
|
|
|
|
typedef struct cluster_s {
|
|
myconf_t* myconf;
|
|
xce_peerinfo_t* myhost; /* points at myhost_info once initialised */
|
|
xce_peerinfo_t myhost_info; /* storage; name set from myconf->name */
|
|
hooksys_t hooksys;
|
|
iomgr_t iomgr;
|
|
zarray_t endpoints;
|
|
endpoint_t ep;
|
|
zarray_t configs;
|
|
zarray_t sharedinst;
|
|
controller_t controllers[N_CONTROLLER_MAX];
|
|
cluster_apiserver_t apiservers[N_APISERVER_MAX];
|
|
int myidx;
|
|
int master;
|
|
int ncontrollers;
|
|
delaymgr_t delaymgr;
|
|
scheduler_t sched;
|
|
var jobmgr;
|
|
var resmgr;
|
|
var workermgr;
|
|
var qmgr;
|
|
var configmgr;
|
|
vtaskmgr_t vtaskmgr;
|
|
cbuf_t wbuf;
|
|
int running;
|
|
persist_t persist; /* Persistence module — P0-F */
|
|
ha_state_t ha; /* HA role management — P1-5 */
|
|
_Atomic int restart_requested; /* set by OP_upgradeConfig handler */
|
|
pthread_t heartbeat_listener_tid; /* pre-Phase-2 SSL listener thread */
|
|
_Atomic int heartbeat_listener_running;
|
|
_Atomic int lost_and_found_job_count; /* incremented during persist_recover() */
|
|
|
|
/* Performance-tuning parameters — initialized by init_controller_tunables()
|
|
* in cluster_init_phase1 so they are available before cluster_init_phase2.
|
|
* TODO: wire to cluster_config once config generation tool supports @13-@17. */
|
|
struct {
|
|
int jobmgr_nhash; /* hash slots for job table */
|
|
int jobmgr_delta; /* growth step for job table */
|
|
int workermgr_nhash; /* hash slots for worker table */
|
|
int workermgr_delta; /* growth step for worker table */
|
|
int qmgr_nhash; /* hash slots for queue table */
|
|
int qmgr_delta; /* growth step for queue table */
|
|
int resmgr_nhash; /* hash slots for resource table */
|
|
int resmgr_delta; /* growth step for resource table */
|
|
int resmgr_inst; /* growth step for shared-instance array */
|
|
int xstrings_nhash; /* hash slots for xstring table */
|
|
} tunables;
|
|
} cluster_t;
|
|
|
|
#endif /* XCE_CLUSTER_DEF_H */
|