Search in sources :

Example 81 with NodeEngineImpl

use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.

the class ReplicaSyncRequest method createReplicationOperations.

private List<Operation> createReplicationOperations() {
    NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
    Collection<ServiceInfo> services = nodeEngine.getServiceInfos(MigrationAwareService.class);
    PartitionReplicationEvent event = new PartitionReplicationEvent(getPartitionId(), getReplicaIndex());
    List<Operation> tasks = new LinkedList<Operation>();
    for (ServiceInfo serviceInfo : services) {
        MigrationAwareService service = (MigrationAwareService) serviceInfo.getService();
        Operation op = service.prepareReplicationOperation(event);
        if (op != null) {
            op.setServiceName(serviceInfo.getName());
            tasks.add(op);
        }
    }
    return tasks;
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) ServiceInfo(com.hazelcast.spi.impl.servicemanager.ServiceInfo) MigrationAwareService(com.hazelcast.spi.MigrationAwareService) PartitionAwareOperation(com.hazelcast.spi.PartitionAwareOperation) MigrationCycleOperation(com.hazelcast.internal.partition.MigrationCycleOperation) Operation(com.hazelcast.spi.Operation) PartitionReplicationEvent(com.hazelcast.spi.PartitionReplicationEvent) LinkedList(java.util.LinkedList)

Example 82 with NodeEngineImpl

use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.

the class MasterClaimOperation method run.

@Override
public void run() {
    final NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
    Node node = nodeEngine.getNode();
    Joiner joiner = node.getJoiner();
    final ILogger logger = node.getLogger(getClass().getName());
    if (joiner instanceof TcpIpJoiner) {
        TcpIpJoiner tcpIpJoiner = (TcpIpJoiner) joiner;
        final Address endpoint = getCallerAddress();
        final Address masterAddress = node.getMasterAddress();
        approvedAsMaster = !tcpIpJoiner.isClaimingMaster() && !node.isMaster() && (masterAddress == null || masterAddress.equals(endpoint));
    } else {
        approvedAsMaster = false;
        logger.warning("This node requires MulticastJoin strategy!");
    }
    if (logger.isFineEnabled()) {
        logger.fine("Sending '" + approvedAsMaster + "' for master claim of node: " + getCallerAddress());
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) TcpIpJoiner(com.hazelcast.cluster.impl.TcpIpJoiner) Joiner(com.hazelcast.cluster.Joiner) Address(com.hazelcast.nio.Address) Node(com.hazelcast.instance.Node) ILogger(com.hazelcast.logging.ILogger) TcpIpJoiner(com.hazelcast.cluster.impl.TcpIpJoiner)

Example 83 with NodeEngineImpl

use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.

the class MemberInfoUpdateOperation method checkLocalMemberUuid.

final void checkLocalMemberUuid() {
    ClusterServiceImpl clusterService = getService();
    NodeEngineImpl nodeEngine = clusterService.getNodeEngine();
    Node node = nodeEngine.getNode();
    if (!node.getThisUuid().equals(targetUuid)) {
        String msg = "targetUuid: " + targetUuid + " is different than this node's uuid: " + node.getThisUuid();
        throw new IllegalStateException(msg);
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Node(com.hazelcast.instance.Node) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl)

Example 84 with NodeEngineImpl

use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.

the class BeforeJoinCheckFailureOperation method run.

@Override
public void run() {
    final NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
    final Node node = nodeEngine.getNode();
    if (node.joined()) {
        throw new IllegalStateException("Node is already joined but received a termination message! " + "Reason: " + failReasonMsg);
    }
    final ILogger logger = nodeEngine.getLogger("com.hazelcast.security");
    logger.severe("Node could not join cluster. Before join check failed node is going to shutdown now!");
    logger.severe("Reason of failure for node join : " + failReasonMsg);
    node.shutdown(true);
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Node(com.hazelcast.instance.Node) ILogger(com.hazelcast.logging.ILogger)

Example 85 with NodeEngineImpl

use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.

the class FinalizeJoinOperation method sendPostJoinOperations.

private void sendPostJoinOperations() {
    final ClusterServiceImpl clusterService = getService();
    final NodeEngineImpl nodeEngine = clusterService.getNodeEngine();
    // Post join operations must be lock free; means no locks at all;
    // no partition locks, no key-based locks, no service level locks!
    final Operation[] postJoinOperations = nodeEngine.getPostJoinOperations();
    final OperationService operationService = nodeEngine.getOperationService();
    if (postJoinOperations != null && postJoinOperations.length > 0) {
        final Collection<Member> members = clusterService.getMembers();
        for (Member member : members) {
            if (!member.localMember()) {
                PostJoinOperation operation = new PostJoinOperation(postJoinOperations);
                operationService.createInvocationBuilder(ClusterServiceImpl.SERVICE_NAME, operation, member.getAddress()).setTryCount(POST_JOIN_TRY_COUNT).invoke();
            }
        }
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) Operation(com.hazelcast.spi.Operation) InternalOperationService(com.hazelcast.spi.impl.operationservice.InternalOperationService) OperationService(com.hazelcast.spi.OperationService) Member(com.hazelcast.core.Member)

Aggregations

NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)112 HazelcastInstance (com.hazelcast.core.HazelcastInstance)39 Test (org.junit.Test)32 ParallelTest (com.hazelcast.test.annotation.ParallelTest)31 QuickTest (com.hazelcast.test.annotation.QuickTest)31 Node (com.hazelcast.instance.Node)21 MapService (com.hazelcast.map.impl.MapService)20 Config (com.hazelcast.config.Config)19 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)19 InternalOperationService (com.hazelcast.spi.impl.operationservice.InternalOperationService)16 MetaDataGenerator (com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator)14 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)14 ILogger (com.hazelcast.logging.ILogger)11 AssertTask (com.hazelcast.test.AssertTask)11 Invalidator (com.hazelcast.internal.nearcache.impl.invalidation.Invalidator)10 MapNearCacheManager (com.hazelcast.map.impl.nearcache.MapNearCacheManager)10 Address (com.hazelcast.nio.Address)10 Data (com.hazelcast.nio.serialization.Data)10 Before (org.junit.Before)10 Operation (com.hazelcast.spi.Operation)9