Search in sources :

Example 1 with TcpIpJoiner

use of com.hazelcast.cluster.impl.TcpIpJoiner 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 2 with TcpIpJoiner

use of com.hazelcast.cluster.impl.TcpIpJoiner in project hazelcast by hazelcast.

the class Node method createJoiner.

Joiner createJoiner() {
    JoinConfig join = config.getNetworkConfig().getJoin();
    join.verify();
    if (properties.getBoolean(DISCOVERY_SPI_ENABLED)) {
        //TODO: Auto-Upgrade Multicast+AWS configuration!
        logger.info("Activating Discovery SPI Joiner");
        return new DiscoveryJoiner(this, discoveryService, properties.getBoolean(DISCOVERY_SPI_PUBLIC_IP_ENABLED));
    } else {
        if (join.getMulticastConfig().isEnabled() && multicastService != null) {
            logger.info("Creating MulticastJoiner");
            return new MulticastJoiner(this);
        } else if (join.getTcpIpConfig().isEnabled()) {
            logger.info("Creating TcpIpJoiner");
            return new TcpIpJoiner(this);
        } else if (join.getAwsConfig().isEnabled()) {
            Class clazz;
            try {
                logger.info("Creating AWSJoiner");
                clazz = Class.forName("com.hazelcast.cluster.impl.TcpIpJoinerOverAWS");
                Constructor constructor = clazz.getConstructor(Node.class);
                return (Joiner) constructor.newInstance(this);
            } catch (Exception e) {
                throw ExceptionUtil.rethrow(e);
            }
        }
    }
    return null;
}
Also used : MulticastJoiner(com.hazelcast.internal.cluster.impl.MulticastJoiner) DiscoveryJoiner(com.hazelcast.internal.cluster.impl.DiscoveryJoiner) Joiner(com.hazelcast.cluster.Joiner) TcpIpJoiner(com.hazelcast.cluster.impl.TcpIpJoiner) Constructor(java.lang.reflect.Constructor) JoinConfig(com.hazelcast.config.JoinConfig) DiscoveryJoiner(com.hazelcast.internal.cluster.impl.DiscoveryJoiner) TcpIpJoiner(com.hazelcast.cluster.impl.TcpIpJoiner) MulticastJoiner(com.hazelcast.internal.cluster.impl.MulticastJoiner)

Aggregations

Joiner (com.hazelcast.cluster.Joiner)2 TcpIpJoiner (com.hazelcast.cluster.impl.TcpIpJoiner)2 JoinConfig (com.hazelcast.config.JoinConfig)1 Node (com.hazelcast.instance.Node)1 DiscoveryJoiner (com.hazelcast.internal.cluster.impl.DiscoveryJoiner)1 MulticastJoiner (com.hazelcast.internal.cluster.impl.MulticastJoiner)1 ILogger (com.hazelcast.logging.ILogger)1 Address (com.hazelcast.nio.Address)1 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)1 Constructor (java.lang.reflect.Constructor)1