Search in sources :

Example 1 with MapReduceService

use of com.hazelcast.mapreduce.impl.MapReduceService 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 MapReduceService

use of com.hazelcast.mapreduce.impl.MapReduceService 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 MapReduceService

use of com.hazelcast.mapreduce.impl.MapReduceService 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 MapReduceService

use of com.hazelcast.mapreduce.impl.MapReduceService 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 MapReduceService

use of com.hazelcast.mapreduce.impl.MapReduceService 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

MapReduceService (com.hazelcast.mapreduce.impl.MapReduceService)20 JobSupervisor (com.hazelcast.mapreduce.impl.task.JobSupervisor)14 JobPartitionState (com.hazelcast.mapreduce.JobPartitionState)5 AbstractJobTracker (com.hazelcast.mapreduce.impl.AbstractJobTracker)5 JobProcessInformationImpl (com.hazelcast.mapreduce.impl.task.JobProcessInformationImpl)5 Address (com.hazelcast.nio.Address)5 IOException (java.io.IOException)4 TrackableJobFuture (com.hazelcast.mapreduce.impl.task.TrackableJobFuture)3 CancellationException (java.util.concurrent.CancellationException)3 ClusterService (com.hazelcast.internal.cluster.ClusterService)2 TopologyChangedStrategy (com.hazelcast.mapreduce.TopologyChangedStrategy)2 HashMap (java.util.HashMap)2 JobTrackerConfig (com.hazelcast.config.JobTrackerConfig)1 Member (com.hazelcast.core.Member)1 CombinerFactory (com.hazelcast.mapreduce.CombinerFactory)1 JobProcessInformation (com.hazelcast.mapreduce.JobProcessInformation)1 KeyPredicate (com.hazelcast.mapreduce.KeyPredicate)1 KeyValueSource (com.hazelcast.mapreduce.KeyValueSource)1 Mapper (com.hazelcast.mapreduce.Mapper)1 ReducerFactory (com.hazelcast.mapreduce.ReducerFactory)1