@Test public void getLocalNodeNameClient() throws Exception { CommonUtils.PROCESS_TYPE.set(ProcessType.CLIENT); try (Closeable c = new ConfigurationRule(PropertyKey.LOCALITY_TIER_NODE, "client", mConfiguration) .toResource()) { assertEquals("client", NetworkAddressUtils.getLocalNodeName(mConfiguration)); } }
public static String getLocalNodeName(AlluxioConfiguration conf) { switch (CommonUtils.PROCESS_TYPE.get()) { case JOB_MASTER: if (conf.isSet(PropertyKey.JOB_MASTER_HOSTNAME)) { return conf.get(PropertyKey.JOB_MASTER_HOSTNAME); } break; case JOB_WORKER: if (conf.isSet(PropertyKey.JOB_WORKER_HOSTNAME)) { return conf.get(PropertyKey.JOB_WORKER_HOSTNAME); } break; case CLIENT: if (conf.isSet(PropertyKey.USER_HOSTNAME)) { return conf.get(PropertyKey.USER_HOSTNAME); } break; case MASTER: if (conf.isSet(PropertyKey.MASTER_HOSTNAME)) { return conf.get(PropertyKey.MASTER_HOSTNAME); } break; case WORKER: if (conf.isSet(PropertyKey.WORKER_HOSTNAME)) { return conf.get(PropertyKey.WORKER_HOSTNAME); } break; default: break; } if (conf.isSet(PropertyKey.LOCALITY_TIER_NODE)) { return conf.get(PropertyKey.LOCALITY_TIER_NODE); } return getLocalHostName((int) conf.getMs(PropertyKey.NETWORK_HOST_RESOLUTION_TIMEOUT_MS)); }
NetworkAddressUtils { public static String getLocalNodeName(AlluxioConfiguration conf) { switch (CommonUtils.PROCESS_TYPE.get()) { case JOB_MASTER: if (conf.isSet(PropertyKey.JOB_MASTER_HOSTNAME)) { return conf.get(PropertyKey.JOB_MASTER_HOSTNAME); } break; case JOB_WORKER: if (conf.isSet(PropertyKey.JOB_WORKER_HOSTNAME)) { return conf.get(PropertyKey.JOB_WORKER_HOSTNAME); } break; case CLIENT: if (conf.isSet(PropertyKey.USER_HOSTNAME)) { return conf.get(PropertyKey.USER_HOSTNAME); } break; case MASTER: if (conf.isSet(PropertyKey.MASTER_HOSTNAME)) { return conf.get(PropertyKey.MASTER_HOSTNAME); } break; case WORKER: if (conf.isSet(PropertyKey.WORKER_HOSTNAME)) { return conf.get(PropertyKey.WORKER_HOSTNAME); } break; default: break; } if (conf.isSet(PropertyKey.LOCALITY_TIER_NODE)) { return conf.get(PropertyKey.LOCALITY_TIER_NODE); } return getLocalHostName((int) conf.getMs(PropertyKey.NETWORK_HOST_RESOLUTION_TIMEOUT_MS)); } }
NetworkAddressUtils { public static String getLocalNodeName(AlluxioConfiguration conf) { switch (CommonUtils.PROCESS_TYPE.get()) { case JOB_MASTER: if (conf.isSet(PropertyKey.JOB_MASTER_HOSTNAME)) { return conf.get(PropertyKey.JOB_MASTER_HOSTNAME); } break; case JOB_WORKER: if (conf.isSet(PropertyKey.JOB_WORKER_HOSTNAME)) { return conf.get(PropertyKey.JOB_WORKER_HOSTNAME); } break; case CLIENT: if (conf.isSet(PropertyKey.USER_HOSTNAME)) { return conf.get(PropertyKey.USER_HOSTNAME); } break; case MASTER: if (conf.isSet(PropertyKey.MASTER_HOSTNAME)) { return conf.get(PropertyKey.MASTER_HOSTNAME); } break; case WORKER: if (conf.isSet(PropertyKey.WORKER_HOSTNAME)) { return conf.get(PropertyKey.WORKER_HOSTNAME); } break; default: break; } if (conf.isSet(PropertyKey.LOCALITY_TIER_NODE)) { return conf.get(PropertyKey.LOCALITY_TIER_NODE); } return getLocalHostName((int) conf.getMs(PropertyKey.NETWORK_HOST_RESOLUTION_TIMEOUT_MS)); } private  NetworkAddressUtils(); }
NetworkAddressUtils { public static String getLocalNodeName(AlluxioConfiguration conf) { switch (CommonUtils.PROCESS_TYPE.get()) { case JOB_MASTER: if (conf.isSet(PropertyKey.JOB_MASTER_HOSTNAME)) { return conf.get(PropertyKey.JOB_MASTER_HOSTNAME); } break; case JOB_WORKER: if (conf.isSet(PropertyKey.JOB_WORKER_HOSTNAME)) { return conf.get(PropertyKey.JOB_WORKER_HOSTNAME); } break; case CLIENT: if (conf.isSet(PropertyKey.USER_HOSTNAME)) { return conf.get(PropertyKey.USER_HOSTNAME); } break; case MASTER: if (conf.isSet(PropertyKey.MASTER_HOSTNAME)) { return conf.get(PropertyKey.MASTER_HOSTNAME); } break; case WORKER: if (conf.isSet(PropertyKey.WORKER_HOSTNAME)) { return conf.get(PropertyKey.WORKER_HOSTNAME); } break; default: break; } if (conf.isSet(PropertyKey.LOCALITY_TIER_NODE)) { return conf.get(PropertyKey.LOCALITY_TIER_NODE); } return getLocalHostName((int) conf.getMs(PropertyKey.NETWORK_HOST_RESOLUTION_TIMEOUT_MS)); } private  NetworkAddressUtils(); static void assertValidPort(final int port); static void assertValidPort(final InetSocketAddress address); static InetSocketAddress getConnectAddress(ServiceType service,
      AlluxioConfiguration conf); static String getConnectHost(ServiceType service, AlluxioConfiguration conf); static int getPort(ServiceType service, AlluxioConfiguration conf); static InetSocketAddress getBindAddress(ServiceType service, AlluxioConfiguration conf); static String getBindHost(ServiceType service, AlluxioConfiguration conf); static String getClientHostName(AlluxioConfiguration conf); static String getLocalNodeName(AlluxioConfiguration conf); static synchronized String getLocalHostName(int timeoutMs); static synchronized String getLocalHostMetricName(int timeoutMs); static synchronized String getLocalIpAddress(int timeoutMs); static boolean isServing(String host, int port); @Nullable static String resolveHostName(String hostname); static String resolveIpAddress(String hostname); static String getFqdnHost(InetSocketAddress addr); static String getFqdnHost(WorkerNetAddress addr); @Nullable static InetSocketAddress parseInetSocketAddress(String address); static InetSocketAddress getRpcPortSocketAddress(WorkerNetAddress netAddress); static SocketAddress getDataPortSocketAddress(WorkerNetAddress netAddress,
      AlluxioConfiguration conf); static void pingService(InetSocketAddress address, alluxio.grpc.ServiceType serviceType,
      AlluxioConfiguration conf, UserState userState); }
NetworkAddressUtils { public static String getLocalNodeName(AlluxioConfiguration conf) { switch (CommonUtils.PROCESS_TYPE.get()) { case JOB_MASTER: if (conf.isSet(PropertyKey.JOB_MASTER_HOSTNAME)) { return conf.get(PropertyKey.JOB_MASTER_HOSTNAME); } break; case JOB_WORKER: if (conf.isSet(PropertyKey.JOB_WORKER_HOSTNAME)) { return conf.get(PropertyKey.JOB_WORKER_HOSTNAME); } break; case CLIENT: if (conf.isSet(PropertyKey.USER_HOSTNAME)) { return conf.get(PropertyKey.USER_HOSTNAME); } break; case MASTER: if (conf.isSet(PropertyKey.MASTER_HOSTNAME)) { return conf.get(PropertyKey.MASTER_HOSTNAME); } break; case WORKER: if (conf.isSet(PropertyKey.WORKER_HOSTNAME)) { return conf.get(PropertyKey.WORKER_HOSTNAME); } break; default: break; } if (conf.isSet(PropertyKey.LOCALITY_TIER_NODE)) { return conf.get(PropertyKey.LOCALITY_TIER_NODE); } return getLocalHostName((int) conf.getMs(PropertyKey.NETWORK_HOST_RESOLUTION_TIMEOUT_MS)); } private  NetworkAddressUtils(); static void assertValidPort(final int port); static void assertValidPort(final InetSocketAddress address); static InetSocketAddress getConnectAddress(ServiceType service,
      AlluxioConfiguration conf); static String getConnectHost(ServiceType service, AlluxioConfiguration conf); static int getPort(ServiceType service, AlluxioConfiguration conf); static InetSocketAddress getBindAddress(ServiceType service, AlluxioConfiguration conf); static String getBindHost(ServiceType service, AlluxioConfiguration conf); static String getClientHostName(AlluxioConfiguration conf); static String getLocalNodeName(AlluxioConfiguration conf); static synchronized String getLocalHostName(int timeoutMs); static synchronized String getLocalHostMetricName(int timeoutMs); static synchronized String getLocalIpAddress(int timeoutMs); static boolean isServing(String host, int port); @Nullable static String resolveHostName(String hostname); static String resolveIpAddress(String hostname); static String getFqdnHost(InetSocketAddress addr); static String getFqdnHost(WorkerNetAddress addr); @Nullable static InetSocketAddress parseInetSocketAddress(String address); static InetSocketAddress getRpcPortSocketAddress(WorkerNetAddress netAddress); static SocketAddress getDataPortSocketAddress(WorkerNetAddress netAddress,
      AlluxioConfiguration conf); static void pingService(InetSocketAddress address, alluxio.grpc.ServiceType serviceType,
      AlluxioConfiguration conf, UserState userState); static final String WILDCARD_ADDRESS; static final String UNKNOWN_HOSTNAME; static final boolean WINDOWS; }