Class ChalkFeatureUploader
- All Implemented Interfaces:
AutoCloseable
upload_features. Accumulates feature rows and flushes
them as a single columnar upload when the buffer fills (see add(java.util.Map<java.lang.String, java.lang.Object>)), or when the owning sink
asks (checkpoint / close). Retries transient failures (gRPC UNAVAILABLE / DEADLINE_EXCEEDED
/ RESOURCE_EXHAUSTED / ABORTED) with exponential backoff until the retryTimeout budget is
spent; non-transient failures (auth, invalid argument) are thrown immediately. On exhaustion it
throws, letting the caller (a Flink sink) fail and replay from the last checkpoint — at-least-once,
made safe by upsert semantics.
The budget is time, not attempts, so it survives a backend rollout of a known duration regardless of how the backoff is tuned. Retries run inline on the task thread, so the budget is also the worst-case subtask stall.
Flush latency is bounded by min(batchSize reached, checkpoint interval). The
configured flush interval is a best-effort upper bound evaluated when the next element arrives; on
a fully idle stream a partial buffer is drained by the next checkpoint (or close), not by a
background timer — there is none. At-least-once therefore requires checkpointing to be enabled.
All mutating methods are synchronized defensively. Flink's mailbox model already runs
invoke/write, snapshotState/flush, and close serially on a
single task thread, so this guards only against unexpected external callers.
-
Constructor Summary
ConstructorsConstructorDescriptionChalkFeatureUploader(ChalkSinkConfig config) Production constructor: builds the real gRPC-backed client from config.ChalkFeatureUploader(ChalkSinkConfig config, ChalkUploadClient client) Test/advanced constructor: inject a customChalkUploadClient. -
Method Summary
-
Constructor Details
-
ChalkFeatureUploader
Production constructor: builds the real gRPC-backed client from config. -
ChalkFeatureUploader
Test/advanced constructor: inject a customChalkUploadClient.
-
-
Method Details
-
add
Buffer one row; flush if the batch is full or the flush interval has elapsed. -
flush
public void flush()Upload the buffered rows as one columnar batch, then clear the buffer. No-op if empty. -
bufferedRows
public int bufferedRows()Rows currently buffered (not yet uploaded). Exposed for metrics/tests. -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-