Search in sources :

Example 6 with MapReduceService

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

the class FireNotificationOperation method run.

@Override
public void run() throws Exception {
    MapReduceService mapReduceService = getService();
    mapReduceService.dispatchEvent(notification);
}
Also used : MapReduceService(com.hazelcast.mapreduce.impl.MapReduceService)

Example 7 with MapReduceService

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

the class MapCombineTask method requestAssignment.

private static void requestAssignment(Set<Object> keys, JobSupervisor supervisor) {
    try {
        MapReduceService mapReduceService = supervisor.getMapReduceService();
        String name = supervisor.getConfiguration().getName();
        String jobId = supervisor.getConfiguration().getJobId();
        KeysAssignmentResult assignmentResult = mapReduceService.processRequest(supervisor.getJobOwner(), new KeysAssignmentOperation(name, jobId, keys));
        if (assignmentResult.getResultState() == SUCCESSFUL) {
            Map<Object, Address> assignment = assignmentResult.getAssignment();
            for (Map.Entry<Object, Address> entry : assignment.entrySet()) {
                // Cache the keys for later mappings
                if (!supervisor.assignKeyReducerAddress(entry.getKey(), entry.getValue())) {
                    throw new IllegalStateException("Key reducer assignment in illegal state");
                }
            }
        }
    } catch (Exception e) {
        // Just announce it to higher levels
        throw new RuntimeException(e);
    }
}
Also used : KeysAssignmentOperation(com.hazelcast.mapreduce.impl.operation.KeysAssignmentOperation) Address(com.hazelcast.nio.Address) KeysAssignmentResult(com.hazelcast.mapreduce.impl.operation.KeysAssignmentResult) MapReduceService(com.hazelcast.mapreduce.impl.MapReduceService) HashMap(java.util.HashMap) Map(java.util.Map) MapReduceUtil.notifyRemoteException(com.hazelcast.mapreduce.impl.MapReduceUtil.notifyRemoteException) TimeoutException(java.util.concurrent.TimeoutException)

Example 8 with MapReduceService

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

the class AbstractMapReduceTask method processMessage.

@Override
protected void processMessage() {
    MapReduceService mapReduceService = getService(MapReduceService.SERVICE_NAME);
    NodeEngine nodeEngine = mapReduceService.getNodeEngine();
    ClusterService clusterService = nodeEngine.getClusterService();
    if (clusterService.getSize(MemberSelectors.DATA_MEMBER_SELECTOR) == 0) {
        throw new IllegalStateException("Could not register map reduce job since there are no nodes owning a partition");
    }
    final String objectName = getDistributedObjectName();
    AbstractJobTracker jobTracker = (AbstractJobTracker) mapReduceService.createDistributedObject(objectName);
    TrackableJobFuture jobFuture = new TrackableJobFuture(objectName, getJobId(), jobTracker, nodeEngine, null);
    if (jobTracker.registerTrackableJob(jobFuture)) {
        startSupervisionTask(jobTracker);
        jobFuture.andThen(this);
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) TrackableJobFuture(com.hazelcast.mapreduce.impl.task.TrackableJobFuture) ClusterService(com.hazelcast.internal.cluster.ClusterService) MapReduceService(com.hazelcast.mapreduce.impl.MapReduceService) AbstractJobTracker(com.hazelcast.mapreduce.impl.AbstractJobTracker)

Example 9 with MapReduceService

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

the class MapReduceCancelMessageTask method call.

@Override
protected Object call() throws Exception {
    MapReduceService mapReduceService = getService(MapReduceService.SERVICE_NAME);
    Address jobOwner = mapReduceService.getLocalAddress();
    mapReduceService.registerJobSupervisorCancellation(parameters.name, parameters.jobId, jobOwner);
    JobSupervisor supervisor = mapReduceService.getJobSupervisor(parameters.name, parameters.jobId);
    if (supervisor != null && supervisor.isOwnerNode()) {
        Exception exception = new CancellationException("Operation was cancelled by the user");
        supervisor.cancelAndNotify(exception);
    }
    return true;
}
Also used : Address(com.hazelcast.nio.Address) CancellationException(java.util.concurrent.CancellationException) MapReduceService(com.hazelcast.mapreduce.impl.MapReduceService) JobSupervisor(com.hazelcast.mapreduce.impl.task.JobSupervisor) CancellationException(java.util.concurrent.CancellationException)

Example 10 with MapReduceService

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

the class AbstractMapReduceTask method startSupervisionTask.

private void startSupervisionTask(JobTracker jobTracker) {
    final MapReduceService mapReduceService = getService(MapReduceService.SERVICE_NAME);
    final JobTrackerConfig config = ((AbstractJobTracker) jobTracker).getJobTrackerConfig();
    final boolean communicateStats = config.isCommunicateStats();
    final int chunkSize = getChunkSizeOrConfigChunkSize(config);
    final TopologyChangedStrategy topologyChangedStrategy = getTopologyChangedStrategyOrConfigTopologyChangedStrategy(config);
    final String name = getDistributedObjectName();
    final String jobId = getJobId();
    final KeyValueSource keyValueSource = getKeyValueSource();
    final Mapper mapper = getMapper();
    final CombinerFactory combinerFactory = getCombinerFactory();
    final ReducerFactory reducerFactory = getReducerFactory();
    final Collection keys = getKeys();
    final Collection<Object> keyObjects = getKeyObjects(keys);
    final KeyPredicate predicate = getPredicate();
    final ClusterService clusterService = nodeEngine.getClusterService();
    for (Member member : clusterService.getMembers(KeyValueJobOperation.MEMBER_SELECTOR)) {
        Operation operation = new KeyValueJobOperation(name, jobId, chunkSize, keyValueSource, mapper, combinerFactory, reducerFactory, communicateStats, topologyChangedStrategy);
        executeOperation(operation, member.getAddress(), mapReduceService, nodeEngine);
    }
    // After we prepared all the remote systems we can now start the processing
    for (Member member : clusterService.getMembers(DATA_MEMBER_SELECTOR)) {
        Operation operation = new StartProcessingJobOperation(name, jobId, keyObjects, predicate);
        executeOperation(operation, member.getAddress(), mapReduceService, nodeEngine);
    }
}
Also used : JobTrackerConfig(com.hazelcast.config.JobTrackerConfig) KeyValueJobOperation(com.hazelcast.mapreduce.impl.operation.KeyValueJobOperation) ReducerFactory(com.hazelcast.mapreduce.ReducerFactory) AbstractJobTracker(com.hazelcast.mapreduce.impl.AbstractJobTracker) StartProcessingJobOperation(com.hazelcast.mapreduce.impl.operation.StartProcessingJobOperation) Operation(com.hazelcast.spi.Operation) MapReduceUtil.executeOperation(com.hazelcast.mapreduce.impl.MapReduceUtil.executeOperation) KeyValueJobOperation(com.hazelcast.mapreduce.impl.operation.KeyValueJobOperation) KeyPredicate(com.hazelcast.mapreduce.KeyPredicate) KeyValueSource(com.hazelcast.mapreduce.KeyValueSource) CombinerFactory(com.hazelcast.mapreduce.CombinerFactory) Mapper(com.hazelcast.mapreduce.Mapper) TopologyChangedStrategy(com.hazelcast.mapreduce.TopologyChangedStrategy) ClusterService(com.hazelcast.internal.cluster.ClusterService) MapReduceService(com.hazelcast.mapreduce.impl.MapReduceService) Collection(java.util.Collection) StartProcessingJobOperation(com.hazelcast.mapreduce.impl.operation.StartProcessingJobOperation) Member(com.hazelcast.core.Member)

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