Package org.apache.iotdb.pipe.api
Interface PipeSink
- All Superinterfaces:
AutoCloseable,PipeConnector,PipePlugin
PipeSink
PipeSink is responsible for sending Events to sinks.
Various network protocols can be supported by implementing different PipeSink classes.
The lifecycle of a PipeSink is as follows:
- When a collaboration task is created, the KV pairs of `WITH SINK` clause in SQL are parsed
and the validation method
validate(PipeParameterValidator)will be called to validate the parameters. - Before the collaboration task starts, the method
customize(PipeParameters, PipeSinkRuntimeConfiguration)will be called to configure the runtime behavior of the PipeSink and the methodhandshake()will be called to create a connection with sink. - While the collaboration task is in progress:
PipeSourcecaptures theEvents and wraps them into three types ofEventinstances.PipeProcessorprocesses theEventand then passes them to thePipeSink.PipeSinkserializes theEvents into binaries and send them to sinks. The following 3 methods will be called:transfer(TabletInsertionEvent),transfer(TsFileInsertionEvent)andtransfer(Event).
- When the collaboration task is cancelled (the `DROP PIPE` command is executed), the
AutoCloseable.close()method will be called.
In addition, the method heartbeat() will be called periodically to check
whether the connection with sink is still alive. The method handshake() will be
called to create a new connection with the sink when the method heartbeat()
throws exceptions.
-
Method Summary
Modifier and TypeMethodDescriptionvoidcustomize(PipeParameters parameters, PipeSinkRuntimeConfiguration configuration) This method is mainly used to customizePipeSink.voidThis method is used to create a connection with sink.voidThis method will be called periodically to check whether the connection with sink is still alive.voidtransfer(TabletInsertionEvent tabletInsertionEvent) This method is used to transfer theTabletInsertionEvent.default voidtransfer(TsFileInsertionEvent tsFileInsertionEvent) This method is used to transfer theTsFileInsertionEvent.voidThis method is used to transfer the genericEvents, including HeartbeatEvent.voidvalidate(PipeParameterValidator validator) This method is mainly used to validatePipeParametersand it is executed beforecustomize(PipeParameters, PipeSinkRuntimeConfiguration)is called.Methods inherited from interface java.lang.AutoCloseable
closeMethods inherited from interface org.apache.iotdb.pipe.api.PipeConnector
customize
-
Method Details
-
validate
This method is mainly used to validatePipeParametersand it is executed beforecustomize(PipeParameters, PipeSinkRuntimeConfiguration)is called.- Specified by:
validatein interfacePipeConnector- Parameters:
validator- the validator used to validatePipeParameters- Throws:
Exception- if any ofPipeParametersis not valid
-
customize
void customize(PipeParameters parameters, PipeSinkRuntimeConfiguration configuration) throws Exception This method is mainly used to customizePipeSink. In this method, the user can do the following things:- Use
PipeParametersto parse key-value pair attributes entered by the user. - Set the running configurations in
PipeSinkRuntimeConfiguration.
This method is called after the method
validate(PipeParameterValidator)is called and before the methodhandshake()is called.- Parameters:
parameters- used to parse the inputPipeParametersentered by the userconfiguration- used to set the required properties of the running PipeSink- Throws:
Exception- the user can throw errors if necessary
- Use
-
handshake
This method is used to create a connection with sink. This method will be called after the methodcustomize(PipeParameters, PipeSinkRuntimeConfiguration)is called or will be called when the methodheartbeat()throws exceptions.- Specified by:
handshakein interfacePipeConnector- Throws:
Exception- if the connection is failed to be created
-
heartbeat
This method will be called periodically to check whether the connection with sink is still alive.- Specified by:
heartbeatin interfacePipeConnector- Throws:
Exception- if the connection dies
-
transfer
This method is used to transfer theTabletInsertionEvent.- Specified by:
transferin interfacePipeConnector- Parameters:
tabletInsertionEvent-TabletInsertionEventto be transferred- Throws:
PipeConnectionException- if the connection is brokenException- the user can throw errors if necessary
-
transfer
This method is used to transfer theTsFileInsertionEvent.- Specified by:
transferin interfacePipeConnector- Parameters:
tsFileInsertionEvent-TsFileInsertionEventto be transferred- Throws:
PipeConnectionException- if the connection is brokenException- the user can throw errors if necessary
-
transfer
This method is used to transfer the genericEvents, including HeartbeatEvent.- Specified by:
transferin interfacePipeConnector- Parameters:
event-Eventto be transferred- Throws:
PipeConnectionException- if the connection is brokenException- the user can throw errors if necessary
-