Class Connection
Class that stablish a connection with Kivi-direct to use the KiVi API. Only one connection can be active at the same time so it is needed to close the current connection before connecting to another Leanxcale instance
In order to interact with Leanxcale, it is needed a session provider that will age every session along all the datastore nodes. This API supports two connections modes: a basic one that is based on the session timestamp, and an external provider, that will provide the age for every new session. To use the external one, its address must be provided at the "ltmport" and "ltmip" parameters when calling dial(String, String, String, String, String).
This class allows also to list all the tables in a Leanxcale node.
It also provides a couple of method for debugging as debug(String) and lastError().
Inheritance
Inherited Members
Namespace: lxapi
Assembly: lxapi.dll
Syntax
public class Connection
Examples
Connect to a Leanxcale node with user "user1" which metadata server is running at ip "10.8.0.11" and port "44000", and its external provider is running at the same address but at port "9876". Also in this example, network logs are activated before dialing in order to find out any network problem. Finally, it prints the list of database tables before closing and dialing to another node.
Connection.debug("+1DN");
Connection.dial("user1", "10.8.0.11", "44000", "9876");
List <string> tables = Connection.tables();
foreach (string tname in tables)
{
Console.WriteLine("Table {0}", tname);
}
Connection.close();
Connection.dial("user2", "138.2.1.37", "44000", "9876", "138.2.1.50");
Methods
close()
Close the connection
Declaration
public static void close()
Exceptions
Type | Condition |
---|---|
LxException | Thrown when connection was already closed. |
debug(String)
For debugging, takes a debug flag string, updates debug flags, and returns debug flags in use. Debug flags are named using letters. If it starts with a plus sign, flags that follow are added (or their level increased). A minus sign before the flags clears them. Otherwise, debug flags are set exactly to the ones given.
Declaration
public static string debug(string what)
Parameters
Type | Name | Description |
---|---|---|
System.String | what | debug flag string |
Returns
Type | Description |
---|---|
System.String | current debug flag string |
dial(String, String, String, String, String)
Connect to a metadata server and optionally to an LTM server. Only one session can be active.
Declaration
public static void dial(string uid, string ip, string port, string ltmport = null, string ltmip = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | uid | User id |
System.String | ip | Metadat ip |
System.String | port | Metadata port |
System.String | ltmport | LTM server port |
System.String | ltmip | LTM server IP. It use |
Examples
Connect to a Leanxcale node with user "user1" which metadata server is running at ip "10.8.0.11" and port "44000", and its external provider is running at ip "10.8.0.9" and port "9876".
Connection.dial("user1", "10.8.0.11", "44000", "9876", "10.8.0.9");
dial(String, String[])
Connect to the metadata servers with user. Only one session can be active.
Declaration
public static void dial(string uid, string[] maddrs)
Parameters
Type | Name | Description |
---|---|---|
System.String | uid | User id |
System.String[] | maddrs | Addresses for the metadata servers |
Examples
Connect to two metadata servers running at ip "10.8.0.11" and port "44000", and at ip "10.8.0.12" and port "9876".
string[] metaservers = {"10.8.0.11!44000", "10.8.0.12!44000"};
Connection.dial("user1", metaservers);
Exceptions
Type | Condition |
---|---|
LxException | Thrown when connection failed. |
lastError()
Retrieve last error message
Declaration
public static string lastError()
Returns
Type | Description |
---|---|
System.String | last error message |
tables()
List database tables
Declaration
public static List<string> tables()
Returns
Type | Description |
---|---|
System.Collections.Generic.List<System.String> | List of database tables |