Search in sources :

Example 6 with AdvertisedSocketAddress

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));
}
Also used : AdvertisedSocketAddress(org.neo4j.helpers.AdvertisedSocketAddress) URI(java.net.URI) Test(org.junit.Test)

Example 7 with AdvertisedSocketAddress

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");
}
Also used : AdvertisedSocketAddress(org.neo4j.helpers.AdvertisedSocketAddress) URI(java.net.URI) Before(org.junit.Before)

Example 8 with AdvertisedSocketAddress

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" }));
    }
}
Also used : CoreClusterMember(org.neo4j.causalclustering.discovery.CoreClusterMember) Cluster(org.neo4j.causalclustering.discovery.Cluster) AdvertisedSocketAddress(org.neo4j.helpers.AdvertisedSocketAddress) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 9 with AdvertisedSocketAddress

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);
}
Also used : MemberId(org.neo4j.causalclustering.identity.MemberId) ReadReplicaInfo(org.neo4j.causalclustering.discovery.ReadReplicaInfo) HashMap(java.util.HashMap) AdvertisedSocketAddress(org.neo4j.helpers.AdvertisedSocketAddress) ClientConnectorAddresses(org.neo4j.causalclustering.discovery.ClientConnectorAddresses) ReadReplicaTopology(org.neo4j.causalclustering.discovery.ReadReplicaTopology)

Example 10 with AdvertisedSocketAddress

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());
}
Also used : AdvertisedSocketAddress(org.neo4j.helpers.AdvertisedSocketAddress) Test(org.junit.Test)

Aggregations

AdvertisedSocketAddress (org.neo4j.helpers.AdvertisedSocketAddress)31 Test (org.junit.Test)15 HashMap (java.util.HashMap)7 MemberId (org.neo4j.causalclustering.identity.MemberId)6 BoltConnector (org.neo4j.kernel.configuration.BoltConnector)4 Config (org.neo4j.kernel.configuration.Config)4 BiFunction (java.util.function.BiFunction)3 ClientConnectorAddresses (org.neo4j.causalclustering.discovery.ClientConnectorAddresses)3 ListenSocketAddress (org.neo4j.helpers.ListenSocketAddress)3 MemberAttributeConfig (com.hazelcast.config.MemberAttributeConfig)2 Channel (io.netty.channel.Channel)2 File (java.io.File)2 InetSocketAddress (java.net.InetSocketAddress)2 URI (java.net.URI)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 Before (org.junit.Before)2 ConnectorUri (org.neo4j.causalclustering.discovery.ClientConnectorAddresses.ConnectorUri)2 Cluster (org.neo4j.causalclustering.discovery.Cluster)2 CoreServerInfo (org.neo4j.causalclustering.discovery.CoreServerInfo)2