All Downloads are FREE. Search and download functionalities are using the official Maven repository.

co.decodable.sdk.pipeline.internal.DelegatingSplitEnumeratorContext Maven / Gradle / Ivy

Go to download

A software development kit for implementing Apache Flink jobs and running them on Decodable

There is a newer version: 1.0.0.Beta7
Show newest version
/*
 * SPDX-License-Identifier: Apache-2.0
 *
 * Copyright Decodable, Inc.
 *
 * Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
 */
package co.decodable.sdk.pipeline.internal;

import co.decodable.sdk.pipeline.DecodableSourceSplit;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;
import org.apache.flink.api.connector.source.ReaderInfo;
import org.apache.flink.api.connector.source.SourceEvent;
import org.apache.flink.api.connector.source.SplitEnumeratorContext;
import org.apache.flink.api.connector.source.SplitsAssignment;
import org.apache.flink.connector.kafka.source.split.KafkaPartitionSplit;
import org.apache.flink.metrics.groups.SplitEnumeratorMetricGroup;

public class DelegatingSplitEnumeratorContext
    implements SplitEnumeratorContext {

  private final SplitEnumeratorContext delegate;

  public DelegatingSplitEnumeratorContext(SplitEnumeratorContext delegate) {
    this.delegate = delegate;
  }

  @Override
  public SplitEnumeratorMetricGroup metricGroup() {
    return delegate.metricGroup();
  }

  @Override
  public void sendEventToSourceReader(int subtaskId, SourceEvent event) {
    delegate.sendEventToSourceReader(subtaskId, event);
  }

  @Override
  public int currentParallelism() {
    return delegate.currentParallelism();
  }

  @Override
  public Map registeredReaders() {
    return delegate.registeredReaders();
  }

  @Override
  public void assignSplits(SplitsAssignment newSplitAssignments) {
    Map> delegateAssignments =
        newSplitAssignments.assignment().entrySet().stream()
            .collect(
                Collectors.toMap(
                    e -> e.getKey(),
                    e ->
                        e.getValue().stream()
                            .map(DecodableSourceSplitImpl::new)
                            .collect(Collectors.toList())));

    delegate.assignSplits(new SplitsAssignment(delegateAssignments));
  }

  @Override
  public void signalNoMoreSplits(int subtask) {
    delegate.signalNoMoreSplits(subtask);
  }

  @Override
  public  void callAsync(Callable callable, BiConsumer handler) {
    delegate.callAsync(callable, handler);
  }

  @Override
  public  void callAsync(
      Callable callable,
      BiConsumer handler,
      long initialDelayMillis,
      long periodMillis) {
    delegate.callAsync(callable, handler, initialDelayMillis, periodMillis);
  }

  @Override
  public void runInCoordinatorThread(Runnable runnable) {
    delegate.runInCoordinatorThread(runnable);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy