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
eac9d34f
Commit
eac9d34f
authored
Aug 14, 2015
by
Daniele Kruse
Browse files
Removed the tapeserver/client dir along with all its consequences
parent
2392edc7
Changes
29
Hide whitespace changes
Inline
Side-by-side
tapeserver/castor/tape/tapeserver/CMakeLists.txt
View file @
eac9d34f
...
...
@@ -36,7 +36,6 @@ set(CTEST_OUTPUT_ON_FAILURE 1)
#set(TEST_LIBS "")
# Add parts first in dependency order
add_subdirectory
(
client
)
add_subdirectory
(
SCSI
)
add_subdirectory
(
drive
)
add_subdirectory
(
system
)
...
...
tapeserver/castor/tape/tapeserver/client/CMakeLists.txt
deleted
100644 → 0
View file @
2392edc7
tapeserver/castor/tape/tapeserver/client/ClientInterface.hpp
deleted
100644 → 0
View file @
2392edc7
/******************************************************************************
*
* 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
*****************************************************************************/
/*
* Author: dcome
*
* Created on March 18, 2014, 12:27 PM
*/
#pragma once
#include
"castor/exception/Exception.hpp"
#include
"castor/tape/tapegateway/GatewayMessage.hpp"
#include
"castor/tape/tapegateway/VolumeMode.hpp"
#include
"castor/server/Threading.hpp"
#include
"scheduler/MountType.hpp"
namespace
castor
{
namespace
tape
{
namespace
tapeserver
{
namespace
client
{
class
ClientInterface
{
public
:
/**
* Class holding the timing information for the request/reply,
* and the message sequence Id.
*/
class
RequestReport
{
public:
RequestReport
()
:
transactionId
(
""
),
connectDuration
(
0
),
sendRecvDuration
(
0
)
{}
std
::
string
transactionId
;
double
connectDuration
;
double
sendRecvDuration
;
};
/**
* Class holding the result of a Volume request
*/
class
VolumeInfo
{
public:
VolumeInfo
()
{};
/** The VID we will work on */
std
::
string
vid
;
/** The density of the volume */
std
::
string
density
;
/** The label field seems to be in disuse */
std
::
string
labelObsolete
;
/** The mount type: archive or retrieve */
cta
::
MountType
::
Enum
mountType
;
};
/**
* Reports end of session to the client. This should be the last call to
* the client.
* @param transactionReport Placeholder to network timing information,
* populated during the call and used by the caller to log performance
* and context information
* @param errorMsg (sent to the client)
* @param errorCode (sent to the client)
*/
virtual
void
reportEndOfSessionWithError
(
const
std
::
string
&
errorMsg
,
int
errorCode
,
RequestReport
&
transactionReport
)
=
0
;
/**
* Reports end of session to the client. This should be the last call to
* the client.
*/
virtual
void
reportEndOfSession
(
RequestReport
&
report
)
=
0
;
virtual
~
ClientInterface
(){}
};
}}}}
tapeserver/castor/tape/tapeserver/client/ClientProxy.cpp
deleted
100644 → 0
View file @
2392edc7
/******************************************************************************
*
* 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
*****************************************************************************/
#include
"castor/io/ClientSocket.hpp"
#include
"castor/tape/tapegateway/EndNotificationErrorReport.hpp"
#include
"castor/tape/tapegateway/EndNotification.hpp"
#include
"castor/tape/tapegateway/NoMoreFiles.hpp"
#include
"castor/tape/tapegateway/NotificationAcknowledge.hpp"
#include
"castor/tape/tapegateway/Volume.hpp"
#include
"castor/tape/tapegateway/VolumeRequest.hpp"
#include
"castor/tape/tapeserver/client/ClientProxy.hpp"
#include
"castor/tape/tapeserver/daemon/Constants.hpp"
#include
"castor/utils/Timer.hpp"
#include
<cxxabi.h>
#include
<memory>
#include
<stdlib.h>
#include
<typeinfo>
namespace
castor
{
namespace
tape
{
namespace
tapeserver
{
namespace
client
{
//------------------------------------------------------------------------------
//ClientProxy constructor
//------------------------------------------------------------------------------
ClientProxy
::
ClientProxy
()
:
m_transactionId
(
0
)
{}
//------------------------------------------------------------------------------
//UnexpectedResponse::UnexpectedResponse
//------------------------------------------------------------------------------
ClientProxy
::
UnexpectedResponse
::
UnexpectedResponse
(
const
castor
::
IObject
*
resp
,
const
std
::
string
&
w
)
:
castor
::
exception
::
Exception
(
w
)
{
std
::
string
responseType
=
typeid
(
*
resp
).
name
();
int
status
=
-
1
;
char
*
demangled
=
abi
::
__cxa_demangle
(
responseType
.
c_str
(),
NULL
,
NULL
,
&
status
);
if
(
!
status
)
responseType
=
demangled
;
free
(
demangled
);
getMessage
()
<<
" Response type was: "
<<
responseType
;
}
//------------------------------------------------------------------------------
//requestResponseSession
//------------------------------------------------------------------------------
tapegateway
::
GatewayMessage
*
ClientProxy
::
requestResponseSession
(
const
tapegateway
::
GatewayMessage
&
req
,
RequestReport
&
report
,
int
timeout
)
{
std
::
ostringstream
msg
;
msg
<<
__FUNCTION__
<<
": Gatway communication is not supported in the CTA"
" version of tapeserverd"
;
throw
castor
::
exception
::
Exception
(
msg
.
str
());
}
//------------------------------------------------------------------------------
//fetchVolumeId
//------------------------------------------------------------------------------
void
ClientProxy
::
fetchVolumeId
(
VolumeInfo
&
volInfo
,
RequestReport
&
report
)
{
std
::
ostringstream
msg
;
msg
<<
__FUNCTION__
<<
": Gatway communication is not supported in the CTA"
" version of tapeserverd"
;
throw
castor
::
exception
::
Exception
(
msg
.
str
());
}
//------------------------------------------------------------------------------
//reportEndOfSession
//------------------------------------------------------------------------------
void
ClientProxy
::
reportEndOfSession
(
RequestReport
&
transactionReport
)
{
std
::
ostringstream
msg
;
msg
<<
__FUNCTION__
<<
": Gatway communication is not supported in the CTA"
" version of tapeserverd"
;
throw
castor
::
exception
::
Exception
(
msg
.
str
());
}
//------------------------------------------------------------------------------
//reportEndOfSessionWithError
//------------------------------------------------------------------------------
void
ClientProxy
::
reportEndOfSessionWithError
(
const
std
::
string
&
errorMsg
,
int
errorCode
,
RequestReport
&
transactionReport
)
{
std
::
ostringstream
msg
;
msg
<<
__FUNCTION__
<<
": Gatway communication is not supported in the CTA"
" version of tapeserverd"
;
throw
castor
::
exception
::
Exception
(
msg
.
str
());
}
}}}}
tapeserver/castor/tape/tapeserver/client/ClientProxy.hpp
deleted
100644 → 0
View file @
2392edc7
/******************************************************************************
*
* 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
*****************************************************************************/
#pragma once
#include
"castor/exception/Exception.hpp"
#include
"castor/tape/tapegateway/GatewayMessage.hpp"
#include
"castor/tape/tapegateway/VolumeMode.hpp"
#include
"castor/tape/tapeserver/client/ClientInterface.hpp"
#include
"castor/server/Threading.hpp"
#include
"castor/server/AtomicCounter.hpp"
namespace
castor
{
namespace
tape
{
namespace
tapeserver
{
namespace
client
{
/**
* A class managing the communications with the tape server's client.
* The client address will have been received from the VDQM by the main
* process.
*/
class
ClientProxy
:
public
ClientInterface
{
public:
/**
* Constructor: contact client, gather initial information about the
* session and decide get that information ready for th user of the class
* (read/write session, first file information, etc...)
*/
ClientProxy
();
/**
* Retrieves the volume Id from the client (with transfer direction)
* Throws an EndOfSession exception
* @param report report on timing and request Id. It will still be filled
* up and can be used when a exception is thrown.
* @return the transaction id
*/
void
fetchVolumeId
(
VolumeInfo
&
volInfo
,
RequestReport
&
report
);
/**
* Reports end of session to the client. This should be the last call to
* the client.
*/
virtual
void
reportEndOfSession
(
RequestReport
&
report
);
/**
* Reports end of session to the client. This should be the last call to
* the client.
* @param transactionReport Placeholder to network timing information,
* populated during the call and used by the caller to log performance
* and context information
* @param errorMsg (sent to the client)
* @param errorCode (sent to the client)
*/
virtual
void
reportEndOfSessionWithError
(
const
std
::
string
&
errorMsg
,
int
errorCode
,
RequestReport
&
transactionReport
);
/**
* Exception thrown when the wrong response type was received from
* the client after a request. Extracts the type and prints it.
*/
class
UnexpectedResponse
:
public
castor
::
exception
::
Exception
{
public:
UnexpectedResponse
(
const
castor
::
IObject
*
resp
,
const
std
::
string
&
w
=
""
);
};
/**
* Exception marking end of session
*/
class
EndOfSession
:
public
castor
::
exception
::
Exception
{
public:
EndOfSession
(
std
::
string
w
=
""
)
:
castor
::
exception
::
Exception
(
w
)
{}
};
/**
* Exception marking end of with error
*/
class
EndOfSessionWithError
:
public
EndOfSession
{
public:
EndOfSessionWithError
(
std
::
string
w
=
""
)
:
EndOfSession
(
w
)
{}
};
private:
/**
* A helper function managing a single request-response session with the
* client.
* @param req the request to send to the client
* @param report Report of the connection and request-reply time
* @param timeout (optional) read response timeout (castor wide default if
* not set, currently 20 seconds)
* @return the response from the client
*/
tapegateway
::
GatewayMessage
*
requestResponseSession
(
const
tapegateway
::
GatewayMessage
&
req
,
RequestReport
&
report
,
int
timeout
=
0
);
/** The file transaction id a.k.a. aggregator transaction id. This is the
* serial number of the message in the session */
castor
::
server
::
AtomicCounter
<
uint32_t
>
m_transactionId
;
};
}
}
}
}
tapeserver/castor/tape/tapeserver/client/ClientSimSingleReply.hpp
deleted
100644 → 0
View file @
2392edc7
/******************************************************************************
*
* 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
*****************************************************************************/
#pragma once
#include
"../../tpcp/TpcpCommand.hpp"
#include
<memory>
#include
"castor/tape/tapegateway/FileToMigrateStruct.hpp"
#include
"castor/tape/tapegateway/FilesToMigrateList.hpp"
#include
"castor/tape/tapegateway/FileToRecallStruct.hpp"
#include
"castor/tape/tapegateway/FilesToRecallList.hpp"
namespace
castor
{
namespace
tape
{
namespace
tapeserver
{
namespace
client
{
/**
* A templated class, reusing code of TpcpCommand which simulates the
* tapegateway part of the client communication with the server. The
* constructor will hence setup a client callback socket and wait. The
* method processRequest will wait for a message and reply with the type
* chosen on template implementation.
*/
template
<
class
ReplyType
>
class
ClientSimSingleReply
:
public
tpcp
::
TpcpCommand
{
public:
ClientSimSingleReply
(
uint32_t
volReqId
,
const
std
::
string
&
vid
,
const
std
::
string
&
density
,
bool
breakTransaction
=
false
)
:
TpcpCommand
(
"clientSimulator::clientSimulator"
),
m_vid
(
vid
),
m_density
(
density
),
m_breakTransaction
(
breakTransaction
)
{
m_volReqId
=
volReqId
;
setupCallbackSock
();
}
virtual
~
ClientSimSingleReply
()
throw
()
{}
struct
ipPort
{
ipPort
(
uint32_t
i
,
uint16_t
p
)
:
ip
(
i
),
port
(
p
)
{}
union
{
uint32_t
ip
;
struct
{
uint8_t
a
;
uint8_t
b
;
uint8_t
c
;
uint8_t
d
;
}
parts
;
};
uint16_t
port
;
};
struct
ipPort
getCallbackAddress
()
{
unsigned
short
port
=
0
;
/* This is a workaround for the usage of unsigned long for ips in castor
* (it's not fine anymore on 64 bits systems).
*/
unsigned
long
ip
=
0
;
m_callbackSock
.
getPortIp
(
port
,
ip
);
return
ipPort
(
ip
,
port
);
}
void
sessionLoop
()
{
processFirstRequest
();
m_callbackSock
.
close
();
}
protected:
// Place holders for pure virtual members of TpcpCommand we don't
// use in the simulator
virtual
void
usage
(
std
::
ostream
&
)
const
throw
()
{}
virtual
void
parseCommandLine
(
const
int
,
char
**
)
{}
virtual
void
checkAccessToDisk
()
const
{}
virtual
void
checkAccessToTape
()
const
{}
virtual
void
requestDriveFromVdqm
(
char
*
const
)
{}
virtual
void
performTransfer
()
{}
// The functions we actually implement in the simulator
virtual
void
sendVolumeToTapeServer
(
const
tapegateway
::
VolumeRequest
&
volumeRequest
,
castor
::
io
::
AbstractTCPSocket
&
connection
)
const
{}
virtual
bool
dispatchMsgHandler
(
castor
::
IObject
*
const
obj
,
castor
::
io
::
AbstractSocket
&
sock
)
{
return
false
;
}
private:
// Process the first request which should be getVolume
void
processFirstRequest
()
{
// Accept the next connection
std
::
unique_ptr
<
castor
::
io
::
ServerSocket
>
clientConnection
(
m_callbackSock
.
accept
());
// Read in the message sent by the tapebridge
std
::
unique_ptr
<
castor
::
IObject
>
obj
(
clientConnection
->
readObject
());
// Convert to a gateway message (for transactionId)
tapegateway
::
GatewayMessage
&
gm
=
dynamic_cast
<
tapegateway
::
GatewayMessage
&>
(
*
obj
);
// Reply with our own type and transaction id
ReplyType
repl
;
repl
.
setAggregatorTransactionId
(
gm
.
aggregatorTransactionId
()
^
(
m_breakTransaction
?
666
:
0
));
repl
.
setMountTransactionId
(
m_volReqId
);
clientConnection
->
sendObject
(
repl
);
}
// Notify the client
void
sendEndNotificationErrorReport
(
const
uint64_t
tapebridgeTransactionId
,
const
int
errorCode
,
const
std
::
string
&
errorMessage
,
castor
::
io
::
AbstractSocket
&
sock
)
throw
();
std
::
string
m_vid
;
std
::
string
m_volLabel
;
std
::
string
m_density
;
bool
m_breakTransaction
;
};
/**
* Specific version for the FilesToMigrateList: we want
* to pass a non empty list, so it has to be a little bit less trivial.
*/
template
<
>
void
ClientSimSingleReply
<
castor
::
tape
::
tapegateway
::
FilesToMigrateList
>::
processFirstRequest
()
{
using
namespace
castor
::
tape
::
tapegateway
;
// Accept the next connection
std
::
unique_ptr
<
castor
::
io
::
ServerSocket
>
clientConnection
(
m_callbackSock
.
accept
());
// Read in the message sent by the tapebridge
std
::
unique_ptr
<
castor
::
IObject
>
obj
(
clientConnection
->
readObject
());
// Convert to a gateway message (for transactionId)
GatewayMessage
&
gm
=
dynamic_cast
<
tapegateway
::
GatewayMessage
&>
(
*
obj
);
// Reply with our own type and transaction id
FilesToMigrateList
repl
;
repl
.
setAggregatorTransactionId
(
gm
.
aggregatorTransactionId
()
^
(
m_breakTransaction
?
666
:
0
));
repl
.
setMountTransactionId
(
m_volReqId
);
repl
.
filesToMigrate
().
push_back
(
new
FileToMigrateStruct
());
clientConnection
->
sendObject
(
repl
);
}
/**
* Specific version for the FilesToRecallList: we want
* to pass a non empty list, so it has to be a little bit less trivial.
*/
template
<
>
void
ClientSimSingleReply
<
castor
::
tape
::
tapegateway
::
FilesToRecallList
>::
processFirstRequest
()
{
using
namespace
castor
::
tape
::
tapegateway
;
// Accept the next connection
std
::
unique_ptr
<
castor
::
io
::
ServerSocket
>
clientConnection
(
m_callbackSock
.
accept
());
// Read in the message sent by the tapebridge
std
::
unique_ptr
<
castor
::
IObject
>
obj
(
clientConnection
->
readObject
());
// Convert to a gateway message (for transactionId)
GatewayMessage
&
gm
=
dynamic_cast
<
tapegateway
::
GatewayMessage
&>
(
*
obj
);
// Reply with our own type and transaction id
FilesToRecallList
repl
;
repl
.
setAggregatorTransactionId
(
gm
.
aggregatorTransactionId
()
^
(
m_breakTransaction
?
666
:
0
));
repl
.
setMountTransactionId
(
m_volReqId
);
repl
.
filesToRecall
().
push_back
(
new
FileToRecallStruct
());
clientConnection
->
sendObject
(
repl
);
}
}
}
}
}
tapeserver/castor/tape/tapeserver/client/FakeClient.hpp
deleted
100644 → 0
View file @
2392edc7
/******************************************************************************
*
* 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
*****************************************************************************/
#pragma once
#include
"castor/tape/tapeserver/client/ClientInterface.hpp"
#include
"castor/tape/tapegateway/FilesToRecallList.hpp"
#include
"castor/tape/tapegateway/FileToRecallStruct.hpp"
#include
<memory>
#include
<gtest/gtest.h>
#include
<gmock/gmock.h>
namespace
unitTests
{
using
namespace
castor
::
tape
;
const
int
init_value
=-
1
;
const
unsigned
int
nbFile
=
5
;
class
FakeClient
:
public
castor
::
tape
::
tapeserver
::
client
::
ClientInterface
{
public:
FakeClient
(
int
nbCalls
=
0
)
:
m_current
(
0
)
/*current_succes_migration(init_value),current_failled_migration(init_value),
current_succes_recall(0),current_failled_recall(0)*/
{
for
(
int
n
=
0
;
n
<
nbCalls
;
++
n
)
{
std
::
unique_ptr
<
tapegateway
::
FilesToRecallList
>
ptr
(
new
tapegateway
::
FilesToRecallList
());
for
(
unsigned
int
i
=
0
;
i
<
nbFile
;
++
i
)
{
ptr
->
filesToRecall
().
push_back
(
new
tapegateway
::
FileToRecallStruct
);