Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dCache
dcache-cta
Commits
34971402
Commit
34971402
authored
Dec 02, 2021
by
Tigran Mkrtchyan
☕
Browse files
driver: add basic 'cancel' implementation
parent
6223ebfd
Pipeline
#13867
passed with stages
in 3 minutes and 48 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/dcache/nearline/cta/CtaNearlineStorage.java
View file @
34971402
...
...
@@ -16,11 +16,13 @@ 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
;
...
...
@@ -307,6 +309,16 @@ 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
();
while
(
requestIterator
.
hasNext
())
{
var
r
=
requestIterator
.
next
().
getValue
().
getRequest
();
if
(
r
.
getId
().
equals
(
uuid
))
{
r
.
failed
(
new
CancellationException
(
"Canceled by dCache"
));
// no other matches expected.
break
;
}
}
}
/**
...
...
src/test/java/org/dcache/nearline/cta/CtaNearlineStorageTest.java
View file @
34971402
...
...
@@ -416,6 +416,24 @@ public class CtaNearlineStorageTest {
assertEquals
(
"pending request count not zero"
,
0
,
driver
.
getPendingRequestsCount
());
}
@Test
public
void
testCencelOfPendingRequest
()
{
var
request
=
mockedStageRequest
();
driver
=
new
CtaNearlineStorage
(
"foo"
,
"bar"
);
driver
.
configure
(
drvConfig
);
driver
.
start
();
driver
.
stage
(
Set
.
of
(
request
));
cta
.
waitToReply
();
driver
.
cancel
(
request
.
getId
());
assertEquals
(
"unexpected pending request queue size"
,
0
,
driver
.
getPendingRequestsCount
());
}
void
waitToComplete
()
{
try
{
waitForComplete
.
get
(
1
,
TimeUnit
.
SECONDS
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment