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);
}
}
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;
}
}
}
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;
}
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);
}
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;
}
Aggregations