cluster_t embeds commit_engine_t; init in cluster_init_phase2 after the vtaskmgr guard (idempotence-guarded — phase2 can run twice), wiring repl_set_commit_engine + ha.repl back-pointer before any standby can register; fini after iomgr/vtask shutdown. persist_wal_sync_append passes written_lsn; engine-wired path drops -ENODEV and the committed_lsn store (engine owns advancement); LSN-0 first-entry routes to legacy per the accepted interim. p2 -ENODEV pin updated to the Req 6.3 contract. 34/34 + 6/6 green through honest delegation; census exactly at the 3 validated baselines; production binary links.
148 lines
4.4 KiB
C
148 lines
4.4 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 "commit.h"
|
|
#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 */
|
|
commit_engine_t commit; /* Per-entry commit engine — ha-commit-engine 5.3 */
|
|
_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 */
|