Search in sources :

Example 6 with JobSupervisor

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;
        }
    }
}
Also used : JobPartitionState(com.hazelcast.mapreduce.JobPartitionState) IPartitionService(com.hazelcast.spi.partition.IPartitionService) MapReduceService(com.hazelcast.mapreduce.impl.MapReduceService) JobProcessInformationImpl(com.hazelcast.mapreduce.impl.task.JobProcessInformationImpl) JobSupervisor(com.hazelcast.mapreduce.impl.task.JobSupervisor)

Example 7 with JobSupervisor

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

Example 8 with JobSupervisor

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

Example 9 with 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);
}
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 10 with JobSupervisor

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

Aggregations

JobSupervisor (com.hazelcast.mapreduce.impl.task.JobSupervisor)16 MapReduceService (com.hazelcast.mapreduce.impl.MapReduceService)14 JobPartitionState (com.hazelcast.mapreduce.JobPartitionState)5 JobProcessInformationImpl (com.hazelcast.mapreduce.impl.task.JobProcessInformationImpl)5 AbstractJobTracker (com.hazelcast.mapreduce.impl.AbstractJobTracker)3 Address (com.hazelcast.nio.Address)3 IOException (java.io.IOException)3 CancellationException (java.util.concurrent.CancellationException)3 TrackableJobFuture (com.hazelcast.mapreduce.impl.task.TrackableJobFuture)2 JobProcessInformation (com.hazelcast.mapreduce.JobProcessInformation)1 TopologyChangedException (com.hazelcast.mapreduce.TopologyChangedException)1 TopologyChangedStrategy (com.hazelcast.mapreduce.TopologyChangedStrategy)1 JobTaskConfiguration (com.hazelcast.mapreduce.impl.task.JobTaskConfiguration)1 KeyValueSourceMappingPhase (com.hazelcast.mapreduce.impl.task.KeyValueSourceMappingPhase)1 MappingPhase (com.hazelcast.mapreduce.impl.task.MappingPhase)1 MemberAssigningJobProcessInformationImpl (com.hazelcast.mapreduce.impl.task.MemberAssigningJobProcessInformationImpl)1 NoDataMemberInClusterException (com.hazelcast.partition.NoDataMemberInClusterException)1 IPartitionService (com.hazelcast.spi.partition.IPartitionService)1 HashMap (java.util.HashMap)1