use of org.neo4j.helpers.AdvertisedSocketAddress in project neo4j by neo4j.
the class IdleChannelReaperHandler method userEventTriggered.
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
if (evt instanceof IdleStateEvent && evt == IdleStateEvent.ALL_IDLE_STATE_EVENT) {
final InetSocketAddress socketAddress = (InetSocketAddress) ctx.channel().remoteAddress();
final AdvertisedSocketAddress address = new AdvertisedSocketAddress(socketAddress.getHostName(), socketAddress.getPort());
nonBlockingChannels.remove(address);
}
}
use of org.neo4j.helpers.AdvertisedSocketAddress in project neo4j by neo4j.
the class UserDefinedConfigurationStrategyTest method fakeReadReplicaTopology.
static ReadReplicaTopology fakeReadReplicaTopology(MemberId... readReplicaIds) {
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)));
offset++;
}
return new ReadReplicaTopology(readReplicas);
}
use of org.neo4j.helpers.AdvertisedSocketAddress in project neo4j by neo4j.
the class HazelcastClusterTopologyTest method shouldCollectMembersAsAMap.
@Test
public void shouldCollectMembersAsAMap() throws Exception {
// given
Set<Member> hazelcastMembers = new HashSet<>();
List<MemberId> coreMembers = new ArrayList<>();
for (int i = 0; i < 5; i++) {
MemberId memberId = new MemberId(UUID.randomUUID());
coreMembers.add(memberId);
Config config = Config.defaults();
HashMap<String, String> settings = new HashMap<>();
settings.put(CausalClusteringSettings.transaction_advertised_address.name(), "tx:" + (i + 1));
settings.put(CausalClusteringSettings.raft_advertised_address.name(), "raft:" + (i + 1));
settings.put(new BoltConnector("bolt").type.name(), "BOLT");
settings.put(new BoltConnector("bolt").enabled.name(), "true");
settings.put(new BoltConnector("bolt").advertised_address.name(), "bolt:" + (i + 1));
settings.put(new BoltConnector("http").type.name(), "HTTP");
settings.put(new BoltConnector("http").enabled.name(), "true");
settings.put(new BoltConnector("http").advertised_address.name(), "http:" + (i + 1));
config.augment(settings);
Map<String, Object> attributes = buildMemberAttributesForCore(memberId, config).getAttributes();
hazelcastMembers.add(new MemberImpl(new Address("localhost", i), null, attributes, false));
}
// when
Map<MemberId, CoreServerInfo> coreMemberMap = toCoreMemberMap(hazelcastMembers, NullLog.getInstance(), hzInstance);
// then
for (int i = 0; i < 5; i++) {
CoreServerInfo coreServerInfo = coreMemberMap.get(coreMembers.get(i));
assertEquals(new AdvertisedSocketAddress("tx", i + 1), coreServerInfo.getCatchupServer());
assertEquals(new AdvertisedSocketAddress("raft", i + 1), coreServerInfo.getRaftServer());
assertEquals(new AdvertisedSocketAddress("bolt", i + 1), coreServerInfo.connectors().boltAddress());
assertEquals(coreServerInfo.groups(), GROUPS);
}
}
use of org.neo4j.helpers.AdvertisedSocketAddress in project neo4j by neo4j.
the class ClientConnectorAddressesTest method shouldSerializeToString.
@Test
public void shouldSerializeToString() throws Exception {
// given
ClientConnectorAddresses connectorAddresses = new ClientConnectorAddresses(asList(new ConnectorUri(bolt, new AdvertisedSocketAddress("host", 1)), new ConnectorUri(http, new AdvertisedSocketAddress("host", 2)), new ConnectorUri(https, new AdvertisedSocketAddress("host", 3))));
// when
ClientConnectorAddresses out = ClientConnectorAddresses.fromString(connectorAddresses.toString());
// then
assertEquals(connectorAddresses, out);
}
use of org.neo4j.helpers.AdvertisedSocketAddress in project neo4j by neo4j.
the class ClientConnectorAddressesTest method shouldSerializeWithNoHttpsAddress.
@Test
public void shouldSerializeWithNoHttpsAddress() throws Exception {
// given
ClientConnectorAddresses connectorAddresses = new ClientConnectorAddresses(asList(new ConnectorUri(bolt, new AdvertisedSocketAddress("host", 1)), new ConnectorUri(http, new AdvertisedSocketAddress("host", 2))));
// when
ClientConnectorAddresses out = ClientConnectorAddresses.fromString(connectorAddresses.toString());
// then
assertEquals(connectorAddresses, out);
}
Aggregations