use of org.apache.flink.runtime.jobgraph.tasks.InputSplitProviderException in project flink by apache.
the class TaskInputSplitProvider method getNextInputSplit.
@Override
public InputSplit getNextInputSplit(ClassLoader userCodeClassLoader) throws InputSplitProviderException {
Preconditions.checkNotNull(userCodeClassLoader);
final Future<Object> response = jobManager.ask(new JobManagerMessages.RequestNextInputSplit(jobID, vertexID, executionID), timeout);
final Object result;
try {
result = Await.result(response, timeout);
} catch (Exception e) {
throw new InputSplitProviderException("Did not receive next input split from JobManager.", e);
}
if (result instanceof JobManagerMessages.NextInputSplit) {
final JobManagerMessages.NextInputSplit nextInputSplit = (JobManagerMessages.NextInputSplit) result;
byte[] serializedData = nextInputSplit.splitData();
if (serializedData == null) {
return null;
} else {
final Object deserialized;
try {
deserialized = InstantiationUtil.deserializeObject(serializedData, userCodeClassLoader);
} catch (Exception e) {
throw new InputSplitProviderException("Could not deserialize the serialized input split.", e);
}
return (InputSplit) deserialized;
}
} else {
throw new InputSplitProviderException("RequestNextInputSplit requires a response of type " + "NextInputSplit. Instead response is of type " + result.getClass() + '.');
}
}
use of org.apache.flink.runtime.jobgraph.tasks.InputSplitProviderException in project flink by apache.
the class DataSourceTask method getInputSplits.
private Iterator<InputSplit> getInputSplits() {
final InputSplitProvider provider = getEnvironment().getInputSplitProvider();
return new Iterator<InputSplit>() {
private InputSplit nextSplit;
private boolean exhausted;
@Override
public boolean hasNext() {
if (exhausted) {
return false;
}
if (nextSplit != null) {
return true;
}
final InputSplit split;
try {
split = provider.getNextInputSplit(getUserCodeClassLoader());
} catch (InputSplitProviderException e) {
throw new RuntimeException("Could not retrieve next input split.", e);
}
if (split != null) {
this.nextSplit = split;
return true;
} else {
exhausted = true;
return false;
}
}
@Override
public InputSplit next() {
if (this.nextSplit == null && !hasNext()) {
throw new NoSuchElementException();
}
final InputSplit tmp = this.nextSplit;
this.nextSplit = null;
return tmp;
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
}
use of org.apache.flink.runtime.jobgraph.tasks.InputSplitProviderException in project flink by apache.
the class InputFormatSourceFunction method getInputSplits.
private Iterator<InputSplit> getInputSplits() {
return new Iterator<InputSplit>() {
private InputSplit nextSplit;
private boolean exhausted;
@Override
public boolean hasNext() {
if (exhausted) {
return false;
}
if (nextSplit != null) {
return true;
}
final InputSplit split;
try {
split = provider.getNextInputSplit(getRuntimeContext().getUserCodeClassLoader());
} catch (InputSplitProviderException e) {
throw new RuntimeException("Could not retrieve next input split.", e);
}
if (split != null) {
this.nextSplit = split;
return true;
} else {
exhausted = true;
return false;
}
}
@Override
public InputSplit next() {
if (this.nextSplit == null && !hasNext()) {
throw new NoSuchElementException();
}
final InputSplit tmp = this.nextSplit;
this.nextSplit = null;
return tmp;
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
}
use of org.apache.flink.runtime.jobgraph.tasks.InputSplitProviderException in project flink by apache.
the class RpcInputSplitProvider method getNextInputSplit.
@Override
public InputSplit getNextInputSplit(ClassLoader userCodeClassLoader) throws InputSplitProviderException {
Preconditions.checkNotNull(userCodeClassLoader);
Future<SerializedInputSplit> futureInputSplit = jobMasterGateway.requestNextInputSplit(jobMasterLeaderId, jobVertexID, executionAttemptID);
try {
SerializedInputSplit serializedInputSplit = futureInputSplit.get(timeout.getSize(), timeout.getUnit());
if (serializedInputSplit.isEmpty()) {
return null;
} else {
return InstantiationUtil.deserializeObject(serializedInputSplit.getInputSplitData(), userCodeClassLoader);
}
} catch (Exception e) {
throw new InputSplitProviderException("Requesting the next input split failed.", e);
}
}
Aggregations