use of com.hazelcast.mapreduce.impl.task.JobSupervisor in project hazelcast by hazelcast.
the class RequestPartitionMapping 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;
}
IPartitionService ps = getNodeEngine().getPartitionService();
List<Integer> memberPartitions = ps.getMemberPartitions(getCallerAddress());
JobProcessInformationImpl processInformation = supervisor.getJobProcessInformation();
while (true) {
int selectedPartition = searchMemberPartitionToProcess(processInformation, memberPartitions);
if (selectedPartition == -1) {
// All partitions seem to be assigned so give up
result = new RequestPartitionResult(NO_MORE_PARTITIONS, -1);
return;
}
JobPartitionState.State nextState = stateChange(getCallerAddress(), selectedPartition, WAITING, processInformation, supervisor.getConfiguration());
if (nextState == MAPPING) {
result = new RequestPartitionResult(SUCCESSFUL, selectedPartition);
return;
}
}
}
use of com.hazelcast.mapreduce.impl.task.JobSupervisor in project hazelcast by hazelcast.
the class MapReduceService method dispatchEvent.
public void dispatchEvent(MapReduceNotification notification) {
String name = notification.getName();
String jobId = notification.getJobId();
JobSupervisor supervisor = getJobSupervisor(name, jobId);
if (supervisor == null) {
throw new NullPointerException("JobSupervisor name=" + name + ", jobId=" + jobId + " not found");
}
supervisor.onNotification(notification);
}
use of com.hazelcast.mapreduce.impl.task.JobSupervisor in project hazelcast by hazelcast.
the class MapReduceService method createJobSupervisor.
public JobSupervisor createJobSupervisor(JobTaskConfiguration configuration) {
// Job might already be cancelled (due to async processing)
NodeJobTracker jobTracker = (NodeJobTracker) createDistributedObject(configuration.getName());
if (jobTracker.unregisterJobSupervisorCancellation(configuration.getJobId())) {
return null;
}
JobSupervisorKey key = new JobSupervisorKey(configuration.getName(), configuration.getJobId());
boolean ownerNode = nodeEngine.getThisAddress().equals(configuration.getJobOwner());
JobSupervisor jobSupervisor = new JobSupervisor(configuration, jobTracker, ownerNode, this);
JobSupervisor oldSupervisor = jobSupervisors.putIfAbsent(key, jobSupervisor);
return oldSupervisor != null ? oldSupervisor : jobSupervisor;
}
use of com.hazelcast.mapreduce.impl.task.JobSupervisor 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.impl.task.JobSupervisor in project hazelcast by hazelcast.
the class RequestPartitionReducing 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();
JobPartitionState.State nextState = stateChange(getCallerAddress(), partitionId, MAPPING, processInformation, supervisor.getConfiguration());
if (nextState != null) {
result = new RequestPartitionResult(SUCCESSFUL, partitionId);
return;
}
result = new RequestPartitionResult(CHECK_STATE_FAILED, -1);
}
Aggregations