Skip to content

Commit

Permalink
feat: cluster information (GreptimeTeam#3631)
Browse files Browse the repository at this point in the history
* chore: keep the same method order in KvBackend

* feat: make meta client can get all node info of cluster

* feat: cluster info data model

* feat: frontend and datanode info

* feat: list node info

* chore: remove the method: is_started

* fix: scan key prefix

* chore: impl From for NodeInfoKey

* chore: doc for trait and struct

* chore: reuse the error

* chore: refactor two collec cluster info handlers

* chore: remove inline

* chore: refactor two collec cluster info handlers
  • Loading branch information
fengjiachun authored Apr 8, 2024
1 parent e920f95 commit 12286f0
Show file tree
Hide file tree
Showing 24 changed files with 874 additions and 189 deletions.
56 changes: 28 additions & 28 deletions src/catalog/src/kvbackend/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,10 @@ impl KvBackend for MetaKvBackend {
"MetaKvBackend"
}

fn as_any(&self) -> &dyn Any {
self
}

async fn range(&self, req: RangeRequest) -> Result<RangeResponse> {
self.client
.range(req)
Expand All @@ -372,17 +376,12 @@ impl KvBackend for MetaKvBackend {
.context(ExternalSnafu)
}

async fn get(&self, key: &[u8]) -> Result<Option<KeyValue>> {
let mut response = self
.client
.range(RangeRequest::new().with_key(key))
async fn put(&self, req: PutRequest) -> Result<PutResponse> {
self.client
.put(req)
.await
.map_err(BoxedError::new)
.context(ExternalSnafu)?;
Ok(response.take_kvs().get_mut(0).map(|kv| KeyValue {
key: kv.take_key(),
value: kv.take_value(),
}))
.context(ExternalSnafu)
}

async fn batch_put(&self, req: BatchPutRequest) -> Result<BatchPutResponse> {
Expand All @@ -393,51 +392,52 @@ impl KvBackend for MetaKvBackend {
.context(ExternalSnafu)
}

async fn put(&self, req: PutRequest) -> Result<PutResponse> {
async fn batch_get(&self, req: BatchGetRequest) -> Result<BatchGetResponse> {
self.client
.put(req)
.batch_get(req)
.await
.map_err(BoxedError::new)
.context(ExternalSnafu)
}

async fn delete_range(&self, req: DeleteRangeRequest) -> Result<DeleteRangeResponse> {
async fn compare_and_put(
&self,
request: CompareAndPutRequest,
) -> Result<CompareAndPutResponse> {
self.client
.delete_range(req)
.compare_and_put(request)
.await
.map_err(BoxedError::new)
.context(ExternalSnafu)
}

async fn batch_delete(&self, req: BatchDeleteRequest) -> Result<BatchDeleteResponse> {
async fn delete_range(&self, req: DeleteRangeRequest) -> Result<DeleteRangeResponse> {
self.client
.batch_delete(req)
.delete_range(req)
.await
.map_err(BoxedError::new)
.context(ExternalSnafu)
}

async fn batch_get(&self, req: BatchGetRequest) -> Result<BatchGetResponse> {
async fn batch_delete(&self, req: BatchDeleteRequest) -> Result<BatchDeleteResponse> {
self.client
.batch_get(req)
.batch_delete(req)
.await
.map_err(BoxedError::new)
.context(ExternalSnafu)
}

async fn compare_and_put(
&self,
request: CompareAndPutRequest,
) -> Result<CompareAndPutResponse> {
self.client
.compare_and_put(request)
async fn get(&self, key: &[u8]) -> Result<Option<KeyValue>> {
let mut response = self
.client
.range(RangeRequest::new().with_key(key))
.await
.map_err(BoxedError::new)
.context(ExternalSnafu)
}

fn as_any(&self) -> &dyn Any {
self
.context(ExternalSnafu)?;
Ok(response.take_kvs().get_mut(0).map(|kv| KeyValue {
key: kv.take_key(),
value: kv.take_value(),
}))
}
}

Expand Down
Loading

0 comments on commit 12286f0

Please sign in to comment.