Search in sources :

Example 46 with ClusterService

use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.

the class PartitionReplicaStateChecker method hasOnGoingMigrationMaster.

boolean hasOnGoingMigrationMaster(Level level) {
    ClusterService clusterService = node.getClusterService();
    Address masterAddress = clusterService.getMasterAddress();
    if (masterAddress == null) {
        return clusterService.isJoined();
    }
    Operation operation = new HasOngoingMigration();
    OperationService operationService = nodeEngine.getOperationService();
    InvocationFuture<Boolean> future = operationService.createInvocationBuilder(SERVICE_NAME, operation, masterAddress).setTryCount(INVOCATION_TRY_COUNT).setTryPauseMillis(INVOCATION_TRY_PAUSE_MILLIS).invoke();
    try {
        return future.joinInternal();
    } catch (Exception e) {
        logger.log(level, "Could not get a response from master about migrations! -> " + e.toString());
    }
    return false;
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) HasOngoingMigration(com.hazelcast.internal.partition.operation.HasOngoingMigration) Address(com.hazelcast.cluster.Address) Operation(com.hazelcast.spi.impl.operationservice.Operation) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean)

Example 47 with ClusterService

use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.

the class ShutdownRequestOperation method run.

@Override
public void run() {
    InternalPartitionServiceImpl partitionService = getService();
    ILogger logger = getLogger();
    Address caller = getCallerAddress();
    if (partitionService.isLocalMemberMaster()) {
        ClusterService clusterService = getNodeEngine().getClusterService();
        Member member = clusterService.getMember(caller);
        if (member != null) {
            if (logger.isFinestEnabled()) {
                logger.finest("Received shutdown request from " + caller);
            }
            partitionService.onShutdownRequest(member);
        } else {
            logger.warning("Ignoring shutdown request from " + caller + " because it is not a member");
        }
    } else {
        logger.warning("Received shutdown request from " + caller + " but this node is not master.");
    }
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) Address(com.hazelcast.cluster.Address) InternalPartitionServiceImpl(com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl) ILogger(com.hazelcast.logging.ILogger) Member(com.hazelcast.cluster.Member)

Example 48 with ClusterService

use of com.hazelcast.internal.cluster.ClusterService 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 49 with ClusterService

use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.

the class ClassLocator method fetchBytecodeFromRemote.

// called while holding class lock
private ClassData fetchBytecodeFromRemote(String className) {
    ClusterService cluster = nodeEngine.getClusterService();
    ClassData classData;
    boolean interrupted = false;
    for (Member member : cluster.getMembers()) {
        if (!isCandidateMember(member)) {
            continue;
        }
        try {
            classData = tryToFetchClassDataFromMember(className, member);
            if (classData != null) {
                if (logger.isFineEnabled()) {
                    logger.finest("Loaded class " + className + " from " + member);
                }
                return classData;
            }
        } catch (InterruptedException e) {
            // question: should we give up on loading at this point and simply throw ClassNotFoundException?
            interrupted = true;
        } catch (Exception e) {
            if (logger.isFinestEnabled()) {
                logger.finest("Unable to get class data for class " + className + " from member " + member, e);
            }
        }
    }
    if (interrupted) {
        Thread.currentThread().interrupt();
    }
    return null;
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) Member(com.hazelcast.cluster.Member) ExecutionException(java.util.concurrent.ExecutionException)

Example 50 with ClusterService

use of com.hazelcast.internal.cluster.ClusterService in project hazelcast by hazelcast.

the class ClusterServiceMemberListTest method verifySizeFromDataMember.

private void verifySizeFromDataMember(final HazelcastInstance instance) {
    final ClusterService clusterService = getClusterService(instance);
    assertEquals(1, clusterService.getSize(MemberSelectors.LITE_MEMBER_SELECTOR));
    assertEquals(2, clusterService.getSize(MemberSelectors.DATA_MEMBER_SELECTOR));
    assertEquals(1, clusterService.getSize(MemberSelectors.and(DATA_MEMBER_SELECTOR, NON_LOCAL_MEMBER_SELECTOR)));
    assertEquals(2, clusterService.getSize(MemberSelectors.or(LITE_MEMBER_SELECTOR, LOCAL_MEMBER_SELECTOR)));
}
Also used : Accessors.getClusterService(com.hazelcast.test.Accessors.getClusterService) ClusterService(com.hazelcast.internal.cluster.ClusterService)

Aggregations

ClusterService (com.hazelcast.internal.cluster.ClusterService)53 Address (com.hazelcast.cluster.Address)11 Member (com.hazelcast.cluster.Member)10 ArrayList (java.util.ArrayList)10 MemberImpl (com.hazelcast.cluster.impl.MemberImpl)8 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)8 Future (java.util.concurrent.Future)8 UUID (java.util.UUID)6 CPMember (com.hazelcast.cp.CPMember)5 ILogger (com.hazelcast.logging.ILogger)5 Accessors.getClusterService (com.hazelcast.test.Accessors.getClusterService)5 ClusterState (com.hazelcast.cluster.ClusterState)4 Node (com.hazelcast.instance.impl.Node)4 JsonObject (com.hazelcast.internal.json.JsonObject)4 AbstractJobTracker (com.hazelcast.mapreduce.impl.AbstractJobTracker)4 NodeEngine (com.hazelcast.spi.impl.NodeEngine)4 Operation (com.hazelcast.spi.impl.operationservice.Operation)4 Member (com.hazelcast.core.Member)3 CPGroupId (com.hazelcast.cp.CPGroupId)3 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)3