Example usage for java.net InetSocketAddress getHostName

List of usage examples for java.net InetSocketAddress getHostName

Introduction

In this page you can find the example usage for java.net InetSocketAddress getHostName.

Prototype

public final String getHostName() 

Source Link

Document

Gets the hostname .

Usage

From source file:org.sonar.ide.intellij.wsclient.WSClientFactory.java

/**
 * Creates new Sonar web service client, which uses proxy settings from IntelliJ.
 *//*from  w  w w .  j a  v  a2  s.c o  m*/
private SonarClient createSonarClient(Host host) {
    SonarClient.Builder builder = SonarClient.builder().url(host.getHost()).login(host.getUsername())
            .password(host.getPassword());
    Proxy proxy = getIntelliJProxyFor(host);
    if (proxy != null) {
        InetSocketAddress address = (InetSocketAddress) proxy.address();
        HttpConfigurable proxySettings = HttpConfigurable.getInstance();
        builder.proxy(address.getHostName(), address.getPort());
        if (proxySettings.PROXY_AUTHENTICATION) {
            builder.proxyLogin(proxySettings.PROXY_LOGIN).proxyPassword(proxySettings.getPlainProxyPassword());
        }
    }
    return builder.build();
}

From source file:org.apache.hadoop.hdfs.server.namenode.AvatarNodeNew.java

public static InetSocketAddress getAvatarShellAddress(Configuration conf) {
    InetSocketAddress u = NameNode.getAddress(conf);
    int port = conf.getInt("dfs.avatarnode.port", u.getPort() + 1);
    String avatarShellIP = conf.get("dfs.avatarshell.ip", u.getHostName());
    return new InetSocketAddress(avatarShellIP, port);
}

From source file:org.apache.hadoop.mapred.JobHistoryServer.java

private HttpServer initializeWebContainer(JobConf conf, ACLsManager aclsManager) throws IOException {
    InetSocketAddress infoSocAddr = NetUtils.createSocketAddr(historyInfoAddr);
    int tmpInfoPort = infoSocAddr.getPort();
    return new HttpServer("history", infoSocAddr.getHostName(), tmpInfoPort, tmpInfoPort == 0, conf,
            aclsManager.getAdminsAcl());
}

From source file:org.apache.hadoop.mapreduce.v2.hs.JobHistoryServer.java

protected void doSecureLogin(Configuration conf) throws IOException {
    InetSocketAddress socAddr = getBindAddress(conf);
    SecurityUtil.login(conf, JHAdminConfig.MR_HISTORY_KEYTAB, JHAdminConfig.MR_HISTORY_PRINCIPAL,
            socAddr.getHostName());
}

From source file:org.wso2.carbon.clustering.hazelcast.wka.WKABasedMembershipScheme.java

@Override
public void joinGroup() throws ClusteringFault {
    primaryHazelcastInstance.getCluster().addMembershipListener(new WKAMembershipListener());
    allMembers = MemberUtils.getMembersMap(primaryHazelcastInstance, primaryDomain);
    allMembers.addEntryListener(new MemberEntryListener(), true);

    // Add the rest of the members
    for (Member member : allMembers.values()) {
        InetSocketAddress inetSocketAddress = localMember.getInetSocketAddress();
        if (!member.getHostName().equals(inetSocketAddress.getHostName())
                && member.getPort() != inetSocketAddress.getPort()) { // Don't add the local member
            MemberUtils.addMember(member, nwConfig.getJoin().getTcpIpConfig());
        }/*w w  w .  j  a  va2  s.  c  o  m*/
    }
}

From source file:org.ethereum.config.DefaultConfig.java

@Bean
public PeerExplorer peerExplorer() {
    RskSystemProperties rskConfig = RskSystemProperties.RSKCONFIG;
    ECKey key = rskConfig.getMyKey();
    Node localNode = new Node(key.getNodeId(), rskConfig.bindIp(), rskConfig.listenPort());
    NodeDistanceTable distanceTable = new NodeDistanceTable(KademliaOptions.BINS, KademliaOptions.BUCKET_SIZE,
            localNode);// www . j av a 2 s .  c o m
    long msgTimeOut = rskConfig.peerDiscoveryMessageTimeOut();
    long refreshPeriod = rskConfig.peerDiscoveryRefreshPeriod();
    List<String> initialBootNodes = rskConfig.peerDiscoveryIPList();
    List<Node> activePeers = rskConfig.peerActive();
    if (CollectionUtils.isNotEmpty(activePeers)) {
        for (Node n : activePeers) {
            InetSocketAddress address = n.getAddress();
            initialBootNodes.add(address.getHostName() + ":" + address.getPort());
        }
    }
    return new PeerExplorer(initialBootNodes, localNode, distanceTable, key, msgTimeOut, refreshPeriod);
}

From source file:brooklyn.util.ResourceUtilsHttpTest.java

@BeforeClass(alwaysRun = true)
public void setUp() throws Exception {
    utils = ResourceUtils.create(this, "mycontext");

    BasicHttpProcessor httpProcessor = new BasicHttpProcessor();
    httpProcessor.addInterceptor(new ResponseServer());
    httpProcessor.addInterceptor(new ResponseContent());
    httpProcessor.addInterceptor(new ResponseConnControl());
    httpProcessor.addInterceptor(new RequestBasicAuth());
    httpProcessor.addInterceptor(new ResponseBasicUnauthorized());

    server = new LocalTestServer(httpProcessor, null);
    server.register("/simple", new SimpleResponseHandler("OK"));
    server.register("/empty", new SimpleResponseHandler(HttpStatus.SC_NO_CONTENT, ""));
    server.register("/missing", new SimpleResponseHandler(HttpStatus.SC_NOT_FOUND, "Missing"));
    server.register("/redirect", new SimpleResponseHandler(HttpStatus.SC_MOVED_TEMPORARILY, "Redirect",
            new BasicHeader("Location", "/simple")));
    server.register("/cycle", new SimpleResponseHandler(HttpStatus.SC_MOVED_TEMPORARILY, "Redirect",
            new BasicHeader("Location", "/cycle")));
    server.register("/secure", new SimpleResponseHandler(HttpStatus.SC_MOVED_TEMPORARILY, "Redirect",
            new BasicHeader("Location", "https://0.0.0.0/")));
    server.register("/auth", new AuthHandler("test", "test", "OK"));
    server.register("/auth_escape", new AuthHandler("test@me:/", "test", "OK"));
    server.register("/auth_escape2", new AuthHandler("test@me:test", "", "OK"));
    server.register("/no_credentials", new CheckNoCredentials());
    server.start();/* w w  w  .  j a v  a  2  s. c om*/

    InetSocketAddress addr = server.getServiceAddress();
    baseUrl = "http://" + addr.getHostName() + ":" + addr.getPort();
}

From source file:org.apache.hadoop.hdfs.tools.DFSZKFailoverController.java

@Override
public void loginAsFCUser() throws IOException {
    InetSocketAddress socAddr = NameNode.getAddress(conf);
    SecurityUtil.login(conf, DFS_NAMENODE_KEYTAB_FILE_KEY, DFS_NAMENODE_KERBEROS_PRINCIPAL_KEY,
            socAddr.getHostName());
}

From source file:org.apache.flink.client.CliFrontendAddressConfigurationTest.java

@Test
public void testInvalidConfigAndOption() {
    try {/*from  w  w w. j ava2s .  c  o m*/
        CliFrontend frontend = new CliFrontend(CliFrontendTestUtils.getInvalidConfigDir());

        CommandLineOptions options = mock(CommandLineOptions.class);
        when(options.getJobManagerAddress()).thenReturn("10.221.130.22:7788");

        frontend.updateConfig(options);
        Configuration config = frontend.getConfiguration();

        InetSocketAddress expectedAddress = new InetSocketAddress("10.221.130.22", 7788);

        checkJobManagerAddress(config, expectedAddress.getHostName(), expectedAddress.getPort());
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}

From source file:org.apache.hadoop.registry.server.services.MicroZookeeperService.java

/**
 * Get the connection string./*from   w  w  w. j av a2  s.c o  m*/
 * @return the string
 * @throws IllegalStateException if the connection is not yet valid
 */
public String getConnectionString() {
    Preconditions.checkState(factory != null, "service not started");
    InetSocketAddress addr = factory.getLocalAddress();
    return String.format("%s:%d", addr.getHostName(), addr.getPort());
}