Skip to content

[FLINK-37308] Support pauseOrResumeSplits in HybridSource #26483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -247,4 +248,10 @@ private void setCurrentReader(int index) {
addSplits(splits);
}
}

@Override
public void pauseOrResumeSplits(
Collection<String> splitsToPause, Collection<String> splitsToResume) {
currentReader.pauseOrResumeSplits(splitsToPause, splitsToResume);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,33 @@ public SourceReader<Integer, MockSourceSplit> createReader(
reader.close();
}

@Test
void testPauseResumeCurrentSourceSplits() throws Exception {
TestingReaderContext readerContext = new TestingReaderContext();
MockBaseSource source =
new MockBaseSource(1, 1, Boundedness.BOUNDED) {
@Override
public SourceReader<Integer, MockSourceSplit> createReader(
SourceReaderContext readerContext) {
return Mockito.spy(super.createReader(readerContext));
}
};

HybridSourceReader<Integer> reader = new HybridSourceReader<>(readerContext);

reader.start();
assertAndClearSourceReaderFinishedEvent(readerContext, -1);
reader.handleSourceEvents(new SwitchSourceEvent(0, source, false));
SourceReader<Integer, MockSourceSplit> underlyingReader = currentReader(reader);

reader.pauseOrResumeSplits(
Collections.singletonList("foo"), Collections.singletonList("bar"));
Mockito.verify(underlyingReader)
.pauseOrResumeSplits(
Collections.singletonList("foo"), Collections.singletonList("bar"));
reader.close();
}

private static SourceReader<Integer, MockSourceSplit> currentReader(
HybridSourceReader<?> reader) {
return Whitebox.getInternalState(reader, "currentReader");
Expand Down