use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.
the class ConnectionInfoIT method hzTest.
@Test
public void hzTest() throws Throwable {
// given
testSocket = bindPort("0.0.0.0", 4243);
//when
AssertableLogProvider logProvider = new AssertableLogProvider();
AssertableLogProvider userLogProvider = new AssertableLogProvider();
HazelcastDiscoveryServiceFactory hzFactory = new HazelcastDiscoveryServiceFactory();
Config config = embeddedDefaults(stringMap(discovery_listen_address.name(), ":" + testSocket.getLocalPort(), CausalClusteringSettings.initial_discovery_members.name(), "localhost:" + testSocket.getLocalPort(), new BoltConnector("bolt").enabled.name(), "true", new HttpConnector("http").enabled.name(), "true"));
Neo4jJobScheduler jobScheduler = new Neo4jJobScheduler();
jobScheduler.init();
CoreTopologyService coreTopologyService = hzFactory.coreTopologyService(config, new MemberId(UUID.randomUUID()), jobScheduler, logProvider, userLogProvider);
try {
coreTopologyService.init();
coreTopologyService.start();
}//then
catch (Throwable throwable) {
//expected
}
logProvider.assertContainsMessageContaining("Hazelcast was unable to start with setting");
userLogProvider.assertContainsMessageContaining("Hazelcast was unable to start with setting");
}
use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.
the class SegmentedRaftLogPartialEntryRecoveryTest method incompleteEntriesAtTheEndShouldNotCauseFailures.
@Test
public void incompleteEntriesAtTheEndShouldNotCauseFailures() throws Throwable {
// Given
// we use a RaftLog to create a raft log file and then we will start chopping bits off from the end
SegmentedRaftLog raftLog = createRaftLog(100_000);
raftLog.start();
// Add a bunch of entries, preferably one of each available kind.
raftLog.append(new RaftLogEntry(4, new NewLeaderBarrier()));
raftLog.append(new RaftLogEntry(4, new ReplicatedIdAllocationRequest(new MemberId(UUID.randomUUID()), IdType.RELATIONSHIP, 1, 1024)));
raftLog.append(new RaftLogEntry(4, new ReplicatedIdAllocationRequest(new MemberId(UUID.randomUUID()), IdType.RELATIONSHIP, 1025, 1024)));
raftLog.append(new RaftLogEntry(4, new ReplicatedLockTokenRequest(new MemberId(UUID.randomUUID()), 1)));
raftLog.append(new RaftLogEntry(4, new NewLeaderBarrier()));
raftLog.append(new RaftLogEntry(5, new ReplicatedTokenRequest(TokenType.LABEL, "labelToken", new byte[] { 1, 2, 3 })));
raftLog.append(new RaftLogEntry(5, new ReplicatedTransaction(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 })));
raftLog.stop();
// We use a temporary RecoveryProtocol to get the file to chop
RecoveryProtocol recovery = createRecoveryProtocol();
State recoveryState = recovery.run();
String logFilename = recoveryState.segments.last().getFilename();
File logFile = new File(logDirectory, logFilename);
// When
// We remove any number of bytes from the end (up to but not including the header) and try to recover
// Then
// No exceptions should be thrown
truncateAndRecover(logFile, SegmentHeader.SIZE);
}
use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.
the class MemberIdMarshalTest method shouldThrowExceptionForHalfWrittenInstance.
@Test
public void shouldThrowExceptionForHalfWrittenInstance() throws Exception {
// given
// a CoreMember and a ByteBuffer to write it to
MemberId.Marshal marshal = new MemberId.Marshal();
final MemberId aRealMember = new MemberId(UUID.randomUUID());
ByteBuf buffer = Unpooled.buffer(1000);
// and the CoreMember is serialized but for 5 bytes at the end
marshal.marshal(aRealMember, new NetworkFlushableChannelNetty4(buffer));
ByteBuf bufferWithMissingBytes = buffer.copy(0, buffer.writerIndex() - 5);
// when
try {
marshal.unmarshal(new NetworkReadableClosableChannelNetty4(bufferWithMissingBytes));
fail("Should have thrown exception");
} catch (EndOfStreamException e) {
// expected
}
}
use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.
the class MemberIdMarshalTest method shouldSerializeAndDeserialize.
@Test
public void shouldSerializeAndDeserialize() throws Exception {
// given
MemberId.Marshal marshal = new MemberId.Marshal();
final MemberId member = new MemberId(UUID.randomUUID());
// when
ByteBuf buffer = Unpooled.buffer(1_000);
marshal.marshal(member, new NetworkFlushableChannelNetty4(buffer));
final MemberId recovered = marshal.unmarshal(new NetworkReadableClosableChannelNetty4(buffer));
// then
assertEquals(member, recovered);
}
use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.
the class RaftGroupMembershipTest method shouldNotFormGroupWithoutAnyBootstrapping.
@Test
public void shouldNotFormGroupWithoutAnyBootstrapping() throws Exception {
// given
DirectNetworking net = new DirectNetworking();
final MemberId[] ids = { member(0), member(1), member(2) };
RaftTestFixture fixture = new RaftTestFixture(net, 3, ids);
fixture.members().setTargetMembershipSet(new RaftTestGroup(ids).getMembers());
fixture.members().invokeTimeout(ELECTION);
// when
net.processMessages();
// then
assertThat(fixture.members(), hasCurrentMembers(new RaftTestGroup(new int[0])));
assertEquals(0, fixture.members().withRole(LEADER).size());
assertEquals(3, fixture.members().withRole(FOLLOWER).size());
}
Aggregations