Search in sources :

Example 1 with IntermediateChunkNotification

use of com.hazelcast.mapreduce.impl.notification.IntermediateChunkNotification in project hazelcast by hazelcast.

the class JobSupervisor method onNotification.

public void onNotification(MapReduceNotification notification) {
    if (notification instanceof IntermediateChunkNotification) {
        IntermediateChunkNotification icn = (IntermediateChunkNotification) notification;
        ReducerTask reducerTask = jobTracker.getReducerTask(icn.getJobId());
        reducerTask.processChunk(icn.getChunk());
    } else if (notification instanceof LastChunkNotification) {
        LastChunkNotification lcn = (LastChunkNotification) notification;
        ReducerTask reducerTask = jobTracker.getReducerTask(lcn.getJobId());
        reducerTask.processChunk(lcn.getPartitionId(), lcn.getSender(), lcn.getChunk());
    } else if (notification instanceof ReducingFinishedNotification) {
        final ReducingFinishedNotification rfn = (ReducingFinishedNotification) notification;
        // Just offload it to free the event queue
        executorService.submit(new Runnable() {

            @Override
            public void run() {
                processReducerFinished0(rfn);
            }
        });
    }
}
Also used : LastChunkNotification(com.hazelcast.mapreduce.impl.notification.LastChunkNotification) ReducingFinishedNotification(com.hazelcast.mapreduce.impl.notification.ReducingFinishedNotification) IntermediateChunkNotification(com.hazelcast.mapreduce.impl.notification.IntermediateChunkNotification)

Example 2 with IntermediateChunkNotification

use of com.hazelcast.mapreduce.impl.notification.IntermediateChunkNotification in project hazelcast by hazelcast.

the class MapCombineTask method onEmit.

void onEmit(DefaultContext<KeyOut, ValueOut> context, int partitionId) {
    // we need to collect all values locally and wait for final request
    if (supervisor.getConfiguration().getReducerFactory() != null) {
        if (context.getCollected() == chunkSize) {
            Map<KeyOut, Chunk> chunkMap = context.requestChunk();
            // Wrap into IntermediateChunkNotification object
            Map<Address, Map<KeyOut, Chunk>> mapping = mapResultToMember(supervisor, chunkMap);
            // Register remote addresses and partitionId for receiving reducer events
            supervisor.registerReducerEventInterests(partitionId, mapping.keySet());
            for (Map.Entry<Address, Map<KeyOut, Chunk>> entry : mapping.entrySet()) {
                mapReduceService.sendNotification(entry.getKey(), new IntermediateChunkNotification(entry.getKey(), name, jobId, entry.getValue(), partitionId));
            }
        }
    }
}
Also used : Address(com.hazelcast.nio.Address) IntermediateChunkNotification(com.hazelcast.mapreduce.impl.notification.IntermediateChunkNotification) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with IntermediateChunkNotification

use of com.hazelcast.mapreduce.impl.notification.IntermediateChunkNotification in project hazelcast by hazelcast.

the class MapReduceDataSerializerHook method createFactory.

@Override
public DataSerializableFactory createFactory() {
    ConstructorFunction<Integer, IdentifiedDataSerializable>[] constructors = new ConstructorFunction[LEN];
    constructors[KEY_VALUE_SOURCE_MAP] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        @Override
        public IdentifiedDataSerializable createNew(Integer arg) {
            return new MapKeyValueSource();
        }
    };
    constructors[KEY_VALUE_SOURCE_MULTIMAP] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        @Override
        public IdentifiedDataSerializable createNew(Integer arg) {
            return new MultiMapKeyValueSource();
        }
    };
    constructors[REDUCER_CHUNK_MESSAGE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        @Override
        public IdentifiedDataSerializable createNew(Integer arg) {
            return new IntermediateChunkNotification();
        }
    };
    constructors[REDUCER_LAST_CHUNK_MESSAGE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        @Override
        public IdentifiedDataSerializable createNew(Integer arg) {
            return new LastChunkNotification();
        }
    };
    constructors[TRACKED_JOB_OPERATION] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        @Override
        public IdentifiedDataSerializable createNew(Integer arg) {
            return new KeyValueJobOperation();
        }
    };
    constructors[REQUEST_PARTITION_MAPPING] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        @Override
        public IdentifiedDataSerializable createNew(Integer arg) {
            return new RequestPartitionMapping();
        }
    };
    constructors[REQUEST_PARTITION_REDUCING] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        @Override
        public IdentifiedDataSerializable createNew(Integer arg) {
            return new RequestPartitionReducing();
        }
    };
    constructors[REQUEST_PARTITION_PROCESSED] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        @Override
        public IdentifiedDataSerializable createNew(Integer arg) {
            return new RequestPartitionProcessed();
        }
    };
    constructors[GET_RESULT_OPERATION] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        @Override
        public IdentifiedDataSerializable createNew(Integer arg) {
            return new GetResultOperation();
        }
    };
    constructors[START_PROCESSING_OPERATION] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        @Override
        public IdentifiedDataSerializable createNew(Integer arg) {
            return new StartProcessingJobOperation();
        }
    };
    constructors[REQUEST_PARTITION_RESULT] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        @Override
        public IdentifiedDataSerializable createNew(Integer arg) {
            return new RequestPartitionResult();
        }
    };
    constructors[REDUCING_FINISHED_MESSAGE] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        @Override
        public IdentifiedDataSerializable createNew(Integer arg) {
            return new ReducingFinishedNotification();
        }
    };
    constructors[FIRE_NOTIFICATION_OPERATION] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        @Override
        public IdentifiedDataSerializable createNew(Integer arg) {
            return new FireNotificationOperation();
        }
    };
    constructors[REQUEST_MEMBERID_ASSIGNMENT] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        @Override
        public IdentifiedDataSerializable createNew(Integer arg) {
            return new RequestMemberIdAssignment();
        }
    };
    constructors[PROCESS_STATS_UPDATE_OPERATION] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        @Override
        public IdentifiedDataSerializable createNew(Integer arg) {
            return new ProcessStatsUpdateOperation();
        }
    };
    constructors[NOTIFY_REMOTE_EXCEPTION_OPERATION] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        @Override
        public IdentifiedDataSerializable createNew(Integer arg) {
            return new NotifyRemoteExceptionOperation();
        }
    };
    constructors[CANCEL_JOB_SUPERVISOR_OPERATION] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        @Override
        public IdentifiedDataSerializable createNew(Integer arg) {
            return new CancelJobSupervisorOperation();
        }
    };
    constructors[KEY_VALUE_SOURCE_LIST] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        @Override
        public IdentifiedDataSerializable createNew(Integer arg) {
            return new ListKeyValueSource();
        }
    };
    constructors[KEY_VALUE_SOURCE_SET] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        @Override
        public IdentifiedDataSerializable createNew(Integer arg) {
            return new SetKeyValueSource();
        }
    };
    constructors[KEYS_ASSIGNMENT_RESULT] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        @Override
        public IdentifiedDataSerializable createNew(Integer arg) {
            return new KeysAssignmentResult();
        }
    };
    constructors[KEYS_ASSIGNMENT_OPERATION] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        @Override
        public IdentifiedDataSerializable createNew(Integer arg) {
            return new KeysAssignmentOperation();
        }
    };
    constructors[POSTPONE_PARTITION_PROCESSING_OPERATION] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        @Override
        public IdentifiedDataSerializable createNew(Integer arg) {
            return new PostPonePartitionProcessing();
        }
    };
    constructors[HASH_MAP_ADAPTER] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        @Override
        public IdentifiedDataSerializable createNew(Integer arg) {
            return new HashMapAdapter();
        }
    };
    constructors[COMBINER_RESULT_LIST] = new ConstructorFunction<Integer, IdentifiedDataSerializable>() {

        @Override
        public IdentifiedDataSerializable createNew(Integer arg) {
            return new CombinerResultList();
        }
    };
    return new ArrayDataSerializableFactory(constructors);
}
Also used : GetResultOperation(com.hazelcast.mapreduce.impl.operation.GetResultOperation) KeyValueJobOperation(com.hazelcast.mapreduce.impl.operation.KeyValueJobOperation) ProcessStatsUpdateOperation(com.hazelcast.mapreduce.impl.operation.ProcessStatsUpdateOperation) LastChunkNotification(com.hazelcast.mapreduce.impl.notification.LastChunkNotification) KeysAssignmentResult(com.hazelcast.mapreduce.impl.operation.KeysAssignmentResult) ReducingFinishedNotification(com.hazelcast.mapreduce.impl.notification.ReducingFinishedNotification) RequestPartitionProcessed(com.hazelcast.mapreduce.impl.operation.RequestPartitionProcessed) IdentifiedDataSerializable(com.hazelcast.nio.serialization.IdentifiedDataSerializable) KeysAssignmentOperation(com.hazelcast.mapreduce.impl.operation.KeysAssignmentOperation) PostPonePartitionProcessing(com.hazelcast.mapreduce.impl.operation.PostPonePartitionProcessing) IntermediateChunkNotification(com.hazelcast.mapreduce.impl.notification.IntermediateChunkNotification) ConstructorFunction(com.hazelcast.util.ConstructorFunction) RequestPartitionReducing(com.hazelcast.mapreduce.impl.operation.RequestPartitionReducing) FireNotificationOperation(com.hazelcast.mapreduce.impl.operation.FireNotificationOperation) RequestPartitionResult(com.hazelcast.mapreduce.impl.operation.RequestPartitionResult) RequestPartitionMapping(com.hazelcast.mapreduce.impl.operation.RequestPartitionMapping) StartProcessingJobOperation(com.hazelcast.mapreduce.impl.operation.StartProcessingJobOperation) RequestMemberIdAssignment(com.hazelcast.mapreduce.impl.operation.RequestMemberIdAssignment) ArrayDataSerializableFactory(com.hazelcast.internal.serialization.impl.ArrayDataSerializableFactory) CancelJobSupervisorOperation(com.hazelcast.mapreduce.impl.operation.CancelJobSupervisorOperation) NotifyRemoteExceptionOperation(com.hazelcast.mapreduce.impl.operation.NotifyRemoteExceptionOperation)

Aggregations

IntermediateChunkNotification (com.hazelcast.mapreduce.impl.notification.IntermediateChunkNotification)3 LastChunkNotification (com.hazelcast.mapreduce.impl.notification.LastChunkNotification)2 ReducingFinishedNotification (com.hazelcast.mapreduce.impl.notification.ReducingFinishedNotification)2 ArrayDataSerializableFactory (com.hazelcast.internal.serialization.impl.ArrayDataSerializableFactory)1 CancelJobSupervisorOperation (com.hazelcast.mapreduce.impl.operation.CancelJobSupervisorOperation)1 FireNotificationOperation (com.hazelcast.mapreduce.impl.operation.FireNotificationOperation)1 GetResultOperation (com.hazelcast.mapreduce.impl.operation.GetResultOperation)1 KeyValueJobOperation (com.hazelcast.mapreduce.impl.operation.KeyValueJobOperation)1 KeysAssignmentOperation (com.hazelcast.mapreduce.impl.operation.KeysAssignmentOperation)1 KeysAssignmentResult (com.hazelcast.mapreduce.impl.operation.KeysAssignmentResult)1 NotifyRemoteExceptionOperation (com.hazelcast.mapreduce.impl.operation.NotifyRemoteExceptionOperation)1 PostPonePartitionProcessing (com.hazelcast.mapreduce.impl.operation.PostPonePartitionProcessing)1 ProcessStatsUpdateOperation (com.hazelcast.mapreduce.impl.operation.ProcessStatsUpdateOperation)1 RequestMemberIdAssignment (com.hazelcast.mapreduce.impl.operation.RequestMemberIdAssignment)1 RequestPartitionMapping (com.hazelcast.mapreduce.impl.operation.RequestPartitionMapping)1 RequestPartitionProcessed (com.hazelcast.mapreduce.impl.operation.RequestPartitionProcessed)1 RequestPartitionReducing (com.hazelcast.mapreduce.impl.operation.RequestPartitionReducing)1 RequestPartitionResult (com.hazelcast.mapreduce.impl.operation.RequestPartitionResult)1 StartProcessingJobOperation (com.hazelcast.mapreduce.impl.operation.StartProcessingJobOperation)1 Address (com.hazelcast.nio.Address)1