use of org.apache.hadoop.registry.client.types.ServiceRecord in project hive by apache.
the class TezAmRegistryImpl method register.
public String register(int amPort, int pluginPort, String sessionId, String serializedToken, String jobIdForToken, int guaranteedCount) throws IOException {
if (srv != null) {
throw new UnsupportedOperationException("Already registered with " + srv);
}
srv = new ServiceRecord();
Endpoint rpcEndpoint = RegistryTypeUtils.ipcEndpoint(IPC_TEZCLIENT, new InetSocketAddress(hostname, amPort));
srv.addInternalEndpoint(rpcEndpoint);
Endpoint pluginEndpoint = null;
if (pluginPort >= 0) {
pluginEndpoint = RegistryTypeUtils.ipcEndpoint(IPC_PLUGIN, new InetSocketAddress(hostname, pluginPort));
srv.addInternalEndpoint(pluginEndpoint);
}
srv.set(AM_SESSION_ID, sessionId);
boolean hasToken = serializedToken != null;
srv.set(AM_PLUGIN_TOKEN, hasToken ? serializedToken : "");
srv.set(AM_PLUGIN_JOBID, jobIdForToken != null ? jobIdForToken : "");
srv.set(AM_GUARANTEED_COUNT, Integer.toString(guaranteedCount));
String uniqueId = registerServiceRecord(srv);
LOG.info("Registered this AM: rpc: {}, plugin: {}, sessionId: {}, token: {}, znodePath: {}", rpcEndpoint, pluginEndpoint, sessionId, hasToken, getRegistrationZnodePath());
return uniqueId;
}
use of org.apache.hadoop.registry.client.types.ServiceRecord in project hive by apache.
the class ZkRegistryBase method populateCache.
protected final void populateCache(PathChildrenCache instancesCache, boolean doInvokeListeners) {
for (ChildData childData : instancesCache.getCurrentData()) {
byte[] data = getWorkerData(childData, workerNodePrefix);
if (data == null)
continue;
String nodeName = extractNodeName(childData);
if (!nodeName.startsWith(workerNodePrefix))
continue;
int ephSeqVersion = extractSeqNum(nodeName);
try {
ServiceRecord srv = encoder.fromBytes(childData.getPath(), data);
InstanceType instance = createServiceInstance(srv);
addToCache(childData.getPath(), instance.getHost(), instance);
if (doInvokeListeners) {
for (ServiceInstanceStateChangeListener<InstanceType> listener : stateChangeListeners) {
listener.onCreate(instance, ephSeqVersion);
}
}
} catch (IOException e) {
LOG.error("Unable to decode data for zkpath: {}." + " Ignoring from current instances list..", childData.getPath());
}
}
}
Aggregations