Search in sources :

Example 96 with OperationService

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

the class PromotionCommitOperation method finalizePromotion.

/**
 * Processes the sent partition state and sends {@link FinalizePromotionOperation} for all promotions.
 */
private void finalizePromotion() {
    NodeEngine nodeEngine = getNodeEngine();
    InternalPartitionServiceImpl partitionService = getService();
    OperationService operationService = nodeEngine.getOperationService();
    partitionState.setMaster(getCallerAddress());
    success = partitionService.processPartitionRuntimeState(partitionState);
    ILogger logger = getLogger();
    if (!success) {
        logger.severe("Promotion of " + promotions.size() + " partitions failed. " + ". Promotion partition state stamp: " + partitionState.getStamp() + ", current partition state stamp: " + partitionService.getPartitionStateStamp());
    }
    if (logger.isFineEnabled()) {
        logger.fine("Submitting FinalizePromotionOperations for " + promotions.size() + " promotions. Result: " + success + ". Promotion partition state stamp: " + partitionState.getStamp() + ", current partition state stamp: " + partitionService.getPartitionStateStamp());
    }
    PromotionOperationCallback finalizePromotionsCallback = new FinalizePromotionOperationCallback(this, promotions.size());
    for (MigrationInfo promotion : promotions) {
        if (logger.isFinestEnabled()) {
            logger.finest("Submitting FinalizePromotionOperation for promotion: " + promotion + ". Result: " + success);
        }
        Operation op = new FinalizePromotionOperation(promotion, success, finalizePromotionsCallback);
        op.setPartitionId(promotion.getPartitionId()).setNodeEngine(nodeEngine).setService(partitionService);
        operationService.execute(op);
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) MigrationInfo(com.hazelcast.internal.partition.MigrationInfo) InternalPartitionServiceImpl(com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl) ILogger(com.hazelcast.logging.ILogger) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) Operation(com.hazelcast.spi.impl.operationservice.Operation) MigrationCycleOperation(com.hazelcast.internal.partition.MigrationCycleOperation)

Example 97 with OperationService

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

the class PartitionReplicaSyncRequest method sendRetryResponse.

/**
 * Send a response to the replica to retry the replica sync
 */
protected void sendRetryResponse() {
    NodeEngine nodeEngine = getNodeEngine();
    int partitionId = partitionId();
    int replicaIndex = getReplicaIndex();
    PartitionReplicaSyncRetryResponse response = new PartitionReplicaSyncRetryResponse(namespaces);
    response.setPartitionId(partitionId).setReplicaIndex(replicaIndex);
    Address target = getCallerAddress();
    OperationService operationService = nodeEngine.getOperationService();
    operationService.send(response, target);
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) Address(com.hazelcast.cluster.Address) OperationService(com.hazelcast.spi.impl.operationservice.OperationService)

Example 98 with OperationService

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

the class MemberSchemaService method searchClusterAsync.

private CompletableFuture<Schema> searchClusterAsync(long schemaId, Iterator<Member> iterator, OperationService operationService) {
    if (!iterator.hasNext()) {
        return CompletableFuture.completedFuture(null);
    }
    Address address = iterator.next().getAddress();
    FetchSchemaOperation op = new FetchSchemaOperation(schemaId);
    InvocationFuture<Schema> future = operationService.invokeOnTarget(SERVICE_NAME, op, address);
    return future.handle((data, throwable) -> {
        // handle the exception and carry it to next `thenCompose` method
        if (throwable != null) {
            return throwable;
        }
        return data;
    }).thenCompose(o -> {
        if (o instanceof Throwable || o == null) {
            return searchClusterAsync(schemaId, iterator, operationService);
        }
        Schema retrievedSchema = (Schema) o;
        putLocal(retrievedSchema);
        return CompletableFuture.completedFuture(getLocal(schemaId));
    });
}
Also used : InvocationUtil.invokeOnStableClusterSerial(com.hazelcast.internal.util.InvocationUtil.invokeOnStableClusterSerial) Address(com.hazelcast.cluster.Address) InvocationFuture(com.hazelcast.spi.impl.operationservice.impl.InvocationFuture) NodeEngine(com.hazelcast.spi.impl.NodeEngine) Properties(java.util.Properties) Iterator(java.util.Iterator) Member(com.hazelcast.cluster.Member) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) CompletableFuture(java.util.concurrent.CompletableFuture) ManagedService(com.hazelcast.internal.services.ManagedService) Schema(com.hazelcast.internal.serialization.impl.compact.Schema) ArrayList(java.util.ArrayList) ClusterService(com.hazelcast.internal.cluster.ClusterService) List(java.util.List) ILogger(com.hazelcast.logging.ILogger) Operation(com.hazelcast.spi.impl.operationservice.Operation) SchemaService(com.hazelcast.internal.serialization.impl.compact.SchemaService) Map(java.util.Map) PreJoinAwareService(com.hazelcast.internal.services.PreJoinAwareService) Versions(com.hazelcast.internal.cluster.Versions) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) Nonnull(javax.annotation.Nonnull) Address(com.hazelcast.cluster.Address) Schema(com.hazelcast.internal.serialization.impl.compact.Schema)

Example 99 with OperationService

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

the class MemberSchemaService method getAsync.

public CompletableFuture<Schema> getAsync(long schemaId) {
    if (!nodeEngine.getClusterService().getClusterVersion().isEqualTo(Versions.V5_2)) {
        throw new UnsupportedOperationException("The BETA compact format can only be used with 5.2 cluster");
    }
    Schema schema = getLocal(schemaId);
    if (schema != null) {
        return CompletableFuture.completedFuture(schema);
    }
    if (logger.isFinestEnabled()) {
        logger.finest("Could not find schema id  " + schemaId + " locally, will search on the cluster" + schemaId);
    }
    ClusterService cluster = nodeEngine.getClusterService();
    OperationService operationService = nodeEngine.getOperationService();
    Set<Member> members = cluster.getMembers();
    Iterator<Member> iterator = members.iterator();
    return searchClusterAsync(schemaId, iterator, operationService);
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) Schema(com.hazelcast.internal.serialization.impl.compact.Schema) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) Member(com.hazelcast.cluster.Member)

Example 100 with OperationService

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

the class ClassLocator method tryToFetchClassDataFromMember.

private ClassData tryToFetchClassDataFromMember(String className, Member member) throws ExecutionException, InterruptedException {
    OperationService operationService = nodeEngine.getOperationService();
    ClassDataFinderOperation op = new ClassDataFinderOperation(className);
    Future<ClassData> classDataFuture = operationService.invokeOnTarget(UserCodeDeploymentService.SERVICE_NAME, op, member.getAddress());
    return classDataFuture.get();
}
Also used : OperationService(com.hazelcast.spi.impl.operationservice.OperationService) ClassDataFinderOperation(com.hazelcast.internal.usercodedeployment.impl.operation.ClassDataFinderOperation)

Aggregations

OperationService (com.hazelcast.spi.impl.operationservice.OperationService)140 Operation (com.hazelcast.spi.impl.operationservice.Operation)55 Test (org.junit.Test)54 HazelcastInstance (com.hazelcast.core.HazelcastInstance)46 QuickTest (com.hazelcast.test.annotation.QuickTest)41 Accessors.getOperationService (com.hazelcast.test.Accessors.getOperationService)40 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)40 Address (com.hazelcast.cluster.Address)31 NodeEngine (com.hazelcast.spi.impl.NodeEngine)31 InternalCompletableFuture (com.hazelcast.spi.impl.InternalCompletableFuture)24 Future (java.util.concurrent.Future)24 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)23 Config (com.hazelcast.config.Config)22 Member (com.hazelcast.cluster.Member)21 Data (com.hazelcast.internal.serialization.Data)12 SlowTest (com.hazelcast.test.annotation.SlowTest)12 ClusterService (com.hazelcast.internal.cluster.ClusterService)9 ILogger (com.hazelcast.logging.ILogger)7 ArrayList (java.util.ArrayList)7 IPartitionService (com.hazelcast.internal.partition.IPartitionService)6