Skip to main content

RegionEngine

Trait RegionEngine 

Source
pub trait RegionEngine: Send + Sync {
Show 20 methods // Required methods fn name(&self) -> &str; fn handle_request<'life0, 'async_trait>( &'life0 self, region_id: RegionId, request: RegionRequest, ) -> Pin<Box<dyn Future<Output = Result<RegionResponse, BoxedError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_committed_sequence<'life0, 'async_trait>( &'life0 self, region_id: RegionId, ) -> Pin<Box<dyn Future<Output = Result<SequenceNumber, BoxedError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn handle_query<'life0, 'async_trait>( &'life0 self, region_id: RegionId, request: ScanRequest, ) -> Pin<Box<dyn Future<Output = Result<RegionScannerRef, BoxedError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_metadata<'life0, 'async_trait>( &'life0 self, region_id: RegionId, ) -> Pin<Box<dyn Future<Output = Result<RegionMetadataRef, BoxedError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn region_statistic(&self, region_id: RegionId) -> Option<RegionStatistic>; fn stop<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), BoxedError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn set_region_role( &self, region_id: RegionId, role: RegionRole, ) -> Result<(), BoxedError>; fn set_region_role_with_lease( &self, region_id: RegionId, role: RegionRole, sent_at: Instant, deadline: Instant, candidate_lease_id: Option<u64>, ) -> Result<bool, BoxedError>; fn sync_region<'life0, 'async_trait>( &'life0 self, region_id: RegionId, request: SyncRegionFromRequest, ) -> Pin<Box<dyn Future<Output = Result<SyncRegionFromResponse, BoxedError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn remap_manifests<'life0, 'async_trait>( &'life0 self, request: RemapManifestsRequest, ) -> Pin<Box<dyn Future<Output = Result<RemapManifestsResponse, BoxedError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn set_region_role_state_gracefully<'life0, 'async_trait>( &'life0 self, region_id: RegionId, region_role_state: SettableRegionRoleState, ) -> Pin<Box<dyn Future<Output = Result<SetRegionRoleStateResponse, BoxedError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn role(&self, region_id: RegionId) -> Option<RegionRole>; fn as_any(&self) -> &dyn Any; // Provided methods fn handle_batch_open_requests<'life0, 'async_trait>( &'life0 self, parallelism: usize, requests: Vec<(RegionId, RegionOpenRequest)>, ) -> Pin<Box<dyn Future<Output = Result<BatchResponses, BoxedError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn handle_batch_catchup_requests<'life0, 'async_trait>( &'life0 self, parallelism: usize, requests: Vec<(RegionId, RegionCatchupRequest)>, ) -> Pin<Box<dyn Future<Output = Result<BatchResponses, BoxedError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn handle_batch_put_requests( self: Arc<Self>, requests: Vec<(RegionId, RegionPutRequest)>, ) -> Vec<BatchPutResponse> ⓘ where Self: 'static { ... } fn handle_batch_ddl_requests<'life0, 'async_trait>( &'life0 self, request: BatchRegionDdlRequest, ) -> Pin<Box<dyn Future<Output = Result<RegionResponse, BoxedError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn query_memory_tracker(&self) -> Option<QueryMemoryTracker> { ... } fn is_confirmed_leader(&self, region_id: RegionId) -> Option<bool> { ... }
}

Required Methods§

Source

fn name(&self) -> &str

Name of this engine

Source

fn handle_request<'life0, 'async_trait>( &'life0 self, region_id: RegionId, request: RegionRequest, ) -> Pin<Box<dyn Future<Output = Result<RegionResponse, BoxedError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Handles non-query request to the region. Returns the count of affected rows.

Source

fn get_committed_sequence<'life0, 'async_trait>( &'life0 self, region_id: RegionId, ) -> Pin<Box<dyn Future<Output = Result<SequenceNumber, BoxedError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the committed sequence (sequence of latest written data).

Source

fn handle_query<'life0, 'async_trait>( &'life0 self, region_id: RegionId, request: ScanRequest, ) -> Pin<Box<dyn Future<Output = Result<RegionScannerRef, BoxedError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Handles query and return a scanner that can be used to scan the region concurrently.

Source

fn get_metadata<'life0, 'async_trait>( &'life0 self, region_id: RegionId, ) -> Pin<Box<dyn Future<Output = Result<RegionMetadataRef, BoxedError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieves region’s metadata.

Source

fn region_statistic(&self, region_id: RegionId) -> Option<RegionStatistic>

Retrieves region’s statistic.

Source

fn stop<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), BoxedError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Stops the engine

Source

fn set_region_role( &self, region_id: RegionId, role: RegionRole, ) -> Result<(), BoxedError>

Sets RegionRole for a region.

The engine checks whether the region is writable before writing to the region. Setting the region as readonly doesn’t guarantee that write operations in progress will not take effect.

Source

fn set_region_role_with_lease( &self, region_id: RegionId, role: RegionRole, sent_at: Instant, deadline: Instant, candidate_lease_id: Option<u64>, ) -> Result<bool, BoxedError>

Sets RegionRole for a region from a lease the metasrv grants until deadline, in reply to a heartbeat sent at sent_at. Returns false if the engine ignores a Leader lease because the region was downgraded or (re)opened after sent_at, a catchup runs on it, or it waits for a reload.

The region must not acknowledge a write whose WAL append completes at or after the deadline of its latest Leader or StagingLeader lease. Leases of other roles do not extend that deadline.

candidate_lease_id is the lease’s GrantedRegion::candidate_lease_id. A Follower lease that carries one may leave a region that a catchup made writable alone until its Leader or StagingLeader lease, see is_confirmed_leader.

Source

fn sync_region<'life0, 'async_trait>( &'life0 self, region_id: RegionId, request: SyncRegionFromRequest, ) -> Pin<Box<dyn Future<Output = Result<SyncRegionFromResponse, BoxedError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Syncs the region manifest to the given manifest version.

Source

fn remap_manifests<'life0, 'async_trait>( &'life0 self, request: RemapManifestsRequest, ) -> Pin<Box<dyn Future<Output = Result<RemapManifestsResponse, BoxedError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Remaps manifests from old regions to new regions.

Source

fn set_region_role_state_gracefully<'life0, 'async_trait>( &'life0 self, region_id: RegionId, region_role_state: SettableRegionRoleState, ) -> Pin<Box<dyn Future<Output = Result<SetRegionRoleStateResponse, BoxedError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sets region role state gracefully.

After the call returns, the engine ensures no more write operations will succeed in the region.

Source

fn role(&self, region_id: RegionId) -> Option<RegionRole>

Indicates region role.

Returns the None if the region is not found.

Source

fn as_any(&self) -> &dyn Any

Provided Methods§

Source

fn handle_batch_open_requests<'life0, 'async_trait>( &'life0 self, parallelism: usize, requests: Vec<(RegionId, RegionOpenRequest)>, ) -> Pin<Box<dyn Future<Output = Result<BatchResponses, BoxedError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Handles batch open region requests.

Source

fn handle_batch_catchup_requests<'life0, 'async_trait>( &'life0 self, parallelism: usize, requests: Vec<(RegionId, RegionCatchupRequest)>, ) -> Pin<Box<dyn Future<Output = Result<BatchResponses, BoxedError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn handle_batch_put_requests( self: Arc<Self>, requests: Vec<(RegionId, RegionPutRequest)>, ) -> Vec<BatchPutResponse> ⓘ
where Self: 'static,

Handles the puts of one request into regions of this engine and returns the responses to await on their own, each with the region of every put it answers for: two puts to one region are two entries.

The default handles each put with handle_request and answers each put on its own. An engine that writes several puts together may answer them with one response whose affected rows count all of them.

Source

fn handle_batch_ddl_requests<'life0, 'async_trait>( &'life0 self, request: BatchRegionDdlRequest, ) -> Pin<Box<dyn Future<Output = Result<RegionResponse, BoxedError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn query_memory_tracker(&self) -> Option<QueryMemoryTracker>

Returns the query memory tracker for scan execution.

Source

fn is_confirmed_leader(&self, region_id: RegionId) -> Option<bool>

Returns whether the region is a leader that needs no catchup: None if the region is not found, Some(false) if it is a follower or, on a node that requires leases to confirm its leaders, a catchup made it a leader and no Leader or StagingLeader lease sent after that catchup, nor a direct promotion to Leader, has applied since, and Some(true) otherwise. The default answers from role alone, which suits an engine that does not tie its commits to leases.

An upgrade reports a region that answers Some(true) ready without a catchup, sends one that answers Some(false) a catchup with set_writable, and reports one that answers None missing.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§