use of org.neo4j.cluster.InstanceId in project neo4j by neo4j.
the class HeartbeatRefreshProcessor method process.
@Override
public boolean process(Message<? extends MessageType> message) {
if (!message.isInternal() && !message.getMessageType().equals(HeartbeatMessage.i_am_alive)) {
try {
String to = message.getHeader(Message.TO);
InstanceId serverId = clusterContext.getConfiguration().getIdForUri(new URI(to));
if (!clusterContext.isMe(serverId)) {
outgoing.offer(Message.internal(HeartbeatMessage.reset_send_heartbeat, serverId));
}
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
return true;
}
use of org.neo4j.cluster.InstanceId in project neo4j by neo4j.
the class MultiPaxosContextTest method shouldDeepClone.
@Test
public void shouldDeepClone() throws Exception {
// Given
ObjectStreamFactory objStream = new ObjectStreamFactory();
AcceptorInstanceStore acceptorInstances = mock(AcceptorInstanceStore.class);
Executor executor = mock(Executor.class);
Timeouts timeouts = mock(Timeouts.class);
ClusterConfiguration clusterConfig = new ClusterConfiguration("myCluster", NullLogProvider.getInstance());
ElectionCredentialsProvider electionCredentials = mock(ElectionCredentialsProvider.class);
Config config = mock(Config.class);
when(config.get(ClusterSettings.max_acceptors)).thenReturn(10);
MultiPaxosContext ctx = new MultiPaxosContext(new InstanceId(1), Collections.<ElectionRole>emptyList(), clusterConfig, executor, NullLogProvider.getInstance(), objStream, objStream, acceptorInstances, timeouts, electionCredentials, config);
// When
MultiPaxosContext snapshot = ctx.snapshot(NullLogProvider.getInstance(), timeouts, executor, acceptorInstances, objStream, objStream, electionCredentials);
// Then
assertEquals(ctx, snapshot);
}
use of org.neo4j.cluster.InstanceId in project neo4j by neo4j.
the class MultiPaxosServer method config.
public void config() {
ClusterConfiguration configuration = ((ClusterContext) server.getStateMachines().getStateMachine(ClusterMessage.class).getContext()).getConfiguration();
Collection<InstanceId> failed = ((HeartbeatContext) server.getStateMachines().getStateMachine(HeartbeatMessage.class).getContext()).getFailed();
}
use of org.neo4j.cluster.InstanceId in project neo4j by neo4j.
the class InstanceIdTest method nodeTriesToJoinRunningClusterWithExistingServerId.
@Test
public void nodeTriesToJoinRunningClusterWithExistingServerId() throws InterruptedException, ExecutionException, TimeoutException, URISyntaxException {
List<URI> correctMembers = new ArrayList<>();
correctMembers.add(URI.create("server1"));
correctMembers.add(URI.create("server2"));
correctMembers.add(URI.create("server3"));
Map<String, InstanceId> roles = new HashMap<>();
roles.put("coordinator", new InstanceId(1));
testCluster(new int[] { 1, 2, 3, 3 }, new VerifyInstanceConfiguration[] { new VerifyInstanceConfiguration(correctMembers, roles, Collections.emptySet()), new VerifyInstanceConfiguration(correctMembers, roles, Collections.emptySet()), new VerifyInstanceConfiguration(correctMembers, roles, Collections.emptySet()), new VerifyInstanceConfiguration(Collections.emptyList(), Collections.emptyMap(), Collections.emptySet()) }, DEFAULT_NETWORK(), new ClusterTestScriptDSL().rounds(600).join(100, 1, 1).join(100, 2, 1).join(100, 3, 1).join(5000, 4, 1).message(0, "*** Conflicting node tried to join"));
}
use of org.neo4j.cluster.InstanceId in project neo4j by neo4j.
the class ElectionContextTest method testElectionOkLessThanQuorumFailed.
@Test
public void testElectionOkLessThanQuorumFailed() {
Set<InstanceId> failed = new HashSet<InstanceId>();
failed.add(new InstanceId(1));
baseTestForElectionOk(failed, false);
}
Aggregations