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
cta
Commits
0ca18445
Commit
0ca18445
authored
Sep 26, 2014
by
Steven Murray
Browse files
Added initial structure of AcsProxy
parent
54e7d8ed
Changes
19
Hide whitespace changes
Inline
Side-by-side
castor/messages/AcsMountTapeForRecall.proto
0 → 100644
View file @
0ca18445
// 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 Castor Dev team, castor-dev@cern.ch
package
castor
.
messages
;
message
AcsMountTapeForRecall
{
required
string
vid
=
1
;
required
uint32
acs
=
2
;
required
uint32
lsm
=
3
;
required
uint32
panel
=
4
;
required
uint32
drive
=
5
;
}
castor/messages/
TapeserverProxyFactor
y.cpp
→
castor/messages/
AcsProx
y.cpp
View file @
0ca18445
...
@@ -16,13 +16,15 @@
...
@@ -16,13 +16,15 @@
* along with this program; if not, write to the Free Software
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
*
*
* @author Castor Dev team, castor-dev@cern.ch
* @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
*****************************************************************************/
#include
"castor/messages/
TapeserverProxyFactor
y.hpp"
#include
"castor/messages/
AcsProx
y.hpp"
//-----------------------------------------------------------------------------
-
//-----------------------------------------------------------------------------
// destructor
// destructor
//-----------------------------------------------------------------------------
-
//-----------------------------------------------------------------------------
castor
::
messages
::
TapeserverProxyFactory
::~
TapeserverProxyFactory
()
throw
()
{
castor
::
messages
::
AcsProxy
::~
AcsProxy
()
{
}
}
castor/messages/
TapeserverProxyFactor
y.hpp
→
castor/messages/
AcsProx
y.hpp
View file @
0ca18445
...
@@ -21,35 +21,37 @@
...
@@ -21,35 +21,37 @@
#pragma once
#pragma once
#include
"castor/messages/TapeserverProxy.hpp"
#include
<stdint.h>
#include
<string>
namespace
castor
{
namespace
castor
{
namespace
messages
{
namespace
messages
{
/**
/**
* Abstract factory for creating objects of type TapeserverProxy.
* Abstract class defining the interface to a proxy object representing the
* CASTOR ACS daemon.
*/
*/
class
TapeserverProxyFactor
y
{
class
AcsProx
y
{
public:
public:
/**
/**
* Destructor.
* Destructor.
*/
*/
virtual
~
TapeserverProxyFactory
()
throw
()
=
0
;
virtual
~
AcsProxy
()
=
0
;
/**
/**
* Creates an object of type TapeserverProxy on the heap and returns a pointer to
* Request the CASTOR ACS daemon to mount the specifed tape for recall.
* it.
*
*
*
Please note that it is the responsibility of the caller to deallocate the
*
@param vid The tape to be mounted.
*
proxy object from the heap
.
*
@param acs The ACS identifier
.
*
*
@param lsm The LSM identifier.
* @param
zmqContext The ZMQ context
.
* @param
panel The panel identifier
.
* @
return A pointer to the newly created object
.
* @
param drive The drive identifier
.
*/
*/
virtual
TapeserverProxy
*
create
(
void
*
const
zmqContext
)
=
0
;
virtual
void
mountTapeForRecall
(
const
std
::
string
&
vid
,
const
uint32_t
acs
,
const
uint32_t
lsm
,
const
uint32_t
panel
,
const
uint32_t
drive
)
=
0
;
};
// class
TapeserverProxyFactor
y
};
// class
AcsProx
y
}
// namespace messages
}
// namespace messages
}
// namespace castor
}
// namespace castor
...
...
castor/messages/
Tapeserver
ProxyDummy
Factory
.cpp
→
castor/messages/
Acs
ProxyDummy.cpp
View file @
0ca18445
...
@@ -19,18 +19,12 @@
...
@@ -19,18 +19,12 @@
* @author Castor Dev team, castor-dev@cern.ch
* @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
*****************************************************************************/
#include
"castor/messages/TapeserverProxyDummy.hpp"
#include
"castor/messages/AcsProxyDummy.hpp"
#include
"castor/messages/TapeserverProxyDummyFactory.hpp"
#include
"castor/log/LogContext.hpp"
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
castor
::
messages
::
TapeserverProxyDummyFactory
::~
TapeserverProxyDummyFactory
()
throw
()
{
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//
create
//
mountTapeForRecall
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
castor
::
messages
::
TapeserverProxy
*
castor
::
messages
::
TapeserverProxyDummyFactory
::
create
(
void
*
const
zmqContext
)
{
void
castor
::
messages
::
AcsProxyDummy
::
mountTapeForRecall
(
const
std
::
string
&
vid
,
return
new
TapeserverProxyDummy
();
const
uint32_t
acs
,
const
uint32_t
lsm
,
const
uint32_t
panel
,
const
uint32_t
drive
)
{
}
}
castor/messages/
Tapeserver
ProxyDummy
Factory
.hpp
→
castor/messages/
Acs
ProxyDummy.hpp
View file @
0ca18445
...
@@ -21,35 +21,30 @@
...
@@ -21,35 +21,30 @@
#pragma once
#pragma once
#include
"castor/messages/
TapeserverProxyFactor
y.hpp"
#include
"castor/messages/
AcsProx
y.hpp"
namespace
castor
{
namespace
castor
{
namespace
messages
{
namespace
messages
{
/**
/**
* Concrete
factory for crea
ti
n
g
objects of type TapeserverProxyDumm
y.
* Concrete
class implemen
ti
m
g
a dummy AcsProx
y.
*/
*/
class
Tapeserver
ProxyDummy
Factory
:
public
TapeserverProxyFactor
y
{
class
Acs
ProxyDummy
:
public
AcsProx
y
{
public:
public:
/**
/**
* Destructor.
* Request the CASTOR ACS daemon to mount the specifed tape for recall.
*/
~
TapeserverProxyDummyFactory
()
throw
();
/**
* Creates an object of type TapeserverProxyDummy on the heap and returns a pointer
* to it.
*
* Please note that it is the responsibility of the caller to deallocate the
* proxy object from the heap.
*
*
* @param zmqContext The ZMQ context.
* @param vid The tape to be mounted.
* @return A pointer to the newly created object.
* @param acs The ACS identifier.
* @param lsm The LSM identifier.
* @param panel The panel identifier.
* @param drive The drive identifier.
*/
*/
TapeserverProxy
*
create
(
void
*
const
zmqContext
);
void
mountTapeForRecall
(
const
std
::
string
&
vid
,
const
uint32_t
acs
,
const
uint32_t
lsm
,
const
uint32_t
panel
,
const
uint32_t
drive
);
};
// class
Tapeserver
ProxyDummy
Factory
};
// class
Acs
ProxyDummy
}
// namespace messages
}
// namespace messages
}
// namespace castor
}
// namespace castor
...
...
castor/messages/
Tapeserver
ProxyZmq
Factory
.cpp
→
castor/messages/
Acs
ProxyZmq.cpp
View file @
0ca18445
...
@@ -19,27 +19,79 @@
...
@@ -19,27 +19,79 @@
* @author Castor Dev team, castor-dev@cern.ch
* @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
*****************************************************************************/
#include
"castor/messages/TapeserverProxyZmq.hpp"
#include
"castor/messages/AcsMountTapeForRecall.pb.h"
#include
"castor/messages/TapeserverProxyZmqFactory.hpp"
#include
"castor/messages/AcsProxyZmq.hpp"
#include
"castor/messages/Constants.hpp"
#include
"castor/messages/messages.hpp"
#include
"castor/messages/ReturnValue.pb.h"
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// constructor
// constructor
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
castor
::
messages
::
TapeserverProxyZmqFactory
::
TapeserverProxyZmqFactory
(
log
::
Logger
&
log
,
const
unsigned
short
tapeserverPort
,
const
int
netTimeout
)
throw
()
:
castor
::
messages
::
AcsProxyZmq
::
AcsProxyZmq
(
log
::
Logger
&
log
,
m_log
(
log
),
const
unsigned
short
serverPort
,
void
*
const
zmqContext
)
throw
()
:
m_tapeserverPort
(
tapeserverPort
),
m_log
(
log
),
m_netTimeout
(
netTimeout
)
{
m_serverPort
(
serverPort
),
}
m_serverSocket
(
zmqContext
,
ZMQ_REQ
)
{
connectZmqSocketToLocalhost
(
m_serverSocket
,
serverPort
);
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//
destructor
//
mountTapeForRecall
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
castor
::
messages
::
TapeserverProxyZmqFactory
::~
TapeserverProxyZmqFactory
()
throw
()
{
void
castor
::
messages
::
AcsProxyZmq
::
mountTapeForRecall
(
const
std
::
string
&
vid
,
const
uint32_t
acs
,
const
uint32_t
lsm
,
const
uint32_t
panel
,
const
uint32_t
drive
)
{
try
{
const
Frame
rqst
=
createAcsMountTapeForRecallFrame
(
vid
,
acs
,
lsm
,
panel
,
drive
);
sendFrame
(
m_serverSocket
,
rqst
);
ReturnValue
reply
;
recvTapeReplyOrEx
(
m_serverSocket
,
reply
);
if
(
0
!=
reply
.
value
())
{
// Should never get here
castor
::
exception
::
Exception
ex
;
ex
.
getMessage
()
<<
"Received an unexpected return value"
": expected=0 actual="
<<
reply
.
value
();
throw
ex
;
}
}
catch
(
castor
::
exception
::
Exception
&
ne
)
{
castor
::
exception
::
Exception
ex
;
ex
.
getMessage
()
<<
"Failed to request CASTOR ACS daemon to mount tape for recall: "
<<
"vid="
<<
vid
<<
" acs="
<<
acs
<<
" lsm="
<<
lsm
<<
" panel="
<<
panel
<<
" drive="
<<
drive
<<
": "
<<
ne
.
getMessage
().
str
();
throw
ex
;
}
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// create
// create
AcsMountTapeForRecallFrame
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
castor
::
messages
::
TapeserverProxy
*
castor
::
messages
::
TapeserverProxyZmqFactory
::
create
(
void
*
const
zmqContext
)
{
castor
::
messages
::
Frame
castor
::
messages
::
AcsProxyZmq
::
return
new
TapeserverProxyZmq
(
m_log
,
m_tapeserverPort
,
m_netTimeout
,
zmqContext
);
createAcsMountTapeForRecallFrame
(
const
std
::
string
&
vid
,
const
uint32_t
acs
,
const
uint32_t
lsm
,
const
uint32_t
panel
,
const
uint32_t
drive
)
{
try
{
Frame
frame
;
frame
.
header
=
messages
::
protoTapePreFillHeader
();
frame
.
header
.
set_msgtype
(
messages
::
MSG_TYPE_ACSMOUNTTAPEFORRECALL
);
frame
.
header
.
set_bodysignature
(
"PIPO"
);
AcsMountTapeForRecall
body
;
body
.
set_vid
(
vid
);
body
.
set_acs
(
acs
);
body
.
set_lsm
(
lsm
);
body
.
set_panel
(
panel
);
body
.
set_drive
(
drive
);
frame
.
serializeProtocolBufferIntoBody
(
body
);
return
frame
;
}
catch
(
castor
::
exception
::
Exception
&
ne
)
{
castor
::
exception
::
Exception
ex
;
ex
.
getMessage
()
<<
"Failed to create AcsMountTapeForRecall frame: "
<<
ne
.
getMessage
().
str
();
throw
ex
;
}
}
}
castor/messages/
Tapeserver
ProxyZmq
Factory
.hpp
→
castor/messages/
Acs
ProxyZmq.hpp
View file @
0ca18445
...
@@ -21,42 +21,42 @@
...
@@ -21,42 +21,42 @@
#pragma once
#pragma once
#include
"castor/messages/TapeserverProxyFactory.hpp"
#include
"castor/log/Logger.hpp"
#include
"castor/messages/AcsProxy.hpp"
#include
"castor/messages/Frame.hpp"
#include
"castor/messages/ZmqSocketMT.hpp"
namespace
castor
{
namespace
castor
{
namespace
messages
{
namespace
messages
{
/**
/**
* Concrete
factory for creating objects of type Tapeserver
Proxy
Zmq
.
* Concrete
class providing a ZMQ implementation of an Acs
Proxy.
*/
*/
class
Tapeserver
ProxyZmq
Factory
:
public
TapeserverProxyFactor
y
{
class
Acs
ProxyZmq
:
public
AcsProx
y
{
public:
public:
/**
/**
* Constructor.
* Constructor.
*
*
* @param log The object representing the API of the CASTOR logging system.
* @param log The object representing the API of the CASTOR logging system.
* @param netTimeout The timeout in seconds to be applied when performing
* @param serverPort The TCP/IP port on which the CASTOR ACS daemon is listening
* network read and write operations.
* for ZMQ messages.
*/
* @param zmqContext The ZMQ context.
TapeserverProxyZmqFactory
(
log
::
Logger
&
log
,
const
unsigned
short
tapeserverPort
,
const
int
netTimeout
)
throw
();
/**
* Destructor.
*/
*/
~
TapeserverProxyZmqFactory
()
throw
();
AcsProxyZmq
(
log
::
Logger
&
log
,
const
unsigned
short
serverPort
,
void
*
const
zmqContext
)
throw
();
/**
/**
* Creates an object of type TapeserverProxyZmq on the heap and returns a pointer
* Request the CASTOR ACS daemon to mount the specifed tape for recall.
* to it.
*
* Please note that it is the responsibility of the caller to deallocate the
* proxy object from the heap.
*
*
* @param zmqContext The ZMQ context.
* @param vid The tape to be mounted.
* @return A pointer to the newly created object.
* @param acs The ACS identifier.
* @param lsm The LSM identifier.
* @param panel The panel identifier.
* @param drive The drive identifier.
*/
*/
TapeserverProxy
*
create
(
void
*
const
zmqContext
);
void
mountTapeForRecall
(
const
std
::
string
&
vid
,
const
uint32_t
acs
,
const
uint32_t
lsm
,
const
uint32_t
panel
,
const
uint32_t
drive
);
private:
private:
...
@@ -64,19 +64,33 @@ private:
...
@@ -64,19 +64,33 @@ private:
* The object representing the API of the CASTOR logging system.
* The object representing the API of the CASTOR logging system.
*/
*/
log
::
Logger
&
m_log
;
log
::
Logger
&
m_log
;
/**
/**
* The TCP/IP port on which the vdqmd daemon is listening.
* The TCP/IP port on which the CASTOR ACS daemon is listening for ZMQ
* messages.
*/
*/
const
unsigned
short
m_
tape
serverPort
;
const
unsigned
short
m_serverPort
;
/**
/**
* The timeout in seconds to be applied when performing network read and
* Socket connecting this proxy the daemon it represents.
* write operations.
*/
ZmqSocketMT
m_serverSocket
;
/**
* Creates a frame containing a AcsMountTapeForRecall message.
*
* @param vid The tape to be mounted.
* @param acs The ACS identifier.
* @param lsm The LSM identifier.
* @param panel The panel identifier.
* @param drive The drive identifier.
* @return The frame.
*/
*/
const
int
m_netTimeout
;
Frame
createAcsMountTapeForRecallFrame
(
const
std
::
string
&
vid
,
const
uint32_t
acs
,
const
uint32_t
lsm
,
const
uint32_t
panel
,
const
uint32_t
drive
);
};
// class
Tapeserver
ProxyZmq
Factory
};
// class
Acs
ProxyZmq
}
// namespace messages
}
// namespace messages
}
// namespace castor
}
// namespace castor
...
...
castor/messages/CMakeLists.txt
View file @
0ca18445
...
@@ -5,16 +5,16 @@ PROTOBUF_GENERATE_CPP(ProtoSources ProtoHeaders ${ProtoFiles})
...
@@ -5,16 +5,16 @@ PROTOBUF_GENERATE_CPP(ProtoSources ProtoHeaders ${ProtoFiles})
add_library
(
castormessages SHARED
add_library
(
castormessages SHARED
${
ProtoSources
}
${
ProtoSources
}
AcsProxy.cpp
AcsProxyDummy.cpp
AcsProxyZmq.cpp
Constants.cpp
Constants.cpp
Frame.cpp
Frame.cpp
messages.cpp
messages.cpp
SmartZmqContext.cpp
SmartZmqContext.cpp
TapeserverProxy.cpp
TapeserverProxy.cpp
TapeserverProxyDummy.cpp
TapeserverProxyDummy.cpp
TapeserverProxyDummyFactory.cpp
TapeserverProxyFactory.cpp
TapeserverProxyZmq.cpp
TapeserverProxyZmq.cpp
TapeserverProxyZmqFactory.cpp
ZmqMsg.cpp
ZmqMsg.cpp
ZmqSocket.cpp
ZmqSocket.cpp
ZmqSocketMT.cpp
ZmqSocketMT.cpp
...
...
castor/messages/Constants.cpp
View file @
0ca18445
...
@@ -70,6 +70,8 @@ const char *castor::messages::msgTypeToString(const MsgType msgType) throw() {
...
@@ -70,6 +70,8 @@ const char *castor::messages::msgTypeToString(const MsgType msgType) throw() {
return
"TapeUnmounted"
;
return
"TapeUnmounted"
;
case
MSG_TYPE_LABELERROR
:
case
MSG_TYPE_LABELERROR
:
return
"LabelError"
;
return
"LabelError"
;
case
MSG_TYPE_ACSMOUNTTAPEFORRECALL
:
return
"AcsMountTapeForRecall"
;
default:
default:
return
"Unknown"
;
return
"Unknown"
;
}
}
...
...
castor/messages/Constants.hpp
View file @
0ca18445
...
@@ -52,7 +52,8 @@ enum MsgType {
...
@@ -52,7 +52,8 @@ enum MsgType {
MSG_TYPE_TAPEMOUNTEDFORRECALL
,
MSG_TYPE_TAPEMOUNTEDFORRECALL
,
MSG_TYPE_TAPEUNMOUNTSTARTED
,
MSG_TYPE_TAPEUNMOUNTSTARTED
,
MSG_TYPE_TAPEUNMOUNTED
,
MSG_TYPE_TAPEUNMOUNTED
,
MSG_TYPE_LABELERROR
MSG_TYPE_LABELERROR
,
MSG_TYPE_ACSMOUNTTAPEFORRECALL
};
};
enum
ProtocolVersion
{
enum
ProtocolVersion
{
...
...
castor/messages/Heartbeat.proto
View file @
0ca18445
//
// castor/messages/TapeserverProxyFactory.cpp
//
// This file is part of the Castor project.
// This file is part of the Castor project.
// See http://castor.web.cern.ch/castor
// See http://castor.web.cern.ch/castor
//
//
...
...
castor/messages/TapeserverProxy.hpp
View file @
0ca18445
...
@@ -21,9 +21,8 @@
...
@@ -21,9 +21,8 @@
#pragma once
#pragma once
#include
"castor/
log/Logger
.hpp"
#include
"castor/
exception/Exception
.hpp"
#include
<memory>
#include
<stdint.h>
#include
<stdint.h>
#include
<string>
#include
<string>
...
@@ -36,11 +35,9 @@ namespace messages {
...
@@ -36,11 +35,9 @@ namespace messages {
*/
*/
class
TapeserverProxy
{
class
TapeserverProxy
{
public:
public:
/**
/**
* Destructor.
* Destructor.
*
* Closes the listening socket created in the constructor to listen for
* connections from the vdqmd daemon.
*/
*/
virtual
~
TapeserverProxy
()
=
0
;
virtual
~
TapeserverProxy
()
=
0
;
...
...
castor/messages/TapeserverProxyDummy.cpp
View file @
0ca18445
...
@@ -21,18 +21,6 @@
...
@@ -21,18 +21,6 @@
#include
"castor/messages/TapeserverProxyDummy.hpp"
#include
"castor/messages/TapeserverProxyDummy.hpp"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
castor
::
messages
::
TapeserverProxyDummy
::
TapeserverProxyDummy
()
throw
()
{
}
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
castor
::
messages
::
TapeserverProxyDummy
::~
TapeserverProxyDummy
()
throw
()
{
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// gotRecallJobFromTapeGateway
// gotRecallJobFromTapeGateway
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
...
...
castor/messages/TapeserverProxyDummy.hpp
View file @
0ca18445
...
@@ -32,16 +32,6 @@ namespace messages {
...
@@ -32,16 +32,6 @@ namespace messages {
class
TapeserverProxyDummy
:
public
TapeserverProxy
{
class
TapeserverProxyDummy
:
public
TapeserverProxy
{
public:
public:
/**
* Constructor.
*/
TapeserverProxyDummy
()
throw
();
/**
* Destructor.
*/
~
TapeserverProxyDummy
()
throw
();
/**
/**
* Notifies the tapeserverd daemon that the mount-session child-process got
* Notifies the tapeserverd daemon that the mount-session child-process got
* a recall job from the tapegatewayd daemon.
* a recall job from the tapegatewayd daemon.
...
...
castor/messages/TapeserverProxyZmq.cpp
View file @
0ca18445
...
@@ -19,7 +19,6 @@
...
@@ -19,7 +19,6 @@
* @author Castor Dev team, castor-dev@cern.ch
* @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
*****************************************************************************/
#include
"castor/io/io.hpp"
#include
"castor/messages/Heartbeat.pb.h"
#include
"castor/messages/Heartbeat.pb.h"
#include
"castor/messages/Header.pb.h"
#include
"castor/messages/Header.pb.h"
#include
"castor/messages/Constants.hpp"
#include
"castor/messages/Constants.hpp"
...
@@ -36,26 +35,16 @@
...
@@ -36,26 +35,16 @@
#include
"castor/messages/TapeserverProxyZmq.hpp"
#include
"castor/messages/TapeserverProxyZmq.hpp"
#include
"castor/messages/TapeUnmounted.pb.h"
#include
"castor/messages/TapeUnmounted.pb.h"
#include
"castor/messages/TapeUnmountStarted.pb.h"
#include
"castor/messages/TapeUnmountStarted.pb.h"
#include
"castor/tape/tapegateway/ClientType.hpp"