forked from ray-project/ray
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce local scheduler heartbeats which carry load information. (r…
…ay-project#155) * Introduce local scheduler heartbeats which carry load information.
- Loading branch information
1 parent
9bb9f8c
commit 3d697c7
Showing
10 changed files
with
248 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "local_scheduler_table.h" | ||
#include "redis.h" | ||
|
||
void local_scheduler_table_subscribe( | ||
db_handle *db_handle, | ||
local_scheduler_table_subscribe_callback subscribe_callback, | ||
void *subscribe_context, | ||
retry_info *retry) { | ||
local_scheduler_table_subscribe_data *sub_data = | ||
malloc(sizeof(local_scheduler_table_subscribe_data)); | ||
sub_data->subscribe_callback = subscribe_callback; | ||
sub_data->subscribe_context = subscribe_context; | ||
|
||
init_table_callback(db_handle, NIL_ID, __func__, sub_data, retry, NULL, | ||
redis_local_scheduler_table_subscribe, NULL); | ||
} | ||
|
||
void local_scheduler_table_send_info(db_handle *db_handle, | ||
local_scheduler_info *info, | ||
retry_info *retry) { | ||
local_scheduler_table_send_info_data *data = | ||
malloc(sizeof(local_scheduler_table_send_info_data)); | ||
data->info = *info; | ||
|
||
init_table_callback(db_handle, NIL_ID, __func__, data, retry, NULL, | ||
redis_local_scheduler_table_send_info, NULL); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#ifndef LOCAL_SCHEDULER_TABLE_H | ||
#define LOCAL_SCHEDULER_TABLE_H | ||
|
||
#include "db.h" | ||
#include "table.h" | ||
|
||
typedef struct { | ||
int task_queue_length; | ||
int available_workers; | ||
} local_scheduler_info; | ||
|
||
/* | ||
* ==== Subscribing to the local scheduler table ==== | ||
*/ | ||
|
||
/* Callback for subscribing to the local scheduler table. */ | ||
typedef void (*local_scheduler_table_subscribe_callback)( | ||
db_client_id client_id, | ||
local_scheduler_info info, | ||
void *user_context); | ||
|
||
/** | ||
* Register a callback for a local scheduler table event. | ||
* | ||
* @param db_handle Database handle. | ||
* @param subscribe_callback Callback that will be called when the local | ||
* scheduler event happens. | ||
* @param subscribe_context Context that will be passed into the | ||
* subscribe_callback. | ||
* @param retry Information about retrying the request to the database. | ||
* @return Void. | ||
*/ | ||
void local_scheduler_table_subscribe( | ||
db_handle *db_handle, | ||
local_scheduler_table_subscribe_callback subscribe_callback, | ||
void *subscribe_context, | ||
retry_info *retry); | ||
|
||
/* Data that is needed to register local scheduler table subscribe callbacks | ||
* with the state database. */ | ||
typedef struct { | ||
local_scheduler_table_subscribe_callback subscribe_callback; | ||
void *subscribe_context; | ||
} local_scheduler_table_subscribe_data; | ||
|
||
/** | ||
* Send a heartbeat to all subscriers to the local scheduler table. This | ||
* heartbeat contains some information about the load on the local scheduler. | ||
* | ||
* @param db_handle Database handle. | ||
* @param info Information about the local scheduler, including the load on the | ||
* local scheduler. | ||
* @param retry Information about retrying the request to the database. | ||
*/ | ||
void local_scheduler_table_send_info(db_handle *db_handle, | ||
local_scheduler_info *info, | ||
retry_info *retry); | ||
|
||
/* Data that is needed to publish local scheduer heartbeats to the local | ||
* scheduler table. */ | ||
typedef struct { | ||
local_scheduler_info info; | ||
} local_scheduler_table_send_info_data; | ||
|
||
#endif /* LOCAL_SCHEDULER_TABLE_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters