use of org.neo4j.helpers.AdvertisedSocketAddress in project neo4j by neo4j.
the class DiscoveryRepresentationTest method shouldCreateAMapContainingDataAndManagementURIs.
@Test
public void shouldCreateAMapContainingDataAndManagementURIs() throws Exception {
String managementUri = "/management";
String dataUri = "/data";
AdvertisedSocketAddress boltAddress = new AdvertisedSocketAddress("localhost", 7687);
DiscoveryRepresentation dr = new DiscoveryRepresentation(managementUri, dataUri, boltAddress);
Map<String, Object> mapOfUris = RepresentationTestAccess.serialize(dr);
Object mappedManagementUri = mapOfUris.get("management");
Object mappedDataUri = mapOfUris.get("data");
Object mappedBoltUri = mapOfUris.get("bolt");
assertNotNull(mappedManagementUri);
assertNotNull(mappedDataUri);
assertNotNull(mappedBoltUri);
URI baseUri = RepresentationTestBase.BASE_URI;
assertEquals(mappedManagementUri.toString(), Serializer.joinBaseWithRelativePath(baseUri, managementUri));
assertEquals(mappedDataUri.toString(), Serializer.joinBaseWithRelativePath(baseUri, dataUri));
assertEquals(mappedBoltUri.toString(), toBoltUri(boltAddress));
}
use of org.neo4j.helpers.AdvertisedSocketAddress in project neo4j by neo4j.
the class DiscoveryServiceTest method setUp.
@Before
public void setUp() throws URISyntaxException {
baseUri = "http://www.example.com";
boltAddress = new AdvertisedSocketAddress("www.example.com", 7687);
dataUri = new URI("/data");
managementUri = new URI("/management");
}
use of org.neo4j.helpers.AdvertisedSocketAddress in project neo4j by neo4j.
the class ClusterMembershipChangeIT method newMemberNotInInitialMembersConfig.
@Test
@Ignore("Incomplete, HC will hang waiting for others to join.")
public void newMemberNotInInitialMembersConfig() throws Throwable {
// when
Cluster cluster = clusterRule.withNumberOfReadReplicas(0).startCluster();
List<AdvertisedSocketAddress> onlyServerZero = singletonList(Cluster.socketAddressForServer(0));
// then
cluster.addCoreMemberWithIdAndInitialMembers(3, onlyServerZero).start();
cluster.addCoreMemberWithIdAndInitialMembers(4, onlyServerZero).start();
cluster.addCoreMemberWithIdAndInitialMembers(5, onlyServerZero).start();
cluster.removeCoreMemberWithMemberId(0);
cluster.removeCoreMemberWithMemberId(1);
cluster.removeCoreMemberWithMemberId(2);
cluster.shutdown();
cluster.start();
List<Object[]> currentMembers;
for (CoreClusterMember member : cluster.coreMembers()) {
currentMembers = discoverClusterMembers(member.database());
assertThat(currentMembers, containsInAnyOrder(new Object[] { "127.0.0.1:8003" }, new Object[] { "127.0.0.1:8004" }, new Object[] { "127.0.0.1:8005" }));
}
}
use of org.neo4j.helpers.AdvertisedSocketAddress 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.helpers.AdvertisedSocketAddress in project neo4j by neo4j.
the class AdvertisedAddressSettingsTest method shouldCombineDefaultHostnameWithExplicitPortWhenOnlyAPortProvided.
@Test
public void shouldCombineDefaultHostnameWithExplicitPortWhenOnlyAPortProvided() throws Exception {
// given
Map<String, String> config = stringMap(GraphDatabaseSettings.default_advertised_address.name(), "server1.example.com", advertised_address_setting.name(), ":4000");
// when
AdvertisedSocketAddress advertisedSocketAddress = advertised_address_setting.apply(config::get);
// then
assertEquals("server1.example.com", advertisedSocketAddress.getHostname());
assertEquals(4000, advertisedSocketAddress.getPort());
}
Aggregations