Search in sources :

Example 1 with JobPartitionState

use of com.hazelcast.mapreduce.JobPartitionState in project hazelcast by hazelcast.

the class JobSupervisor method checkFullyProcessed.

public void checkFullyProcessed(JobProcessInformation processInformation) {
    if (isOwnerNode()) {
        JobPartitionState[] partitionStates = processInformation.getPartitionStates();
        for (JobPartitionState partitionState : partitionStates) {
            if (partitionState == null || partitionState.getState() != JobPartitionState.State.PROCESSED) {
                return;
            }
        }
        final String name = configuration.getName();
        final String jobId = configuration.getJobId();
        final NodeEngine nodeEngine = configuration.getNodeEngine();
        final GetResultOperationFactory operationFactory = new GetResultOperationFactory(name, jobId);
        // Get the initial future object to eventually set the result and cleanup
        final TrackableJobFuture future = jobTracker.unregisterTrackableJob(jobId);
        if (future == null) {
            // If already handled just return
            return;
        }
        final JobSupervisor jobSupervisor = this;
        Runnable runnable = new GetResultsRunnable(nodeEngine, operationFactory, jobId, jobSupervisor, future);
        ExecutionService executionService = nodeEngine.getExecutionService();
        ManagedExecutorService executor = executionService.getExecutor(ExecutionService.ASYNC_EXECUTOR);
        executor.submit(runnable);
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) ManagedExecutorService(com.hazelcast.util.executor.ManagedExecutorService) JobPartitionState(com.hazelcast.mapreduce.JobPartitionState) GetResultOperationFactory(com.hazelcast.mapreduce.impl.operation.GetResultOperationFactory) ExecutionService(com.hazelcast.spi.ExecutionService)

Example 2 with JobPartitionState

use of com.hazelcast.mapreduce.JobPartitionState in project hazelcast by hazelcast.

the class PostPonePartitionProcessing method run.

@Override
public void run() throws Exception {
    MapReduceService mapReduceService = getService();
    JobSupervisor supervisor = mapReduceService.getJobSupervisor(getName(), getJobId());
    if (supervisor == null) {
        result = new RequestPartitionResult(NO_SUPERVISOR, -1);
        return;
    }
    JobProcessInformationImpl processInformation = supervisor.getJobProcessInformation();
    while (true) {
        JobPartitionState[] partitionStates = processInformation.getPartitionStates();
        JobPartitionState oldPartitionState = partitionStates[partitionId];
        if (oldPartitionState == null || !getCallerAddress().equals(oldPartitionState.getOwner())) {
            result = new RequestPartitionResult(CHECK_STATE_FAILED, partitionId);
            return;
        }
        if (processInformation.updatePartitionState(partitionId, oldPartitionState, null)) {
            result = new RequestPartitionResult(SUCCESSFUL, partitionId);
            return;
        }
    }
}
Also used : JobPartitionState(com.hazelcast.mapreduce.JobPartitionState) MapReduceService(com.hazelcast.mapreduce.impl.MapReduceService) JobProcessInformationImpl(com.hazelcast.mapreduce.impl.task.JobProcessInformationImpl) JobSupervisor(com.hazelcast.mapreduce.impl.task.JobSupervisor)

Example 3 with JobPartitionState

use of com.hazelcast.mapreduce.JobPartitionState in project hazelcast by hazelcast.

the class RequestPartitionMapping method checkState.

private boolean checkState(JobProcessInformation processInformation, int partitionId) {
    JobPartitionState[] partitionStates = processInformation.getPartitionStates();
    JobPartitionState partitionState = partitionStates[partitionId];
    return partitionState == null || partitionState.getState() == JobPartitionState.State.WAITING;
}
Also used : JobPartitionState(com.hazelcast.mapreduce.JobPartitionState)

Example 4 with JobPartitionState

use of com.hazelcast.mapreduce.JobPartitionState in project hazelcast by hazelcast.

the class MapReduceJobProcessInformationMessageTask method call.

@Override
protected Object call() throws Exception {
    MapReduceService mapReduceService = getService(MapReduceService.SERVICE_NAME);
    JobSupervisor supervisor = mapReduceService.getJobSupervisor(parameters.name, parameters.jobId);
    if (supervisor != null && supervisor.getJobProcessInformation() != null) {
        JobProcessInformation current = supervisor.getJobProcessInformation();
        List<JobPartitionState> jobPartitionStates = Arrays.asList(current.getPartitionStates());
        return MapReduceJobProcessInformationCodec.encodeResponse(jobPartitionStates, current.getProcessedRecords());
    }
    throw new IllegalStateException("Information not found for map reduce with name : " + parameters.name + ", job id : " + parameters.jobId);
}
Also used : JobProcessInformation(com.hazelcast.mapreduce.JobProcessInformation) JobPartitionState(com.hazelcast.mapreduce.JobPartitionState) MapReduceService(com.hazelcast.mapreduce.impl.MapReduceService) JobSupervisor(com.hazelcast.mapreduce.impl.task.JobSupervisor)

Example 5 with JobPartitionState

use of com.hazelcast.mapreduce.JobPartitionState in project hazelcast by hazelcast.

the class JobProcessInformationImpl method cancelPartitionState.

public void cancelPartitionState() {
    JobPartitionState[] oldPartitionStates = this.partitionStates;
    JobPartitionState[] newPartitionStates = new JobPartitionState[oldPartitionStates.length];
    for (int i = 0; i < newPartitionStates.length; i++) {
        Address owner = oldPartitionStates[i] != null ? oldPartitionStates[i].getOwner() : null;
        newPartitionStates[i] = new JobPartitionStateImpl(owner, CANCELLED);
    }
    this.partitionStates = newPartitionStates;
}
Also used : JobPartitionState(com.hazelcast.mapreduce.JobPartitionState) Address(com.hazelcast.nio.Address)

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