Skip to content

Commit

Permalink
Merge pull request #6059 from BohuTANG/dev-handler-help
Browse files Browse the repository at this point in the history
chore(log): make the databend server and port for human
  • Loading branch information
BohuTANG authored Jun 19, 2022
2 parents e4ee25f + f94f025 commit cf3fbf6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
36 changes: 18 additions & 18 deletions query/bin/databend-query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ async fn main(_global_tracker: Arc<RuntimeTracker>) -> common_exception::Result<
shutdown_handle.add_service(handler);

tracing::info!(
"MySQL handler listening on {}, Usage: mysql -uroot -h{} -P{}",
"Listening for MySQL compatibility protocol: {}, Usage: mysql -uroot -h{} -P{}",
listening,
listening.ip(),
listening.port(),
Expand All @@ -94,42 +94,42 @@ async fn main(_global_tracker: Arc<RuntimeTracker>) -> common_exception::Result<
shutdown_handle.add_service(srv);

tracing::info!(
"ClickHouse handler listening on {}, Usage: clickhouse-client --host {} --port {}",
"Listening for ClickHouse compatibility native protocol: {}, Usage: clickhouse-client --host {} --port {}",
listening,
listening.ip(),
listening.port(),
);
}

// HTTP handler.
// ClickHouse HTTP handler.
{
let hostname = conf.query.http_handler_host.clone();
let listening = format!("{}:{}", hostname, conf.query.http_handler_port);
let hostname = conf.query.clickhouse_http_handler_host.clone();
let listening = format!("{}:{}", hostname, conf.query.clickhouse_http_handler_port);

let mut srv = HttpHandler::create(session_manager.clone(), HttpHandlerKind::Query);
let mut srv = HttpHandler::create(session_manager.clone(), HttpHandlerKind::Clickhouse);
let listening = srv.start(listening.parse()?).await?;
shutdown_handle.add_service(srv);

let http_handler_usage = HttpHandlerKind::Query.usage(listening);
let http_handler_usage = HttpHandlerKind::Clickhouse.usage(listening);
tracing::info!(
"Http handler listening on {} {}",
"Listening for ClickHouse compatibility http protocol: {}, Usage: {}",
listening,
http_handler_usage
);
}

// clickhouse HTTP handler.
// Databend HTTP handler.
{
let hostname = conf.query.clickhouse_http_handler_host.clone();
let listening = format!("{}:{}", hostname, conf.query.clickhouse_http_handler_port);
let hostname = conf.query.http_handler_host.clone();
let listening = format!("{}:{}", hostname, conf.query.http_handler_port);

let mut srv = HttpHandler::create(session_manager.clone(), HttpHandlerKind::Clickhouse);
let mut srv = HttpHandler::create(session_manager.clone(), HttpHandlerKind::Query);
let listening = srv.start(listening.parse()?).await?;
shutdown_handle.add_service(srv);

let http_handler_usage = HttpHandlerKind::Clickhouse.usage(listening);
let http_handler_usage = HttpHandlerKind::Query.usage(listening);
tracing::info!(
"clickhouse Http handler listening on {} {}",
"Listening for Databend HTTP API: {}, Usage: {}",
listening,
http_handler_usage
);
Expand All @@ -141,16 +141,16 @@ async fn main(_global_tracker: Arc<RuntimeTracker>) -> common_exception::Result<
let mut srv = MetricService::create(session_manager.clone());
let listening = srv.start(address.parse()?).await?;
shutdown_handle.add_service(srv);
tracing::info!("Metric API server listening on {}/metrics", listening);
tracing::info!("Listening for Metric API: {}/metrics", listening);
}

// HTTP API service.
// Admin HTTP API service.
{
let address = conf.query.admin_api_address.clone();
let mut srv = HttpService::create(session_manager.clone());
let listening = srv.start(address.parse()?).await?;
shutdown_handle.add_service(srv);
tracing::info!("HTTP API server listening on {}", listening);
tracing::info!("Listening for Admin HTTP API: {}", listening);
}

// RPC API service.
Expand All @@ -159,7 +159,7 @@ async fn main(_global_tracker: Arc<RuntimeTracker>) -> common_exception::Result<
let mut srv = RpcService::create(session_manager.clone());
let listening = srv.start(address.parse()?).await?;
shutdown_handle.add_service(srv);
tracing::info!("RPC API server listening on {}", listening);
tracing::info!("Listening for RPC API (interserver): {}", listening);
}

// Cluster register.
Expand Down
6 changes: 2 additions & 4 deletions query/src/servers/http/http_services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,15 @@ impl HttpHandlerKind {
match self {
HttpHandlerKind::Query => {
format!(
r#" examples:
curl -u root: --request POST '{:?}/v1/query/' --header 'Content-Type: application/json' --data-raw '{{"sql": "SELECT avg(number) FROM numbers(100000000)"}}'
r#" curl -u root: --request POST '{:?}/v1/query/' --header 'Content-Type: application/json' --data-raw '{{"sql": "SELECT avg(number) FROM numbers(100000000)"}}'
"#,
sock,
)
}
HttpHandlerKind::Clickhouse => {
let json = r#"{"foo": "bar"}"#;
format!(
r#" examples:
echo 'create table test(foo string)' | curl -u root: '{:?}' --data-binary @-
r#" echo 'create table test(foo string)' | curl -u root: '{:?}' --data-binary @-
echo '{}' | curl -u root: '{:?}/?query=INSERT%20INTO%20test%20FORMAT%20JSONEachRow' --data-binary @-"#,
sock, json, sock,
)
Expand Down

0 comments on commit cf3fbf6

Please sign in to comment.