Search in sources :

Example 1 with JobSupervisor

use of com.hazelcast.mapreduce.impl.task.JobSupervisor in project hazelcast by hazelcast.

the class StartProcessingJobOperation method run.

@Override
public void run() throws Exception {
    MapReduceService mapReduceService = getService();
    if (mapReduceService.unregisterJobSupervisorCancellation(name, jobId)) {
        // Supervisor was cancelled prior to creation
        AbstractJobTracker jobTracker = (AbstractJobTracker) mapReduceService.getJobTracker(name);
        TrackableJobFuture future = jobTracker.unregisterTrackableJob(jobId);
        if (future != null) {
            Exception exception = new CancellationException("Operation was cancelled by the user");
            future.setResult(exception);
        }
        return;
    }
    JobSupervisor supervisor = mapReduceService.getJobSupervisor(name, jobId);
    if (supervisor == null) {
        return;
    }
    // Create actual mapping operation
    MappingPhase mappingPhase = new KeyValueSourceMappingPhase(keys, predicate);
    supervisor.startTasks(mappingPhase);
}
Also used : MappingPhase(com.hazelcast.mapreduce.impl.task.MappingPhase) KeyValueSourceMappingPhase(com.hazelcast.mapreduce.impl.task.KeyValueSourceMappingPhase) TrackableJobFuture(com.hazelcast.mapreduce.impl.task.TrackableJobFuture) KeyValueSourceMappingPhase(com.hazelcast.mapreduce.impl.task.KeyValueSourceMappingPhase) CancellationException(java.util.concurrent.CancellationException) MapReduceService(com.hazelcast.mapreduce.impl.MapReduceService) AbstractJobTracker(com.hazelcast.mapreduce.impl.AbstractJobTracker) CancellationException(java.util.concurrent.CancellationException) IOException(java.io.IOException) JobSupervisor(com.hazelcast.mapreduce.impl.task.JobSupervisor)

Example 2 with JobSupervisor

use of com.hazelcast.mapreduce.impl.task.JobSupervisor in project hazelcast by hazelcast.

the class KeyValueJobOperation method run.

@Override
public void run() throws Exception {
    MapReduceService mapReduceService = getService();
    Address jobOwner = getCallerAddress();
    if (jobOwner == null) {
        jobOwner = getNodeEngine().getThisAddress();
    }
    // Inject managed context
    injectManagedContext(mapper, combinerFactory, reducerFactory, keyValueSource);
    // Build immutable configuration
    JobTaskConfiguration config = new JobTaskConfiguration(jobOwner, getNodeEngine(), chunkSize, name, jobId, mapper, combinerFactory, reducerFactory, keyValueSource, communicateStats, topologyChangedStrategy);
    JobSupervisor supervisor = mapReduceService.createJobSupervisor(config);
    if (supervisor == null) {
        // Supervisor was cancelled prior to creation
        AbstractJobTracker jobTracker = (AbstractJobTracker) mapReduceService.getJobTracker(name);
        TrackableJobFuture future = jobTracker.unregisterTrackableJob(jobId);
        if (future != null) {
            Exception exception = new CancellationException("Operation was cancelled by the user");
            future.setResult(exception);
        }
    }
}
Also used : TrackableJobFuture(com.hazelcast.mapreduce.impl.task.TrackableJobFuture) Address(com.hazelcast.nio.Address) CancellationException(java.util.concurrent.CancellationException) MapReduceService(com.hazelcast.mapreduce.impl.MapReduceService) AbstractJobTracker(com.hazelcast.mapreduce.impl.AbstractJobTracker) JobTaskConfiguration(com.hazelcast.mapreduce.impl.task.JobTaskConfiguration) JobSupervisor(com.hazelcast.mapreduce.impl.task.JobSupervisor) CancellationException(java.util.concurrent.CancellationException) IOException(java.io.IOException)

Example 3 with JobSupervisor

use of com.hazelcast.mapreduce.impl.task.JobSupervisor 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 4 with JobSupervisor

use of com.hazelcast.mapreduce.impl.task.JobSupervisor in project hazelcast by hazelcast.

the class RequestMemberIdAssignment 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;
    }
    MemberAssigningJobProcessInformationImpl processInformation = getProcessInformation(supervisor);
    int memberId = processInformation.assignMemberId(getCallerAddress(), getCallerUuid(), supervisor.getConfiguration());
    if (memberId == -1) {
        result = new RequestPartitionResult(NO_MORE_PARTITIONS, -1);
        return;
    }
    result = new RequestPartitionResult(SUCCESSFUL, memberId);
}
Also used : MemberAssigningJobProcessInformationImpl(com.hazelcast.mapreduce.impl.task.MemberAssigningJobProcessInformationImpl) MapReduceService(com.hazelcast.mapreduce.impl.MapReduceService) JobSupervisor(com.hazelcast.mapreduce.impl.task.JobSupervisor)

Example 5 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)

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