pub struct StreamingEngine {Show 13 fields
pub worker_handles: Vec<WorkerHandle>,
worker_selector: Mutex<usize>,
pub query_engine: Arc<dyn QueryEngine>,
table_info_source: ManagedTableSource,
frontend_invoker: RwLock<Option<FrontendInvoker>>,
node_context: RwLock<FlownodeContext>,
refill_tasks: RwLock<BTreeMap<u64, RefillTask>>,
flow_err_collectors: RwLock<BTreeMap<u64, ErrCollector>>,
src_send_buf_lens: RwLock<BTreeMap<TableId, Receiver<usize>>>,
tick_manager: FlowTickManager,
pub node_id: Option<u32>,
flush_lock: RwLock<()>,
state_report_handler: RwLock<Option<Receiver<Sender<FlowStat>>>>,
}
Expand description
FlowNodeManager manages the state of all tasks in the flow node, which should be run on the same thread
The choice of timestamp is just using current system timestamp for now
Fields§
§worker_handles: Vec<WorkerHandle>
The handler to the worker that will run the dataflow
which is !Send
so a handle is used
worker_selector: Mutex<usize>
The selector to select a worker to run the dataflow
query_engine: Arc<dyn QueryEngine>
The query engine that will be used to parse the query and convert it to a dataflow plan
table_info_source: ManagedTableSource
Getting table name and table schema from table info manager
frontend_invoker: RwLock<Option<FrontendInvoker>>
§node_context: RwLock<FlownodeContext>
contains mapping from table name to global id, and table schema
refill_tasks: RwLock<BTreeMap<u64, RefillTask>>
Contains all refill tasks
flow_err_collectors: RwLock<BTreeMap<u64, ErrCollector>>
§src_send_buf_lens: RwLock<BTreeMap<TableId, Receiver<usize>>>
§tick_manager: FlowTickManager
§node_id: Option<u32>
This node id is only available in distributed mode, on standalone mode this is guaranteed to be None
flush_lock: RwLock<()>
Lock for flushing, will be read
by handle_inserts
and write
by flush_flow
So that a series of event like inserts -> flush
can be handled correctly
state_report_handler: RwLock<Option<Receiver<Sender<FlowStat>>>>
receive a oneshot sender to send state size report
Implementations§
Source§impl StreamingEngine
impl StreamingEngine
async fn handle_inserts_inner( &self, request: InsertRequests, ) -> Result<(), Error>
Source§impl StreamingEngine
impl StreamingEngine
Sourcepub async fn create_and_start_refill_flow_tasks(
self: &FlowStreamingEngineRef,
flow_metadata_manager: &FlowMetadataManagerRef,
catalog_manager: &CatalogManagerRef,
) -> Result<(), Error>
pub async fn create_and_start_refill_flow_tasks( self: &FlowStreamingEngineRef, flow_metadata_manager: &FlowMetadataManagerRef, catalog_manager: &CatalogManagerRef, ) -> Result<(), Error>
Create and start refill flow tasks in background
Sourcepub async fn create_refill_flow_tasks(
&self,
flow_metadata_manager: &FlowMetadataManagerRef,
catalog_manager: &CatalogManagerRef,
) -> Result<Vec<RefillTask>, Error>
pub async fn create_refill_flow_tasks( &self, flow_metadata_manager: &FlowMetadataManagerRef, catalog_manager: &CatalogManagerRef, ) -> Result<Vec<RefillTask>, Error>
Create a series of tasks to refill flow
Sourcepub(crate) async fn starting_refill_flows(
self: &FlowStreamingEngineRef,
tasks: Vec<RefillTask>,
) -> Result<(), Error>
pub(crate) async fn starting_refill_flows( self: &FlowStreamingEngineRef, tasks: Vec<RefillTask>, ) -> Result<(), Error>
Starting to refill flows, if any error occurs, will rebuild the flow and retry
Source§impl StreamingEngine
impl StreamingEngine
pub async fn gen_state_report(&self) -> FlowStat
Source§impl StreamingEngine
impl StreamingEngine
Sourcepub(crate) async fn get_worker_handle_for_create_flow(&self) -> &WorkerHandle
pub(crate) async fn get_worker_handle_for_create_flow(&self) -> &WorkerHandle
Get a worker handle for creating flow, using round robin to select a worker
Sourcepub(crate) async fn create_table_from_relation(
&self,
flow_name: &str,
table_name: &[String; 3],
relation_desc: &RelationDesc,
) -> Result<bool, Error>
pub(crate) async fn create_table_from_relation( &self, flow_name: &str, table_name: &[String; 3], relation_desc: &RelationDesc, ) -> Result<bool, Error>
Create table from given schema(will adjust to add auto column if needed), return true if table is created
Sourcepub(crate) async fn try_fetch_existing_table(
&self,
table_name: &[String; 3],
) -> Result<Option<(bool, Vec<ColumnSchema>)>, Error>
pub(crate) async fn try_fetch_existing_table( &self, table_name: &[String; 3], ) -> Result<Option<(bool, Vec<ColumnSchema>)>, Error>
Try fetch table with adjusted schema(added auto column if needed)
Sourcepub(crate) async fn submit_create_sink_table_ddl(
&self,
create_table: CreateTableExpr,
) -> Result<(), Error>
pub(crate) async fn submit_create_sink_table_ddl( &self, create_table: CreateTableExpr, ) -> Result<(), Error>
submit a create table ddl
Source§impl StreamingEngine
Building FlownodeManager
impl StreamingEngine
Building FlownodeManager
Sourcepub async fn set_frontend_invoker(&self, frontend: FrontendInvoker)
pub async fn set_frontend_invoker(&self, frontend: FrontendInvoker)
set frontend invoker
Sourcepub fn new(
node_id: Option<u32>,
query_engine: Arc<dyn QueryEngine>,
table_meta: TableMetadataManagerRef,
) -> Self
pub fn new( node_id: Option<u32>, query_engine: Arc<dyn QueryEngine>, table_meta: TableMetadataManagerRef, ) -> Self
Create without setting frontend_invoker
pub async fn with_state_report_handler( self, handler: Receiver<Sender<FlowStat>>, ) -> Self
Sourcepub fn new_with_workers<'s>(
node_id: Option<u32>,
query_engine: Arc<dyn QueryEngine>,
table_meta: TableMetadataManagerRef,
num_workers: usize,
) -> (Self, Vec<Worker<'s>>)
pub fn new_with_workers<'s>( node_id: Option<u32>, query_engine: Arc<dyn QueryEngine>, table_meta: TableMetadataManagerRef, num_workers: usize, ) -> (Self, Vec<Worker<'s>>)
Create a flownode manager with one worker
Sourcepub fn add_worker_handle(&mut self, handle: WorkerHandle)
pub fn add_worker_handle(&mut self, handle: WorkerHandle)
add a worker handler to manager, meaning this corresponding worker is under it’s manage
Source§impl StreamingEngine
This impl block contains methods to send writeback requests to frontend
impl StreamingEngine
This impl block contains methods to send writeback requests to frontend
Sourcepub async fn send_writeback_requests(&self) -> Result<usize, Error>
pub async fn send_writeback_requests(&self) -> Result<usize, Error>
Return the number of requests it made
Sourcepub async fn generate_writeback_request(
&self,
) -> Result<BTreeMap<[String; 3], Vec<DiffRequest>>, Error>
pub async fn generate_writeback_request( &self, ) -> Result<BTreeMap<[String; 3], Vec<DiffRequest>>, Error>
Generate writeback request for all sink table
Sourceasync fn fetch_table_pk_schema(
&self,
table_name: &[String; 3],
) -> Result<Option<(Vec<String>, Option<usize>, Vec<ColumnSchema>)>, Error>
async fn fetch_table_pk_schema( &self, table_name: &[String; 3], ) -> Result<Option<(Vec<String>, Option<usize>, Vec<ColumnSchema>)>, Error>
Fetch table schema and primary key from table info source, if table not exist return None
Sourceasync fn adjust_auto_created_table_schema(
&self,
schema: &RelationDesc,
) -> Result<(Vec<String>, Vec<ColumnSchema>, bool), Error>
async fn adjust_auto_created_table_schema( &self, schema: &RelationDesc, ) -> Result<(Vec<String>, Vec<ColumnSchema>, bool), Error>
return (primary keys, schema and if the table have a placeholder timestamp column) schema of the table comes from flow’s output plan
adjust to add update_at
column and ts placeholder if needed
Source§impl StreamingEngine
Flow Runtime related methods
impl StreamingEngine
Flow Runtime related methods
Sourceasync fn start_state_report_handler(self: Arc<Self>) -> Option<JoinHandle<()>>
async fn start_state_report_handler(self: Arc<Self>) -> Option<JoinHandle<()>>
Start state report handler, which will receive a sender from HeartbeatTask to send state size report back
if heartbeat task is shutdown, this future will exit too
Sourcepub fn run_background(
self: Arc<Self>,
shutdown: Option<Receiver<()>>,
) -> JoinHandle<()>
pub fn run_background( self: Arc<Self>, shutdown: Option<Receiver<()>>, ) -> JoinHandle<()>
run in common_runtime background runtime
Sourcepub async fn log_all_errors(&self)
pub async fn log_all_errors(&self)
log all flow errors
Sourcepub async fn run(&self, shutdown: Option<Receiver<()>>)
pub async fn run(&self, shutdown: Option<Receiver<()>>)
Trigger dataflow running, and then send writeback request to the source sender
note that this method didn’t handle input mirror request, as this should be handled by grpc server
Sourcepub async fn run_available(&self, blocking: bool) -> Result<usize, Error>
pub async fn run_available(&self, blocking: bool) -> Result<usize, Error>
Run all available subgraph in the flow node This will try to run all dataflow in this node
set blocking
to true to wait until worker finish running
false to just trigger run and return immediately
return numbers of rows send to worker(Inaccuary)
TODO(discord9): add flag for subgraph that have input since last run
Source§impl StreamingEngine
Create&Remove flow
impl StreamingEngine
Create&Remove flow
Sourcepub async fn remove_flow_inner(&self, flow_id: u64) -> Result<(), Error>
pub async fn remove_flow_inner(&self, flow_id: u64) -> Result<(), Error>
remove a flow by it’s id
Sourcepub async fn create_flow_inner(
&self,
args: CreateFlowArgs,
) -> Result<Option<u64>, Error>
pub async fn create_flow_inner( &self, args: CreateFlowArgs, ) -> Result<Option<u64>, Error>
Return task id if a new task is created, otherwise return None
steps to create task:
- parse query into typed plan(and optional parse expire_after expr)
- render source/sink with output table id and used input table id
pub async fn flush_flow_inner(&self, flow_id: u64) -> Result<usize, Error>
pub async fn flow_exist_inner(&self, flow_id: u64) -> Result<bool, Error>
Trait Implementations§
Source§impl FlowEngine for StreamingEngine
impl FlowEngine for StreamingEngine
Source§async fn create_flow(&self, args: CreateFlowArgs) -> Result<Option<u64>, Error>
async fn create_flow(&self, args: CreateFlowArgs) -> Result<Option<u64>, Error>
Source§async fn flush_flow(&self, flow_id: u64) -> Result<usize, Error>
async fn flush_flow(&self, flow_id: u64) -> Result<usize, Error>
Source§async fn list_flows(&self) -> Result<impl IntoIterator<Item = u64>, Error>
async fn list_flows(&self) -> Result<impl IntoIterator<Item = u64>, Error>
Source§impl Flownode for StreamingEngine
impl Flownode for StreamingEngine
fn handle<'life0, 'async_trait>(
&'life0 self,
request: FlowRequest,
) -> Pin<Box<dyn Future<Output = MetaResult<FlowResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn handle_inserts<'life0, 'async_trait>(
&'life0 self,
request: InsertRequests,
) -> Pin<Box<dyn Future<Output = MetaResult<FlowResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl !Freeze for StreamingEngine
impl !RefUnwindSafe for StreamingEngine
impl Send for StreamingEngine
impl Sync for StreamingEngine
impl Unpin for StreamingEngine
impl !UnwindSafe for StreamingEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T, V> Convert<T> for Vwhere
V: Into<T>,
impl<T, V> Convert<T> for Vwhere
V: Into<T>,
fn convert(value: Self) -> T
fn convert_box(value: Box<Self>) -> Box<T>
fn convert_vec(value: Vec<Self>) -> Vec<T>
fn convert_vec_box(value: Vec<Box<Self>>) -> Vec<Box<T>>
fn convert_matrix(value: Vec<Vec<Self>>) -> Vec<Vec<T>>
fn convert_option(value: Option<Self>) -> Option<T>
fn convert_option_box(value: Option<Box<Self>>) -> Option<Box<T>>
fn convert_option_vec(value: Option<Vec<Self>>) -> Option<Vec<T>>
§impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
§impl<T, U, I> LiftInto<U, I> for Twhere
U: LiftFrom<T, I>,
impl<T, U, I> LiftInto<U, I> for Twhere
U: LiftFrom<T, I>,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<Source> Sculptor<HNil, HNil> for Source
impl<Source> Sculptor<HNil, HNil> for Source
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.