Search in sources :

Example 6 with InvocationBuilder

use of com.hazelcast.spi.impl.operationservice.InvocationBuilder in project hazelcast by hazelcast.

the class MasterSplitTest method test_migrationFailsOnMasterMismatch_onSource.

@Test
public void test_migrationFailsOnMasterMismatch_onSource() throws InterruptedException {
    HazelcastInstance member1 = factory.newHazelcastInstance();
    HazelcastInstance member2 = factory.newHazelcastInstance();
    warmUpPartitions(member1, member2);
    MigrationInfo migration = createMigrationInfo(member1, member2);
    Operation op = new MigrationRequestOperation(migration, Collections.emptyList(), 0, true, chunkedMigrationEnabled, Integer.MAX_VALUE);
    InvocationBuilder invocationBuilder = getOperationService(member1).createInvocationBuilder(SERVICE_NAME, op, getAddress(member2)).setCallTimeout(TimeUnit.MINUTES.toMillis(1));
    Future future = invocationBuilder.invoke();
    try {
        future.get();
        fail();
    } catch (ExecutionException e) {
        assertTrue(e.getCause() instanceof IllegalStateException);
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MigrationRequestOperation(com.hazelcast.internal.partition.operation.MigrationRequestOperation) InternalCompletableFuture(com.hazelcast.spi.impl.InternalCompletableFuture) Future(java.util.concurrent.Future) MigrationRequestOperation(com.hazelcast.internal.partition.operation.MigrationRequestOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) MigrationOperation(com.hazelcast.internal.partition.operation.MigrationOperation) FetchPartitionStateOperation(com.hazelcast.internal.partition.operation.FetchPartitionStateOperation) InvocationBuilder(com.hazelcast.spi.impl.operationservice.InvocationBuilder) ExecutionException(java.util.concurrent.ExecutionException) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with InvocationBuilder

use of com.hazelcast.spi.impl.operationservice.InvocationBuilder in project hazelcast by hazelcast.

the class MapPublisherCreateMessageTask method createInvocations.

private void createInvocations(Collection<MemberImpl> members, List<Future> futures) {
    final OperationServiceImpl operationService = nodeEngine.getOperationService();
    for (MemberImpl member : members) {
        Predicate predicate = serializationService.toObject(parameters.predicate);
        AccumulatorInfo accumulatorInfo = AccumulatorInfo.toAccumulatorInfo(parameters.mapName, parameters.cacheName, predicate, parameters.batchSize, parameters.bufferSize, parameters.delaySeconds, false, parameters.populate, parameters.coalesce);
        PublisherCreateOperation operation = new PublisherCreateOperation(accumulatorInfo);
        operation.setCallerUuid(endpoint.getUuid());
        Address address = member.getAddress();
        InvocationBuilder invocationBuilder = operationService.createInvocationBuilder(SERVICE_NAME, operation, address);
        Future future = invocationBuilder.invoke();
        futures.add(future);
    }
}
Also used : Address(com.hazelcast.cluster.Address) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) Future(java.util.concurrent.Future) AccumulatorInfo(com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfo) InvocationBuilder(com.hazelcast.spi.impl.operationservice.InvocationBuilder) PublisherCreateOperation(com.hazelcast.map.impl.querycache.subscriber.operation.PublisherCreateOperation) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl) Predicate(com.hazelcast.query.Predicate)

Example 8 with InvocationBuilder

use of com.hazelcast.spi.impl.operationservice.InvocationBuilder in project hazelcast by hazelcast.

the class CancellableDelegatingFuture method invokeCancelOperation.

private Future<Boolean> invokeCancelOperation(boolean mayInterruptIfRunning) {
    CancellationOperation op = new CancellationOperation(uuid, mayInterruptIfRunning);
    OperationService opService = nodeEngine.getOperationService();
    InvocationBuilder builder;
    if (partitionId > -1) {
        builder = opService.createInvocationBuilder(DistributedExecutorService.SERVICE_NAME, op, partitionId);
    } else {
        builder = opService.createInvocationBuilder(DistributedExecutorService.SERVICE_NAME, op, target);
    }
    builder.setTryCount(CANCEL_TRY_COUNT).setTryPauseMillis(CANCEL_TRY_PAUSE_MILLIS);
    return builder.invoke();
}
Also used : CancellationOperation(com.hazelcast.executor.impl.operations.CancellationOperation) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) InvocationBuilder(com.hazelcast.spi.impl.operationservice.InvocationBuilder)

Example 9 with InvocationBuilder

use of com.hazelcast.spi.impl.operationservice.InvocationBuilder in project hazelcast by hazelcast.

the class MasterSplitTest method test_migrationFailsOnMasterMismatch_onDestination.

@Test
public void test_migrationFailsOnMasterMismatch_onDestination() throws InterruptedException {
    HazelcastInstance member1 = factory.newHazelcastInstance();
    HazelcastInstance member2 = factory.newHazelcastInstance();
    warmUpPartitions(member1, member2);
    MigrationInfo migration = createMigrationInfo(member1, member2);
    ReplicaFragmentMigrationState migrationState = new ReplicaFragmentMigrationState(Collections.emptyMap(), Collections.emptySet(), Collections.emptySet(), chunkedMigrationEnabled, (int) MemoryUnit.MEGABYTES.toBytes(50), Logger.getLogger(getClass()), 1);
    Operation op = new MigrationOperation(migration, Collections.emptyList(), 0, migrationState, true, true);
    InvocationBuilder invocationBuilder = getOperationService(member1).createInvocationBuilder(SERVICE_NAME, op, getAddress(member2)).setCallTimeout(TimeUnit.MINUTES.toMillis(1));
    Future future = invocationBuilder.invoke();
    try {
        future.get();
        fail();
    } catch (ExecutionException e) {
        assertTrue(e.getCause() instanceof IllegalStateException);
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MigrationOperation(com.hazelcast.internal.partition.operation.MigrationOperation) InternalCompletableFuture(com.hazelcast.spi.impl.InternalCompletableFuture) Future(java.util.concurrent.Future) MigrationRequestOperation(com.hazelcast.internal.partition.operation.MigrationRequestOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) MigrationOperation(com.hazelcast.internal.partition.operation.MigrationOperation) FetchPartitionStateOperation(com.hazelcast.internal.partition.operation.FetchPartitionStateOperation) InvocationBuilder(com.hazelcast.spi.impl.operationservice.InvocationBuilder) ExecutionException(java.util.concurrent.ExecutionException) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 10 with InvocationBuilder

use of com.hazelcast.spi.impl.operationservice.InvocationBuilder in project hazelcast by hazelcast.

the class OperationServiceImpl_BasicTest method testPropagateSerializationErrorOnResponseToCallerGithubIssue2559.

@Test(expected = ExecutionException.class)
public void testPropagateSerializationErrorOnResponseToCallerGithubIssue2559() throws Exception {
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
    HazelcastInstance hz1 = factory.newHazelcastInstance();
    HazelcastInstance hz2 = factory.newHazelcastInstance();
    Field original = HazelcastInstanceProxy.class.getDeclaredField("original");
    original.setAccessible(true);
    HazelcastInstanceImpl impl = (HazelcastInstanceImpl) original.get(hz1);
    OperationService operationService = impl.node.nodeEngine.getOperationService();
    Address address = hz2.getCluster().getLocalMember().getAddress();
    Operation operation = new GithubIssue2559Operation();
    String serviceName = DistributedExecutorService.SERVICE_NAME;
    InvocationBuilder invocationBuilder = operationService.createInvocationBuilder(serviceName, operation, address);
    invocationBuilder.invoke().get();
}
Also used : HazelcastInstanceImpl(com.hazelcast.instance.impl.HazelcastInstanceImpl) Field(java.lang.reflect.Field) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Address(com.hazelcast.cluster.Address) Accessors.getAddress(com.hazelcast.test.Accessors.getAddress) Accessors.getOperationService(com.hazelcast.test.Accessors.getOperationService) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) Operation(com.hazelcast.spi.impl.operationservice.Operation) InvocationBuilder(com.hazelcast.spi.impl.operationservice.InvocationBuilder) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

InvocationBuilder (com.hazelcast.spi.impl.operationservice.InvocationBuilder)11 Operation (com.hazelcast.spi.impl.operationservice.Operation)6 HazelcastInstance (com.hazelcast.core.HazelcastInstance)5 OperationServiceImpl (com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)5 Address (com.hazelcast.cluster.Address)4 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4 Future (java.util.concurrent.Future)4 Test (org.junit.Test)4 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)3 MemberImpl (com.hazelcast.cluster.impl.MemberImpl)2 FetchPartitionStateOperation (com.hazelcast.internal.partition.operation.FetchPartitionStateOperation)2 MigrationOperation (com.hazelcast.internal.partition.operation.MigrationOperation)2 MigrationRequestOperation (com.hazelcast.internal.partition.operation.MigrationRequestOperation)2 Data (com.hazelcast.internal.serialization.Data)2 AccumulatorInfo (com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfo)2 PublisherCreateOperation (com.hazelcast.map.impl.querycache.subscriber.operation.PublisherCreateOperation)2 Predicate (com.hazelcast.query.Predicate)2 InternalCompletableFuture (com.hazelcast.spi.impl.InternalCompletableFuture)2 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)2