use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.
the class ReplicatedIdAllocationRequestSerializer method unmarshal.
public static ReplicatedIdAllocationRequest unmarshal(ReadableChannel channel) throws IOException, EndOfStreamException {
MemberId owner = new MemberId.Marshal().unmarshal(channel);
IdType idType = IdType.values()[channel.getInt()];
long idRangeStart = channel.getLong();
int idRangeLength = channel.getInt();
return new ReplicatedIdAllocationRequest(owner, idType, idRangeStart, idRangeLength);
}
use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.
the class UserDefinedConfigurationStrategyTest method fakeReadReplicaTopology.
private ReadReplicaTopology fakeReadReplicaTopology(MemberId[] readReplicaIds, NoEastGroupGenerator groupGenerator) {
assert readReplicaIds.length > 0;
Map<MemberId, ReadReplicaInfo> readReplicas = new HashMap<>();
int offset = 0;
for (MemberId memberId : readReplicaIds) {
readReplicas.put(memberId, new ReadReplicaInfo(new ClientConnectorAddresses(singletonList(new ClientConnectorAddresses.ConnectorUri(ClientConnectorAddresses.Scheme.bolt, new AdvertisedSocketAddress("localhost", 11000 + offset)))), new AdvertisedSocketAddress("localhost", 10000 + offset), groupGenerator.get(memberId)));
offset++;
}
return new ReadReplicaTopology(readReplicas);
}
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
}
}
Aggregations