public static class OneToOneSourceSplitTransition implements
MultipleArcTransition<VertexImpl, VertexEvent, VertexState> {
@Override
public VertexState transition(VertexImpl vertex, VertexEvent event) {
VertexEventOneToOneSourceSplit splitEvent =
(VertexEventOneToOneSourceSplit)event;
TezVertexID originalSplitSource = splitEvent.getOriginalSplitSource();
if (vertex.originalOneToOneSplitSource != null) {
VertexState state = vertex.getState();
Preconditions
.checkState(
(state == VertexState.INITIALIZING
|| state == VertexState.INITED || state == VertexState.RUNNING),
" Unexpected 1-1 split for vertex " + vertex.getVertexId()
+ " in state " + vertex.getState() + " . Split in vertex "
+ originalSplitSource + " sent by vertex "
+ splitEvent.getSenderVertex() + " numTasks "
+ splitEvent.getNumTasks());
if (vertex.originalOneToOneSplitSource.equals(originalSplitSource)) {
// ignore another split event that may have come from a different
// path in the DAG. We have already split because of that source
LOG.info("Ignoring split of vertex " + vertex.getVertexId() +
" because of split in vertex " + originalSplitSource +
" sent by vertex " + splitEvent.getSenderVertex() +
" numTasks " + splitEvent.getNumTasks());
return state;
}
// cannot split from multiple sources
throw new TezUncheckedException("Vertex: " + vertex.getVertexId() +
" asked to split by: " + originalSplitSource +
" but was already split by:" + vertex.originalOneToOneSplitSource);
}
LOG.info("Splitting vertex " + vertex.getVertexId() +
" because of split in vertex " + originalSplitSource +
" sent by vertex " + splitEvent.getSenderVertex() +
" numTasks " + splitEvent.getNumTasks());
vertex.originalOneToOneSplitSource = originalSplitSource;
vertex.setParallelism(splitEvent.getNumTasks(), null, null, null);
if (vertex.getState() == VertexState.RUNNING ||
vertex.getState() == VertexState.INITED) {
return vertex.getState();
} else {
Preconditions.checkState(vertex.getState() == VertexState.INITIALIZING,
" Unexpected 1-1 split for vertex " + vertex.getVertexId() +
" in state " + vertex.getState() +
" . Split in vertex " + originalSplitSource +
" sent by vertex " + splitEvent.getSenderVertex() +
" numTasks " + splitEvent.getNumTasks());
return vertex.getState();
}
}