use of org.neo4j.cluster.InstanceId in project neo4j by neo4j.
the class TestSlaveOnlyCluster method testMasterElectionAfterMasterRecoversInSlaveOnlyCluster.
@Test
public void testMasterElectionAfterMasterRecoversInSlaveOnlyCluster() throws Throwable {
ManagedCluster cluster = clusterRule.startCluster();
assertThat(cluster.getServerId(cluster.getMaster()), equalTo(new InstanceId(3)));
HighlyAvailableGraphDatabase master = cluster.getMaster();
CountDownLatch masterFailedLatch = createMasterFailLatch(cluster);
RepairKit repairKit = cluster.fail(master);
try {
assertTrue(masterFailedLatch.await(60, TimeUnit.SECONDS));
} finally {
repairKit.repair();
}
cluster.await(allSeesAllAsAvailable());
long nodeId = createNodeWithPropertyOn(cluster.getAnySlave(), PROPERTY, VALUE);
try (Transaction ignore = master.beginTx()) {
assertThat(master.getNodeById(nodeId).getProperty(PROPERTY), equalTo(VALUE));
}
}
use of org.neo4j.cluster.InstanceId in project neo4j by neo4j.
the class ClusterStateTest method joinDeniedTimeoutShouldBeHandledWithExceptionIncludingConfiguration.
@Test
public void joinDeniedTimeoutShouldBeHandledWithExceptionIncludingConfiguration() throws Throwable {
// GIVEN
ClusterContext context = mock(ClusterContext.class);
Map<InstanceId, URI> existingMembers = members(1, 2);
when(context.getLog(any(Class.class))).thenReturn(NullLog.getInstance());
when(context.getJoiningInstances()).thenReturn(Collections.<URI>emptyList());
when(context.hasJoinBeenDenied()).thenReturn(true);
when(context.getJoinDeniedConfigurationResponseState()).thenReturn(configurationResponseState(existingMembers));
TrackingMessageHolder outgoing = new TrackingMessageHolder();
// WHEN the join denial actually takes effect (signaled by a join timeout locally)
ClusterState.joining.handle(context, to(ClusterMessage.joiningTimeout, uri(2)).setHeader(Message.CONVERSATION_ID, "bla"), outgoing);
// THEN assert that the failure contains the received configuration
Message<? extends MessageType> response = outgoing.single();
ClusterEntryDeniedException deniedException = response.getPayload();
assertEquals(existingMembers, deniedException.getConfigurationResponseState().getMembers());
}
use of org.neo4j.cluster.InstanceId in project neo4j by neo4j.
the class ClusterStateTest method joinDeniedHandlingShouldKeepResponseConfiguration.
@Test
public void joinDeniedHandlingShouldKeepResponseConfiguration() throws Throwable {
// GIVEN
ClusterContext context = mock(ClusterContext.class);
when(context.getLog(any(Class.class))).thenReturn(NullLog.getInstance());
TrackingMessageHolder outgoing = new TrackingMessageHolder();
Map<InstanceId, URI> members = members(1, 2);
// WHEN a joining instance receives a denial to join
ClusterState.discovery.handle(context, to(joinDenied, uri(2), configurationResponseState(members)), outgoing);
// THEN assert that the response contains the configuration
verify(context).joinDenied(argThat(new ConfigurationResponseStateMatcher().withMembers(members)));
}
use of org.neo4j.cluster.InstanceId in project neo4j by neo4j.
the class MemberIsUnavailableTest method shouldBeDeserializedWhenClusterUriIsNull.
@Test
public void shouldBeDeserializedWhenClusterUriIsNull() throws Exception {
// Given
MemberIsUnavailable message = new MemberIsUnavailable("slave", new InstanceId(1), null);
byte[] serialized = serialize(message);
// When
MemberIsUnavailable deserialized = deserialize(serialized);
// Then
assertNotSame(message, deserialized);
assertEquals("slave", message.getRole());
assertEquals(new InstanceId(1), message.getInstanceId());
assertNull(message.getClusterUri());
}
use of org.neo4j.cluster.InstanceId in project neo4j by neo4j.
the class MemberIsUnavailableTest method shouldBeSerializedWhenClusterUriIsNull.
@Test
public void shouldBeSerializedWhenClusterUriIsNull() throws IOException {
// Given
MemberIsUnavailable message = new MemberIsUnavailable("master", new InstanceId(1), null);
// When
byte[] serialized = serialize(message);
// Then
assertNotEquals(0, serialized.length);
}
Aggregations