Class Source
- java.lang.Object
-
- io.github.punchplatform.api.punchline.Node
-
- io.github.punchplatform.api.punchline.java.Source
-
public abstract class Source extends Node
Extend this class to implement a source.
-
-
Field Summary
Fields Modifier and Type Field Description protected MetricContextmetricContextThe metric context to create gauges, histograms and counters.protected SourceTableCollectortableCollectorThe private table collector in charge of inserting rows into the target tables.-
Fields inherited from class io.github.punchplatform.api.punchline.Node
engineSettings, exitConditions, id, kind, load_control, out, punchline, settings, taskId, type
-
-
Constructor Summary
Constructors Constructor Description Source()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidack(Object ctx)Acknowledge a row.abstract voidfail(Object ctx)Fail a row.protected voidinsert(Out out, List<Object> values, Object ctx)Insert a row into an output.protected voidinsert(List<Out> outs, List<Object> values, Object ctx)Insert a row toward several destinations.voidsetMetricContext(MetricContext metricContext)voidsetTableCollector(SourceTableCollector tableCollector)Setter to make it clearer to source implementor to not refer directly to the collector.abstract voidstart()Start your source.
-
-
-
Field Detail
-
metricContext
protected MetricContext metricContext
The metric context to create gauges, histograms and counters.
-
tableCollector
protected SourceTableCollector tableCollector
The private table collector in charge of inserting rows into the target tables. Not visible from source implementations.
-
-
Method Detail
-
start
public abstract void start() throws IOException, ConfigurationExceptionStart your source. This method never return for streaming source, and return or exit for batch source.This call is expected to never return. You can take ownership of the calling thread in a way you like. Whenever you return, the punchline will stop soon after.
- Throws:
IOException- in case of IO errorConfigurationException- in case of configuration error.
-
insert
protected void insert(Out out, List<Object> values, Object ctx)
Insert a row into an output. Remember an output is associated to a table.This call is potentially blocking if the max number of inserted rows has been reached. Eventually it will return because pending rows will eventually be acked or failed.
This blocking behavior is what you want so as to slow down automatically the insertions of new rows in the punchline.
- Parameters:
out- the outputvalues- the column valuesctx- an optional context object
-
insert
protected void insert(List<Out> outs, List<Object> values, Object ctx)
Insert a row toward several destinations.- Parameters:
outs- the outputsvalues- the column valuesctx- an optional context object
-
ack
public abstract void ack(Object ctx)
Acknowledge a row. What you receive is an arbitrary context object provided at insertion time.Watch out this is up called from a runtime punchline thread. Do not block it.
- Parameters:
ctx- an arbitrary object provide at insert time
-
fail
public abstract void fail(Object ctx)
Fail a row. What you receive is an arbitrary context object provided at insertion time.- Parameters:
ctx- an arbitrary object provide at insert time
-
setTableCollector
public void setTableCollector(SourceTableCollector tableCollector)
Setter to make it clearer to source implementor to not refer directly to the collector.- Parameters:
tableCollector- collector to use
-
setMetricContext
public void setMetricContext(MetricContext metricContext)
-
-