use of com.continuuity.weave.internal.appmaster.ApplicationMasterLiveNodeData in project weave by continuuity.
the class YarnWeaveRunnerService method getApplicationId.
/**
* Decodes application ID stored inside the node data.
* @param nodeData The node data to decode from. If it is {@code null}, this method would return {@code null}.
* @return The ApplicationId or {@code null} if failed to decode.
*/
private ApplicationId getApplicationId(NodeData nodeData) {
byte[] data = nodeData == null ? null : nodeData.getData();
if (data == null) {
return null;
}
Gson gson = new Gson();
JsonElement json = gson.fromJson(new String(data, Charsets.UTF_8), JsonElement.class);
if (!json.isJsonObject()) {
LOG.warn("Unable to decode live data node.");
return null;
}
JsonObject jsonObj = json.getAsJsonObject();
json = jsonObj.get("data");
if (!json.isJsonObject()) {
LOG.warn("Property data not found in live data node.");
return null;
}
try {
ApplicationMasterLiveNodeData amLiveNode = gson.fromJson(json, ApplicationMasterLiveNodeData.class);
return YarnUtils.createApplicationId(amLiveNode.getAppIdClusterTime(), amLiveNode.getAppId());
} catch (Exception e) {
LOG.warn("Failed to decode application live node data.", e);
return null;
}
}
Aggregations