Refactor local scheduler to remove worker indices. (#245)

* Refactor local scheduler to remove worker indices.

* Change scheduling state enum to int in all function signatures.

* Bug fix, don't use pointers into a resizable array.

* Remove total_num_workers.

* Fix tests.
This commit is contained in:
Robert Nishihara
2017-02-05 14:52:28 -08:00
committed by Philipp Moritz
parent ca254b8689
commit 2d1c980ad7
12 changed files with 135 additions and 120 deletions
+2 -2
View File
@@ -785,7 +785,7 @@ void redis_task_table_add_task(table_callback_data *callback_data) {
task *task = callback_data->data;
task_id task_id = task_task_id(task);
db_client_id local_scheduler_id = task_local_scheduler(task);
scheduling_state state = task_state(task);
int state = task_state(task);
task_spec *spec = task_task_spec(task);
CHECKM(task != NULL, "NULL task passed to redis_task_table_add_task.");
@@ -821,7 +821,7 @@ void redis_task_table_update(table_callback_data *callback_data) {
task *task = callback_data->data;
task_id task_id = task_task_id(task);
db_client_id local_scheduler_id = task_local_scheduler(task);
scheduling_state state = task_state(task);
int state = task_state(task);
CHECKM(task != NULL, "NULL task passed to redis_task_table_update.");
int status = redisAsyncCommand(
+3 -3
View File
@@ -32,8 +32,8 @@ void task_table_update(db_handle *db_handle,
void task_table_test_and_update(db_handle *db_handle,
task_id task_id,
scheduling_state test_state,
scheduling_state update_state,
int test_state,
int update_state,
retry_info *retry,
task_table_get_callback done_callback,
void *user_context) {
@@ -51,7 +51,7 @@ void task_table_test_and_update(db_handle *db_handle,
/* TODO(swang): A corresponding task_table_unsubscribe. */
void task_table_subscribe(db_handle *db_handle,
db_client_id local_scheduler_id,
scheduling_state state_filter,
int state_filter,
task_table_subscribe_callback subscribe_callback,
void *subscribe_context,
retry_info *retry,
+6 -6
View File
@@ -108,16 +108,16 @@ void task_table_update(db_handle *db_handle,
*/
void task_table_test_and_update(db_handle *db_handle,
task_id task_id,
scheduling_state test_state,
scheduling_state update_state,
int test_state,
int update_state,
retry_info *retry,
task_table_get_callback done_callback,
void *user_context);
/* Data that is needed to test and set the task's scheduling state. */
typedef struct {
scheduling_state test_state;
scheduling_state update_state;
int test_state;
int update_state;
db_client_id local_scheduler_id;
} task_table_test_and_update_data;
@@ -153,7 +153,7 @@ typedef void (*task_table_subscribe_callback)(task *task, void *user_context);
*/
void task_table_subscribe(db_handle *db_handle,
db_client_id local_scheduler_id,
scheduling_state state_filter,
int state_filter,
task_table_subscribe_callback subscribe_callback,
void *subscribe_context,
retry_info *retry,
@@ -164,7 +164,7 @@ void task_table_subscribe(db_handle *db_handle,
* database. */
typedef struct {
db_client_id local_scheduler_id;
scheduling_state state_filter;
int state_filter;
task_table_subscribe_callback subscribe_callback;
void *subscribe_context;
} task_table_subscribe_data;
+7 -6
View File
@@ -299,14 +299,15 @@ void print_task(task_spec *spec, UT_string *output) {
/* TASK INSTANCES */
struct task_impl {
scheduling_state state;
/** The scheduling state of the task. */
int state;
/** The ID of the local scheduler involved. */
db_client_id local_scheduler_id;
/** The task specification for this task. */
task_spec spec;
};
task *alloc_task(task_spec *spec,
scheduling_state state,
db_client_id local_scheduler_id) {
task *alloc_task(task_spec *spec, int state, db_client_id local_scheduler_id) {
int64_t size = sizeof(task) - sizeof(task_spec) + task_spec_size(spec);
task *result = malloc(size);
memset(result, 0, size);
@@ -328,11 +329,11 @@ int64_t task_size(task *task_arg) {
return sizeof(task) - sizeof(task_spec) + task_spec_size(&task_arg->spec);
}
scheduling_state task_state(task *task) {
int task_state(task *task) {
return task->state;
}
void task_set_state(task *task, scheduling_state state) {
void task_set_state(task *task, int state) {
task->state = state;
}
+3 -5
View File
@@ -291,9 +291,7 @@ typedef struct task_impl task;
* @param local_scheduler_id The ID of the local scheduler that the task is
* scheduled on, if any.
*/
task *alloc_task(task_spec *spec,
scheduling_state state,
db_client_id local_scheduler_id);
task *alloc_task(task_spec *spec, int state, db_client_id local_scheduler_id);
/**
* Create a copy of the task. Must be freed with free_task after use.
@@ -307,10 +305,10 @@ task *copy_task(task *other);
int64_t task_size(task *task);
/** The scheduling state of the task. */
scheduling_state task_state(task *task);
int task_state(task *task);
/** Update the schedule state of the task. */
void task_set_state(task *task, scheduling_state state);
void task_set_state(task *task, int state);
/** Local scheduler this task has been assigned to or is running on. */
db_client_id task_local_scheduler(task *task);
+2 -2
View File
@@ -44,7 +44,7 @@ static inline task_spec *example_task_spec(int64_t num_args,
static inline task *example_task_with_args(int64_t num_args,
int64_t num_returns,
scheduling_state task_state,
int task_state,
object_id arg_ids[]) {
task_spec *spec = example_task_spec_with_args(num_args, num_returns, arg_ids);
task *instance = alloc_task(spec, task_state, NIL_ID);
@@ -54,7 +54,7 @@ static inline task *example_task_with_args(int64_t num_args,
static inline task *example_task(int64_t num_args,
int64_t num_returns,
scheduling_state task_state) {
int task_state) {
task_spec *spec = example_task_spec(num_args, num_returns);
task *instance = alloc_task(spec, task_state, NIL_ID);
free_task_spec(spec);