-
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.
Merge branch 'GreptimeTeam:develop' into develop
- Loading branch information
Showing
14 changed files
with
926 additions
and
100 deletions.
There are no files selected for viewing
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,54 @@ | ||
// 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 common_error::ext::ErrorExt; | ||
use common_meta::instruction::{InstructionReply, SimpleReply}; | ||
use common_meta::RegionIdent; | ||
use common_telemetry::warn; | ||
use futures_util::future::BoxFuture; | ||
use store_api::region_request::{RegionCloseRequest, RegionRequest}; | ||
|
||
use crate::error; | ||
use crate::heartbeat::handler::HandlerContext; | ||
|
||
impl HandlerContext { | ||
pub(crate) fn handle_close_region_instruction( | ||
self, | ||
region_ident: RegionIdent, | ||
) -> BoxFuture<'static, InstructionReply> { | ||
Box::pin(async move { | ||
let region_id = Self::region_ident_to_region_id(®ion_ident); | ||
let request = RegionRequest::Close(RegionCloseRequest {}); | ||
let result = self.region_server.handle_request(region_id, request).await; | ||
|
||
match result { | ||
Ok(_) => InstructionReply::CloseRegion(SimpleReply { | ||
result: true, | ||
error: None, | ||
}), | ||
Err(error::Error::RegionNotFound { .. }) => { | ||
warn!("Received a close region instruction from meta, but target region:{region_id} is not found."); | ||
InstructionReply::CloseRegion(SimpleReply { | ||
result: true, | ||
error: None, | ||
}) | ||
} | ||
Err(err) => InstructionReply::CloseRegion(SimpleReply { | ||
result: false, | ||
error: Some(err.output_msg()), | ||
}), | ||
} | ||
}) | ||
} | ||
} |
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,51 @@ | ||
// 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 common_error::ext::ErrorExt; | ||
use common_meta::instruction::{DowngradeRegion, DowngradeRegionReply, InstructionReply}; | ||
use futures_util::future::BoxFuture; | ||
use store_api::region_engine::SetReadonlyResponse; | ||
|
||
use crate::heartbeat::handler::HandlerContext; | ||
|
||
impl HandlerContext { | ||
pub(crate) fn handle_downgrade_region_instruction( | ||
self, | ||
DowngradeRegion { region_id }: DowngradeRegion, | ||
) -> BoxFuture<'static, InstructionReply> { | ||
Box::pin(async move { | ||
match self.region_server.set_readonly_gracefully(region_id).await { | ||
Ok(SetReadonlyResponse::Success { last_entry_id }) => { | ||
InstructionReply::DowngradeRegion(DowngradeRegionReply { | ||
last_entry_id, | ||
exists: true, | ||
error: None, | ||
}) | ||
} | ||
Ok(SetReadonlyResponse::NotFound) => { | ||
InstructionReply::DowngradeRegion(DowngradeRegionReply { | ||
last_entry_id: None, | ||
exists: false, | ||
error: None, | ||
}) | ||
} | ||
Err(err) => InstructionReply::DowngradeRegion(DowngradeRegionReply { | ||
last_entry_id: None, | ||
exists: true, | ||
error: Some(err.output_msg()), | ||
}), | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.