Package org.cdlib.mrt.zk
Class Batch
- java.lang.Object
-
- org.cdlib.mrt.zk.QueueItem
-
- org.cdlib.mrt.zk.Batch
-
public class Batch extends QueueItem
Class to manage a Merritt Ingest Batch in the Batch Queue.- See Also:
- State Transition Design
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.cdlib.mrt.zk.QueueItem
QueueItem.BatchJobStates, QueueItem.ZkPaths, QueueItem.ZkPrefixes
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Batch
acquireBatchForReporting(org.apache.zookeeper.ZooKeeper client)
static Batch
acquirePendingBatch(org.apache.zookeeper.ZooKeeper client)
String
batchUuid()
static String
batchUuidPath(String uuid)
static Batch
createBatch(org.apache.zookeeper.ZooKeeper client, org.json.JSONObject submission)
void
delete(org.apache.zookeeper.ZooKeeper client)
static List<String>
deleteCompletedBatches(org.apache.zookeeper.ZooKeeper client)
String
dir()
static Batch
findByUuid(org.apache.zookeeper.ZooKeeper client, String uuid)
List<Job>
getCompletedJobs(org.apache.zookeeper.ZooKeeper client)
List<Job>
getDeletedJobs(org.apache.zookeeper.ZooKeeper client)
List<Job>
getFailedJobs(org.apache.zookeeper.ZooKeeper client)
List<Job>
getJobs(org.apache.zookeeper.ZooKeeper client, QueueItem.BatchJobStates state)
List<Job>
getProcessingJobs(org.apache.zookeeper.ZooKeeper client)
boolean
hasFailure()
Indicate that a batch contains a failed job in the Job Queue.static IngestState
initStatus()
void
loadHasFailure(org.apache.zookeeper.ZooKeeper client)
void
loadProperties(org.apache.zookeeper.ZooKeeper client)
static void
main(String[] argv)
String
prefix()
static String
prefixPath()
IngestState
resolveStatus(String s)
IngestState[]
states()
-
Methods inherited from class org.cdlib.mrt.zk.QueueItem
createData, createOrSetData, data, id, intProperty, jsonDataProperty, jsonIntProperty, jsonLongProperty, jsonProperty, jsonStringProperty, load, loadStatus, lock, longProperty, makePath, optJsonProperty, optStringProperty, path, setData, setStatus, setStatus, setStatusTrigger, status, statusObject, stringProperty, unlock
-
-
-
-
Constructor Detail
-
Batch
public Batch(String id)
- Parameters:
id
- Unique id assigned to a batch. This id is generated by creating a sequential batch folder.
-
Batch
public Batch(String id, org.json.JSONObject data)
- Parameters:
id
- Unique id assigned to a batch. This id is generated by creating a sequential batch folder.data
- JSON representation of an ingest initiated by a Merritt depostor.
-
-
Method Detail
-
hasFailure
public boolean hasFailure()
Indicate that a batch contains a failed job in the Job Queue.- Returns:
- true if a failed job exists for the batch
-
prefixPath
public static String prefixPath()
-
initStatus
public static IngestState initStatus()
-
loadHasFailure
public void loadHasFailure(org.apache.zookeeper.ZooKeeper client) throws org.apache.zookeeper.KeeperException, InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
resolveStatus
public IngestState resolveStatus(String s)
- Specified by:
resolveStatus
in classQueueItem
-
batchUuid
public String batchUuid()
-
loadProperties
public void loadProperties(org.apache.zookeeper.ZooKeeper client) throws org.apache.zookeeper.KeeperException, InterruptedException, MerrittZKNodeInvalid
- Overrides:
loadProperties
in classQueueItem
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
MerrittZKNodeInvalid
-
states
public IngestState[] states()
-
createBatch
public static Batch createBatch(org.apache.zookeeper.ZooKeeper client, org.json.JSONObject submission) throws org.apache.zookeeper.KeeperException, InterruptedException, MerrittZKNodeInvalid, MerrittStateError
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
MerrittZKNodeInvalid
MerrittStateError
-
delete
public void delete(org.apache.zookeeper.ZooKeeper client) throws MerrittStateError, MerrittZKNodeInvalid, org.apache.zookeeper.KeeperException, InterruptedException
- Specified by:
delete
in classQueueItem
- Throws:
MerrittStateError
MerrittZKNodeInvalid
org.apache.zookeeper.KeeperException
InterruptedException
-
acquirePendingBatch
public static Batch acquirePendingBatch(org.apache.zookeeper.ZooKeeper client) throws MerrittZKNodeInvalid, org.apache.zookeeper.KeeperException, InterruptedException, MerrittStateError
- Throws:
MerrittZKNodeInvalid
org.apache.zookeeper.KeeperException
InterruptedException
MerrittStateError
-
acquireBatchForReporting
public static Batch acquireBatchForReporting(org.apache.zookeeper.ZooKeeper client) throws MerrittZKNodeInvalid, org.apache.zookeeper.KeeperException, InterruptedException, MerrittStateError
- Throws:
MerrittZKNodeInvalid
org.apache.zookeeper.KeeperException
InterruptedException
MerrittStateError
-
deleteCompletedBatches
public static List<String> deleteCompletedBatches(org.apache.zookeeper.ZooKeeper client) throws MerrittZKNodeInvalid, org.apache.zookeeper.KeeperException, InterruptedException, MerrittStateError
- Throws:
MerrittZKNodeInvalid
org.apache.zookeeper.KeeperException
InterruptedException
MerrittStateError
-
getProcessingJobs
public List<Job> getProcessingJobs(org.apache.zookeeper.ZooKeeper client) throws org.apache.zookeeper.KeeperException, InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
getCompletedJobs
public List<Job> getCompletedJobs(org.apache.zookeeper.ZooKeeper client) throws org.apache.zookeeper.KeeperException, InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
getFailedJobs
public List<Job> getFailedJobs(org.apache.zookeeper.ZooKeeper client) throws org.apache.zookeeper.KeeperException, InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
getDeletedJobs
public List<Job> getDeletedJobs(org.apache.zookeeper.ZooKeeper client) throws org.apache.zookeeper.KeeperException, InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
getJobs
public List<Job> getJobs(org.apache.zookeeper.ZooKeeper client, QueueItem.BatchJobStates state) throws org.apache.zookeeper.KeeperException, InterruptedException
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
findByUuid
public static Batch findByUuid(org.apache.zookeeper.ZooKeeper client, String uuid) throws org.apache.zookeeper.KeeperException, InterruptedException, MerrittZKNodeInvalid
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
MerrittZKNodeInvalid
-
main
public static void main(String[] argv)
-
-