// this is wraps the normal roll sink with an extra roll detection
// decorator that triggers ack delivery on close.
@Override
public EventSink newSink(Context ctx) throws IOException {
String tag = tagger.newTag();
EventSink drain;
try {
drain = new CompositeSink(ctx, snkSpec);
} catch (FlumeSpecException e) {
throw new IOException("Unable to instantiate '" + snkSpec + "'", e);
}
return new RollDetectDeco(drain, tag);
}
};
long initMs = FlumeConfiguration.get().getInsistentOpenInitBackoff();
long cumulativeMaxMs = FlumeConfiguration.get()
.getFailoverMaxCumulativeBackoff();
long maxMs = FlumeConfiguration.get().getFailoverMaxSingleBackoff();
BackoffPolicy backoff1 = new CumulativeCappedExponentialBackoff(initMs,
maxMs, cumulativeMaxMs);
BackoffPolicy backoff2 = new CumulativeCappedExponentialBackoff(initMs,
maxMs, cumulativeMaxMs);
// the collector snk has ack checking logic, retry and reopen logic, and
// needs an extra mask before rolling, writing to disk and forwarding acks
// (roll detect).
// { ackChecksumChecker => insistentAppend => stubbornAppend =>
// insistentOpen => mask("rolltag") => roll(xx) { rollDetect =>
// subsink } }
EventSink tmp = new MaskDecorator<EventSink>(roller, "rolltag");
tmp = new InsistentOpenDecorator<EventSink>(tmp, backoff1);
tmp = new StubbornAppendSink<EventSink>(tmp);
tmp = new InsistentAppendDecorator<EventSink>(tmp, backoff2);
snk = new AckChecksumChecker<EventSink>(tmp, accum);
}