mirror of
https://github.com/vale981/ray
synced 2025-03-08 19:41:38 -05:00
Replace UT strings in local scheduler (#1213)
* Convert to string using std::string * Fix linting issue * Fix linting * Construct db_connect_args using vector * Use vector size() instead of num_args * Hopefully fix linting now
This commit is contained in:
parent
94423c0542
commit
d986294c2b
1 changed files with 20 additions and 33 deletions
|
@ -6,6 +6,8 @@
|
|||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "common.h"
|
||||
#include "common_protocol.h"
|
||||
#include "event_loop.h"
|
||||
|
@ -342,42 +344,27 @@ LocalSchedulerState *LocalSchedulerState_init(
|
|||
|
||||
/* Connect to Redis if a Redis address is provided. */
|
||||
if (redis_primary_addr != NULL) {
|
||||
int num_args;
|
||||
const char **db_connect_args = NULL;
|
||||
/* Use UT_string to convert the resource value into a string. */
|
||||
UT_string *num_cpus;
|
||||
UT_string *num_gpus;
|
||||
utstring_new(num_cpus);
|
||||
utstring_new(num_gpus);
|
||||
utstring_printf(num_cpus, "%f", static_resource_conf[0]);
|
||||
utstring_printf(num_gpus, "%f", static_resource_conf[1]);
|
||||
/* Use std::string to convert the resource value into a string. */
|
||||
std::string num_cpus = std::to_string(static_resource_conf[0]);
|
||||
std::string num_gpus = std::to_string(static_resource_conf[1]);
|
||||
|
||||
/* Construct db_connect_args */
|
||||
std::vector<const char *> db_connect_args;
|
||||
db_connect_args.push_back("local_scheduler_socket_name");
|
||||
db_connect_args.push_back(local_scheduler_socket_name);
|
||||
db_connect_args.push_back("num_cpus");
|
||||
db_connect_args.push_back(num_cpus.c_str());
|
||||
db_connect_args.push_back("num_gpus");
|
||||
db_connect_args.push_back(num_gpus.c_str());
|
||||
|
||||
if (plasma_manager_address != NULL) {
|
||||
num_args = 8;
|
||||
db_connect_args = (const char **) malloc(sizeof(char *) * num_args);
|
||||
db_connect_args[0] = "local_scheduler_socket_name";
|
||||
db_connect_args[1] = local_scheduler_socket_name;
|
||||
db_connect_args[2] = "num_cpus";
|
||||
db_connect_args[3] = utstring_body(num_cpus);
|
||||
db_connect_args[4] = "num_gpus";
|
||||
db_connect_args[5] = utstring_body(num_gpus);
|
||||
db_connect_args[6] = "manager_address";
|
||||
db_connect_args[7] = plasma_manager_address;
|
||||
} else {
|
||||
num_args = 6;
|
||||
db_connect_args = (const char **) malloc(sizeof(char *) * num_args);
|
||||
db_connect_args[0] = "local_scheduler_socket_name";
|
||||
db_connect_args[1] = local_scheduler_socket_name;
|
||||
db_connect_args[2] = "num_cpus";
|
||||
db_connect_args[3] = utstring_body(num_cpus);
|
||||
db_connect_args[4] = "num_gpus";
|
||||
db_connect_args[5] = utstring_body(num_gpus);
|
||||
db_connect_args.push_back("manager_address");
|
||||
db_connect_args.push_back(plasma_manager_address);
|
||||
}
|
||||
|
||||
state->db = db_connect(std::string(redis_primary_addr), redis_primary_port,
|
||||
"local_scheduler", node_ip_address, num_args,
|
||||
db_connect_args);
|
||||
utstring_free(num_cpus);
|
||||
utstring_free(num_gpus);
|
||||
free(db_connect_args);
|
||||
"local_scheduler", node_ip_address,
|
||||
db_connect_args.size(), &db_connect_args[0]);
|
||||
db_attach(state->db, loop, false);
|
||||
} else {
|
||||
state->db = NULL;
|
||||
|
|
Loading…
Add table
Reference in a new issue