diff --git a/frontend-grpc/FrontendGRpcSvc.cpp b/frontend-grpc/FrontendGRpcSvc.cpp index 8470dba6f889c65c23930a2bbc098cf2b0924b32..2df229e41149af20433551f0788ec34dd8972dda 100644 --- a/frontend-grpc/FrontendGRpcSvc.cpp +++ b/frontend-grpc/FrontendGRpcSvc.cpp @@ -26,7 +26,7 @@ Status CtaRpcImpl::Version(::grpc::ServerContext *context, const ::google::proto return Status::OK; } -Status CtaRpcImpl::Archive(::grpc::ServerContext* context, const ::cta::dcache::rpc::ArchiveRequest* request, ::cta::dcache::rpc::ArchiveResponse* response) { +Status CtaRpcImpl::Archive(::grpc::ServerContext* context, const ::cta::frontend::rpc::ArchiveRequest* request, ::cta::frontend::rpc::ArchiveResponse* response) { cta::log::LogContext lc(*m_log); cta::log::ScopedParamContainer sp(lc); @@ -63,6 +63,21 @@ Status CtaRpcImpl::Archive(::grpc::ServerContext* context, const ::cta::dcache:: return ::grpc::Status(::grpc::StatusCode::INVALID_ARGUMENT, "CTA groupname is not set."); } + if (!request->file().uid()) { + lc.log(cta::log::WARNING, "File's owner uid can't be zero"); + return ::grpc::Status(::grpc::StatusCode::INVALID_ARGUMENT, "File's owner uid can't be zero"); + } + + if (!request->file().gid()) { + lc.log(cta::log::WARNING, "File's owner gid can't be zero"); + return ::grpc::Status(::grpc::StatusCode::INVALID_ARGUMENT, "File's owner gid can't be zero"); + } + + if (request->file().path().empty()) { + lc.log(cta::log::WARNING, "File's path can't be empty"); + return ::grpc::Status(::grpc::StatusCode::INVALID_ARGUMENT, "File's path can't be empty"); + } + auto instance = request->instance().name(); sp.add("instance", instance); sp.add("username", request->cli().user().username()); @@ -77,9 +92,9 @@ Status CtaRpcImpl::Archive(::grpc::ServerContext* context, const ::cta::dcache:: cta::common::dataStructures::ArchiveRequest archiveRequest; cta::checksum::ProtobufToChecksumBlob(request->file().csb(), archiveRequest.checksumBlob); - archiveRequest.diskFileInfo.owner_uid = 1; - archiveRequest.diskFileInfo.gid = 1; - archiveRequest.diskFileInfo.path = "/" + request->file().fid(); + archiveRequest.diskFileInfo.owner_uid = request->file().uid(); + archiveRequest.diskFileInfo.gid = request->file().gid(); + archiveRequest.diskFileInfo.path = request->file().path(); archiveRequest.diskFileID = request->file().fid(); archiveRequest.fileSize = request->file().size(); archiveRequest.requester.name = request->cli().user().username(); @@ -111,7 +126,7 @@ Status CtaRpcImpl::Archive(::grpc::ServerContext* context, const ::cta::dcache:: } -Status CtaRpcImpl::Delete(::grpc::ServerContext* context, const ::cta::dcache::rpc::DeleteRequest* request, ::google::protobuf::Empty* response) { +Status CtaRpcImpl::Delete(::grpc::ServerContext* context, const ::cta::frontend::rpc::DeleteRequest* request, ::google::protobuf::Empty* response) { cta::log::LogContext lc(*m_log); cta::log::ScopedParamContainer sp(lc); @@ -142,6 +157,21 @@ Status CtaRpcImpl::Delete(::grpc::ServerContext* context, const ::cta::dcache::r return ::grpc::Status(::grpc::StatusCode::INVALID_ARGUMENT, "Invalid archive file id."); } + if (!request->file().uid()) { + lc.log(cta::log::WARNING, "File's owner uid can't be zero"); + return ::grpc::Status(::grpc::StatusCode::INVALID_ARGUMENT, "File's owner uid can't be zero"); + } + + if (!request->file().gid()) { + lc.log(cta::log::WARNING, "File's owner gid can't be zero"); + return ::grpc::Status(::grpc::StatusCode::INVALID_ARGUMENT, "File's owner gid can't be zero"); + } + + if (request->file().path().empty()) { + lc.log(cta::log::WARNING, "File's path can't be empty"); + return ::grpc::Status(::grpc::StatusCode::INVALID_ARGUMENT, "File's path can't be empty"); + } + auto instance = request->instance().name(); // Unpack message cta::common::dataStructures::DeleteArchiveRequest deleteRequest; @@ -153,8 +183,7 @@ Status CtaRpcImpl::Delete(::grpc::ServerContext* context, const ::cta::dcache::r sp.add("groupname", request->cli().user().groupname()); sp.add("fileID", request->file().fid()); - - deleteRequest.diskFilePath = "/" + request->file().fid(); + deleteRequest.diskFilePath = request->file().path(); deleteRequest.diskFileId = request->file().fid(); deleteRequest.diskInstance = instance; @@ -178,7 +207,7 @@ Status CtaRpcImpl::Delete(::grpc::ServerContext* context, const ::cta::dcache::r return Status::OK; } -Status CtaRpcImpl::Retrieve(::grpc::ServerContext* context, const ::cta::dcache::rpc::RetrieveRequest* request, ::cta::dcache::rpc::RetrieveResponse *response) { +Status CtaRpcImpl::Retrieve(::grpc::ServerContext* context, const ::cta::frontend::rpc::RetrieveRequest* request, ::cta::frontend::rpc::RetrieveResponse *response) { cta::log::LogContext lc(*m_log); @@ -215,6 +244,21 @@ Status CtaRpcImpl::Retrieve(::grpc::ServerContext* context, const ::cta::dcache: return ::grpc::Status(::grpc::StatusCode::INVALID_ARGUMENT, "Invalid archive file id."); } + if (!request->file().uid()) { + lc.log(cta::log::WARNING, "File's owner uid can't be zero"); + return ::grpc::Status(::grpc::StatusCode::INVALID_ARGUMENT, "File's owner uid can't be zero"); + } + + if (!request->file().gid()) { + lc.log(cta::log::WARNING, "File's owner gid can't be zero"); + return ::grpc::Status(::grpc::StatusCode::INVALID_ARGUMENT, "File's owner gid can't be zero"); + } + + if (request->file().path().empty()) { + lc.log(cta::log::WARNING, "File's path can't be empty"); + return ::grpc::Status(::grpc::StatusCode::INVALID_ARGUMENT, "File's path can't be empty"); + } + auto instance = request->instance().name(); sp.add("instance", instance); @@ -230,9 +274,9 @@ Status CtaRpcImpl::Retrieve(::grpc::ServerContext* context, const ::cta::dcache: retrieveRequest.requester.group = request->cli().user().groupname(); retrieveRequest.dstURL = request->transport().dst_url(); retrieveRequest.errorReportURL = request->transport().error_report_url(); - retrieveRequest.diskFileInfo.owner_uid = 1; - retrieveRequest.diskFileInfo.gid = 1; - retrieveRequest.diskFileInfo.path = "/" + request->file().fid(); + retrieveRequest.diskFileInfo.owner_uid = request->file().uid(); + retrieveRequest.diskFileInfo.gid = request->file().gid(); + retrieveRequest.diskFileInfo.path = request->file().path(); retrieveRequest.creationLog.host = context->peer(); retrieveRequest.creationLog.username = instance; retrieveRequest.creationLog.time = time(nullptr); @@ -260,7 +304,7 @@ Status CtaRpcImpl::Retrieve(::grpc::ServerContext* context, const ::cta::dcache: return Status::OK; } -Status CtaRpcImpl::CancelRetrieve(::grpc::ServerContext* context, const ::cta::dcache::rpc::CancelRetrieveRequest* request, ::google::protobuf::Empty* response) { +Status CtaRpcImpl::CancelRetrieve(::grpc::ServerContext* context, const ::cta::frontend::rpc::CancelRetrieveRequest* request, ::google::protobuf::Empty* response) { cta::log::LogContext lc(*m_log); cta::log::ScopedParamContainer sp(lc); @@ -286,7 +330,7 @@ Status CtaRpcImpl::CancelRetrieve(::grpc::ServerContext* context, const ::cta::d return ::grpc::Status(::grpc::StatusCode::INVALID_ARGUMENT, "CTA groupname is not set."); } - if (request->fid() == 0) { + if (!request->archiveid()) { lc.log(cta::log::WARNING, "Invalid archive file id"); return ::grpc::Status(::grpc::StatusCode::INVALID_ARGUMENT, "Invalid archive file id."); } @@ -296,13 +340,13 @@ Status CtaRpcImpl::CancelRetrieve(::grpc::ServerContext* context, const ::cta::d cta::common::dataStructures::CancelRetrieveRequest cancelRequest; cancelRequest.requester.name = request->cli().user().username(); cancelRequest.requester.group = request->cli().user().groupname(); - cancelRequest.archiveFileID = request->fid(); + cancelRequest.archiveFileID = request->archiveid(); cancelRequest.retrieveRequestId = request->reqid(); sp.add("instance", instance); sp.add("username", request->cli().user().username()); sp.add("groupname", request->cli().user().groupname()); - sp.add("fileID", request->fid()); + sp.add("fileID", request->archiveid()); sp.add("schedulerJobID", request->reqid()); m_scheduler->abortRetrieve(instance, cancelRequest, lc); diff --git a/frontend-grpc/FrontendGRpcSvc.h b/frontend-grpc/FrontendGRpcSvc.h index ccd5d4dcd0faae7b3954146428658d12d76b88ca..294f0f40cc9c1e827454e6c09ad35c4518f6403e 100644 --- a/frontend-grpc/FrontendGRpcSvc.h +++ b/frontend-grpc/FrontendGRpcSvc.h @@ -7,11 +7,11 @@ #include <scheduler/Scheduler.hpp> #include "common/log/Logger.hpp" -#include "cta_dcache.grpc.pb.h" +#include "cta_grpc_frontend.grpc.pb.h" using cta::Scheduler; using cta::catalogue::Catalogue; -using cta::dcache::rpc::CtaRpc; +using cta::frontend::rpc::CtaRpc; using grpc::Server; using grpc::ServerBuilder; @@ -30,9 +30,9 @@ public: Status Version(::grpc::ServerContext *context, const ::google::protobuf::Empty *request, ::cta::admin::Version *response); - Status Archive(::grpc::ServerContext* context, const ::cta::dcache::rpc::ArchiveRequest* request, ::cta::dcache::rpc::ArchiveResponse* response); - Status Retrieve(::grpc::ServerContext* context, const ::cta::dcache::rpc::RetrieveRequest* request, ::cta::dcache::rpc::RetrieveResponse* response); - Status Delete(::grpc::ServerContext* context, const ::cta::dcache::rpc::DeleteRequest* request, ::google::protobuf::Empty* response); - Status CancelRetrieve(::grpc::ServerContext* context, const ::cta::dcache::rpc::CancelRetrieveRequest* request, ::google::protobuf::Empty* response); + Status Archive(::grpc::ServerContext* context, const ::cta::frontend::rpc::ArchiveRequest* request, ::cta::frontend::rpc::ArchiveResponse* response); + Status Retrieve(::grpc::ServerContext* context, const ::cta::frontend::rpc::RetrieveRequest* request, ::cta::frontend::rpc::RetrieveResponse* response); + Status Delete(::grpc::ServerContext* context, const ::cta::frontend::rpc::DeleteRequest* request, ::google::protobuf::Empty* response); + Status CancelRetrieve(::grpc::ServerContext* context, const ::cta::frontend::rpc::CancelRetrieveRequest* request, ::google::protobuf::Empty* response); }; diff --git a/frontend-grpc/grpc-proto/protobuf/cta_dcache.proto b/frontend-grpc/grpc-proto/protobuf/cta_grpc_frontend.proto similarity index 90% rename from frontend-grpc/grpc-proto/protobuf/cta_dcache.proto rename to frontend-grpc/grpc-proto/protobuf/cta_grpc_frontend.proto index f648041851b8deba76a8e9634297fbf0d3821c95..d2ad36748f1f30893a9866560b7384877a01c553 100644 --- a/frontend-grpc/grpc-proto/protobuf/cta_dcache.proto +++ b/frontend-grpc/grpc-proto/protobuf/cta_grpc_frontend.proto @@ -1,9 +1,9 @@ syntax = "proto3"; option java_multiple_files = true; -option java_package = "org.dcache.cta.rpc"; +option java_package = "ch.cern.cta.rpc"; option optimize_for = CODE_SIZE; -package cta.dcache.rpc; +package cta.frontend.rpc; import "google/protobuf/empty.proto"; @@ -23,6 +23,9 @@ message FileInfo { uint64 size = 2; // file size string storageClass = 3; // tape system related storage class (file family) cta.common.ChecksumBlob csb = 4; // set of knows checksums for the given file + uint32 uid = 5; // files owner user id + uint32 gid = 6; // files owner group id + string path = 7; // files path at creation time } /* @@ -79,7 +82,7 @@ message DeleteRequest { message CancelRetrieveRequest { cta.common.Service instance = 1; // client instance ID cta.eos.Client cli = 2; // requester information - uint64 fid = 3; // tape system unique file ID + uint64 archiveId = 3; // tape system unique file ID string reqId = 4; // tape request scheduler ID, used to cancel the request }