-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5c99837
commit 4511384
Showing
14 changed files
with
482 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@PACKAGE_INIT@ | ||
include(CMakeFindDependencyMacro) | ||
get_filename_component(BookkeepingProtoApi_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) | ||
|
||
find_dependency(Protobuf CONFIG REQUIRED) | ||
find_dependency(gRPC REQUIRED) | ||
|
||
if(NOT TARGET AliceO2::BookkeepingProtoApi) | ||
include("${BookkeepingProtoApi_CMAKE_DIR}/BookkeepingProtoApiTargets.cmake") | ||
endif() | ||
|
||
message(STATUS "BookkeepingProtoApi-O2 ${BookkeepingApi_VERSION} found") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright 2019-2020 CERN and copyright holders of ALICE O2. | ||
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. | ||
// All rights not expressly granted are reserved. | ||
// | ||
// This software is distributed under the terms of the GNU General Public | ||
// License v3 (GPL Version 3), copied verbatim in the file "COPYING". | ||
// | ||
// In applying this license CERN does not waive the privileges and immunities | ||
// granted to it by virtue of its status as an Intergovernmental Organization | ||
// or submit itself to any jurisdiction. | ||
|
||
#include <stdexcept> | ||
#include <iostream> | ||
#include <sstream> | ||
#include "BookkeepingApi/BkpProtoClientFactory.h" | ||
#include "run.pb.h" | ||
#include "dplProcessExecution.pb.h" | ||
|
||
using namespace o2::bkp::api::proto; | ||
using namespace o2::bookkeeping; | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
if (argc < 2) { | ||
std::cerr << "You need to provide the gRPC URI as first argument" << std::endl; | ||
exit(1); | ||
} | ||
|
||
try { | ||
auto client = BkpProtoClientFactory::create(argv[1]); | ||
|
||
// First option: direct implementation, using constructed request | ||
auto request = std::make_shared<RunFetchRequest>(); | ||
request->set_runnumber(106); | ||
request->add_relations(RUN_RELATIONS_LHC_FILL); | ||
std::shared_ptr<RunWithRelations> run106WithRelations = client->run()->Get(request); | ||
std::ostringstream messageStreamRun106; | ||
messageStreamRun106 << "Retrieved run 106 info, such as time o2 start <" << run106WithRelations->run().timeo2start() << ">"; | ||
if (run106WithRelations->has_lhcfill()) { | ||
messageStreamRun106 << " and related fill info such as fill beam type <" << run106WithRelations->lhcfill().beamtype() << ">"; | ||
} | ||
std::cout << messageStreamRun106.str() << std::endl; | ||
|
||
// Second option: use shortcut method | ||
std::shared_ptr<RunWithRelations> run105WithRelations = client->run()->Get(105, { RUN_RELATIONS_LHC_FILL }); | ||
std::ostringstream messageStreamRun105; | ||
messageStreamRun105 << "Retrieved run 105 info, such as time o2 start <" << run106WithRelations->run().timeo2start() << ">"; | ||
if (run106WithRelations->has_lhcfill()) { | ||
messageStreamRun105 << " and related fill info such as fill beam type <" << run106WithRelations->lhcfill().beamtype() << ">"; | ||
} | ||
std::cout << messageStreamRun105.str() << std::endl; | ||
|
||
// Test of DPL process execution | ||
auto creationRequest = std::make_shared<DplProcessExecutionCreationRequest>(); | ||
creationRequest->set_runnumber(106); | ||
creationRequest->set_detectorname("DETECTOR"); | ||
creationRequest->set_processname("PROCESS-NAME"); | ||
creationRequest->set_type(o2::bookkeeping::DPL_PROCESS_TYPE_MERGER); | ||
creationRequest->set_hostname("HOSTNAME"); | ||
std::shared_ptr<DplProcessExecution> dplProcessExecution = client->dplProcessExecution()->Create(creationRequest); | ||
|
||
// Short version | ||
client->dplProcessExecution()->registerProcessExecution(106, o2::bookkeeping::DPL_PROCESS_TYPE_QC_CHECKER, "SECOND-HOSTNAME", "PROCESS-NAME", "", "DEFAUlT"); | ||
} catch (std::runtime_error& error) { | ||
std::cerr << "An error occurred: " << error.what() << std::endl; | ||
exit(2); | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2019-2020 CERN and copyright holders of ALICE O2. | ||
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. | ||
// All rights not expressly granted are reserved. | ||
// | ||
// This software is distributed under the terms of the GNU General Public | ||
// License v3 (GPL Version 3), copied verbatim in the file "COPYING". | ||
// | ||
// In applying this license CERN does not waive the privileges and immunities | ||
// granted to it by virtue of its status as an Intergovernmental Organization | ||
// or submit itself to any jurisdiction. | ||
|
||
#ifndef CXX_CLIENT_BOOKKEEPINGAPI_BKPPROTOCLIENT_H | ||
#define CXX_CLIENT_BOOKKEEPINGAPI_BKPPROTOCLIENT_H | ||
|
||
#include <memory> | ||
#include "RunProtoClient.h" | ||
#include "DplProcessExecutionProtoClient.h" | ||
|
||
namespace o2::bkp::api::proto { | ||
class BkpProtoClient { | ||
public: | ||
virtual ~BkpProtoClient() = default; | ||
|
||
/// Returns the implementation of the Run service defined in run.proto | ||
virtual const std::unique_ptr<RunProtoClient>& run() const = 0; | ||
|
||
/// Returns the implementation of the DPL process execution service defined in dpl-process-execution.proto | ||
virtual const std::unique_ptr<DplProcessExecutionProtoClient>& dplProcessExecution() const = 0; | ||
}; | ||
} | ||
|
||
#endif // CXX_CLIENT_BOOKKEEPINGAPI_BKPPROTOCLIENT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// Created by mboulais on 02/03/23. | ||
// | ||
|
||
#ifndef CXX_CLIENT_BOOKKEEPINGAPI_BKPPROTOCLIENTFACTORY_H | ||
#define CXX_CLIENT_BOOKKEEPINGAPI_BKPPROTOCLIENTFACTORY_H | ||
|
||
#include <memory> | ||
#include "BkpProtoClient.h" | ||
|
||
namespace o2::bkp::api::proto { | ||
class BkpProtoClientFactory { | ||
public: | ||
BkpProtoClientFactory() = delete; | ||
|
||
/// Provides a Bookkeeping proto API client configured from a given configuration URI | ||
/// Proto api implements the services defined in the proto files | ||
static ::std::unique_ptr<BkpProtoClient> create(const ::std::string& gRPCUri); | ||
}; | ||
} | ||
|
||
#endif // CXX_CLIENT_BOOKKEEPINGAPI_BKPPROTOCLIENTFACTORY_H |
40 changes: 40 additions & 0 deletions
40
cxx-client/include/BookkeepingApi/DplProcessExecutionProtoClient.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright 2019-2020 CERN and copyright holders of ALICE O2. | ||
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. | ||
// All rights not expressly granted are reserved. | ||
// | ||
// This software is distributed under the terms of the GNU General Public | ||
// License v3 (GPL Version 3), copied verbatim in the file "COPYING". | ||
// | ||
// In applying this license CERN does not waive the privileges and immunities | ||
// granted to it by virtue of its status as an Intergovernmental Organization | ||
// or submit itself to any jurisdiction. | ||
|
||
#ifndef CXX_CLIENT_BOOKKEEPINGAPI_DPLPROCESSEXECUTIONPROTOCLIENT_H | ||
#define CXX_CLIENT_BOOKKEEPINGAPI_DPLPROCESSEXECUTIONPROTOCLIENT_H | ||
|
||
#include <memory> | ||
#include "dplProcessExecution.pb.h" | ||
|
||
namespace o2::bkp::api::proto | ||
{ | ||
class DplProcessExecutionProtoClient | ||
{ | ||
public: | ||
virtual ~DplProcessExecutionProtoClient() = default; | ||
|
||
/// Returns the implementation of the DPL process execution service defined in dplProcessExecution.proto | ||
virtual std::shared_ptr<o2::bookkeeping::DplProcessExecution> Create(std::shared_ptr<o2::bookkeeping::DplProcessExecutionCreationRequest> request) = 0; | ||
|
||
/// Register the execution fo a DPL process | ||
virtual void registerProcessExecution( | ||
int runNumber, | ||
o2::bookkeeping::DplProcessType type, | ||
std::string hostname, | ||
std::string deviceId, | ||
std::string args, | ||
std::string detector | ||
) = 0; | ||
}; | ||
} // namespace o2::bkp::api::proto | ||
|
||
#endif // CXX_CLIENT_BOOKKEEPINGAPI_DPLPROCESSEXECUTIONPROTOCLIENT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// Created by mboulais on 02/03/23. | ||
// | ||
|
||
#ifndef CXX_CLIENT_BOOKKEEPINGAPI_RUNPROTOCLIENT_H | ||
#define CXX_CLIENT_BOOKKEEPINGAPI_RUNPROTOCLIENT_H | ||
|
||
#include <memory> | ||
#include "run.pb.h" | ||
|
||
namespace o2::bkp::api::proto | ||
{ | ||
class RunProtoClient | ||
{ | ||
public: | ||
virtual ~RunProtoClient() = default; | ||
|
||
/// Returns the run corresponding to the given run number with optionally its relations | ||
virtual std::shared_ptr<bookkeeping::RunWithRelations> Get(const int runNumber, const std::vector<o2::bookkeeping::RunRelations>& relations) = 0; | ||
|
||
/// Returns the run and the asked relations defined in the given request | ||
virtual std::shared_ptr<o2::bookkeeping::RunWithRelations> Get(std::shared_ptr<o2::bookkeeping::RunFetchRequest> request) = 0; | ||
}; | ||
} // namespace o2::bkp::api::proto | ||
|
||
#endif // CXX_CLIENT_BOOKKEEPINGAPI_RUNPROTOCLIENT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "BookkeepingApi/BkpProtoClientFactory.h" | ||
#include "grpc/GrpcBkpProtoClient.h" | ||
|
||
namespace o2::bkp::api::proto | ||
{ | ||
std::unique_ptr<BkpProtoClient> BkpProtoClientFactory::create(const std::string& gRPCUri) | ||
{ | ||
return std::make_unique<grpc::GrpcBkpProtoClient>(gRPCUri); | ||
} | ||
}; // namespace o2::bkp::api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright 2019-2020 CERN and copyright holders of ALICE O2. | ||
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. | ||
// All rights not expressly granted are reserved. | ||
// | ||
// This software is distributed under the terms of the GNU General Public | ||
// License v3 (GPL Version 3), copied verbatim in the file "COPYING". | ||
// | ||
// In applying this license CERN does not waive the privileges and immunities | ||
// granted to it by virtue of its status as an Intergovernmental Organization | ||
// or submit itself to any jurisdiction. | ||
|
||
#include "GrpcBkpProtoClient.h" | ||
#include <grpc++/grpc++.h> | ||
#include <memory> | ||
#include "grpc/services/GrpcRunProtoClient.h" | ||
#include "grpc/services/GrpcDplProcessExecutionProtoClient.h" | ||
|
||
using grpc::InsecureChannelCredentials; | ||
using o2::bkp::api::proto::RunProtoClient; | ||
using std::make_unique; | ||
|
||
namespace o2::bkp::api::proto::grpc | ||
{ | ||
GrpcBkpProtoClient::GrpcBkpProtoClient(const std::string& uri) | ||
{ | ||
auto channel = CreateChannel(uri, InsecureChannelCredentials()); | ||
mRunClient = make_unique<services::GrpcRunProtoClient>(channel); | ||
mDplProcessExecutionClient = make_unique<services::GrpcDplProcessExecutionProtoClient>(channel); | ||
} | ||
|
||
const std::unique_ptr<RunProtoClient>& GrpcBkpProtoClient::run() const | ||
{ | ||
return mRunClient; | ||
} | ||
|
||
const std::unique_ptr<DplProcessExecutionProtoClient>& GrpcBkpProtoClient::dplProcessExecution() const | ||
{ | ||
return mDplProcessExecutionClient; | ||
} | ||
} // namespace o2::bkp::api::proto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2019-2020 CERN and copyright holders of ALICE O2. | ||
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. | ||
// All rights not expressly granted are reserved. | ||
// | ||
// This software is distributed under the terms of the GNU General Public | ||
// License v3 (GPL Version 3), copied verbatim in the file "COPYING". | ||
// | ||
// In applying this license CERN does not waive the privileges and immunities | ||
// granted to it by virtue of its status as an Intergovernmental Organization | ||
// or submit itself to any jurisdiction. | ||
|
||
#ifndef CXX_CLIENT_BOOKKEEPINGAPI_GRPCBKPPROTOCLIENT_H | ||
#define CXX_CLIENT_BOOKKEEPINGAPI_GRPCBKPPROTOCLIENT_H | ||
|
||
#include "BookkeepingApi/BkpProtoClient.h" | ||
|
||
namespace o2::bkp::api::proto::grpc | ||
{ | ||
class GrpcBkpProtoClient : public BkpProtoClient | ||
{ | ||
public: | ||
explicit GrpcBkpProtoClient(const std::string& uri); | ||
~GrpcBkpProtoClient() override = default; | ||
|
||
const std::unique_ptr<RunProtoClient>& run() const override; | ||
|
||
const std::unique_ptr<DplProcessExecutionProtoClient>& dplProcessExecution() const override; | ||
|
||
private: | ||
std::unique_ptr<::o2::bkp::api::proto::RunProtoClient> mRunClient; | ||
std::unique_ptr<::o2::bkp::api::proto::DplProcessExecutionProtoClient> mDplProcessExecutionClient; | ||
}; | ||
} // namespace o2::bkp::api::proto | ||
|
||
#endif // CXX_CLIENT_BOOKKEEPINGAPI_GRPCBKPPROTOCLIENT_H |
Oops, something went wrong.