Skip to content

Commit

Permalink
fix log for confict glog or collie log
Browse files Browse the repository at this point in the history
  • Loading branch information
lilothar committed Apr 24, 2024
1 parent b3d1b9b commit feaa017
Show file tree
Hide file tree
Showing 398 changed files with 4,004 additions and 4,005 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ message(STATUS ${PROJECT_NAME}_IS_TOP_PROJECT)
set(PROJECT_DESCRIPTION "Hercules is an ahead of time compiler for a subset of the Python language framework.")
set(PROJECT_VERSION_MAJOR 0)
set(PROJECT_VERSION_MINOR 5)
set(PROJECT_VERSION_PATCH 6)
set(PROJECT_VERSION_PATCH 7)
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")

set(${PROJECT_NAME}_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
Expand Down
3 changes: 1 addition & 2 deletions cmake/melon_cxx_config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -425,5 +425,4 @@ list(APPEND MELON_TEST_CXX_OPTIONS
"-Wno-invalid-offsetof"
"-Wno-unused-parameter"
"-fno-omit-frame-pointer"
)
set(CMAKE_VERBOSE_MAKEFILE ON)
)
8 changes: 4 additions & 4 deletions example/asynchronous_echo_c++/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ void HandleEchoResponse(
std::unique_ptr<example::EchoResponse> response_guard(response);

if (cntl->Failed()) {
LOG(WARNING) << "Fail to send EchoRequest, " << cntl->ErrorText();
MLOG(WARNING) << "Fail to send EchoRequest, " << cntl->ErrorText();
return;
}
LOG(INFO) << "Received response from " << cntl->remote_side()
MLOG(INFO) << "Received response from " << cntl->remote_side()
<< ": " << response->message() << " (attached="
<< cntl->response_attachment() << ")"
<< " latency=" << cntl->latency_us() << "us";
Expand All @@ -63,7 +63,7 @@ int main(int argc, char* argv[]) {
options.timeout_ms = FLAGS_timeout_ms/*milliseconds*/;
options.max_retry = FLAGS_max_retry;
if (channel.Init(FLAGS_server.c_str(), FLAGS_load_balancer.c_str(), &options) != 0) {
LOG(ERROR) << "Fail to initialize channel";
MLOG(ERROR) << "Fail to initialize channel";
return -1;
}

Expand Down Expand Up @@ -104,6 +104,6 @@ int main(int argc, char* argv[]) {
sleep(1);
}

LOG(INFO) << "EchoClient is going to quit";
MLOG(INFO) << "EchoClient is going to quit";
return 0;
}
8 changes: 4 additions & 4 deletions example/asynchronous_echo_c++/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class EchoServiceImpl : public example::EchoService {
// The purpose of following logs is to help you to understand
// how clients interact with servers more intuitively. You should
// remove these logs in performance-sensitive servers.
LOG(INFO) << "Received request[log_id=" << cntl->log_id()
MLOG(INFO) << "Received request[log_id=" << cntl->log_id()
<< "] from " << cntl->remote_side()
<< ": " << request->message()
<< " (attached=" << cntl->request_attachment() << ")";
Expand Down Expand Up @@ -79,7 +79,7 @@ class EchoServiceImpl : public example::EchoService {
std::string res_str;
json2pb::ProtoMessageToJson(*req, &req_str, NULL);
json2pb::ProtoMessageToJson(*res, &res_str, NULL);
LOG(INFO) << "req:" << req_str
MLOG(INFO) << "req:" << req_str
<< " res:" << res_str;
}
};
Expand All @@ -99,15 +99,15 @@ int main(int argc, char* argv[]) {
// use melon::SERVER_OWNS_SERVICE.
if (server.AddService(&echo_service_impl,
melon::SERVER_DOESNT_OWN_SERVICE) != 0) {
LOG(ERROR) << "Fail to add service";
MLOG(ERROR) << "Fail to add service";
return -1;
}

// Start the server.
melon::ServerOptions options;
options.idle_timeout_sec = FLAGS_idle_timeout_s;
if (server.Start(FLAGS_port, &options) != 0) {
LOG(ERROR) << "Fail to start EchoServer";
MLOG(ERROR) << "Fail to start EchoServer";
return -1;
}

Expand Down
20 changes: 10 additions & 10 deletions example/atomic/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static void* sender(void* arg) {
FLAGS_group, FLAGS_timeout_ms);
if (!st.ok()) {
// Not sure about the leader, sleep for a while and the ask again.
LOG(WARNING) << "Fail to refresh_leader : " << st;
MLOG(WARNING) << "Fail to refresh_leader : " << st;
fiber_usleep(FLAGS_timeout_ms * 1000L);
}
continue;
Expand All @@ -60,7 +60,7 @@ static void* sender(void* arg) {
// rpc
melon::Channel channel;
if (channel.Init(leader.addr, NULL) != 0) {
LOG(ERROR) << "Fail to init channel to " << leader;
MLOG(ERROR) << "Fail to init channel to " << leader;
fiber_usleep(FLAGS_timeout_ms * 1000L);
continue;
}
Expand All @@ -77,7 +77,7 @@ static void* sender(void* arg) {
stub.compare_exchange(&cntl, &request, &response, NULL);

if (cntl.Failed()) {
LOG(WARNING) << "Fail to send request to " << leader
MLOG(WARNING) << "Fail to send request to " << leader
<< " : " << cntl.ErrorText();
// Clear leadership since this RPC failed.
melon::raft::rtb::update_leader(FLAGS_group, melon::raft::PeerId());
Expand All @@ -88,7 +88,7 @@ static void* sender(void* arg) {
if (!response.success()) {
// A redirect response
if (!response.has_old_value()) {
LOG(WARNING) << "Fail to send request to " << leader
MLOG(WARNING) << "Fail to send request to " << leader
<< ", redirecting to "
<< (response.has_redirect()
? response.redirect() : "nowhere");
Expand All @@ -104,15 +104,15 @@ static void* sender(void* arg) {
// There was false negative
value = response.old_value();
} else {
CHECK_EQ(value, response.old_value());
MCHECK_EQ(value, response.old_value());
exit(-1);
}
} else {
value = response.new_value();
}
g_latency_recorder << cntl.latency_us();
if (FLAGS_log_each_request) {
LOG(INFO) << "Received response from " << leader
MLOG(INFO) << "Received response from " << leader
<< " old_value=" << response.old_value()
<< " new_value=" << response.new_value()
<< " latency=" << cntl.latency_us();
Expand All @@ -128,7 +128,7 @@ int main(int argc, char* argv[]) {

// Register configuration of target group to RouteTable
if (melon::raft::rtb::update_configuration(FLAGS_group, FLAGS_conf) != 0) {
LOG(ERROR) << "Fail to register configuration " << FLAGS_conf
MLOG(ERROR) << "Fail to register configuration " << FLAGS_conf
<< " of group " << FLAGS_group;
return -1;
}
Expand All @@ -146,7 +146,7 @@ int main(int argc, char* argv[]) {
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (pthread_create(
&pids[i], NULL, sender, &args[i]) != 0) {
LOG(ERROR) << "Fail to create pthread";
MLOG(ERROR) << "Fail to create pthread";
return -1;
}
}
Expand All @@ -155,7 +155,7 @@ int main(int argc, char* argv[]) {
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (fiber_start_background(
&tids[i], NULL, sender, &args[i]) != 0) {
LOG(ERROR) << "Fail to create fiber";
MLOG(ERROR) << "Fail to create fiber";
return -1;
}
}
Expand All @@ -170,7 +170,7 @@ int main(int argc, char* argv[]) {
<< " latency=" << g_latency_recorder.latency(1);
}

LOG(INFO) << "Counter client is going to quit";
MLOG(INFO) << "Counter client is going to quit";
for (int i = 0; i < FLAGS_thread_num; ++i) {
if (!FLAGS_use_fiber) {
pthread_join(pids[i], NULL);
Expand Down
46 changes: 23 additions & 23 deletions example/atomic/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Atomic : public melon::raft::StateMachine {
: _node(NULL)
, _leader_term(-1)
{
CHECK_EQ(0, _value_map.init(FLAGS_map_capacity));
MCHECK_EQ(0, _value_map.init(FLAGS_map_capacity));
}

~Atomic() {
Expand All @@ -94,7 +94,7 @@ class Atomic : public melon::raft::StateMachine {
mutil::EndPoint addr(mutil::my_ip(), FLAGS_port);
melon::raft::NodeOptions node_options;
if (node_options.initial_conf.parse_from(FLAGS_conf) != 0) {
LOG(ERROR) << "Fail to parse configuration `" << FLAGS_conf << '\'';
MLOG(ERROR) << "Fail to parse configuration `" << FLAGS_conf << '\'';
return -1;
}
node_options.election_timeout_ms = FLAGS_election_timeout_ms;
Expand All @@ -108,7 +108,7 @@ class Atomic : public melon::raft::StateMachine {
node_options.disable_cli = FLAGS_disable_cli;
melon::raft::Node* node = new melon::raft::Node(FLAGS_group, melon::raft::PeerId(addr));
if (node->init(node_options) != 0) {
LOG(ERROR) << "Fail to init raft node";
MLOG(ERROR) << "Fail to init raft node";
delete node;
return -1;
}
Expand Down Expand Up @@ -169,7 +169,7 @@ friend class AtomicClosure;
log.push_back((uint8_t)type);
mutil::IOBufAsZeroCopyOutputStream wrapper(&log);
if (!request->SerializeToZeroCopyStream(&wrapper)) {
LOG(ERROR) << "Fail to serialize request";
MLOG(ERROR) << "Fail to serialize request";
response->set_success(false);
return;
}
Expand Down Expand Up @@ -237,7 +237,7 @@ friend class AtomicClosure;
cas(data, request, response);
break;
default:
CHECK(false) << "Unknown type=" << static_cast<int>(type);
MCHECK(false) << "Unknown type=" << static_cast<int>(type);
break;
}

Expand Down Expand Up @@ -273,7 +273,7 @@ friend class AtomicClosure;
}

int on_snapshot_load(melon::raft::SnapshotReader* reader) {
CHECK_EQ(-1, _leader_term) << "Leader is not supposed to load snapshot";
MCHECK_EQ(-1, _leader_term) << "Leader is not supposed to load snapshot";
_value_map.clear();
std::string snapshot_path = reader->get_path();
snapshot_path.append("/data");
Expand All @@ -288,28 +288,28 @@ friend class AtomicClosure;

void on_leader_start(int64_t term) {
_leader_term.store(term, mutil::memory_order_release);
LOG(INFO) << "Node becomes leader";
MLOG(INFO) << "Node becomes leader";
}

void on_leader_stop(const mutil::Status& status) {
_leader_term.store(-1, mutil::memory_order_release);
LOG(INFO) << "Node stepped down : " << status;
MLOG(INFO) << "Node stepped down : " << status;
}

void on_shutdown() {
LOG(INFO) << "This node is down";
MLOG(INFO) << "This node is down";
}
void on_error(const ::melon::raft::Error& e) {
LOG(ERROR) << "Met raft error " << e;
MLOG(ERROR) << "Met raft error " << e;
}
void on_configuration_committed(const ::melon::raft::Configuration& conf) {
LOG(INFO) << "Configuration of this group is " << conf;
MLOG(INFO) << "Configuration of this group is " << conf;
}
void on_stop_following(const ::melon::raft::LeaderChangeContext& ctx) {
LOG(INFO) << "Node stops following " << ctx;
MLOG(INFO) << "Node stops following " << ctx;
}
void on_start_following(const ::melon::raft::LeaderChangeContext& ctx) {
LOG(INFO) << "Node start following " << ctx;
MLOG(INFO) << "Node start following " << ctx;
}

// end of @melon::raft::StateMachine
Expand All @@ -325,7 +325,7 @@ friend class AtomicClosure;
} else {
mutil::IOBufAsZeroCopyInputStream wrapper(data);
GetRequest req;
CHECK(req.ParseFromZeroCopyStream(&wrapper));
MCHECK(req.ParseFromZeroCopyStream(&wrapper));
id = req.id();
}
int64_t* const v = _value_map.seek(id);
Expand All @@ -350,7 +350,7 @@ friend class AtomicClosure;
} else {
mutil::IOBufAsZeroCopyInputStream wrapper(data);
ExchangeRequest req;
CHECK(req.ParseFromZeroCopyStream(&wrapper));
MCHECK(req.ParseFromZeroCopyStream(&wrapper));
id = req.id();
value = req.value();
}
Expand Down Expand Up @@ -379,7 +379,7 @@ friend class AtomicClosure;
} else {
mutil::IOBufAsZeroCopyInputStream wrapper(data);
CompareExchangeRequest req;
CHECK(req.ParseFromZeroCopyStream(&wrapper));
MCHECK(req.ParseFromZeroCopyStream(&wrapper));
id = req.id();
value = req.new_value();
expected = req.expected_value();
Expand Down Expand Up @@ -407,7 +407,7 @@ friend class AtomicClosure;
for (size_t i = 0; i < sc->values.size(); ++i) {
os << sc->values[i].first << ' ' << sc->values[i].second << '\n';
}
CHECK_EQ(0, sc->writer->add_file("data"));
MCHECK_EQ(0, sc->writer->add_file("data"));
return NULL;
}

Expand Down Expand Up @@ -478,15 +478,15 @@ int main(int argc, char* argv[]) {
// Add your service into RPC rerver
if (server.AddService(&service,
melon::SERVER_DOESNT_OWN_SERVICE) != 0) {
LOG(ERROR) << "Fail to add service";
MLOG(ERROR) << "Fail to add service";
return -1;
}
// raft can share the same RPC server. Notice the second parameter, because
// adding services into a running server is not allowed and the listen
// address of this server is impossible to get before the server starts. You
// have to specify the address of the server.
if (melon::raft::add_service(&server, FLAGS_port) != 0) {
LOG(ERROR) << "Fail to add raft service";
MLOG(ERROR) << "Fail to add raft service";
return -1;
}

Expand All @@ -496,23 +496,23 @@ int main(int argc, char* argv[]) {
// Notice the default options of server is used here. Check out details from
// the doc of melon if you would like change some options;
if (server.Start(FLAGS_port, NULL) != 0) {
LOG(ERROR) << "Fail to start Server";
MLOG(ERROR) << "Fail to start Server";
return -1;
}

// It's ok to start Atomic;
if (atomic.start() != 0) {
LOG(ERROR) << "Fail to start Atomic";
MLOG(ERROR) << "Fail to start Atomic";
return -1;
}

LOG(INFO) << "Atomic service is running on " << server.listen_address();
MLOG(INFO) << "Atomic service is running on " << server.listen_address();
// Wait until 'CTRL-C' is pressed. then Stop() and Join() the service
while (!melon::IsAskedToQuit()) {
sleep(1);
}

LOG(INFO) << "Atomic service is going to quit";
MLOG(INFO) << "Atomic service is going to quit";

// Stop counter before server
atomic.shutdown();
Expand Down
Loading

0 comments on commit feaa017

Please sign in to comment.