Skip to content

Commit

Permalink
Null check for ids and retry logic for queue deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
mreyescdl committed Aug 23, 2024
1 parent 62150cb commit 9cbb09d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/main/java/org/cdlib/mrt/zk/Job.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ public String ercWhere() {

public static JSONObject createJobIdentifiers(String primary, String local) {
JSONObject json = new JSONObject();
if (primary == null ) primary = "";
json.put(MerrittJsonKey.PrimaryId.key(), primary);
JSONArray arr = new JSONArray();
if (local == null ) local = "";
for(String s: local.split(";")) {
if (!s.isEmpty()) {
arr.put(s);
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/org/cdlib/mrt/zk/QueueItemHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,17 @@ public static void deleteAll(ZooKeeper client, String p) throws InterruptedExcep
for(String cp: client.getChildren(p, false)) {
deleteAll(client, String.format("%s/%s", p, cp));
}
client.delete(p, -1);

// retry delete, if necessary
for (int i=0; i<3; i++) {
try {
client.delete(p, -1);
break;
} catch (Exception e) {
System.err.println("Error cleaning ZK node: " + p);
Thread.sleep(2000);
}
}
}
}

Expand Down

0 comments on commit 9cbb09d

Please sign in to comment.