Debian Codegraph @

src/modules/ndb_cassandra/README

raw
1 NDB_CASSANDRA Module
2
3 Luis Martin Gil
4
5 <[email protected]>
6
7 Edited by
8
9 Luis Martin Gil
10
11 <[email protected]>
12
13 Copyright © 2013 www.indigital.net
14 __________________________________________________________________
15
16 Table of Contents
17
18 1. Admin Guide
19
20 1. Overview
21 2. Dependencies
22
23 2.1. Kamailio Modules
24 2.2. External Libraries or Applications
25
26 3. Parameters
27
28 3.1. host (str)
29
30 4. Functions
31
32 4.1. cass_insert(keyspace, column_family, key, column,
33 value)
34
35 4.2. cass_retrieve(keyspace, column_family, key, column,
36 value)
37
38 List of Examples
39
40 1.1. Set host and port parameters
41 1.2. Example usage
42
43 Chapter 1. Admin Guide
44
45 Table of Contents
46
47 1. Overview
48 2. Dependencies
49
50 2.1. Kamailio Modules
51 2.2. External Libraries or Applications
52
53 3. Parameters
54
55 3.1. host (str)
56
57 4. Functions
58
59 4.1. cass_insert(keyspace, column_family, key, column, value)
60 4.2. cass_retrieve(keyspace, column_family, key, column, value)
61
62 1. Overview
63
64 Apache Cassandra is an open source distributed database management
65 system. It is designed to handle very large amounts of data spread out
66 across many servers. It is a NoSQL solution.
67
68 The module allows the insertion and retrieval of information from
69 Cassandra clusters. This is not a DB driver module.
70
71 2. Dependencies
72
73 2.1. Kamailio Modules
74 2.2. External Libraries or Applications
75
76 2.1. Kamailio Modules
77
78 The following modules must be loaded before this module:
79 * none.
80
81 2.2. External Libraries or Applications
82
83 This module depends on the thrift library version 0.7.0. Please install
84 this library in order to be able to successful compile this module. You
85 can find this library at http://thrift.apache.org/
86 * thrift 0.7.0 - available at http://thrift.apache.org/
87
88 3. Parameters
89
90 3.1. host (str)
91
92 3.1. host (str)
93
94 3.1. host (str)
95
96 Host of Cassandra node.
97
98 Port of Cassandra node.
99
100 Example 1.1. Set host and port parameters
101 ...
102 modparam("ndb_cassandra", "host", "10.22.22.190")
103 modparam("ndb_cassandra", "port", 9160)
104 ...
105
106 4. Functions
107
108 4.1. cass_insert(keyspace, column_family, key, column, value)
109 4.2. cass_retrieve(keyspace, column_family, key, column, value)
110
111 4.1. cass_insert(keyspace, column_family, key, column, value)
112
113 Inserts the value for the given key, column, column_family and
114 keyspace. There must be an existing keyspace called 'keyspace' with a
115 column_family called 'column_family' in the targeted Cassandra node.
116
117 Return integer needs to be checked:
118 * ret < 0, error
119 * ret > 0, success
120
121 4.2. cass_retrieve(keyspace, column_family, key, column, value)
122
123 Retrieves the value for the given key, column, column_family and
124 keyspace. There must be an existing keyspace called 'keyspace' with a
125 column_family called 'column_family' in the targeted Cassandra node.
126
127 value will be returned as well as an integer return code.
128
129 Return integer needs to be checked:
130 * ret < 0, error
131 * ret > 0, success
132
133 Example 1.2. Example usage
134 ...
135 loadmodule "ndb_cassandra.so"
136 # (...)
137 modparam("ndb_cassandra", "host", "10.22.22.190")
138 modparam("ndb_cassandra", "port", 9160)
139 # (...)
140 xlog("L_DBG", "Testing ndb_cassandra module.");
141 # Inserting to cassandra
142 $var(keyspace) = "indigital";
143 $var(column_family) = "employees";
144 $var(column) = "name";
145 $var(val_write) = "TestMyName"; # To be written
146 if (cass_insert("$var(keyspace)", "$var(column_family)", "$ru", "$var(column
147 )", "$var(val_write)") > 0) {
148 xlog("L_DBG", "ndb_cassandra. Success while inserting to Cassandra. val_w
149 rite: \"$var(val_write)\"");
150 } else {
151 xlog("L_DBG", "ndb_cassandra. Error while inserting to Cassandra");
152 }
153
154 # Retrieving from cassandra
155 $var(keyspace) = "indigital";
156 $var(column_family) = "employees";
157 $var(key) = "sip:10.22.22.110"; # Before we saved our $ru, which was 'sip:10
158 .22.22.110'
159 $var(column) = "name";
160 $var(val_read) = ""; # To be read
161 if (cass_retrieve("$var(keyspace)", "$var(column_family)", "$var(key)", "$va
162 r(column)", "$var(val_read)") > 0) {
163 xlog("L_DBG", "ndb_cassandra. Success while reading from Cassandra. val_r
164 ead: \"$var(val_read)\"");
165 } else {
166 xlog("L_DBG", "ndb_cassandra. Error while reading from Cassandra");
167 }
168 ...