Search in sources :

Example 6 with JobPartitionState

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;
}
Also used : JobPartitionState(com.hazelcast.mapreduce.JobPartitionState)

Aggregations

JobPartitionState (com.hazelcast.mapreduce.JobPartitionState)6 MapReduceService (com.hazelcast.mapreduce.impl.MapReduceService)2 JobSupervisor (com.hazelcast.mapreduce.impl.task.JobSupervisor)2 JobProcessInformation (com.hazelcast.mapreduce.JobProcessInformation)1 GetResultOperationFactory (com.hazelcast.mapreduce.impl.operation.GetResultOperationFactory)1 JobProcessInformationImpl (com.hazelcast.mapreduce.impl.task.JobProcessInformationImpl)1 Address (com.hazelcast.nio.Address)1 ExecutionService (com.hazelcast.spi.ExecutionService)1 NodeEngine (com.hazelcast.spi.NodeEngine)1 ManagedExecutorService (com.hazelcast.util.executor.ManagedExecutorService)1