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

[EOS-CTA] Integrates XrdSsi Service object

The framework now expects only 3 protobuf types (Request, Metadata-response
and Alert). This is because the response payload will be arbitrary data of
arbitrary length and so is less well suited for protocol buffers.

We can define the characteristics of the response (size, format, etc.) in
the Metadata protobuf, or (if there is a use case), we can split the response
into records and use a protobuf for the record format.
parent 065ef4fc
No related branches found
No related tags found
No related merge requests found
......@@ -32,6 +32,9 @@ include_directories (${CMAKE_SOURCE_DIR}/tapeserver/)
# eosctastub is a drop-in replacement for "cta archive|retrieve|delete"
#
# Get some extra debug messages on stdout
add_definitions(-DXRDSSI_DEBUG)
# XRootD must be compiled with the SSI extensions
find_package(xrootd REQUIRED)
find_package(Protobuf3 REQUIRED)
......@@ -39,6 +42,6 @@ find_package(cryptopp REQUIRED)
include_directories(${PROTOBUF3_INCLUDE_DIRS} ${XROOTD_INCLUDE_DIR} ../xroot_ssi_pb)
add_executable(eoscta_stub EosCtaStub.cpp)
target_link_libraries (eoscta_stub ctaeosmessages ${PROTOBUF3_LIBRARIES} cryptopp)
target_link_libraries (eoscta_stub cryptopp ctaeosmessages ${PROTOBUF3_LIBRARIES} XrdSsi-4 XrdSsiLib)
install(TARGETS eoscta_stub DESTINATION usr/bin)
......@@ -3,17 +3,14 @@
#ifndef __EOS_CTA_API_H
#define __EOS_CTA_API_H
#include "XrdSsiPbServiceClientSide.h" // XRootD SSI/Protocol Buffer Service bindings (client side)
#include "eos/messages/eos_messages.pb.h" // Auto-generated message types from .proto file
#include "XrdSsiPbServiceClientSide.h" // XRootD SSI/Protocol Buffer Service bindings (client side)
#include "eos/messages/eos_messages.pb.h" // Auto-generated message types from .proto file
#if 0
// Bind the type of the XrdSsiService to the types defined in the .proto file
typedef XrdSsiPbServiceClientSide<xrdssi::test::Request, // Request message type
xrdssi::test::Result, // Response message type
xrdssi::test::Metadata, // Metadata message type
xrdssi::test::Alert> // Alert message type
typedef XrdSsiPbServiceClientSide<eos::wfe::Notification, // XrdSSi Request message type
eos::wfe::Response, // XrdSsi Metadata message type
eos::wfe::Alert> // Alert message type
XrdSsiPbServiceType;
#endif
#endif
......@@ -23,6 +23,7 @@
#include <sstream>
#include <cryptopp/base64.h>
#include <google/protobuf/util/json_util.h>
#include "common/dataStructures/FrontendReturnCode.hpp"
#include "EosCtaApi.h"
......@@ -306,11 +307,15 @@ int exceptionThrowingMain(int argc, const char *const *const argv)
std::cout << MessageToJsonString(notification);
}
#if 0
// Obtain a Service Provider
// Obtain a Service Provider
XrdSsiPbServiceType test_ssi_service(host, port, resource);
std::string host("localhost");
int port = 10955;
std::string resource("/cta");
XrdSsiPbServiceType cta_service(host, port, resource);
#if 0
// Create a Request object
xrdssi::test::Request request;
......
......@@ -19,7 +19,7 @@ public:
// XRootD SSI + Protocol Buffers Request class
template <typename RequestType, typename ResponseType, typename MetadataType, typename AlertType>
template <typename RequestType, typename MetadataType, typename AlertType>
class XrdSsiPbRequest : public XrdSsiRequest
{
public:
......@@ -28,9 +28,11 @@ public:
m_request_len(buffer_str.size()),
m_response_bufsize(response_bufsize)
{
std::cerr << "Creating XrdSsiPbRequest object:" << std::endl;
std::cerr << " Response buffer size = " << m_response_bufsize << std::endl;
std::cerr << " Response timeout = " << timeout << std::endl;
#ifdef XRDSSI_DEBUG
std::cout << "Creating XrdSsiPbRequest object:" << std::endl;
std::cout << " Response buffer size = " << m_response_bufsize << std::endl;
std::cout << " Response timeout = " << timeout << std::endl;
#endif
// Set response timeout
......@@ -38,7 +40,9 @@ public:
}
virtual ~XrdSsiPbRequest()
{
std::cerr << "Deleting XrdSsiPbRequest object" << std::endl;
#ifdef XRDSSI_DEBUG
std::cout << "Deleting XrdSsiPbRequest object" << std::endl;
#endif
}
// It is up to the implementation to create request data, save it in some manner, and provide it to
......@@ -77,7 +81,7 @@ private:
// Callbacks for each of the XRootD reply types
XrdSsiPbRequestCallback<ResponseType> ResponseCallback;
//XrdSsiPbRequestCallback<ResponseType> ResponseCallback;
XrdSsiPbRequestCallback<MetadataType> MetadataCallback;
XrdSsiPbRequestCallback<AlertType> AlertCallback;
......@@ -90,10 +94,12 @@ private:
// Process the response
template<typename RequestType, typename ResponseType, typename MetadataType, typename AlertType>
bool XrdSsiPbRequest<RequestType, ResponseType, MetadataType, AlertType>::ProcessResponse(const XrdSsiErrInfo &eInfo, const XrdSsiRespInfo &rInfo)
template<typename RequestType, typename MetadataType, typename AlertType>
bool XrdSsiPbRequest<RequestType, MetadataType, AlertType>::ProcessResponse(const XrdSsiErrInfo &eInfo, const XrdSsiRespInfo &rInfo)
{
std::cerr << "ProcessResponse() callback called with response type = " << rInfo.State() << std::endl;
#ifdef XRDSSI_DEBUG
std::cout << "ProcessResponse() callback called with response type = " << rInfo.State() << std::endl;
#endif
switch(rInfo.rType)
{
......@@ -182,14 +188,15 @@ bool XrdSsiPbRequest<RequestType, ResponseType, MetadataType, AlertType>::Proces
template<typename RequestType, typename ResponseType, typename MetadataType, typename AlertType>
XrdSsiRequest::PRD_Xeq XrdSsiPbRequest<RequestType, ResponseType, MetadataType, AlertType>
template<typename RequestType, typename MetadataType, typename AlertType>
XrdSsiRequest::PRD_Xeq XrdSsiPbRequest<RequestType, MetadataType, AlertType>
::ProcessResponseData(const XrdSsiErrInfo &eInfo, char *response_bufptr, int response_buflen, bool is_last)
{
// The buffer length can be 0 if the response is metadata only
if(response_buflen != 0)
{
#if 0
// How do we handle message boundaries for multi-block responses?
// Deserialize the response
......@@ -204,6 +211,7 @@ XrdSsiRequest::PRD_Xeq XrdSsiPbRequest<RequestType, ResponseType, MetadataType,
{
ErrorCallback("response.ParseFromArray() failed");
}
#endif
}
// If there is more data then get it, otherwise clean up
......@@ -232,8 +240,8 @@ XrdSsiRequest::PRD_Xeq XrdSsiPbRequest<RequestType, ResponseType, MetadataType,
template<typename RequestType, typename ResponseType, typename MetadataType, typename AlertType>
void XrdSsiPbRequest<RequestType, ResponseType, MetadataType, AlertType>::Alert(XrdSsiRespInfoMsg &alert_msg)
template<typename RequestType, typename MetadataType, typename AlertType>
void XrdSsiPbRequest<RequestType, MetadataType, AlertType>::Alert(XrdSsiRespInfoMsg &alert_msg)
{
// Get the Alert
......
......@@ -41,9 +41,21 @@ private:
// These methods should be specialized according to the needs of each <RequestType, ResponseType> pair
void ExecuteAction() { std::cerr << "Called default ExecuteAction()" << std::endl; }
void ExecuteAlerts() { std::cerr << "Called default ExecuteAlerts()" << std::endl; }
void ExecuteMetadata() { std::cerr << "Called default ExecuteMetadata()" << std::endl; }
void ExecuteAction() {
#ifdef XRDSSI_DEBUG
std::cout << "Called default ExecuteAction()" << std::endl;
#endif
}
void ExecuteAlerts() {
#ifdef XRDSSI_DEBUG
std::cout << "Called default ExecuteAlerts()" << std::endl;
#endif
}
void ExecuteMetadata() {
#ifdef XRDSSI_DEBUG
std::cout << "Called default ExecuteMetadata()" << std::endl;
#endif
}
RequestType m_request;
ResponseType m_response;
......@@ -61,7 +73,9 @@ private:
template <typename RequestType, typename ResponseType, typename MetadataType, typename AlertType>
void RequestProc<RequestType, ResponseType, MetadataType, AlertType>::Execute()
{
std::cerr << "Execute()" << std::endl;
#ifdef XRDSSI_DEBUG
std::cout << "Execute()" << std::endl;
#endif
// Deserialize the Request
......@@ -125,7 +139,9 @@ void RequestProc<RequestType, ResponseType, MetadataType, AlertType>::Execute()
template <typename RequestType, typename ResponseType, typename MetadataType, typename AlertType>
void RequestProc<RequestType, ResponseType, MetadataType, AlertType>::Finished(XrdSsiRequest &rqstR, const XrdSsiRespInfo &rInfo, bool cancel)
{
std::cerr << "Finished()" << std::endl;
#ifdef XRDSSI_DEBUG
std::cout << "Finished()" << std::endl;
#endif
// Reclaim any allocated resources
}
......
......@@ -26,7 +26,7 @@ extern XrdSsiProvider *XrdSsiProviderClient;
// Convenience object to manage the XRootD SSI service on the client side
template <typename RequestType, typename ResponseType, typename MetadataType, typename AlertType>
template <typename RequestType, typename MetadataType, typename AlertType>
class XrdSsiPbServiceClientSide
{
public:
......@@ -73,10 +73,10 @@ private:
// Destructor
template <typename RequestType, typename ResponseType, typename MetadataType, typename AlertType>
XrdSsiPbServiceClientSide<RequestType, ResponseType, MetadataType, AlertType>::~XrdSsiPbServiceClientSide()
template <typename RequestType, typename MetadataType, typename AlertType>
XrdSsiPbServiceClientSide<RequestType, MetadataType, AlertType>::~XrdSsiPbServiceClientSide()
{
std::cerr << "Stopping XRootD SSI service...";
std::cout << "Stopping XRootD SSI service...";
// The XrdSsiService object cannot be explicitly deleted. The Stop() method deletes the object if
// it is safe to do so.
......@@ -84,12 +84,12 @@ XrdSsiPbServiceClientSide<RequestType, ResponseType, MetadataType, AlertType>::~
while(!m_server_ptr->Stop() && m_shutdown_tmo--)
{
sleep(1);
std::cerr << ".";
std::cout << ".";
}
if(m_shutdown_tmo > 0)
{
std::cerr << "done." << std::endl;
std::cout << "done." << std::endl;
}
else
{
......@@ -105,7 +105,7 @@ XrdSsiPbServiceClientSide<RequestType, ResponseType, MetadataType, AlertType>::~
// Until this is solved, deleting the Service may leak memory, so don't delete Service objects
// unless the client is shutting down!
std::cerr << "failed." << std::endl;
std::cout << "failed." << std::endl;
}
}
......@@ -113,8 +113,8 @@ XrdSsiPbServiceClientSide<RequestType, ResponseType, MetadataType, AlertType>::~
// Send a Request to the Service
template <typename RequestType, typename ResponseType, typename MetadataType, typename AlertType>
void XrdSsiPbServiceClientSide<RequestType, ResponseType, MetadataType, AlertType>::send(const RequestType &request)
template <typename RequestType, typename MetadataType, typename AlertType>
void XrdSsiPbServiceClientSide<RequestType, MetadataType, AlertType>::send(const RequestType &request)
{
// Serialize the request object
......@@ -128,7 +128,7 @@ void XrdSsiPbServiceClientSide<RequestType, ResponseType, MetadataType, AlertTyp
// Requests are always executed in the context of a service. They need to correspond to what the service allows.
XrdSsiRequest *request_ptr =
new XrdSsiPbRequest<RequestType, ResponseType, MetadataType, AlertType>(request_str, m_response_bufsize, m_server_tmo);
new XrdSsiPbRequest<RequestType, MetadataType, AlertType>(request_str, m_response_bufsize, m_server_tmo);
// Transfer ownership of the request to the service object
// TestSsiRequest handles deletion of the request buffer, so we can allow the pointer to go out-of-scope
......
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