Search in sources :

Example 1 with SplitBrainMergeValidationOperation

use of com.hazelcast.internal.cluster.impl.operations.SplitBrainMergeValidationOperation in project hazelcast by hazelcast.

the class AbstractJoiner method sendSplitBrainJoinMessage.

protected SplitBrainJoinMessage sendSplitBrainJoinMessage(Address target) {
    if (logger.isFineEnabled()) {
        logger.fine("Sending SplitBrainJoinMessage to " + target);
    }
    Connection conn = node.connectionManager.getOrConnect(target, true);
    long timeout = SPLIT_BRAIN_CONN_TIMEOUT;
    while (conn == null) {
        timeout -= SPLIT_BRAIN_SLEEP_TIME;
        if (timeout < 0) {
            return null;
        }
        try {
            //noinspection BusyWait
            Thread.sleep(SPLIT_BRAIN_SLEEP_TIME);
        } catch (InterruptedException e) {
            EmptyStatement.ignore(e);
            return null;
        }
        conn = node.connectionManager.getConnection(target);
    }
    NodeEngine nodeEngine = node.nodeEngine;
    Future future = nodeEngine.getOperationService().createInvocationBuilder(ClusterServiceImpl.SERVICE_NAME, new SplitBrainMergeValidationOperation(node.createSplitBrainJoinMessage()), target).setTryCount(1).invoke();
    try {
        return (SplitBrainJoinMessage) future.get(SPLIT_BRAIN_JOIN_CHECK_TIMEOUT_SECONDS, TimeUnit.SECONDS);
    } catch (TimeoutException e) {
        logger.fine("Timeout during join check!", e);
    } catch (Exception e) {
        logger.warning("Error during join check!", e);
    }
    return null;
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) SplitBrainMergeValidationOperation(com.hazelcast.internal.cluster.impl.operations.SplitBrainMergeValidationOperation) Connection(com.hazelcast.nio.Connection) Future(java.util.concurrent.Future) TimeoutException(java.util.concurrent.TimeoutException) MemberLeftException(com.hazelcast.core.MemberLeftException) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

MemberLeftException (com.hazelcast.core.MemberLeftException)1 SplitBrainMergeValidationOperation (com.hazelcast.internal.cluster.impl.operations.SplitBrainMergeValidationOperation)1 Connection (com.hazelcast.nio.Connection)1 NodeEngine (com.hazelcast.spi.NodeEngine)1 Future (java.util.concurrent.Future)1 TimeoutException (java.util.concurrent.TimeoutException)1