Search in sources :

Example 61 with OperationService

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

the class PartitionReplicaSyncRequestOffloadable method readReplicaVersions.

private void readReplicaVersions() {
    InternalPartitionServiceImpl partitionService = getService();
    OperationService operationService = getNodeEngine().getOperationService();
    PartitionReplicaVersionManager versionManager = partitionService.getPartitionReplicaVersionManager();
    UrgentPartitionRunnable<Void> gatherReplicaVersionsRunnable = new UrgentPartitionRunnable<>(partitionId(), () -> {
        for (ServiceNamespace ns : namespaces) {
            // make a copy because
            // getPartitionReplicaVersions
            // returns references to the internal
            // replica versions data structures
            // that may change under our feet
            long[] versions = Arrays.copyOf(versionManager.getPartitionReplicaVersions(partitionId(), ns), IPartition.MAX_BACKUP_COUNT);
            replicaVersions.put(BiTuple.of(partitionId(), ns), versions);
        }
    });
    operationService.execute(gatherReplicaVersionsRunnable);
    gatherReplicaVersionsRunnable.future.joinInternal();
}
Also used : InternalPartitionServiceImpl(com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl) NonFragmentedServiceNamespace(com.hazelcast.internal.partition.NonFragmentedServiceNamespace) ServiceNamespace(com.hazelcast.internal.services.ServiceNamespace) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) PartitionReplicaVersionManager(com.hazelcast.internal.partition.PartitionReplicaVersionManager)

Example 62 with OperationService

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

the class CacheDestroyOperation method destroyCacheOnAllMembers.

private void destroyCacheOnAllMembers(String name, UUID callerUuid) {
    NodeEngine nodeEngine = getNodeEngine();
    OperationService operationService = nodeEngine.getOperationService();
    Collection<Member> members = nodeEngine.getClusterService().getMembers();
    for (Member member : members) {
        if (!member.localMember() && !member.getUuid().equals(callerUuid)) {
            CacheDestroyOperation op = new CacheDestroyOperation(name, true);
            operationService.invokeOnTarget(ICacheService.SERVICE_NAME, op, member.getAddress());
        }
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) Member(com.hazelcast.cluster.Member)

Example 63 with OperationService

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

the class ClientEngineImpl method getClientsInCluster.

Map<UUID, String> getClientsInCluster() {
    OperationService operationService = node.nodeEngine.getOperationService();
    Map<UUID, String> clientsMap = new HashMap<>();
    for (Member member : node.getClusterService().getMembers()) {
        Address target = member.getAddress();
        Operation clientInfoOperation = new GetConnectedClientsOperation();
        Future<Map<UUID, String>> future = operationService.invokeOnTarget(SERVICE_NAME, clientInfoOperation, target);
        try {
            Map<UUID, String> endpoints = future.get();
            if (endpoints == null) {
                continue;
            }
            // Merge connected clients according to their UUID
            clientsMap.putAll(endpoints);
        } catch (Exception e) {
            logger.warning("Cannot get client information from: " + target.toString(), e);
        }
    }
    return clientsMap;
}
Also used : Address(com.hazelcast.cluster.Address) InetSocketAddress(java.net.InetSocketAddress) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) MapUtil.createHashMap(com.hazelcast.internal.util.MapUtil.createHashMap) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) GetConnectedClientsOperation(com.hazelcast.client.impl.operations.GetConnectedClientsOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) GetConnectedClientsOperation(com.hazelcast.client.impl.operations.GetConnectedClientsOperation) UUID(java.util.UUID) Member(com.hazelcast.cluster.Member) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) MapUtil.createHashMap(com.hazelcast.internal.util.MapUtil.createHashMap) LoginException(javax.security.auth.login.LoginException)

Example 64 with OperationService

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

the class ClusterJoinManager method ensureValidConfiguration.

private boolean ensureValidConfiguration(JoinMessage joinMessage) {
    Address address = joinMessage.getAddress();
    try {
        if (isValidJoinMessage(joinMessage)) {
            return true;
        }
        logger.warning(format("Received an invalid join request from %s, cause: members part of different cluster", address));
        nodeEngine.getOperationService().send(new ClusterMismatchOp(), address);
    } catch (ConfigMismatchException e) {
        logger.warning(format("Received an invalid join request from %s, cause: %s", address, e.getMessage()));
        OperationService operationService = nodeEngine.getOperationService();
        operationService.send(new ConfigMismatchOp(e.getMessage()), address);
    }
    return false;
}
Also used : ConfigMismatchOp(com.hazelcast.internal.cluster.impl.operations.ConfigMismatchOp) Address(com.hazelcast.cluster.Address) ClusterMismatchOp(com.hazelcast.internal.cluster.impl.operations.ClusterMismatchOp) OperationService(com.hazelcast.spi.impl.operationservice.OperationService)

Example 65 with OperationService

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

the class ClusterJoinManager method checkClusterStateBeforeJoin.

private boolean checkClusterStateBeforeJoin(Address target, UUID uuid) {
    ClusterState state = clusterStateManager.getState();
    if (state == ClusterState.IN_TRANSITION) {
        logger.warning("Cluster state is in transition process. Join is not allowed until " + "transaction is completed -> " + clusterStateManager.stateToString());
        return true;
    }
    if (state.isJoinAllowed()) {
        return checkRecentlyJoinedMemberUuidBeforeJoin(target, uuid);
    }
    if (clusterService.isMissingMember(target, uuid)) {
        return false;
    }
    if (node.getNodeExtension().isStartCompleted()) {
        String message = "Cluster state either is locked or doesn't allow new members to join -> " + clusterStateManager.stateToString();
        logger.warning(message);
        OperationService operationService = nodeEngine.getOperationService();
        BeforeJoinCheckFailureOp op = new BeforeJoinCheckFailureOp(message);
        operationService.send(op, target);
    } else {
        String message = "Cluster state either is locked or doesn't allow new members to join -> " + clusterStateManager.stateToString() + ". Silently ignored join request of " + target + " because start not completed.";
        logger.warning(message);
    }
    return true;
}
Also used : ClusterState(com.hazelcast.cluster.ClusterState) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) BeforeJoinCheckFailureOp(com.hazelcast.internal.cluster.impl.operations.BeforeJoinCheckFailureOp)

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