diff --git a/modules/dcache-bulk/src/main/java/org/dcache/services/bulk/store/jdbc/request/JdbcBulkRequestArchiver.java b/modules/dcache-bulk/src/main/java/org/dcache/services/bulk/store/jdbc/request/JdbcBulkRequestArchiver.java index 14744921c1d..58bc3911f4a 100644 --- a/modules/dcache-bulk/src/main/java/org/dcache/services/bulk/store/jdbc/request/JdbcBulkRequestArchiver.java +++ b/modules/dcache-bulk/src/main/java/org/dcache/services/bulk/store/jdbc/request/JdbcBulkRequestArchiver.java @@ -61,6 +61,7 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING import static org.dcache.services.bulk.BulkRequestStatus.CANCELLED; import static org.dcache.services.bulk.BulkRequestStatus.COMPLETED; +import static org.dcache.services.bulk.BulkRequestStatus.INCOMPLETE; import dmg.cells.nucleus.CellInfoProvider; import java.io.PrintWriter; @@ -137,7 +138,7 @@ public void run() { long threshhold = System.currentTimeMillis() - archiverWindowUnit.toMillis(archiverWindow); List expiredUids = requestDao.getUids( - requestDao.where().modifiedBefore(threshhold).status(COMPLETED, CANCELLED), + requestDao.where().modifiedBefore(threshhold).status(INCOMPLETE, COMPLETED, CANCELLED), Integer.MAX_VALUE); /* diff --git a/modules/dcache-bulk/src/main/java/org/dcache/services/bulk/store/jdbc/request/JdbcBulkRequestCriterion.java b/modules/dcache-bulk/src/main/java/org/dcache/services/bulk/store/jdbc/request/JdbcBulkRequestCriterion.java index bb3324d8f6d..6d029efc7a7 100644 --- a/modules/dcache-bulk/src/main/java/org/dcache/services/bulk/store/jdbc/request/JdbcBulkRequestCriterion.java +++ b/modules/dcache-bulk/src/main/java/org/dcache/services/bulk/store/jdbc/request/JdbcBulkRequestCriterion.java @@ -92,6 +92,13 @@ public JdbcBulkRequestCriterion id(Long id) { return this; } + public JdbcBulkRequestCriterion unique(Long id) { + if (id != null) { + addClause("bulk_request.id = ?", id); + } + return this; + } + public JdbcBulkRequestCriterion pnfsId(String pnfsid) { if (pnfsid != null) { addClause("request_target.pnfsid = ?", pnfsid); diff --git a/modules/dcache-bulk/src/main/java/org/dcache/services/bulk/store/jdbc/request/JdbcBulkRequestDao.java b/modules/dcache-bulk/src/main/java/org/dcache/services/bulk/store/jdbc/request/JdbcBulkRequestDao.java index 5224733968f..25b64dec381 100644 --- a/modules/dcache-bulk/src/main/java/org/dcache/services/bulk/store/jdbc/request/JdbcBulkRequestDao.java +++ b/modules/dcache-bulk/src/main/java/org/dcache/services/bulk/store/jdbc/request/JdbcBulkRequestDao.java @@ -300,7 +300,7 @@ public JdbcBulkRequestUpdate updateFrom(BulkRequest request, String user) .clearOnSuccess(request.isClearOnSuccess()).clearOnFailure(request.isClearOnFailure()) .depth(request.getExpandDirectories()) .targetPrefix(request.getTargetPrefix()).urlPrefix(request.getUrlPrefix()).user(user) - .status(BulkRequestStatus.QUEUED).arrivedAt(System.currentTimeMillis()); + .status(BulkRequestStatus.INCOMPLETE).arrivedAt(System.currentTimeMillis()); } public JdbcBulkRequestCriterion where() { diff --git a/modules/dcache-bulk/src/main/java/org/dcache/services/bulk/store/jdbc/request/JdbcBulkRequestStore.java b/modules/dcache-bulk/src/main/java/org/dcache/services/bulk/store/jdbc/request/JdbcBulkRequestStore.java index f36708d5633..064a06361e6 100644 --- a/modules/dcache-bulk/src/main/java/org/dcache/services/bulk/store/jdbc/request/JdbcBulkRequestStore.java +++ b/modules/dcache-bulk/src/main/java/org/dcache/services/bulk/store/jdbc/request/JdbcBulkRequestStore.java @@ -610,6 +610,8 @@ public void store(Subject subject, Restriction restriction, BulkRequest request) try { /* * Insertion order: request, permissions, must be maintained. + * Initial insertion status is INCOMPLETE. This is immediately changed to QUEUED + * after insertion is complete. */ requestDao.insert( requestDao.updateFrom(request, BulkRequestStore.uidGidKey(subject))) @@ -623,6 +625,8 @@ public void store(Subject subject, Restriction restriction, BulkRequest request) requestDao.insertArguments(request); requestTargetDao.insertInitialTargets(request); + + requestDao.update(requestDao.where().unique(request.getId()), requestDao.set().status(QUEUED)); } catch (BulkStorageException e) { throw new BulkStorageException("store failed for " + request.getUid(), e); } diff --git a/modules/dcache-vehicles/src/main/java/org/dcache/services/bulk/BulkRequestStatus.java b/modules/dcache-vehicles/src/main/java/org/dcache/services/bulk/BulkRequestStatus.java index 783aeff2beb..dcd8d6f78c4 100644 --- a/modules/dcache-vehicles/src/main/java/org/dcache/services/bulk/BulkRequestStatus.java +++ b/modules/dcache-vehicles/src/main/java/org/dcache/services/bulk/BulkRequestStatus.java @@ -60,6 +60,7 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING package org.dcache.services.bulk; public enum BulkRequestStatus { + INCOMPLETE("Request has been created but insertion is not yet complete."), QUEUED("Request has been submitted to the service and awaits processing."), STARTED("Request has been set to active and has begun processing."), COMPLETED("All targets of the request have reached terminal state."),