return 0;
}
+int ctdb_ctrl_get_db_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t db_id, uint32_t *priority)
+{
+ int ret;
+ int32_t res;
+ TDB_DATA data;
+ TALLOC_CTX *tmp_ctx = talloc_new(NULL);
+
+ data.dptr = (uint8_t*)&db_id;
+ data.dsize = sizeof(db_id);
+
+ ret = ctdb_control(ctdb, destnode, 0,
+ CTDB_CONTROL_GET_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;
+ }
+
+ if (priority) {
+ *priority = res;
+ }
+
+ talloc_free(tmp_ctx);
+
+ 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 ctdb_ctrl_get_db_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t db_id, uint32_t *priority);
#endif
CTDB_CONTROL_TRAVERSE_KILL = 97,
CTDB_CONTROL_RECD_RECLOCK_LATENCY = 98,
CTDB_CONTROL_SET_DB_PRIORITY = 111,
+ CTDB_CONTROL_GET_DB_PRIORITY = 112,
};
/*
CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_db_priority));
return ctdb_control_set_db_priority(ctdb, indata);
+ case CTDB_CONTROL_GET_DB_PRIORITY: {
+ uint32_t db_id;
+ struct ctdb_db_context *ctdb_db;
+
+ CHECK_CONTROL_DATA_SIZE(sizeof(db_id));
+ db_id = *(uint32_t *)indata.dptr;
+ ctdb_db = find_ctdb_db(ctdb, db_id);
+ if (ctdb_db == NULL) return -1;
+ return ctdb_db->priority;
+ }
+
default:
DEBUG(DEBUG_CRIT,(__location__ " Unknown CTDB control opcode %u\n", opcode));
return -1;
return 0;
}
+/*
+ get db priority
+ */
+static int control_getdbprio(struct ctdb_context *ctdb, int argc, const char **argv)
+{
+ uint32_t db_id, priority;
+ int ret;
+
+ if (argc < 1) {
+ usage();
+ }
+
+ db_id = strtoul(argv[0], NULL, 0);
+
+ ret = ctdb_ctrl_get_db_priority(ctdb, TIMELIMIT(), options.pnn, db_id, &priority);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR,("Unable to get db prio\n"));
+ return -1;
+ }
+
+ DEBUG(DEBUG_ERR,("Priority:%u\n", priority));
+
+ return 0;
+}
+
/*
run an eventscript on a node
*/
{ "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>"},
+ { "getdbprio", control_getdbprio, false, false, "Get DB priority", "<dbid>"},
};
/*