Class CloudTasksWriterOptions.Builder

java.lang.Object
io.github.flink.gcp.connector.cloudtasks.sink.CloudTasksWriterOptions.Builder
Enclosing class:
CloudTasksWriterOptions

@Public public static final class CloudTasksWriterOptions.Builder extends Object
  • Method Details

    • maxInFlightTasks

      public CloudTasksWriterOptions.Builder maxInFlightTasks(int maxInFlightTasks)
      Caps the task creations the writer keeps outstanding — those in flight plus those waiting out a retry backoff. A write at the cap yields to the task mailbox until creations complete, bounding sink memory between checkpoints. Defaults to 1000.
      Parameters:
      maxInFlightTasks - the in-flight cap, positive
      Returns:
      this builder
    • channelPoolSize

      public CloudTasksWriterOptions.Builder channelPoolSize(int channelPoolSize)
      Sizes the client's gRPC channel pool. Unset by default, leaving the client's own transport configuration — one channel — alone.

      One HTTP/2 channel carries about 100 concurrent streams, so the default transport delivers only ~100 of the in-flight cap's nominal concurrency no matter how high the cap is set; a subtask that needs more concurrent creates than that needs more channels, about one per 100 concurrent creates. Raising it can push a single subtask past the queue's recommended ~1,000 TPS ceiling — mind the documented ramp guidance before doing so. Rejected in combination with an emulator endpoint when the sink is built: the emulator always uses one plaintext channel, so the pool would be silently ignored.

      Parameters:
      channelPoolSize - the number of gRPC channels, positive
      Returns:
      this builder
    • recoveryInitialBackoff

      public CloudTasksWriterOptions.Builder recoveryInitialBackoff(Duration recoveryInitialBackoff)
      Sets the first backoff of the transient-failure retry (UNAVAILABLE, DEADLINE_EXCEEDED, RESOURCE_EXHAUSTED). Defaults to 100 ms.
      Parameters:
      recoveryInitialBackoff - the first backoff, at least 1 ms
      Returns:
      this builder
    • recoveryMaxBackoff

      public CloudTasksWriterOptions.Builder recoveryMaxBackoff(Duration recoveryMaxBackoff)
      Caps the backoff of the transient-failure retry. Defaults to 10 s.
      Parameters:
      recoveryMaxBackoff - the backoff cap, at least 1 ms and at least the initial backoff
      Returns:
      this builder
    • recoveryMaxAttempts

      public CloudTasksWriterOptions.Builder recoveryMaxAttempts(int recoveryMaxAttempts)
      Caps the attempts of the transient-failure retry, the initial creation included. Defaults to 8; exhausting the budget fails the job.
      Parameters:
      recoveryMaxAttempts - the maximum attempts, positive
      Returns:
      this builder
    • notFoundRecoveryInitialBackoff

      public CloudTasksWriterOptions.Builder notFoundRecoveryInitialBackoff(Duration notFoundRecoveryInitialBackoff)
      Sets the first backoff of the NOT_FOUND retry. Defaults to 500 ms.
      Parameters:
      notFoundRecoveryInitialBackoff - the first backoff, at least 1 ms
      Returns:
      this builder
    • notFoundRecoveryMaxBackoff

      public CloudTasksWriterOptions.Builder notFoundRecoveryMaxBackoff(Duration notFoundRecoveryMaxBackoff)
      Caps the backoff of the NOT_FOUND retry. Defaults to 2 s.
      Parameters:
      notFoundRecoveryMaxBackoff - the backoff cap, at least 1 ms and at least the initial backoff
      Returns:
      this builder
    • notFoundRecoveryMaxAttempts

      public CloudTasksWriterOptions.Builder notFoundRecoveryMaxAttempts(int notFoundRecoveryMaxAttempts)
      Caps the attempts of the NOT_FOUND retry, the initial creation included. Defaults to 3: long enough to ride out a queue that is briefly unavailable, short enough that a mistyped queue name fails quickly. A queue that takes minutes to re-activate outlives this budget on purpose — recovering from that is the job's restart strategy, not the writer's.
      Parameters:
      notFoundRecoveryMaxAttempts - the maximum attempts, positive
      Returns:
      this builder
    • perDestinationMetrics

      public CloudTasksWriterOptions.Builder perDestinationMetrics(boolean perDestinationMetrics)
      Registers per-queue recordsSend and sendErrors counters beside the writer's totals. Defaults to false.

      Off by default because Flink cannot unregister a metric: with a per-record destinationResolver the queue set is unbounded, so every queue the job ever writes to keeps a row in the metric registry for the lifetime of the task. Switch it on for a sink whose queues are few and known — a fixed queue(...) especially.

      Parameters:
      perDestinationMetrics - whether to register per-queue counters
      Returns:
      this builder
    • build

      public CloudTasksWriterOptions build()
      Builds the options.
      Returns:
      the options