chore(quic): enable edge task and reduce service logs
This commit is contained in:
parent
59576ff7e9
commit
5443a05972
@ -37,6 +37,6 @@ task_manager {
|
||||
type: TASK_TYPE_QUIC_EDGE
|
||||
run_mode: TASK_RUN_MODE_BLOCKING_SERVICE
|
||||
config_file: "tasks/quic_edge_task/quic_edge_task.pb.txt"
|
||||
enable: false
|
||||
enable: true
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,8 +12,6 @@
|
||||
#include <unordered_set>
|
||||
#include <utility>
|
||||
|
||||
#include "common/base/logging/logger.h"
|
||||
|
||||
namespace cmvr::quic_edge {
|
||||
namespace {
|
||||
|
||||
@ -112,12 +110,6 @@ public:
|
||||
const std::string& server_name =
|
||||
config.tls().allow_insecure() || config.tls().server_name().empty()
|
||||
? config.server_host() : config.tls().server_name();
|
||||
CMVR_LOG(INFO) << "[MsQuicTransport] ConnectionStart"
|
||||
<< ", connect_host=" << server_name
|
||||
<< ", configured_server_host=" << config.server_host()
|
||||
<< ", port=" << config.server_port()
|
||||
<< ", ca_file=" << config.tls().ca_file()
|
||||
<< ", allow_insecure=" << config.tls().allow_insecure();
|
||||
status = api_->ConnectionStart(
|
||||
opened_connection, configuration_, QUIC_ADDRESS_FAMILY_UNSPEC,
|
||||
server_name.c_str(),
|
||||
|
||||
@ -753,24 +753,12 @@ void QuicEdgeService::run()
|
||||
}
|
||||
resetConnectionStatus();
|
||||
setState(QuicEdgeServiceState::CONNECTING);
|
||||
CMVR_LOG(INFO) << "[QuicEdgeService] connecting"
|
||||
<< ", target=" << config_.server_host() << ':'
|
||||
<< config_.server_port()
|
||||
<< ", tls_server_name=" << config_.tls().server_name()
|
||||
<< ", alpn=" << config_.alpn()
|
||||
<< ", node_id=" << node_id_;
|
||||
|
||||
std::string error;
|
||||
if (!transport_->connect(
|
||||
config_,
|
||||
std::chrono::milliseconds(config_.reconnect().connect_timeout_ms()),
|
||||
&error)) {
|
||||
CMVR_LOG(ERROR) << "[QuicEdgeService] connect failed"
|
||||
<< ", target=" << config_.server_host() << ':'
|
||||
<< config_.server_port()
|
||||
<< ", error="
|
||||
<< (error.empty() ? "QUIC connect failed" : error)
|
||||
<< ", backoff_ms=" << backoff.count();
|
||||
setState(QuicEdgeServiceState::BACKOFF,
|
||||
error.empty() ? "QUIC connect failed" : error);
|
||||
if (waitForStop(jittered(backoff))) break;
|
||||
@ -792,10 +780,6 @@ void QuicEdgeService::run()
|
||||
has_inbound_message_sequence_ = false;
|
||||
ControlFrameDecoder decoder(config_.maximum_control_frame_bytes());
|
||||
setState(QuicEdgeServiceState::REGISTERING);
|
||||
CMVR_LOG(INFO) << "[QuicEdgeService] connected, registering node"
|
||||
<< ", target=" << config_.server_host() << ':'
|
||||
<< config_.server_port()
|
||||
<< ", node_id=" << node_id_;
|
||||
|
||||
if (!performRegistration(&decoder, &error)) {
|
||||
transport_->disconnect();
|
||||
@ -803,22 +787,13 @@ void QuicEdgeService::run()
|
||||
std::lock_guard lock(mutex_);
|
||||
if (stop_requested_) break;
|
||||
}
|
||||
CMVR_LOG(ERROR) << "[QuicEdgeService] registration failed"
|
||||
<< ", target=" << config_.server_host() << ':'
|
||||
<< config_.server_port()
|
||||
<< ", error=" << error
|
||||
<< ", backoff_ms=" << backoff.count();
|
||||
setState(QuicEdgeServiceState::BACKOFF, error);
|
||||
setState(QuicEdgeServiceState::BACKOFF,
|
||||
error.empty() ? "QUIC node registration failed" : error);
|
||||
if (waitForStop(jittered(backoff))) break;
|
||||
backoff = nextBackoff(backoff);
|
||||
continue;
|
||||
}
|
||||
setState(QuicEdgeServiceState::ONLINE);
|
||||
CMVR_LOG(INFO) << "[QuicEdgeService] online"
|
||||
<< ", target=" << config_.server_host() << ':'
|
||||
<< config_.server_port()
|
||||
<< ", node_id=" << node_id_
|
||||
<< ", session=" << session_id_;
|
||||
|
||||
if (!startMediaWorker(&error)) {
|
||||
transport_->disconnect();
|
||||
@ -826,7 +801,8 @@ void QuicEdgeService::run()
|
||||
std::lock_guard lock(mutex_);
|
||||
if (stop_requested_) break;
|
||||
}
|
||||
setState(QuicEdgeServiceState::BACKOFF, error);
|
||||
setState(QuicEdgeServiceState::BACKOFF,
|
||||
error.empty() ? "QUIC media worker failed to start" : error);
|
||||
if (waitForStop(jittered(backoff))) break;
|
||||
backoff = nextBackoff(backoff);
|
||||
continue;
|
||||
@ -1192,18 +1168,6 @@ bool QuicEdgeService::sendNodeRegistration(std::string* error)
|
||||
return false;
|
||||
}
|
||||
if (!sendControlEnvelope(serialized, error)) return false;
|
||||
const auto& node = request->node();
|
||||
CMVR_LOG(INFO) << "[QuicEdgeService] sent NodeRegisterRequest"
|
||||
<< ", message_sequence=" << envelope.message_sequence()
|
||||
<< ", payload_bytes=" << serialized.size()
|
||||
<< ", node_id=" << node.node_id()
|
||||
<< ", robot_id=" << node.robot_id()
|
||||
<< ", boot_id=" << node.boot_id()
|
||||
<< ", grpc_endpoint=" << node.grpc_endpoint().host()
|
||||
<< ':' << node.grpc_endpoint().port()
|
||||
<< ", grpc_tls=" << node.grpc_endpoint().tls()
|
||||
<< ", interfaces=" << node.local_interfaces_size()
|
||||
<< ", sent_at_unix_ms=" << request->sent_at_unix_ms();
|
||||
std::lock_guard lock(mutex_);
|
||||
++stats_.registrations_sent;
|
||||
return true;
|
||||
@ -1268,19 +1232,7 @@ bool QuicEdgeService::sendHeartbeat(const std::uint64_t sequence,
|
||||
setError(error, "failed to serialize NodeHeartbeat");
|
||||
return false;
|
||||
}
|
||||
if (!sendControlEnvelope(serialized, error)) return false;
|
||||
CMVR_LOG(INFO) << "[QuicEdgeService] sent NodeHeartbeat"
|
||||
<< ", message_sequence=" << envelope.message_sequence()
|
||||
<< ", payload_bytes=" << serialized.size()
|
||||
<< ", robot_id=" << heartbeat->robot_id()
|
||||
<< ", session=" << session_id
|
||||
<< ", heartbeat_sequence=" << sequence
|
||||
<< ", grpc_endpoint=" << heartbeat->grpc_endpoint().host()
|
||||
<< ':' << heartbeat->grpc_endpoint().port()
|
||||
<< ", interfaces=" << heartbeat->local_interfaces_size()
|
||||
<< ", devices=" << heartbeat->device_manager().devices_size()
|
||||
<< ", sent_at_unix_ms=" << sent_at_unix_ms;
|
||||
return true;
|
||||
return sendControlEnvelope(serialized, error);
|
||||
}
|
||||
|
||||
bool QuicEdgeService::receiveAndDispatchControl(
|
||||
@ -1561,14 +1513,7 @@ bool QuicEdgeService::sendSessionOpen(std::string* error)
|
||||
setError(error, "failed to serialize MediaSessionOpen");
|
||||
return false;
|
||||
}
|
||||
if (!sendControlEnvelope(serialized, error)) return false;
|
||||
CMVR_LOG(INFO) << "[QuicEdgeService] sent MediaSessionOpen"
|
||||
<< ", message_sequence=" << envelope.message_sequence()
|
||||
<< ", payload_bytes=" << serialized.size()
|
||||
<< ", session=" << session_id
|
||||
<< ", session_epoch=" << session_epoch_
|
||||
<< ", node_id=" << node_id_;
|
||||
return true;
|
||||
return sendControlEnvelope(serialized, error);
|
||||
}
|
||||
|
||||
bool QuicEdgeService::sendTrackDescription(
|
||||
@ -1602,25 +1547,7 @@ bool QuicEdgeService::sendTrackDescription(
|
||||
setError(error, "failed to serialize MediaTrackDescriptor");
|
||||
return false;
|
||||
}
|
||||
if (!sendControlEnvelope(serialized, error)) return false;
|
||||
CMVR_LOG(INFO) << "[QuicEdgeService] sent MediaTrackDescriptor"
|
||||
<< ", message_sequence=" << envelope.message_sequence()
|
||||
<< ", payload_bytes=" << serialized.size()
|
||||
<< ", track_id=" << description.track_id
|
||||
<< ", source_track_id=" << description.source_track_id
|
||||
<< ", source_id=" << description.source_id
|
||||
<< ", kind=" << static_cast<int>(description.kind)
|
||||
<< ", codec=" << codecName(description.codec)
|
||||
<< ", payload_format=" << payloadFormatName(description.payload_format)
|
||||
<< ", codec_generation=" << description.codec_generation
|
||||
<< ", codec_generation_token="
|
||||
<< description.codec_generation_token
|
||||
<< ", size=" << description.width << 'x' << description.height
|
||||
<< ", fps=" << description.nominal_rate
|
||||
<< ", sample_rate=" << description.sample_rate
|
||||
<< ", channels=" << description.channels
|
||||
<< ", codec_config_bytes=" << description.codec_config.size();
|
||||
return true;
|
||||
return sendControlEnvelope(serialized, error);
|
||||
}
|
||||
|
||||
bool QuicEdgeService::sendControlEnvelope(const std::string& serialized,
|
||||
@ -1813,22 +1740,6 @@ bool QuicEdgeService::processTrack(ActiveTrack* track,
|
||||
std::lock_guard lock(mutex_);
|
||||
++stats_.frames_queued;
|
||||
stats_.datagrams_queued += datagram_count;
|
||||
CMVR_LOG(INFO) << "[QuicEdgeService] queued media frame"
|
||||
<< ", track_id=" << track->config.track_id()
|
||||
<< ", source_track_id=" << track->source_track_id
|
||||
<< ", frame_sequence=" << frame->sequence
|
||||
<< ", wire_frame_sequence=" << wire_frame_sequence
|
||||
<< ", payload_bytes=" << frame->size()
|
||||
<< ", datagrams=" << datagram_count
|
||||
<< ", key_frame=" << frame->key_frame
|
||||
<< ", discontinuity=" << discontinuity
|
||||
<< ", codec=" << codecName(description.codec)
|
||||
<< ", payload_format="
|
||||
<< payloadFormatName(description.payload_format)
|
||||
<< ", capture_timestamp_us="
|
||||
<< frame->capture_time_ns / 1000U
|
||||
<< ", source_timestamp=" << frame->source_timestamp
|
||||
<< ", source_frame_number=" << frame->source_frame_number;
|
||||
return true;
|
||||
}
|
||||
if (result == TransportSendResult::WOULD_BLOCK) {
|
||||
@ -1923,13 +1834,26 @@ void QuicEdgeService::recordMediaError(const std::string& error)
|
||||
void QuicEdgeService::setState(const QuicEdgeServiceState state,
|
||||
const std::string& error)
|
||||
{
|
||||
std::lock_guard lock(mutex_);
|
||||
state_ = state;
|
||||
if (!error.empty()) {
|
||||
last_error_ = error;
|
||||
} else if (state == QuicEdgeServiceState::ONLINE ||
|
||||
state == QuicEdgeServiceState::STOPPED) {
|
||||
last_error_.clear();
|
||||
QuicEdgeServiceState previous_state;
|
||||
bool report_error;
|
||||
{
|
||||
std::lock_guard lock(mutex_);
|
||||
previous_state = state_;
|
||||
state_ = state;
|
||||
if (!error.empty()) {
|
||||
last_error_ = error;
|
||||
} else if (state == QuicEdgeServiceState::ONLINE ||
|
||||
state == QuicEdgeServiceState::STOPPED) {
|
||||
last_error_.clear();
|
||||
}
|
||||
report_error = !error.empty() &&
|
||||
!(state == QuicEdgeServiceState::BACKOFF && stop_requested_);
|
||||
}
|
||||
if (report_error) {
|
||||
CMVR_LOG(ERROR) << "[QuicEdgeService] phase=" << toString(previous_state)
|
||||
<< ", state=" << toString(state)
|
||||
<< ", target=" << config_.server_host() << ':' << config_.server_port()
|
||||
<< ", error=" << error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -244,8 +244,6 @@ bool QuicEdgeTask::start()
|
||||
}
|
||||
last_error_.clear();
|
||||
state_ = TaskState::RUNNING;
|
||||
CMVR_LOG(INFO) << "[QuicEdgeTask] Started, id=" << id_
|
||||
<< ", platforms=" << services_.size();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user