2017-02-27 12:24:07 -08:00
|
|
|
#ifndef LOCAL_SCHEDULER_CLIENT_H
|
|
|
|
#define LOCAL_SCHEDULER_CLIENT_H
|
2016-09-27 19:11:09 -07:00
|
|
|
|
|
|
|
#include "common/task.h"
|
2017-02-27 12:24:07 -08:00
|
|
|
#include "local_scheduler_shared.h"
|
2016-09-27 19:11:09 -07:00
|
|
|
|
2016-10-04 12:55:10 -07:00
|
|
|
typedef struct {
|
2017-02-27 12:24:07 -08:00
|
|
|
/** File descriptor of the Unix domain socket that connects to local
|
|
|
|
* scheduler. */
|
2016-10-04 12:55:10 -07:00
|
|
|
int conn;
|
2017-02-27 12:24:07 -08:00
|
|
|
} LocalSchedulerConnection;
|
2016-09-27 19:11:09 -07:00
|
|
|
|
2016-10-04 12:55:10 -07:00
|
|
|
/**
|
|
|
|
* Connect to the local scheduler.
|
|
|
|
*
|
2017-02-27 12:24:07 -08:00
|
|
|
* @param local_scheduler_socket The name of the socket to use to connect to the
|
|
|
|
* local scheduler.
|
2017-02-15 00:10:05 -08:00
|
|
|
* @param actor_id The ID of the actor running on this worker. If no actor is
|
|
|
|
* running on this actor, this should be NIL_ACTOR_ID.
|
2017-03-17 17:03:58 -07:00
|
|
|
* @param is_worker Whether this client is a worker. If it is a worker, an
|
|
|
|
* additional message will be sent to register as one.
|
2016-10-04 12:55:10 -07:00
|
|
|
* @return The connection information.
|
|
|
|
*/
|
2017-02-27 12:24:07 -08:00
|
|
|
LocalSchedulerConnection *LocalSchedulerConnection_init(
|
|
|
|
const char *local_scheduler_socket,
|
2017-04-07 23:03:37 -07:00
|
|
|
UniqueID worker_id,
|
2017-03-17 17:03:58 -07:00
|
|
|
ActorID actor_id,
|
|
|
|
bool is_worker);
|
2016-09-27 19:11:09 -07:00
|
|
|
|
2016-12-12 23:17:22 -08:00
|
|
|
/**
|
|
|
|
* Disconnect from the local scheduler.
|
|
|
|
*
|
2017-02-27 12:24:07 -08:00
|
|
|
* @param conn Local scheduler connection information returned by
|
|
|
|
* LocalSchedulerConnection_init.
|
2016-12-12 23:17:22 -08:00
|
|
|
* @return Void.
|
|
|
|
*/
|
2017-02-27 12:24:07 -08:00
|
|
|
void LocalSchedulerConnection_free(LocalSchedulerConnection *conn);
|
2016-12-12 23:17:22 -08:00
|
|
|
|
2016-10-04 12:55:10 -07:00
|
|
|
/**
|
|
|
|
* Submit a task to the local scheduler.
|
|
|
|
*
|
|
|
|
* @param conn The connection information.
|
|
|
|
* @param task The address of the task to submit.
|
|
|
|
* @return Void.
|
|
|
|
*/
|
2017-03-05 02:05:02 -08:00
|
|
|
void local_scheduler_submit(LocalSchedulerConnection *conn,
|
|
|
|
TaskSpec *task,
|
|
|
|
int64_t task_size);
|
2016-09-27 19:11:09 -07:00
|
|
|
|
2017-01-05 16:47:16 -08:00
|
|
|
/**
|
|
|
|
* Log an event to the event log. This will call RPUSH key value. We use RPUSH
|
|
|
|
* instead of SET so that it is possible to flush the log multiple times with
|
|
|
|
* the same key (for example the key might be shared across logging calls in the
|
|
|
|
* same task on a worker).
|
|
|
|
*
|
|
|
|
* @param conn The connection information.
|
|
|
|
* @param key The key to store the event in.
|
|
|
|
* @param key_length The length of the key.
|
|
|
|
* @param value The value to store.
|
|
|
|
* @param value_length The length of the value.
|
|
|
|
* @return Void.
|
|
|
|
*/
|
2017-02-27 12:24:07 -08:00
|
|
|
void local_scheduler_log_event(LocalSchedulerConnection *conn,
|
|
|
|
uint8_t *key,
|
|
|
|
int64_t key_length,
|
|
|
|
uint8_t *value,
|
|
|
|
int64_t value_length);
|
2017-01-05 16:47:16 -08:00
|
|
|
|
2016-10-04 12:55:10 -07:00
|
|
|
/**
|
|
|
|
* Get next task for this client. This will block until the scheduler assigns
|
|
|
|
* a task to this worker. This allocates and returns a task, and so the task
|
|
|
|
* must be freed by the caller.
|
|
|
|
*
|
|
|
|
* @todo When does this actually get freed?
|
|
|
|
*
|
|
|
|
* @param conn The connection information.
|
|
|
|
* @return The address of the assigned task.
|
|
|
|
*/
|
2017-03-05 02:05:02 -08:00
|
|
|
TaskSpec *local_scheduler_get_task(LocalSchedulerConnection *conn,
|
|
|
|
int64_t *task_size);
|
2016-09-27 19:11:09 -07:00
|
|
|
|
2016-10-04 12:55:10 -07:00
|
|
|
/**
|
|
|
|
* Tell the local scheduler that the client has finished executing a task.
|
|
|
|
*
|
|
|
|
* @param conn The connection information.
|
|
|
|
* @return Void.
|
|
|
|
*/
|
2017-02-27 12:24:07 -08:00
|
|
|
void local_scheduler_task_done(LocalSchedulerConnection *conn);
|
2016-09-27 19:11:09 -07:00
|
|
|
|
2016-10-04 12:55:10 -07:00
|
|
|
/**
|
2016-12-12 23:17:22 -08:00
|
|
|
* Tell the local scheduler to reconstruct an object.
|
2016-10-04 12:55:10 -07:00
|
|
|
*
|
|
|
|
* @param conn The connection information.
|
2016-12-12 23:17:22 -08:00
|
|
|
* @param object_id The ID of the object to reconstruct.
|
2016-10-04 12:55:10 -07:00
|
|
|
* @return Void.
|
|
|
|
*/
|
2017-02-27 12:24:07 -08:00
|
|
|
void local_scheduler_reconstruct_object(LocalSchedulerConnection *conn,
|
|
|
|
ObjectID object_id);
|
2016-09-27 19:11:09 -07:00
|
|
|
|
2016-10-04 12:55:10 -07:00
|
|
|
/**
|
|
|
|
* Send a log message to the local scheduler.
|
|
|
|
*
|
|
|
|
* @param conn The connection information.
|
|
|
|
* @return Void.
|
|
|
|
*/
|
2017-02-27 12:24:07 -08:00
|
|
|
void local_scheduler_log_message(LocalSchedulerConnection *conn);
|
2016-09-27 19:11:09 -07:00
|
|
|
|
2017-02-17 17:08:52 -08:00
|
|
|
/**
|
|
|
|
* Notify the local scheduler that this client (worker) is no longer blocked.
|
|
|
|
*
|
|
|
|
* @param conn The connection information.
|
|
|
|
* @return Void.
|
|
|
|
*/
|
2017-02-27 12:24:07 -08:00
|
|
|
void local_scheduler_notify_unblocked(LocalSchedulerConnection *conn);
|
2017-02-17 17:08:52 -08:00
|
|
|
|
2017-03-21 00:16:48 -07:00
|
|
|
/**
|
|
|
|
* Record the mapping from object ID to task ID for put events.
|
|
|
|
*
|
|
|
|
* @param conn The connection information.
|
|
|
|
* @param task_id The ID of the task that called put.
|
|
|
|
* @param object_id The ID of the object being stored.
|
|
|
|
* @return Void.
|
|
|
|
*/
|
|
|
|
void local_scheduler_put_object(LocalSchedulerConnection *conn,
|
|
|
|
TaskID task_id,
|
|
|
|
ObjectID object_id);
|
|
|
|
|
2016-09-27 19:11:09 -07:00
|
|
|
#endif
|