database priorities will be used to control in which order databases are locked during recovery in.
return 0;
}
+
+int ctdb_ctrl_set_db_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, struct ctdb_db_priority *db_prio)
+{
+ int ret;
+ int32_t res;
+ TDB_DATA data;
+ TALLOC_CTX *tmp_ctx = talloc_new(NULL);
+
+ data.dptr = (uint8_t*)db_prio;
+ data.dsize = sizeof(*db_prio);
+
+ ret = ctdb_control(ctdb, destnode, 0,
+ CTDB_CONTROL_SET_DB_PRIORITY, 0, data,
+ tmp_ctx, NULL, &res, &timeout, NULL);
+ if (ret != 0 || res != 0) {
+ DEBUG(DEBUG_ERR,(__location__ " ctdb_control for set_db_priority failed\n"));
+ talloc_free(tmp_ctx);
+ return -1;
+ }
+
+ talloc_free(tmp_ctx);
+
+ return 0;
+}
+
TALLOC_CTX *mem_ctx, struct ctdb_monitoring_wire **script_status);
+
+struct ctdb_db_priority {
+ uint32_t db_id;
+ uint32_t priority;
+};
+
+int ctdb_ctrl_set_db_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, struct ctdb_db_priority *db_prio);
+
#endif
struct ctdb_db_context *next, *prev;
struct ctdb_context *ctdb;
uint32_t db_id;
+ uint32_t priority;
bool persistent;
const char *db_name;
const char *db_path;
CTDB_CONTROL_GET_EVENT_SCRIPT_STATUS = 96,
CTDB_CONTROL_TRAVERSE_KILL = 97,
CTDB_CONTROL_RECD_RECLOCK_LATENCY = 98,
+ CTDB_CONTROL_SET_DB_PRIORITY = 111,
};
/*
int ctdb_vacuum_init(struct ctdb_db_context *ctdb_db);
+int32_t ctdb_control_set_db_priority(struct ctdb_context *ctdb, TDB_DATA indata);
+
#endif
CHECK_CONTROL_DATA_SIZE(sizeof(double));
ctdb_reclock_latency(ctdb, "recd reclock", &ctdb->statistics.reclock.recd, *((double *)indata.dptr));
return 0;
+
+ case CTDB_CONTROL_SET_DB_PRIORITY:
+ CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_db_priority));
+ return ctdb_control_set_db_priority(ctdb, indata);
+
default:
DEBUG(DEBUG_CRIT,(__location__ " Unknown CTDB control opcode %u\n", opcode));
return -1;
{
struct ctdb_db_context *ctdb_db;
for (ctdb_db=ctdb->db_list;ctdb_db;ctdb_db=ctdb_db->next) {
+ DEBUG(DEBUG_INFO,("locking database 0x%08x priority:%u %s\n", ctdb_db->db_id, ctdb_db->priority, ctdb_db->db_name));
if (tdb_lockall(ctdb_db->ltdb->tdb) != 0) {
return -1;
}
ctdb_db = talloc_zero(ctdb, struct ctdb_db_context);
CTDB_NO_MEMORY(ctdb, ctdb_db);
+ ctdb_db->priority = 1;
ctdb_db->ctdb = ctdb;
ctdb_db->db_name = talloc_strdup(ctdb_db, db_name);
CTDB_NO_MEMORY(ctdb, ctdb_db->db_name);
return 0;
}
+int32_t ctdb_control_set_db_priority(struct ctdb_context *ctdb, TDB_DATA indata)
+{
+ struct ctdb_db_priority *db_prio = (struct ctdb_db_priority *)indata.dptr;
+ struct ctdb_db_context *ctdb_db;
+
+ ctdb_db = find_ctdb_db(ctdb, db_prio->db_id);
+ if (!ctdb_db) {
+ DEBUG(DEBUG_ERR,("Unknown db_id 0x%x in ctdb_set_db_priority\n", db_prio->db_id));
+ return -1;
+ }
+
+ ctdb_db->priority = db_prio->priority;
+ DEBUG(DEBUG_INFO,("Setting DB priority to %u for db 0x%08x\n", db_prio->priority, db_prio->db_id));
+
+ return 0;
+}
+
+
return 0;
}
+/*
+ set db priority
+ */
+static int control_setdbprio(struct ctdb_context *ctdb, int argc, const char **argv)
+{
+ struct ctdb_db_priority db_prio;
+ int ret;
+
+ if (argc < 2) {
+ usage();
+ }
+
+ db_prio.db_id = strtoul(argv[0], NULL, 0);
+ db_prio.priority = strtoul(argv[1], NULL, 0);
+
+ ret = ctdb_ctrl_set_db_priority(ctdb, TIMELIMIT(), options.pnn, &db_prio);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR,("Unable to set db prio\n"));
+ return -1;
+ }
+
+ return 0;
+}
+
/*
run an eventscript on a node
*/
{ "scriptstatus", control_scriptstatus, false, false, "show the status of the monitoring scripts"},
{ "natgwlist", control_natgwlist, false, false, "show the nodes belonging to this natgw configuration"},
{ "xpnn", control_xpnn, true, true, "find the pnn of the local node without talking to the daemon (unreliable)" },
+ { "setdbprio", control_setdbprio, false, false, "Set DB priority", "<dbid> <prio:1-3>"},
};
/*