use of com.hazelcast.mapreduce.JobPartitionState in project hazelcast by hazelcast.
the class MapReduceUtil method stateChange.
public static JobPartitionState.State stateChange(Address owner, int partitionId, JobPartitionState.State currentState, JobProcessInformationImpl processInformation, JobTaskConfiguration configuration) {
JobPartitionState[] partitionStates = processInformation.getPartitionStates();
JobPartitionState partitionState = partitionStates[partitionId];
// If not yet assigned we don't need to check owner and state
JobPartitionState.State finalState = null;
if (partitionState != null) {
if (!owner.equals(partitionState.getOwner())) {
return null;
}
if (partitionState.getState() != currentState) {
return null;
}
if (currentState == MAPPING) {
finalState = stateChangeMapping(partitionId, partitionState, processInformation, owner, configuration);
} else if (currentState == REDUCING) {
finalState = stateChangeReducing(partitionId, partitionState, processInformation, owner);
}
}
if (currentState == WAITING) {
if (compareAndSwapPartitionState(partitionId, partitionState, processInformation, owner, MAPPING)) {
finalState = MAPPING;
}
}
return finalState;
}
Aggregations