Skip to content
Snippets Groups Projects
Commit 8b67ef4a authored by Tigran Mkrtchyan's avatar Tigran Mkrtchyan :coffee:
Browse files

frondtent: add foundation for gRPC based frontend service

parent 83eabdfc
No related branches found
No related tags found
No related merge requests found
......@@ -128,6 +128,7 @@ ELSE(DEFINED PackageOnly)
add_subdirectory(cmdline)
add_subdirectory(xroot_plugins)
add_subdirectory(frontend_svc)
add_subdirectory(catalogue)
add_subdirectory(common)
......
......@@ -24,23 +24,31 @@ set(PROTOBUF_EOS_CTA_DIR ${XRD_SSI_PB_DIR}/eos_cta/protobuf)
file(GLOB ProtoFilesEosCta "${PROTOBUF_EOS_CTA_DIR}/*.proto")
set(PROTOBUF_MIGRATION_DIR ${PROJECT_SOURCE_DIR}/migration/grpc-proto/protobuf)
file(GLOB ProtoFilesMigration "${PROTOBUF_MIGRATION_DIR}/*.proto")
set(PROTOBUF_FRONTEND_DIR ${PROJECT_SOURCE_DIR}/frontend_svc/grpc-proto/protobuf)
file(GLOB ProtoFilesFrontendCta "${PROTOBUF_FRONTEND_DIR}/*.proto")
# Compile protobufs
set(PROTOBUF3_INCLUDE_PATH ${PROTOBUF_EOS_CTA_DIR}:${PROTOBUF_MIGRATION_DIR})
set(PROTOBUF3_INCLUDE_PATH ${PROTOBUF_EOS_CTA_DIR}:${PROTOBUF_MIGRATION_DIR}:${PROTOBUF_FRONTEND_DIR}:${PROTOBUF3_INCLUDE_DIRS})
PROTOBUF3_GENERATE_CPP(ProtoSourcesEosCta ProtoHeadersEosCta ${ProtoFilesEosCta})
PROTOBUF3_GENERATE_CPP(ProtoSourcesMigration ProtoHeadersMigration ${ProtoFilesMigration})
PROTOBUF3_GENERATE_CPP(ProtoSourcesFrontendCta ProtoHeadersFrontendCta ${ProtoFilesFrontendCta})
# Compile gRPC code
set(GRPC_PROTOBUF_PATH "${CMAKE_BINARY_DIR}/eos_cta/")
grpc_generate_cpp(ProtoGrpcSourcesMigration ProtoGrpcHeadersMigration ${GRPC_PROTOBUF_PATH} ${ProtoFilesMigration})
# depends on CTA_EOS definitions
set(PROTOBUF3_IMPORT_DIRS "${PROTOBUF_EOS_CTA_DIR}:${PROTOBUF3_INCLUDE_DIRS}")
grpc_generate_cpp(ProtoGrpcSourcesFrontendCta ProtoGrpcHeadersFrontendCta ${GRPC_PROTOBUF_PATH} ${ProtoFilesFrontendCta})
set_source_files_properties(
${ProtoSourcesEosCta} ${ProtoHeadersEosCta}
${ProtoSourcesMigration} ${ProtoHeadersMigration}
${ProtoGrpcSourcesMigration} ${ProtoGrpcHeadersMigration}
${ProtoSourcesFrontendCta} ${ProtoHeadersFrontendCta}
${ProtoGrpcSourcesFrontendCta} ${ProtoGrpcHeadersFrontendCta}
PROPERTIES GENERATED TRUE)
foreach(PROTO_SRC ${ProtoSourcesEosCta} ${ProtoSourcesMigration} ${ProtoGrpcSourcesMigration})
foreach(PROTO_SRC ${ProtoSourcesEosCta} ${ProtoSourcesMigration} ${ProtoGrpcSourcesMigration} ${ProtoSourcesFrontendCta} ${ProtoGrpcSourcesFrontendCta})
set_property(SOURCE ${PROTO_SRC} PROPERTY COMPILE_FLAGS " -Wno-missing-field-initializers -fPIC -Wno-narrowing -Wno-implicit-fallthrough")
endforeach(PROTO_SRC)
......@@ -55,3 +63,11 @@ set_target_properties(EosMigration PROPERTIES
LINKER_LANGUAGE CXX
POSITION_INDEPENDENT_CODE TRUE)
target_link_libraries(EosMigration ${PROTOBUF3_GRPC_LIBRARIES})
add_library(CtaGRpc ${ProtoSourcesFrontendCta} ${ProtoGrpcSourcesFrontendCta})
set_target_properties(CtaGRpc PROPERTIES
LINKER_LANGUAGE CXX
POSITION_INDEPENDENT_CODE TRUE)
target_link_libraries(CtaGRpc ${PROTOBUF3_GRPC_LIBRARIES})
add_dependencies(CtaGRpc XrdSsiPbEosCta)
\ No newline at end of file
# @project The CERN Tape Archive (CTA)
# @copyright 2021 DESY
# @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
# 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/>.
cmake_minimum_required (VERSION 2.6)
add_subdirectory(gRPC)
# @project The CERN Tape Archive (CTA)
# @copyright Copyright(C) 2021 DESY
# @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
# 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/>.
cmake_minimum_required (VERSION 2.6)
find_package(Protobuf3 REQUIRED)
include_directories(${CMAKE_BINARY_DIR}/eos_cta
${PROTOBUF3_INCLUDE_DIRS})
add_executable(frontend-grpc-svc FrontendGRpcSvc.cpp)
target_link_libraries(frontend-grpc-svc CtaGRpc
${PROTOBUF3_LIBRARIES} ${GRPC_GRPC++_LIBRARY}
ctascheduler ctacommon ctaobjectstore ctacatalogue)
set_property(TARGET frontend-grpc-svc APPEND PROPERTY INSTALL_RPATH ${PROTOBUF3_RPATH})
\ No newline at end of file
/*
* @project The CERN Tape Archive (CTA)
* @copyright Copyright(C) 2021 CERN
* @copyright Copyright(C) 2021 DESY
* @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
* 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 "FrontendGRpcSvc.h"
#include "version.h"
using grpc::Server;
using grpc::ServerBuilder;
using grpc::ServerContext;
using grpc::Status;
using cta::rpc::CtaRpc;
#include "common/log/SyslogLogger.hpp"
#include "common/log/StdoutLogger.hpp"
#include "common/log/FileLogger.hpp"
#include "common/log/LogLevel.hpp"
class CtaRpcImpl final : public CtaRpc::Service {
Status Version(::grpc::ServerContext* context, const ::google::protobuf::Empty* request, ::cta::admin::Version* response) override {
response->set_cta_version(CTA_VERSION);
response->set_xrootd_ssi_protobuf_interface_version("gPRC-frontend v0.0.1");
return Status::OK;
}
};
using namespace cta;
int main(const int argc, char *const *const argv) {
std::unique_ptr <cta::log::Logger> m_log;
m_log.reset(new log::StdoutLogger("cta-dev", "cta-grpc-frontend"));
log::LogContext lc(*m_log);
std::string server_address("0.0.0.0:17017");
CtaRpcImpl svc;
// grpc::EnableDefaultHealthCheckService(true);
// grpc::reflection::InitProtoReflectionServerBuilderPlugin();
ServerBuilder builder;
// Listen on the given address without any authentication mechanism.
builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
// Register "service" as the instance through which we'll communicate with
// clients. In this case it corresponds to an *synchronous* service.
builder.RegisterService(&svc);
// Finally assemble the server.
std::unique_ptr <Server> server(builder.BuildAndStart());
lc.log(log::INFO, "Listening on socket address: " + server_address);
// Wait for the server to shutdown. Note that some other thread must be
// responsible for shutting down the server for this call to ever return.
server->Wait();
}
\ No newline at end of file
#ifndef CTA_FRONTENDGRPCSVC_H
#define CTA_FRONTENDGRPCSVC_H
#include <grpcpp/grpcpp.h>
#include "catalogue/CatalogueFactoryFactory.hpp"
#include "rdbms/Login.hpp"
#include <common/Configuration.hpp>
#include <common/utils/utils.hpp>
#include <scheduler/Scheduler.hpp>
#include <scheduler/OStoreDB/OStoreDBInit.hpp>
#include "common/log/SyslogLogger.hpp"
#include "common/log/StdoutLogger.hpp"
#include "common/log/FileLogger.hpp"
#include "common/log/LogLevel.hpp"
#include "cta_rpc.grpc.pb.h"
#endif //CTA_FRONTENDGRPCSVC_H
syntax = "proto3";
option java_multiple_files = true;
option java_package = "ch.cern.cta.rpc";
option optimize_for = CODE_SIZE;
package cta.rpc;
import "google/protobuf/empty.proto";
import "cta_admin.proto";
//
// gRPC interface to CTA frontend
//
service CtaRpc {
rpc Version (google.protobuf.Empty) returns (cta.admin.Version) {}
}
\ No newline at end of file
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