diff --git a/src/main/java/org/cdlib/mrt/zk/JobState.java b/src/main/java/org/cdlib/mrt/zk/JobState.java index d762278..4ddd143 100644 --- a/src/main/java/org/cdlib/mrt/zk/JobState.java +++ b/src/main/java/org/cdlib/mrt/zk/JobState.java @@ -14,7 +14,10 @@ public enum JobState implements IngestState { */ Pending { public List nextStates() { - return Arrays.asList(JobState.Held, JobState.Estimating); + return Arrays.asList(JobState.Held, JobState.Estimating, JobState.Failed); + } + public JobState fail() { + return JobState.Failed; } }, /** @@ -123,7 +126,7 @@ public JobState fail() { Failed { public List nextStates() { return Arrays.asList( - JobState.Estimating, JobState.Provisioning, JobState.Deleted, JobState.Downloading, JobState.Processing, JobState.Recording, JobState.Notify + JobState.Pending, JobState.Estimating, JobState.Provisioning, JobState.Deleted, JobState.Downloading, JobState.Processing, JobState.Recording, JobState.Notify ); } }, diff --git a/src/main/java/org/cdlib/mrt/zk/MerrittLocks.java b/src/main/java/org/cdlib/mrt/zk/MerrittLocks.java index 9fc6136..f9fdd58 100644 --- a/src/main/java/org/cdlib/mrt/zk/MerrittLocks.java +++ b/src/main/java/org/cdlib/mrt/zk/MerrittLocks.java @@ -15,6 +15,7 @@ public class MerrittLocks { public static void initLocks(ZooKeeper client) throws KeeperException, InterruptedException { QueueItemHelper.createIfNeeded(client, QueueItem.ZkPaths.Locks.path); QueueItemHelper.createIfNeeded(client, QueueItem.ZkPaths.LocksQueue.path); + QueueItemHelper.createIfNeeded(client, QueueItem.ZkPaths.LocksLocalID.path); QueueItemHelper.createIfNeeded(client, QueueItem.ZkPaths.LocksStorage.path); QueueItemHelper.createIfNeeded(client, QueueItem.ZkPaths.LocksInventory.path); QueueItemHelper.createIfNeeded(client, QueueItem.ZkPaths.LocksCollections.path); @@ -79,6 +80,16 @@ public static boolean checkLockCollection(ZooKeeper client, String mnemonic) thr return QueueItemHelper.exists(client, Paths.get(QueueItem.ZkPaths.LocksCollections.path, mnemonic).toString()); } + public static boolean lockObjectLocalID(ZooKeeper client, String lid) { + return createEphemeralLock(client, Paths.get(QueueItem.ZkPaths.LocksLocalID.path, lid.replaceAll(":?/", "_")).toString()); + } + public static void unlockObjectLocalID(ZooKeeper client, String lid) throws InterruptedException, KeeperException { + QueueItemHelper.delete(client, Paths.get(QueueItem.ZkPaths.LocksLocalID.path, lid.replaceAll(":?/", "_")).toString()); + } + public static boolean checkLockObjectLocalID(ZooKeeper client, String lid) throws KeeperException, InterruptedException { + return QueueItemHelper.exists(client, Paths.get(QueueItem.ZkPaths.LocksLocalID.path, lid.replaceAll(":?/", "_")).toString()); + } + public static boolean lockObjectStorage(ZooKeeper client, String ark) { return createEphemeralLock(client, Paths.get(QueueItem.ZkPaths.LocksStorage.path, ark.replaceAll(":?/", "_")).toString()); } diff --git a/src/main/java/org/cdlib/mrt/zk/QueueItem.java b/src/main/java/org/cdlib/mrt/zk/QueueItem.java index c3a1fe5..50ff62b 100644 --- a/src/main/java/org/cdlib/mrt/zk/QueueItem.java +++ b/src/main/java/org/cdlib/mrt/zk/QueueItem.java @@ -26,6 +26,7 @@ public static enum ZkPaths { LocksQueueIngest("/locks/queue/ingest"), LocksQueueAccessSmall("/locks/queue/accessSmall"), LocksQueueAccessLarge("/locks/queue/accessLarge"), + LocksLocalID("/locks/localid"), LocksStorage("/locks/storage"), LocksInventory("/locks/inventory"), LocksCollections("/locks/collections"); diff --git a/src/test/java/org/cdlib/mrt/zk/StateTest.java b/src/test/java/org/cdlib/mrt/zk/StateTest.java index cb5fcee..476c217 100644 --- a/src/test/java/org/cdlib/mrt/zk/StateTest.java +++ b/src/test/java/org/cdlib/mrt/zk/StateTest.java @@ -285,4 +285,4 @@ public void JobRecoveryPath() { assertTrue(state.isDeletable()); } -} \ No newline at end of file +} diff --git a/src/test/java/org/cdlib/mrt/zk/ZKTestIT.java b/src/test/java/org/cdlib/mrt/zk/ZKTestIT.java index 3bcc862..368313c 100644 --- a/src/test/java/org/cdlib/mrt/zk/ZKTestIT.java +++ b/src/test/java/org/cdlib/mrt/zk/ZKTestIT.java @@ -240,6 +240,7 @@ public boolean skipListing(String path, Object dp) throws KeeperException, Inter } if (path.equals(QueueItem.ZkPaths.LocksInventory.path) || path.equals(QueueItem.ZkPaths.LocksCollections.path) || + path.equals(QueueItem.ZkPaths.LocksLocalID.path) || path.equals(QueueItem.ZkPaths.LocksStorage.path) || path.equals(QueueItem.ZkPaths.LocksQueue.path)) { return true; @@ -1431,4 +1432,4 @@ public void findByUuid() throws KeeperException, InterruptedException, MerrittZK assertNull(bbb); } -} \ No newline at end of file +} diff --git a/states.yml b/states.yml index 4d0ea2d..6580692 100644 --- a/states.yml +++ b/states.yml @@ -2,6 +2,7 @@ job_states: Pending: Held: Estimating: + Failed: {fail: true} Held: Pending: Deleted: @@ -26,6 +27,7 @@ job_states: Completed: Deleted: Failed: + Pending: Estimating: Provisioning: Downloading: