Newer
Older
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
## Installation
### Dependencies
#### hiredis
Either install from package manager or
> git clone https://github.com/redis/hiredis.git
> cd hiredis
> mkdir build && cd build
> cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/hiredis
> make -j9 && sudo make install
#### redis-plus-plus
> git clone https://github.com/sewenew/redis-plus-plus
> cd redis-plus-plus
> mkdir build && cd build
If redis has been manually installed in /usr/local/hiredis, then execute
> cmake .. -DCMAKE_INSTALL_PREFIX=/opt/redis-plus-plus -DCMAKE_PREFIX_PATH=/opt/hiredis -DHIREDIS_HEADER=/opt/redis-plus-plus/include
otherwise the options -DCMAKE_PREFIX_PATH and HIREDIS_HEADER is not necessary.
We experienced that CMAKE_PREFIX_PATH is not enough to let redis plus plus include hiredis files
correctly, and we need to add also -DHIREDIS_HEADER.
> make -j9
> sudo make install
### service Installation
Assuming the paths mentioned above were used to install hiredis and redis-plus-plus:
> git clone https://gitlab.elettra.eu/puma/server/ca-tango-db-cache-mgr
Adjust PKG_CONFIG_PATH according to the caserver-lib, hiredis, redis-plus-plus, cumbia-libs
installation paths. For example:
> export PKG_CONFIG_PATH=/opt/caserver-lib/lib/pkgconfig:/opt/hiredis/lib/pkgconfig:/opt/redis-plus-plus/lib/pkgconfig:$PKG_CONFIG_PATH
*nlohmann-json* dependency is also required. You can place a copy in the *subprojects* directory if the
package is not installed system-wide
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#### Subscribe to the attribute configuration change event and cache the configuration
Source *test/device/1/double_scalar*
> curl http://woody.elettra.eu:9296 -d $'{"srcs":[{"src":"test/device/1/double_scalar"}]}'
Three sources:
> curl -v http://taeyang.elettra.eu:9296 -d $'{"srcs":[{"src":"test/device/1/double_scalar"},{"src":"test/device/1/long_scalar"},{"src":"test/device/1/short_scalar"}]}'
The first source will be processed immediately, the others according to the
```
ca-tango-db-cache-mgr:subscribe-rate
```
option in the configuration file (subscribe rate per second: default: two subscriptions per second)
##### Expected reply
```json
{"msg":"ok","pos":0,"queue-cnt":3,"scheduled-cnt":3}
```
#### List the subscribed sources (method: "l")
> curl -v http://taeyang.elettra.eu:9296 -d $'{"method":"l"}'
##### Expected reply
```json
{"srcs":[{"src":"test/device/1/double_scalar"},{"src":"test/device/1/long_scalar"},{"src":"test/device/1/short_scalar"}]}
```
#### Process immediately all the queued sources (method "p")
If you want to subscribe immediately all the sources in the queue regardless the maximum rate per second
specified in the configuration:
> curl http://taeyang.elettra.eu:9296 -d $'{"method":"p"}'
##### Expected reply
```json
{
"count": 2,
"srcs": [
{
"msg": "ok",
"src": "test/device/1/long_scalar"
},
{
"msg": "ok",
"src": "test/device/1/short_scalar"
}
]
}
```
#### Unsubscribe a set of sources (method: "u")
Unsubscribe *double_scalar* and *long_scalar* from *test/device/1*:
> curl -v http://taeyang.elettra.eu:9296 -d $'{"method":"u", "srcs":[{"src":"test/device/1/double_scalar"},{"src":"test/device/1/long_scalar"}]}'
#### Expected reply
If the two sources were being monitored:
```json
{"count":2,"method":"u","removed":2,"srcs":[{"msg":"ok","src":"test/device/1/double_scalar"},{"msg":"ok","src":"test/device/1/long_scalar"}]}
```
In case of error (let's remove the two sources above twice):
```json
{"count":2,"method":"u","removed":0,"srcs":[{"msg":"attribute double_scalar not found (devicetest/device/1)","src":"test/device/1/double_scalar"},{"msg":"attribute long_scalar not found (devicetest/device/1)","src":"test/device/1/long_scalar"}]}
```
#### Read the saved configuration for a set of sources (method:"r")
This method can be useful to measure the time it takes to retrieve the configuration from the cache.
It can be compared with the time taken to query the Tango Database directly to get the same piece of
information.