Java Code Examples for org.elasticsearch.common.transport.TransportAddress#getAddress()

The following examples show how to use org.elasticsearch.common.transport.TransportAddress#getAddress() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CoordinatorTests.java    From crate with Apache License 2.0 5 votes vote down vote up
ClusterNode restartedNode(Function<MetaData, MetaData> adaptGlobalMetaData, Function<Long, Long> adaptCurrentTerm,
                          Settings nodeSettings) {
    final TransportAddress address = randomBoolean() ? buildNewFakeTransportAddress() : localNode.getAddress();
    final DiscoveryNode newLocalNode = new DiscoveryNode(localNode.getName(), localNode.getId(),
        UUIDs.randomBase64UUID(random()), // generated deterministically for repeatable tests
        address.address().getHostString(), address.getAddress(), address, Collections.emptyMap(),
        localNode.isMasterNode() ? EnumSet.allOf(Role.class) : emptySet(), Version.CURRENT);
    return new ClusterNode(nodeIndex, newLocalNode,
        node -> new MockPersistedState(newLocalNode, persistedState, adaptGlobalMetaData, adaptCurrentTerm), nodeSettings);
}
 
Example 2
Source File: CoordinatorTests.java    From crate with Apache License 2.0 5 votes vote down vote up
private static DiscoveryNode createDiscoveryNode(int nodeIndex, boolean masterEligible) {
    final TransportAddress address = buildNewFakeTransportAddress();
    return new DiscoveryNode("", "node" + nodeIndex,
        UUIDs.randomBase64UUID(random()), // generated deterministically for repeatable tests
        address.address().getHostString(), address.getAddress(), address, Collections.emptyMap(),
        masterEligible ? EnumSet.allOf(Role.class) : emptySet(), Version.CURRENT);
}
 
Example 3
Source File: CoordinationStateTests.java    From crate with Apache License 2.0 5 votes vote down vote up
public static DiscoveryNode createNode(String id) {
    final TransportAddress address = buildNewFakeTransportAddress();
    return new DiscoveryNode("", id,
        UUIDs.randomBase64UUID(random()), // generated deterministically for repeatable tests
        address.address().getHostString(), address.getAddress(), address, Collections.emptyMap(),
        EnumSet.allOf(Role.class), Version.CURRENT);
}
 
Example 4
Source File: AuditMessage.java    From deprecated-security-advanced-modules with Apache License 2.0 4 votes vote down vote up
public void addRemoteAddress(TransportAddress remoteAddress) {
    if (remoteAddress != null && remoteAddress.getAddress() != null) {
        auditInfo.put(REMOTE_ADDRESS, remoteAddress.getAddress());
    }
}
 
Example 5
Source File: DiscoveryNode.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public static String formatIntoIpPort(TransportAddress address) {
    return address.getAddress() + ":" + address.getPort();
}
 
Example 6
Source File: EmbeddedElasticsearchPolicy.java    From calcite with Apache License 2.0 4 votes vote down vote up
HttpHost httpHost() {
  final TransportAddress address = httpAddress();
  return new HttpHost(address.getAddress(), address.getPort());
}
 
Example 7
Source File: ElasticExtension.java    From immutables with Apache License 2.0 4 votes vote down vote up
private HttpHost httpHost() {
  final TransportAddress address = node.httpAddress();
  return new HttpHost(address.getAddress(), address.getPort());
}
 
Example 8
Source File: DiscoveryNode.java    From Elasticsearch with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new {@link DiscoveryNode}
 * <p>
 * <b>Note:</b> if the version of the node is unknown {@link #MINIMUM_DISCOVERY_NODE_VERSION} should be used.
 * it corresponds to the minimum version this elasticsearch version can communicate with. If a higher version is used
 * the node might not be able to communicate with the remove node. After initial handshakes node versions will be discovered
 * and updated.
 * </p>
 *
 * @param nodeName   the nodes name
 * @param nodeId     the nodes unique id.
 * @param address    the nodes transport address
 * @param attributes node attributes
 * @param version    the version of the node.
 */
public DiscoveryNode(String nodeName, String nodeId, TransportAddress address, Map<String, String> attributes, Version version) {
    this(nodeName, nodeId, address.getHost(), address.getAddress(), address, attributes, version);
}
 
Example 9
Source File: DiscoveryNode.java    From crate with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new {@link DiscoveryNode}
 * <p>
 * <b>Note:</b> if the version of the node is unknown {@link Version#minimumCompatibilityVersion()} should be used for the current
 * version. it corresponds to the minimum version this elasticsearch version can communicate with. If a higher version is used
 * the node might not be able to communicate with the remove node. After initial handshakes node versions will be discovered
 * and updated.
 * </p>
 *
 * @param nodeName         the nodes name
 * @param nodeId           the nodes unique persistent id. An ephemeral id will be auto generated.
 * @param address          the nodes transport address
 * @param attributes       node attributes
 * @param roles            node roles
 * @param version          the version of the node
 */
public DiscoveryNode(String nodeName, String nodeId, TransportAddress address,
                     Map<String, String> attributes, Set<Role> roles, Version version) {
    this(nodeName, nodeId, UUIDs.randomBase64UUID(), address.address().getHostString(), address.getAddress(), address, attributes,
        roles, version);
}