public void delete(String yarnAppId, String jobId) {
String path = this.zkRoot + "/" + yarnAppId + "/" + jobId;
try {
lock.acquire();
if (curator.checkExists().forPath(path) != null) {
curator.delete().deletingChildrenIfNeeded().forPath(path);
LOG.info("delete job {} for yarn app {}, path {} ", jobId, yarnAppId, path);
String yarnPath = this.zkRoot + "/" + yarnAppId;
if (curator.getChildren().forPath(yarnPath).size() == 0) {
delete(yarnAppId);
}
}
} catch (Exception e) {
LOG.error("failed to delete job {} for yarn app {}, path {}, {}", jobId, yarnAppId, path, e);
} finally {
try {
lock.release();
} catch (Exception e) {
LOG.error("fail releasing lock", e);
}
}
}