API for task log and scheduled task (#25)

* API revision

* update

* make status a bitmap

* update api

* tests working

* new task log APIs

* update APIs

* write binary structures to redis

* update tests

* fix clang-format

* Fix formatting.
This commit is contained in:
Philipp Moritz
2016-09-29 21:12:06 -07:00
committed by Robert Nishihara
parent 084220b0e7
commit e21e9f68df
12 changed files with 307 additions and 215 deletions
+65 -3
View File
@@ -1,7 +1,7 @@
#ifndef TASK_H
#define TASK_H
/* This API specifies the task data structure. It is in C so we can
/* This API specifies the task data structures. It is in C so we can
* easily construct tasks from other languages like Python. The datastructures
* are also defined in such a way that memory is contiguous and all pointers
* are relative, so that we can memcpy the datastructure and ship it over the
@@ -15,6 +15,24 @@
typedef unique_id function_id;
typedef unique_id object_id;
/* The task ID is a deterministic hash of the function ID that
* the task executes and the argument IDs or argument values */
typedef unique_id task_id;
/* The task instance ID is a globally unique ID generated which
* identifies this particular execution of the task */
typedef unique_id task_iid;
/* The node id is an identifier for the node the task is
* scheduled on */
typedef unique_id node_id;
/*
* TASK SPECIFICATIONS: Contain all the information neccessary
* to execute the task (function id, arguments, return object ids).
*
*/
typedef struct task_spec_impl task_spec;
/* If argument is passed by value or reference. */
@@ -65,7 +83,51 @@ task_spec *read_task(int fd);
/* Print task as a humanly readable string. */
void print_task(task_spec *spec, UT_string *output);
/* Parse task as printed by print_task. */
task_spec *parse_task(char *task_string, int64_t task_length);
/*
* SCHEDULED TASK: Contains information about a scheduled task:
* the task iid, the task specification and the task status
* (WAITING, SCHEDULED, RUNNING, DONE) and which node the
* task is scheduled on.
*
*/
/* The scheduling_state can be used as a flag when we are listening
* for an event, for example TASK_WAITING | TASK_SCHEDULED. */
enum scheduling_state {
TASK_WAITING = 1,
TASK_SCHEDULED = 2,
TASK_RUNNING = 4,
TASK_DONE = 8
};
/* A task instance is one execution of a task specification.
* It has a unique instance id, a state of execution (see scheduling_state)
* and a node it is scheduled on or running on. */
typedef struct task_instance_impl task_instance;
/* Allocate and initialize a new task instance. Must be freed with
* scheduled_task_free after use. */
task_instance *make_task_instance(task_iid task_iid,
task_spec *task,
int32_t state,
node_id node);
/* Size of task instance structure in bytes. */
int64_t task_instance_size(task_instance *instance);
/* Instance ID of the task instance. */
task_iid *task_instance_id(task_instance *instance);
/* The scheduling state of the task instance. */
int32_t *task_instance_state(task_instance *instance);
/* Node this task instance has been assigned to or is running on. */
node_id *task_instance_node(task_instance *instance);
/* Task specification of this task instance. */
task_spec *task_instance_task_spec(task_instance *instance);
/* Free this task instance datastructure. */
void task_instance_free(task_instance *instance);
#endif