Search in sources :

Example 26 with RaftEndpoint

use of com.hazelcast.cp.internal.raft.impl.RaftEndpoint in project hazelcast by hazelcast.

the class RaftStateTest method isKnownEndpoint.

@Test
public void isKnownEndpoint() {
    for (RaftEndpoint endpoint : members) {
        assertTrue(state.isKnownMember(endpoint));
    }
    assertFalse(state.isKnownMember(newRaftMember(1234)));
    assertFalse(state.isKnownMember(new TestRaftEndpoint(UUID.randomUUID(), localMember.getPort())));
    assertFalse(state.isKnownMember(new TestRaftEndpoint(localMember.getUuid(), 1234)));
}
Also used : TestRaftEndpoint(com.hazelcast.cp.internal.raft.impl.testing.TestRaftEndpoint) RaftEndpoint(com.hazelcast.cp.internal.raft.impl.RaftEndpoint) TestRaftEndpoint(com.hazelcast.cp.internal.raft.impl.testing.TestRaftEndpoint) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 27 with RaftEndpoint

use of com.hazelcast.cp.internal.raft.impl.RaftEndpoint in project hazelcast by hazelcast.

the class LocalRaftGroup method getNodesExcept.

public RaftNodeImpl[] getNodesExcept(RaftEndpoint endpoint) {
    RaftNodeImpl[] n = new RaftNodeImpl[nodes.length - 1];
    int i = 0;
    for (RaftNodeImpl node : nodes) {
        if (!node.getLocalMember().equals(endpoint)) {
            n[i++] = node;
        }
    }
    if (i != n.length) {
        throw new IllegalArgumentException();
    }
    return n;
}
Also used : RaftNodeImpl(com.hazelcast.cp.internal.raft.impl.RaftNodeImpl) RaftEndpoint(com.hazelcast.cp.internal.raft.impl.RaftEndpoint)

Example 28 with RaftEndpoint

use of com.hazelcast.cp.internal.raft.impl.RaftEndpoint in project hazelcast by hazelcast.

the class LocalRaftGroup method allowMessagesToAll.

/**
 * Allows specific message type one-way from -> to all nodes.
 */
public void allowMessagesToAll(RaftEndpoint from, Class messageType) {
    LocalRaftIntegration integration = getIntegration(getIndexOfRunning(from));
    for (RaftEndpoint endpoint : members) {
        if (!integration.isReachable(endpoint)) {
            throw new IllegalStateException("Cannot allow " + messageType + " from " + from + " -> " + endpoint + ", since all messages are dropped between.");
        }
    }
    integration.allowMessagesToAll(messageType);
}
Also used : RaftEndpoint(com.hazelcast.cp.internal.raft.impl.RaftEndpoint)

Example 29 with RaftEndpoint

use of com.hazelcast.cp.internal.raft.impl.RaftEndpoint in project hazelcast by hazelcast.

the class LocalRaftGroup method split.

/**
 * Split nodes having these members from rest of the cluster.
 */
public void split(RaftEndpoint... endpoints) {
    int[] indexes = new int[endpoints.length];
    for (int i = 0; i < indexes.length; i++) {
        indexes[i] = getIndexOfRunning(endpoints[i]);
    }
    split(indexes);
}
Also used : RaftEndpoint(com.hazelcast.cp.internal.raft.impl.RaftEndpoint)

Example 30 with RaftEndpoint

use of com.hazelcast.cp.internal.raft.impl.RaftEndpoint in project hazelcast by hazelcast.

the class LocalRaftGroup method createNewRaftNode.

public RaftNodeImpl createNewRaftNode(RestoredRaftState restoredRaftState, RaftStateStore stateStore) {
    checkNotNull(restoredRaftState);
    int oldSize = this.integrations.length;
    int newSize = oldSize + 1;
    RaftEndpoint[] endpoints = new RaftEndpoint[newSize];
    LocalRaftIntegration[] integrations = new LocalRaftIntegration[newSize];
    RaftNodeImpl[] nodes = new RaftNodeImpl[newSize];
    System.arraycopy(this.members, 0, endpoints, 0, oldSize);
    System.arraycopy(this.integrations, 0, integrations, 0, oldSize);
    System.arraycopy(this.nodes, 0, nodes, 0, oldSize);
    LocalRaftIntegration integration = createNewLocalRaftIntegration((TestRaftEndpoint) restoredRaftState.localEndpoint());
    createdNodeCount++;
    integrations[oldSize] = integration;
    RaftEndpoint endpoint = integration.getLocalEndpoint();
    endpoints[oldSize] = endpoint;
    RaftNodeImpl node = restoreRaftNode(groupId, restoredRaftState, raftAlgorithmConfig, integration, stateStore);
    nodes[oldSize] = node;
    this.members = endpoints;
    this.integrations = integrations;
    this.nodes = nodes;
    node.start();
    initDiscovery();
    return node;
}
Also used : RaftNodeImpl(com.hazelcast.cp.internal.raft.impl.RaftNodeImpl) RaftEndpoint(com.hazelcast.cp.internal.raft.impl.RaftEndpoint) RaftEndpoint(com.hazelcast.cp.internal.raft.impl.RaftEndpoint)

Aggregations

RaftEndpoint (com.hazelcast.cp.internal.raft.impl.RaftEndpoint)57 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)14 QuickTest (com.hazelcast.test.annotation.QuickTest)14 Test (org.junit.Test)14 RaftNodeImpl (com.hazelcast.cp.internal.raft.impl.RaftNodeImpl)8 RaftState (com.hazelcast.cp.internal.raft.impl.state.RaftState)7 ArrayList (java.util.ArrayList)7 CPMember (com.hazelcast.cp.CPMember)6 RaftLog (com.hazelcast.cp.internal.raft.impl.log.RaftLog)6 UUID (java.util.UUID)6 HazelcastInstance (com.hazelcast.core.HazelcastInstance)5 CPGroupId (com.hazelcast.cp.CPGroupId)5 TestRaftEndpoint (com.hazelcast.cp.internal.raft.impl.testing.TestRaftEndpoint)5 LinkedHashSet (java.util.LinkedHashSet)4 LogEntry (com.hazelcast.cp.internal.raft.impl.log.LogEntry)3 CPSubsystemException (com.hazelcast.cp.exception.CPSubsystemException)2 NotLeaderException (com.hazelcast.cp.exception.NotLeaderException)2 CannotCreateRaftGroupException (com.hazelcast.cp.internal.exception.CannotCreateRaftGroupException)2 RaftStateStore (com.hazelcast.cp.internal.raft.impl.persistence.RaftStateStore)2 LeaderState (com.hazelcast.cp.internal.raft.impl.state.LeaderState)2