Commit 419ea364 authored by Michael Davis's avatar Michael Davis
Browse files

[XrdSsi] Updates eos_messages.proto and deletes Opaque Query

Update the protobuf file to the version required by EOS-CTA SSI
interface and delete all source code that depends on the previous
version (i.e. all the opaque query code).
parent 8079a1d4
syntax = "proto3";
syntax = "proto3";
package eos.wfe;
message Id {
fixed64 uid = 1; //< user identity number
string username = 2; //< user name
fixed64 gid = 3; //< group identity number
string groupname = 4; //< group name
message Clock {
uint64 sec = 1; //< seconds of a clock
uint64 nsec = 2; //< nanoseconds of a clock
}
message Checksum {
string value = 1; //< checksum value
string name = 2; //< checksum name
string name = 1; //< checksum name
string value = 2; //< checksum value
}
message Clock {
fixed64 sec = 1; //< seconds of a clock
fixed64 nsec = 2; //< nanoseconds of a clock
message Service {
string name = 1; //< name of the service
string url = 2; //< access url of the service
}
message Md {
fixed64 fid = 1; //< file/container id
fixed64 pid = 2; //< parent id
Clock ctime = 3; //< change time
Clock mtime = 4; //< modification time
Clock btime = 5; //< birth time
Clock ttime = 6; //< tree modification time
Id owner = 7; //< ownership
fixed64 size = 8; //< size
Checksum cks = 9; //< checksum information
sfixed32 mode = 10; //< mode
string lpath = 11; //< logical path
map<string, string> xattr = 12; //< xattribute map
};
message Id {
uint64 uid = 1; //< user identity number
string username = 2; //< user name
uint64 gid = 3; //< group identity number
string groupname = 4; //< group name
}
message Security {
string host = 1; //< client host
string app = 2; //< app string
string name = 3; //< sec name
string prot = 4; //< security protocol
string grps = 5; //< security grps
string host = 1; //< client host
string app = 2; //< app string
string name = 3; //< security name
string prot = 4; //< security protocol
string grps = 5; //< security grps
}
message Client {
Id user = 1; //< acting client
Security sec = 2; //< client security information
}
message Service {
string name = 1; //< name of the service
string url = 2; //< access url of the service
//
// Alert Messages
//
message Alert {
enum Audience { EOSLOG = 0; ENDUSER = 1; }
Audience audience = 1; //< The intended audience of the error message
string message_txt = 2; //< An empty if success, else an error message
}
//
// Messages sent from EOS to CTA Frontend
//
message Workflow {
enum EventType {
NONE = 0;
OPENR = 1;
OPENW = 2;
CLOSER = 3;
CLOSEW = 4;
DELETE = 5;
PREPARE = 6;}
EventType event = 1; //< event
string queue = 2; //< queue
string wfname = 3; //< workflow
string vpath = 4; //< vpath
Service instance = 5; //< instance information
fixed64 timestamp = 6; //< event timestamp
NONE = 0;
OPENR = 1;
OPENW = 2;
CLOSER = 3;
CLOSEW = 4;
DELETE = 5;
PREPARE = 6;
}
EventType event = 1; //< event
string queue = 2; //< queue
string wfname = 3; //< workflow
string vpath = 4; //< vpath
Service instance = 5; //< instance information
uint64 timestamp = 6; //< event timestamp
}
message Notification {
Workflow wf = 1; //< workflow
string turl = 2; //< transport URL
Client cli = 3; //< client information
Md file = 4; //< file meta data
Md directory = 5; //< directory meta data
message Client {
Id user = 1; //< acting client
Security sec = 2; //< client security information
}
message Xattr {
enum Operation { NONE = 0; GET = 1; ADD = 2; SET = 3; DELETE = 4;}
fixed64 fid = 1; //< file id
map<string, string> xattrs = 2; //< xattribute map
Operation op = 3; //< operation to execute for this xattr map
message Transport {
string url = 1; //< transport URL
}
message Tapereplica {
enum Status { NONE = 0; OFFTAPE = 1; ONTAPE = 2; ONTAPESAVE = 3;}
fixed64 fid = 1; //< file id
Status status = 2; //< state state for file ID
fixed64 size = 3; //< File size as recorded on tape for cross check
Checksum cks = 4; //< File checksum as computer while writing to tape
}
message Metadata {
uint64 fid = 1; //< file/container id
uint64 pid = 2; //< parent id
Clock ctime = 3; //< change time
Clock mtime = 4; //< modification time
Clock btime = 5; //< birth time
Clock ttime = 6; //< tree modification time
Id owner = 7; //< ownership
uint64 size = 8; //< size
Checksum cks = 9; //< checksum information
sint32 mode = 10; //< mode
string lpath = 11; //< logical path
map<string, string> xattr = 12; //< xattribute map
};
message Error {
enum Audience { NONE = 0; EOSLOG = 1; ENDUSER = 2;}
Audience audience = 1; //< The intended audience of the error message
fixed64 code = 2; //< Zero means success, non-zero means error
string message = 3; //< An empty if success, else an error message
message Notification {
Workflow wf = 1; //< workflow
Client cli = 2; //< client information
Transport transport = 3; //< transport
Metadata file = 4; //< file meta data
Metadata directory = 5; //< directory meta data
}
// The following message is used to wrap all messages sent between EOS and its
// peers.
//
// This wrapper message allows new message types to be added to the protocol in
// the future.
//
// This wrapper message also allows EOS peers to receive non-EOS messages as
// long as the following two conditions are met:
// 1. The peer uses a wrapper message with exactly the same (simple) structure.
// 2. No two message types use the same numeric tag value.
// Messages sent from CTA Frontend to EOS
//
// The structure of this message is based on the "Union Types" section of the
// following Google protocol buffers web page:
message Response {
enum ResponseType {
RSP_SUCCESS = 0; //< Notification was queued successfully
RSP_ERR_PROTOBUF = 1; //< Framework error caused by Google Protocol Buffers layer
RSP_ERR_CTA = 2; //< Server error reported by CTA Frontend
}
ResponseType type = 1; //< Encode the type of this reply
string message_txt = 2; //< Text of the reply
}
//
// https://developers.google.com/protocol-buffers/docs/techniques
// Messages sent from the Tape Server to EOS
//
// A protocol buffer parser cannot determine a message type based solely on its
// contents. The type field of this wrapper message provides the required
// metadata.
message Wrapper {
enum Type {NONE = 0; ERROR = 1; NOTIFICATION = 2; XATTR = 3; TAPEREPLICA = 4;}
Type type = 1;
Error error = 2;
Notification notification = 3;
Xattr xattr = 4;
Tapereplica tapereplica = 5;
}
//message Tapereplica {
// enum Status { NONE = 0; OFFTAPE = 1; ONTAPE = 2; ONTAPESAVE = 3; }
// uint64 fid = 1; //< file id
// Status status = 2; //< status for file id
// uint64 size = 3; //< File size as recorded on tape, for cross-check
// Checksum cks = 4; //< File checksum as computer while writing to tape
//}
......@@ -33,22 +33,3 @@ INSTALL (FILES xrootd-cta.cfg DESTINATION /etc/xrootd/)
INSTALL (FILES cta-frontend.conf DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/cta)
install (FILES cta-frontend.logrotate DESTINATION /etc/logrotate.d RENAME cta-frontend)
set (OPAQUE_QUERY_CMD_SRC_FILES
CmdLineTool.cpp
OpaqueQueryCmd.cpp
OpaqueQueryCmdLineArgs.cpp
OpaqueQueryCmdMain.cpp)
add_executable (cta-xrootd_plugins-opaque-query ${OPAQUE_QUERY_CMD_SRC_FILES})
add_dependencies (cta-xrootd_plugins-opaque-query generate_notification.pb.h)
target_link_libraries (cta-xrootd_plugins-opaque-query ctacommon)
set (WRITE_NOTIFICATION_MSG_CMD_SRC_FILES
CmdLineTool.cpp
WriteNotificationMsgCmd.cpp
WriteNotificationMsgCmdLineArgs.cpp
WriteNotificationMsgCmdMain.cpp)
add_executable (cta-xrootd_plugins-write-notification-msg ${WRITE_NOTIFICATION_MSG_CMD_SRC_FILES})
add_dependencies (cta-xrootd_plugins-write-notification-msg generate_notification.pb.h)
target_link_libraries (cta-xrootd_plugins-write-notification-msg ctacommon ctaeosmessages)
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "common/make_unique.hpp"
#include "eos/messages/eos_messages.pb.h"
#include "xroot_plugins/OpaqueQueryCmd.hpp"
#include "xroot_plugins/OpaqueQueryCmdLineArgs.hpp"
#include <fstream>
#include <iostream>
#include <stdint.h>
#include <string>
#include <XrdCl/XrdClFileSystem.hh>
namespace cta {
namespace xroot_plugins {
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
OpaqueQueryCmd::OpaqueQueryCmd(std::istream &inStream, std::ostream &outStream, std::ostream &errStream):
CmdLineTool(inStream, outStream, errStream) {
}
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
OpaqueQueryCmd::~OpaqueQueryCmd() noexcept {
}
//------------------------------------------------------------------------------
// exceptionThrowingMain
//------------------------------------------------------------------------------
int OpaqueQueryCmd::exceptionThrowingMain(const int argc, char *const *const argv) {
const OpaqueQueryCmdLineArgs cmdLineArgs(argc, argv);
if(cmdLineArgs.help) {
printUsage(m_out);
return 0;
}
std::ifstream queryFileStream(cmdLineArgs.queryFilename, std::ios_base::binary);
if(!queryFileStream) {
m_err << "Failed to open " << cmdLineArgs.queryFilename << std::endl;
return 1;
}
std::vector<char> queryFileContents(
(std::istreambuf_iterator<char>(queryFileStream)),
(std::istreambuf_iterator<char>()));
const std::string protocol = "xroot";
const std::string fsUrl = protocol + ":" + "//" + cmdLineArgs.ctaHost + ":" + std::to_string(cmdLineArgs.ctaPort);
XrdCl::FileSystem fs(fsUrl, false);
XrdCl::Buffer arg;
arg.Append(&queryFileContents[0], queryFileContents.size(), 0);
XrdCl::Buffer *response = nullptr;
const XrdCl::XRootDStatus status = fs.Query(XrdCl::QueryCode::Opaque, arg, response);
std::unique_ptr<XrdCl::Buffer> smartResponse(response);
std::cout << "status.IsError()=" << (status.IsError() ? "true" : "false") << std::endl;
std::cout << "status.IsFatal()=" << (status.IsFatal() ? "true" : "false") << std::endl;
std::cout << "status.IsOK()=" << (status.IsOK() ? "true" : "false") << std::endl;
if(nullptr != smartResponse.get()) {
std::cout << "response->GetSize()=" << response->GetSize() << std::endl;
std::ofstream responseFileStream(cmdLineArgs.responseFilename, std::ios_base::binary);
if(!responseFileStream) {
std::cerr << "Failed to open " << cmdLineArgs.responseFilename << std::endl;
}
const char *buf = smartResponse->GetBuffer();
const uint32_t bufSize = smartResponse->GetSize();
responseFileStream.write(buf, bufSize);
}
return 0;
}
//------------------------------------------------------------------------------
// printUsage
//------------------------------------------------------------------------------
void OpaqueQueryCmd::printUsage(std::ostream &os) {
OpaqueQueryCmdLineArgs::printUsage(os);
}
} // namespace xroot_plugins
} // namespace cta
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "xroot_plugins/CmdLineTool.hpp"
#include "rdbms/Conn.hpp"
namespace cta {
namespace xroot_plugins {
/**
* Command-line tool to emulate EOS sending CTA a message.
*/
class OpaqueQueryCmd: public CmdLineTool {
public:
/**
* Constructor.
*
* @param inStream Standard input stream.
* @param outStream Standard output stream.
* @param errStream Standard error stream.
*/
OpaqueQueryCmd(std::istream &inStream, std::ostream &outStream, std::ostream &errStream);
/**
* Destructor.
*/
~OpaqueQueryCmd() noexcept;
private:
/**
* An exception throwing version of main().
*
* @param argc The number of command-line arguments including the program name.
* @param argv The command-line arguments.
* @return The exit value of the program.
*/
int exceptionThrowingMain(const int argc, char *const *const argv) override;
/**
* Prints the usage message of the command-line tool.
*
* @param os The output stream to which the usage message is to be printed.
*/
void printUsage(std::ostream &os) override;
}; // class OpaqueQueryCmd
} // namespace xroot_plugins
} // namespace cta
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "common/exception/CommandLineNotParsed.hpp"
#include "common/utils/utils.hpp"
#include "xroot_plugins/OpaqueQueryCmdLineArgs.hpp"
#include <getopt.h>
#include <ostream>
namespace cta {
namespace xroot_plugins {
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
OpaqueQueryCmdLineArgs::OpaqueQueryCmdLineArgs(const int argc, char *const *const argv):
ctaPort(0),
help(false) {
static struct option longopts[] = {
{"help", no_argument, NULL, 'h'},
{NULL , 0, NULL, 0}
};
// Prevent getopt() from printing an error message if it does not recognize
// an option character
opterr = 0;
int opt = 0;
while((opt = getopt_long(argc, argv, ":h", longopts, NULL)) != -1) {
switch(opt) {
case 'h':
help = true;
break;
case ':': // Missing parameter
{
exception::CommandLineNotParsed ex;
ex.getMessage() << "The -" << (char)opt << " option requires a parameter";
throw ex;
}
case '?': // Unknown option
{
exception::CommandLineNotParsed ex;
if(0 == optopt) {
ex.getMessage() << "Unknown command-line option";
} else {
ex.getMessage() << "Unknown command-line option: -" << (char)optopt;
}
throw ex;
}
default:
{
exception::CommandLineNotParsed ex;
ex.getMessage() <<
"getopt_long returned the following unknown value: 0x" <<
std::hex << (int)opt;
throw ex;
}
} // switch(opt)
} // while getopt_long()
// Calculate the number of non-option ARGV-elements
const int actualNbArgs = argc - optind;
if(help && actualNbArgs > 0) {
exception::CommandLineNotParsed ex;
ex.getMessage() << "A command-line argument cannot be specified with the -h|--help option";
throw ex;
}
// There is no need to continue parsing when the help option is set
if(help) {
return;
}
// Check the number of arguments
const int expectedNbArgs = 4;
if(actualNbArgs != expectedNbArgs) {
exception::CommandLineNotParsed ex;
ex.getMessage() << "Wrong number of command-line arguments: excepted=" << expectedNbArgs << " actual=" <<
actualNbArgs;
throw ex;
}
ctaHost = argv[optind];
try {
ctaPort = utils::toUint16(argv[optind + 1]);
} catch(exception::Exception &ex) {
throw exception::Exception(std::string("Invalid CTA port number: " + ex.getMessage().str()));
}
queryFilename = argv[optind+2];
responseFilename = argv[optind+3];
}
//------------------------------------------------------------------------------
// printUsage
//------------------------------------------------------------------------------
void OpaqueQueryCmdLineArgs::printUsage(std::ostream &os) {
os <<
"Description:" << std::endl <<
" Sends an xrootd \"opaque query\" message to the CTA front end" << std::endl <<
"Usage:" << std::endl <<
" cta-xroot_plugins-opaque-query [options] ctaHost ctaPort queryFilename responseFileName" << std::endl <<
"Where:" << std::endl <<
" ctaHost" << std::endl <<
" The network name of the host on which the CTA front end is running" << std::endl <<
" ctaPort" << std::endl <<
" The TCP/IP port on which the CTA front end is listening for connections" << std::endl <<
" queryFilename" << std::endl <<
" The name of file containing the query blob to be sent to the CTA front end" << std::endl <<
" responseFilename" << std::endl <<
" The name of file to which the binary responce from the CTA front end will be written" << std::endl <<
"Options:" << std::endl <<
" -h,--help" << std::endl <<
" Prints this usage message" << std::endl <<
"Example 1:" << std::endl <<
" echo -n -e 'Hello\\n\\x00World' > strange.msg" << std::endl <<
" cta-xrootd_plugins-opaque-query localhost 10955 strange.msg response.msg" << std::endl <<
"Example 2:" << std::endl <<
" cta-xrootd_plugins-write-notification-msg CLOSEW notification.msg" << std::endl <<
" cta-xrootd_plugins-opaque-query localhost 10955 notification.msg response.msg" << std::endl;
}
} // namespace xroot_plugins
} // namespace cta
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <ostream>
#include <stdint.h>
#include <string>
namespace cta {
namespace xroot_plugins {
/**
* Structure to store the command-line arguments of the command-line tool
* named cta-xroot_plugins-fake-eos.
*/
struct OpaqueQueryCmdLineArgs {
/**
* The name of the host on which the CTA front end is running.
*/
std::string ctaHost;
/**
* The TCP/IP port on which the CTA front end is listening.
*/
uint16_t ctaPort;
/**