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
1167e2a0
Commit
1167e2a0
authored
Nov 30, 2021
by
Tigran Mkrtchyan
☕
Browse files
xroot: log IO rates
parent
d39e0402
Pipeline
#13642
passed with stages
in 3 minutes and 31 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/dcache/nearline/cta/xrootd/DataServerHandler.java
View file @
1167e2a0
...
@@ -41,12 +41,15 @@ import java.nio.ByteBuffer;
...
@@ -41,12 +41,15 @@ import java.nio.ByteBuffer;
import
java.nio.channels.ClosedChannelException
;
import
java.nio.channels.ClosedChannelException
;
import
java.nio.channels.FileChannel
;
import
java.nio.channels.FileChannel
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.charset.StandardCharsets
;
import
java.time.Duration
;
import
java.time.Instant
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Base64
;
import
java.util.Base64
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.concurrent.ConcurrentMap
;
import
java.util.concurrent.ConcurrentMap
;
import
java.util.concurrent.ForkJoinPool
;
import
java.util.concurrent.ForkJoinPool
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.locks.ReadWriteLock
;
import
java.util.concurrent.locks.ReadWriteLock
;
import
java.util.concurrent.locks.ReentrantReadWriteLock
;
import
java.util.concurrent.locks.ReentrantReadWriteLock
;
import
org.dcache.pool.nearline.spi.FlushRequest
;
import
org.dcache.pool.nearline.spi.FlushRequest
;
...
@@ -54,6 +57,8 @@ import org.dcache.pool.nearline.spi.NearlineRequest;
...
@@ -54,6 +57,8 @@ import org.dcache.pool.nearline.spi.NearlineRequest;
import
org.dcache.pool.nearline.spi.StageRequest
;
import
org.dcache.pool.nearline.spi.StageRequest
;
import
org.dcache.util.Checksum
;
import
org.dcache.util.Checksum
;
import
org.dcache.util.ChecksumType
;
import
org.dcache.util.ChecksumType
;
import
org.dcache.util.Strings
;
import
org.dcache.util.TimeUtils
;
import
org.dcache.xrootd.core.XrootdException
;
import
org.dcache.xrootd.core.XrootdException
;
import
org.dcache.xrootd.core.XrootdRequestHandler
;
import
org.dcache.xrootd.core.XrootdRequestHandler
;
import
org.dcache.xrootd.protocol.messages.CloseRequest
;
import
org.dcache.xrootd.protocol.messages.CloseRequest
;
...
@@ -85,9 +90,21 @@ public class DataServerHandler extends XrootdRequestHandler {
...
@@ -85,9 +90,21 @@ public class DataServerHandler extends XrootdRequestHandler {
*/
*/
private
static
class
MigrationRequest
{
private
static
class
MigrationRequest
{
/**
* The nearline request associated with this migration.
*/
private
final
NearlineRequest
request
;
private
final
NearlineRequest
request
;
/**
* File to migrate.
*/
private
final
RandomAccessFile
raf
;
private
final
RandomAccessFile
raf
;
/**
* Migration request creation time.
*/
private
final
Instant
btime
=
Instant
.
now
();
public
MigrationRequest
(
NearlineRequest
request
,
RandomAccessFile
raf
)
{
public
MigrationRequest
(
NearlineRequest
request
,
RandomAccessFile
raf
)
{
this
.
request
=
request
;
this
.
request
=
request
;
this
.
raf
=
raf
;
this
.
raf
=
raf
;
...
@@ -100,6 +117,10 @@ public class DataServerHandler extends XrootdRequestHandler {
...
@@ -100,6 +117,10 @@ public class DataServerHandler extends XrootdRequestHandler {
public
NearlineRequest
request
()
{
public
NearlineRequest
request
()
{
return
request
;
return
request
;
}
}
public
Instant
getCreationTime
()
{
return
btime
;
}
}
}
/**
/**
...
@@ -299,9 +320,20 @@ public class DataServerHandler extends XrootdRequestHandler {
...
@@ -299,9 +320,20 @@ public class DataServerHandler extends XrootdRequestHandler {
protected
OkResponse
<
CloseRequest
>
doOnClose
(
ChannelHandlerContext
ctx
,
CloseRequest
msg
)
protected
OkResponse
<
CloseRequest
>
doOnClose
(
ChannelHandlerContext
ctx
,
CloseRequest
msg
)
throws
XrootdException
{
throws
XrootdException
{
try
{
try
{
var
r
=
closeOpenFile
(
msg
.
getFileHandle
());
var
migrationRequest
=
getAndRemoveOpenFile
(
msg
.
getFileHandle
());
migrationRequest
.
raf
().
close
();
var
r
=
migrationRequest
.
request
();
var
file
=
getFile
(
r
);
var
file
=
getFile
(
r
);
LOGGER
.
info
(
"Closing file {}."
,
file
);
long
size
=
file
.
length
();
long
duration
=
Duration
.
between
(
migrationRequest
.
getCreationTime
(),
Instant
.
now
()).
toMillis
();
double
bandwidth
=
(
double
)
size
/
duration
;
LOGGER
.
info
(
"Closing file {}. Transferred {} in {}, {}"
,
file
,
Strings
.
humanReadableSize
(
size
),
TimeUtils
.
describeDuration
(
duration
,
TimeUnit
.
MILLISECONDS
),
Strings
.
describeBandwidth
(
bandwidth
*
1000
)
);
if
(
r
instanceof
StageRequest
)
{
if
(
r
instanceof
StageRequest
)
{
ForkJoinPool
.
commonPool
().
execute
(()
->
{
ForkJoinPool
.
commonPool
().
execute
(()
->
{
try
{
try
{
...
@@ -430,15 +462,6 @@ public class DataServerHandler extends XrootdRequestHandler {
...
@@ -430,15 +462,6 @@ public class DataServerHandler extends XrootdRequestHandler {
throw
new
XrootdException
(
kXR_FileNotOpen
,
"Invalid file descriptor"
);
throw
new
XrootdException
(
kXR_FileNotOpen
,
"Invalid file descriptor"
);
}
}
private
NearlineRequest
closeOpenFile
(
int
fd
)
throws
XrootdException
,
IOException
{
var
migrationRequest
=
getAndRemoveOpenFile
(
fd
);
migrationRequest
.
raf
().
close
();
return
migrationRequest
.
request
();
}
private
NearlineRequest
getIORequest
(
String
path
)
private
NearlineRequest
getIORequest
(
String
path
)
throws
XrootdException
{
throws
XrootdException
{
...
...
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