Search in sources :

Example 51 with Operation

use of com.hazelcast.spi.Operation 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)

Example 52 with Operation

use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.

the class KeyValueJob method startSupervisionTask.

private <T> JobCompletableFuture<T> startSupervisionTask(TrackableJobFuture<T> jobFuture, String jobId) {
    AbstractJobTracker jobTracker = (AbstractJobTracker) this.jobTracker;
    JobTrackerConfig config = jobTracker.getJobTrackerConfig();
    boolean communicateStats = config.isCommunicateStats();
    if (chunkSize == -1) {
        chunkSize = config.getChunkSize();
    }
    if (topologyChangedStrategy == null) {
        topologyChangedStrategy = config.getTopologyChangedStrategy();
    }
    ClusterService clusterService = nodeEngine.getClusterService();
    for (Member member : clusterService.getMembers(KeyValueJobOperation.MEMBER_SELECTOR)) {
        Operation operation = new KeyValueJobOperation<KeyIn, ValueIn>(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<KeyIn>(name, jobId, keys, predicate);
        executeOperation(operation, member.getAddress(), mapReduceService, nodeEngine);
    }
    return jobFuture;
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) JobTrackerConfig(com.hazelcast.config.JobTrackerConfig) KeyValueJobOperation(com.hazelcast.mapreduce.impl.operation.KeyValueJobOperation) AbstractJobTracker(com.hazelcast.mapreduce.impl.AbstractJobTracker) StartProcessingJobOperation(com.hazelcast.mapreduce.impl.operation.StartProcessingJobOperation) Operation(com.hazelcast.spi.Operation) StartProcessingJobOperation(com.hazelcast.mapreduce.impl.operation.StartProcessingJobOperation) MapReduceUtil.executeOperation(com.hazelcast.mapreduce.impl.MapReduceUtil.executeOperation) KeyValueJobOperation(com.hazelcast.mapreduce.impl.operation.KeyValueJobOperation) Member(com.hazelcast.core.Member)

Example 53 with Operation

use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.

the class AdvancedClusterStateTest method partitionInvocation_shouldFail_whenPartitionsNotAssigned_inFrozenState.

@Test(expected = IllegalStateException.class)
public void partitionInvocation_shouldFail_whenPartitionsNotAssigned_inFrozenState() throws InterruptedException {
    Config config = new Config();
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(3);
    HazelcastInstance[] instances = factory.newInstances(config);
    HazelcastInstance hz1 = instances[0];
    HazelcastInstance hz2 = instances[1];
    HazelcastInstance hz3 = instances[2];
    hz2.getCluster().changeClusterState(ClusterState.FROZEN);
    InternalOperationService operationService = getNode(hz3).getNodeEngine().getOperationService();
    Operation op = new AddAndGetOperation(randomName(), 1);
    Future<Long> future = operationService.invokeOnPartition(AtomicLongService.SERVICE_NAME, op, 1);
    try {
        future.get();
        fail("Partition invocation must fail, because partitions cannot be assigned!");
    } catch (ExecutionException e) {
        // IllegalStateException should be cause of ExecutionException.
        throw ExceptionUtil.rethrow(e);
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) AddAndGetOperation(com.hazelcast.concurrent.atomiclong.operations.AddAndGetOperation) Config(com.hazelcast.config.Config) InternalOperationService(com.hazelcast.spi.impl.operationservice.InternalOperationService) Operation(com.hazelcast.spi.Operation) AddAndGetOperation(com.hazelcast.concurrent.atomiclong.operations.AddAndGetOperation) ExecutionException(java.util.concurrent.ExecutionException) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 54 with Operation

use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.

the class BasicRecordStoreLoader method sendOperation.

private Future<?> sendOperation(List<Data> keyValueSequence, AtomicInteger finishedBatchCounter) {
    OperationService operationService = mapServiceContext.getNodeEngine().getOperationService();
    final Operation operation = createOperation(keyValueSequence, finishedBatchCounter);
    //operationService.executeOperation(operation);
    return operationService.invokeOnPartition(MapService.SERVICE_NAME, operation, partitionId);
}
Also used : OperationService(com.hazelcast.spi.OperationService) MapOperation(com.hazelcast.map.impl.operation.MapOperation) Operation(com.hazelcast.spi.Operation) RemoveFromLoadAllOperation(com.hazelcast.map.impl.operation.RemoveFromLoadAllOperation)

Example 55 with Operation

use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.

the class OperationThread method process.

private void process(Object task) {
    try {
        if (task.getClass() == Packet.class) {
            Packet packet = (Packet) task;
            currentRunner = getOperationRunner(packet.getPartitionId());
            currentRunner.run(packet);
            completedPacketCount.inc();
        } else if (task instanceof Operation) {
            Operation operation = (Operation) task;
            currentRunner = getOperationRunner(operation.getPartitionId());
            currentRunner.run(operation);
            completedOperationCount.inc();
        } else if (task instanceof PartitionSpecificRunnable) {
            PartitionSpecificRunnable runnable = (PartitionSpecificRunnable) task;
            currentRunner = getOperationRunner(runnable.getPartitionId());
            currentRunner.run(runnable);
            completedPartitionSpecificRunnableCount.inc();
        } else if (task instanceof Runnable) {
            Runnable runnable = (Runnable) task;
            runnable.run();
            completedRunnableCount.inc();
        } else {
            throw new IllegalStateException("Unhandled task type for task:" + task);
        }
        completedTotalCount.inc();
    } catch (Throwable t) {
        errorCount.inc();
        inspectOutOfMemoryError(t);
        logger.severe("Failed to process packet: " + task + " on " + getName(), t);
    } finally {
        currentRunner = null;
    }
}
Also used : Packet(com.hazelcast.nio.Packet) PartitionSpecificRunnable(com.hazelcast.spi.impl.PartitionSpecificRunnable) Operation(com.hazelcast.spi.Operation) PartitionSpecificRunnable(com.hazelcast.spi.impl.PartitionSpecificRunnable)

Aggregations

Operation (com.hazelcast.spi.Operation)94 OperationService (com.hazelcast.spi.OperationService)14 Member (com.hazelcast.core.Member)13 Address (com.hazelcast.nio.Address)11 InternalCompletableFuture (com.hazelcast.spi.InternalCompletableFuture)8 ArrayList (java.util.ArrayList)8 ILogger (com.hazelcast.logging.ILogger)7 UrgentSystemOperation (com.hazelcast.spi.UrgentSystemOperation)7 ParallelTest (com.hazelcast.test.annotation.ParallelTest)7 QuickTest (com.hazelcast.test.annotation.QuickTest)7 Test (org.junit.Test)7 AcquireOperation (com.hazelcast.concurrent.semaphore.operations.AcquireOperation)6 AvailableOperation (com.hazelcast.concurrent.semaphore.operations.AvailableOperation)6 DrainOperation (com.hazelcast.concurrent.semaphore.operations.DrainOperation)6 InitOperation (com.hazelcast.concurrent.semaphore.operations.InitOperation)6 ReduceOperation (com.hazelcast.concurrent.semaphore.operations.ReduceOperation)6 ReleaseOperation (com.hazelcast.concurrent.semaphore.operations.ReleaseOperation)6 MemberInfo (com.hazelcast.internal.cluster.MemberInfo)6 NodeEngine (com.hazelcast.spi.NodeEngine)6 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)6