Search in sources :

Example 1 with Joiner

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

the class JoinMastershipClaimOp method run.

@Override
public void run() {
    final NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
    Node node = nodeEngine.getNode();
    Joiner joiner = node.getJoiner();
    ClusterServiceImpl clusterService = node.getClusterService();
    final ILogger logger = node.getLogger(getClass().getName());
    if (joiner instanceof TcpIpJoiner) {
        TcpIpJoiner tcpIpJoiner = (TcpIpJoiner) joiner;
        final Address endpoint = getCallerAddress();
        final Address masterAddress = clusterService.getMasterAddress();
        approvedAsMaster = !tcpIpJoiner.isClaimingMastership() && !clusterService.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) Joiner(com.hazelcast.internal.cluster.Joiner) TcpIpJoiner(com.hazelcast.internal.cluster.impl.TcpIpJoiner) Address(com.hazelcast.cluster.Address) Node(com.hazelcast.instance.impl.Node) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) ILogger(com.hazelcast.logging.ILogger) TcpIpJoiner(com.hazelcast.internal.cluster.impl.TcpIpJoiner)

Example 2 with Joiner

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

the class NodeMulticastListener method handleNotActiveOrNotJoined.

private void handleNotActiveOrNotJoined(JoinMessage joinMessage) {
    if (isJoinRequest(joinMessage)) {
        Joiner joiner = node.getJoiner();
        if (joiner instanceof MulticastJoiner) {
            MulticastJoiner multicastJoiner = (MulticastJoiner) joiner;
            multicastJoiner.onReceivedJoinRequest((JoinRequest) joinMessage);
        } else {
            logDroppedMessage(joinMessage);
        }
    } else {
        Address address = joinMessage.getAddress();
        if (node.getJoiner().isBlacklisted(address)) {
            logDroppedMessage(joinMessage);
            return;
        }
        ClusterServiceImpl clusterService = node.getClusterService();
        if (!clusterService.isJoined() && clusterService.getMasterAddress() == null) {
            clusterService.setMasterAddressToJoin(joinMessage.getAddress());
        } else {
            logDroppedMessage(joinMessage);
        }
    }
}
Also used : Joiner(com.hazelcast.internal.cluster.Joiner) Address(com.hazelcast.cluster.Address)

Aggregations

Address (com.hazelcast.cluster.Address)2 Joiner (com.hazelcast.internal.cluster.Joiner)2 Node (com.hazelcast.instance.impl.Node)1 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)1 TcpIpJoiner (com.hazelcast.internal.cluster.impl.TcpIpJoiner)1 ILogger (com.hazelcast.logging.ILogger)1 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)1