public class TestPubsubSignal extends java.lang.Object implements TestRule
PCollection
and checks whether they match the
success criteria.
Uses a random temporary Pubsub topic for synchronization.
Modifier and Type | Method and Description |
---|---|
Statement |
apply(Statement base,
Description description) |
static TestPubsubSignal |
create()
Creates an instance of this rule.
|
PTransform<PBegin,PDone> |
signalStart()
Outputs a message that the pipeline has started.
|
<T> PTransform<PCollection<? extends T>,POutput> |
signalSuccessWhen(Coder<T> coder,
SerializableFunction<java.util.Set<T>,java.lang.Boolean> successPredicate)
Invocation of
signalSuccessWhen(Coder, SerializableFunction, SerializableFunction)
with Object.toString() as the formatter. |
<T> PTransform<PCollection<? extends T>,POutput> |
signalSuccessWhen(Coder<T> coder,
SerializableFunction<T,java.lang.String> formatter,
SerializableFunction<java.util.Set<T>,java.lang.Boolean> successPredicate)
Outputs a success message when
successPredicate is evaluated to true. |
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Supplier<java.lang.Void> |
waitForStart(Duration duration)
Future that waits for a start signal for
duration . |
void |
waitForSuccess(Duration duration)
Wait for a success signal for
duration . |
public static TestPubsubSignal create()
Loads GCP configuration from TestPipelineOptions
.
public Statement apply(Statement base, Description description)
public PTransform<PBegin,PDone> signalStart()
public <T> PTransform<PCollection<? extends T>,POutput> signalSuccessWhen(Coder<T> coder, SerializableFunction<T,java.lang.String> formatter, SerializableFunction<java.util.Set<T>,java.lang.Boolean> successPredicate)
successPredicate
is evaluated to true.
successPredicate
is a SerializableFunction
that accepts a set of currently
captured events and returns true when the set satisfies the success criteria.
If successPredicate
is evaluated to false, then it will be re-evaluated when next
event becomes available.
If successPredicate
is evaluated to true, then a success will be signaled and waitForSuccess(Duration)
will unblock.
If successPredicate
throws, then failure will be signaled and waitForSuccess(Duration)
will unblock.
public <T> PTransform<PCollection<? extends T>,POutput> signalSuccessWhen(Coder<T> coder, SerializableFunction<java.util.Set<T>,java.lang.Boolean> successPredicate)
signalSuccessWhen(Coder, SerializableFunction, SerializableFunction)
with Object.toString()
as the formatter.public org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Supplier<java.lang.Void> waitForStart(Duration duration)
duration
.
This future must be created before running the pipeline. A subscription must exist prior to the start signal being published, which occurs immediately upon pipeline startup.
public void waitForSuccess(Duration duration) throws java.io.IOException
duration
.java.io.IOException