/** * Textual representation format for an advertised socket address. * @param hostname of the address. * @param port of the address. * @return a string representing the address. */ public static String advertisedAddress( String hostname, int port ) { return new AdvertisedSocketAddress( hostname, port ).toString(); } }
public String address() { return address.toString(); }
/** * Textual representation format for an advertised socket address. * @param hostname of the address. * @param port of the address. * @return a string representing the address. */ public static String advertisedAddress( String hostname, int port ) { return new AdvertisedSocketAddress( hostname, port ).toString(); } }
static Object[] build( MultiClusterRoutingResult result ) { Function<List<Endpoint>, Object[]> stringifyAddresses = es -> es.stream().map( e -> e.address().toString() ).toArray(); List<Map<String,Object>> response = result.routers().entrySet().stream().map( entry -> { String dbName = entry.getKey(); Object[] addresses = stringifyAddresses.apply( entry.getValue() ); Map<String,Object> responseRow = new TreeMap<>(); responseRow.put( DB_NAME_KEY, dbName ); responseRow.put( ADDRESSES_KEY, addresses ); return responseRow; } ).collect( Collectors.toList() ); long ttlSeconds = MILLISECONDS.toSeconds( result.ttlMillis() ); return new Object[]{ttlSeconds, response}; }
static MemberAttributeConfig buildMemberAttributes( MemberId myself, Config config ) { MemberAttributeConfig memberAttributeConfig = new MemberAttributeConfig(); memberAttributeConfig.setStringAttribute( MEMBER_UUID, myself.getUuid().toString() ); AdvertisedSocketAddress discoveryAddress = config.get( CoreEdgeClusterSettings.discovery_advertised_address ); memberAttributeConfig.setStringAttribute( DISCOVERY_SERVER, discoveryAddress.toString() ); AdvertisedSocketAddress transactionSource = config.get( CoreEdgeClusterSettings.transaction_advertised_address ); memberAttributeConfig.setStringAttribute( TRANSACTION_SERVER, transactionSource.toString() ); AdvertisedSocketAddress raftAddress = config.get( CoreEdgeClusterSettings.raft_advertised_address ); memberAttributeConfig.setStringAttribute( RAFT_SERVER, raftAddress.toString() ); ClientConnectorAddresses clientConnectorAddresses = ClientConnectorAddresses.extractFromConfig( config ); memberAttributeConfig.setStringAttribute( CLIENT_CONNECTOR_ADDRESSES, clientConnectorAddresses.toString() ); return memberAttributeConfig; }
private void keepReadReplicaAlive() throws HazelcastInstanceNotActiveException { hzInstance.perform( hazelcastInstance -> { String uuid = hazelcastInstance.getLocalEndpoint().getUuid(); String addresses = connectorAddresses.toString(); log.debug( "Adding read replica into cluster (%s -> %s)", uuid, addresses ); hazelcastInstance.getMap( READ_REPLICAS_DB_NAME_MAP ).put( uuid, dbName, timeToLive, MILLISECONDS); hazelcastInstance.getMap( READ_REPLICA_TRANSACTION_SERVER_ADDRESS_MAP ).put( uuid, transactionSource.toString(), timeToLive, MILLISECONDS ); hazelcastInstance.getMap( READ_REPLICA_MEMBER_ID_MAP ).put( uuid, myself.getUuid().toString(), timeToLive, MILLISECONDS ); refreshGroups( hazelcastInstance, uuid, groups ); // this needs to be last as when we read from it in HazelcastClusterTopology.readReplicas // we assume that all the other maps have been populated if an entry exists in this one hazelcastInstance.getMap( READ_REPLICA_BOLT_ADDRESS_MAP ).put( uuid, addresses, timeToLive, MILLISECONDS ); } ); } }
@Override public HazelcastInstance connectToHazelcast() { ClientConfig clientConfig = new ClientConfig(); for ( AdvertisedSocketAddress address : config.get( CoreEdgeClusterSettings.initial_discovery_members ) ) { clientConfig.getNetworkConfig().addAddress( address.toString() ); } return HazelcastClient.newHazelcastClient( clientConfig ); } }
static MemberAttributeConfig buildMemberAttributesForCore( MemberId myself, Config config ) { MemberAttributeConfig memberAttributeConfig = new MemberAttributeConfig(); memberAttributeConfig.setStringAttribute( MEMBER_UUID, myself.getUuid().toString() ); AdvertisedSocketAddress discoveryAddress = config.get( CausalClusteringSettings.discovery_advertised_address ); memberAttributeConfig.setStringAttribute( DISCOVERY_SERVER, discoveryAddress.toString() ); AdvertisedSocketAddress transactionSource = config.get( CausalClusteringSettings.transaction_advertised_address ); memberAttributeConfig.setStringAttribute( TRANSACTION_SERVER, transactionSource.toString() ); AdvertisedSocketAddress raftAddress = config.get( CausalClusteringSettings.raft_advertised_address ); memberAttributeConfig.setStringAttribute( RAFT_SERVER, raftAddress.toString() ); ClientConnectorAddresses clientConnectorAddresses = ClientConnectorAddresses.extractFromConfig( config ); memberAttributeConfig.setStringAttribute( CLIENT_CONNECTOR_ADDRESSES, clientConnectorAddresses.toString() ); memberAttributeConfig.setBooleanAttribute( REFUSE_TO_BE_LEADER_KEY, config.get( refuse_to_be_leader ) ); memberAttributeConfig.setStringAttribute( MEMBER_DB_NAME, config.get( CausalClusteringSettings.database ) ); return memberAttributeConfig; } }
@Override public HazelcastInstance connectToHazelcast() { ClientConfig clientConfig = new ClientConfig(); ClientNetworkConfig networkConfig = clientConfig.getNetworkConfig(); for ( AdvertisedSocketAddress address : config.get( CausalClusteringSettings.initial_discovery_members ) ) { for ( AdvertisedSocketAddress advertisedSocketAddress : hostnameResolver.resolve( address ) ) { networkConfig.addAddress( advertisedSocketAddress.toString() ); } } additionalConfig( networkConfig, logProvider ); return HazelcastClient.newHazelcastClient( clientConfig ); }
for ( AdvertisedSocketAddress address : initialMembers ) tcpIpConfig.addMember( address.toString() );
tcpIpConfig.addMember( advertisedSocketAddress.toString() );