Class Source
- java.lang.Object
-
- io.github.punchplatform.api.punchline.Node
-
- io.github.punchplatform.api.punchline.java.Source
-
public abstract class Source extends io.github.punchplatform.api.punchline.NodeExtend this class to implement a source.
-
-
Field Summary
Fields Modifier and Type Field Description protected io.github.punchplatform.api.punchline.metrics.MetricContextmetricContextThe metric context to create gauges, histograms and counters.
-
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(io.github.punchplatform.api.punchline.Out out, List<Object> values, Object ctx)Insert a row into an output.protected voidinsert(List<io.github.punchplatform.api.punchline.Out> outs, List<Object> values, Object ctx)Insert a row toward several destinations.voidsetMetricContext(io.github.punchplatform.api.punchline.metrics.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.
-
-
-
Method Detail
-
start
public abstract void start() throws IOException, io.github.punchplatform.api.exceptions.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 errorio.github.punchplatform.api.exceptions.ConfigurationException- in case of configuration error.
-
insert
protected void insert(io.github.punchplatform.api.punchline.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<io.github.punchplatform.api.punchline.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(io.github.punchplatform.api.punchline.metrics.MetricContext metricContext)
-
-