Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dCache
cta
Commits
5fc38552
Commit
5fc38552
authored
Aug 19, 2015
by
Steven Murray
Browse files
Added libcastortapeserverfileunittests.so
parent
adc63355
Changes
20
Hide whitespace changes
Inline
Side-by-side
common/archiveNS/ArchiveFileInfo.cpp
View file @
5fc38552
...
...
@@ -19,11 +19,19 @@
#include
"ArchiveFileInfo.hpp"
namespace
cta
{
ArchiveFileInfo
::
ArchiveFileInfo
()
:
fileId
(
0
),
size
(
0
),
lastModificationTime
(
0
)
{
}
ArchiveFileInfo
::
ArchiveFileInfo
(
const
std
::
string
&
lastKnownPath
,
uint64_t
fileId
,
uint64_t
size
,
const
Checksum
&
checksum
,
const
time_t
lastModificationTime
)
:
lastKnownPath
(
lastKnownPath
),
fileId
(
fileId
),
size
(
size
),
checksum
(
checksum
),
lastModificationTime
(
lastModificationTime
)
{}
}
\ No newline at end of file
checksum
(
checksum
),
lastModificationTime
(
lastModificationTime
)
{}
}
common/archiveNS/ArchiveFileInfo.hpp
View file @
5fc38552
...
...
@@ -27,12 +27,20 @@ namespace cta {
*/
class
ArchiveFileInfo
{
public:
/**
* Constructor.
*/
ArchiveFileInfo
();
/**
* Constructor.
*/
ArchiveFileInfo
(
const
std
::
string
&
lastKnownPath
,
uint64_t
fileId
,
uint64_t
size
,
const
Checksum
&
checksum
,
const
time_t
lastModificationTime
);
const
std
::
string
lastKnownPath
;
/**< The location of the file at NS lookup time */
const
uint64_t
fileId
;
/**< The file ID (to be used in the tape copy header, among other */
const
uint64_t
size
;
/**< The file's size */
const
Checksum
checksum
;
const
time_t
lastModificationTime
;
std
::
string
lastKnownPath
;
/**< The location of the file at NS lookup time */
uint64_t
fileId
;
/**< The file ID (to be used in the tape copy header, among other */
uint64_t
size
;
/**< The file's size */
Checksum
checksum
;
time_t
lastModificationTime
;
};
}
\ No newline at end of file
}
common/archiveNS/TapeCopyInfo.cpp
View file @
5fc38552
...
...
@@ -22,7 +22,7 @@
// constructor
//------------------------------------------------------------------------------
cta
::
TapeCopyInfo
::
TapeCopyInfo
()
:
f
s
eq
(
0
),
f
S
eq
(
0
),
blockId
(
0
)
{
}
...
...
@@ -30,9 +30,9 @@ cta::TapeCopyInfo::TapeCopyInfo():
// constructor
//------------------------------------------------------------------------------
cta
::
TapeCopyInfo
::
TapeCopyInfo
(
const
std
::
string
&
vid
,
const
uint64_t
f
s
eq
,
const
uint64_t
blockId
,
uint16_t
copyNumber
)
:
const
uint64_t
f
S
eq
,
const
uint64_t
blockId
,
uint16_t
copyNumber
)
:
vid
(
vid
),
f
s
eq
(
f
s
eq
),
f
S
eq
(
f
S
eq
),
blockId
(
blockId
),
copyNumber
(
copyNumber
)
{
}
common/archiveNS/TapeCopyInfo.hpp
View file @
5fc38552
...
...
@@ -37,11 +37,11 @@ struct TapeCopyInfo {
* Constructor.
*
* @param vid The volume identifier of the tape.
* @param f
s
eq The sequence number of the file.
* @param f
S
eq The sequence number of the file.
* @param blockId The block identifier of the file.
* @param copyNumber The copy number for this tape copy.
*/
TapeCopyInfo
(
const
std
::
string
&
vid
,
const
uint64_t
f
s
eq
,
TapeCopyInfo
(
const
std
::
string
&
vid
,
const
uint64_t
f
S
eq
,
const
uint64_t
blockId
,
uint16_t
copyNumber
);
/**
...
...
@@ -62,7 +62,7 @@ struct TapeCopyInfo {
/**
* The sequence number of the file.
*/
uint64_t
f
s
eq
;
uint64_t
f
S
eq
;
/**
* The block identifier of the file.
...
...
scheduler/ArchiveJob.cpp
View file @
5fc38552
...
...
@@ -24,6 +24,12 @@
cta
::
ArchiveJob
::~
ArchiveJob
()
throw
()
{
}
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta
::
ArchiveJob
::
ArchiveJob
()
{
}
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
...
...
@@ -31,12 +37,12 @@ cta::ArchiveJob::ArchiveJob(
const
std
::
string
&
tapePoolName
,
const
ArchiveFileInfo
&
archiveFile
,
const
RemotePathAndStatus
&
remoteFile
,
const
TapeCopyLocationAndStatus
&
copyLocation
,
const
TapeCopyLocationAndStatus
&
tapeCopy
,
const
uint16_t
copyNb
)
:
tapePoolName
(
tapePoolName
),
archiveFile
(
archiveFile
),
remoteFile
(
remoteFile
),
copyLocation
(
copyLocation
),
tapeCopy
(
tapeCopy
),
copyNumber
(
copyNb
)
{}
//------------------------------------------------------------------------------
...
...
scheduler/ArchiveJob.hpp
View file @
5fc38552
...
...
@@ -44,10 +44,16 @@ class ArchiveJob {
friend
class
ArchiveMount
;
CTA_GENERATE_EXCEPTION_CLASS
(
NotImplemented
);
pr
ivate
:
pr
otected
:
/**
* Constructor. It is private as the ArchiveJob is generated by the
* Constructor. It is not protected as the ArchiveJob is generated by the
* ArchiveMount.
*/
ArchiveJob
();
/**
* Constructor. It is not protected as the ArchiveJob is generated by the
* ArchiveMount.
*
* @param tapePoolName the name of the tape pool the tape copy should be
...
...
@@ -61,7 +67,7 @@ private:
const
std
::
string
&
tapePoolName
,
const
ArchiveFileInfo
&
archiveFile
,
const
RemotePathAndStatus
&
remoteFile
,
const
TapeCopyLocationAndStatus
&
copyLocation
,
const
TapeCopyLocationAndStatus
&
tapeCopy
,
const
uint16_t
copyNb
);
public:
...
...
@@ -78,13 +84,6 @@ public:
*/
const
std
::
string
&
getTapePoolName
()
const
throw
();
/**
* Returns the size of the file to be archived in bytes.
*
* @return The size of the file to be archived in bytes.
*/
uint64_t
getFileSize
()
const
throw
();
/**
* Returns the The URL of the remote source file.
*
...
...
@@ -92,13 +91,6 @@ public:
*/
std
::
string
getRemoteFile
()
const
throw
();
/**
* Stores the location of the archives tape copy prior to calling complete()
* @param tapeCopyLocation all the information about the tape copy after
* writing
*/
void
setCopyLocationAndStatus
(
const
TapeCopyLocationAndStatus
&
tapeCopyLocation
);
/**
* Indicates that the job was successful and updates the backend store
*
...
...
@@ -130,16 +122,16 @@ public:
virtual
void
retry
();
public:
const
std
::
string
tapePoolName
;
std
::
string
tapePoolName
;
/**< The name of the destination tape pool. */
const
ArchiveFileInfo
archiveFile
;
ArchiveFileInfo
archiveFile
;
/**< All information related to the archive file for which we
* are recording this tape copy. */
const
RemotePathAndStatus
remoteFile
;
RemotePathAndStatus
remoteFile
;
/**< The size of the file to be archived in bytes. */
TapeCopyLocationAndStatus
copyLocation
;
const
uint16_t
copyNumber
;
TapeCopyLocationAndStatus
tapeCopy
;
uint16_t
copyNumber
;
/**< The copy number for this tape copy */
CTA_GENERATE_EXCEPTION_CLASS
(
LocationNotSet
);
/**< Accessor to the tape location status */
...
...
scheduler/RetrieveJob.cpp
View file @
5fc38552
...
...
@@ -24,19 +24,25 @@
cta
::
RetrieveJob
::~
RetrieveJob
()
throw
()
{
}
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta
::
RetrieveJob
::
RetrieveJob
()
{
}
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
cta
::
RetrieveJob
::
RetrieveJob
(
// TO BE DECIDED
//RetrieveMount &mount,
const
TapeCopyInfo
&
tapeCopy
Location
,
const
TapeCopyInfo
&
tapeCopy
,
const
std
::
string
&
id
,
const
std
::
string
&
userRequestId
,
const
uint32_t
copyNb
,
const
std
::
string
&
remoteFile
,
const
uint64_t
castorNsFileId
)
:
tapeCopy
Info
(
tapeCopy
Location
),
m_id
(
id
)
{
tapeCopy
(
tapeCopy
),
m_id
(
id
)
{
}
//------------------------------------------------------------------------------
...
...
scheduler/RetrieveJob.hpp
View file @
5fc38552
...
...
@@ -37,15 +37,21 @@ class RetrieveJob {
*/
friend
class
RetrieveMount
;
private:
protected:
/**
* Constructor. It is not public as the ArchiveJob is generated by the
* RetrieveMount.
*/
RetrieveJob
();
/**
* Constructor. It is
private
as the ArchiveJob is generated by the
* Constructor. It is
not public
as the ArchiveJob is generated by the
* RetrieveMount.
*
// TO BE DECIDED
* @param mount The mount to which the job belongs.
* @param tape
File
The location of the source tape file.
* @param tape
Copy
The location of the source tape file.
* @param id The identifier of the tape job.
* @param userRequestId The identifier of the associated user request.
* @param copyNb The copy number.
...
...
@@ -57,7 +63,7 @@ private:
RetrieveJob
(
// TO BE DECIDED
// RetrieveMount &mount,
const
TapeCopyInfo
&
tape
File
,
const
TapeCopyInfo
&
tape
Copy
,
const
std
::
string
&
id
,
const
std
::
string
&
userRequestId
,
const
uint32_t
copyNb
,
...
...
@@ -112,7 +118,7 @@ public:
/** Translation of positioningMethod */
std
::
string
toString
(
PositioningMethod
);
TapeCopyInfo
tapeCopy
Info
;
/**<The location of the source tape file. */
TapeCopyInfo
tapeCopy
;
/**<The location of the source tape file. */
PositioningMethod
positioningMethod
;
/**< The desired positioning method. */
RemotePath
remoteFilePath
;
/** <The location of the destination file. */
std
::
string
m_id
;
...
...
scheduler/SchedulerDatabaseTest.cpp
View file @
5fc38552
...
...
@@ -477,7 +477,7 @@ TEST_P(SchedulerDatabaseTest, getMountInfo) {
tcl
.
back
().
blockId
=
666
;
tcl
.
back
().
fileId
=
777
;
tcl
.
back
().
archiveFilePath
=
"cta:://cta/myfile"
;
tcl
.
back
().
f
s
eq
=
10
;
tcl
.
back
().
f
S
eq
=
10
;
tcl
.
back
().
nsHostName
=
"NSHost"
;
tcl
.
back
().
vid
=
"Tape2"
;
tcl
.
back
().
copyNumber
=
1
;
...
...
@@ -485,7 +485,7 @@ TEST_P(SchedulerDatabaseTest, getMountInfo) {
tcl
.
back
().
blockId
=
111
;
tcl
.
back
().
fileId
=
777
;
tcl
.
back
().
archiveFilePath
=
"cta:://cta/myfile"
;
tcl
.
back
().
f
s
eq
=
5
;
tcl
.
back
().
f
S
eq
=
5
;
tcl
.
back
().
nsHostName
=
"NSHost"
;
tcl
.
back
().
vid
=
"Tape3"
;
tcl
.
back
().
copyNumber
=
2
;
...
...
@@ -526,7 +526,7 @@ TEST_P(SchedulerDatabaseTest, getMountInfo) {
tcl2
.
back
().
blockId
=
999
;
tcl2
.
back
().
fileId
=
888
;
tcl2
.
back
().
archiveFilePath
=
"cta:://cta/myfile2"
;
tcl2
.
back
().
f
s
eq
=
11
;
tcl2
.
back
().
f
S
eq
=
11
;
tcl2
.
back
().
nsHostName
=
"NSHost"
;
tcl2
.
back
().
vid
=
"Tape3"
;
tcl2
.
back
().
copyNumber
=
1
;
...
...
@@ -534,7 +534,7 @@ TEST_P(SchedulerDatabaseTest, getMountInfo) {
tcl2
.
back
().
blockId
=
333
;
tcl2
.
back
().
fileId
=
888
;
tcl2
.
back
().
archiveFilePath
=
"cta:://cta/myfile2"
;
tcl2
.
back
().
f
s
eq
=
3
;
tcl2
.
back
().
f
S
eq
=
3
;
tcl2
.
back
().
nsHostName
=
"NSHost"
;
tcl2
.
back
().
vid
=
"Tape2"
;
tcl2
.
back
().
copyNumber
=
2
;
...
...
tapeserver/castor/tape/tapeserver/daemon/DiskReadTask.cpp
View file @
5fc38552
...
...
@@ -90,7 +90,7 @@ void DiskReadTask::execute(log::LogContext& lc, diskFile::DiskFileFactory & file
m_stats
.
waitFreeMemoryTime
+=
localTime
.
secs
(
castor
::
utils
::
Timer
::
resetCounter
);
//set metadata and read the data
mb
->
m_fileid
=
m_archiveJob
->
copyLocation
.
fileId
;
mb
->
m_fileid
=
m_archiveJob
->
tapeCopy
.
fileId
;
mb
->
m_fileBlock
=
blockId
++
;
currentErrorToCount
=
"Error_diskRead"
;
...
...
@@ -180,7 +180,7 @@ void DiskReadTask::circulateAllBlocks(size_t fromBlockId, MemBlock * mb){
mb
=
m_nextTask
.
getFreeBlock
();
++
blockId
;
}
mb
->
m_fileid
=
m_archiveJob
->
copyLocation
.
fileId
;
mb
->
m_fileid
=
m_archiveJob
->
tapeCopy
.
fileId
;
mb
->
markAsCancelled
();
m_nextTask
.
pushDataBlock
(
mb
);
mb
=
NULL
;
...
...
@@ -208,7 +208,7 @@ void DiskReadTask::logWithStat(int level,const std::string& msg,log::LogContext&
m_stats
.
transferTime
?
1.0
*
m_stats
.
dataVolume
/
1000
/
1000
/
m_stats
.
transferTime
:
0
)
.
add
(
"openRWCloseToTransferTimeRatio"
,
m_stats
.
transferTime
?
(
m_stats
.
openingTime
+
m_stats
.
readWriteTime
+
m_stats
.
closingTime
)
/
m_stats
.
transferTime
:
0.0
)
.
add
(
"FILEID"
,
m_archiveJob
->
copyLocation
.
fileId
)
.
add
(
"FILEID"
,
m_archiveJob
->
tapeCopy
.
fileId
)
.
add
(
"path"
,
m_archiveJob
->
archiveFile
.
lastKnownPath
);
lc
.
log
(
level
,
msg
);
}
...
...
tapeserver/castor/tape/tapeserver/daemon/DiskWriteTask.cpp
View file @
5fc38552
...
...
@@ -52,10 +52,10 @@ bool DiskWriteTask::execute(RecallReportPacker& reporter,log::LogContext& lc,
castor
::
utils
::
Timer
totalTime
(
localTime
);
castor
::
utils
::
Timer
transferTime
(
localTime
);
log
::
ScopedParamContainer
URLcontext
(
lc
);
URLcontext
.
add
(
"NSFILEID"
,
m_retrieveJob
->
tapeCopy
Info
.
fileId
)
.
add
(
"path"
,
m_retrieveJob
->
tapeCopy
Info
.
archiveFilePath
)
URLcontext
.
add
(
"NSFILEID"
,
m_retrieveJob
->
tapeCopy
.
fileId
)
.
add
(
"path"
,
m_retrieveJob
->
tapeCopy
.
archiveFilePath
)
.
add
(
"fileTransactionId"
,
m_retrieveJob
->
m_id
)
.
add
(
"fSeq"
,
m_retrieveJob
->
tapeCopy
Info
.
f
s
eq
);
.
add
(
"fSeq"
,
m_retrieveJob
->
tapeCopy
.
f
S
eq
);
// This out-of-try-catch variables allows us to record the stage of the
// process we're in, and to count the error if it occurs.
// We will not record errors for an empty string. This will allow us to
...
...
@@ -90,7 +90,7 @@ bool DiskWriteTask::execute(RecallReportPacker& reporter,log::LogContext& lc,
// Synchronise the counter with the open time counter.
currentErrorToCount
=
"Error_diskOpenForWrite"
;
transferTime
=
localTime
;
writeFile
.
reset
(
fileFactory
.
createWriteFile
(
m_retrieveJob
->
tapeCopy
Info
.
archiveFilePath
));
writeFile
.
reset
(
fileFactory
.
createWriteFile
(
m_retrieveJob
->
tapeCopy
.
archiveFilePath
));
URLcontext
.
add
(
"actualURL"
,
writeFile
->
URL
());
lc
.
log
(
LOG_INFO
,
"Opened disk file for writing"
);
m_stats
.
openingTime
+=
localTime
.
secs
(
castor
::
utils
::
Timer
::
resetCounter
);
...
...
@@ -200,7 +200,7 @@ void DiskWriteTask::releaseAllBlock(){
//------------------------------------------------------------------------------
void
DiskWriteTask
::
checkErrors
(
MemBlock
*
mb
,
int
blockId
,
castor
::
log
::
LogContext
&
lc
){
using
namespace
castor
::
log
;
if
(
m_retrieveJob
->
tapeCopy
Info
.
fileId
!=
static_cast
<
unsigned
int
>
(
mb
->
m_fileid
)
if
(
m_retrieveJob
->
tapeCopy
.
fileId
!=
static_cast
<
unsigned
int
>
(
mb
->
m_fileid
)
||
blockId
!=
mb
->
m_fileBlock
||
mb
->
isFailed
()
){
LogContext
::
ScopedParam
sp
[]
=
{
LogContext
::
ScopedParam
(
lc
,
Param
(
"received_NSFILEID"
,
mb
->
m_fileid
)),
...
...
@@ -253,8 +253,8 @@ void DiskWriteTask::logWithStat(int level,const std::string& msg,log::LogContext
m_stats
.
transferTime
?
1.0
*
m_stats
.
dataVolume
/
1000
/
1000
/
m_stats
.
transferTime
:
0
)
.
add
(
"openRWCloseToTransferTimeRatio"
,
m_stats
.
transferTime
?
(
m_stats
.
openingTime
+
m_stats
.
readWriteTime
+
m_stats
.
closingTime
)
/
m_stats
.
transferTime
:
0.0
)
.
add
(
"FILEID"
,
m_retrieveJob
->
tapeCopy
Info
.
fileId
)
.
add
(
"path"
,
m_retrieveJob
->
tapeCopy
Info
.
archiveFilePath
);
.
add
(
"FILEID"
,
m_retrieveJob
->
tapeCopy
.
fileId
)
.
add
(
"path"
,
m_retrieveJob
->
tapeCopy
.
archiveFilePath
);
lc
.
log
(
level
,
msg
);
}
}}}}
...
...
tapeserver/castor/tape/tapeserver/daemon/MigrationTaskInjector.cpp
View file @
5fc38552
...
...
@@ -56,9 +56,9 @@ namespace daemon {
for
(
auto
it
=
jobs
.
begin
();
it
!=
jobs
.
end
();
++
it
){
const
u_signed64
fileSize
=
(
*
it
)
->
archiveFile
.
size
;
LogContext
::
ScopedParam
sp
[]
=
{
LogContext
::
ScopedParam
(
m_lc
,
Param
(
"NSHOSTNAME"
,
(
*
it
)
->
copyLocation
.
nsHostName
)),
LogContext
::
ScopedParam
(
m_lc
,
Param
(
"NSFILEID"
,
(
*
it
)
->
copyLocation
.
fileId
)),
LogContext
::
ScopedParam
(
m_lc
,
Param
(
"fSeq"
,
(
*
it
)
->
copyLocation
.
fSeq
)),
LogContext
::
ScopedParam
(
m_lc
,
Param
(
"NSHOSTNAME"
,
(
*
it
)
->
tapeCopy
.
nsHostName
)),
LogContext
::
ScopedParam
(
m_lc
,
Param
(
"NSFILEID"
,
(
*
it
)
->
tapeCopy
.
fileId
)),
LogContext
::
ScopedParam
(
m_lc
,
Param
(
"fSeq"
,
(
*
it
)
->
tapeCopy
.
fSeq
)),
LogContext
::
ScopedParam
(
m_lc
,
Param
(
"path"
,
(
*
it
)
->
archiveFile
.
lastKnownPath
))
};
tape
::
utils
::
suppresUnusedVariable
(
sp
);
...
...
@@ -129,7 +129,7 @@ namespace daemon {
m_lc
.
log
(
LOG_ERR
,
"No files to migrate: empty mount"
);
return
false
;
}
else
{
m_firstFseqToWrite
=
jobs
.
front
()
->
copyLocation
.
fSeq
;
m_firstFseqToWrite
=
jobs
.
front
()
->
tapeCopy
.
fSeq
;
injectBulkMigrations
(
jobs
);
return
true
;
}
...
...
tapeserver/castor/tape/tapeserver/daemon/RecallTaskInjector.cpp
View file @
5fc38552
...
...
@@ -91,11 +91,11 @@ void RecallTaskInjector::injectBulkRecalls(const std::vector<cta::RetrieveJob *>
(
*
it
)
->
positioningMethod
=
cta
::
RetrieveJob
::
PositioningMethod
::
ByBlock
;
LogContext
::
ScopedParam
sp
[]
=
{
LogContext
::
ScopedParam
(
m_lc
,
Param
(
"NSHOSTNAME"
,
(
*
it
)
->
tapeCopy
Info
.
nsHostName
)),
LogContext
::
ScopedParam
(
m_lc
,
Param
(
"NSFILEID"
,
(
*
it
)
->
tapeCopy
Info
.
fileId
)),
LogContext
::
ScopedParam
(
m_lc
,
Param
(
"fSeq"
,
(
*
it
)
->
tapeCopy
Info
.
f
s
eq
)),
LogContext
::
ScopedParam
(
m_lc
,
Param
(
"blockID"
,
(
*
it
)
->
tapeCopy
Info
.
blockId
)),
LogContext
::
ScopedParam
(
m_lc
,
Param
(
"path"
,
(
*
it
)
->
tapeCopy
Info
.
archiveFilePath
))
LogContext
::
ScopedParam
(
m_lc
,
Param
(
"NSHOSTNAME"
,
(
*
it
)
->
tapeCopy
.
nsHostName
)),
LogContext
::
ScopedParam
(
m_lc
,
Param
(
"NSFILEID"
,
(
*
it
)
->
tapeCopy
.
fileId
)),
LogContext
::
ScopedParam
(
m_lc
,
Param
(
"fSeq"
,
(
*
it
)
->
tapeCopy
.
f
S
eq
)),
LogContext
::
ScopedParam
(
m_lc
,
Param
(
"blockID"
,
(
*
it
)
->
tapeCopy
.
blockId
)),
LogContext
::
ScopedParam
(
m_lc
,
Param
(
"path"
,
(
*
it
)
->
tapeCopy
.
archiveFilePath
))
};
tape
::
utils
::
suppresUnusedVariable
(
sp
);
...
...
tapeserver/castor/tape/tapeserver/daemon/TapeReadTask.hpp
View file @
5fc38552
...
...
@@ -69,12 +69,12 @@ public:
// Set the common context for all the coming logs (file info)
log
::
ScopedParamContainer
params
(
lc
);
params
.
add
(
"NSHOSTNAME"
,
m_retrieveJob
->
tapeCopy
Info
.
nsHostName
)
.
add
(
"NSFILEID"
,
m_retrieveJob
->
tapeCopy
Info
.
fileId
)
.
add
(
"BlockId"
,
m_retrieveJob
->
tapeCopy
Info
.
blockId
)
.
add
(
"fSeq"
,
m_retrieveJob
->
tapeCopy
Info
.
f
s
eq
)
params
.
add
(
"NSHOSTNAME"
,
m_retrieveJob
->
tapeCopy
.
nsHostName
)
.
add
(
"NSFILEID"
,
m_retrieveJob
->
tapeCopy
.
fileId
)
.
add
(
"BlockId"
,
m_retrieveJob
->
tapeCopy
.
blockId
)
.
add
(
"fSeq"
,
m_retrieveJob
->
tapeCopy
.
f
S
eq
)
.
add
(
"fileTransactionId"
,
m_retrieveJob
->
m_id
)
.
add
(
"path"
,
m_retrieveJob
->
tapeCopy
Info
.
archiveFilePath
);
.
add
(
"path"
,
m_retrieveJob
->
tapeCopy
.
archiveFilePath
);
// We will clock the stats for the file itself, and eventually add those
// stats to the session's.
...
...
@@ -110,9 +110,9 @@ public:
mb
=
m_mm
.
getFreeBlock
();
localStats
.
waitFreeMemoryTime
+=
timer
.
secs
(
castor
::
utils
::
Timer
::
resetCounter
);
mb
->
m_fSeq
=
m_retrieveJob
->
tapeCopy
Info
.
f
s
eq
;
mb
->
m_fSeq
=
m_retrieveJob
->
tapeCopy
.
f
S
eq
;
mb
->
m_fileBlock
=
fileBlock
++
;
mb
->
m_fileid
=
m_retrieveJob
->
tapeCopy
Info
.
fileId
;
mb
->
m_fileid
=
m_retrieveJob
->
tapeCopy
.
fileId
;
mb
->
m_tapeFileBlock
=
tapeBlock
;
mb
->
m_tapeBlockSize
=
rf
->
getBlockSize
();
try
{
...
...
@@ -191,8 +191,8 @@ public:
*/
void
reportCancellationToDiskTask
(){
MemBlock
*
mb
=
m_mm
.
getFreeBlock
();
mb
->
m_fSeq
=
m_retrieveJob
->
tapeCopy
Info
.
f
s
eq
;
mb
->
m_fileid
=
m_retrieveJob
->
tapeCopy
Info
.
fileId
;
mb
->
m_fSeq
=
m_retrieveJob
->
tapeCopy
.
f
S
eq
;
mb
->
m_fileid
=
m_retrieveJob
->
tapeCopy
.
fileId
;
//mark the block cancelled and push it (plus signal the end)
mb
->
markAsCancelled
();
m_fifo
.
pushDataBlock
(
mb
);
...
...
@@ -208,8 +208,8 @@ private:
// fill it up
if
(
!
mb
)
{
mb
=
m_mm
.
getFreeBlock
();
mb
->
m_fSeq
=
m_retrieveJob
->
tapeCopy
Info
.
f
s
eq
;
mb
->
m_fileid
=
m_retrieveJob
->
tapeCopy
Info
.
fileId
;
mb
->
m_fSeq
=
m_retrieveJob
->
tapeCopy
.
f
S
eq
;
mb
->
m_fileid
=
m_retrieveJob
->
tapeCopy
.
fileId
;
}
//mark the block failed and push it (plus signal the end)
mb
->
markAsFailed
(
msg
,
code
);
...
...
tapeserver/castor/tape/tapeserver/daemon/TapeWriteTask.cpp
View file @
5fc38552
...
...
@@ -69,11 +69,11 @@ namespace daemon {
using
castor
::
log
::
ScopedParamContainer
;
// Add to our logs the informations on the file
ScopedParamContainer
params
(
lc
);
params
.
add
(
"NSHOSTNAME"
,
m_archiveJob
->
copyLocation
.
nsHostName
)
.
add
(
"NSFILEID"
,
m_archiveJob
->
copyLocation
.
fileId
)
params
.
add
(
"NSHOSTNAME"
,
m_archiveJob
->
tapeCopy
.
nsHostName
)
.
add
(
"NSFILEID"
,
m_archiveJob
->
tapeCopy
.
fileId
)
.
add
(
"lastKnownFilename"
,
m_archiveJob
->
archiveFile
.
lastKnownPath
)
.
add
(
"fileSize"
,
m_archiveJob
->
archiveFile
.
size
)
.
add
(
"fSeq"
,
m_archiveJob
->
copyLocation
.
fSeq
)
.
add
(
"fSeq"
,
m_archiveJob
->
tapeCopy
.
fSeq
)
.
add
(
"path"
,
m_archiveJob
->
remoteFile
.
path
.
getRaw
());
// We will clock the stats for the file itself, and eventually add those
...
...
@@ -90,7 +90,7 @@ namespace daemon {
// We will not record errors for an empty string. This will allow us to
// prevent counting where error happened upstream.
std
::
string
currentErrorToCount
=
"Error_tapeFSeqOutOfSequenceForWrite"
;
session
.
validateNextFSeq
(
m_archiveJob
->
copyLocation
.
fSeq
);
session
.
validateNextFSeq
(
m_archiveJob
->
tapeCopy
.
fSeq
);
try
{
//try to open the session
currentErrorToCount
=
"Error_tapeWriteHeader"
;
...
...
@@ -129,7 +129,7 @@ namespace daemon {
m_taskStats
.
headerVolume
+=
TapeSessionStats
::
trailerVolumePerFile
;
m_taskStats
.
filesCount
++
;
// Record the fSeq in the tape session
session
.
reportWrittenFSeq
(
m_archiveJob
->
copyLocation
.
fSeq
);
session
.
reportWrittenFSeq
(
m_archiveJob
->
tapeCopy
.
fSeq
);
reportPacker
.
reportCompletedJob
(
std
::
move
(
m_archiveJob
),
ckSum
,
output
->
getBlockId
());
m_taskStats
.
waitReportingTime
+=
timer
.
secs
(
castor
::
utils
::
Timer
::
resetCounter
);
m_taskStats
.
totalTime
=
localTime
.
secs
();
...
...
@@ -314,9 +314,9 @@ namespace daemon {
.
add
(
"payloadTransferSpeedMBps"
,
m_taskStats
.
totalTime
?
1.0
*
m_taskStats
.
dataVolume
/
1000
/
1000
/
m_taskStats
.
totalTime
:
0.0
)
.
add
(
"fileSize"
,
m_archiveJob
->
archiveFile
.
size
)
.
add
(
"NSHOST"
,
m_archiveJob
->
copyLocation
.
nsHostName
)
.
add
(
"NSFILEID"
,
m_archiveJob
->
copyLocation
.
fileId
)
.
add
(
"fSeq"
,
m_archiveJob
->
copyLocation
.
fSeq
)
.
add
(
"NSHOST"
,
m_archiveJob
->
tapeCopy
.
nsHostName
)
.
add
(
"NSFILEID"
,
m_archiveJob
->
tapeCopy
.
fileId
)
.
add
(
"fSeq"
,
m_archiveJob
->
tapeCopy
.
fSeq
)
.
add
(
"lastKnownFilename"
,
m_archiveJob
->
archiveFile
.
lastKnownPath
)
.
add
(
"lastModificationTime"
,
m_archiveJob
->
archiveFile
.
lastModificationTime
);
...
...
tapeserver/castor/tape/tapeserver/file/CMakeLists.txt
View file @
5fc38552
...
...
@@ -32,3 +32,9 @@ add_library(File
../exception/XrootCl.cpp
)
target_link_libraries
(
File castorrfio XrdCl cryptopp
)
add_library
(
castortapeserverfileunittests SHARED
StructuresTest.cpp
FileTest.cpp
)
target_link_libraries
(
castortapeserverfileunittests
File
)
tapeserver/castor/tape/tapeserver/file/File.cpp
View file @
5fc38552
...
...
@@ -108,13 +108,13 @@ namespace castor {
const
cta
::
RetrieveJob
&
filetoRecall
,
const
tape
::
tapeserver
::
daemon
::
VolumeInfo
&
volInfo
)
{
const
std
::
string
&
volId
=
volInfo
.
vid
;
if
(
!
checkHeaderNumericalField
(
hdr1
.
getFileId
(),
filetoRecall
.
tapeCopy
Info
.
fileId
,
hexadecimal
))
{
if
(
!
checkHeaderNumericalField
(
hdr1
.
getFileId
(),
filetoRecall
.
tapeCopy
.
fileId
,
hexadecimal
))
{
// the nsfileid stored in HDR1 as an hexadecimal string . The one in
// filetoRecall is numeric
std
::
stringstream
ex_str
;
ex_str
<<
"[HeaderChecker::checkHDR1] - Invalid fileid detected: (0x)
\"
"
<<
hdr1
.
getFileId
()
<<
"
\"
. Wanted: 0x"
<<
std
::
hex
<<
filetoRecall
.
tapeCopy
Info
.
fileId
<<
std
::
endl
;
<<
filetoRecall
.
tapeCopy
.
fileId
<<
std
::
endl
;
throw
TapeFormatError
(
ex_str
.
str
());
}
...
...
@@ -129,19 +129,19 @@ namespace castor {
void
HeaderChecker
::
checkUHL1
(
const
UHL1
&
uhl1
,
const
cta
::
RetrieveJob
&
fileToRecall
)
{
if
(
!
checkHeaderNumericalField
(
uhl1
.
getfSeq
(),
fileToRecall
.
tapeCopy
Info
.
f
s
eq
,
decimal
))
{
if
(
!
checkHeaderNumericalField
(
uhl1
.
getfSeq
(),
fileToRecall
.
tapeCopy
.
f
S
eq
,
decimal
))
{
std
::
stringstream
ex_str
;
ex_str
<<
"[HeaderChecker::checkUHL1] - Invalid fseq detected in uhl1:
\"
"
<<
uhl1
.
getfSeq
()
<<
"
\"
. Wanted: "
<<
fileToRecall
.
tapeCopy
Info
.
f
s
eq
;
<<
uhl1
.
getfSeq
()
<<
"
\"
. Wanted: "
<<
fileToRecall
.
tapeCopy
.
f
S
eq
;
throw
TapeFormatError
(
ex_str
.
str
());
}
}
void
HeaderChecker
::
checkUTL1
(
const
UTL1
&
utl1
,
const
uint32_t
f
s
eq
)
{
if
(
!
checkHeaderNumericalField
(
utl1
.
getfSeq
(),
(
uint64_t
)
f
s
eq
,
decimal
))
{
void
HeaderChecker
::
checkUTL1
(
const
UTL1
&
utl1
,
const
uint32_t
f
S
eq
)
{
if
(
!
checkHeaderNumericalField
(
utl1
.
getfSeq
(),
(
uint64_t
)
f
S
eq
,
decimal
))
{
std
::
stringstream
ex_str
;
ex_str
<<
"[HeaderChecker::checkUTL1] - Invalid fseq detected in utl1:
\"
"
<<
utl1
.
getfSeq
()
<<
"
\"
. Wanted: "
<<
f
s
eq
;
<<
utl1
.
getfSeq
()
<<
"
\"
. Wanted: "
<<
f
S
eq
;
throw
TapeFormatError
(
ex_str
.
str
());
}
}
...
...
@@ -174,15 +174,15 @@ namespace castor {
m_session
->
release
();
}
void
ReadFile
::
positionByFseq
(
const
cta
::
RetrieveJob
&
fileToRecall
)
{
if
(
fileToRecall
.
tapeCopy
Info
.
f
s
eq
<
1
)
{
if
(
fileToRecall
.
tapeCopy
.
f
S
eq
<
1
)
{
std
::
stringstream
err
;
err
<<
"Unexpected fileId in ReadFile::position with fSeq expected >=1, got: "
<<
fileToRecall
.
tapeCopy
Info
.
f
s
eq
<<
")"
;
<<
fileToRecall
.
tapeCopy
.
f
S
eq
<<
")"
;
throw
castor
::
exception
::
InvalidArgument
(
err
.
str
());
}
int64_t
f
s
eq_delta
=
fileToRecall
.
tapeCopy
Info
.
f
s
eq
-
m_session
->
getCurrentFseq
();
if
(
fileToRecall
.
tapeCopy
Info
.
f
s
eq
==
1
)
{
int64_t
f
S
eq_delta
=
fileToRecall
.
tapeCopy
.
f
S
eq
-
m_session
->
getCurrentFseq
();
if
(
fileToRecall
.
tapeCopy
.
f
S
eq
==
1
)
{
// special case: we can rewind the tape to be faster
//(TODO: in the future we could also think of a threshold above
//which we rewind the tape anyway and then space forward)
...
...
@@ -195,31 +195,31 @@ namespace castor {
throw
TapeFormatError
(
e
.
what
());
}
}
else
if
(
f
s
eq_delta
==
0
)
{