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);
}
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);
}
}
}
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;
}
}
}
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);
}
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;
}
}
}
Aggregations