/** * Create a (hostname, port) address pair * @param address socket address whose hostname and port are used for the * generated address. * @return a 1 entry map. */ public static Map<String, String> hostnamePortPair(InetSocketAddress address) { return hostnamePortPair(address.getHostName(), address.getPort()); }
/** * Create a (hostname, port) address pair * @param address socket address whose hostname and port are used for the * generated address. * @return a 1 entry map. */ public static Map<String, String> hostnamePortPair(InetSocketAddress address) { return hostnamePortPair(address.getHostName(), address.getPort()); }
/** * Create an IPC endpoint * @param api API * @param address the address as a tuple of (hostname, port) * @return the new endpoint */ public static Endpoint ipcEndpoint(String api, InetSocketAddress address) { return new Endpoint(api, ADDRESS_HOSTNAME_AND_PORT, ProtocolTypes.PROTOCOL_HADOOP_IPC, address== null ? null: hostnamePortPair(address)); }
/** * Create an IPC endpoint * @param api API * @param address the address as a tuple of (hostname, port) * @return the new endpoint */ public static Endpoint ipcEndpoint(String api, InetSocketAddress address) { return new Endpoint(api, ADDRESS_HOSTNAME_AND_PORT, ProtocolTypes.PROTOCOL_HADOOP_IPC, address== null ? null: hostnamePortPair(address)); }
/** * Create an internet address endpoint from a list of URIs * @param api implemented API * @param protocolType protocol type * @param hostname hostname/FQDN * @param port port * @return a new endpoint */ public static Endpoint inetAddrEndpoint(String api, String protocolType, String hostname, int port) { Preconditions.checkArgument(api != null, "null API"); Preconditions.checkArgument(protocolType != null, "null protocolType"); Preconditions.checkArgument(hostname != null, "null hostname"); return new Endpoint(api, ADDRESS_HOSTNAME_AND_PORT, protocolType, hostnamePortPair(hostname, port)); }
/** * Create an internet address endpoint from a list of URIs * @param api implemented API * @param protocolType protocol type * @param hostname hostname/FQDN * @param port port * @return a new endpoint */ public static Endpoint inetAddrEndpoint(String api, String protocolType, String hostname, int port) { Preconditions.checkArgument(api != null, "null API"); Preconditions.checkArgument(protocolType != null, "null protocolType"); Preconditions.checkArgument(hostname != null, "null hostname"); return new Endpoint(api, ADDRESS_HOSTNAME_AND_PORT, protocolType, hostnamePortPair(hostname, port)); }
/** * Add some endpoints * @param entry entry */ public static void addSampleEndpoints(ServiceRecord entry, String hostname) throws URISyntaxException { assertNotNull(hostname); entry.addExternalEndpoint(webEndpoint(HTTP_API, new URI("http", hostname + ":80", "/"))); entry.addExternalEndpoint( restEndpoint(API_WEBHDFS, new URI("http", hostname + ":8020", "/"))); Endpoint endpoint = ipcEndpoint(API_HDFS, null); endpoint.addresses.add(RegistryTypeUtils.hostnamePortPair(hostname, 8030)); entry.addInternalEndpoint(endpoint); InetSocketAddress localhost = new InetSocketAddress("localhost", 8050); entry.addInternalEndpoint( inetAddrEndpoint(NNIPC, ProtocolTypes.PROTOCOL_THRIFT, "localhost", 8050)); entry.addInternalEndpoint( RegistryTypeUtils.ipcEndpoint( IPC2, localhost)); }
/** * Add some endpoints * @param entry entry */ public static void addSampleEndpoints(ServiceRecord entry, String hostname) throws URISyntaxException { assertNotNull(hostname); entry.addExternalEndpoint(webEndpoint(HTTP_API, new URI("http", hostname + ":80", "/"))); entry.addExternalEndpoint( restEndpoint(API_WEBHDFS, new URI("http", hostname + ":8020", "/"))); Endpoint endpoint = ipcEndpoint(API_HDFS, null); endpoint.addresses.add(RegistryTypeUtils.hostnamePortPair(hostname, 8030)); entry.addInternalEndpoint(endpoint); InetSocketAddress localhost = new InetSocketAddress("localhost", 8050); entry.addInternalEndpoint( inetAddrEndpoint(NNIPC, ProtocolTypes.PROTOCOL_THRIFT, "localhost", 8050)); entry.addInternalEndpoint( RegistryTypeUtils.ipcEndpoint( IPC2, localhost)); }