ndb_cassandra_admin.xml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?xml version="1.0" encoding='ISO-8859-1'?>
  2. <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
  4. <!-- Include general documentation entities -->
  5. <!ENTITY % docentities SYSTEM "../../../docbook/entities.xml">
  6. %docentities;
  7. ]>
  8. <!-- Module User's Guide -->
  9. <chapter>
  10. <title>&adminguide;</title>
  11. <section>
  12. <title>Overview</title>
  13. <para>
  14. Apache Cassandra is an open source distributed database management system.
  15. It is designed to handle very large amounts of data spread out across many
  16. servers. It is a NoSQL solution.
  17. </para>
  18. <para>
  19. The module allows the insertion and retrieval of information from Cassandra
  20. clusters. This is not a DB driver module.
  21. </para>
  22. </section>
  23. <section>
  24. <title>Dependencies</title>
  25. <section>
  26. <title>&kamailio; Modules</title>
  27. <para>
  28. The following modules must be loaded before this module:
  29. <itemizedlist>
  30. <listitem>
  31. <para>
  32. <emphasis>none</emphasis>.
  33. </para>
  34. </listitem>
  35. </itemizedlist>
  36. </para>
  37. </section>
  38. <section>
  39. <title>External Libraries or Applications</title>
  40. <para>
  41. This module depends on the thrift library version 0.7.0. Please install this
  42. library in order to be able to successful compile this module. You can find
  43. this library at http://thrift.apache.org/
  44. <itemizedlist>
  45. <listitem>
  46. <para>
  47. <emphasis>thrift 0.7.0</emphasis> - available at
  48. http://thrift.apache.org/
  49. </para>
  50. </listitem>
  51. </itemizedlist>
  52. </para>
  53. </section>
  54. </section>
  55. <section>
  56. <title>Parameters</title>
  57. <section>
  58. <title><varname>host</varname> (str)</title>
  59. <para>
  60. Host of Cassandra node.
  61. </para>
  62. <title><varname>port</varname> (int)</title>
  63. <para>
  64. Port of Cassandra node.
  65. </para>
  66. <example>
  67. <title>Set <varname>host</varname> and <varname>port</varname> parameters</title>
  68. <programlisting format="linespecific">
  69. ...
  70. modparam("ndb_cassandra", "host", "10.22.22.190")
  71. modparam("ndb_cassandra", "port", 9160)
  72. ...
  73. </programlisting>
  74. </example>
  75. </section>
  76. </section>
  77. <section>
  78. <title>Functions</title>
  79. <section>
  80. <title>
  81. <function moreinfo="none">cass_insert(keyspace, column_family, key, column, value)</function>
  82. </title>
  83. <para>
  84. Inserts the value for the given key, column, column_family and keyspace.
  85. There must be an existing keyspace called 'keyspace' with a column_family
  86. called 'column_family' in the targeted Cassandra node.
  87. </para>
  88. <para>
  89. Return integer needs to be checked:
  90. <itemizedlist>
  91. <listitem>
  92. <para>ret &lt; 0, error</para>
  93. </listitem>
  94. <listitem>
  95. <para>ret &gt; 0, success</para>
  96. </listitem>
  97. </itemizedlist>
  98. </para>
  99. </section>
  100. <section>
  101. <title>
  102. <function moreinfo="none">cass_retrieve(keyspace, column_family, key, column, value)</function>
  103. </title>
  104. <para>
  105. Retrieves the value for the given key, column, column_family and keyspace.
  106. There must be an existing keyspace called 'keyspace' with a column_family
  107. called 'column_family' in the targeted Cassandra node.
  108. </para>
  109. <para>
  110. <varname>value</varname> will be returned as well as a integer return code.
  111. </para>
  112. <para>
  113. Return integer needs to be checked:
  114. <itemizedlist>
  115. <listitem>
  116. <para>
  117. ret &lt; 0, error
  118. </para>
  119. </listitem>
  120. <listitem>
  121. <para>
  122. ret &gt; 0, success
  123. </para>
  124. </listitem>
  125. </itemizedlist>
  126. </para>
  127. </section>
  128. <example>
  129. <title>Example usage</title>
  130. <programlisting format="linespecific">
  131. ...
  132. loadmodule "ndb_cassandra.so"
  133. # (...)
  134. modparam("ndb_cassandra", "host", "10.22.22.190")
  135. modparam("ndb_cassandra", "port", 9160)
  136. # (...)
  137. xlog("L_DBG", "Testing ndb_cassandra module.");
  138. # Inserting to cassandra
  139. $var(keyspace) = "indigital";
  140. $var(column_family) = "employees";
  141. $var(column) = "name";
  142. $var(val_write) = "TestMyName"; # To be written
  143. if (cass_insert("$var(keyspace)", "$var(column_family)", "$ru", "$var(column)", "$var(val_write)") > 0) {
  144. xlog("L_DBG", "ndb_cassandra. Sucess while inserting to Cassandra. val_write: \"$var(val_write)\"");
  145. } else {
  146. xlog("L_DBG", "ndb_cassandra. Error while inserting to Cassandra");
  147. }
  148. # Retrieving from cassandra
  149. $var(keyspace) = "indigital";
  150. $var(column_family) = "employees";
  151. $var(key) = "sip:10.22.22.110"; # Before we saved our $ru, which was 'sip:10.22.22.110'
  152. $var(column) = "name";
  153. $var(val_read) = ""; # To be read
  154. if (cass_retrieve("$var(keyspace)", "$var(column_family)", "$var(key)", "$var(column)", "$var(val_read)") > 0) {
  155. xlog("L_DBG", "ndb_cassandra. Sucess while reading from Cassandra. val_read: \"$var(val_read)\"");
  156. } else {
  157. xlog("L_DBG", "ndb_cassandra. Error while reading from Cassandra");
  158. }
  159. ...
  160. </programlisting>
  161. </example>
  162. </section>
  163. </chapter>