Search in sources :

Example 1 with AbstractJobTracker

use of com.hazelcast.mapreduce.impl.AbstractJobTracker 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 2 with AbstractJobTracker

use of com.hazelcast.mapreduce.impl.AbstractJobTracker 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 3 with AbstractJobTracker

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

the class KeyValueJob method invoke.

@Override
protected <T> JobCompletableFuture<T> invoke(Collator collator) {
    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");
    }
    String jobId = UuidUtil.newUnsecureUuidString();
    AbstractJobTracker jobTracker = (AbstractJobTracker) this.jobTracker;
    TrackableJobFuture<T> jobFuture = new TrackableJobFuture<T>(name, jobId, jobTracker, nodeEngine, collator);
    if (jobTracker.registerTrackableJob(jobFuture)) {
        return startSupervisionTask(jobFuture, jobId);
    }
    throw new IllegalStateException("Could not register map reduce job");
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) AbstractJobTracker(com.hazelcast.mapreduce.impl.AbstractJobTracker)

Example 4 with AbstractJobTracker

use of com.hazelcast.mapreduce.impl.AbstractJobTracker 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 5 with AbstractJobTracker

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

AbstractJobTracker (com.hazelcast.mapreduce.impl.AbstractJobTracker)7 MapReduceService (com.hazelcast.mapreduce.impl.MapReduceService)5 ClusterService (com.hazelcast.internal.cluster.ClusterService)4 JobSupervisor (com.hazelcast.mapreduce.impl.task.JobSupervisor)3 TrackableJobFuture (com.hazelcast.mapreduce.impl.task.TrackableJobFuture)3 JobTrackerConfig (com.hazelcast.config.JobTrackerConfig)2 Member (com.hazelcast.core.Member)2 MapReduceUtil.executeOperation (com.hazelcast.mapreduce.impl.MapReduceUtil.executeOperation)2 KeyValueJobOperation (com.hazelcast.mapreduce.impl.operation.KeyValueJobOperation)2 StartProcessingJobOperation (com.hazelcast.mapreduce.impl.operation.StartProcessingJobOperation)2 Operation (com.hazelcast.spi.Operation)2 IOException (java.io.IOException)2 CancellationException (java.util.concurrent.CancellationException)2 CombinerFactory (com.hazelcast.mapreduce.CombinerFactory)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 TopologyChangedStrategy (com.hazelcast.mapreduce.TopologyChangedStrategy)1 JobTaskConfiguration (com.hazelcast.mapreduce.impl.task.JobTaskConfiguration)1