Commit 29821e6b authored by Tigran Mkrtchyan's avatar Tigran Mkrtchyan
Browse files

driver: move request cancellation into PendingRequest#cancel

parent 21e5d7f9
Pipeline #14981 passed with stages
in 3 minutes and 39 seconds
......@@ -16,13 +16,11 @@ import java.net.InetSocketAddress;
import java.net.URI;
import java.net.UnknownHostException;
import java.time.Instant;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutionException;
......@@ -309,12 +307,11 @@ public class CtaNearlineStorage implements NearlineStorage {
*/
@Override
public void cancel(UUID uuid) {
// FIXME: we need to cancel the requests in CTA.
var requestIterator = pendingRequests.entrySet().iterator();
var requestIterator = pendingRequests.entrySet().iterator();
while (requestIterator.hasNext()) {
var r = requestIterator.next().getValue().getRequest();
if (r.getId().equals(uuid)) {
r.failed(new CancellationException("Canceled by dCache"));
var pendingRequest = requestIterator.next().getValue();
if (pendingRequest.getRequestId().equals(uuid)) {
pendingRequest.cancel();
// no other matches expected.
break;
}
......
package org.dcache.nearline.cta;
import java.time.Instant;
import java.util.UUID;
import java.util.concurrent.CancellationException;
import org.dcache.pool.nearline.spi.NearlineRequest;
/**
......@@ -9,7 +11,7 @@ import org.dcache.pool.nearline.spi.NearlineRequest;
public class PendingRequest {
/**
* Point on the time-line when request was submitted into pending queue.
* Point on the time-line when request was submitted into pending queue.
*/
private final Instant submissionTime;
......@@ -23,11 +25,35 @@ public class PendingRequest {
this.request = request;
}
/**
* Returns request submission timestamp.
*
* @return request submission timestamp.
*/
public Instant getSubmissionTime() {
return submissionTime;
}
/**
* Returns underlying {@link NearlineRequest} requests.
*
* @return requests the nearline request.
*/
public NearlineRequest getRequest() {
return request;
}
/**
* Returns requests {@link UUID} assigned by dCache's flush queue.
*
* @return requests uuid.
*/
public UUID getRequestId() {
return request.getId();
}
public void cancel() {
// FIXME: we need to cancel the requests in CTA.
request.failed(new CancellationException("Canceled by dCache"));
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment