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
4f4b3716
Commit
4f4b3716
authored
Dec 04, 2008
by
Steven Murray
Browse files
Moved the unmarshalling of an RCP job reply message to the Marshaller.
parent
b7869655
Changes
11
Hide whitespace changes
Inline
Side-by-side
castor/tape/aggregator/AggregatorDaemon.cpp
View file @
4f4b3716
...
...
@@ -133,7 +133,8 @@ void castor::tape::aggregator::AggregatorDaemon::parseCommandLine(
castor
::
dlf
::
dlf_writep
(
nullCuuid
,
DLF_LVL_ERROR
,
AGGREGATOR_FAILED_TO_PARSE_COMMAND_LINE
,
2
,
params
);
castor
::
exception
::
InvalidArgument
ex
;
ex
.
getMessage
()
<<
oss
.
str
();
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": "
<<
oss
.
str
();
throw
ex
;
}
}
...
...
@@ -154,7 +155,8 @@ void castor::tape::aggregator::AggregatorDaemon::parseCommandLine(
castor
::
dlf
::
dlf_writep
(
nullCuuid
,
DLF_LVL_ERROR
,
AGGREGATOR_FAILED_TO_PARSE_COMMAND_LINE
,
2
,
params
);
castor
::
exception
::
InvalidArgument
ex
;
ex
.
getMessage
()
<<
oss
.
str
();
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": "
<<
oss
.
str
();
throw
ex
;
}
case
':'
:
...
...
@@ -169,7 +171,8 @@ void castor::tape::aggregator::AggregatorDaemon::parseCommandLine(
castor
::
dlf
::
dlf_writep
(
nullCuuid
,
DLF_LVL_ERROR
,
AGGREGATOR_FAILED_TO_PARSE_COMMAND_LINE
,
2
,
params
);
castor
::
exception
::
InvalidArgument
ex
;
ex
.
getMessage
()
<<
oss
.
str
();
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": "
<<
oss
.
str
();
throw
ex
;
}
default:
...
...
@@ -185,7 +188,8 @@ void castor::tape::aggregator::AggregatorDaemon::parseCommandLine(
castor
::
dlf
::
dlf_writep
(
nullCuuid
,
DLF_LVL_ERROR
,
AGGREGATOR_FAILED_TO_PARSE_COMMAND_LINE
,
2
,
params
);
castor
::
exception
::
Internal
ex
;
ex
.
getMessage
()
<<
oss
.
str
();
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": "
<<
oss
.
str
();
throw
ex
;
}
}
...
...
@@ -202,7 +206,8 @@ void castor::tape::aggregator::AggregatorDaemon::parseCommandLine(
castor
::
dlf
::
dlf_writep
(
nullCuuid
,
DLF_LVL_ERROR
,
AGGREGATOR_FAILED_TO_PARSE_COMMAND_LINE
,
2
,
params
);
castor
::
exception
::
Internal
ex
;
ex
.
getMessage
()
<<
oss
.
str
();
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": "
<<
oss
.
str
();
throw
ex
;
}
...
...
@@ -219,9 +224,10 @@ void castor::tape::aggregator::AggregatorDaemon::parseCommandLine(
castor
::
dlf
::
Param
(
"Reason"
,
oss
.
str
())};
castor
::
dlf
::
dlf_writep
(
nullCuuid
,
DLF_LVL_ERROR
,
AGGREGATOR_FAILED_TO_PARSE_COMMAND_LINE
,
2
,
params
);
castor
::
exception
::
InvalidArgument
e
;
e
.
getMessage
()
<<
oss
.
str
();
throw
e
;
castor
::
exception
::
InvalidArgument
ex
;
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": "
<<
oss
.
str
();
throw
ex
;
}
}
...
...
@@ -241,7 +247,8 @@ int castor::tape::aggregator::AggregatorDaemon::getVdqmListenPort()
castor
::
exception
::
InvalidConfigEntry
ex
(
"TAPEAGGREGATOR"
,
"VDQMPORT"
,
configEntry
);
ex
.
getMessage
()
<<
"Invalid configuration entry: "
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Invalid configuration entry: "
<<
ex
.
getEntryCategory
()
<<
" "
<<
ex
.
getEntryName
()
<<
" "
<<
ex
.
getEntryValue
();
...
...
@@ -268,7 +275,8 @@ int castor::tape::aggregator::AggregatorDaemon::getRtcpdListenPort()
castor
::
exception
::
InvalidConfigEntry
ex
(
"TAPEAGGREGATOR"
,
"RTCPDPORT"
,
configEntry
);
ex
.
getMessage
()
<<
"Invalid configuration entry: "
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Invalid configuration entry: "
<<
ex
.
getEntryCategory
()
<<
" "
<<
ex
.
getEntryName
()
<<
" "
<<
ex
.
getEntryValue
();
...
...
castor/tape/aggregator/AggregatorMain.cpp
View file @
4f4b3716
...
...
@@ -86,7 +86,8 @@ int main(int argc, char *argv[]) {
if
(
vdqmRequestHandlerThreadPool
==
NULL
)
{
castor
::
exception
::
Internal
ie
;
ie
.
getMessage
()
<<
"Failed to get VdqmRequestHandlerThreadPool"
;
ie
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Failed to get VdqmRequestHandlerThreadPool"
;
throw
ie
;
}
vdqmRequestHandlerThreadPool
->
setNbThreads
(
0
);
...
...
@@ -108,7 +109,8 @@ int main(int argc, char *argv[]) {
if
(
rtcpdHandlerThreadPool
==
NULL
)
{
castor
::
exception
::
Internal
ie
;
ie
.
getMessage
()
<<
"Failed to get RtcpdHandlerThreadPool"
;
ie
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Failed to get RtcpdHandlerThreadPool"
;
throw
ie
;
}
rtcpdHandlerThreadPool
->
setNbThreads
(
10
);
...
...
castor/tape/aggregator/Marshaller.cpp
View file @
4f4b3716
...
...
@@ -43,7 +43,8 @@ void castor::tape::aggregator::Marshaller::marshallUint8(uint8_t src,
if
(
dst
==
NULL
)
{
castor
::
exception
::
Exception
ex
(
EINVAL
);
ex
.
getMessage
()
<<
"Pointer to destination buffer is NULL"
;
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Pointer to destination buffer is NULL"
;
throw
ex
;
}
...
...
@@ -64,7 +65,8 @@ void castor::tape::aggregator::Marshaller::marshallUint16(uint16_t src,
if
(
dst
==
NULL
)
{
castor
::
exception
::
Exception
ex
(
EINVAL
);
ex
.
getMessage
()
<<
"Pointer to destination buffer is NULL"
;
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Pointer to destination buffer is NULL"
;
throw
ex
;
}
...
...
@@ -85,7 +87,8 @@ void castor::tape::aggregator::Marshaller::marshallUint32(uint32_t src,
if
(
dst
==
NULL
)
{
castor
::
exception
::
Exception
ex
(
EINVAL
);
ex
.
getMessage
()
<<
"Pointer to destination buffer is NULL"
;
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Pointer to destination buffer is NULL"
;
throw
ex
;
}
...
...
@@ -100,20 +103,22 @@ void castor::tape::aggregator::Marshaller::marshallUint32(uint32_t src,
//------------------------------------------------------------------------------
// unmarshallInt32
//------------------------------------------------------------------------------
void
castor
::
tape
::
aggregator
::
Marshaller
::
unmarshallUint32
(
char
*
&
src
,
void
castor
::
tape
::
aggregator
::
Marshaller
::
unmarshallUint32
(
const
char
*
&
src
,
size_t
&
srcLen
,
uint32_t
&
dst
)
throw
(
castor
::
exception
::
Exception
)
{
if
(
src
==
NULL
)
{
castor
::
exception
::
Exception
ex
(
EINVAL
);
ex
.
getMessage
()
<<
"Pointer to source buffer is NULL"
;
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Pointer to source buffer is NULL"
;
throw
ex
;
}
if
(
srcLen
<
sizeof
(
dst
))
{
castor
::
exception
::
Exception
ex
(
EINVAL
);
ex
.
getMessage
()
<<
"Source buffer length is too small: Expected length: "
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Source buffer length is too small: Expected length: "
<<
sizeof
(
dst
)
<<
": Actual length: "
<<
srcLen
;
throw
ex
;
}
...
...
@@ -135,7 +140,8 @@ void castor::tape::aggregator::Marshaller::marshallString(const char * src,
if
(
dst
==
NULL
)
{
castor
::
exception
::
Exception
ex
(
EINVAL
);
ex
.
getMessage
()
<<
"Pointer to destination buffer is NULL"
;
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Pointer to destination buffer is NULL"
;
throw
ex
;
}
...
...
@@ -154,7 +160,8 @@ void castor::tape::aggregator::Marshaller::marshallString(
if
(
dst
==
NULL
)
{
castor
::
exception
::
Exception
ex
(
EINVAL
);
ex
.
getMessage
()
<<
"Pointer to destination buffer is NULL"
;
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Pointer to destination buffer is NULL"
;
throw
ex
;
}
...
...
@@ -167,35 +174,39 @@ void castor::tape::aggregator::Marshaller::marshallString(
//------------------------------------------------------------------------------
// unmarshallString
//------------------------------------------------------------------------------
void
castor
::
tape
::
aggregator
::
Marshaller
::
unmarshallString
(
char
*
&
src
,
void
castor
::
tape
::
aggregator
::
Marshaller
::
unmarshallString
(
const
char
*
&
src
,
size_t
&
srcLen
,
char
*
dst
,
const
size_t
dstLen
)
throw
(
castor
::
exception
::
Exception
)
{
if
(
src
==
NULL
)
{
castor
::
exception
::
Exception
ex
(
EINVAL
);
ex
.
getMessage
()
<<
"Pointer to source buffer is NULL"
;
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Pointer to source buffer is NULL"
;
throw
ex
;
}
if
(
srcLen
==
0
)
{
castor
::
exception
::
Exception
ex
(
EINVAL
);
ex
.
getMessage
()
<<
"Source buffer length is 0"
;
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Source buffer length is 0"
;
throw
ex
;
}
if
(
dst
==
NULL
)
{
castor
::
exception
::
Exception
ex
(
EINVAL
);
ex
.
getMessage
()
<<
"Pointer to destination buffer is NULL"
;
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Pointer to destination buffer is NULL"
;
throw
ex
;
}
if
(
dstLen
==
0
)
{
castor
::
exception
::
Exception
ex
(
EINVAL
);
ex
.
getMessage
()
<<
"Destination buffer length is 0"
;
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Destination buffer length is 0"
;
throw
ex
;
}
...
...
@@ -225,7 +236,8 @@ void castor::tape::aggregator::Marshaller::unmarshallString(char * &src,
if
(
!
strTerminatorReached
)
{
castor
::
exception
::
Exception
ex
(
EINVAL
);
ex
.
getMessage
()
<<
"String terminator of source buffer was not reached"
;
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": String terminator of source buffer was not reached"
;
throw
ex
;
}
}
...
...
@@ -241,7 +253,8 @@ size_t castor::tape::aggregator::Marshaller::marshallRcpJobRequest(
if
(
dst
==
NULL
)
{
castor
::
exception
::
Exception
ex
(
EINVAL
);
ex
.
getMessage
()
<<
"Pointer to destination buffer is NULL"
;
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Pointer to destination buffer is NULL"
;
throw
ex
;
}
...
...
@@ -262,7 +275,8 @@ size_t castor::tape::aggregator::Marshaller::marshallRcpJobRequest(
if
(
totalLen
>
dstLen
)
{
castor
::
exception
::
Exception
ex
(
EMSGSIZE
);
ex
.
getMessage
()
<<
"Buffer too small for job submission request message: "
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Buffer too small for job submission request message: "
"Required size: "
<<
totalLen
<<
" Actual size: "
<<
dstLen
;
throw
ex
;
...
...
@@ -270,17 +284,17 @@ size_t castor::tape::aggregator::Marshaller::marshallRcpJobRequest(
// Marshall the whole message (header + body)
char
*
p
=
dst
;
marshallUint32
(
RTCOPY_MAGIC_OLD0
,
p
);
marshallUint32
(
VDQM_CLIENTINFO
,
p
);
marshallUint32
(
len
,
p
);
marshallUint32
(
request
.
tapeRequestID
,
p
);
marshallUint32
(
request
.
clientPort
,
p
);
marshallUint32
(
request
.
clientEuid
,
p
);
marshallUint32
(
request
.
clientEgid
,
p
);
marshallString
(
request
.
clientHost
,
p
);
marshallString
(
request
.
deviceGroupName
,
p
);
marshallString
(
request
.
tapeDriveName
,
p
);
marshallString
(
request
.
clientUserName
,
p
);
marshallUint32
(
RTCOPY_MAGIC_OLD0
,
p
);
marshallUint32
(
VDQM_CLIENTINFO
,
p
);
marshallUint32
(
len
,
p
);
marshallUint32
(
request
.
tapeRequestID
,
p
);
marshallUint32
(
request
.
clientPort
,
p
);
marshallUint32
(
request
.
clientEuid
,
p
);
marshallUint32
(
request
.
clientEgid
,
p
);
marshallString
(
request
.
clientHost
,
p
);
marshallString
(
request
.
deviceGroupName
,
p
);
marshallString
(
request
.
tapeDriveName
,
p
);
marshallString
(
request
.
clientUserName
,
p
);
// Calculate the number of bytes actually marshalled
const
size_t
nbBytesMarshalled
=
p
-
dst
;
...
...
@@ -289,7 +303,8 @@ size_t castor::tape::aggregator::Marshaller::marshallRcpJobRequest(
if
(
totalLen
!=
nbBytesMarshalled
)
{
castor
::
exception
::
Internal
ie
;
ie
.
getMessage
()
<<
"Mismatch between the expected total length of the "
ie
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Mismatch between the expected total length of the "
"RCP job submission request message and the actual number of bytes "
"marshalled: Expected length: "
<<
totalLen
<<
" Marshalled: "
<<
nbBytesMarshalled
;
...
...
@@ -301,6 +316,33 @@ size_t castor::tape::aggregator::Marshaller::marshallRcpJobRequest(
}
//-----------------------------------------------------------------------------
// unmarshallRcpJobReply
//-----------------------------------------------------------------------------
void
castor
::
tape
::
aggregator
::
Marshaller
::
unmarshallRcpJobReply
(
const
char
*
&
src
,
size_t
&
srcLen
,
RcpJobReply
&
dst
)
throw
(
castor
::
exception
::
Exception
)
{
// Unmarshall the status number
Marshaller
::
unmarshallUint32
(
src
,
srcLen
,
dst
.
status
);
// The error message will be right trimmed if it is too large
const
size_t
maxBytesToUnmarshall
=
srcLen
<
sizeof
(
dst
.
errorMessage
)
?
srcLen
:
sizeof
(
dst
.
errorMessage
);
// Unmarshall the error message
if
(
maxBytesToUnmarshall
>
0
)
{
strncpy
(
dst
.
errorMessage
,
src
,
maxBytesToUnmarshall
);
dst
.
errorMessage
[
maxBytesToUnmarshall
-
1
]
=
'\0'
;
src
=
src
+
strlen
(
dst
.
errorMessage
)
+
1
;
srcLen
=
srcLen
-
strlen
(
dst
.
errorMessage
)
-
1
;
}
else
{
dst
.
errorMessage
[
0
]
=
'\0'
;
// No need to update src or srcLen
}
}
//-----------------------------------------------------------------------------
// marshallRtcpAckn
//-----------------------------------------------------------------------------
...
...
@@ -311,7 +353,8 @@ size_t castor::tape::aggregator::Marshaller::marshallRtcpAckn(char *const dst,
if
(
dst
==
NULL
)
{
castor
::
exception
::
Exception
ex
(
EINVAL
);
ex
.
getMessage
()
<<
"Pointer to destination buffer is NULL"
;
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Pointer to destination buffer is NULL"
;
throw
ex
;
}
...
...
@@ -320,7 +363,8 @@ size_t castor::tape::aggregator::Marshaller::marshallRtcpAckn(char *const dst,
if
(
dstLen
<
4
*
sizeof
(
uint32_t
)
+
1
)
{
castor
::
exception
::
Exception
ex
(
EINVAL
);
ex
.
getMessage
()
<<
"Destination buffer length is too small: "
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Destination buffer length is too small: "
"Expected minimum length: "
<<
(
4
*
sizeof
(
uint32_t
)
+
1
)
<<
": Actual length: "
<<
dstLen
;
throw
ex
;
...
...
@@ -329,7 +373,8 @@ size_t castor::tape::aggregator::Marshaller::marshallRtcpAckn(char *const dst,
if
(
errorMsg
==
NULL
)
{
castor
::
exception
::
Exception
ex
(
EINVAL
);
ex
.
getMessage
()
<<
"Pointer to error message is NULL"
;
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Pointer to error message is NULL"
;
throw
ex
;
}
...
...
@@ -368,7 +413,8 @@ size_t castor::tape::aggregator::Marshaller::marshallRtcpAckn(char *const dst,
if
(
totalLen
!=
nbBytesMarshalled
)
{
castor
::
exception
::
Internal
ie
;
ie
.
getMessage
()
<<
"Mismatch between the expected total length of the "
ie
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Mismatch between the expected total length of the "
"RTCP acknowledge message and the actual number of bytes marshalled: "
"Expected length: "
<<
totalLen
<<
" Marshalled: "
<<
nbBytesMarshalled
;
...
...
@@ -380,9 +426,9 @@ size_t castor::tape::aggregator::Marshaller::marshallRtcpAckn(char *const dst,
//-----------------------------------------------------------------------------
// marshallR
TCP
TapeRequest
// marshallR
tcp
TapeRequest
//-----------------------------------------------------------------------------
size_t
castor
::
tape
::
aggregator
::
Marshaller
::
marshallR
TCP
TapeRequest
(
char
*
dst
,
size_t
castor
::
tape
::
aggregator
::
Marshaller
::
marshallR
tcp
TapeRequest
(
char
*
dst
,
const
size_t
dstLen
,
const
RtcpTapeRequest
&
request
)
throw
(
castor
::
exception
::
Exception
)
{
...
...
@@ -401,7 +447,8 @@ size_t castor::tape::aggregator::Marshaller::marshallRTCPTapeRequest(char *dst,
if
(
totalLen
>
dstLen
)
{
castor
::
exception
::
Exception
ex
(
EMSGSIZE
);
ex
.
getMessage
()
<<
"Buffer too small for tape request message: "
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Buffer too small for tape request message: "
"Required size: "
<<
totalLen
<<
" Actual size: "
<<
dstLen
;
throw
ex
;
...
...
@@ -456,7 +503,8 @@ size_t castor::tape::aggregator::Marshaller::marshallRTCPTapeRequest(char *dst,
if
(
totalLen
!=
nbBytesMarshalled
)
{
castor
::
exception
::
Internal
ie
;
ie
.
getMessage
()
<<
"Mismatch between the expected total length of the "
ie
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Mismatch between the expected total length of the "
"RTCP tape request message and the actual number of bytes marshalled: "
"Expected length: "
<<
totalLen
<<
" Marshalled: "
<<
nbBytesMarshalled
;
...
...
@@ -465,3 +513,18 @@ size_t castor::tape::aggregator::Marshaller::marshallRTCPTapeRequest(char *dst,
return
totalLen
;
}
//-----------------------------------------------------------------------------
// unmarshallRtcpTapeRequest
//-----------------------------------------------------------------------------
void
castor
::
tape
::
aggregator
::
Marshaller
::
unmarshallRtcpTapeRequest
(
const
char
*
&
src
,
size_t
&
srcLen
,
RtcpTapeRequest
&
request
)
throw
(
castor
::
exception
::
Exception
)
{
castor
::
exception
::
Internal
ie
;
ie
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Not implemented"
;
throw
ie
;
}
castor/tape/aggregator/Marshaller.hpp
View file @
4f4b3716
...
...
@@ -27,6 +27,7 @@
#define CASTOR_TAPE_AGGREGATOR_MARSHALLER_HPP 1
#include
"castor/exception/Exception.hpp"
#include
"castor/tape/aggregator/RcpJobReply.hpp"
#include
"castor/tape/aggregator/RcpJobRequest.hpp"
#include
"castor/tape/aggregator/RtcpTapeRequest.hpp"
...
...
@@ -96,8 +97,8 @@ namespace aggregator {
* and on return is the number of bytes remaining in the source buffer
* @param dst the destination unsigned 32-bit integer
*/
static
void
unmarshallUint32
(
char
*
&
src
,
size_t
&
srcLen
,
uint32_t
&
dst
)
throw
(
castor
::
exception
::
Exception
);
static
void
unmarshallUint32
(
const
char
*
&
src
,
size_t
&
srcLen
,
uint32_t
&
dst
)
throw
(
castor
::
exception
::
Exception
);
/**
* Marshalls the specified string into the specified destination buffer.
...
...
@@ -141,7 +142,7 @@ namespace aggregator {
* @param dstLen the length of the destination buffer where the string
* should unmarshalled to
*/
static
void
unmarshallString
(
char
*
&
src
,
size_t
&
srcLen
,
char
*
dst
,
static
void
unmarshallString
(
const
char
*
&
src
,
size_t
&
srcLen
,
char
*
dst
,
const
size_t
dstLen
)
throw
(
castor
::
exception
::
Exception
);
/**
...
...
@@ -157,6 +158,22 @@ namespace aggregator {
static
size_t
marshallRcpJobRequest
(
char
*
const
dst
,
const
size_t
dstLen
,
const
RcpJobRequest
&
request
)
throw
(
castor
::
exception
::
Exception
);
/**
* Unmarshalls the message body of an RCP job reply from the specified
* source buffer into the specified destination RCP job reply structure.
*
* @param src in/out parameter, before invocation points to the source
* buffer where the message body should be unmarshalled from and on return
* points to the byte in the source buffer immediately after the
* unmarshalled message body
* @param srcLen in/our parameter, before invocation is the length of the
* source buffer from where the message body should unmarshalled and on
* return is the number of bytes remaining in the source buffer
* @param dst the destination RCP job reply structure
*/
static
void
unmarshallRcpJobReply
(
const
char
*
&
src
,
size_t
&
srcLen
,
RcpJobReply
&
dst
)
throw
(
castor
::
exception
::
Exception
);
/**
* Marshalls the specified status code and possible error message into
* the specified destination buffer in order to create an RTCP acknowledge
...
...
@@ -181,8 +198,24 @@ namespace aggregator {
* @param request The tape request
* @return The total length of the message (header + body)
*/
static
size_t
marshallRTCPTapeRequest
(
char
*
const
dst
,
const
size_t
dstLen
,
const
RtcpTapeRequest
&
request
)
throw
(
castor
::
exception
::
Exception
);
static
size_t
marshallRtcpTapeRequest
(
char
*
const
dst
,
const
size_t
dstLen
,
const
RtcpTapeRequest
&
request
)
throw
(
castor
::
exception
::
Exception
);
/**
* Unmarshalls the message body of a tape request from the specified source
* buffer into the specified destination tape request structure.
*
* @param src in/out parameter, before invocation points to the source
* buffer where the message body should be unmarshalled from and on return
* points to the byte in the source buffer immediately after the
* unmarshalled message body
* @param srcLen in/our parameter, before invocation is the length of the
* source buffer from where the message body should unmarshalled and on
* return is the number of bytes remaining in the source buffer
* @param dst the destination tape request structure
*/
static
void
unmarshallRtcpTapeRequest
(
const
char
*
&
src
,
size_t
&
srcLen
,
RtcpTapeRequest
&
request
)
throw
(
castor
::
exception
::
Exception
);
};
// class Utils
...
...
castor/tape/aggregator/RcpJobReply.hpp
0 → 100644
View file @
4f4b3716
/******************************************************************************
* castor/tape/aggregator/RcpJobReply.hpp
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
*
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
*
* @author Steven Murray Steven.Murray@cern.ch
*****************************************************************************/
#ifndef CASTOR_TAPE_AGGREGATOR_RCPJOBREPLY
#define CASTOR_TAPE_AGGREGATOR_RCPJOBREPLY
#include
"h/Castor_limits.h"
#include
<stdint.h>
#include
<string>
namespace
castor
{
namespace
tape
{
namespace
aggregator
{
/**
* An RCP job reply message.
*/
struct
RcpJobReply
{
uint32_t
status
;
char
errorMessage
[
1024
];
};
// struct RtcpTapeRequest
}
// namespace aggregator
}
// namespace tape
}
// namespace castor
#endif // CASTOR_TAPE_AGGREGATOR_RCPJOBREPLY
castor/tape/aggregator/RcpJobSubmitter.cpp
View file @
4f4b3716
...
...
@@ -29,6 +29,7 @@
#include
"castor/tape/aggregator/Constants.hpp"
#include
"castor/tape/aggregator/Marshaller.hpp"
#include
"castor/tape/aggregator/RcpJobRequest.hpp"
#include
"castor/tape/aggregator/RcpJobReply.hpp"
#include
"castor/tape/aggregator/RcpJobSubmitter.hpp"
#include
"castor/tape/aggregator/SocketHelper.hpp"
#include
"h/net.h"
...
...
@@ -67,7 +68,8 @@ void castor::tape::aggregator::RcpJobSubmitter::submit(
if
(
clientHost
.
length
()
>
sizeof
(
request
.
clientHost
)
-
1
)
{
castor
::
exception
::
Exception
ex
(
EINVAL
);
ex
.
getMessage
()
<<
"Length of clientHost string is too large: "
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Length of clientHost string is too large: "
"Maximum: "
<<
(
sizeof
(
request
.
clientHost
)
-
1
)
<<
" Actual: "
<<
clientHost
.
length
();
...
...
@@ -76,7 +78,8 @@ void castor::tape::aggregator::RcpJobSubmitter::submit(
if
(
deviceGroupName
.
length
()
>
sizeof
(
request
.
deviceGroupName
)
-
1
)
{
castor
::
exception
::
Exception
ex
(
EINVAL
);
ex
.
getMessage
()
<<
"Length of deviceGroupName string is too large: "
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Length of deviceGroupName string is too large: "
"Maximum: "
<<
(
sizeof
(
request
.
deviceGroupName
)
-
1
)
<<
" Actual: "
<<
deviceGroupName
.
length
();
...
...
@@ -85,7 +88,8 @@ void castor::tape::aggregator::RcpJobSubmitter::submit(
if
(
tapeDriveName
.
length
()
>
sizeof
(
request
.
tapeDriveName
)
-
1
)
{
castor
::
exception
::
Exception
ex
(
EINVAL
);
ex
.
getMessage
()
<<
"Length of tapeDriveName string is too large: "
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Length of tapeDriveName string is too large: "
"Maximum: "
<<
(
sizeof
(
request
.
tapeDriveName
)
-
1
)
<<
" Actual: "
<<
tapeDriveName
.
length
();
...
...
@@ -94,7 +98,8 @@ void castor::tape::aggregator::RcpJobSubmitter::submit(
if
(
clientUserName
.
length
()
>
sizeof
(
request
.
clientUserName
)
-
1
)
{
castor
::
exception
::
Exception
ex
(
EINVAL
);
ex
.
getMessage
()
<<
"Length of clientUserName string is too large: "
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Length of clientUserName string is too large: "
"Maximum: "
<<
(
sizeof
(
request
.
clientUserName
)
-
1
)
<<
" Actual: "
<<
clientUserName
.
length
();
...
...
@@ -121,8 +126,8 @@ void castor::tape::aggregator::RcpJobSubmitter::submit(
}
catch
(
castor
::
exception
::
Exception
&
ex
)
{
castor
::
exception
::
Internal
ie
;
ie
.
getMessage
()
<<
"Failed to marshall RCP job submission request message: "
ie
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
"
:
Failed to marshall RCP job submission request message: "
<<
ex
.
getMessage
().
str
();
throw
ie
;
...
...
@@ -136,26 +141,25 @@ void castor::tape::aggregator::RcpJobSubmitter::submit(
}
catch
(
castor
::
exception
::
Exception
&
connectex
)
{
castor
::
exception
::
Exception
ex
(
ECONNABORTED
);
ex
.
getMessage
()
<<
"Failed to connect to "
<<
remoteCopyType
ex
.
getMessage
()
<<
__PRETTY_FUNCTION__
<<
": Failed to connect to "
<<
remoteCopyType
<<
": host: "
<<
host
<<
": port: "
<<
port
<<
": "
<<
connectex
.
getMessage
().
str
();
}
// Send the job submission request message to the RTCPD or tape aggregator
// daemon
const
int
rc
=
netwrite_timeout
(
socket
.
socket
(),
buf
,
totalLen
,
netReadWriteTimeout
);
try
{
SocketHelper
::
writeBytes
(
socket
,
netReadWriteTimeout
,
totalLen
,
buf
);
}
catch
(
castor
::
exception
::
Exception
&
ex
)
{
castor
::
exception
::
Exception
ex2
(
SECOMERR
);
if
(
rc
==
-
1
)
{