mirror of
https://github.com/wassname/ray.git
synced 2026-08-03 13:10:57 +08:00
Update logging and check macros. (#1627)
* Update logging and check macros. * Fix linting. * Fix RAY_DCHECK and unused variable. * Fix linting
This commit is contained in:
committed by
Philipp Moritz
parent
e7df293946
commit
0fcceef772
+1
-63
@@ -25,6 +25,7 @@ extern "C" {
|
||||
#include "arrow/util/macros.h"
|
||||
#include "plasma/common.h"
|
||||
#include "ray/id.h"
|
||||
#include "ray/util/logging.h"
|
||||
|
||||
#include "state/ray_config.h"
|
||||
|
||||
@@ -44,69 +45,6 @@ extern "C" {
|
||||
#define RAY_COMMON_LOG_LEVEL RAY_COMMON_INFO
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Macros to enable each level of Ray logging statements depending on the
|
||||
* current logging level. */
|
||||
#if (RAY_COMMON_LOG_LEVEL > RAY_COMMON_DEBUG)
|
||||
#define LOG_DEBUG(M, ...)
|
||||
#else
|
||||
#define LOG_DEBUG(M, ...) \
|
||||
fprintf(stderr, "[DEBUG] (%s:%d) " M "\n", __FILE__, __LINE__, ##__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if (RAY_COMMON_LOG_LEVEL > RAY_COMMON_INFO)
|
||||
#define LOG_INFO(M, ...)
|
||||
#else
|
||||
#define LOG_INFO(M, ...) \
|
||||
fprintf(stderr, "[INFO] (%s:%d) " M "\n", __FILE__, __LINE__, ##__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if (RAY_COMMON_LOG_LEVEL > RAY_COMMON_WARNING)
|
||||
#define LOG_WARN(M, ...)
|
||||
#else
|
||||
#define LOG_WARN(M, ...) \
|
||||
fprintf(stderr, "[WARN] (%s:%d) " M "\n", __FILE__, __LINE__, ##__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if (RAY_COMMON_LOG_LEVEL > RAY_COMMON_ERROR)
|
||||
#define LOG_ERROR(M, ...)
|
||||
#else
|
||||
#define LOG_ERROR(M, ...) \
|
||||
fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " M "\n", __FILE__, __LINE__, \
|
||||
errno == 0 ? "None" : strerror(errno), ##__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if (RAY_COMMON_LOG_LEVEL > RAY_COMMON_FATAL)
|
||||
#define LOG_FATAL(M, ...)
|
||||
#elif defined(_EXECINFO_H) || !defined(_WIN32)
|
||||
#define LOG_FATAL(M, ...) \
|
||||
do { \
|
||||
fprintf(stderr, "[FATAL] (%s:%d: errno: %s) " M "\n", __FILE__, __LINE__, \
|
||||
errno == 0 ? "None" : strerror(errno), ##__VA_ARGS__); \
|
||||
void *buffer[255]; \
|
||||
const int calls = backtrace(buffer, sizeof(buffer) / sizeof(void *)); \
|
||||
backtrace_symbols_fd(buffer, calls, 1); \
|
||||
abort(); \
|
||||
} while (0)
|
||||
#else
|
||||
#define LOG_FATAL(M, ...) \
|
||||
do { \
|
||||
fprintf(stderr, "[FATAL] (%s:%d: errno: %s) " M "\n", __FILE__, __LINE__, \
|
||||
errno == 0 ? "None" : strerror(errno), ##__VA_ARGS__); \
|
||||
exit(-1); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
/** Assertion definitions, with optional logging. */
|
||||
#define CHECKM(COND, M, ...) \
|
||||
if (!(COND)) { \
|
||||
LOG_FATAL("Check failure: %s \n" M, #COND, ##__VA_ARGS__); \
|
||||
}
|
||||
|
||||
#define CHECK(COND) CHECKM(COND, "")
|
||||
|
||||
#define RAY_DCHECK(COND) CHECK(COND)
|
||||
|
||||
/* These are exit codes for common errors that can occur in Ray components. */
|
||||
#define EXIT_COULD_NOT_BIND_PORT -2
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ flatbuffers::Offset<flatbuffers::String> to_flatbuf(
|
||||
|
||||
ray::ObjectID from_flatbuf(const flatbuffers::String &string) {
|
||||
ray::ObjectID object_id;
|
||||
CHECK(string.size() == sizeof(ray::ObjectID));
|
||||
RAY_CHECK(string.size() == sizeof(ray::ObjectID));
|
||||
memcpy(object_id.mutable_data(), string.data(), sizeof(ray::ObjectID));
|
||||
return object_id;
|
||||
}
|
||||
|
||||
+33
-30
@@ -24,7 +24,7 @@ int bind_inet_sock(const int port, bool shall_listen) {
|
||||
struct sockaddr_in name;
|
||||
int socket_fd = socket(PF_INET, SOCK_STREAM, 0);
|
||||
if (socket_fd < 0) {
|
||||
LOG_ERROR("socket() failed for port %d.", port);
|
||||
RAY_LOG(ERROR) << "socket() failed for port " << port;
|
||||
return -1;
|
||||
}
|
||||
name.sin_family = AF_INET;
|
||||
@@ -33,23 +33,23 @@ int bind_inet_sock(const int port, bool shall_listen) {
|
||||
int on = 1;
|
||||
/* TODO(pcm): http://stackoverflow.com/q/1150635 */
|
||||
if (ioctl(socket_fd, FIONBIO, (char *) &on) < 0) {
|
||||
LOG_ERROR("ioctl failed");
|
||||
RAY_LOG(ERROR) << "ioctl failed";
|
||||
close(socket_fd);
|
||||
return -1;
|
||||
}
|
||||
int *const pon = (int *const) & on;
|
||||
if (setsockopt(socket_fd, SOL_SOCKET, SO_REUSEADDR, pon, sizeof(on)) < 0) {
|
||||
LOG_ERROR("setsockopt failed for port %d", port);
|
||||
RAY_LOG(ERROR) << "setsockopt failed for port " << port;
|
||||
close(socket_fd);
|
||||
return -1;
|
||||
}
|
||||
if (bind(socket_fd, (struct sockaddr *) &name, sizeof(name)) < 0) {
|
||||
LOG_ERROR("Bind failed for port %d", port);
|
||||
RAY_LOG(ERROR) << "Bind failed for port " << port;
|
||||
close(socket_fd);
|
||||
return -1;
|
||||
}
|
||||
if (shall_listen && listen(socket_fd, 128) == -1) {
|
||||
LOG_ERROR("Could not listen to socket %d", port);
|
||||
RAY_LOG(ERROR) << "Could not listen to socket " << port;
|
||||
close(socket_fd);
|
||||
return -1;
|
||||
}
|
||||
@@ -60,14 +60,14 @@ int bind_ipc_sock(const char *socket_pathname, bool shall_listen) {
|
||||
struct sockaddr_un socket_address;
|
||||
int socket_fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (socket_fd < 0) {
|
||||
LOG_ERROR("socket() failed for pathname %s.", socket_pathname);
|
||||
RAY_LOG(ERROR) << "socket() failed for pathname " << socket_pathname;
|
||||
return -1;
|
||||
}
|
||||
/* Tell the system to allow the port to be reused. */
|
||||
int on = 1;
|
||||
if (setsockopt(socket_fd, SOL_SOCKET, SO_REUSEADDR, (char *) &on,
|
||||
sizeof(on)) < 0) {
|
||||
LOG_ERROR("setsockopt failed for pathname %s", socket_pathname);
|
||||
RAY_LOG(ERROR) << "setsockopt failed for pathname " << socket_pathname;
|
||||
close(socket_fd);
|
||||
return -1;
|
||||
}
|
||||
@@ -76,7 +76,7 @@ int bind_ipc_sock(const char *socket_pathname, bool shall_listen) {
|
||||
memset(&socket_address, 0, sizeof(socket_address));
|
||||
socket_address.sun_family = AF_UNIX;
|
||||
if (strlen(socket_pathname) + 1 > sizeof(socket_address.sun_path)) {
|
||||
LOG_ERROR("Socket pathname is too long.");
|
||||
RAY_LOG(ERROR) << "Socket pathname is too long.";
|
||||
close(socket_fd);
|
||||
return -1;
|
||||
}
|
||||
@@ -85,12 +85,12 @@ int bind_ipc_sock(const char *socket_pathname, bool shall_listen) {
|
||||
|
||||
if (bind(socket_fd, (struct sockaddr *) &socket_address,
|
||||
sizeof(socket_address)) != 0) {
|
||||
LOG_ERROR("Bind failed for pathname %s.", socket_pathname);
|
||||
RAY_LOG(ERROR) << "Bind failed for pathname " << socket_pathname;
|
||||
close(socket_fd);
|
||||
return -1;
|
||||
}
|
||||
if (shall_listen && listen(socket_fd, 128) == -1) {
|
||||
LOG_ERROR("Could not listen to socket %s", socket_pathname);
|
||||
RAY_LOG(ERROR) << "Could not listen to socket " << socket_pathname;
|
||||
close(socket_fd);
|
||||
return -1;
|
||||
}
|
||||
@@ -108,7 +108,7 @@ int connect_ipc_sock_retry(const char *socket_pathname,
|
||||
timeout = RayConfig::instance().connect_timeout_milliseconds();
|
||||
}
|
||||
|
||||
CHECK(socket_pathname);
|
||||
RAY_CHECK(socket_pathname);
|
||||
int fd = -1;
|
||||
for (int num_attempts = 0; num_attempts < num_retries; ++num_attempts) {
|
||||
fd = connect_ipc_sock(socket_pathname);
|
||||
@@ -116,15 +116,15 @@ int connect_ipc_sock_retry(const char *socket_pathname,
|
||||
break;
|
||||
}
|
||||
if (num_attempts == 0) {
|
||||
LOG_ERROR("Connection to socket failed for pathname %s.",
|
||||
socket_pathname);
|
||||
RAY_LOG(ERROR) << "Connection to socket failed for pathname "
|
||||
<< socket_pathname;
|
||||
}
|
||||
/* Sleep for timeout milliseconds. */
|
||||
usleep(timeout * 1000);
|
||||
}
|
||||
/* If we could not connect to the socket, exit. */
|
||||
if (fd == -1) {
|
||||
LOG_FATAL("Could not connect to socket %s", socket_pathname);
|
||||
RAY_LOG(FATAL) << "Could not connect to socket " << socket_pathname;
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
@@ -135,14 +135,14 @@ int connect_ipc_sock(const char *socket_pathname) {
|
||||
|
||||
socket_fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (socket_fd < 0) {
|
||||
LOG_ERROR("socket() failed for pathname %s.", socket_pathname);
|
||||
RAY_LOG(ERROR) << "socket() failed for pathname " << socket_pathname;
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(&socket_address, 0, sizeof(socket_address));
|
||||
socket_address.sun_family = AF_UNIX;
|
||||
if (strlen(socket_pathname) + 1 > sizeof(socket_address.sun_path)) {
|
||||
LOG_ERROR("Socket pathname is too long.");
|
||||
RAY_LOG(ERROR) << "Socket pathname is too long.";
|
||||
return -1;
|
||||
}
|
||||
strncpy(socket_address.sun_path, socket_pathname,
|
||||
@@ -169,7 +169,7 @@ int connect_inet_sock_retry(const char *ip_addr,
|
||||
timeout = RayConfig::instance().connect_timeout_milliseconds();
|
||||
}
|
||||
|
||||
CHECK(ip_addr);
|
||||
RAY_CHECK(ip_addr);
|
||||
int fd = -1;
|
||||
for (int num_attempts = 0; num_attempts < num_retries; ++num_attempts) {
|
||||
fd = connect_inet_sock(ip_addr, port);
|
||||
@@ -177,15 +177,15 @@ int connect_inet_sock_retry(const char *ip_addr,
|
||||
break;
|
||||
}
|
||||
if (num_attempts == 0) {
|
||||
LOG_ERROR("Connection to socket failed for address %s:%d.", ip_addr,
|
||||
port);
|
||||
RAY_LOG(ERROR) << "Connection to socket failed for address " << ip_addr
|
||||
<< ":" << port;
|
||||
}
|
||||
/* Sleep for timeout milliseconds. */
|
||||
usleep(timeout * 1000);
|
||||
}
|
||||
/* If we could not connect to the socket, exit. */
|
||||
if (fd == -1) {
|
||||
LOG_FATAL("Could not connect to address %s:%d", ip_addr, port);
|
||||
RAY_LOG(FATAL) << "Could not connect to address " << ip_addr << ":" << port;
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
@@ -193,13 +193,14 @@ int connect_inet_sock_retry(const char *ip_addr,
|
||||
int connect_inet_sock(const char *ip_addr, int port) {
|
||||
int fd = socket(PF_INET, SOCK_STREAM, 0);
|
||||
if (fd < 0) {
|
||||
LOG_ERROR("socket() failed for address %s:%d.", ip_addr, port);
|
||||
RAY_LOG(ERROR) << "socket() failed for address " << ip_addr << ":" << port;
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct hostent *manager = gethostbyname(ip_addr); /* TODO(pcm): cache this */
|
||||
if (!manager) {
|
||||
LOG_ERROR("Failed to get hostname from address %s:%d.", ip_addr, port);
|
||||
RAY_LOG(ERROR) << "Failed to get hostname from address " << ip_addr << ":"
|
||||
<< port;
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
@@ -219,7 +220,7 @@ int connect_inet_sock(const char *ip_addr, int port) {
|
||||
int accept_client(int socket_fd) {
|
||||
int client_fd = accept(socket_fd, NULL, NULL);
|
||||
if (client_fd < 0) {
|
||||
LOG_ERROR("Error reading from socket.");
|
||||
RAY_LOG(ERROR) << "Error reading from socket.";
|
||||
return -1;
|
||||
}
|
||||
return client_fd;
|
||||
@@ -242,7 +243,7 @@ int write_bytes(int fd, uint8_t *cursor, size_t length) {
|
||||
/* Encountered early EOF. */
|
||||
return -1;
|
||||
}
|
||||
CHECK(nbytes > 0);
|
||||
RAY_CHECK(nbytes > 0);
|
||||
bytesleft -= nbytes;
|
||||
offset += nbytes;
|
||||
}
|
||||
@@ -288,7 +289,7 @@ int read_bytes(int fd, uint8_t *cursor, size_t length) {
|
||||
/* Encountered early EOF. */
|
||||
return -1;
|
||||
}
|
||||
CHECK(nbytes > 0);
|
||||
RAY_CHECK(nbytes > 0);
|
||||
bytesleft -= nbytes;
|
||||
offset += nbytes;
|
||||
}
|
||||
@@ -302,7 +303,7 @@ void read_message(int fd, int64_t *type, int64_t *length, uint8_t **bytes) {
|
||||
if (closed) {
|
||||
goto disconnected;
|
||||
}
|
||||
CHECK(version == RayConfig::instance().ray_protocol_version());
|
||||
RAY_CHECK(version == RayConfig::instance().ray_protocol_version());
|
||||
closed = read_bytes(fd, (uint8_t *) type, sizeof(*type));
|
||||
if (closed) {
|
||||
goto disconnected;
|
||||
@@ -332,7 +333,8 @@ uint8_t *read_message_async(event_loop *loop, int sock) {
|
||||
int error = read_bytes(sock, (uint8_t *) &size, sizeof(int64_t));
|
||||
if (error < 0) {
|
||||
/* The other side has closed the socket. */
|
||||
LOG_DEBUG("Socket has been closed, or some other error has occurred.");
|
||||
RAY_LOG(DEBUG) << "Socket has been closed, or some other error has "
|
||||
<< "occurred.";
|
||||
if (loop != NULL) {
|
||||
event_loop_remove_file(loop, sock);
|
||||
}
|
||||
@@ -343,7 +345,8 @@ uint8_t *read_message_async(event_loop *loop, int sock) {
|
||||
error = read_bytes(sock, message, size);
|
||||
if (error < 0) {
|
||||
/* The other side has closed the socket. */
|
||||
LOG_DEBUG("Socket has been closed, or some other error has occurred.");
|
||||
RAY_LOG(DEBUG) << "Socket has been closed, or some other error has "
|
||||
<< "occurred.";
|
||||
if (loop != NULL) {
|
||||
event_loop_remove_file(loop, sock);
|
||||
}
|
||||
@@ -359,7 +362,7 @@ int64_t read_vector(int fd, int64_t *type, std::vector<uint8_t> &buffer) {
|
||||
if (closed) {
|
||||
goto disconnected;
|
||||
}
|
||||
CHECK(version == RayConfig::instance().ray_protocol_version());
|
||||
RAY_CHECK(version == RayConfig::instance().ray_protocol_version());
|
||||
int64_t length;
|
||||
closed = read_bytes(fd, (uint8_t *) type, sizeof(*type));
|
||||
if (closed) {
|
||||
@@ -393,6 +396,6 @@ char *read_log_message(int fd) {
|
||||
int64_t type;
|
||||
int64_t length;
|
||||
read_message(fd, &type, &length, &bytes);
|
||||
CHECK(type == LOG_MESSAGE);
|
||||
RAY_CHECK(type == LOG_MESSAGE);
|
||||
return (char *) bytes;
|
||||
}
|
||||
|
||||
@@ -28,14 +28,14 @@ void init_pickle_module(void) {
|
||||
#else
|
||||
pickle_module = PyImport_ImportModuleNoBlock("cPickle");
|
||||
#endif
|
||||
CHECK(pickle_module != NULL);
|
||||
CHECK(PyObject_HasAttrString(pickle_module, "loads"));
|
||||
CHECK(PyObject_HasAttrString(pickle_module, "dumps"));
|
||||
CHECK(PyObject_HasAttrString(pickle_module, "HIGHEST_PROTOCOL"));
|
||||
RAY_CHECK(pickle_module != NULL);
|
||||
RAY_CHECK(PyObject_HasAttrString(pickle_module, "loads"));
|
||||
RAY_CHECK(PyObject_HasAttrString(pickle_module, "dumps"));
|
||||
RAY_CHECK(PyObject_HasAttrString(pickle_module, "HIGHEST_PROTOCOL"));
|
||||
pickle_loads = PyUnicode_FromString("loads");
|
||||
pickle_dumps = PyUnicode_FromString("dumps");
|
||||
pickle_protocol = PyObject_GetAttrString(pickle_module, "HIGHEST_PROTOCOL");
|
||||
CHECK(pickle_protocol != NULL);
|
||||
RAY_CHECK(pickle_protocol != NULL);
|
||||
}
|
||||
|
||||
TaskBuilder *g_task_builder = NULL;
|
||||
@@ -449,8 +449,8 @@ static PyObject *PyTask_arguments(PyObject *self) {
|
||||
assert(count == 1);
|
||||
PyList_SetItem(arg_list, i, PyObjectID_make(TaskSpec_arg_id(task, i, 0)));
|
||||
} else {
|
||||
CHECK(pickle_module != NULL);
|
||||
CHECK(pickle_loads != NULL);
|
||||
RAY_CHECK(pickle_module != NULL);
|
||||
RAY_CHECK(pickle_loads != NULL);
|
||||
PyObject *str =
|
||||
PyBytes_FromStringAndSize((char *) TaskSpec_arg_val(task, i),
|
||||
(Py_ssize_t) TaskSpec_arg_length(task, i));
|
||||
|
||||
@@ -441,7 +441,8 @@ int TableAdd_RedisCommand(RedisModuleCtx *ctx,
|
||||
|
||||
/* See how many clients received this publish. */
|
||||
long long num_clients = RedisModule_CallReplyInteger(reply);
|
||||
CHECKM(num_clients <= 1, "Published to %lld clients.", num_clients);
|
||||
RAY_CHECK(num_clients <= 1) << "Published to " << num_clients
|
||||
<< " clients.";
|
||||
|
||||
RedisModule_FreeString(ctx, publish_message);
|
||||
RedisModule_FreeString(ctx, publish_topic);
|
||||
@@ -473,7 +474,7 @@ int TableLookup_RedisCommand(RedisModuleCtx *ctx,
|
||||
}
|
||||
|
||||
bool is_nil(const std::string &data) {
|
||||
CHECK(data.size() == kUniqueIDSize);
|
||||
RAY_CHECK(data.size() == kUniqueIDSize);
|
||||
const uint8_t *d = reinterpret_cast<const uint8_t *>(data.data());
|
||||
for (int i = 0; i < kUniqueIDSize; ++i) {
|
||||
if (d[i] != 255) {
|
||||
@@ -518,9 +519,9 @@ int TableTestAndUpdate_RedisCommand(RedisModuleCtx *ctx,
|
||||
}
|
||||
|
||||
if (do_update) {
|
||||
CHECK(data->mutate_scheduling_state(update->update_state()));
|
||||
RAY_CHECK(data->mutate_scheduling_state(update->update_state()));
|
||||
}
|
||||
CHECK(data->mutate_updated(do_update));
|
||||
RAY_CHECK(data->mutate_updated(do_update));
|
||||
|
||||
int result = RedisModule_ReplyWithStringBuffer(ctx, value_buf, value_len);
|
||||
|
||||
@@ -978,8 +979,8 @@ int ResultTableLookup_RedisCommand(RedisModuleCtx *ctx,
|
||||
data_size_value = -1;
|
||||
} else {
|
||||
RedisModule_StringToLongLong(data_size, &data_size_value);
|
||||
CHECK(RedisModule_StringToLongLong(data_size, &data_size_value) ==
|
||||
REDISMODULE_OK);
|
||||
RAY_CHECK(RedisModule_StringToLongLong(data_size, &data_size_value) ==
|
||||
REDISMODULE_OK);
|
||||
}
|
||||
|
||||
flatbuffers::Offset<flatbuffers::String> hash_str;
|
||||
@@ -1091,7 +1092,8 @@ int TaskTableWrite(RedisModuleCtx *ctx,
|
||||
|
||||
/* See how many clients received this publish. */
|
||||
long long num_clients = RedisModule_CallReplyInteger(reply);
|
||||
CHECKM(num_clients <= 1, "Published to %lld clients.", num_clients);
|
||||
RAY_CHECK(num_clients <= 1) << "Published to " << num_clients
|
||||
<< " clients.";
|
||||
|
||||
RedisModule_FreeString(ctx, publish_message);
|
||||
RedisModule_FreeString(ctx, publish_topic);
|
||||
|
||||
@@ -44,16 +44,15 @@ const std::vector<std::string> db_client_table_get_ip_addresses(
|
||||
|
||||
for (auto const &manager_id : manager_ids) {
|
||||
DBClient client = redis_cache_get_db_client(db_handle, manager_id);
|
||||
CHECK(!client.manager_address.empty());
|
||||
RAY_CHECK(!client.manager_address.empty());
|
||||
manager_vector.push_back(client.manager_address);
|
||||
}
|
||||
|
||||
int64_t end_time = current_time_ms();
|
||||
if (end_time - start_time > RayConfig::instance().max_time_for_loop()) {
|
||||
LOG_WARN(
|
||||
"calling redis_get_cached_db_client in a loop in with %zu manager IDs "
|
||||
"took %" PRId64 " milliseconds.",
|
||||
manager_ids.size(), end_time - start_time);
|
||||
RAY_LOG(WARNING) << "calling redis_get_cached_db_client in a loop in with "
|
||||
<< manager_ids.size() << " manager IDs took "
|
||||
<< end_time - start_time << " milliseconds.";
|
||||
}
|
||||
|
||||
return manager_vector;
|
||||
@@ -71,7 +70,7 @@ void db_client_table_cache_init(DBHandle *db_handle) {
|
||||
}
|
||||
|
||||
DBClient db_client_table_cache_get(DBHandle *db_handle, DBClientID client_id) {
|
||||
CHECK(!client_id.is_nil());
|
||||
RAY_CHECK(!client_id.is_nil());
|
||||
return redis_cache_get_db_client(db_handle, client_id);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ void push_error(DBHandle *db_handle,
|
||||
int error_index,
|
||||
size_t data_length,
|
||||
const unsigned char *data) {
|
||||
CHECK(error_index >= 0 && error_index < MAX_ERROR_INDEX);
|
||||
RAY_CHECK(error_index >= 0 && error_index < MAX_ERROR_INDEX);
|
||||
/* Allocate a struct to hold the error information. */
|
||||
ErrorInfo *info = (ErrorInfo *) malloc(sizeof(ErrorInfo) + data_length);
|
||||
info->driver_id = driver_id;
|
||||
@@ -22,7 +22,7 @@ void push_error(DBHandle *db_handle,
|
||||
info->data_length = data_length;
|
||||
memcpy(info->data, data, data_length);
|
||||
/* Generate a random key to identify this error message. */
|
||||
CHECK(sizeof(info->error_key) >= sizeof(UniqueID));
|
||||
RAY_CHECK(sizeof(info->error_key) >= sizeof(UniqueID));
|
||||
UniqueID error_key = UniqueID::from_random();
|
||||
memcpy(info->error_key, error_key.data(), sizeof(info->error_key));
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ void object_table_lookup(DBHandle *db_handle,
|
||||
RetryInfo *retry,
|
||||
object_table_lookup_done_callback done_callback,
|
||||
void *user_context) {
|
||||
CHECK(db_handle != NULL);
|
||||
RAY_CHECK(db_handle != NULL);
|
||||
init_table_callback(db_handle, object_id, __func__,
|
||||
new CommonCallbackData(NULL), retry,
|
||||
(table_done_callback) done_callback,
|
||||
@@ -20,7 +20,7 @@ void object_table_add(DBHandle *db_handle,
|
||||
RetryInfo *retry,
|
||||
object_table_done_callback done_callback,
|
||||
void *user_context) {
|
||||
CHECK(db_handle != NULL);
|
||||
RAY_CHECK(db_handle != NULL);
|
||||
|
||||
ObjectTableAddData *info =
|
||||
(ObjectTableAddData *) malloc(sizeof(ObjectTableAddData));
|
||||
@@ -38,7 +38,7 @@ void object_table_remove(DBHandle *db_handle,
|
||||
RetryInfo *retry,
|
||||
object_table_done_callback done_callback,
|
||||
void *user_context) {
|
||||
CHECK(db_handle != NULL);
|
||||
RAY_CHECK(db_handle != NULL);
|
||||
/* Copy the client ID, if one was provided. */
|
||||
DBClientID *client_id_copy = NULL;
|
||||
if (client_id != NULL) {
|
||||
@@ -59,7 +59,7 @@ void object_table_subscribe_to_notifications(
|
||||
RetryInfo *retry,
|
||||
object_table_lookup_done_callback done_callback,
|
||||
void *user_context) {
|
||||
CHECK(db_handle != NULL);
|
||||
RAY_CHECK(db_handle != NULL);
|
||||
ObjectTableSubscribeData *sub_data =
|
||||
(ObjectTableSubscribeData *) malloc(sizeof(ObjectTableSubscribeData));
|
||||
sub_data->object_available_callback = object_available_callback;
|
||||
@@ -76,8 +76,8 @@ void object_table_request_notifications(DBHandle *db_handle,
|
||||
int num_object_ids,
|
||||
ObjectID object_ids[],
|
||||
RetryInfo *retry) {
|
||||
CHECK(db_handle != NULL);
|
||||
CHECK(num_object_ids > 0);
|
||||
RAY_CHECK(db_handle != NULL);
|
||||
RAY_CHECK(num_object_ids > 0);
|
||||
ObjectTableRequestNotificationsData *data =
|
||||
(ObjectTableRequestNotificationsData *) malloc(
|
||||
sizeof(ObjectTableRequestNotificationsData) +
|
||||
|
||||
+140
-135
@@ -35,17 +35,17 @@ extern "C" {
|
||||
extern int usleep(useconds_t usec);
|
||||
#endif
|
||||
|
||||
#define CHECK_REDIS_CONNECT(CONTEXT_TYPE, context, M, ...) \
|
||||
do { \
|
||||
CONTEXT_TYPE *_context = (context); \
|
||||
if (!_context) { \
|
||||
LOG_FATAL("could not allocate redis context"); \
|
||||
} \
|
||||
if (_context->err) { \
|
||||
LOG_ERROR(M, ##__VA_ARGS__); \
|
||||
LOG_REDIS_ERROR(_context, ""); \
|
||||
exit(-1); \
|
||||
} \
|
||||
#define CHECK_REDIS_CONNECT(CONTEXT_TYPE, context, M, ...) \
|
||||
do { \
|
||||
CONTEXT_TYPE *_context = (context); \
|
||||
if (!_context) { \
|
||||
RAY_LOG(FATAL) << "could not allocate redis context"; \
|
||||
} \
|
||||
if (_context->err) { \
|
||||
RAY_LOG(ERROR) << M; \
|
||||
LOG_REDIS_ERROR(_context, ""); \
|
||||
exit(-1); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
@@ -110,14 +110,14 @@ void get_redis_shards(redisContext *context,
|
||||
num_attempts++;
|
||||
continue;
|
||||
}
|
||||
CHECKM(num_attempts < RayConfig::instance().redis_db_connect_retries(),
|
||||
"No entry found for NumRedisShards");
|
||||
CHECKM(reply->type == REDIS_REPLY_STRING,
|
||||
"Expected string, found Redis type %d for NumRedisShards",
|
||||
reply->type);
|
||||
RAY_CHECK(num_attempts < RayConfig::instance().redis_db_connect_retries())
|
||||
<< "No entry found for NumRedisShards";
|
||||
RAY_CHECK(reply->type == REDIS_REPLY_STRING)
|
||||
<< "Expected string, found Redis type " << reply->type
|
||||
<< " for NumRedisShards";
|
||||
int num_redis_shards = atoi(reply->str);
|
||||
CHECKM(num_redis_shards >= 1, "Expected at least one Redis shard, found %d.",
|
||||
num_redis_shards);
|
||||
RAY_CHECK(num_redis_shards >= 1) << "Expected at least one Redis shard, "
|
||||
<< "found " << num_redis_shards;
|
||||
freeReplyObject(reply);
|
||||
|
||||
/* Get the addresses of all of the Redis shards. */
|
||||
@@ -137,18 +137,18 @@ void get_redis_shards(redisContext *context,
|
||||
num_attempts++;
|
||||
continue;
|
||||
}
|
||||
CHECKM(num_attempts < RayConfig::instance().redis_db_connect_retries(),
|
||||
"Expected %d Redis shard addresses, found %d", num_redis_shards,
|
||||
(int) reply->elements);
|
||||
RAY_CHECK(num_attempts < RayConfig::instance().redis_db_connect_retries())
|
||||
<< "Expected " << num_redis_shards << " Redis shard addresses, found "
|
||||
<< reply->elements;
|
||||
|
||||
/* Parse the Redis shard addresses. */
|
||||
char db_shard_address[16];
|
||||
int db_shard_port;
|
||||
for (size_t i = 0; i < reply->elements; ++i) {
|
||||
/* Parse the shard addresses and ports. */
|
||||
CHECK(reply->element[i]->type == REDIS_REPLY_STRING);
|
||||
CHECK(parse_ip_addr_port(reply->element[i]->str, db_shard_address,
|
||||
&db_shard_port) == 0);
|
||||
RAY_CHECK(reply->element[i]->type == REDIS_REPLY_STRING);
|
||||
RAY_CHECK(parse_ip_addr_port(reply->element[i]->str, db_shard_address,
|
||||
&db_shard_port) == 0);
|
||||
db_shards_addresses.push_back(std::string(db_shard_address));
|
||||
db_shards_ports.push_back(db_shard_port);
|
||||
}
|
||||
@@ -174,7 +174,7 @@ void db_connect_shard(const std::string &db_address,
|
||||
RayConfig::instance().redis_db_connect_retries()) {
|
||||
break;
|
||||
}
|
||||
LOG_WARN("Failed to connect to Redis, retrying.");
|
||||
RAY_LOG(WARNING) << "Failed to connect to Redis, retrying.";
|
||||
/* Sleep for a little. */
|
||||
usleep(RayConfig::instance().redis_db_connect_wait_milliseconds() * 1000);
|
||||
sync_context = redisConnect(db_address.c_str(), db_port);
|
||||
@@ -190,13 +190,13 @@ void db_connect_shard(const std::string &db_address,
|
||||
* processes by hand), it is easier to do it multiple times. */
|
||||
reply = (redisReply *) redisCommand(sync_context,
|
||||
"CONFIG SET notify-keyspace-events Kl");
|
||||
CHECKM(reply != NULL, "db_connect failed on CONFIG SET");
|
||||
RAY_CHECK(reply != NULL) << "db_connect failed on CONFIG SET";
|
||||
freeReplyObject(reply);
|
||||
/* Also configure Redis to not run in protected mode, so clients on other
|
||||
* hosts can connect to it. */
|
||||
reply =
|
||||
(redisReply *) redisCommand(sync_context, "CONFIG SET protected-mode no");
|
||||
CHECKM(reply != NULL, "db_connect failed on CONFIG SET");
|
||||
RAY_CHECK(reply != NULL) << "db_connect failed on CONFIG SET";
|
||||
freeReplyObject(reply);
|
||||
|
||||
/* Construct the argument arrays for RAY.CONNECT. */
|
||||
@@ -224,9 +224,9 @@ void db_connect_shard(const std::string &db_address,
|
||||
/* Register this client with Redis. RAY.CONNECT is a custom Redis command that
|
||||
* we've defined. */
|
||||
reply = (redisReply *) redisCommandArgv(sync_context, argc, argv, argvlen);
|
||||
CHECKM(reply != NULL, "db_connect failed on RAY.CONNECT");
|
||||
CHECKM(reply->type != REDIS_REPLY_ERROR, "reply->str is %s", reply->str);
|
||||
CHECKM(strcmp(reply->str, "OK") == 0, "reply->str is %s", reply->str);
|
||||
RAY_CHECK(reply != NULL) << "db_connect failed on RAY.CONNECT";
|
||||
RAY_CHECK(reply->type != REDIS_REPLY_ERROR) << "reply->str is " << reply->str;
|
||||
RAY_CHECK(strcmp(reply->str, "OK") == 0) << "reply->str is " << reply->str;
|
||||
freeReplyObject(reply);
|
||||
free(argv);
|
||||
free(argvlen);
|
||||
@@ -261,7 +261,7 @@ DBHandle *db_connect(const std::string &db_primary_address,
|
||||
/* Check that the number of args is even. These args will be passed to the
|
||||
* RAY.CONNECT Redis command, which takes arguments in pairs. */
|
||||
if (args.size() % 2 != 0) {
|
||||
LOG_FATAL("The number of extra args must be divisible by two.");
|
||||
RAY_LOG(FATAL) << "The number of extra args must be divisible by two.";
|
||||
}
|
||||
|
||||
/* Create a client ID for this client. */
|
||||
@@ -288,7 +288,7 @@ DBHandle *db_connect(const std::string &db_primary_address,
|
||||
std::vector<std::string> db_shards_addresses;
|
||||
std::vector<int> db_shards_ports;
|
||||
get_redis_shards(db->sync_context, db_shards_addresses, db_shards_ports);
|
||||
CHECKM(db_shards_addresses.size() > 0, "No Redis shards found");
|
||||
RAY_CHECK(db_shards_addresses.size() > 0) << "No Redis shards found";
|
||||
/* Connect to the shards. */
|
||||
for (size_t i = 0; i < db_shards_addresses.size(); ++i) {
|
||||
db_connect_shard(db_shards_addresses[i], db_shards_ports[i], client,
|
||||
@@ -309,7 +309,7 @@ void DBHandle_free(DBHandle *db) {
|
||||
redisAsyncFree(db->subscribe_context);
|
||||
|
||||
/* Clean up the Redis shards. */
|
||||
CHECK(db->contexts.size() == db->subscribe_contexts.size());
|
||||
RAY_CHECK(db->contexts.size() == db->subscribe_contexts.size());
|
||||
for (size_t i = 0; i < db->contexts.size(); ++i) {
|
||||
redisAsyncFree(db->contexts[i]);
|
||||
redisAsyncFree(db->subscribe_contexts[i]);
|
||||
@@ -326,8 +326,8 @@ void db_disconnect(DBHandle *db) {
|
||||
redisReply *reply =
|
||||
(redisReply *) redisCommand(db->sync_context, "RAY.DISCONNECT %b",
|
||||
db->client.data(), sizeof(db->client));
|
||||
CHECKM(reply->type != REDIS_REPLY_ERROR, "reply->str is %s", reply->str);
|
||||
CHECKM(strcmp(reply->str, "OK") == 0, "reply->str is %s", reply->str);
|
||||
RAY_CHECK(reply->type != REDIS_REPLY_ERROR) << "reply->str is " << reply->str;
|
||||
RAY_CHECK(strcmp(reply->str, "OK") == 0) << "reply->str is " << reply->str;
|
||||
freeReplyObject(reply);
|
||||
|
||||
DBHandle_free(db);
|
||||
@@ -340,24 +340,24 @@ void db_attach(DBHandle *db, event_loop *loop, bool reattach) {
|
||||
/* If the database is reattached in the tests, redis normally gives
|
||||
* an error which we can safely ignore. */
|
||||
if (!reattach) {
|
||||
CHECKM(err == REDIS_OK, "failed to attach the event loop");
|
||||
RAY_CHECK(err == REDIS_OK) << "failed to attach the event loop";
|
||||
}
|
||||
err = redisAeAttach(loop, db->subscribe_context);
|
||||
if (!reattach) {
|
||||
CHECKM(err == REDIS_OK, "failed to attach the event loop");
|
||||
RAY_CHECK(err == REDIS_OK) << "failed to attach the event loop";
|
||||
}
|
||||
/* Attach other redis shards to the event loop. */
|
||||
CHECK(db->contexts.size() == db->subscribe_contexts.size());
|
||||
RAY_CHECK(db->contexts.size() == db->subscribe_contexts.size());
|
||||
for (size_t i = 0; i < db->contexts.size(); ++i) {
|
||||
int err = redisAeAttach(loop, db->contexts[i]);
|
||||
/* If the database is reattached in the tests, redis normally gives
|
||||
* an error which we can safely ignore. */
|
||||
if (!reattach) {
|
||||
CHECKM(err == REDIS_OK, "failed to attach the event loop");
|
||||
RAY_CHECK(err == REDIS_OK) << "failed to attach the event loop";
|
||||
}
|
||||
err = redisAeAttach(loop, db->subscribe_contexts[i]);
|
||||
if (!reattach) {
|
||||
CHECKM(err == REDIS_OK, "failed to attach the event loop");
|
||||
RAY_CHECK(err == REDIS_OK) << "failed to attach the event loop";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -377,13 +377,14 @@ void redis_object_table_add_callback(redisAsyncContext *c,
|
||||
if (!success) {
|
||||
/* If our object hash doesn't match the one recorded in the table, report
|
||||
* the error back to the user and exit immediately. */
|
||||
LOG_WARN(
|
||||
"Found objects with different value but same object ID, most likely "
|
||||
"because a nondeterministic task was executed twice, either for "
|
||||
"reconstruction or for speculation.");
|
||||
RAY_LOG(WARNING) << "Found objects with different value but same object "
|
||||
<< "ID, most likely because a nondeterministic task was "
|
||||
<< "executed twice, either for reconstruction or for "
|
||||
<< "speculation.";
|
||||
} else {
|
||||
CHECKM(reply->type != REDIS_REPLY_ERROR, "reply->str is %s", reply->str);
|
||||
CHECKM(strcmp(reply->str, "OK") == 0, "reply->str is %s", reply->str);
|
||||
RAY_CHECK(reply->type != REDIS_REPLY_ERROR) << "reply->str is "
|
||||
<< reply->str;
|
||||
RAY_CHECK(strcmp(reply->str, "OK") == 0) << "reply->str is " << reply->str;
|
||||
}
|
||||
/* Call the done callback if there is one. */
|
||||
if (callback_data->done_callback != NULL) {
|
||||
@@ -428,8 +429,8 @@ void redis_object_table_remove_callback(redisAsyncContext *c,
|
||||
* condition with an object_table_add. */
|
||||
return;
|
||||
}
|
||||
CHECKM(reply->type != REDIS_REPLY_ERROR, "reply->str is %s", reply->str);
|
||||
CHECKM(strcmp(reply->str, "OK") == 0, "reply->str is %s", reply->str);
|
||||
RAY_CHECK(reply->type != REDIS_REPLY_ERROR) << "reply->str is " << reply->str;
|
||||
RAY_CHECK(strcmp(reply->str, "OK") == 0) << "reply->str is " << reply->str;
|
||||
/* Call the done callback if there is one. */
|
||||
if (callback_data->done_callback != NULL) {
|
||||
object_table_done_callback done_callback =
|
||||
@@ -464,7 +465,7 @@ void redis_object_table_remove(TableCallbackData *callback_data) {
|
||||
}
|
||||
|
||||
void redis_object_table_lookup(TableCallbackData *callback_data) {
|
||||
CHECK(callback_data);
|
||||
RAY_CHECK(callback_data);
|
||||
DBHandle *db = callback_data->db_handle;
|
||||
|
||||
ObjectID obj_id = callback_data->id;
|
||||
@@ -486,9 +487,9 @@ void redis_result_table_add_callback(redisAsyncContext *c,
|
||||
REDIS_CALLBACK_HEADER(db, callback_data, r);
|
||||
redisReply *reply = (redisReply *) r;
|
||||
/* Check that the command succeeded. */
|
||||
CHECKM(reply->type != REDIS_REPLY_ERROR, "reply->str is %s", reply->str);
|
||||
CHECKM(strncmp(reply->str, "OK", strlen("OK")) == 0, "reply->str is %s",
|
||||
reply->str);
|
||||
RAY_CHECK(reply->type != REDIS_REPLY_ERROR) << "reply->str is " << reply->str;
|
||||
RAY_CHECK(strncmp(reply->str, "OK", strlen("OK")) == 0) << "reply->str is "
|
||||
<< reply->str;
|
||||
/* Call the done callback if there is one. */
|
||||
if (callback_data->done_callback) {
|
||||
result_table_done_callback done_callback =
|
||||
@@ -499,7 +500,7 @@ void redis_result_table_add_callback(redisAsyncContext *c,
|
||||
}
|
||||
|
||||
void redis_result_table_add(TableCallbackData *callback_data) {
|
||||
CHECK(callback_data);
|
||||
RAY_CHECK(callback_data);
|
||||
DBHandle *db = callback_data->db_handle;
|
||||
ObjectID id = callback_data->id;
|
||||
ResultTableAddInfo *info = (ResultTableAddInfo *) callback_data->data->Get();
|
||||
@@ -522,10 +523,9 @@ void redis_result_table_add(TableCallbackData *callback_data) {
|
||||
* task is NULL. This is used by both redis_result_table_lookup_callback and
|
||||
* redis_task_table_get_task_callback. */
|
||||
Task *parse_and_construct_task_from_redis_reply(redisReply *reply) {
|
||||
Task *task;
|
||||
Task *task = NULL;
|
||||
if (reply->type == REDIS_REPLY_NIL) {
|
||||
/* There is no task in the reply, so return NULL. */
|
||||
task = NULL;
|
||||
} else if (reply->type == REDIS_REPLY_STRING) {
|
||||
/* The reply is a flatbuffer TaskReply object. Parse it and construct the
|
||||
* task. */
|
||||
@@ -540,7 +540,7 @@ Task *parse_and_construct_task_from_redis_reply(redisReply *reply) {
|
||||
from_flatbuf(*message->local_scheduler_id()),
|
||||
from_flatbuf(*execution_dependencies->execution_dependencies()));
|
||||
} else {
|
||||
LOG_FATAL("Unexpected reply type %d", reply->type);
|
||||
RAY_LOG(FATAL) << "Unexpected reply type " << reply->type;
|
||||
}
|
||||
/* Return the task. If it is not NULL, then it must be freed by the caller. */
|
||||
return task;
|
||||
@@ -551,9 +551,9 @@ void redis_result_table_lookup_callback(redisAsyncContext *c,
|
||||
void *privdata) {
|
||||
REDIS_CALLBACK_HEADER(db, callback_data, r);
|
||||
redisReply *reply = (redisReply *) r;
|
||||
CHECKM(reply->type == REDIS_REPLY_NIL || reply->type == REDIS_REPLY_STRING,
|
||||
"Unexpected reply type %d in redis_result_table_lookup_callback",
|
||||
reply->type);
|
||||
RAY_CHECK(reply->type == REDIS_REPLY_NIL || reply->type == REDIS_REPLY_STRING)
|
||||
<< "Unexpected reply type " << reply->type << " in "
|
||||
<< "redis_result_table_lookup_callback";
|
||||
/* Parse the task from the reply. */
|
||||
TaskID result_id = TaskID::nil();
|
||||
bool is_put = false;
|
||||
@@ -575,7 +575,7 @@ void redis_result_table_lookup_callback(redisAsyncContext *c,
|
||||
}
|
||||
|
||||
void redis_result_table_lookup(TableCallbackData *callback_data) {
|
||||
CHECK(callback_data);
|
||||
RAY_CHECK(callback_data);
|
||||
DBHandle *db = callback_data->db_handle;
|
||||
ObjectID id = callback_data->id;
|
||||
redisAsyncContext *context = get_redis_context(db, id);
|
||||
@@ -594,8 +594,8 @@ DBClient redis_db_client_table_get(DBHandle *db,
|
||||
redisReply *reply =
|
||||
(redisReply *) redisCommand(db->sync_context, "HGETALL %s%b",
|
||||
DB_CLIENT_PREFIX, client_id, client_id_len);
|
||||
CHECK(reply->type == REDIS_REPLY_ARRAY);
|
||||
CHECK(reply->elements > 0);
|
||||
RAY_CHECK(reply->type == REDIS_REPLY_ARRAY);
|
||||
RAY_CHECK(reply->elements > 0);
|
||||
DBClient db_client;
|
||||
int num_fields = 0;
|
||||
/* Parse the fields into a DBClient. */
|
||||
@@ -620,7 +620,7 @@ DBClient redis_db_client_table_get(DBHandle *db,
|
||||
freeReplyObject(reply);
|
||||
/* The client ID, type, and whether it is deleted are all
|
||||
* mandatory fields. Auxiliary address is optional. */
|
||||
CHECK(num_fields >= 3);
|
||||
RAY_CHECK(num_fields >= 3);
|
||||
return db_client;
|
||||
}
|
||||
|
||||
@@ -651,8 +651,8 @@ void redis_object_table_lookup_callback(redisAsyncContext *c,
|
||||
void *privdata) {
|
||||
REDIS_CALLBACK_HEADER(db, callback_data, r);
|
||||
redisReply *reply = (redisReply *) r;
|
||||
LOG_DEBUG("Object table lookup callback");
|
||||
CHECK(reply->type == REDIS_REPLY_NIL || reply->type == REDIS_REPLY_ARRAY);
|
||||
RAY_LOG(DEBUG) << "Object table lookup callback";
|
||||
RAY_CHECK(reply->type == REDIS_REPLY_NIL || reply->type == REDIS_REPLY_ARRAY);
|
||||
|
||||
object_table_lookup_done_callback done_callback =
|
||||
(object_table_lookup_done_callback) callback_data->done_callback;
|
||||
@@ -671,7 +671,7 @@ void redis_object_table_lookup_callback(redisAsyncContext *c,
|
||||
std::vector<DBClientID> manager_ids;
|
||||
|
||||
for (size_t j = 0; j < reply->elements; ++j) {
|
||||
CHECK(reply->element[j]->type == REDIS_REPLY_STRING);
|
||||
RAY_CHECK(reply->element[j]->type == REDIS_REPLY_STRING);
|
||||
DBClientID manager_id;
|
||||
memcpy(manager_id.mutable_data(), reply->element[j]->str,
|
||||
sizeof(manager_id));
|
||||
@@ -682,7 +682,7 @@ void redis_object_table_lookup_callback(redisAsyncContext *c,
|
||||
done_callback(obj_id, false, manager_ids, callback_data->user_context);
|
||||
}
|
||||
} else {
|
||||
LOG_FATAL("Unexpected reply type from object table lookup.");
|
||||
RAY_LOG(FATAL) << "Unexpected reply type from object table lookup.";
|
||||
}
|
||||
|
||||
/* Clean up timer and callback. */
|
||||
@@ -708,11 +708,11 @@ void object_table_redis_subscribe_to_notifications_callback(
|
||||
* - reply->emement[2]->str is the contents of the message.
|
||||
*/
|
||||
redisReply *reply = (redisReply *) r;
|
||||
CHECK(reply->type == REDIS_REPLY_ARRAY);
|
||||
CHECK(reply->elements == 3);
|
||||
RAY_CHECK(reply->type == REDIS_REPLY_ARRAY);
|
||||
RAY_CHECK(reply->elements == 3);
|
||||
redisReply *message_type = reply->element[0];
|
||||
LOG_DEBUG("Object table subscribe to notifications callback, message %s",
|
||||
message_type->str);
|
||||
RAY_LOG(DEBUG) << "Object table subscribe to notifications callback, message"
|
||||
<< message_type->str;
|
||||
|
||||
if (strcmp(message_type->str, "message") == 0) {
|
||||
/* We received an object notification. Parse the payload. */
|
||||
@@ -752,8 +752,8 @@ void object_table_redis_subscribe_to_notifications_callback(
|
||||
* destroy the callback data. */
|
||||
remove_timer_callback(db->loop, callback_data);
|
||||
} else {
|
||||
LOG_FATAL(
|
||||
"Unexpected reply type from object table subscribe to notifications.");
|
||||
RAY_LOG(FATAL) << "Unexpected reply type from object table subscribe to "
|
||||
<< "notifications.";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -770,8 +770,8 @@ void redis_object_table_subscribe_to_notifications(
|
||||
* as the channel name so this channel is specific to this client.
|
||||
* TODO(rkn):
|
||||
* The channel name should probably be the client ID with some prefix. */
|
||||
CHECKM(callback_data->data->Get() != NULL,
|
||||
"Object table subscribe data passed as NULL.");
|
||||
RAY_CHECK(callback_data->data->Get() != NULL)
|
||||
<< "Object table subscribe data passed as NULL.";
|
||||
if (((ObjectTableSubscribeData *) (callback_data->data->Get()))
|
||||
->subscribe_all) {
|
||||
/* Subscribe to the object broadcast channel. */
|
||||
@@ -802,9 +802,9 @@ void redis_object_table_request_notifications_callback(redisAsyncContext *c,
|
||||
|
||||
/* Do some minimal checking. */
|
||||
redisReply *reply = (redisReply *) r;
|
||||
CHECKM(reply->type != REDIS_REPLY_ERROR, "reply->str is %s", reply->str);
|
||||
CHECKM(strcmp(reply->str, "OK") == 0, "reply->str is %s", reply->str);
|
||||
CHECK(callback_data->done_callback == NULL);
|
||||
RAY_CHECK(reply->type != REDIS_REPLY_ERROR) << "reply->str is " << reply->str;
|
||||
RAY_CHECK(strcmp(reply->str, "OK") == 0) << "reply->str is " << reply->str;
|
||||
RAY_CHECK(callback_data->done_callback == NULL);
|
||||
/* Clean up the timer and callback. */
|
||||
destroy_timer_callback(db->loop, callback_data);
|
||||
}
|
||||
@@ -876,7 +876,7 @@ void redis_task_table_get_task_callback(redisAsyncContext *c,
|
||||
|
||||
void redis_task_table_get_task(TableCallbackData *callback_data) {
|
||||
DBHandle *db = callback_data->db_handle;
|
||||
CHECK(callback_data->data->Get() == NULL);
|
||||
RAY_CHECK(callback_data->data->Get() == NULL);
|
||||
TaskID task_id = callback_data->id;
|
||||
|
||||
redisAsyncContext *context = get_redis_context(db, task_id);
|
||||
@@ -902,15 +902,16 @@ void redis_task_table_add_task_callback(redisAsyncContext *c,
|
||||
// db_client table before retrying the add.
|
||||
if (reply->type == REDIS_REPLY_ERROR &&
|
||||
strcmp(reply->str, "No subscribers received message.") == 0) {
|
||||
LOG_WARN("No subscribers received the task_table_add message.");
|
||||
RAY_LOG(WARNING) << "No subscribers received the task_table_add message.";
|
||||
if (callback_data->retry.fail_callback != NULL) {
|
||||
callback_data->retry.fail_callback(callback_data->id,
|
||||
callback_data->user_context,
|
||||
callback_data->data->Get());
|
||||
}
|
||||
} else {
|
||||
CHECKM(reply->type != REDIS_REPLY_ERROR, "reply->str is %s", reply->str);
|
||||
CHECKM(strcmp(reply->str, "OK") == 0, "reply->str is %s", reply->str);
|
||||
RAY_CHECK(reply->type != REDIS_REPLY_ERROR) << "reply->str is "
|
||||
<< reply->str;
|
||||
RAY_CHECK(strcmp(reply->str, "OK") == 0) << "reply->str is " << reply->str;
|
||||
/* Call the done callback if there is one. */
|
||||
if (callback_data->done_callback != NULL) {
|
||||
task_table_done_callback done_callback =
|
||||
@@ -926,7 +927,7 @@ void redis_task_table_add_task_callback(redisAsyncContext *c,
|
||||
void redis_task_table_add_task(TableCallbackData *callback_data) {
|
||||
DBHandle *db = callback_data->db_handle;
|
||||
Task *task = (Task *) callback_data->data->Get();
|
||||
CHECKM(task != NULL, "NULL task passed to redis_task_table_add_task.");
|
||||
RAY_CHECK(task != NULL) << "NULL task passed to redis_task_table_add_task.";
|
||||
|
||||
TaskID task_id = Task_task_id(task);
|
||||
DBClientID local_scheduler_id = Task_local_scheduler(task);
|
||||
@@ -967,15 +968,17 @@ void redis_task_table_update_callback(redisAsyncContext *c,
|
||||
// alive in the db_client table.
|
||||
if (reply->type == REDIS_REPLY_ERROR &&
|
||||
strcmp(reply->str, "No subscribers received message.") == 0) {
|
||||
LOG_WARN("No subscribers received the task_table_update message.");
|
||||
RAY_LOG(WARNING) << "No subscribers received the task_table_update "
|
||||
<< "message.";
|
||||
if (callback_data->retry.fail_callback != NULL) {
|
||||
callback_data->retry.fail_callback(callback_data->id,
|
||||
callback_data->user_context,
|
||||
callback_data->data->Get());
|
||||
}
|
||||
} else {
|
||||
CHECKM(reply->type != REDIS_REPLY_ERROR, "reply->str is %s", reply->str);
|
||||
CHECKM(strcmp(reply->str, "OK") == 0, "reply->str is %s", reply->str);
|
||||
RAY_CHECK(reply->type != REDIS_REPLY_ERROR) << "reply->str is "
|
||||
<< reply->str;
|
||||
RAY_CHECK(strcmp(reply->str, "OK") == 0) << "reply->str is " << reply->str;
|
||||
|
||||
/* Call the done callback if there is one. */
|
||||
if (callback_data->done_callback != NULL) {
|
||||
@@ -992,7 +995,7 @@ void redis_task_table_update_callback(redisAsyncContext *c,
|
||||
void redis_task_table_update(TableCallbackData *callback_data) {
|
||||
DBHandle *db = callback_data->db_handle;
|
||||
Task *task = (Task *) callback_data->data->Get();
|
||||
CHECKM(task != NULL, "NULL task passed to redis_task_table_update.");
|
||||
RAY_CHECK(task != NULL) << "NULL task passed to redis_task_table_update.";
|
||||
|
||||
TaskID task_id = Task_task_id(task);
|
||||
redisAsyncContext *context = get_redis_context(db, task_id);
|
||||
@@ -1030,7 +1033,7 @@ void redis_task_table_test_and_update_callback(redisAsyncContext *c,
|
||||
* delayed when added to the task table if they are submitted to a local
|
||||
* scheduler before it receives the notification that maps the actor to a
|
||||
* local scheduler. */
|
||||
LOG_ERROR("No task found during task_table_test_and_update");
|
||||
RAY_LOG(ERROR) << "No task found during task_table_test_and_update";
|
||||
return;
|
||||
}
|
||||
/* Determine whether the update happened. */
|
||||
@@ -1091,11 +1094,11 @@ void redis_task_table_subscribe_callback(redisAsyncContext *c,
|
||||
REDIS_CALLBACK_HEADER(db, callback_data, r);
|
||||
redisReply *reply = (redisReply *) r;
|
||||
|
||||
CHECK(reply->type == REDIS_REPLY_ARRAY);
|
||||
RAY_CHECK(reply->type == REDIS_REPLY_ARRAY);
|
||||
/* The number of elements is 3 for a reply to SUBSCRIBE, and 4 for a reply to
|
||||
* PSUBSCRIBE. */
|
||||
CHECKM(reply->elements == 3 || reply->elements == 4, "reply->elements is %zu",
|
||||
reply->elements);
|
||||
RAY_CHECK(reply->elements == 3 || reply->elements == 4)
|
||||
<< "reply->elements is " << reply->elements;
|
||||
/* The first element is the message type and the last entry is the payload.
|
||||
* The middle one or middle two elements describe the channel that was
|
||||
* published on. */
|
||||
@@ -1148,9 +1151,8 @@ void redis_task_table_subscribe_callback(redisAsyncContext *c,
|
||||
* subscription callback needs this data. */
|
||||
remove_timer_callback(db->loop, callback_data);
|
||||
} else {
|
||||
LOG_FATAL(
|
||||
"Unexpected reply type from task table subscribe. Message type is %s.",
|
||||
message_type->str);
|
||||
RAY_LOG(FATAL) << "Unexpected reply type from task table subscribe. "
|
||||
<< "Message type is " << message_type->str;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1200,8 +1202,8 @@ void redis_db_client_table_remove_callback(redisAsyncContext *c,
|
||||
REDIS_CALLBACK_HEADER(db, callback_data, r);
|
||||
redisReply *reply = (redisReply *) r;
|
||||
|
||||
CHECKM(reply->type != REDIS_REPLY_ERROR, "reply->str is %s", reply->str);
|
||||
CHECKM(strcmp(reply->str, "OK") == 0, "reply->str is %s", reply->str);
|
||||
RAY_CHECK(reply->type != REDIS_REPLY_ERROR) << "reply->str is " << reply->str;
|
||||
RAY_CHECK(strcmp(reply->str, "OK") == 0) << "reply->str is " << reply->str;
|
||||
|
||||
/* Call the done callback if there is one. */
|
||||
db_client_table_done_callback done_callback =
|
||||
@@ -1235,7 +1237,7 @@ void redis_db_client_table_scan(DBHandle *db,
|
||||
return;
|
||||
}
|
||||
/* Get all the database client information. */
|
||||
CHECK(reply->type == REDIS_REPLY_ARRAY);
|
||||
RAY_CHECK(reply->type == REDIS_REPLY_ARRAY);
|
||||
for (size_t i = 0; i < reply->elements; ++i) {
|
||||
/* Strip the database client table prefix. */
|
||||
unsigned char *key = (unsigned char *) reply->element[i]->str;
|
||||
@@ -1255,8 +1257,8 @@ void redis_db_client_table_subscribe_callback(redisAsyncContext *c,
|
||||
REDIS_CALLBACK_HEADER(db, callback_data, r);
|
||||
redisReply *reply = (redisReply *) r;
|
||||
|
||||
CHECK(reply->type == REDIS_REPLY_ARRAY);
|
||||
CHECK(reply->elements > 2);
|
||||
RAY_CHECK(reply->type == REDIS_REPLY_ARRAY);
|
||||
RAY_CHECK(reply->elements > 2);
|
||||
/* First entry is message type, then possibly the regex we psubscribed to,
|
||||
* then topic, then payload. */
|
||||
redisReply *payload = reply->element[reply->elements - 1];
|
||||
@@ -1323,11 +1325,11 @@ void redis_local_scheduler_table_subscribe_callback(redisAsyncContext *c,
|
||||
REDIS_CALLBACK_HEADER(db, callback_data, r);
|
||||
|
||||
redisReply *reply = (redisReply *) r;
|
||||
CHECK(reply->type == REDIS_REPLY_ARRAY);
|
||||
CHECK(reply->elements == 3);
|
||||
RAY_CHECK(reply->type == REDIS_REPLY_ARRAY);
|
||||
RAY_CHECK(reply->elements == 3);
|
||||
redisReply *message_type = reply->element[0];
|
||||
LOG_DEBUG("Local scheduler table subscribe callback, message %s",
|
||||
message_type->str);
|
||||
RAY_LOG(DEBUG) << "Local scheduler table subscribe callback, message "
|
||||
<< message_type->str;
|
||||
|
||||
if (strcmp(message_type->str, "message") == 0) {
|
||||
/* Handle a local scheduler heartbeat. Parse the payload and call the
|
||||
@@ -1362,13 +1364,13 @@ void redis_local_scheduler_table_subscribe_callback(redisAsyncContext *c,
|
||||
}
|
||||
} else if (strcmp(message_type->str, "subscribe") == 0) {
|
||||
/* The reply for the initial SUBSCRIBE command. */
|
||||
CHECK(callback_data->done_callback == NULL);
|
||||
RAY_CHECK(callback_data->done_callback == NULL);
|
||||
/* If the initial SUBSCRIBE was successful, clean up the timer, but don't
|
||||
* destroy the callback data. */
|
||||
remove_timer_callback(db->loop, callback_data);
|
||||
|
||||
} else {
|
||||
LOG_FATAL("Unexpected reply type from local scheduler subscribe.");
|
||||
RAY_LOG(FATAL) << "Unexpected reply type from local scheduler subscribe.";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1389,10 +1391,10 @@ void redis_local_scheduler_table_send_info_callback(redisAsyncContext *c,
|
||||
REDIS_CALLBACK_HEADER(db, callback_data, r);
|
||||
|
||||
redisReply *reply = (redisReply *) r;
|
||||
CHECK(reply->type == REDIS_REPLY_INTEGER);
|
||||
LOG_DEBUG("%lld subscribers received this publish.\n", reply->integer);
|
||||
RAY_CHECK(reply->type == REDIS_REPLY_INTEGER);
|
||||
RAY_LOG(DEBUG) << reply->integer << " subscribers received this publish.";
|
||||
|
||||
CHECK(callback_data->done_callback == NULL);
|
||||
RAY_CHECK(callback_data->done_callback == NULL);
|
||||
/* Clean up the timer and callback. */
|
||||
destroy_timer_callback(db->loop, callback_data);
|
||||
}
|
||||
@@ -1430,9 +1432,9 @@ void redis_local_scheduler_table_disconnect(DBHandle *db) {
|
||||
redisReply *reply = (redisReply *) redisCommand(
|
||||
db->sync_context, "PUBLISH local_schedulers %b", fbb.GetBufferPointer(),
|
||||
(size_t) fbb.GetSize());
|
||||
CHECKM(reply->type != REDIS_REPLY_ERROR, "reply->str is %s", reply->str);
|
||||
CHECK(reply->type == REDIS_REPLY_INTEGER);
|
||||
LOG_DEBUG("%lld subscribers received this publish.\n", reply->integer);
|
||||
RAY_CHECK(reply->type != REDIS_REPLY_ERROR) << "reply->str is " << reply->str;
|
||||
RAY_CHECK(reply->type == REDIS_REPLY_INTEGER);
|
||||
RAY_LOG(DEBUG) << reply->integer << " subscribers received this publish.";
|
||||
freeReplyObject(reply);
|
||||
}
|
||||
|
||||
@@ -1442,10 +1444,11 @@ void redis_driver_table_subscribe_callback(redisAsyncContext *c,
|
||||
REDIS_CALLBACK_HEADER(db, callback_data, r);
|
||||
|
||||
redisReply *reply = (redisReply *) r;
|
||||
CHECK(reply->type == REDIS_REPLY_ARRAY);
|
||||
CHECK(reply->elements == 3);
|
||||
RAY_CHECK(reply->type == REDIS_REPLY_ARRAY);
|
||||
RAY_CHECK(reply->elements == 3);
|
||||
redisReply *message_type = reply->element[0];
|
||||
LOG_DEBUG("Driver table subscribe callback, message %s", message_type->str);
|
||||
RAY_LOG(DEBUG) << "Driver table subscribe callback, message "
|
||||
<< message_type->str;
|
||||
|
||||
if (strcmp(message_type->str, "message") == 0) {
|
||||
/* Handle a driver heartbeat. Parse the payload and call the subscribe
|
||||
@@ -1463,13 +1466,13 @@ void redis_driver_table_subscribe_callback(redisAsyncContext *c,
|
||||
}
|
||||
} else if (strcmp(message_type->str, "subscribe") == 0) {
|
||||
/* The reply for the initial SUBSCRIBE command. */
|
||||
CHECK(callback_data->done_callback == NULL);
|
||||
RAY_CHECK(callback_data->done_callback == NULL);
|
||||
/* If the initial SUBSCRIBE was successful, clean up the timer, but don't
|
||||
* destroy the callback data. */
|
||||
remove_timer_callback(db->loop, callback_data);
|
||||
|
||||
} else {
|
||||
LOG_FATAL("Unexpected reply type from driver subscribe.");
|
||||
RAY_LOG(FATAL) << "Unexpected reply type from driver subscribe.";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1490,13 +1493,13 @@ void redis_driver_table_send_driver_death_callback(redisAsyncContext *c,
|
||||
REDIS_CALLBACK_HEADER(db, callback_data, r);
|
||||
|
||||
redisReply *reply = (redisReply *) r;
|
||||
CHECK(reply->type == REDIS_REPLY_INTEGER);
|
||||
LOG_DEBUG("%lld subscribers received this publish.\n", reply->integer);
|
||||
RAY_CHECK(reply->type == REDIS_REPLY_INTEGER);
|
||||
RAY_LOG(DEBUG) << reply->integer << " subscribers received this publish.";
|
||||
/* At the very least, the local scheduler that publishes this message should
|
||||
* also receive it. */
|
||||
CHECK(reply->integer >= 1);
|
||||
RAY_CHECK(reply->integer >= 1);
|
||||
|
||||
CHECK(callback_data->done_callback == NULL);
|
||||
RAY_CHECK(callback_data->done_callback == NULL);
|
||||
/* Clean up the timer and callback. */
|
||||
destroy_timer_callback(db->loop, callback_data);
|
||||
}
|
||||
@@ -1544,11 +1547,11 @@ void redis_actor_notification_table_subscribe_callback(redisAsyncContext *c,
|
||||
REDIS_CALLBACK_HEADER(db, callback_data, r);
|
||||
|
||||
redisReply *reply = (redisReply *) r;
|
||||
CHECK(reply->type == REDIS_REPLY_ARRAY);
|
||||
CHECK(reply->elements == 3);
|
||||
RAY_CHECK(reply->type == REDIS_REPLY_ARRAY);
|
||||
RAY_CHECK(reply->elements == 3);
|
||||
redisReply *message_type = reply->element[0];
|
||||
LOG_DEBUG("Local scheduler table subscribe callback, message %s",
|
||||
message_type->str);
|
||||
RAY_LOG(DEBUG) << "Local scheduler table subscribe callback, message "
|
||||
<< message_type->str;
|
||||
|
||||
if (strcmp(message_type->str, "message") == 0) {
|
||||
/* Handle an actor notification message. Parse the payload and call the
|
||||
@@ -1561,9 +1564,9 @@ void redis_actor_notification_table_subscribe_callback(redisAsyncContext *c,
|
||||
WorkerID driver_id;
|
||||
DBClientID local_scheduler_id;
|
||||
bool reconstruct;
|
||||
CHECK(sizeof(actor_id) + sizeof(driver_id) + sizeof(local_scheduler_id) +
|
||||
1 ==
|
||||
payload->len);
|
||||
RAY_CHECK(sizeof(actor_id) + sizeof(driver_id) +
|
||||
sizeof(local_scheduler_id) + 1 ==
|
||||
payload->len);
|
||||
char *current_ptr = payload->str;
|
||||
/* Parse the actor ID. */
|
||||
memcpy(&actor_id, current_ptr, sizeof(actor_id));
|
||||
@@ -1580,7 +1583,8 @@ void redis_actor_notification_table_subscribe_callback(redisAsyncContext *c,
|
||||
} else if (*current_ptr == '0') {
|
||||
reconstruct = false;
|
||||
} else {
|
||||
LOG_FATAL("This code should be unreachable.");
|
||||
reconstruct = false; // We set this value to avoid a compiler warning.
|
||||
RAY_LOG(FATAL) << "This code should be unreachable.";
|
||||
}
|
||||
current_ptr += 1;
|
||||
|
||||
@@ -1590,13 +1594,14 @@ void redis_actor_notification_table_subscribe_callback(redisAsyncContext *c,
|
||||
}
|
||||
} else if (strcmp(message_type->str, "subscribe") == 0) {
|
||||
/* The reply for the initial SUBSCRIBE command. */
|
||||
CHECK(callback_data->done_callback == NULL);
|
||||
RAY_CHECK(callback_data->done_callback == NULL);
|
||||
/* If the initial SUBSCRIBE was successful, clean up the timer, but don't
|
||||
* destroy the callback data. */
|
||||
remove_timer_callback(db->loop, callback_data);
|
||||
|
||||
} else {
|
||||
LOG_FATAL("Unexpected reply type from actor notification subscribe.");
|
||||
RAY_LOG(FATAL) << "Unexpected reply type from actor notification "
|
||||
<< "subscribe.";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1627,7 +1632,7 @@ void redis_push_error_rpush_callback(redisAsyncContext *c,
|
||||
REDIS_CALLBACK_HEADER(db, callback_data, r);
|
||||
redisReply *reply = (redisReply *) r;
|
||||
/* The reply should be the length of the errors list after our RPUSH. */
|
||||
CHECK(reply->type == REDIS_REPLY_INTEGER);
|
||||
RAY_CHECK(reply->type == REDIS_REPLY_INTEGER);
|
||||
destroy_timer_callback(db->loop, callback_data);
|
||||
}
|
||||
|
||||
@@ -1638,8 +1643,8 @@ void redis_push_error_hmset_callback(redisAsyncContext *c,
|
||||
redisReply *reply = (redisReply *) r;
|
||||
|
||||
/* Make sure we were able to add the error information. */
|
||||
CHECKM(reply->type != REDIS_REPLY_ERROR, "reply->str is %s", reply->str);
|
||||
CHECKM(strcmp(reply->str, "OK") == 0, "reply->str is %s", reply->str);
|
||||
RAY_CHECK(reply->type != REDIS_REPLY_ERROR) << "reply->str is " << reply->str;
|
||||
RAY_CHECK(strcmp(reply->str, "OK") == 0) << "reply->str is " << reply->str;
|
||||
|
||||
/* Add the error to this driver's list of errors. */
|
||||
ErrorInfo *info = (ErrorInfo *) callback_data->data->Get();
|
||||
@@ -1656,7 +1661,7 @@ void redis_push_error_hmset_callback(redisAsyncContext *c,
|
||||
void redis_push_error(TableCallbackData *callback_data) {
|
||||
DBHandle *db = callback_data->db_handle;
|
||||
ErrorInfo *info = (ErrorInfo *) callback_data->data->Get();
|
||||
CHECK(info->error_index < MAX_ERROR_INDEX && info->error_index >= 0);
|
||||
RAY_CHECK(info->error_index < MAX_ERROR_INDEX && info->error_index >= 0);
|
||||
/* Look up the error type. */
|
||||
const char *error_type = error_types[info->error_index];
|
||||
const char *error_message = error_messages[info->error_index];
|
||||
@@ -1674,6 +1679,6 @@ void redis_push_error(TableCallbackData *callback_data) {
|
||||
}
|
||||
|
||||
DBClientID get_db_client_id(DBHandle *db) {
|
||||
CHECK(db != NULL);
|
||||
RAY_CHECK(db != NULL);
|
||||
return db->client;
|
||||
}
|
||||
|
||||
@@ -11,11 +11,13 @@
|
||||
#include "hiredis/hiredis.h"
|
||||
#include "hiredis/async.h"
|
||||
|
||||
#define LOG_REDIS_ERROR(context, M, ...) \
|
||||
LOG_ERROR("Redis error %d %s; %s", context->err, context->errstr, M)
|
||||
#define LOG_REDIS_ERROR(context, M, ...) \
|
||||
RAY_LOG(ERROR) << "Redis error " << context->err << " " << context->errstr \
|
||||
<< "; " << M
|
||||
|
||||
#define LOG_REDIS_DEBUG(context, M, ...) \
|
||||
LOG_DEBUG("Redis error %d %s; %s", context->err, context->errstr, M)
|
||||
#define LOG_REDIS_DEBUG(context, M, ...) \
|
||||
RAY_LOG(DEBUG) << "Redis error " << context->err << " " << context->errstr \
|
||||
<< "; " << M;
|
||||
|
||||
struct DBHandle {
|
||||
/** String that identifies this client type. */
|
||||
|
||||
+17
-17
@@ -43,18 +43,18 @@ TableCallbackData *init_table_callback(DBHandle *db_handle,
|
||||
table_done_callback done_callback,
|
||||
table_retry_callback retry_callback,
|
||||
void *user_context) {
|
||||
CHECK(db_handle);
|
||||
CHECK(db_handle->loop);
|
||||
CHECK(data);
|
||||
RAY_CHECK(db_handle);
|
||||
RAY_CHECK(db_handle->loop);
|
||||
RAY_CHECK(data);
|
||||
/* If no retry info is provided, use the default retry info. */
|
||||
if (retry == NULL) {
|
||||
retry = (RetryInfo *) &default_retry;
|
||||
}
|
||||
CHECK(retry);
|
||||
RAY_CHECK(retry);
|
||||
/* Allocate and initialize callback data structure for object table */
|
||||
TableCallbackData *callback_data =
|
||||
(TableCallbackData *) malloc(sizeof(TableCallbackData));
|
||||
CHECKM(callback_data != NULL, "Memory allocation error!")
|
||||
RAY_CHECK(callback_data != NULL) << "Memory allocation error!";
|
||||
callback_data->id = id;
|
||||
callback_data->label = label;
|
||||
callback_data->retry = *retry;
|
||||
@@ -70,8 +70,8 @@ TableCallbackData *init_table_callback(DBHandle *db_handle,
|
||||
callback_data->timer_id = callback_data_id++;
|
||||
outstanding_callbacks_add(callback_data);
|
||||
|
||||
LOG_DEBUG("Initializing table command %s with timer ID %" PRId64,
|
||||
callback_data->label, callback_data->timer_id);
|
||||
RAY_LOG(DEBUG) << "Initializing table command " << callback_data->label
|
||||
<< " with timer ID " << callback_data->timer_id;
|
||||
callback_data->retry_callback(callback_data);
|
||||
|
||||
return callback_data;
|
||||
@@ -92,12 +92,12 @@ void remove_timer_callback(event_loop *loop, TableCallbackData *callback_data) {
|
||||
}
|
||||
|
||||
void destroy_table_callback(TableCallbackData *callback_data) {
|
||||
CHECK(callback_data != NULL);
|
||||
RAY_CHECK(callback_data != NULL);
|
||||
|
||||
if (callback_data->requests_info)
|
||||
free(callback_data->requests_info);
|
||||
|
||||
CHECK(callback_data->data != NULL);
|
||||
RAY_CHECK(callback_data->data != NULL);
|
||||
delete callback_data->data;
|
||||
callback_data->data = NULL;
|
||||
|
||||
@@ -110,20 +110,20 @@ void destroy_table_callback(TableCallbackData *callback_data) {
|
||||
int64_t table_timeout_handler(event_loop *loop,
|
||||
int64_t timer_id,
|
||||
void *user_context) {
|
||||
CHECK(loop != NULL);
|
||||
CHECK(user_context != NULL);
|
||||
RAY_CHECK(loop != NULL);
|
||||
RAY_CHECK(user_context != NULL);
|
||||
TableCallbackData *callback_data = (TableCallbackData *) user_context;
|
||||
|
||||
CHECK(callback_data->retry.num_retries >= 0 ||
|
||||
callback_data->retry.num_retries == -1);
|
||||
LOG_WARN("retrying operation %s, retry_count = %d", callback_data->label,
|
||||
callback_data->retry.num_retries);
|
||||
RAY_CHECK(callback_data->retry.num_retries >= 0 ||
|
||||
callback_data->retry.num_retries == -1);
|
||||
RAY_LOG(WARNING) << "retrying operation " << callback_data->label
|
||||
<< ", retry_count = " << callback_data->retry.num_retries;
|
||||
|
||||
if (callback_data->retry.num_retries == 0) {
|
||||
/* We didn't get a response from the database after exhausting all retries;
|
||||
* let user know, cleanup the state, and remove the timer. */
|
||||
LOG_WARN("Table command %s with timer ID %" PRId64 " failed",
|
||||
callback_data->label, timer_id);
|
||||
RAY_LOG(WARNING) << "Table command " << callback_data->label
|
||||
<< " with timer ID " << timer_id << " failed";
|
||||
if (callback_data->retry.fail_callback) {
|
||||
callback_data->retry.fail_callback(callback_data->id,
|
||||
callback_data->user_context,
|
||||
|
||||
+24
-24
@@ -80,7 +80,7 @@ class TaskBuilder {
|
||||
}
|
||||
|
||||
void SetRequiredResource(const std::string &resource_name, double value) {
|
||||
CHECK(resource_map_.count(resource_name) == 0);
|
||||
RAY_CHECK(resource_map_.count(resource_name) == 0);
|
||||
resource_map_[resource_name] = value;
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ class TaskBuilder {
|
||||
BYTE buff[DIGEST_SIZE];
|
||||
sha256_final(&ctx, buff);
|
||||
TaskID task_id;
|
||||
CHECK(sizeof(task_id) <= DIGEST_SIZE);
|
||||
RAY_CHECK(sizeof(task_id) <= DIGEST_SIZE);
|
||||
memcpy(&task_id, buff, sizeof(task_id));
|
||||
/* Add return object IDs. */
|
||||
std::vector<flatbuffers::Offset<flatbuffers::String>> returns;
|
||||
@@ -206,25 +206,25 @@ void TaskSpec_set_required_resource(TaskBuilder *builder,
|
||||
/* Functions for reading tasks. */
|
||||
|
||||
TaskID TaskSpec_task_id(const TaskSpec *spec) {
|
||||
CHECK(spec);
|
||||
RAY_CHECK(spec);
|
||||
auto message = flatbuffers::GetRoot<TaskInfo>(spec);
|
||||
return from_flatbuf(*message->task_id());
|
||||
}
|
||||
|
||||
FunctionID TaskSpec_function(TaskSpec *spec) {
|
||||
CHECK(spec);
|
||||
RAY_CHECK(spec);
|
||||
auto message = flatbuffers::GetRoot<TaskInfo>(spec);
|
||||
return from_flatbuf(*message->function_id());
|
||||
}
|
||||
|
||||
ActorID TaskSpec_actor_id(TaskSpec *spec) {
|
||||
CHECK(spec);
|
||||
RAY_CHECK(spec);
|
||||
auto message = flatbuffers::GetRoot<TaskInfo>(spec);
|
||||
return from_flatbuf(*message->actor_id());
|
||||
}
|
||||
|
||||
ActorID TaskSpec_actor_handle_id(TaskSpec *spec) {
|
||||
CHECK(spec);
|
||||
RAY_CHECK(spec);
|
||||
auto message = flatbuffers::GetRoot<TaskInfo>(spec);
|
||||
return from_flatbuf(*message->actor_handle_id());
|
||||
}
|
||||
@@ -234,19 +234,19 @@ bool TaskSpec_is_actor_task(TaskSpec *spec) {
|
||||
}
|
||||
|
||||
int64_t TaskSpec_actor_counter(TaskSpec *spec) {
|
||||
CHECK(spec);
|
||||
RAY_CHECK(spec);
|
||||
auto message = flatbuffers::GetRoot<TaskInfo>(spec);
|
||||
return std::abs(message->actor_counter());
|
||||
}
|
||||
|
||||
bool TaskSpec_is_actor_checkpoint_method(TaskSpec *spec) {
|
||||
CHECK(spec);
|
||||
RAY_CHECK(spec);
|
||||
auto message = flatbuffers::GetRoot<TaskInfo>(spec);
|
||||
return message->is_actor_checkpoint_method();
|
||||
}
|
||||
|
||||
ObjectID TaskSpec_actor_dummy_object(TaskSpec *spec) {
|
||||
CHECK(TaskSpec_is_actor_task(spec));
|
||||
RAY_CHECK(TaskSpec_is_actor_task(spec));
|
||||
/* The last return value for actor tasks is the dummy object that
|
||||
* represents that this task has completed execution. */
|
||||
int64_t num_returns = TaskSpec_num_returns(spec);
|
||||
@@ -254,25 +254,25 @@ ObjectID TaskSpec_actor_dummy_object(TaskSpec *spec) {
|
||||
}
|
||||
|
||||
UniqueID TaskSpec_driver_id(const TaskSpec *spec) {
|
||||
CHECK(spec);
|
||||
RAY_CHECK(spec);
|
||||
auto message = flatbuffers::GetRoot<TaskInfo>(spec);
|
||||
return from_flatbuf(*message->driver_id());
|
||||
}
|
||||
|
||||
TaskID TaskSpec_parent_task_id(const TaskSpec *spec) {
|
||||
CHECK(spec);
|
||||
RAY_CHECK(spec);
|
||||
auto message = flatbuffers::GetRoot<TaskInfo>(spec);
|
||||
return from_flatbuf(*message->parent_task_id());
|
||||
}
|
||||
|
||||
int64_t TaskSpec_parent_counter(TaskSpec *spec) {
|
||||
CHECK(spec);
|
||||
RAY_CHECK(spec);
|
||||
auto message = flatbuffers::GetRoot<TaskInfo>(spec);
|
||||
return message->parent_counter();
|
||||
}
|
||||
|
||||
int64_t TaskSpec_num_args(TaskSpec *spec) {
|
||||
CHECK(spec);
|
||||
RAY_CHECK(spec);
|
||||
auto message = flatbuffers::GetRoot<TaskInfo>(spec);
|
||||
return message->args()->size();
|
||||
}
|
||||
@@ -289,45 +289,45 @@ int64_t TaskSpec_num_args_by_ref(TaskSpec *spec) {
|
||||
}
|
||||
|
||||
int TaskSpec_arg_id_count(TaskSpec *spec, int64_t arg_index) {
|
||||
CHECK(spec);
|
||||
RAY_CHECK(spec);
|
||||
auto message = flatbuffers::GetRoot<TaskInfo>(spec);
|
||||
auto ids = message->args()->Get(arg_index)->object_ids();
|
||||
return ids->size();
|
||||
}
|
||||
|
||||
ObjectID TaskSpec_arg_id(TaskSpec *spec, int64_t arg_index, int64_t id_index) {
|
||||
CHECK(spec);
|
||||
RAY_CHECK(spec);
|
||||
auto message = flatbuffers::GetRoot<TaskInfo>(spec);
|
||||
return from_flatbuf(
|
||||
*message->args()->Get(arg_index)->object_ids()->Get(id_index));
|
||||
}
|
||||
|
||||
const uint8_t *TaskSpec_arg_val(TaskSpec *spec, int64_t arg_index) {
|
||||
CHECK(spec);
|
||||
RAY_CHECK(spec);
|
||||
auto message = flatbuffers::GetRoot<TaskInfo>(spec);
|
||||
return (uint8_t *) message->args()->Get(arg_index)->data()->c_str();
|
||||
}
|
||||
|
||||
int64_t TaskSpec_arg_length(TaskSpec *spec, int64_t arg_index) {
|
||||
CHECK(spec);
|
||||
RAY_CHECK(spec);
|
||||
auto message = flatbuffers::GetRoot<TaskInfo>(spec);
|
||||
return message->args()->Get(arg_index)->data()->size();
|
||||
}
|
||||
|
||||
int64_t TaskSpec_num_returns(TaskSpec *spec) {
|
||||
CHECK(spec);
|
||||
RAY_CHECK(spec);
|
||||
auto message = flatbuffers::GetRoot<TaskInfo>(spec);
|
||||
return message->returns()->size();
|
||||
}
|
||||
|
||||
bool TaskSpec_arg_by_ref(TaskSpec *spec, int64_t arg_index) {
|
||||
CHECK(spec);
|
||||
RAY_CHECK(spec);
|
||||
auto message = flatbuffers::GetRoot<TaskInfo>(spec);
|
||||
return message->args()->Get(arg_index)->object_ids()->size() != 0;
|
||||
}
|
||||
|
||||
ObjectID TaskSpec_return(TaskSpec *spec, int64_t return_index) {
|
||||
CHECK(spec);
|
||||
RAY_CHECK(spec);
|
||||
auto message = flatbuffers::GetRoot<TaskInfo>(spec);
|
||||
return from_flatbuf(*message->returns()->Get(return_index));
|
||||
}
|
||||
@@ -336,7 +336,7 @@ double TaskSpec_get_required_resource(const TaskSpec *spec,
|
||||
const std::string &resource_name) {
|
||||
// This is a bit ugly. However it shouldn't be much of a performance issue
|
||||
// because there shouldn't be many distinct resources in a single task spec.
|
||||
CHECK(spec);
|
||||
RAY_CHECK(spec);
|
||||
auto message = flatbuffers::GetRoot<TaskInfo>(spec);
|
||||
for (size_t i = 0; i < message->required_resources()->size(); i++) {
|
||||
const ResourcePair *resource_pair = message->required_resources()->Get(i);
|
||||
@@ -349,7 +349,7 @@ double TaskSpec_get_required_resource(const TaskSpec *spec,
|
||||
|
||||
const std::unordered_map<std::string, double> TaskSpec_get_required_resources(
|
||||
const TaskSpec *spec) {
|
||||
CHECK(spec);
|
||||
RAY_CHECK(spec);
|
||||
auto message = flatbuffers::GetRoot<TaskInfo>(spec);
|
||||
return map_from_flatbuf(*message->required_resources());
|
||||
}
|
||||
@@ -446,7 +446,7 @@ int TaskExecutionSpec::DependencyIdCount(int64_t dependency_index) const {
|
||||
} else {
|
||||
/* Index into the execution dependencies. */
|
||||
dependency_index -= num_args;
|
||||
CHECK((size_t) dependency_index < execution_dependencies_.size());
|
||||
RAY_CHECK((size_t) dependency_index < execution_dependencies_.size());
|
||||
/* All elements in the execution dependency list have exactly one ID. */
|
||||
return 1;
|
||||
}
|
||||
@@ -465,7 +465,7 @@ ObjectID TaskExecutionSpec::DependencyId(int64_t dependency_index,
|
||||
} else {
|
||||
/* Index into the execution dependencies. */
|
||||
dependency_index -= num_args;
|
||||
CHECK((size_t) dependency_index < execution_dependencies_.size());
|
||||
RAY_CHECK((size_t) dependency_index < execution_dependencies_.size());
|
||||
return execution_dependencies_[dependency_index];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,13 +42,13 @@ void lookup_done_callback(ObjectID object_id,
|
||||
const std::vector<DBClientID> &manager_ids,
|
||||
void *user_context) {
|
||||
DBHandle *db = (DBHandle *) user_context;
|
||||
CHECK(manager_ids.size() == 2);
|
||||
RAY_CHECK(manager_ids.size() == 2);
|
||||
const std::vector<std::string> managers =
|
||||
db_client_table_get_ip_addresses(db, manager_ids);
|
||||
CHECK(parse_ip_addr_port(managers.at(0).c_str(), received_addr1,
|
||||
&received_port1) == 0);
|
||||
CHECK(parse_ip_addr_port(managers.at(1).c_str(), received_addr2,
|
||||
&received_port2) == 0);
|
||||
RAY_CHECK(parse_ip_addr_port(managers.at(0).c_str(), received_addr1,
|
||||
&received_port1) == 0);
|
||||
RAY_CHECK(parse_ip_addr_port(managers.at(1).c_str(), received_addr2,
|
||||
&received_port2) == 0);
|
||||
}
|
||||
|
||||
/* Entry added to database successfully. */
|
||||
@@ -57,7 +57,7 @@ void add_done_callback(ObjectID object_id, bool success, void *user_context) {}
|
||||
/* Test if we got a timeout callback if we couldn't connect database. */
|
||||
void timeout_callback(ObjectID object_id, void *context, void *user_data) {
|
||||
user_context *uc = (user_context *) context;
|
||||
CHECK(uc->test_number == TEST_NUMBER)
|
||||
RAY_CHECK(uc->test_number == TEST_NUMBER);
|
||||
}
|
||||
|
||||
int64_t timeout_handler(event_loop *loop, int64_t id, void *context) {
|
||||
@@ -136,9 +136,9 @@ int64_t task_table_delayed_add_task(event_loop *loop,
|
||||
|
||||
void task_table_test_callback(Task *callback_task, void *user_data) {
|
||||
task_table_test_callback_called = 1;
|
||||
CHECK(Task_state(callback_task) == TASK_STATUS_SCHEDULED);
|
||||
CHECK(Task_size(callback_task) == Task_size(task_table_test_task));
|
||||
CHECK(Task_equals(callback_task, task_table_test_task));
|
||||
RAY_CHECK(Task_state(callback_task) == TASK_STATUS_SCHEDULED);
|
||||
RAY_CHECK(Task_size(callback_task) == Task_size(task_table_test_task));
|
||||
RAY_CHECK(Task_equals(callback_task, task_table_test_task));
|
||||
event_loop *loop = (event_loop *) user_data;
|
||||
event_loop_stop(loop);
|
||||
}
|
||||
|
||||
@@ -38,13 +38,13 @@ void new_object_done_callback(ObjectID object_id,
|
||||
bool is_put,
|
||||
void *user_context) {
|
||||
new_object_succeeded = 1;
|
||||
CHECK(object_id == new_object_id);
|
||||
CHECK(task_id == new_object_task_id);
|
||||
RAY_CHECK(object_id == new_object_id);
|
||||
RAY_CHECK(task_id == new_object_task_id);
|
||||
event_loop_stop(g_loop);
|
||||
}
|
||||
|
||||
void new_object_lookup_callback(ObjectID object_id, void *user_context) {
|
||||
CHECK(object_id == new_object_id);
|
||||
RAY_CHECK(object_id == new_object_id);
|
||||
RetryInfo retry = {
|
||||
.num_retries = 5,
|
||||
.timeout = 100,
|
||||
@@ -109,7 +109,7 @@ void new_object_no_task_callback(ObjectID object_id,
|
||||
bool is_put,
|
||||
void *user_context) {
|
||||
new_object_succeeded = 1;
|
||||
CHECK(task_id.is_nil());
|
||||
RAY_CHECK(task_id.is_nil());
|
||||
event_loop_stop(g_loop);
|
||||
}
|
||||
|
||||
@@ -150,12 +150,12 @@ void lookup_done_callback(ObjectID object_id,
|
||||
const std::vector<DBClientID> &manager_vector,
|
||||
void *context) {
|
||||
/* The done callback should not be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
void lookup_fail_callback(UniqueID id, void *user_context, void *user_data) {
|
||||
lookup_failed = 1;
|
||||
CHECK(user_context == (void *) lookup_timeout_context);
|
||||
RAY_CHECK(user_context == (void *) lookup_timeout_context);
|
||||
event_loop_stop(g_loop);
|
||||
}
|
||||
|
||||
@@ -189,12 +189,12 @@ int add_failed = 0;
|
||||
|
||||
void add_done_callback(ObjectID object_id, bool success, void *user_context) {
|
||||
/* The done callback should not be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
void add_fail_callback(UniqueID id, void *user_context, void *user_data) {
|
||||
add_failed = 1;
|
||||
CHECK(user_context == (void *) add_timeout_context);
|
||||
RAY_CHECK(user_context == (void *) add_timeout_context);
|
||||
event_loop_stop(g_loop);
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ void subscribe_done_callback(ObjectID object_id,
|
||||
const std::vector<DBClientID> &manager_vector,
|
||||
void *user_context) {
|
||||
/* The done callback should not be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
void subscribe_fail_callback(UniqueID id, void *user_context, void *user_data) {
|
||||
@@ -277,7 +277,7 @@ int64_t reconnect_context_callback(event_loop *loop,
|
||||
db->sync_context = redisConnect("127.0.0.1", 6379);
|
||||
/* Re-attach the database to the event loop (the file descriptor changed). */
|
||||
db_attach(db, loop, true);
|
||||
LOG_DEBUG("Reconnected to Redis");
|
||||
RAY_LOG(DEBUG) << "Reconnected to Redis";
|
||||
return EVENT_LOOP_TIMER_DONE;
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ void lookup_retry_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
/* The fail callback should not be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
/* === Test add retry === */
|
||||
@@ -312,15 +312,15 @@ void add_lookup_done_callback(ObjectID object_id,
|
||||
const std::vector<DBClientID> &manager_ids,
|
||||
void *context) {
|
||||
DBHandle *db = (DBHandle *) context;
|
||||
CHECK(manager_ids.size() == 1);
|
||||
RAY_CHECK(manager_ids.size() == 1);
|
||||
const std::vector<std::string> managers =
|
||||
db_client_table_get_ip_addresses(db, manager_ids);
|
||||
CHECK(managers.at(0) == "127.0.0.1:11235");
|
||||
RAY_CHECK(managers.at(0) == "127.0.0.1:11235");
|
||||
lookup_retry_succeeded = 1;
|
||||
}
|
||||
|
||||
void add_lookup_callback(ObjectID object_id, bool success, void *user_context) {
|
||||
CHECK(success);
|
||||
RAY_CHECK(success);
|
||||
DBHandle *db = (DBHandle *) user_context;
|
||||
RetryInfo retry = {
|
||||
.num_retries = 5,
|
||||
@@ -366,15 +366,15 @@ void add_remove_lookup_done_callback(
|
||||
bool never_created,
|
||||
const std::vector<DBClientID> &manager_vector,
|
||||
void *context) {
|
||||
CHECK(context == (void *) lookup_retry_context);
|
||||
CHECK(manager_vector.size() == 0);
|
||||
RAY_CHECK(context == (void *) lookup_retry_context);
|
||||
RAY_CHECK(manager_vector.size() == 0);
|
||||
lookup_retry_succeeded = 1;
|
||||
}
|
||||
|
||||
void add_remove_lookup_callback(ObjectID object_id,
|
||||
bool success,
|
||||
void *user_context) {
|
||||
CHECK(success);
|
||||
RAY_CHECK(success);
|
||||
DBHandle *db = (DBHandle *) user_context;
|
||||
RetryInfo retry = {
|
||||
.num_retries = 5,
|
||||
@@ -387,7 +387,7 @@ void add_remove_lookup_callback(ObjectID object_id,
|
||||
}
|
||||
|
||||
void add_remove_callback(ObjectID object_id, bool success, void *user_context) {
|
||||
CHECK(success);
|
||||
RAY_CHECK(success);
|
||||
DBHandle *db = (DBHandle *) user_context;
|
||||
RetryInfo retry = {
|
||||
.num_retries = 5,
|
||||
@@ -433,7 +433,7 @@ int lookup_late_failed = 0;
|
||||
void lookup_late_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
CHECK(user_context == (void *) lookup_late_context);
|
||||
RAY_CHECK(user_context == (void *) lookup_late_context);
|
||||
lookup_late_failed = 1;
|
||||
}
|
||||
|
||||
@@ -442,7 +442,7 @@ void lookup_late_done_callback(ObjectID object_id,
|
||||
const std::vector<DBClientID> &manager_vector,
|
||||
void *context) {
|
||||
/* This function should never be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
TEST lookup_late_test(void) {
|
||||
@@ -478,7 +478,7 @@ const char *add_late_context = "add_late";
|
||||
int add_late_failed = 0;
|
||||
|
||||
void add_late_fail_callback(UniqueID id, void *user_context, void *user_data) {
|
||||
CHECK(user_context == (void *) add_late_context);
|
||||
RAY_CHECK(user_context == (void *) add_late_context);
|
||||
add_late_failed = 1;
|
||||
}
|
||||
|
||||
@@ -486,7 +486,7 @@ void add_late_done_callback(ObjectID object_id,
|
||||
bool success,
|
||||
void *user_context) {
|
||||
/* This function should never be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
TEST add_late_test(void) {
|
||||
@@ -522,7 +522,7 @@ int subscribe_late_failed = 0;
|
||||
void subscribe_late_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
CHECK(user_context == (void *) subscribe_late_context);
|
||||
RAY_CHECK(user_context == (void *) subscribe_late_context);
|
||||
subscribe_late_failed = 1;
|
||||
}
|
||||
|
||||
@@ -531,7 +531,7 @@ void subscribe_late_done_callback(ObjectID object_id,
|
||||
const std::vector<DBClientID> &manager_vector,
|
||||
void *user_context) {
|
||||
/* This function should never be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
TEST subscribe_late_test(void) {
|
||||
@@ -573,7 +573,7 @@ void subscribe_success_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
/* This function should never be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
void subscribe_success_done_callback(
|
||||
@@ -594,9 +594,9 @@ void subscribe_success_object_available_callback(
|
||||
int64_t data_size,
|
||||
const std::vector<DBClientID> &manager_vector,
|
||||
void *user_context) {
|
||||
CHECK(user_context == (void *) subscribe_success_context);
|
||||
CHECK(object_id == subscribe_id);
|
||||
CHECK(manager_vector.size() == 1);
|
||||
RAY_CHECK(user_context == (void *) subscribe_success_context);
|
||||
RAY_CHECK(object_id == subscribe_id);
|
||||
RAY_CHECK(manager_vector.size() == 1);
|
||||
subscribe_success_succeeded = 1;
|
||||
}
|
||||
|
||||
@@ -656,15 +656,15 @@ void subscribe_object_present_object_available_callback(
|
||||
void *user_context) {
|
||||
subscribe_object_present_context_t *ctx =
|
||||
(subscribe_object_present_context_t *) user_context;
|
||||
CHECK(ctx->data_size == data_size);
|
||||
CHECK(strcmp(subscribe_object_present_str, ctx->teststr) == 0);
|
||||
RAY_CHECK(ctx->data_size == data_size);
|
||||
RAY_CHECK(strcmp(subscribe_object_present_str, ctx->teststr) == 0);
|
||||
subscribe_object_present_succeeded = 1;
|
||||
CHECK(manager_vector.size() == 1);
|
||||
RAY_CHECK(manager_vector.size() == 1);
|
||||
}
|
||||
|
||||
void fatal_fail_callback(UniqueID id, void *user_context, void *user_data) {
|
||||
/* This function should never be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
TEST subscribe_object_present_test(void) {
|
||||
@@ -723,7 +723,7 @@ void subscribe_object_not_present_object_available_callback(
|
||||
const std::vector<DBClientID> &manager_vector,
|
||||
void *user_context) {
|
||||
/* This should not be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
TEST subscribe_object_not_present_test(void) {
|
||||
@@ -773,11 +773,12 @@ void subscribe_object_available_later_object_available_callback(
|
||||
void *user_context) {
|
||||
subscribe_object_present_context_t *myctx =
|
||||
(subscribe_object_present_context_t *) user_context;
|
||||
CHECK(myctx->data_size == data_size);
|
||||
CHECK(strcmp(myctx->teststr, subscribe_object_available_later_context) == 0);
|
||||
RAY_CHECK(myctx->data_size == data_size);
|
||||
RAY_CHECK(strcmp(myctx->teststr, subscribe_object_available_later_context) ==
|
||||
0);
|
||||
/* Make sure the callback is only called once. */
|
||||
subscribe_object_available_later_succeeded += 1;
|
||||
CHECK(manager_vector.size() == 1);
|
||||
RAY_CHECK(manager_vector.size() == 1);
|
||||
}
|
||||
|
||||
TEST subscribe_object_available_later_test(void) {
|
||||
|
||||
@@ -47,10 +47,10 @@ void async_redis_socket_test_callback(redisAsyncContext *ac,
|
||||
redisReply *reply =
|
||||
(redisReply *) redisCommand(context, test_get_format, test_key);
|
||||
redisFree(context);
|
||||
CHECK(reply != NULL);
|
||||
RAY_CHECK(reply != NULL);
|
||||
if (strcmp(reply->str, test_value)) {
|
||||
freeReplyObject(reply);
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
freeReplyObject(reply);
|
||||
}
|
||||
@@ -97,7 +97,7 @@ void redis_accept_callback(event_loop *loop,
|
||||
void *context,
|
||||
int events) {
|
||||
int accept_fd = accept_client(socket_fd);
|
||||
CHECK(accept_fd >= 0);
|
||||
RAY_CHECK(accept_fd >= 0);
|
||||
connections.push_back(accept_fd);
|
||||
event_loop_add_file(loop, accept_fd, EVENT_LOOP_READ, redis_read_callback,
|
||||
context);
|
||||
@@ -155,8 +155,8 @@ void logging_test_callback(redisAsyncContext *ac, void *r, void *privdata) {
|
||||
redisContext *context = redisConnect("127.0.0.1", 6379);
|
||||
redisReply *reply = (redisReply *) redisCommand(context, "KEYS %s", "log:*");
|
||||
redisFree(context);
|
||||
CHECK(reply != NULL);
|
||||
CHECK(reply->elements > 0);
|
||||
RAY_CHECK(reply != NULL);
|
||||
RAY_CHECK(reply->elements > 0);
|
||||
freeReplyObject(reply);
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ void logging_accept_callback(event_loop *loop,
|
||||
void *context,
|
||||
int events) {
|
||||
int accept_fd = accept_client(socket_fd);
|
||||
CHECK(accept_fd >= 0);
|
||||
RAY_CHECK(accept_fd >= 0);
|
||||
connections.push_back(accept_fd);
|
||||
event_loop_add_file(loop, accept_fd, EVENT_LOOP_READ, logging_read_callback,
|
||||
context);
|
||||
|
||||
@@ -27,13 +27,13 @@ void lookup_nil_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
/* The fail callback should not be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
void lookup_nil_success_callback(Task *task, void *context) {
|
||||
lookup_nil_success = 1;
|
||||
CHECK(task == NULL);
|
||||
CHECK(context == (void *) lookup_nil_context);
|
||||
RAY_CHECK(task == NULL);
|
||||
RAY_CHECK(context == (void *) lookup_nil_context);
|
||||
event_loop_stop(g_loop);
|
||||
}
|
||||
|
||||
@@ -70,18 +70,18 @@ void add_lookup_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
/* The fail callback should not be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
void lookup_success_callback(Task *task, void *context) {
|
||||
lookup_success = 1;
|
||||
CHECK(Task_equals(task, add_lookup_task));
|
||||
RAY_CHECK(Task_equals(task, add_lookup_task));
|
||||
event_loop_stop(g_loop);
|
||||
}
|
||||
|
||||
void add_success_callback(TaskID task_id, void *context) {
|
||||
add_success = 1;
|
||||
CHECK(TaskID_equal(task_id, Task_task_id(add_lookup_task)));
|
||||
RAY_CHECK(TaskID_equal(task_id, Task_task_id(add_lookup_task)));
|
||||
|
||||
DBHandle *db = (DBHandle *) context;
|
||||
RetryInfo retry = {
|
||||
@@ -137,12 +137,12 @@ int subscribe_failed = 0;
|
||||
|
||||
void subscribe_done_callback(TaskID task_id, void *user_context) {
|
||||
/* The done callback should not be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
void subscribe_fail_callback(UniqueID id, void *user_context, void *user_data) {
|
||||
subscribe_failed = 1;
|
||||
CHECK(user_context == (void *) subscribe_timeout_context);
|
||||
RAY_CHECK(user_context == (void *) subscribe_timeout_context);
|
||||
event_loop_stop(g_loop);
|
||||
}
|
||||
|
||||
@@ -180,12 +180,12 @@ int publish_failed = 0;
|
||||
|
||||
void publish_done_callback(TaskID task_id, void *user_context) {
|
||||
/* The done callback should not be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
void publish_fail_callback(UniqueID id, void *user_context, void *user_data) {
|
||||
publish_failed = 1;
|
||||
CHECK(user_context == (void *) publish_timeout_context);
|
||||
RAY_CHECK(user_context == (void *) publish_timeout_context);
|
||||
event_loop_stop(g_loop);
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ const char *subscribe_retry_context = "subscribe_retry";
|
||||
int subscribe_retry_succeeded = 0;
|
||||
|
||||
void subscribe_retry_done_callback(ObjectID object_id, void *user_context) {
|
||||
CHECK(user_context == (void *) subscribe_retry_context);
|
||||
RAY_CHECK(user_context == (void *) subscribe_retry_context);
|
||||
subscribe_retry_succeeded = 1;
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ void subscribe_retry_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
/* The fail callback should not be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
TEST subscribe_retry_test(void) {
|
||||
@@ -299,7 +299,7 @@ const char *publish_retry_context = "publish_retry";
|
||||
int publish_retry_succeeded = 0;
|
||||
|
||||
void publish_retry_done_callback(ObjectID object_id, void *user_context) {
|
||||
CHECK(user_context == (void *) publish_retry_context);
|
||||
RAY_CHECK(user_context == (void *) publish_retry_context);
|
||||
publish_retry_succeeded = 1;
|
||||
}
|
||||
|
||||
@@ -307,7 +307,7 @@ void publish_retry_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
/* The fail callback should not be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
TEST publish_retry_test(void) {
|
||||
@@ -355,13 +355,13 @@ int subscribe_late_failed = 0;
|
||||
void subscribe_late_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
CHECK(user_context == (void *) subscribe_late_context);
|
||||
RAY_CHECK(user_context == (void *) subscribe_late_context);
|
||||
subscribe_late_failed = 1;
|
||||
}
|
||||
|
||||
void subscribe_late_done_callback(TaskID task_id, void *user_context) {
|
||||
/* This function should never be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
TEST subscribe_late_test(void) {
|
||||
@@ -400,13 +400,13 @@ int publish_late_failed = 0;
|
||||
void publish_late_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
CHECK(user_context == (void *) publish_late_context);
|
||||
RAY_CHECK(user_context == (void *) publish_late_context);
|
||||
publish_late_failed = 1;
|
||||
}
|
||||
|
||||
void publish_late_done_callback(TaskID task_id, void *user_context) {
|
||||
/* This function should never be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
TEST publish_late_test(void) {
|
||||
|
||||
@@ -22,7 +22,8 @@ static inline std::string bind_ipc_sock_retry(const char *socket_name_format,
|
||||
int *fd) {
|
||||
std::string socket_name;
|
||||
for (int num_retries = 0; num_retries < 5; ++num_retries) {
|
||||
LOG_INFO("trying to find plasma socket (attempt %d)", num_retries);
|
||||
RAY_LOG(INFO) << "trying to find plasma socket (attempt " << num_retries
|
||||
<< ")";
|
||||
size_t size = std::snprintf(nullptr, 0, socket_name_format, rand()) + 1;
|
||||
char socket_name_c_str[size];
|
||||
std::snprintf(socket_name_c_str, size, socket_name_format, rand());
|
||||
|
||||
Reference in New Issue
Block a user