Skip to content
Merged
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 @@ -76,9 +76,9 @@ public void mapRebalanceMapRescaleMapSink(InputBenchmarkFlinkEnvironmentContext
DataStreamSource<Long> source = sourceType.source(env, RECORDS_PER_INVOCATION);
source.map(new MultiplyByTwo())
.rebalance()
.map(new SkewableHigherMultiply(1, 0, 5))
.map(new SkewableHigherMultiply(1, 100, 0, 5))
.rescale()
.map(new SkewableHigherMultiply(1, 0, 5))
.map(new SkewableHigherMultiply(1, 100, 0, 5))
.sinkTo(new DiscardingSink<>());

env.execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,33 @@

public class SkewableHigherMultiply extends RichMapFunction<Long, Long> {

private final int additionalCostMillisPerRecord;
private final int additionalCostMillisPerBatch;
private final int recordsPerBatch;
private int numRecordsForCurrentBatch;
private final Set<Integer> expectedSkewedSubTasksIndexes;

public SkewableHigherMultiply(
int additionalCostMillisPerRecord, Integer... expectedSkewedSubTasksIndexes) {
this.additionalCostMillisPerRecord = additionalCostMillisPerRecord;
int additionalCostMillisPerBatch,
int recordsPerBatch,
Integer... expectedSkewedSubTasksIndexes) {
this.additionalCostMillisPerBatch = additionalCostMillisPerBatch;
this.recordsPerBatch = recordsPerBatch;
this.expectedSkewedSubTasksIndexes =
new HashSet<>(Arrays.asList(expectedSkewedSubTasksIndexes));
}

@Override
public Long map(Long value) throws Exception {
double base = value * 2.0d;
if (additionalCostMillisPerRecord <= 0) {
if (additionalCostMillisPerBatch <= 0) {
return (long) base;
} else {
if (expectedSkewedSubTasksIndexes.contains(
getRuntimeContext().getTaskInfo().getIndexOfThisSubtask())) {
Thread.sleep(additionalCostMillisPerRecord);
if (++numRecordsForCurrentBatch == recordsPerBatch) {
numRecordsForCurrentBatch = 0;
Thread.sleep(additionalCostMillisPerBatch);
}
}
return (long) base;
}
Expand Down
Loading