2016-09-27 19:11:09 -07:00
|
|
|
#ifndef PHOTON_CLIENT_H
|
|
|
|
#define PHOTON_CLIENT_H
|
|
|
|
|
|
|
|
#include "common/task.h"
|
|
|
|
#include "photon.h"
|
|
|
|
|
2016-10-04 12:55:10 -07:00
|
|
|
typedef struct {
|
|
|
|
/* File descriptor of the Unix domain socket that connects to photon. */
|
|
|
|
int conn;
|
|
|
|
} photon_conn;
|
2016-09-27 19:11:09 -07:00
|
|
|
|
2016-10-04 12:55:10 -07:00
|
|
|
/**
|
|
|
|
* Connect to the local scheduler.
|
|
|
|
*
|
|
|
|
* @param photon_socket The name of the socket to use to connect to the local
|
2016-12-12 23:17:22 -08:00
|
|
|
* scheduler.
|
2016-10-04 12:55:10 -07:00
|
|
|
* @return The connection information.
|
|
|
|
*/
|
2016-09-27 19:11:09 -07:00
|
|
|
photon_conn *photon_connect(const char *photon_socket);
|
|
|
|
|
2016-12-12 23:17:22 -08:00
|
|
|
/**
|
|
|
|
* Disconnect from the local scheduler.
|
|
|
|
*
|
|
|
|
* @param conn Photon connection information returned by photon_connect.
|
|
|
|
* @return Void.
|
|
|
|
*/
|
|
|
|
void photon_disconnect(photon_conn *conn);
|
|
|
|
|
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.
|
|
|
|
*/
|
2016-09-27 19:11:09 -07:00
|
|
|
void photon_submit(photon_conn *conn, task_spec *task);
|
|
|
|
|
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.
|
|
|
|
*/
|
2016-09-27 19:11:09 -07:00
|
|
|
task_spec *photon_get_task(photon_conn *conn);
|
|
|
|
|
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.
|
|
|
|
*/
|
2016-09-27 19:11:09 -07:00
|
|
|
void photon_task_done(photon_conn *conn);
|
|
|
|
|
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.
|
|
|
|
*/
|
2016-12-12 23:17:22 -08:00
|
|
|
void photon_reconstruct_object(photon_conn *conn, object_id 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.
|
|
|
|
*/
|
2016-09-27 19:11:09 -07:00
|
|
|
void photon_log_message(photon_conn *conn);
|
|
|
|
|
|
|
|
#endif
|