-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Merge branch 'main' into debug/seq-scan-log
- Loading branch information
Showing
46 changed files
with
1,363 additions
and
368 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// Copyright 2023 Greptime Team | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use api::v1::meta::ProcedureStatus; | ||
use common_error::ext::BoxedError; | ||
use common_meta::cluster::{ClusterInfo, NodeInfo}; | ||
use common_meta::datanode::RegionStat; | ||
use common_meta::ddl::{ExecutorContext, ProcedureExecutor}; | ||
use common_meta::rpc::procedure; | ||
use common_procedure::{ProcedureInfo, ProcedureState}; | ||
use meta_client::MetaClientRef; | ||
use snafu::ResultExt; | ||
|
||
use crate::error; | ||
use crate::information_schema::InformationExtension; | ||
|
||
pub struct DistributedInformationExtension { | ||
meta_client: MetaClientRef, | ||
} | ||
|
||
impl DistributedInformationExtension { | ||
pub fn new(meta_client: MetaClientRef) -> Self { | ||
Self { meta_client } | ||
} | ||
} | ||
|
||
#[async_trait::async_trait] | ||
impl InformationExtension for DistributedInformationExtension { | ||
type Error = crate::error::Error; | ||
|
||
async fn nodes(&self) -> std::result::Result<Vec<NodeInfo>, Self::Error> { | ||
self.meta_client | ||
.list_nodes(None) | ||
.await | ||
.map_err(BoxedError::new) | ||
.context(error::ListNodesSnafu) | ||
} | ||
|
||
async fn procedures(&self) -> std::result::Result<Vec<(String, ProcedureInfo)>, Self::Error> { | ||
let procedures = self | ||
.meta_client | ||
.list_procedures(&ExecutorContext::default()) | ||
.await | ||
.map_err(BoxedError::new) | ||
.context(error::ListProceduresSnafu)? | ||
.procedures; | ||
let mut result = Vec::with_capacity(procedures.len()); | ||
for procedure in procedures { | ||
let pid = match procedure.id { | ||
Some(pid) => pid, | ||
None => return error::ProcedureIdNotFoundSnafu {}.fail(), | ||
}; | ||
let pid = procedure::pb_pid_to_pid(&pid) | ||
.map_err(BoxedError::new) | ||
.context(error::ConvertProtoDataSnafu)?; | ||
let status = ProcedureStatus::try_from(procedure.status) | ||
.map(|v| v.as_str_name()) | ||
.unwrap_or("Unknown") | ||
.to_string(); | ||
let procedure_info = ProcedureInfo { | ||
id: pid, | ||
type_name: procedure.type_name, | ||
start_time_ms: procedure.start_time_ms, | ||
end_time_ms: procedure.end_time_ms, | ||
state: ProcedureState::Running, | ||
lock_keys: procedure.lock_keys, | ||
}; | ||
result.push((status, procedure_info)); | ||
} | ||
|
||
Ok(result) | ||
} | ||
|
||
async fn region_stats(&self) -> std::result::Result<Vec<RegionStat>, Self::Error> { | ||
self.meta_client | ||
.list_region_stats() | ||
.await | ||
.map_err(BoxedError::new) | ||
.context(error::ListRegionStatsSnafu) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
[package] | ||
name = "cli" | ||
version.workspace = true | ||
edition.workspace = true | ||
license.workspace = true | ||
|
||
[lints] | ||
workspace = true | ||
|
||
[dependencies] | ||
async-trait.workspace = true | ||
auth.workspace = true | ||
base64.workspace = true | ||
cache.workspace = true | ||
catalog.workspace = true | ||
chrono.workspace = true | ||
clap.workspace = true | ||
client.workspace = true | ||
common-base.workspace = true | ||
common-catalog.workspace = true | ||
common-config.workspace = true | ||
common-error.workspace = true | ||
common-grpc.workspace = true | ||
common-macro.workspace = true | ||
common-meta.workspace = true | ||
common-options.workspace = true | ||
common-procedure.workspace = true | ||
common-query.workspace = true | ||
common-recordbatch.workspace = true | ||
common-runtime.workspace = true | ||
common-telemetry = { workspace = true, features = [ | ||
"deadlock_detection", | ||
] } | ||
common-time.workspace = true | ||
common-version.workspace = true | ||
common-wal.workspace = true | ||
datatypes.workspace = true | ||
either = "1.8" | ||
etcd-client.workspace = true | ||
futures.workspace = true | ||
humantime.workspace = true | ||
meta-client.workspace = true | ||
nu-ansi-term = "0.46" | ||
query.workspace = true | ||
rand.workspace = true | ||
reqwest.workspace = true | ||
rustyline = "10.1" | ||
serde.workspace = true | ||
serde_json.workspace = true | ||
servers.workspace = true | ||
session.workspace = true | ||
snafu.workspace = true | ||
store-api.workspace = true | ||
substrait.workspace = true | ||
table.workspace = true | ||
tokio.workspace = true | ||
tracing-appender.workspace = true | ||
|
||
[dev-dependencies] | ||
client = { workspace = true, features = ["testing"] } | ||
common-test-util.workspace = true | ||
common-version.workspace = true | ||
serde.workspace = true | ||
temp-env = "0.3" | ||
tempfile.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.