Search in sources :

Example 16 with MapReduceService

use of com.hazelcast.mapreduce.impl.MapReduceService in project hazelcast by hazelcast.

the class GetResultOperation method run.

@Override
public void run() throws Exception {
    MapReduceService mapReduceService = getService();
    JobSupervisor supervisor = mapReduceService.getJobSupervisor(getName(), getJobId());
    if (supervisor != null) {
        result = supervisor.getJobResults();
        // This is the final call so cleanup on all nodes that are not job owners
        if (!supervisor.isOwnerNode()) {
            mapReduceService.destroyJobSupervisor(supervisor);
            AbstractJobTracker jobTracker = (AbstractJobTracker) mapReduceService.getJobTracker(getName());
            jobTracker.unregisterTrackableJob(getJobId());
            jobTracker.unregisterMapCombineTask(getJobId());
            jobTracker.unregisterReducerTask(getJobId());
        }
    }
}
Also used : MapReduceService(com.hazelcast.mapreduce.impl.MapReduceService) AbstractJobTracker(com.hazelcast.mapreduce.impl.AbstractJobTracker) JobSupervisor(com.hazelcast.mapreduce.impl.task.JobSupervisor)

Example 17 with MapReduceService

use of com.hazelcast.mapreduce.impl.MapReduceService in project hazelcast by hazelcast.

the class KeysAssignmentOperation method run.

@Override
public void run() throws Exception {
    MapReduceService mapReduceService = getService();
    JobSupervisor supervisor = mapReduceService.getJobSupervisor(getName(), getJobId());
    if (supervisor == null) {
        this.result = new KeysAssignmentResult(NO_SUPERVISOR, null);
        return;
    }
    Map<Object, Address> assignment = new HashMap<Object, Address>();
    // Precheck if still all members are available
    if (!supervisor.checkAssignedMembersAvailable()) {
        TopologyChangedStrategy tcs = supervisor.getConfiguration().getTopologyChangedStrategy();
        if (tcs == CANCEL_RUNNING_OPERATION) {
            Exception exception = new TopologyChangedException();
            supervisor.cancelAndNotify(exception);
            this.result = new KeysAssignmentResult(CHECK_STATE_FAILED, assignment);
            return;
        // TODO Not yet fully supported
        /* } else if (tcs == DISCARD_AND_RESTART) {
             *   supervisor.cancelNotifyAndRestart();
             */
        } else {
            Exception exception = new TopologyChangedException("Unknown or unsupported TopologyChangedStrategy");
            supervisor.cancelAndNotify(exception);
            this.result = new KeysAssignmentResult(CHECK_STATE_FAILED, assignment);
            return;
        }
    }
    try {
        for (Object key : keys) {
            Address address = supervisor.assignKeyReducerAddress(key);
            assignment.put(key, address);
        }
        this.result = new KeysAssignmentResult(SUCCESSFUL, assignment);
    } catch (NoDataMemberInClusterException e) {
        supervisor.cancelAndNotify(e);
        this.result = new KeysAssignmentResult(CHECK_STATE_FAILED, assignment);
    }
}
Also used : TopologyChangedStrategy(com.hazelcast.mapreduce.TopologyChangedStrategy) Address(com.hazelcast.nio.Address) HashMap(java.util.HashMap) MapReduceService(com.hazelcast.mapreduce.impl.MapReduceService) NoDataMemberInClusterException(com.hazelcast.partition.NoDataMemberInClusterException) TopologyChangedException(com.hazelcast.mapreduce.TopologyChangedException) JobSupervisor(com.hazelcast.mapreduce.impl.task.JobSupervisor) IOException(java.io.IOException) TopologyChangedException(com.hazelcast.mapreduce.TopologyChangedException) NoDataMemberInClusterException(com.hazelcast.partition.NoDataMemberInClusterException)

Example 18 with MapReduceService

use of com.hazelcast.mapreduce.impl.MapReduceService in project hazelcast by hazelcast.

the class NotifyRemoteExceptionOperation method run.

@Override
public void run() throws Exception {
    MapReduceService mapReduceService = getService();
    JobSupervisor supervisor = mapReduceService.getJobSupervisor(getName(), getJobId());
    if (supervisor != null) {
        supervisor.notifyRemoteException(getCallerAddress(), throwable);
    }
}
Also used : MapReduceService(com.hazelcast.mapreduce.impl.MapReduceService) JobSupervisor(com.hazelcast.mapreduce.impl.task.JobSupervisor)

Example 19 with MapReduceService

use of com.hazelcast.mapreduce.impl.MapReduceService in project hazelcast by hazelcast.

the class ProcessStatsUpdateOperation method run.

@Override
public void run() throws Exception {
    MapReduceService mapReduceService = getService();
    JobSupervisor supervisor = mapReduceService.getJobSupervisor(getName(), getJobId());
    if (supervisor != null) {
        JobProcessInformationImpl processInformation = supervisor.getJobProcessInformation();
        processInformation.addProcessedRecords(processedRecords);
    }
}
Also used : MapReduceService(com.hazelcast.mapreduce.impl.MapReduceService) JobProcessInformationImpl(com.hazelcast.mapreduce.impl.task.JobProcessInformationImpl) JobSupervisor(com.hazelcast.mapreduce.impl.task.JobSupervisor)

Example 20 with MapReduceService

use of com.hazelcast.mapreduce.impl.MapReduceService in project hazelcast by hazelcast.

the class RequestPartitionProcessed 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, currentState, processInformation, supervisor.getConfiguration());
    if (nextState == PROCESSED) {
        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

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