Commit e3e896f1 authored by Eric Cano's avatar Eric Cano
Browse files

Renamed ClientInterface class as ClientProxy so an interface to it can be created (for unit tests).

parent 8f1a0706
......@@ -21,14 +21,14 @@ add_executable(tapeserver-mm
tapeserver-mm.cpp
RecallTaskInjector.cpp
Exception.cpp
ClientInterface.cpp)
ClientProxy.cpp)
target_link_libraries(tapeserver-mm
TapeDrive Exception SCSI System Utils File
castorcommon castorclient castorTapeServerThreading castortapeutils
castortapegatewayprotocol)
add_library(tapeserver ClientInterface.cpp MountSession.cpp)
add_library(tapeserver ClientProxy.cpp MountSession.cpp)
add_library(tapeserverdTest
ClientSimulator.cpp
......
/******************************************************************************
* clientInterface.cpp
* ClientProxy.cpp
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
......@@ -22,7 +22,7 @@
* @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
#include "ClientInterface.hpp"
#include "ClientProxy.hpp"
#include "castor/io/ClientSocket.hpp"
#include "castor/tape/tapegateway/VolumeRequest.hpp"
#include "castor/tape/tapegateway/Volume.hpp"
......@@ -46,10 +46,10 @@
using namespace castor::tape;
castor::tape::tapeserver::daemon::
ClientInterface::ClientInterface(const legacymsg::RtcpJobRqstMsgBody& clientRequest)
ClientProxy::ClientProxy(const legacymsg::RtcpJobRqstMsgBody& clientRequest)
throw (castor::tape::Exception): m_request(clientRequest) {}
castor::tape::tapeserver::daemon::ClientInterface::UnexpectedResponse::
castor::tape::tapeserver::daemon::ClientProxy::UnexpectedResponse::
UnexpectedResponse(const castor::IObject* resp, const std::string & w):
castor::tape::Exception(w) {
std::string responseType = typeid(*resp).name();
......@@ -62,7 +62,7 @@ castor::tape::Exception(w) {
}
tapegateway::GatewayMessage *
castor::tape::tapeserver::daemon::ClientInterface::requestResponseSession(
castor::tape::tapeserver::daemon::ClientProxy::requestResponseSession(
const tapegateway::GatewayMessage &req,
RequestReport & report)
throw (castor::tape::Exception)
......@@ -106,7 +106,7 @@ throw (castor::tape::Exception)
return ret;
}
void castor::tape::tapeserver::daemon::ClientInterface::fetchVolumeId(
void castor::tape::tapeserver::daemon::ClientProxy::fetchVolumeId(
VolumeInfo & volInfo, RequestReport &report)
throw (castor::tape::Exception) {
// 1) Build the request
......@@ -149,7 +149,7 @@ throw (castor::tape::Exception) {
}
}
void castor::tape::tapeserver::daemon::ClientInterface::reportEndOfSession(
void castor::tape::tapeserver::daemon::ClientProxy::reportEndOfSession(
RequestReport &transactionReport)
throw (castor::tape::Exception) {
// 1) Build the report
......@@ -172,7 +172,7 @@ throw (castor::tape::Exception) {
}
void castor::tape::tapeserver::daemon::ClientInterface::reportEndOfSessionWithError(
void castor::tape::tapeserver::daemon::ClientProxy::reportEndOfSessionWithError(
const std::string & errorMsg, int errorCode, RequestReport &transactionReport)
throw (castor::tape::Exception) {
// 1) Build the report
......@@ -198,7 +198,7 @@ throw (castor::tape::Exception) {
tapegateway::FilesToMigrateList *
castor::tape::tapeserver::daemon::ClientInterface::getFilesToMigrate(
castor::tape::tapeserver::daemon::ClientProxy::getFilesToMigrate(
uint64_t files, uint64_t bytes, RequestReport& report)
throw (castor::tape::Exception) {
// 1) Build the request
......@@ -233,7 +233,7 @@ throw (castor::tape::Exception) {
}
}
void castor::tape::tapeserver::daemon::ClientInterface::reportMigrationResults(
void castor::tape::tapeserver::daemon::ClientProxy::reportMigrationResults(
tapegateway::FileMigrationReportList & migrationReport,
RequestReport& report) throw (castor::tape::Exception) {
// 1) The request is provided already fleshed out by the user. We have to
......@@ -272,7 +272,7 @@ tapegateway::FileMigrationReportList & migrationReport,
}
tapegateway::FilesToRecallList *
castor::tape::tapeserver::daemon::ClientInterface::getFilesToRecall(
castor::tape::tapeserver::daemon::ClientProxy::getFilesToRecall(
uint64_t files, uint64_t bytes, RequestReport& report)
throw (castor::tape::Exception) {
// 1) Build the request
......@@ -307,7 +307,7 @@ throw (castor::tape::Exception) {
}
}
void castor::tape::tapeserver::daemon::ClientInterface::reportRecallResults(
void castor::tape::tapeserver::daemon::ClientProxy::reportRecallResults(
tapegateway::FileRecallReportList & recallReport,
RequestReport& report) throw (castor::tape::Exception) {
// 1) The request is provided already fleshed out by the user. We have to
......
......@@ -44,7 +44,7 @@ namespace daemon {
* The client address will have been received from the VDQM by the main
* process.
*/
class ClientInterface {
class ClientProxy {
public:
/**
* Constructor: contact client, gather initial information about the
......@@ -52,7 +52,7 @@ namespace daemon {
* (read/write session, first file information, etc...)
* @param clientRequest the client information as sent by VDQM.
*/
ClientInterface(const legacymsg::RtcpJobRqstMsgBody & clientRequest)
ClientProxy(const legacymsg::RtcpJobRqstMsgBody & clientRequest)
throw (castor::tape::Exception);
/**
......
......@@ -25,7 +25,7 @@
#include <gtest/gtest.h>
#include "ClientSimulator.hpp"
#include "ClientSimSingleReply.hpp"
#include "ClientInterface.hpp"
#include "ClientProxy.hpp"
#include "../threading/Threading.hpp"
#include "castor/log/StringLogger.hpp"
#include "MountSession.hpp"
......@@ -70,9 +70,9 @@ TEST(tapeServerClientInterface, VolReqVol) {
VDQMjob.clientPort = clientAddr.port;
VDQMjob.volReqId = volReq;
// Setup an interface to it.
ClientInterface cInterf(VDQMjob);
ClientInterface::VolumeInfo volInfo;
ClientInterface::RequestReport reqRep;
ClientProxy cInterf(VDQMjob);
ClientProxy::VolumeInfo volInfo;
ClientProxy::RequestReport reqRep;
ASSERT_NO_THROW(cInterf.fetchVolumeId(volInfo, reqRep));
// Cleanup
csVolRun.wait();
......@@ -98,10 +98,10 @@ TEST(tapeServerClientInterface, VolReqNoMore) {
VDQMjob.clientPort = clientAddr.port;
VDQMjob.volReqId = volReq;
// Setup an interface to it.
ClientInterface cInterf(VDQMjob);
ClientInterface::VolumeInfo volInfo;
ClientInterface::RequestReport reqRep;
ASSERT_THROW(cInterf.fetchVolumeId(volInfo, reqRep), ClientInterface::EndOfSession);
ClientProxy cInterf(VDQMjob);
ClientProxy::VolumeInfo volInfo;
ClientProxy::RequestReport reqRep;
ASSERT_THROW(cInterf.fetchVolumeId(volInfo, reqRep), ClientProxy::EndOfSession);
// Cleanup
csVolRun.wait();
}
......@@ -126,10 +126,10 @@ TEST(tapeServerClientInterface, VolReqEndError) {
VDQMjob.clientPort = clientAddr.port;
VDQMjob.volReqId = volReq;
// Setup an interface to it.
ClientInterface cInterf(VDQMjob);
ClientInterface::VolumeInfo volInfo;
ClientInterface::RequestReport reqRep;
ASSERT_THROW(cInterf.fetchVolumeId(volInfo, reqRep), ClientInterface::EndOfSession);
ClientProxy cInterf(VDQMjob);
ClientProxy::VolumeInfo volInfo;
ClientProxy::RequestReport reqRep;
ASSERT_THROW(cInterf.fetchVolumeId(volInfo, reqRep), ClientProxy::EndOfSession);
// Cleanup
csVolRun.wait();
}
......@@ -154,10 +154,10 @@ TEST(tapeServerClientInterface, VolReqVolReq) {
VDQMjob.clientPort = clientAddr.port;
VDQMjob.volReqId = volReq;
// Setup an interface to it.
ClientInterface cInterf(VDQMjob);
ClientInterface::VolumeInfo volInfo;
ClientInterface::RequestReport reqRep;
ASSERT_THROW(cInterf.fetchVolumeId(volInfo, reqRep), ClientInterface::UnexpectedResponse);
ClientProxy cInterf(VDQMjob);
ClientProxy::VolumeInfo volInfo;
ClientProxy::RequestReport reqRep;
ASSERT_THROW(cInterf.fetchVolumeId(volInfo, reqRep), ClientProxy::UnexpectedResponse);
// Cleanup
csVolRun.wait();
}
......@@ -182,10 +182,10 @@ TEST(tapeServerClientInterface, VolReqVolSeqBreak) {
VDQMjob.clientPort = clientAddr.port;
VDQMjob.volReqId = volReq;
// Setup an interface to it.
ClientInterface cInterf(VDQMjob);
ClientInterface::VolumeInfo volInfo;
ClientInterface::RequestReport reqRep;
ASSERT_THROW(cInterf.fetchVolumeId(volInfo, reqRep), ClientInterface::UnexpectedResponse);
ClientProxy cInterf(VDQMjob);
ClientProxy::VolumeInfo volInfo;
ClientProxy::RequestReport reqRep;
ASSERT_THROW(cInterf.fetchVolumeId(volInfo, reqRep), ClientProxy::UnexpectedResponse);
// Cleanup
csVolRun.wait();
}
......@@ -210,9 +210,9 @@ TEST(tapeServerClientInterface, EndSessionNotifAck) {
VDQMjob.clientPort = clientAddr.port;
VDQMjob.volReqId = volReq;
// Setup an interface to it.
ClientInterface cInterf(VDQMjob);
ClientInterface::VolumeInfo volInfo;
ClientInterface::RequestReport reqRep;
ClientProxy cInterf(VDQMjob);
ClientProxy::VolumeInfo volInfo;
ClientProxy::RequestReport reqRep;
ASSERT_NO_THROW(cInterf.reportEndOfSession(reqRep));
// Cleanup
csVolRun.wait();
......@@ -238,10 +238,10 @@ TEST(tapeServerClientInterface, EndSessionNotifAckSeqBreak) {
VDQMjob.clientPort = clientAddr.port;
VDQMjob.volReqId = volReq;
// Setup an interface to it.
ClientInterface cInterf(VDQMjob);
ClientInterface::VolumeInfo volInfo;
ClientInterface::RequestReport reqRep;
ASSERT_THROW(cInterf.reportEndOfSession(reqRep), ClientInterface::UnexpectedResponse);
ClientProxy cInterf(VDQMjob);
ClientProxy::VolumeInfo volInfo;
ClientProxy::RequestReport reqRep;
ASSERT_THROW(cInterf.reportEndOfSession(reqRep), ClientProxy::UnexpectedResponse);
// Cleanup
csVolRun.wait();
}
......@@ -266,10 +266,10 @@ TEST(tapeServerClientInterface, EndSessionVolReq) {
VDQMjob.clientPort = clientAddr.port;
VDQMjob.volReqId = volReq;
// Setup an interface to it.
ClientInterface cInterf(VDQMjob);
ClientInterface::VolumeInfo volInfo;
ClientInterface::RequestReport reqRep;
ASSERT_THROW(cInterf.reportEndOfSession(reqRep), ClientInterface::UnexpectedResponse);
ClientProxy cInterf(VDQMjob);
ClientProxy::VolumeInfo volInfo;
ClientProxy::RequestReport reqRep;
ASSERT_THROW(cInterf.reportEndOfSession(reqRep), ClientProxy::UnexpectedResponse);
// Cleanup
csVolRun.wait();
}
......@@ -294,9 +294,9 @@ TEST(tapeServerClientInterface, EndSessionErrorNotifAck) {
VDQMjob.clientPort = clientAddr.port;
VDQMjob.volReqId = volReq;
// Setup an interface to it.
ClientInterface cInterf(VDQMjob);
ClientInterface::VolumeInfo volInfo;
ClientInterface::RequestReport reqRep;
ClientProxy cInterf(VDQMjob);
ClientProxy::VolumeInfo volInfo;
ClientProxy::RequestReport reqRep;
ASSERT_NO_THROW(cInterf.reportEndOfSessionWithError("SNAFU!", SEINTERNAL, reqRep));
// Cleanup
csVolRun.wait();
......@@ -322,11 +322,11 @@ TEST(tapeServerClientInterface, EndSessionErrorVolReq) {
VDQMjob.clientPort = clientAddr.port;
VDQMjob.volReqId = volReq;
// Setup an interface to it.
ClientInterface cInterf(VDQMjob);
ClientInterface::VolumeInfo volInfo;
ClientInterface::RequestReport reqRep;
ClientProxy cInterf(VDQMjob);
ClientProxy::VolumeInfo volInfo;
ClientProxy::RequestReport reqRep;
ASSERT_THROW(cInterf.reportEndOfSessionWithError("SNAFU!", SEINTERNAL, reqRep),
ClientInterface::UnexpectedResponse);
ClientProxy::UnexpectedResponse);
// Cleanup
csVolRun.wait();
}
......@@ -351,11 +351,11 @@ TEST(tapeServerClientInterface, EndSessionErrorNotifAckSeqBreak) {
VDQMjob.clientPort = clientAddr.port;
VDQMjob.volReqId = volReq;
// Setup an interface to it.
ClientInterface cInterf(VDQMjob);
ClientInterface::VolumeInfo volInfo;
ClientInterface::RequestReport reqRep;
ClientProxy cInterf(VDQMjob);
ClientProxy::VolumeInfo volInfo;
ClientProxy::RequestReport reqRep;
ASSERT_THROW(cInterf.reportEndOfSessionWithError("SNAFU!", SEINTERNAL, reqRep),
ClientInterface::UnexpectedResponse);
ClientProxy::UnexpectedResponse);
// Cleanup
csVolRun.wait();
}
......@@ -380,9 +380,9 @@ TEST(tapeServerClientInterface, FilesToMigrateReqFilesToMigrate) {
VDQMjob.clientPort = clientAddr.port;
VDQMjob.volReqId = volReq;
// Setup an interface to it.
ClientInterface cInterf(VDQMjob);
ClientInterface::VolumeInfo volInfo;
ClientInterface::RequestReport reqRep;
ClientProxy cInterf(VDQMjob);
ClientProxy::VolumeInfo volInfo;
ClientProxy::RequestReport reqRep;
// We are responsible for the freeing of the result: chuck it into an auto_ptr.
std::auto_ptr<FilesToMigrateList> resp;
ASSERT_NO_THROW(resp.reset(cInterf.getFilesToMigrate(10, 10, reqRep)));
......@@ -411,9 +411,9 @@ TEST(tapeServerClientInterface, FilesToMigrateReqNoMore) {
VDQMjob.clientPort = clientAddr.port;
VDQMjob.volReqId = volReq;
// Setup an interface to it.
ClientInterface cInterf(VDQMjob);
ClientInterface::VolumeInfo volInfo;
ClientInterface::RequestReport reqRep;
ClientProxy cInterf(VDQMjob);
ClientProxy::VolumeInfo volInfo;
ClientProxy::RequestReport reqRep;
// We are responsible for the freeing of the result: chuck it into an auto_ptr.
std::auto_ptr<FilesToMigrateList> resp;
ASSERT_NO_THROW(resp.reset(cInterf.getFilesToMigrate(10, 10, reqRep)));
......@@ -442,12 +442,12 @@ TEST(tapeServerClientInterface, FilesToMigrateReqFilesToMigrateSeqBreak) {
VDQMjob.clientPort = clientAddr.port;
VDQMjob.volReqId = volReq;
// Setup an interface to it.
ClientInterface cInterf(VDQMjob);
ClientInterface::VolumeInfo volInfo;
ClientInterface::RequestReport reqRep;
ClientProxy cInterf(VDQMjob);
ClientProxy::VolumeInfo volInfo;
ClientProxy::RequestReport reqRep;
// We are responsible for the freeing of the result: chuck it into an auto_ptr.
std::auto_ptr<FilesToMigrateList> resp;
ASSERT_THROW(resp.reset(cInterf.getFilesToMigrate(10, 10, reqRep)),ClientInterface::UnexpectedResponse);
ASSERT_THROW(resp.reset(cInterf.getFilesToMigrate(10, 10, reqRep)),ClientProxy::UnexpectedResponse);
// Cleanup
csVolRun.wait();
}
......
......@@ -25,7 +25,7 @@
#include "MountSession.hpp"
#include "castor/log/LogContext.hpp"
#include "castor/tape/tapeserver/exception/Exception.hpp"
#include "ClientInterface.hpp"
#include "ClientProxy.hpp"
#include "log.h"
#include "stager_client_commandline.h"
#include "castor/tape/utils/utils.hpp"
......@@ -53,10 +53,10 @@ throw (castor::tape::Exception) {
LogContext::ScopedParam sp05(lc, Param("driveUnit", m_request.driveUnit));
LogContext::ScopedParam sp06(lc, Param("dgn", m_request.dgn));
// 2a) Get initial information from the client
ClientInterface::RequestReport reqReport;
ClientProxy::RequestReport reqReport;
try {
m_clientIf.fetchVolumeId(m_volInfo, reqReport);
} catch(ClientInterface::EndOfSession & eof) {
} catch(ClientProxy::EndOfSession & eof) {
std::stringstream fullError("Received end of session from client when requesting Volume");
fullError << eof.what();
lc.log(LOG_ERR, fullError.str());
......@@ -67,7 +67,7 @@ throw (castor::tape::Exception) {
LogContext::ScopedParam sp10(lc, Param("ErrorMsg", fullError.str()));
lc.log(LOG_ERR, "Notified client of end session with error");
return;
} catch (ClientInterface::UnexpectedResponse & unexp) {
} catch (ClientProxy::UnexpectedResponse & unexp) {
std::stringstream fullError("Received unexpected response from client when requesting Volume");
fullError << unexp.what();
lc.log(LOG_ERR, fullError.str());
......@@ -124,7 +124,7 @@ void castor::tape::tapeserver::daemon::MountSession::executeRead(LogContext & lc
LogContext::ScopedParam sp08(lc, Param("density", m_volInfo.density));
lc.log(LOG_ERR, "Drive unit not found");
ClientInterface::RequestReport reqReport;
ClientProxy::RequestReport reqReport;
std::stringstream errMsg("Drive unit not found");
errMsg << lc;
m_clientIf.reportEndOfSessionWithError("Drive unit not found", SEINTERNAL, reqReport);
......
......@@ -29,7 +29,7 @@
#include "castor/log/LogContext.hpp"
#include "castor/tape/tapeserver/system/Wrapper.hpp"
#include "castor/tape/utils/utils.hpp"
#include "ClientInterface.hpp"
#include "ClientProxy.hpp"
using namespace castor::tape;
using namespace castor::log;
......@@ -56,8 +56,8 @@ namespace daemon {
private:
legacymsg::RtcpJobRqstMsgBody m_request;
castor::log::Logger & m_logger;
ClientInterface m_clientIf;
ClientInterface::VolumeInfo m_volInfo;
ClientProxy m_clientIf;
ClientProxy::VolumeInfo m_volInfo;
System::virtualWrapper & m_sysWrapper;
utils::TpconfigLines m_tpConfig;
/** sub-part of execute for the read sessions */
......
......@@ -22,7 +22,7 @@ namespace daemon {
RecallTaskInjector::RecallTaskInjector(MemoryManager & mm,
TapeReadSingleThread & tapeReader,DiskWriteThreadPool & diskWriter,
ClientInterface& client,castor::log::LogContext& lc) :
ClientProxy& client,castor::log::LogContext& lc) :
m_thread(*this),m_memManager(mm),
m_tapeReader(tapeReader),m_diskWriter(diskWriter),
m_client(client),m_lc(lc)
......@@ -75,7 +75,7 @@ void RecallTaskInjector::injectBulkRecalls(const std::vector<castor::tape::tapeg
bool RecallTaskInjector::synchronousInjection(uint64_t maxFiles, uint64_t byteSizeThreshold)
{
ClientInterface::RequestReport reqReport;
ClientProxy::RequestReport reqReport;
std::auto_ptr<castor::tape::tapegateway::FilesToRecallList> filesToRecallList(m_client.getFilesToRecall(maxFiles,byteSizeThreshold,reqReport));
LogContext::ScopedParam sp[]={
......@@ -106,7 +106,7 @@ void RecallTaskInjector::WorkerThread::run()
while (1) {
Request req = _this.m_queue.pop();
printf("RecallJobInjector:run: about to call client interface\n");
ClientInterface::RequestReport reqReport;
ClientProxy::RequestReport reqReport;
std::auto_ptr<tapegateway::FilesToRecallList> filesToRecallList(_this.m_client.getFilesToRecall(req.nbMaxFiles, req.byteSizeThreshold,reqReport));
LogContext::ScopedParam sp01(_this.m_lc, Param("transactionId", reqReport.transactionId));
......
......@@ -34,7 +34,7 @@
#include "castor/tape/tapeserver/daemon/DiskWriteFileTask.hpp"
#include "castor/tape/tapeserver/daemon/RecallJob.hpp"
#include "castor/tape/tapeserver/daemon/TapeWriteFileTask.hpp"
#include "castor/tape/tapeserver/daemon/ClientInterface.hpp"
#include "castor/tape/tapeserver/daemon/ClientProxy.hpp"
#include "castor/log/LogContext.hpp"
#include "castor/tape/tapegateway/FileToRecallStruct.hpp"
......@@ -51,7 +51,7 @@ public:
RecallTaskInjector(MemoryManager & mm,
TapeReadSingleThread & tapeReader,
DiskWriteThreadPool & diskWriter,ClientInterface& client,
DiskWriteThreadPool & diskWriter,ClientProxy& client,
castor::log::LogContext& lc);
......
......@@ -25,7 +25,7 @@
#include <gtest/gtest.h>
#include "ClientSimulator.hpp"
#include "ClientSimSingleReply.hpp"
#include "ClientInterface.hpp"
#include "ClientProxy.hpp"
#include "../threading/Threading.hpp"
#include "castor/log/StringLogger.hpp"
#include "MountSession.hpp"
......
......@@ -87,7 +87,7 @@ add_executable(castorUnitTests
../castor/log/LogContextTest.cpp
../castor/log/StringLoggerTest.cpp
../castor/server/DaemonTest.cpp
../castor/tape/tapeserver/daemon/ClientInterfaceTest.cpp
../castor/tape/tapeserver/daemon/ClientProxyTest.cpp
../castor/tape/tapeserver/daemon/DriveCatalogue.cpp
../castor/tape/tapeserver/daemon/DriveCatalogueTest.cpp
../castor/tape/tapeserver/daemon/DummyVdqm.cpp
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment