Skip to content

Commit b6df8cc

Browse files
kouzinopoulosMohammadAlTurany
authored andcommitted
Add a Riak backend to CCDB
1 parent 7b86ff5 commit b6df8cc

17 files changed

Lines changed: 737 additions & 249 deletions

CCDB/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ set(MODULE_NAME "CCDB")
22

33
O2_SETUP(NAME ${MODULE_NAME})
44

5+
PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS src/request.proto)
6+
include_directories(${CMAKE_BINARY_DIR}/CCDB)
7+
58
set(SRCS
69
src/Manager.cxx
710
src/Condition.cxx
@@ -14,6 +17,7 @@ set(SRCS
1417
src/IdRunRange.cxx
1518
src/Storage.cxx
1619
src/XmlHandler.cxx
20+
src/ObjectHandler.cxx
1721
)
1822

1923
set(HEADERS
@@ -28,14 +32,17 @@ set(HEADERS
2832
include/${MODULE_NAME}/Manager.h
2933
include/${MODULE_NAME}/Storage.h
3034
include/${MODULE_NAME}/XmlHandler.h
35+
include/${MODULE_NAME}/ObjectHandler.h
3136
)
3237

3338
Set(NO_DICT_SRCS
3439
src/ConditionsMQServer.cxx
3540
src/ConditionsMQClient.cxx
41+
${PROTO_SRCS}
3642
)
3743

3844
set(LIBRARY_NAME ${MODULE_NAME})
45+
3946
set(LINKDEF src/CCDBLinkDef.h)
4047
set(BUCKET_NAME CCDB_bucket)
4148

CCDB/README

Lines changed: 0 additions & 14 deletions
This file was deleted.

CCDB/README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
## Conditions MQ
2+
3+
Conditions MQ is a client/server CCDB implementation for O2. Currently the implementation supports two backends, an OCDB and a Riak one.
4+
5+
### OCDB backend
6+
7+
To run the MQ server-client example with the MQ server replying with CDB objects to the client requests, the steps below should be followed:
8+
9+
* Create a local O2CDB instance using the following macro in <installation directory>/bin/config/:
10+
11+
```bash
12+
root -l fill_local_ocdb.C
13+
```
14+
15+
This will create "DET/Calib/Histo" calibration objects for a hundred runs in the subdirectory O2CDB/ under the current directory.
16+
17+
* In one shell run the server example:
18+
19+
```bash
20+
conditions-server --id parmq-server --mq-config <installation directory>/bin/config/conditions-server.json --first-input-name local://<installation directory>/bin/config/O2CDB --first-input-type OCDB
21+
```
22+
23+
* In a separate shell run the client example:
24+
25+
```bash
26+
conditions-client --id parmq-client --mq-config <installation directory>/bin/config/conditions-client.json --data-source OCDB
27+
```
28+
29+
### Riak backend
30+
31+
To run the MQ server-client example with the MQ server executing PUT or GET commands to a Riak cluster through an MQ broker, the steps below should be followed:
32+
33+
* In one shell run the server example:
34+
35+
```bash
36+
conditions-server --id parmq-server --mq-config <installation directory>/bin/config/conditions-server.json
37+
```
38+
39+
* In a separate shell run the client example:
40+
41+
```bash
42+
conditions-client --id parmq-client --mq-config <installation directory>/bin/config/conditions-client.json --data-source Riak
43+
```
44+
45+
List of optional client arguments:
46+
47+
- `operation-type` (default = "GET"): "PUT", "GET". Sets the operation type.
48+
- `object-path` (default = "./OCDB/"). Sets the directory that holds the condition objects.

CCDB/config/conditions-client.json

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,25 @@
66
"id": "parmq-client",
77
"channel":
88
{
9-
"name": "data",
9+
"name": "data-put",
1010
"socket":
1111
{
12-
"type": "req",
12+
"type": "push",
1313
"method": "connect",
1414
"address": "tcp://localhost:5005",
15+
"sndBufSize": "200",
16+
"rcvBufSize": "1000",
17+
"rateLogging": "0"
18+
}
19+
},
20+
"channel":
21+
{
22+
"name": "data-get",
23+
"socket":
24+
{
25+
"type": "req",
26+
"method": "connect",
27+
"address": "tcp://localhost:5006",
1528
"sndBufSize": "1000",
1629
"rcvBufSize": "1000",
1730
"rateLogging": "0"

CCDB/config/conditions-server.json

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,55 @@
66
"id": "parmq-server",
77
"channel":
88
{
9-
"name": "data",
9+
"name": "data-put",
1010
"socket":
1111
{
12-
"type": "rep",
12+
"type": "pull",
1313
"method": "bind",
1414
"address": "tcp://*:5005",
1515
"sndBufSize": "1000",
1616
"rcvBufSize": "1000",
1717
"rateLogging": "0"
1818
}
19+
},
20+
"channel":
21+
{
22+
"name": "data-get",
23+
"socket":
24+
{
25+
"type": "rep",
26+
"method": "bind",
27+
"address": "tcp://*:5006",
28+
"sndBufSize": "1000",
29+
"rcvBufSize": "1000",
30+
"rateLogging": "0"
31+
}
32+
},
33+
"channel":
34+
{
35+
"name": "broker-put",
36+
"socket":
37+
{
38+
"type": "push",
39+
"method": "connect",
40+
"address": "tcp://127.0.0.1:5558",
41+
"sndBufSize": "1000",
42+
"rcvBufSize": "1000",
43+
"rateLogging": "0"
44+
}
45+
},
46+
"channel":
47+
{
48+
"name": "broker-get",
49+
"socket":
50+
{
51+
"type": "req",
52+
"method": "connect",
53+
"address": "tcp://127.0.0.1:5559",
54+
"sndBufSize": "1000",
55+
"rcvBufSize": "1000",
56+
"rateLogging": "0"
57+
}
1958
}
2059
}
2160
}

CCDB/example/fill_local_ocdb.C

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
void fill_local_ocdb()
22
{
3-
gSystem->Load("libAliceO2Base");
4-
gSystem->Load("libAliceO2Cdb");
53
AliceO2::CDB::Manager* cdb = AliceO2::CDB::Manager::Instance();
64
cdb->setDefaultStorage("local://O2CDB");
75
TH1F* h = 0;

CCDB/include/CCDB/ConditionsMQClient.h

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
/********************************************************************************
22
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
4-
* This software is distributed under the terms of the *
5-
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
4+
* This software is distributed under the terms of the *
5+
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
66
* copied verbatim in the file "LICENSE" *
77
********************************************************************************/
88
/**
99
* ConditionsMQClient.h
1010
*
1111
* @since 2016-01-11
12-
* @author R. Grosso, from examples/MQ/7-parameters/FairMQExample7Client.h
12+
* @author R. Grosso, C. Kouzinopoulos from examples/MQ/7-parameters/FairMQExample7Client.h
1313
*/
1414

1515
#ifndef ALICEO2_CDB_CONDITIONSMQCLIENT_H_
@@ -22,35 +22,40 @@
2222
namespace AliceO2 {
2323
namespace CDB {
2424

25-
class ConditionsMQClient : public FairMQDevice
26-
{
27-
public:
28-
enum
29-
{
30-
ParameterName = FairMQDevice::Last,
31-
Last
32-
};
25+
class ConditionsMQClient : public FairMQDevice {
26+
public:
27+
enum { ParameterName = FairMQDevice::Last, OperationType, DataSource, ObjectPath, Last };
3328

34-
ConditionsMQClient();
29+
ConditionsMQClient();
3530

36-
virtual ~ConditionsMQClient();
31+
virtual ~ConditionsMQClient();
3732

38-
static void CustomCleanup(void *data, void *hint);
33+
virtual void SetProperty(const int key, const std::string& value);
34+
virtual std::string GetProperty(const int key, const std::string& default_ = "");
35+
virtual void SetProperty(const int key, const int value);
36+
virtual int GetProperty(const int key, const int default_ = 0);
3937

40-
virtual void SetProperty(const int key, const std::string &value);
38+
protected:
39+
virtual void Run();
4140

42-
virtual std::string GetProperty(const int key, const std::string &default_ = "");
41+
private:
42+
int fRunId;
43+
std::string fParameterName;
44+
std::string fOperationType;
45+
std::string fDataSource;
46+
std::string fObjectPath;
4347

44-
virtual void SetProperty(const int key, const int value);
48+
/// Serializes a key (and optionally value) to an std::string using Protocol Buffers
49+
void Serialize(std::string*& messageString, const std::string& key, const std::string& object = std::string());
4550

46-
virtual int GetProperty(const int key, const int default_ = 0);
51+
/// Deserializes a message and stores the value to an std::string using Protocol Buffers
52+
void Deserialize(const std::string& messageString, std::string& object);
4753

48-
protected:
49-
virtual void Run();
54+
/// Run loop when an OCDB backend is chosen
55+
void RunOCDB();
5056

51-
private:
52-
int fRunId;
53-
std::string fParameterName;
57+
/// Run loop when a Riak backend is chosen
58+
void RunRiak();
5459
};
5560
}
5661
}

CCDB/include/CCDB/ConditionsMQServer.h

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,48 @@
11
/********************************************************************************
22
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
4-
* This software is distributed under the terms of the *
5-
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
4+
* This software is distributed under the terms of the *
5+
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
66
* copied verbatim in the file "LICENSE" *
77
********************************************************************************/
88
/**
99
* ConditionsMQServer.h
1010
*
1111
* @since 2016-01-11
12-
* @author R. Grosso, from parmq/ParameterMQServer.h
12+
* @author R. Grosso, C. Kouzinopoulos from parmq/ParameterMQServer.h
1313
*/
1414

1515
#ifndef ALICEO2_CDB_CONDITIONSMQSERVER_H_
1616
#define ALICEO2_CDB_CONDITIONSMQSERVER_H_
1717

1818
#include <string>
1919

20-
#include "ParameterMQServer.h"
2120
#include "CCDB/Manager.h"
21+
#include "ParameterMQServer.h"
2222

2323
namespace AliceO2 {
2424
namespace CDB {
2525

26-
class ConditionsMQServer : public ParameterMQServer
27-
{
28-
public:
29-
ConditionsMQServer();
26+
class ConditionsMQServer : public ParameterMQServer {
27+
public:
28+
ConditionsMQServer();
29+
30+
virtual ~ConditionsMQServer();
31+
32+
virtual void Run();
33+
34+
virtual void InitTask();
3035

31-
virtual ~ConditionsMQServer();
36+
private:
37+
Manager* fCdbManager;
3238

33-
virtual void Run();
39+
void getFromOCDB(std::string key, int runId);
3440

35-
virtual void InitTask();
41+
/// Parses a serialized message for a data source entry
42+
void ParseDataSource(std::string& dataSource, const std::string& data);
3643

37-
private:
38-
Manager *fCdbManager;
44+
/// Parses a serialized message for a key entry
45+
void ParseKey(std::string& key, int& runId, const std::string& data);
3946
};
4047
}
4148
}

CCDB/include/CCDB/ObjectHandler.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#ifndef ALICE_O2_OBJECTHANDLER_H_
2+
#define ALICE_O2_OBJECTHANDLER_H_
3+
4+
#include <string>
5+
#include <vector>
6+
7+
using namespace std;
8+
9+
namespace AliceO2 {
10+
namespace CDB {
11+
12+
class ObjectHandler {
13+
public:
14+
ObjectHandler();
15+
virtual ~ObjectHandler();
16+
17+
/// Returns the binary payload of a ROOT file as an std::string
18+
void GetObject(const std::string& path, std::string& object);
19+
20+
/// Compresses uncompressed_string in to compressed_string using zlib
21+
void Compress(const std::string& uncompressed_string, std::string& compressed_string);
22+
void Decompress(std::string& uncompressed_string, const std::string& compressed_string);
23+
};
24+
}
25+
}
26+
#endif

CCDB/src/CCDBLinkDef.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#ifdef __CLING__
1+
#ifdef __CINT__
22

33
#pragma link off all globals;
44
#pragma link off all classes;

0 commit comments

Comments
 (0)