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
891da7af
Commit
891da7af
authored
Jul 15, 2014
by
David COME
Browse files
Error checking from writing tasks is now handled in a separated function, called from the loop
parent
8c738a6b
Changes
5
Hide whitespace changes
Inline
Side-by-side
castor/tape/tapeserver/daemon/DiskWriteTask.cpp
View file @
891da7af
...
...
@@ -23,7 +23,8 @@
#include
"castor/tape/tapeserver/daemon/DiskWriteTask.hpp"
#include
"castor/tape/tapeserver/daemon/AutoReleaseBlock.hpp"
#include
"castor/tape/tapeserver/daemon/MemBlock.hpp"
#include
"castor/log/LogContext.hpp"
namespace
castor
{
namespace
tape
{
namespace
tapeserver
{
...
...
@@ -56,34 +57,15 @@ bool DiskWriteTask::execute(RecallReportPacker& reporter,log::LogContext& lc) {
lc
.
log
(
LOG_DEBUG
,
"File transfer canceled"
);
return
true
;
}
//----------------------------deal with errors--------------------------
if
(
m_recallingFile
->
fileid
()
!=
static_cast
<
unsigned
int
>
(
mb
->
m_fileid
)
||
blockId
!=
mb
->
m_fileBlock
||
mb
->
isFailed
()
){
LogContext
::
ScopedParam
sp
[]
=
{
LogContext
::
ScopedParam
(
lc
,
Param
(
"expected_NSFILEID"
,
m_recallingFile
->
fileid
())),
LogContext
::
ScopedParam
(
lc
,
Param
(
"received_NSFILEID"
,
mb
->
m_fileid
)),
LogContext
::
ScopedParam
(
lc
,
Param
(
"expected_NSFBLOCKId"
,
blockId
)),
LogContext
::
ScopedParam
(
lc
,
Param
(
"received_NSFBLOCKId"
,
mb
->
m_fileBlock
)),
LogContext
::
ScopedParam
(
lc
,
Param
(
"failed_Status"
,
mb
->
isFailed
()))
};
tape
::
utils
::
suppresUnusedVariable
(
sp
);
std
::
string
errorMsg
;
if
(
mb
->
isFailed
()){
errorMsg
=
mb
->
errorMsg
();
}
else
{
errorMsg
=
"Mistmatch between expected and received filed or blockid"
;
}
lc
.
log
(
LOG_ERR
,
errorMsg
);
throw
castor
::
tape
::
Exception
(
errorMsg
);
}
checkErrors
(
mb
,
blockId
,
lc
);
//----------------------------end deal with errors-----------------------
mb
->
m_payload
.
write
(
ourFile
);
checksum
=
mb
->
m_payload
.
adler32
(
checksum
);
blockId
++
;
}
else
}
//end if block non NULL
else
{
break
;
}
}
//end of while(1)
lc
.
log
(
LOG_DEBUG
,
"File successfully transfered."
);
reporter
.
reportCompletedJob
(
*
m_recallingFile
,
checksum
);
...
...
@@ -141,5 +123,34 @@ void DiskWriteTask::releaseAllBlock(){
}
}
//------------------------------------------------------------------------------
// checkErrors
//------------------------------------------------------------------------------
void
DiskWriteTask
::
checkErrors
(
MemBlock
*
mb
,
int
blockId
,
castor
::
log
::
LogContext
&
lc
){
using
namespace
castor
::
log
;
if
(
m_recallingFile
->
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
)),
LogContext
::
ScopedParam
(
lc
,
Param
(
"expected_NSFBLOCKId"
,
blockId
)),
LogContext
::
ScopedParam
(
lc
,
Param
(
"received_NSFBLOCKId"
,
mb
->
m_fileBlock
)),
LogContext
::
ScopedParam
(
lc
,
Param
(
"failed_Status"
,
mb
->
isFailed
()))
};
tape
::
utils
::
suppresUnusedVariable
(
sp
);
std
::
string
errorMsg
;
int
errCode
;
if
(
mb
->
isFailed
()){
errorMsg
=
mb
->
errorMsg
();
errCode
=
mb
->
errorCode
();
}
else
{
errorMsg
=
"Mistmatch between expected and received filed or blockid"
;
errCode
=
SEINTERNAL
;
}
lc
.
log
(
LOG_ERR
,
errorMsg
);
throw
castor
::
exception
::
Exception
(
errCode
,
errorMsg
);
}
}
}}}}
castor/tape/tapeserver/daemon/DiskWriteTask.hpp
View file @
891da7af
...
...
@@ -44,7 +44,7 @@ namespace castor {
namespace
tape
{
namespace
tapeserver
{
namespace
daemon
{
class
MemBlock
;
/**
* The DiskWriteFileTask is responsible to write a single file onto disk as part of a recall
* session. Being a consumer of memory blocks, it inherits from the DataConsumer class. It also
...
...
@@ -82,8 +82,17 @@ public:
virtual
~
DiskWriteTask
();
private:
/**
* This function will check the consistency of the mem block and
* throw exception is something goes wrong
* @param mb The mem block to check
* @param blockId The block id the mem blopck should be at
* @param lc FOr logging
*/
void
checkErrors
(
MemBlock
*
mb
,
int
blockId
,
castor
::
log
::
LogContext
&
lc
);
void
releaseAllBlock
();
/**
* The fifo containing the memory blocks holding data to be written to disk
*/
...
...
castor/tape/tapeserver/daemon/MemBlock.hpp
View file @
891da7af
...
...
@@ -88,7 +88,14 @@ public:
throw
castor
::
exception
::
Exception
(
"Error Context is not set ="
" no error message to give"
);
}
int
errorCode
()
const
{
if
(
m_context
.
get
())
{
return
m_context
->
m_errorCode
;
}
throw
castor
::
exception
::
Exception
(
"Error Context is not set ="
" no error code to give"
);
}
bool
isFailed
()
const
{
return
m_context
.
get
()
&&
m_context
->
m_failed
;
}
...
...
castor/tape/tapeserver/daemon/TapeWriteTask.cpp
View file @
891da7af
...
...
@@ -32,6 +32,7 @@
#include
"castor/tape/tapeserver/exception/Exception.hpp"
#include
"castor/tape/tapeserver/daemon/MigrationReportPacker.hpp"
#include
"castor/tape/tapeserver/daemon/SessionStats.hpp"
#include
"castor/tape/tapeserver/daemon/MemBlock.hpp"
namespace
castor
{
namespace
tape
{
...
...
@@ -90,32 +91,16 @@ namespace daemon {
MemBlock
*
const
mb
=
m_fifo
.
popDataBlock
();
localStats
.
waitDataTime
+=
timer
.
secs
(
utils
::
Timer
::
resetCounter
);
AutoReleaseBlock
<
MigrationMemoryManager
>
releaser
(
mb
,
m_memManager
);
//----------------------------deal with errors--------------------------
if
(
m_fileToMigrate
->
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
)),
LogContext
::
ScopedParam
(
lc
,
Param
(
"expected_NSFBLOCKId"
,
blockId
)),
LogContext
::
ScopedParam
(
lc
,
Param
(
"received_NSFBLOCKId"
,
mb
->
m_fileBlock
)),
LogContext
::
ScopedParam
(
lc
,
Param
(
"failed_Status"
,
mb
->
isFailed
()))
};
tape
::
utils
::
suppresUnusedVariable
(
sp
);
std
::
string
errorMsg
;
if
(
mb
->
isFailed
()){
errorMsg
=
mb
->
errorMsg
();
}
else
{
errorMsg
=
"Mistmatch between expected and received filed or blockid"
;
}
lc
.
log
(
LOG_ERR
,
errorMsg
);
throw
castor
::
tape
::
Exception
(
errorMsg
);
}
//----------------------------end deal with errors-----------------------
checkErrors
(
mb
,
blockId
,
lc
);
ckSum
=
mb
->
m_payload
.
adler32
(
ckSum
);
localStats
.
checksumingTime
+=
timer
.
secs
(
utils
::
Timer
::
resetCounter
);
mb
->
m_payload
.
write
(
*
output
);
localStats
.
transferTime
+=
timer
.
secs
(
utils
::
Timer
::
resetCounter
);
localStats
.
dataVolume
+=
mb
->
m_payload
.
size
();
++
blockId
;
}
...
...
@@ -191,7 +176,34 @@ namespace daemon {
MemBlock
*
TapeWriteTask
::
getFreeBlock
()
{
return
m_fifo
.
getFreeBlock
();
}
//------------------------------------------------------------------------------
// checkErrors
//------------------------------------------------------------------------------
void
TapeWriteTask
::
checkErrors
(
MemBlock
*
mb
,
int
blockId
,
castor
::
log
::
LogContext
&
lc
){
using
namespace
castor
::
log
;
if
(
m_fileToMigrate
->
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
)),
LogContext
::
ScopedParam
(
lc
,
Param
(
"expected_NSFBLOCKId"
,
blockId
)),
LogContext
::
ScopedParam
(
lc
,
Param
(
"received_NSFBLOCKId"
,
mb
->
m_fileBlock
)),
LogContext
::
ScopedParam
(
lc
,
Param
(
"failed_Status"
,
mb
->
isFailed
()))
};
tape
::
utils
::
suppresUnusedVariable
(
sp
);
std
::
string
errorMsg
;
int
errCode
;
if
(
mb
->
isFailed
()){
errorMsg
=
mb
->
errorMsg
();
errCode
=
mb
->
errorCode
();
}
else
{
errorMsg
=
"Mistmatch between expected and received filed or blockid"
;
errCode
=
SEINTERNAL
;
}
lc
.
log
(
LOG_ERR
,
errorMsg
);
throw
castor
::
exception
::
Exception
(
errCode
,
errorMsg
);
}
}
//------------------------------------------------------------------------------
// pushDataBlock
//------------------------------------------------------------------------------
...
...
@@ -234,6 +246,15 @@ namespace daemon {
// watchdog.notify();
}
}
//------------------------------------------------------------------------------
// hasAnotherTaskTailed
//------------------------------------------------------------------------------
void
TapeWriteTask
::
hasAnotherTaskTailed
()
const
{
//if a task has signaled an error, we stop our job
if
(
m_errorFlag
){
throw
castor
::
tape
::
exceptions
::
ErrorFlag
();
}
}
}}}}
castor/tape/tapeserver/daemon/TapeWriteTask.hpp
View file @
891da7af
...
...
@@ -40,7 +40,7 @@ namespace tapeserver {
namespace
daemon
{
class
MigrationReportPacker
;
class
Memblock
;
/**
* The TapeWriteFileTask is responsible to write a single file onto tape as part of a migration
* session. Being a consumer of memory blocks, it inherits from the DataConsumer class. It also
...
...
@@ -95,12 +95,19 @@ public:
*/
void
circulateMemBlocks
();
private:
void
hasAnotherTaskTailed
()
const
{
//if a task has signaled an error, we stop our job
if
(
m_errorFlag
){
throw
castor
::
tape
::
exceptions
::
ErrorFlag
();
}
}
/**
*Throw an exception if m_errorFlag is set
*/
void
hasAnotherTaskTailed
()
const
;
/**
* This function will check the consistency of the mem block and
* throw exception is something goes wrong
* @param mb The mem block to check
* @param blockId The block id the mem blopck should be at
* @param lc FOr logging
*/
void
checkErrors
(
MemBlock
*
mb
,
int
blockId
,
castor
::
log
::
LogContext
&
lc
);
/**
* Function in charge of opening the WriteFile for m_fileToMigrate
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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