org.apache.flink.core.io.InputSplitAssigner Java Examples

The following examples show how to use org.apache.flink.core.io.InputSplitAssigner. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PreAssignedInputSplitAssignerTest.java    From alibaba-flink-connectors with Apache License 2.0 6 votes vote down vote up
private InputSplitAssigner getAssigner() {
	InputSplit[] inputSplits = new InputSplit[NUM_SPLITS];
	int[] taskInputSplitSize = new int[NUM_TASKS];
	int[] taskInputSplitStartIndex = new int[NUM_TASKS];
	for (int i = 0; i < NUM_SPLITS; i++) {
		inputSplits[i] = new MockInputSplit(i);
	}
	int currentSplitIndex = 0;
	for (int i = 0; i < NUM_TASKS; i++) {
		taskInputSplitSize[i] = i + 1;
		taskInputSplitStartIndex[i] = currentSplitIndex;
		currentSplitIndex += taskInputSplitSize[i];
	}
	return new AbstractParallelSourceBase.PreAssignedInputSplitAssigner(
			inputSplits, taskInputSplitSize, taskInputSplitStartIndex);
}
 
Example #2
Source File: AbstractLocatableParallelSource.java    From alibaba-flink-connectors with Apache License 2.0 5 votes vote down vote up
@Override
public InputSplitAssigner getInputSplitAssigner(InputSplit[] inputSplits) {
	LocatableInputSplit[] locatableInputSplits = new LocatableInputSplit[inputSplits.length];
	for (int i = 0; i < inputSplits.length; i++) {
		locatableInputSplits[i] = (LocatableInputSplit) inputSplits[i];
	}
	if (source.isParallelReadDisabled()) {
		return new LocatableInputSplitAssigner(locatableInputSplits);
	}
	return super.getInputSplitAssigner(inputSplits);
}
 
Example #3
Source File: SourceInputFormat.java    From flink-dataflow with Apache License 2.0 5 votes vote down vote up
@Override
public InputSplitAssigner getInputSplitAssigner(final SourceInputSplit[] sourceInputSplits) {
	return new InputSplitAssigner() {
		private int index = 0;
		private final SourceInputSplit[] splits = sourceInputSplits;
		@Override
		public InputSplit getNextInputSplit(String host, int taskId) {
			if (index < splits.length) {
				return splits[index++];
			} else {
				return null;
			}
		}
	};
}
 
Example #4
Source File: AbstractParallelSourceBase.java    From alibaba-flink-connectors with Apache License 2.0 5 votes vote down vote up
@Override
public InputSplitAssigner getInputSplitAssigner(InputSplit[] inputSplits) {
	if (!source.initInputSplitInMaster || source.disableParallelRead) {
		return new DefaultInputSplitAssigner(inputSplits);
	} else {
		return new PreAssignedInputSplitAssigner(inputSplits, taskInputSplitSize, taskInputSplitStartIndex);
	}
}
 
Example #5
Source File: PreAssignedInputSplitAssignerTest.java    From alibaba-flink-connectors with Apache License 2.0 5 votes vote down vote up
@Test
public void testReturnSplits() {
	InputSplitAssigner assigner = getAssigner();
	assertEquals(3, assigner.getNextInputSplit("", 2).getSplitNumber());
	assertEquals(4, assigner.getNextInputSplit("", 2).getSplitNumber());

	// Return split 3 back.
	assigner.returnInputSplit(Collections.singletonList(new MockInputSplit(3)), 2);

	assertEquals(3, assigner.getNextInputSplit("", 2).getSplitNumber());
	assertEquals(5, assigner.getNextInputSplit("", 2).getSplitNumber());
	assertNull(assigner.getNextInputSplit("", 2));
}
 
Example #6
Source File: PreAssignedInputSplitAssignerTest.java    From alibaba-flink-connectors with Apache License 2.0 5 votes vote down vote up
@Test
public void testInitializeAndAssign() {
	InputSplitAssigner assigner = getAssigner();
	assertEquals(0, assigner.getNextInputSplit("", 0).getSplitNumber());
	assertNull(assigner.getNextInputSplit("", 0));
	assertEquals(1, assigner.getNextInputSplit("", 1).getSplitNumber());
	assertEquals(2, assigner.getNextInputSplit("", 1).getSplitNumber());
	assertNull(assigner.getNextInputSplit("", 1));
	assertEquals(3, assigner.getNextInputSplit("", 2).getSplitNumber());
	assertEquals(4, assigner.getNextInputSplit("", 2).getSplitNumber());
	assertEquals(5, assigner.getNextInputSplit("", 2).getSplitNumber());
	assertNull(assigner.getNextInputSplit("", 2));
}
 
Example #7
Source File: Generator.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public InputSplitAssigner getInputSplitAssigner(GenericInputSplit[] inputSplits) {
	return new DefaultInputSplitAssigner(inputSplits);
}
 
Example #8
Source File: InputFormatSourceFunctionTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public InputSplitAssigner getInputSplitAssigner(InputSplit[] inputSplits) {
	return null;
}
 
Example #9
Source File: Generator.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public InputSplitAssigner getInputSplitAssigner(GenericInputSplit[] inputSplits) {
	return new DefaultInputSplitAssigner(inputSplits);
}
 
Example #10
Source File: ExecutionVertex.java    From flink with Apache License 2.0 4 votes vote down vote up
private Execution resetForNewExecutionInternal(final long timestamp, final long originatingGlobalModVersion) {
	final Execution oldExecution = currentExecution;
	final ExecutionState oldState = oldExecution.getState();

	if (oldState.isTerminal()) {
		if (oldState == FINISHED) {
			// pipelined partitions are released in Execution#cancel(), covering both job failures and vertex resets
			// do not release pipelined partitions here to save RPC calls
			oldExecution.handlePartitionCleanup(false, true);
			getExecutionGraph().getPartitionReleaseStrategy().vertexUnfinished(executionVertexId);
		}

		priorExecutions.add(oldExecution.archive());

		final Execution newExecution = new Execution(
			getExecutionGraph().getFutureExecutor(),
			this,
			oldExecution.getAttemptNumber() + 1,
			originatingGlobalModVersion,
			timestamp,
			timeout);

		currentExecution = newExecution;

		synchronized (inputSplits) {
			InputSplitAssigner assigner = jobVertex.getSplitAssigner();
			if (assigner != null) {
				assigner.returnInputSplit(inputSplits, getParallelSubtaskIndex());
				inputSplits.clear();
			}
		}

		CoLocationGroup grp = jobVertex.getCoLocationGroup();
		if (grp != null) {
			locationConstraint = grp.getLocationConstraint(subTaskIndex);
		}

		// register this execution at the execution graph, to receive call backs
		getExecutionGraph().registerExecution(newExecution);

		// if the execution was 'FINISHED' before, tell the ExecutionGraph that
		// we take one step back on the road to reaching global FINISHED
		if (oldState == FINISHED) {
			getExecutionGraph().vertexUnFinished();
		}

		// reset the intermediate results
		for (IntermediateResultPartition resultPartition : resultPartitions.values()) {
			resultPartition.resetForNewExecution();
		}

		return newExecution;
	}
	else {
		throw new IllegalStateException("Cannot reset a vertex that is in non-terminal state " + oldState);
	}
}
 
Example #11
Source File: KeyedStateInputFormat.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public InputSplitAssigner getInputSplitAssigner(KeyGroupRangeInputSplit[] inputSplits) {
	return new DefaultInputSplitAssigner(inputSplits);
}
 
Example #12
Source File: OperatorStateInputFormat.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public InputSplitAssigner getInputSplitAssigner(OperatorStateInputSplit[] inputSplits) {
	return new DefaultInputSplitAssigner(inputSplits);
}
 
Example #13
Source File: ReplicatingInputFormat.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public InputSplitAssigner getInputSplitAssigner(S[] inputSplits) {
	return new ReplicatingInputSplitAssigner(inputSplits);
}
 
Example #14
Source File: ExecutionJobVertex.java    From flink with Apache License 2.0 4 votes vote down vote up
public InputSplitAssigner getSplitAssigner() {
	return splitAssigner;
}
 
Example #15
Source File: CassandraInputFormatBase.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public InputSplitAssigner getInputSplitAssigner(InputSplit[] inputSplits) {
	return new DefaultInputSplitAssigner(inputSplits);
}
 
Example #16
Source File: JdbcRowDataInputFormat.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public InputSplitAssigner getInputSplitAssigner(InputSplit[] inputSplits) {
	return new DefaultInputSplitAssigner(inputSplits);
}
 
Example #17
Source File: JdbcInputFormat.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public InputSplitAssigner getInputSplitAssigner(InputSplit[] inputSplits) {
	return new DefaultInputSplitAssigner(inputSplits);
}
 
Example #18
Source File: InputFormat.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
InputSplitAssigner getInputSplitAssigner(T[] inputSplits);
 
Example #19
Source File: TapInputFormat.java    From cascading-flink with Apache License 2.0 4 votes vote down vote up
@Override
public InputSplitAssigner getInputSplitAssigner(HadoopInputSplit[] inputSplits) {
	return new LocatableInputSplitAssigner(inputSplits);
}
 
Example #20
Source File: ImpulseInputFormat.java    From beam with Apache License 2.0 4 votes vote down vote up
@Override
public InputSplitAssigner getInputSplitAssigner(GenericInputSplit[] genericInputSplits) {
  return new DefaultInputSplitAssigner(genericInputSplits);
}
 
Example #21
Source File: SourceInputFormat.java    From beam with Apache License 2.0 4 votes vote down vote up
@Override
public InputSplitAssigner getInputSplitAssigner(final SourceInputSplit[] sourceInputSplits) {
  return new DefaultInputSplitAssigner(sourceInputSplits);
}
 
Example #22
Source File: KuduRowInputFormat.java    From bahir-flink with Apache License 2.0 4 votes vote down vote up
@Override
public InputSplitAssigner getInputSplitAssigner(KuduInputSplit[] inputSplits) {
    return new LocatableInputSplitAssigner(inputSplits);
}
 
Example #23
Source File: FlinkPravegaInputFormat.java    From flink-connectors with Apache License 2.0 4 votes vote down vote up
@Override
public InputSplitAssigner getInputSplitAssigner(PravegaInputSplit[] inputSplits) {
    return new DefaultInputSplitAssigner(inputSplits);
}
 
Example #24
Source File: StanfordTweetsDataSetInputFormat.java    From flink-examples with MIT License 4 votes vote down vote up
@Override
public InputSplitAssigner getInputSplitAssigner(TweetFileInputSplit[] inputSplits) {
    return new DefaultInputSplitAssigner(inputSplits);
}
 
Example #25
Source File: GenericCsvInputFormat.java    From Alink with Apache License 2.0 4 votes vote down vote up
@Override
public InputSplitAssigner getInputSplitAssigner(CsvFileInputSplit[] inputSplits) {
    return new DefaultInputSplitAssigner(inputSplits);
}
 
Example #26
Source File: KuduInputFormat.java    From flink-learning with Apache License 2.0 4 votes vote down vote up
@Override
public InputSplitAssigner getInputSplitAssigner(KuduInputSplit[] inputSplits) {
    return new LocatableInputSplitAssigner(inputSplits);
}
 
Example #27
Source File: RocksDBKeyedStateInputFormat.java    From bravo with Apache License 2.0 4 votes vote down vote up
@Override
public InputSplitAssigner getInputSplitAssigner(KeyedStateInputSplit[] inputSplits) {
	return new DefaultInputSplitAssigner(inputSplits);
}
 
Example #28
Source File: FileCopyTaskInputFormat.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public InputSplitAssigner getInputSplitAssigner(FileCopyTaskInputSplit[] inputSplits) {
	return new FileCopyTaskAssigner(inputSplits);
}
 
Example #29
Source File: InputFormatSourceFunctionTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public InputSplitAssigner getInputSplitAssigner(InputSplit[] inputSplits) {
	return null;
}
 
Example #30
Source File: FileCopyTaskInputFormat.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public InputSplitAssigner getInputSplitAssigner(FileCopyTaskInputSplit[] inputSplits) {
	return new FileCopyTaskAssigner(inputSplits);
}