public Endpoint getShuffleEndpoint() { final int shufflePort = HiveConf.getIntVar(conf, ConfVars.LLAP_DAEMON_YARN_SHUFFLE_PORT); // HTTP today, but might not be return RegistryTypeUtils.inetAddrEndpoint(IPC_SHUFFLE, ProtocolTypes.PROTOCOL_TCP, hostname, shufflePort); }
public Endpoint getServicesEndpoint() { final int servicePort = HiveConf.getIntVar(conf, ConfVars.LLAP_DAEMON_WEB_PORT); final boolean isSSL = HiveConf.getBoolVar(conf, ConfVars.LLAP_DAEMON_WEB_SSL); final String scheme = isSSL ? "https" : "http"; final URL serviceURL; try { serviceURL = new URL(scheme, hostname, servicePort, ""); return RegistryTypeUtils.webEndpoint(IPC_SERVICES, serviceURL.toURI()); } catch (MalformedURLException e) { throw new RuntimeException(e); } catch (URISyntaxException e) { throw new RuntimeException("llap service URI for " + hostname + " is invalid", e); } }
public Endpoint getRpcEndpoint() { final int rpcPort = HiveConf.getIntVar(conf, ConfVars.LLAP_DAEMON_RPC_PORT); return RegistryTypeUtils.ipcEndpoint(IPC_LLAP, new InetSocketAddress(hostname, rpcPort)); }
/** * 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)); }
api = line.getOptionValue("api"); sr.addExternalEndpoint( inetAddrEndpoint(api, ProtocolTypes.PROTOCOL_HADOOP_IPC, hostName, portNum)); return usageError("Invalid URI: " + e.getMessage(), BIND_USAGE); sr.addExternalEndpoint(webEndpoint(line.getOptionValue("api"), theUri)); restEndpoint(line.getOptionValue("api"), theUri));
RegistryTypeUtils.webEndpoint( CustomRegistryConstants.WEB_UI, amWebURI.toURI())); RegistryTypeUtils.webEndpoint( CustomRegistryConstants.AM_REST_BASE, amWebURI.toURI())); RegistryTypeUtils.restEndpoint( CustomRegistryConstants.MANAGEMENT_REST_API, managementAPI.toURI())); serviceRecord.addExternalEndpoint( RegistryTypeUtils.restEndpoint( CustomRegistryConstants.PUBLISHER_REST_API, publisherURL.toURI())); serviceRecord.addExternalEndpoint( RegistryTypeUtils.restEndpoint( CustomRegistryConstants.REGISTRY_REST_API, registryREST.toURI())); serviceRecord.addExternalEndpoint( RegistryTypeUtils.restEndpoint( CustomRegistryConstants.PUBLISHER_CONFIGURATIONS_API, new URI(configurationsURL))); serviceRecord.addExternalEndpoint( RegistryTypeUtils.restEndpoint( CustomRegistryConstants.PUBLISHER_EXPORTS_API, new URI(exportsURL)));
@Override public ServiceRecord resolve(String path) throws IOException { byte[] bytes = zkRead(path); ServiceRecord record = serviceRecordMarshal.fromBytes(path, bytes, ServiceRecord.RECORD_TYPE); RegistryTypeUtils.validateServiceRecord(path, record); return record; }
PersistencePolicies.APPLICATION, "tomcat-based web application", null); webapp.addExternalEndpoint(restEndpoint("www", new URI("http", "//loadbalancer/", null))); null, null); comp1.addExternalEndpoint(restEndpoint("www", new URI("http", "//rack4server3:43572", null))); comp1.addInternalEndpoint( inetAddrEndpoint("jmx", "JMX", "rack4server3", 43573)); null, null); comp2.addExternalEndpoint(restEndpoint("www", new URI("http", "//rack1server28:35881", null))); comp2.addInternalEndpoint( inetAddrEndpoint("jmx", "JMX", "rack1server28", 35882));
/** * 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()); }
private void registerHBaseServiceEntry() throws IOException { String name = amState.getApplicationName() ; ServiceRecord serviceRecord = new ServiceRecord(); // bond lifespan to the application serviceRecord.set(YarnRegistryAttributes.YARN_ID, yarnRegistry.getApplicationAttemptId() .getApplicationId().toString()); serviceRecord.set(YarnRegistryAttributes.YARN_PERSISTENCE, PersistencePolicies.APPLICATION); try { URL configURL = new URL(amWebAPI, SLIDER_PATH_PUBLISHER + "/" + HBASE_SERVICE_TYPE); serviceRecord.addExternalEndpoint( RegistryTypeUtils.restEndpoint( CustomRegistryConstants.PUBLISHER_CONFIGURATIONS_API, configURL.toURI())); } catch (URISyntaxException e) { log.warn("failed to create config URL: {}", e, e); } log.info("registering {}/{}", name, HBASE_SERVICE_TYPE); yarnRegistry.putService(HBASE_SERVICE_TYPE, name, serviceRecord, true); PublishedConfiguration publishedSite = new PublishedConfiguration("HBase site", siteConf); PublishedConfigSet configSet = amState.getOrCreatePublishedConfigSet(HBASE_SERVICE_TYPE); configSet.put(HBASE_SITE_PUBLISHED_CONFIG, publishedSite); }
TezAmInstance(ServiceRecord srv) throws IOException { super(srv, TezAmRegistryImpl.IPC_TEZCLIENT); final Endpoint plugin = srv.getInternalEndpoint(TezAmRegistryImpl.IPC_PLUGIN); if (plugin != null) { this.pluginPort = Integer.parseInt(RegistryTypeUtils.getAddressField( plugin.addresses.get(0), AddressTypes.ADDRESS_PORT_FIELD)); } else { this.pluginPort = -1; } }
/** * Get a single URI endpoint * @param epr endpoint * @return the uri of the first entry in the address list. Null if the endpoint * itself is null * @throws InvalidRecordException if the type is wrong, there are no addresses * or the payload ill-formatted */ public static List<String> retrieveAddressesUriType(Endpoint epr) throws InvalidRecordException { if (epr == null) { return null; } requireAddressType(ADDRESS_URI, epr); List<Map<String, String>> addresses = epr.addresses; if (addresses.size() < 1) { throw new InvalidRecordException(epr.toString(), "No addresses in endpoint"); } List<String> results = new ArrayList<String>(addresses.size()); for (Map<String, String> address : addresses) { results.add(getAddressField(address, ADDRESS_URI)); } return results; }
/** * Get the address URLs. Guranteed to return at least one address. * @param epr endpoint * @return the address as a URL * @throws InvalidRecordException if the type is wrong, there are no addresses * or the payload ill-formatted * @throws MalformedURLException address can't be turned into a URL */ public static List<URL> retrieveAddressURLs(Endpoint epr) throws InvalidRecordException, MalformedURLException { if (epr == null) { throw new InvalidRecordException("", "Null endpoint"); } List<String> addresses = retrieveAddressesUriType(epr); List<URL> results = new ArrayList<URL>(addresses.size()); for (String address : addresses) { results.add(new URL(address)); } return results; }
/** * Create a URI * @param uri value * @return a 1 entry map. */ public static Map<String, String> uri(String uri) { return map(ADDRESS_URI, uri); }
/** * 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)); }
api = line.getOptionValue("api"); sr.addExternalEndpoint( inetAddrEndpoint(api, ProtocolTypes.PROTOCOL_HADOOP_IPC, hostName, portNum)); return usageError("Invalid URI: " + e.getMessage(), BIND_USAGE); sr.addExternalEndpoint(webEndpoint(line.getOptionValue("api"), theUri)); restEndpoint(line.getOptionValue("api"), theUri));
RegistryTypeUtils.webEndpoint( CustomRegistryConstants.WEB_UI, amWebURI.toURI())); RegistryTypeUtils.webEndpoint( CustomRegistryConstants.AM_REST_BASE, amWebURI.toURI())); RegistryTypeUtils.restEndpoint( CustomRegistryConstants.MANAGEMENT_REST_API, managementAPI.toURI())); serviceRecord.addExternalEndpoint( RegistryTypeUtils.restEndpoint( CustomRegistryConstants.PUBLISHER_REST_API, publisherURL.toURI())); serviceRecord.addExternalEndpoint( RegistryTypeUtils.restEndpoint( CustomRegistryConstants.REGISTRY_REST_API, registryREST.toURI())); serviceRecord.addExternalEndpoint( RegistryTypeUtils.restEndpoint( CustomRegistryConstants.PUBLISHER_CONFIGURATIONS_API, new URI(configurationsURL))); serviceRecord.addExternalEndpoint( RegistryTypeUtils.restEndpoint( CustomRegistryConstants.PUBLISHER_EXPORTS_API, new URI(exportsURL)));
@Override public ServiceRecord resolve(String path) throws IOException { byte[] bytes = zkRead(path); ServiceRecord record = serviceRecordMarshal.fromBytes(path, bytes, ServiceRecord.RECORD_TYPE); RegistryTypeUtils.validateServiceRecord(path, record); return record; }
/** * 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()); }
public ServiceInstanceBase(ServiceRecord srv, String rpcName) throws IOException { if (LOG.isTraceEnabled()) { LOG.trace("Working with ServiceRecord: {}", srv); } final Endpoint rpc = srv.getInternalEndpoint(rpcName); this.host = RegistryTypeUtils.getAddressField(rpc.addresses.get(0), AddressTypes.ADDRESS_HOSTNAME_FIELD); this.rpcPort = Integer.parseInt(RegistryTypeUtils.getAddressField(rpc.addresses.get(0), AddressTypes.ADDRESS_PORT_FIELD)); this.workerIdentity = srv.get(ZkRegistryBase.UNIQUE_IDENTIFIER); this.properties = srv.attributes(); }