Interface SourceFunction.SourceContext<T>
- Type Parameters:
T- The type of the elements produced by the source.
- Enclosing interface:
- SourceFunction<T>
@Public
public static interface SourceFunction.SourceContext<T>
Interface that source functions use to emit elements, and possibly watermarks.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()This method is called by the system to shut down the context.voidEmits one element from the source, without attaching a timestamp.voidcollectWithTimestamp(T element, long timestamp) Emits one element from the source, and attaches the given timestamp.voidemitWatermark(Watermark mark) Emits the givenWatermark.Returns the checkpoint lock.voidMarks the source to be temporarily idle.
-
Method Details
-
collect
Emits one element from the source, without attaching a timestamp. In most cases, this is the default way of emitting elements.The element will have no timestamp initially. If timestamps and watermarks are required, for example for event-time windows, timers, or joins, then you need to assign a timestamp via
DataStream.assignTimestampsAndWatermarks(WatermarkStrategy)and set a strategy that assigns timestamps (for example usingWatermarkStrategy.withTimestampAssigner(TimestampAssignerSupplier)).- Parameters:
element- The element to emit
-
collectWithTimestamp
Emits one element from the source, and attaches the given timestamp.- Parameters:
element- The element to emittimestamp- The timestamp in milliseconds since the Epoch
-
emitWatermark
Emits the givenWatermark. A Watermark of valuetdeclares that no elements with a timestampt' <= twill occur any more. If further such elements will be emitted, those elements are considered late.- Parameters:
mark- The Watermark to emit
-
markAsTemporarilyIdle
@PublicEvolving void markAsTemporarilyIdle()Marks the source to be temporarily idle. This tells the system that this source will temporarily stop emitting records and watermarks for an indefinite amount of time.Source functions should make a best effort to call this method as soon as they acknowledge themselves to be idle. The system will consider the source to resume activity again once
collect(T),collectWithTimestamp(T, long), oremitWatermark(Watermark)is called to emit elements or watermarks from the source. -
getCheckpointLock
Object getCheckpointLock()Returns the checkpoint lock. Please refer to the class-level comment inSourceFunctionfor details about how to write a consistent checkpointed source.- Returns:
- The object to use as the lock
-
close
void close()This method is called by the system to shut down the context.
-