Package cz.o2.proxima.beam.tools.groovy
Class BeamStreamProvider
- java.lang.Object
-
- cz.o2.proxima.beam.tools.groovy.BeamStreamProvider
-
- All Implemented Interfaces:
StreamProvider,java.io.Closeable,java.lang.AutoCloseable
- Direct Known Subclasses:
BeamStreamProvider.Default
public abstract class BeamStreamProvider extends java.lang.Object implements StreamProvider
AStreamProviderfor groovy tools based on beam.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBeamStreamProvider.Defaultstatic interfaceBeamStreamProvider.RunnerRegistrar-
Nested classes/interfaces inherited from interface cz.o2.proxima.tools.groovy.StreamProvider
StreamProvider.TerminatePredicate
-
-
Constructor Summary
Constructors Constructor Description BeamStreamProvider()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close and release all resources.WindowedStream<StreamElement>getBatchSnapshot(long fromStamp, long toStamp, StreamProvider.TerminatePredicate terminateCheck, AttributeDescriptor<?>... attrs)Retrieve batch snapshot stream.WindowedStream<StreamElement>getBatchUpdates(long startStamp, long endStamp, StreamProvider.TerminatePredicate terminateCheck, AttributeDescriptor<?>... attrs)Retrieve batch updates stream.protected UnaryFunction<org.apache.beam.sdk.options.PipelineOptions,org.apache.beam.sdk.Pipeline>getCreatePipelineFromOpts()ConvertPipelineOptionsintoPipeline.protected java.util.function.Supplier<org.apache.beam.sdk.options.PipelineOptions>getPipelineOptionsFactory()Create factory to be used for pipeline creation.Stream<StreamElement>getStream(Position position, boolean stopAtCurrent, boolean eventTime, StreamProvider.TerminatePredicate terminateCheck, AttributeDescriptor<?>... attrs)Create stream from commit log(s).<T> WindowedStream<T>impulse(java.lang.String name, groovy.lang.Closure<T> factory)Return newWindowedStreamthat contains single element generated by calling given (parameterless)Closure.voidinit(Repository repo, java.lang.String[] args)Initialize the provider with given repository.<T> WindowedStream<T>periodicImpulse(java.lang.String name, groovy.lang.Closure<T> factory, long durationMs)Create newWindowedStreamthat contains single element per fixed time windowed.static <T> Stream<T>wrap(Repository repo, org.apache.beam.sdk.values.PCollection<T> pCollection)Create aStreamfrom givenPCollection.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface cz.o2.proxima.tools.groovy.StreamProvider
impulse, periodicImpulse
-
-
-
-
Method Detail
-
wrap
public static <T> Stream<T> wrap(Repository repo, org.apache.beam.sdk.values.PCollection<T> pCollection)
Create aStreamfrom givenPCollection.- Parameters:
repo-Repositoryto usepCollection- thePCollectionto wrap- Returns:
PCollectionwrapped asStream.
-
init
public void init(Repository repo, java.lang.String[] args)
Description copied from interface:StreamProviderInitialize the provider with given repository.- Specified by:
initin interfaceStreamProvider- Parameters:
repo- the repositoryargs- command line arguments passed toConsole
-
getStream
public Stream<StreamElement> getStream(Position position, boolean stopAtCurrent, boolean eventTime, StreamProvider.TerminatePredicate terminateCheck, AttributeDescriptor<?>... attrs)
Description copied from interface:StreamProviderCreate stream from commit log(s).- Specified by:
getStreamin interfaceStreamProvider- Parameters:
position- position in commit logstopAtCurrent-trueto stop at current dataeventTime-trueto process using event timeterminateCheck-Predicatethat tests if the execution of any terminal operation should be interruptedattrs- attributes to get stream for- Returns:
- stream from commit log
-
getBatchUpdates
public WindowedStream<StreamElement> getBatchUpdates(long startStamp, long endStamp, StreamProvider.TerminatePredicate terminateCheck, AttributeDescriptor<?>... attrs)
Description copied from interface:StreamProviderRetrieve batch updates stream.- Specified by:
getBatchUpdatesin interfaceStreamProvider- Parameters:
startStamp- starting stamp (inclusive)endStamp- ending stamp (exclusive)terminateCheck-Predicatethat tests if the execution of any terminal operation should be interruptedattrs- attributes to read- Returns:
- globally windowed stream
-
getBatchSnapshot
public WindowedStream<StreamElement> getBatchSnapshot(long fromStamp, long toStamp, StreamProvider.TerminatePredicate terminateCheck, AttributeDescriptor<?>... attrs)
Description copied from interface:StreamProviderRetrieve batch snapshot stream.- Specified by:
getBatchSnapshotin interfaceStreamProvider- Parameters:
fromStamp- starting stamp (inclusive)toStamp- ending stamp (exclusive)terminateCheck-Predicatethat tests if the execution of any terminal operation should be interruptedattrs- attributes to read- Returns:
- globally windowed stream
-
impulse
public <T> WindowedStream<T> impulse(java.lang.String name, groovy.lang.Closure<T> factory)
Description copied from interface:StreamProviderReturn newWindowedStreamthat contains single element generated by calling given (parameterless)Closure.- Specified by:
impulsein interfaceStreamProvider- Type Parameters:
T- type of the resulting stream- Parameters:
name- name of the transformfactory- the closure that generates the element- Returns:
- globally windowed stream with single element
-
periodicImpulse
public <T> WindowedStream<T> periodicImpulse(java.lang.String name, groovy.lang.Closure<T> factory, long durationMs)
Description copied from interface:StreamProviderCreate newWindowedStreamthat contains single element per fixed time windowed.- Specified by:
periodicImpulsein interfaceStreamProvider- Type Parameters:
T- type of the resulting stream- Parameters:
name- name of the transformfactory- the closure that generates the elementdurationMs- duration of the fixed time window in ms- Returns:
- globally windowed stream with single element
-
close
public void close()
Description copied from interface:StreamProviderClose and release all resources.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfaceStreamProvider
-
getPipelineOptionsFactory
protected java.util.function.Supplier<org.apache.beam.sdk.options.PipelineOptions> getPipelineOptionsFactory()
Create factory to be used for pipeline creation.- Returns:
- the factory
-
getCreatePipelineFromOpts
protected UnaryFunction<org.apache.beam.sdk.options.PipelineOptions,org.apache.beam.sdk.Pipeline> getCreatePipelineFromOpts()
ConvertPipelineOptionsintoPipeline.- Returns:
- function to use for creating pipeline from options
-
-