Skip to content
Snippets Groups Projects
Commit f09ee4cd authored by Michael Davis's avatar Michael Davis
Browse files

[cta_frontend] Adds server framework for handling Admin commands

parent 198511d4
No related branches found
No related tags found
No related merge requests found
......@@ -40,7 +40,7 @@ add_subdirectory(messages)
add_definitions(-DXRDSSI_DEBUG)
include_directories(../xroot_ssi_pb)
add_library(XrdSsiCta MODULE XrdSsiCtaServiceProvider.cpp XrdSsiCtaRequestProc.cpp XrdSsiCtaEos.cpp)
add_library(XrdSsiCta MODULE XrdSsiCtaServiceProvider.cpp XrdSsiCtaRequestProc.cpp XrdSsiCtaRequestMessage.cpp)
target_link_libraries(XrdSsiCta XrdSsi-4 XrdSsiLib XrdCtaMessages ctascheduler ctacommon ctaobjectstore ctacatalogue)
set_target_properties(XrdSsiCta PROPERTIES INSTALL_RPATH ${PROTOBUF3_RPATH})
......
......@@ -19,37 +19,39 @@
#include "XrdSsiPbException.hpp"
using XrdSsiPb::PbException;
#include "xroot_plugins/messages/cta_frontend.pb.h"
#include "XrdSsiCtaEos.hpp"
#include "XrdSsiCtaRequestMessage.hpp"
#if 0
#include "common/dataStructures/ArchiveRequest.hpp"
#include "common/exception/Exception.hpp"
#ifdef XRDSSI_DEBUG
#include "XrdSsiPbDebug.hpp"
#endif
#include "XrdSsiPbResource.hpp"
#include "XrdSsiPbRequestProc.hpp"
#include "xroot_plugins/messages/cta_frontend.pb.h"
namespace cta { namespace xrd {
#include "XrdSsiCtaServiceProvider.hpp"
#endif
void RequestMessage::process(const cta::xrd::Request &request, cta::xrd::Response &response)
{
// Branch on the Request payload type
switch(request.request_case())
{
using namespace cta::xrd;
case Request::kAdmincmd:
case Request::kNotification: processNotification(request.notification(), response); break;
case Request::REQUEST_NOT_SET: throw PbException("Request message has not been set.");
default: throw PbException("Unrecognized Request message. "
"Possible Protocol Buffer version mismatch between client and server.");
}
}
namespace cta { namespace frontend {
void EosNotificationRequest::process(const cta::eos::Notification &notification, cta::xrd::Response &response)
void RequestMessage::processNotification(const cta::eos::Notification &notification, cta::xrd::Response &response)
{
switch(notification.wf().event())
{
using namespace cta::eos;
case Workflow::CLOSEW: requestProcCLOSEW (notification, response); break;
case Workflow::PREPARE: requestProcPREPARE(notification, response); break;
case Workflow::DELETE: requestProcDELETE (notification, response); break;
case Workflow::CLOSEW: processCLOSEW (notification, response); break;
case Workflow::PREPARE: processPREPARE(notification, response); break;
case Workflow::DELETE: processDELETE (notification, response); break;
default:
throw PbException("Workflow Event type " + std::to_string(notification.wf().event()) + " is not supported.");
......@@ -58,8 +60,7 @@ void EosNotificationRequest::process(const cta::eos::Notification &notification,
void EosNotificationRequest::requestProcCLOSEW(const cta::eos::Notification &notification, cta::xrd::Response &response)
void RequestMessage::processCLOSEW(const cta::eos::Notification &notification, cta::xrd::Response &response)
{
// Unpack message
......@@ -102,7 +103,7 @@ void EosNotificationRequest::requestProcCLOSEW(const cta::eos::Notification &not
void EosNotificationRequest::requestProcPREPARE(const cta::eos::Notification &notification, cta::xrd::Response &response)
void RequestMessage::processPREPARE(const cta::eos::Notification &notification, cta::xrd::Response &response)
{
// Unpack message
......@@ -140,7 +141,7 @@ void EosNotificationRequest::requestProcPREPARE(const cta::eos::Notification &no
void EosNotificationRequest::requestProcDELETE(const cta::eos::Notification &notification, cta::xrd::Response &response)
void RequestMessage::processDELETE(const cta::eos::Notification &notification, cta::xrd::Response &response)
{
// Unpack message
......@@ -174,12 +175,12 @@ void EosNotificationRequest::requestProcDELETE(const cta::eos::Notification &not
cta::log::ScopedParamContainer params(m_lc);
params.add("fileId", request.archiveFileID).add("catalogueTime", t.secs());
m_lc.log(cta::log::INFO, "In requestProcDELETE(): deleted archive file.");
m_lc.log(cta::log::INFO, "In processDELETE(): deleted archive file.");
// Set response type
response.set_type(cta::xrd::Response::RSP_SUCCESS);
}
}} // namespace cta::frontend
}} // namespace cta::xrd
/*!
* @project The CERN Tape Archive (CTA)
* @brief XRootD EOS Notification handler
* @brief CTA Frontend Message handler
* @copyright Copyright 2017 CERN
* @license 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
......@@ -21,16 +21,17 @@
#include <XrdSsi/XrdSsiEntity.hh>
#include "XrdSsiCtaServiceProvider.hpp"
#include "xroot_plugins/messages/cta_frontend.pb.h"
namespace cta { namespace frontend {
namespace cta { namespace xrd {
/*!
* EOS Notification handler class
* CTA Frontend Request Message class
*/
class EosNotificationRequest
class RequestMessage
{
public:
EosNotificationRequest(const XrdSsiEntity &client, const XrdSsiCtaServiceProvider *service) :
RequestMessage(const XrdSsiEntity &client, const XrdSsiCtaServiceProvider *service) :
m_scheduler(service->getScheduler()),
m_lc(service->getLogContext()),
m_instance_name(client.name) {}
......@@ -38,19 +39,27 @@ public:
/*!
* Process the Notification request
*
* @param[in] notification Notification request message from EOS WFE
* @param[in] request
* @param[out] response Response message to return to EOS
*/
void process(const cta::eos::Notification &notification, cta::xrd::Response &response);
void process(const cta::xrd::Request &request, cta::xrd::Response &response);
private:
/*!
* Process the EOS WFE Notification message type
*
* @param[in] notification Notification request message from EOS WFE
* @param[out] response Response message to return to EOS
*/
void processNotification(const cta::eos::Notification &notification, cta::xrd::Response &response);
/*!
* Process the CLOSEW workflow event
*
* @param[in] notification Notification request message from EOS WFE
* @param[out] response Response message to return to EOS
*/
void requestProcCLOSEW(const cta::eos::Notification &notification, cta::xrd::Response &response);
void processCLOSEW(const cta::eos::Notification &notification, cta::xrd::Response &response);
/*!
* Process the PREPARE workflow event
......@@ -58,7 +67,7 @@ private:
* @param[in] notification Notification request message from EOS WFE
* @param[out] response Response message to return to EOS
*/
void requestProcPREPARE(const cta::eos::Notification &notification, cta::xrd::Response &response);
void processPREPARE(const cta::eos::Notification &notification, cta::xrd::Response &response);
/*!
* Process the DELETE workflow event
......@@ -66,7 +75,7 @@ private:
* @param[in] notification Notification request message from EOS WFE
* @param[out] response Response message to return to EOS
*/
void requestProcDELETE(const cta::eos::Notification &notification, cta::xrd::Response &response);
void processDELETE(const cta::eos::Notification &notification, cta::xrd::Response &response);
// Member variables
......@@ -75,4 +84,4 @@ private:
const char * const m_instance_name; //< Instance name = XRootD client name
};
}} // namespace cta::frontend
}} // namespace cta::xrd
......@@ -24,10 +24,9 @@
#endif
#include "XrdSsiPbException.hpp"
#include "XrdSsiPbRequestProc.hpp"
#include "xroot_plugins/messages/cta_frontend.pb.h"
#include "XrdSsiCtaServiceProvider.hpp"
#include "XrdSsiCtaEos.hpp"
#include "XrdSsiCtaRequestMessage.hpp"
......@@ -67,12 +66,16 @@ void RequestProc<cta::xrd::Request, cta::xrd::Response, cta::xrd::Alert>::Execut
OutputJsonString(std::cerr, &m_request);
#endif
// Process EOS Request
//const cta::eos::Notification &notification = m_request.notification();
cta::xrd::RequestMessage request_msg(*(m_resource.client), cta_service_ptr);
request_msg.process(m_request, m_metadata);
}
catch(PbException &ex)
{
// Set the response
cta::frontend::EosNotificationRequest eos_rq(*(m_resource.client), cta_service_ptr);
eos_rq.process(m_request.notification(), m_metadata);
m_metadata.set_type(cta::xrd::Response::RSP_ERR_PROTOBUF);
m_metadata.set_message_txt(ex.what());
}
catch(std::exception &ex)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment