Build TOP Environments

Developer

Precondition

About Specification
Persistence/Non-persistence chmpx connections for C++ API
About sample codes

C API

Debug family(C I/F)
For chmpx family(C I/F)
Last Response Code family(C I/F)
Get family(C I/F)
Get Direct family(C I/F)
Get Subkey family(C I/F)
Get Attribute family(C I/F)
Set family(C I/F)
Set Direct family(C I/F)
Set Subkey family(C I/F)
Clear Subkey family(C I/F)
Add Subkey family(C I/F)
Set All family(C I/F)
Remove Key family(C I/F)
Remove Subkey family(C I/F)
Rename Key family(C I/F)
Queue(KeyQUeue) Push family(C I/F)
Queue(KeyQUeue) Pop family(C I/F)
Queue(KeyQUeue) Remove family(C I/F)
CAS(Compare And Swap) Initialize family(C I/F)
CAS(Compare And Swap) Get family(C I/F)
CAS(Compare And Swap) Set family(C I/F)
CAS(Compare And Swap) Increment/Decrement family(C I/F)

C++ API

Debug family(C++ I/F)
Command Class Factory(C++ I/F)
K2hdkcComGet class
K2hdkcComGetDirect class
K2hdkcComGetSubkeys class
K2hdkcComGetAttrs class
K2hdkcComGetAttr class
K2hdkcComSet class
K2hdkcComSetDirect class
K2hdkcComSetSubkeys class
K2hdkcComSetAll class
K2hdkcComAddSubkeys class
K2hdkcComAddSubkey class
K2hdkcComDel class
K2hdkcComDelSubkeys class
K2hdkcComDelSubkey class
K2hdkcComRen class
K2hdkcComQPush class
K2hdkcComQPop class
K2hdkcComQDel class
K2hdkcComCasInit class
K2hdkcComCasGet class
K2hdkcComCasSet class
K2hdkcComCasIncDec class
K2hdkcComState class


Precondition

This section explains the premise for using the k2hdkc library.

About Specification

Before using the k2hdkc library, it is necessary to understand the specifications of the k2hdkc library. The k2hdkc cluster is built with communication middleware CHMPX and Key Value Store K2HASH library. You can create a program to access this k2hdkc cluster using the k2hdkc library.

k2hdkc API(C/C++ API) that accesses cluster data sends and receives communication commands internally via communication middleware(chmpx). When each API performs internal communication, use one of the following methods.

Although the internal operation of each API is the same, there is a difference whether to connect/disconnect with chmpx every operation of k2hdkc cluster data. Non-persistence chmpx connection is used when the client process can not maintain a persistence connection(ex. the program is implemented as a handler for HTTP process). Persistence chmpx connection can be used in a client process for a daemon.

Persistence/Non-persistence chmpx connections for C++ API

The C++ API has the following procedure differ depending on the case of Persistence/Non-persistence in connection with chmpx. However, although the procedure differs, the internal processing is the same except for the connection/disconnection processing to chmpx. The only difference is switching the call of global method(Implemented with MACROs) that creates a dedicated communication command class object.

Non-persistence chmpx connection for C++

For non-persistence chmpx connection in the C ++ API, call the library by the following procedure.

  1. Get global communication command class object using global GetOtSlaveK2hdkcCom…() method(MACRO).
  2. Call the CommandSend() method of the communication command class object to process it.
  3. The processing result is acquired by the GetResponseData() method of the communication command class object(It can also be acquired simultaneously by the CommandSend() method).
  4. Finally, destroy the communication command class object.

Persistence chmpx connection for C++

For Persistence chmpx connection in the C ++ API, call the library by the following procedure.

  1. Create a K2hdkcSlave class instance and initialize it with the Initialize() method.
  2. Call the Open() method of the K2hdkcSlave class instance and connect to chmpx.
  3. Call the global GetPmSlaveK2hdkcCom…() method(MACRO) with the K2hdkcSlave class instance and get the communication command class object.
  4. Call the CommandSend() method of the communication command class object to process it.
  5. The processing result is acquired by the GetResponseData() method of the communication command class object(It can also be acquired simultaneously by the CommandSend() method).
  6. Destroy the dedicated communication command class object.
  7. Repeat the above 3 to 6
  8. Call the Close() method of the K2hdkcSlave class instance and disconnect from chmpx.

About sample codes

A simple sample code is attached to the explanation of the C, C ++ API of this k2hdkc library interface. For detailed usage, it is recommended to refer to the source codes of k2hdkc test tool(k2hdkclinetool). The test tool contains codes comparable to almost all sample codes. You can use it as sample code by searching the desired function and method in the source codes.


C API

It is an API for C language. Include the following header files when developing.

#include <k2hdkc/k2hdkc.h>

When linking please specify the following as an option.

-lk2hdkc

The functions for C language are explained below. ***

Debug family(C I/F)

The k2hdkc library can output messages to check internal operation and API operation. This function group is a group of functions for controlling message output.

Format

Description

Parameters

Return Values

Note

For environment variables DKCDBGMODE, DKCDBGFILE, see Environments.

Examples

k2hdkc_bump_debug_level();
k2hdkc_set_debug_file("/var/log/k2hdkc/error.log");
k2hdkc_set_debug_level_message();

For chmpx family(C I/F)

This function group makes a persistent CHMPX connection to use the k2hdkc library. The handle k2hdkc_chmpx_h returned in this function group is a handle that can be used with k2hdkc library C I/F.

Format

Description

Parameters

Return Values

Examples

k2hdkc_chmpx_h    chmpxhandle;
if(K2HDKC_INVALID_HANDLE == (chmpxhandle = k2hdkc_open_chmpx_ex(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin, isCleanupBup))){
    exit(EXIT_FAILURE);
}
...
...
...

if(!k2hdkc_close_chmpx_ex(chmpxhandle, isCleanupBup)){
    fprintf(stderr, "Could not close(leave and close msgid) slave node chmpx, but continue for cleanup...\n");
}
chmpxhandle = K2HDKC_INVALID_HANDLE;        // force

Last Response Code family(C I/F)

After using the C API of the k2hdkc library, you can obtain the response code of the API.
The response code is 64 bits, indicating the success/failure with the upper 32 bits, and the lower 32 bits(subcode) indicates the detailed error.
Macro is provided for error code discrimination(See k2hdkccomstructure.h).
The error code is handled in the same way as errno in C language.

Format

Description

Parameters

Return Values

Examples

// get response code
dkcres_type_t    rescode = k2hdkc_get_lastres_code();

// check result
if(!result){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}else if(DKC_RES_SUBCODE_NOTHING != GET_DKC_RES_SUBCODE(rescode)){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}

Get family(C I/F)

This is a function group that obtains the value of the specified key from the cluster of k2hdkc.

Format

Description

These function groups are classified according to the following rules and classified into 4 types.

Each of the above types has similar functions with differences such as arguments.

In addition, depending on the connection type to chmpx slave node, it is divided into the following types.

Parameters

Return Values

Examples

// do command
unsigned char* pval = NULL;
size_t         vallength = 0;
bool           result = k2hdkc_full_get_value(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin, pkey, keylength, &pval, &vallength);
dkcres_type_t  rescode = k2hdkc_get_lastres_code();

// check result
if(!result){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}else if(DKC_RES_SUBCODE_NOTHING != GET_DKC_RES_SUBCODE(rescode)){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}
free(pval);

Get Direct family(C I/F)

This is a function group that obtains the value of the specified key from the cluster of k2hdkc. You can specify the position and size for the value to be acquired.

Format

Description

These function groups are classified according to the following rules and classified into 4 types.

Each of the above types has similar functions with differences such as arguments.

Parameters

Return Values

Note

Get Direct family does not have a type that does not perform attribute check(permission check) and type that specifies pass phrase like Get family.

Examples

// get direct
unsigned char**    ppval    = NULL;
size_t        vallen    = 0;
bool        result    = k2hdkc_full_da_get_value(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin, pkey, keylen, offset, length, ppval, &vallen);
dkcres_type_t    rescode    = k2hdkc_get_lastres_code();

// check result
if(!result){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}else if(DKC_RES_SUBCODE_NOTHING != GET_DKC_RES_SUBCODE(rescode)){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}

Get Subkey family(C I/F)

This function specifies a key and obtains a list of Subkeys from a k2hdkc cluster.

Format

Description

These function groups are classified according to the following rules and classified into 4 types.

Each of the above types has similar functions with differences such as arguments.

In addition, depending on the connection type to chmpx slave node, it is divided into the following types.

Parameters

Return Values

About structure

The base of the K2HDKCKEYPCK structure is defined in K2HASH. That structure is typedef by the k2hdkc library. You can use the following macro function(provided by k2hdkc) or k2hash API to release a pointer to this structured area and a pointer to an array of structures. The structure is as follows.

// structure
typedef struct k2h_key_pack{
    unsigned char*    pkey;
    size_t            length;
}K2HKEYPCK, *PK2HKEYPCK;
 
// typedefs by k2hdkc
typedef K2HKEYPCK                   K2HDKCKEYPCK;
typedef PK2HKEYPCK                  PK2HDKCKEYPCK;
 
// Free function
extern bool k2h_free_keypack(PK2HKEYPCK pkeys, int keycnt);
extern bool k2h_free_keyarray(char** pkeys);
 
// Free macro presented by k2hdkc
#define    DKC_FREE_KEYPACK            k2h_free_keypack
#define    DKC_FREE_KEYARRAY           k2h_free_keyarray

Examples

PK2HDKCKEYPCK    pskeypck = NULL;
int        skeypckcnt = 0;
bool        result = k2hdkc_full_get_subkeys(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin, pkey, keylength, &pskeypck, &skeypckcnt);
dkcres_type_t    rescode = k2hdkc_get_lastres_code();
 
// check result
if(!result){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}else if(DKC_RES_SUBCODE_NOTHING != GET_DKC_RES_SUBCODE(rescode)){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}

Get Attribute family(C I/F)

Function group that specifies a key and acquires an attribute from a k2hdkc cluster.

Format

Description

These function groups are classified according to the following rules and classified into 4 types.

Each of the above types has similar functions with differences such as arguments.

Parameters

Return Values

About structure

The base of the K2HDKCATTRPCK structure is defined in K2HASH. That structure is typedef by the k2hdkc library. You can use the following macro function(provided by k2hdkc) or k2hash API to release a pointer to this structured area and a pointer to an array of structures. The structure is as follows.

// for attributes list
typedef struct k2h_attr_pack{
    unsigned char*    pkey;
    size_t            keylength;
    unsigned char*    pval;
    size_t            vallength;
}K2HATTRPCK, *PK2HATTRPCK;
 
// typedefs by k2hdkc
typedef K2HATTRPCK                    K2HDKCATTRPCK;
typedef PK2HATTRPCK                    PK2HDKCATTRPCK;
 
// Free attributes array
extern bool k2h_free_attrpack(PK2HATTRPCK pattrs, int attrcnt);
 
// Free attributes macro presented by k2hdkc
#define    DKC_FREE_ATTRPACK    k2h_free_attrpack

Examples

PK2HDKCATTRPCK    pattrspck    = NULL;
int        attrspckcnt    = 0;
bool        result = k2hdkc_full_get_attrs(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin, reinterpret_cast<const unsigned char*>(strKey.c_str()), strKey.length() + 1, &pattrspck, &attrspckcnt);
dkcres_type_t    rescode= k2hdkc_get_lastres_code();
 
// check result
if(!result){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}else if(DKC_RES_SUBCODE_NOTHING != GET_DKC_RES_SUBCODE(rescode)){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
    DKC_FREE_ATTRPACK(pattrspck, attrspckcnt);
}

Set family(C I/F)

Function group that specifies a key and set a value to a k2hdkc cluster.

Format

Description

These function groups are classified according to the following rules and classified into 2 types.

Each of the above types has similar functions with differences such as arguments.

In addition, depending on the connection type to chmpx slave node, it is divided into the following types.

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Examples

bool        result = k2hdkc_full_set_value(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin, pKey, KeyLen, pVal, ValLen);
dkcres_type_t    rescode = k2hdkc_get_lastres_code();
 
// check result
if(!result){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}else if(DKC_RES_SUBCODE_NOTHING != GET_DKC_RES_SUBCODE(rescode)){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}

Set Direct family(C I/F)

Function group that specifies a key, position/length of the value and set a value to a k2hdkc cluster.

Format

Description

These function groups are classified according to the following rules and classified into 2 types.

Each of the above types has similar functions with differences such as arguments.

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Examples

bool        result    = k2hdkc_full_da_set_value(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin, pkey, keylen, pval, vallen, offset);
dkcres_type_t    rescode    = k2hdkc_get_lastres_code();
 
// check result
if(!result){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}else if(DKC_RES_SUBCODE_NOTHING != GET_DKC_RES_SUBCODE(rescode)){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}

Set Subkey family(C I/F)

Function group that specifies a key, and set a subkey list to a k2hdkc cluster.

Format

Description

These function groups are classified according to the following rules and classified into 2 types.

Each of the above types has similar functions with differences such as arguments.

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Examples

bool        result    = k2hdkc_full_set_subkeys(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin, pPKey, PKeyLen, pskeypck, skeypckcnt);
dkcres_type_t    rescode = k2hdkc_get_lastres_code();
 
// check result
if(!result){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}else if(DKC_RES_SUBCODE_NOTHING != GET_DKC_RES_SUBCODE(rescode)){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}

Clear Subkey family(C I/F)

Function group that specifies a key, and clear subkey list to a k2hdkc cluster.

Format

Description

These function groups are classified according to the following rules and classified into 2 types.

Each of the above types has similar functions with differences such as arguments.

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Examples

bool        result    = k2hdkc_full_clear_subkeys(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin, pPKey, PKeyLen);
dkcres_type_t    rescode = k2hdkc_get_lastres_code();
 
// check result
if(!result){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}else if(DKC_RES_SUBCODE_NOTHING != GET_DKC_RES_SUBCODE(rescode)){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}

Add Subkey family(C I/F)

Function group that specifies the parent key and the Subkey which is a child of the parent key, and set/create Subkey and value, and set Subkey into parent key’s subkey list.

Format

Description

These function groups are classified according to the following rules and classified into 2 types.

Each of the above types has similar functions with differences such as arguments.

In addition, depending on the connection type to chmpx slave node, it is divided into the following types.

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Examples

bool        result    = k2hdkc_full_set_subkeys(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin, pPKey, PKeyLen, pskeypck, skeypckcnt);
dkcres_type_t    rescode = k2hdkc_get_lastres_code();
 
// check result
if(!result){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}else if(DKC_RES_SUBCODE_NOTHING != GET_DKC_RES_SUBCODE(rescode)){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}

Set All family(C I/F)

Function group that specifies the key, and set/create all data(value/Subkey list/attribute).

Format

Description

These function groups are classified according to the following rules and classified into 2 types.

Each of the above types has similar functions with differences such as arguments.

In addition, depending on the connection type to chmpx slave node, it is divided into the following types.

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Examples

bool        result = k2hdkc_full_set_all(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin, pKey, KeyLen, pVal, ValLen, NULL, 0);
dkcres_type_t    rescode = k2hdkc_get_lastres_code();
 
// check result
if(!result){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}else if(DKC_RES_SUBCODE_NOTHING != GET_DKC_RES_SUBCODE(rescode)){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}

Remove Key family(C I/F)

Function group that specifies the key, and remove it with/without key’s Subkeys.

Format

Description

These function groups are classified according to the following rules and classified into 4 kinds(2 types).

Each of the above types has similar functions with differences such as arguments.

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Examples

bool        result = k2hdkc_full_remove(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin, pkey, keylen);
dkcres_type_t    rescode = k2hdkc_get_lastres_code();
 
// check result
if(!result){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}else if(DKC_RES_SUBCODE_NOTHING != GET_DKC_RES_SUBCODE(rescode)){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}

Remove Subkey family(C I/F)

Function group that specifies the parent key and Subkey, and remove Subkey.

Format

Description

These function groups are classified according to the following rules and classified into 2 types.

Each of the above types has similar functions with differences such as arguments.

In addition, depending on the connection type to chmpx slave node, it is divided into the following types.

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Examples

bool        result = k2hdkc_full_remove_subkey(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin, pkey, keylen, psubkey, subkeylen, true);
dkcres_type_t    rescode = k2hdkc_get_lastres_code();
 
// check result
if(!result){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}else if(DKC_RES_SUBCODE_NOTHING != GET_DKC_RES_SUBCODE(rescode)){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}

Rename Key family(C I/F)

Function group that specifies the key, and rename it.

Format

Description

These function groups are classified according to the following rules and classified into 4 kinds(2 types).

Each of the above types has similar functions with differences such as arguments.

In addition, depending on the connection type to chmpx slave node, it is divided into the following types.

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Note

Examples

bool        result = k2hdkc_full_rename_with_parent(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin, pOldKey, OldKeyLen, pNewKey, NewkeyLen, pParentKey, pParentKeyLen);
dkcres_type_t    rescode = k2hdkc_get_lastres_code();
 
// check result
if(!result){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}else if(DKC_RES_SUBCODE_NOTHING != GET_DKC_RES_SUBCODE(rescode)){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}

Queue(KeyQUeue) Push family(C I/F)

Function group that specifies the queue, and push the data to it.

Format

Description

These function groups are classified according to the following rules and classified into 4 kinds(2 types).

Each of the above types has similar functions with differences such as arguments.

In addition, depending on the connection type to chmpx slave node, it is divided into the following types.

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Examples

bool        result = k2hdkc_full_keyq_push(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin, pName, NameLen, reinterpret_cast<const unsigned char*>(strKey.c_str()), strKey.length() + 1, reinterpret_cast<const unsigned char*>(strValue.c_str()), strValue.length() + 1, is_Fifo);
dkcres_type_t    rescode = k2hdkc_get_lastres_code();
 
// check result
if(!result){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}else if(DKC_RES_SUBCODE_NOTHING != GET_DKC_RES_SUBCODE(rescode)){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}

Queue(KeyQUeue) Pop family(C I/F)

Function group that specifies the queue, and pop the data from it.

Format

Description

These function groups are classified according to the following rules and classified into 4 kinds(2 types).

Each of the above types has similar functions with differences such as arguments.

In addition, depending on the connection type to chmpx slave node, it is divided into the following types.

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Examples

unsigned char*    pkey        = NULL;
size_t        keylength    = 0;
unsigned char*    pval        = NULL;
size_t        vallength    = 0;
bool        result        = k2hdkc_full_keyq_pop(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin, pName, NameLen, is_Fifo, &pkey, &keylength, &pval, &vallength);
dkcres_type_t    rescode        = k2hdkc_get_lastres_code();
 
// check result
if(!result){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}else if(DKC_RES_SUBCODE_NOTHING != GET_DKC_RES_SUBCODE(rescode)){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}

Queue(KeyQUeue) Remove family(C I/F)

Function group that specifies the queue and count, and remove the specified number of data from it.

Format

Description

These function groups are classified according to the following rules and classified into 4 kinds(2 types).

Each of the above types has similar functions with differences such as arguments.

In addition, depending on the connection type to chmpx slave node, it is divided into the following types.

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Examples

bool        result = k2hdkc_full_keyq_remove(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin, pName, NameLen, RmCount, is_Fifo);
dkcres_type_t    rescode = k2hdkc_get_lastres_code();
 
// check result
if(!result){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}else if(DKC_RES_SUBCODE_NOTHING != GET_DKC_RES_SUBCODE(rescode)){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}

CAS(Compare And Swap) Initialize family(C I/F)

Function group that specifies the key, and initialize the key for operation CAS(Compare And Swap).

Format

Description

These function groups are classified according to the following rules and classified into 2 types.

Depending on the data length of CAS value, the following types of these functions are provided.

In addition, the following types are provided for these functions depending on the argument difference.

In addition, depending on the connection type to chmpx slave node, it is divided into the following types.

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Examples

bool        result    = k2hdkc_full_cas64_init(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin, reinterpret_cast<const unsigned char*>(strKey.c_str()), strKey.length() + 1, val);
dkcres_type_t    rescode = k2hdkc_get_lastres_code();
 
// check result
if(!result){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}else if(DKC_RES_SUBCODE_NOTHING != GET_DKC_RES_SUBCODE(rescode)){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}

CAS(Compare And Swap) Get family(C I/F)

Function group that specifies the key, and get the value for operation CAS(Compare And Swap).

Format

Description

These function groups are classified according to the following rules and classified into 2 types.

Depending on the data length of CAS value, the following types of these functions are provided.

In addition, the following types are provided for these functions depending on the argument difference.

In addition, depending on the connection type to chmpx slave node, it is divided into the following types.

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Examples

uint64_t    val64    = 0;
bool        result    = k2hdkc_full_cas64_get(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin, reinterpret_cast<const unsigned char*>(strKey.c_str()), strKey.length() + 1, &val64);
dkcres_type_t    rescode = k2hdkc_get_lastres_code();
 
// check result
if(!result){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}else if(DKC_RES_SUBCODE_NOTHING != GET_DKC_RES_SUBCODE(rescode)){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}

CAS(Compare And Swap) Set family(C I/F)

Function group that specifies the key, and when the value is as same as specified value, set the value for operation CAS(Compare And Swap).

Format

Description

These function groups are classified according to the following rules and classified into 2 types.

Depending on the data length of CAS value, the following types of these functions are provided.

In addition, the following types are provided for these functions depending on the argument difference.

In addition, depending on the connection type to chmpx slave node, it is divided into the following types.

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Examples

bool        result    = k2hdkc_full_cas64_set(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin, reinterpret_cast<const unsigned char*>(strKey.c_str()), strKey.length() + 1, oldval, newval);
dkcres_type_t    rescode = k2hdkc_get_lastres_code();
 
// check result
if(!result){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}else if(DKC_RES_SUBCODE_NOTHING != GET_DKC_RES_SUBCODE(rescode)){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}

CAS(Compare And Swap) Increment/Decrement family(C I/F)

Function group that specifies the key, and increment/decrement the value for operation CAS(Compare And Swap).

Format

Description

These function groups are classified according to the following rules and classified into 4 kinds(2 types).

In addition, the following types are provided for these functions depending on the argument difference.

In addition, depending on the connection type to chmpx slave node, it is divided into the following types.

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Examples

bool        result = k2hdkc_full_cas_increment_wa(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin, reinterpret_cast<const unsigned char*>(strKey.c_str()), strKey.length() + 1, (PassPhrase.empty() ? NULL : PassPhrase.c_str()), (-1 == Expire ? NULL : &Expire));
dkcres_type_t    rescode = k2hdkc_get_lastres_code();
 
// check result
if(!result){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}else if(DKC_RES_SUBCODE_NOTHING != GET_DKC_RES_SUBCODE(rescode)){
    printf("RESULT CODE(%s - %s)\n", STR_DKCRES_RESULT_TYPE(rescode), STR_DKCRES_SUBCODE_TYPE(rescode));
}

C++ API

This is an API for C++ language API for using the k2hdkc library. Include the following header files when developing.

#include <k2hdkc/k2hdkcslave.h>

When linking please specify the following as an option.

-lk2hdkc

The functions for C++ language are explained below. ***

Debug family(C++ I/F)

The k2hdkc library can output messages to check internal operation and API operation. This function group is a group of functions for controlling message output on C++ language.

Format

Description

Parameters

Return Values

Note

For environment variables DKCDBGMODE, DKCDBGFILE, see Environments.


Command Class Factory(C++ I/F)

The class factory creates a communication command class object.

Description

There are two kinds of class factories for Non-persistence chmpx connection and Persistence chmpx connection.
These factories are built by MACRO. The types of class factory types and the communication command classes to be returned are summarized below.

Class factory for Non-persistence chmpx connection

These functions(MACROs) have a prefix of GetOt…().

Class factory for Persistence chmpx connection

These functions(MACROs) have a prefix of GetPm…().

Parameters

Return Values

These functions return a pointer to the corresponding communication command class object.
Please delete the returned class object when it becomes unnecessary.

Examples

//-------------------------------------
// One time connection type
//-------------------------------------
K2hdkcComGet*    pComObj = GetOtSlaveK2hdkcComGet(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin);
bool        result = pComObj->CommandSend(pkey, keylength, !is_noattr, passphrase, &pconstval, &vallength, &rescode);
delete pComObj;
 
//-------------------------------------
// Permanent connection type
//-------------------------------------
// Open chmpx
K2hdkcSlave* pSlave = new K2hdkcSlave();
if(!pSlave->Initialize(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin)){
    cerr << "Could not join slave node chmpx." << endl;
    delete pSlave;
    return false;
}
if(!pSlave->Open(isNoGiveupRejoin)){
    cerr << "Could not open msgid on slave node chmpx." << endl;
    delete pSlave;
    return false;
}
for(int cnt = 0; cnt < 10; ++cnt){    // loop for example
    K2hdkcComGet*    pComObj= GetPmSlaveK2hdkcComGet(pSlave);
    bool        result = pComObj->CommandSend(pkey, keylength, !is_noattr, passphrase, &pconstval, &vallength, &rescode);
    delete pComObj;
}
if(!pSlave->Clean(isCleanupBup)){
    cerr << "Could not leave slave node chmpx, but continue for cleanup..." << endl;
}
delete pSlave;

K2hdkcComGet class

This class is operation for getting the value for the key.

Format

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Note

There are two types of CommandSend() methods, one of which has a method type that sends commands and acquires results at once.

Examples

K2hdkcComGet* pComObj = GetOtSlaveK2hdkcComGet(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin);
bool result = pComObj->CommandSend(pkey, keylength, !is_noattr, passphrase, &pconstval, &vallength, &rescode);

K2hdkcComGetDirect class

This class is operation for getting the value by specifying the key and offset of the value.

Format

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Note

There are two types of CommandSend() methods, one of which has a method type that sends commands and acquires results at once.

Examples

K2hdkcComGetDirect*    pComObj = GetOtSlaveK2hdkcComGetDirect(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin);
bool pComObj->CommandSend(pkey, keylen, offset, length, &pconstval, &vallen, &rescode);

K2hdkcComGetSubkeys class

This class is operation for getting the Subkey list for the key.

Format

Parameters

Return Values

Returns true if it succeeds, false if it fails.サブキーを持たない場合にもfalseを返します。

Note

There are two types of CommandSend() methods, one of which has a method type that sends commands and acquires results at once.
For the operation method of the K2HSubKeys class for the subkey list, see the document of K2HASH.

Examples

K2HSubKeys*           pSubKeys= NULL;
K2hdkcComGetSubkeys*  pComObj = GetOtSlaveK2hdkcComGetSubkeys(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin);
bool                  result  = pComObj->CommandSend(pkey, keylength, !is_noattr, &pSubKeys, &rescode);

K2hdkcComGetAttrs class

This class is operation for getting the attributes for the key.

Format

Parameters

Return Values

Returns true if it succeeds, false if it fails. If the key does not have any attribute, returns false. Since the data of the k2hdkc cluster always has mtime attribute which is one of attribute, there is no reply without attribute.

Note

There are two types of CommandSend() methods, one of which has a method type that sends commands and acquires results at once.
For the operation method of the K2HAttrs class for the subkey list, see the document of K2HASH.

Examples

K2HAttrs*            pAttrsObj    = NULL;
K2hdkcComGetAttrs*    pComObj     = GetOtSlaveK2hdkcComGetAttrs(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin);
bool            result = pComObj->CommandSend(reinterpret_cast<const unsigned char*>(strKey.c_str()), strKey.length() + 1, &pAttrsObj, &rescode);

K2hdkcComGetAttr class

This class is operation for getting the attribute value by specifying the key and attribute name as binary.

Format

Parameters

Return Values

Returns true if it succeeds, false if it fails. If the key does not have any attribute, returns false.

Note

There are two types of CommandSend() methods, one of which has a method type that sends commands and acquires results at once.

Examples

K2hdkcComGetAttrs*    pComObj     = GetOtSlaveK2hdkcComGetAttr(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin);
bool            result = pComObj->CommandSend(reinterpret_cast<const unsigned char*>(strKey.c_str()), strKey.length() + 1, pattrname, attrnamelen, &pAttrval, attrvallen, &rescode);

K2hdkcComSet class

This class is operation for setting/creating the key and value.

Format

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Note

There are two types of CommandSend() methods, one of which has a method type that sends commands and acquires results at once.
Except for the two CommandSend() methods, they are methods used internally and can not be used.

Examples

K2hdkcComSet*    pComObj = GetOtSlaveK2hdkcComSet(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin);
bool            result = pComObj->CommandSend(pKey, KeyLen, pVal, ValLen, is_rmsublist, pPassPhrase, pExpire, &rescode);

K2hdkcComSetDirect class

This class is operation for setting/creating the key and value with offset.

Format

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Note

There are two types of CommandSend() methods, one of which has a method type that sends commands and acquires results at once.

Examples

K2hdkcComSetDirect*    pComObj = GetOtSlaveK2hdkcComSetDirect(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin);
bool            result = pComObj->CommandSend(pkey, keylen, pval, vallen, offset, &rescode);

K2hdkcComSetSubkeys class

This class is operation for adding the Subkey list to the key(and can remove all Subkey list).

Format

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Note

There are two types of CommandSend() methods, one of which has a method type that sends commands and acquires results at once. The ClearSubkeysCommandSend() methods is a method to clear the Subkey list.

Examples

unsigned char*  psubkeys = NULL;
size_t        subkeyslength = 0;
K2HSubKeys    Subkeys;
Subkeys.insert(psubkey, subkeylength);        // Add one subkey
if(!Subkeys.Serialize(&psubkeys, &subkeyslength)){
    return false;
}
 
K2hdkcComSetSubkeys*    pComObj = GetOtSlaveK2hdkcComSetSubkeys(conffile, ctlport, NULL/* cuk is NULL */, is_auto_rejoin, no_giveup_rejoin);
bool            result = pComObj->CommandSend(pPKey, PKeyLen, psubkeys, subkeyslength , &rescode);
 
DKC_FREE(psubkeys);

K2hdkcComSetAll class

This class is operation for set the value and Subkey list and attributes to the key.

Format

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Note

There are two types of CommandSend() methods, one of which has a method type that sends commands and acquires results at once.

Examples

unsigned char*  psubkeys = NULL;
size_t        subkeyslength = 0;
K2HSubKeys    Subkeys;
Subkeys.insert(psubkey, subkeylength);        // Add one subkey
if(!Subkeys.Serialize(&psubkeys, &subkeyslength)){
    return false;
}
 
K2hdkcComSetAll*    pComObj = GetOtSlaveK2hdkcComSetAll(conffile, ctlport, NULL/* cuk is NULL */, is_auto_rejoin, no_giveup_rejoin);
bool            result = pComObj->CommandSend(pPKey, PKeyLen, psubkeys, subkeyslength, NULL, 0, &rescode);
 
DKC_FREE(psubkeys);

K2hdkcComAddSubkeys class

This class is operation for adding the Subkey to the key’s Subkey list.

Format

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Note

There are two types of CommandSend() methods, one of which has a method type that sends commands and acquires results at once.

Examples

K2hdkcComAddSubkeys*    pComObj = GetOtSlaveK2hdkcComAddSubkeys(conffile, ctlport, NULL/* cuk is NULL */, is_auto_rejoin, no_giveup_rejoin);
bool            result = pComObj->CommandSend(pPKey, PKeyLen, psubkey, subkeylen, true, &rescode);

K2hdkcComAddSubkey class

This class is operation for creating the Subkey and value and adding it to the key’s Subkey list.

Format

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Note

There are two types of CommandSend() methods, one of which has a method type that sends commands and acquires results at once.

Examples

K2hdkcComAddSubkey*    pComObj = GetOtSlaveK2hdkcComAddSubkey(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin);
bool            result = pComObj->CommandSend(pParentKey, ParentKeyLen, pSubKey, SubKeyLen, pVal, ValLen, !is_noattr, pPassPhrase, pExpire, &rescode);

K2hdkcComDel class

This class is operation for removing the key.

Format

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Note

There are two types of CommandSend() methods, one of which has a method type that sends commands and acquires results at once.

Examples

K2hdkcComDel*    pComObj = GetOtSlaveK2hdkcComDel(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin);
bool            result = pComObj->CommandSend(pkey, keylen, is_subkeys, true, &rescode);

K2hdkcComDelSubkeys class

This class is operation for removing the Subkey from the key’s Subkey list.

Format

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Note

There are two types of CommandSend() methods, one of which has a method type that sends commands and acquires results at once.

Examples

K2hdkcComDelSubkeys*    pComObj = GetOtSlaveK2hdkcComDelSubkeys(conffile, ctlport, NULL/* cuk is NULL */, is_auto_rejoin, no_giveup_rejoin);
bool            result = pComObj->CommandSend(pPKey, PKeyLen, psubkey, subkeylen, true, &rescode);

K2hdkcComDelSubkey class

This class is operation for removing the Subkey from the key’s Subkey list and remove the Subkey.

Format

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Note

There are two types of CommandSend() methods, one of which has a method type that sends commands and acquires results at once.

Examples

K2hdkcComDelSubkey*    pComObj = GetOtSlaveK2hdkcComDelSubkey(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin);
bool            result = pComObj->CommandSend(pParentKey, ParentKeyLen, pSubKey, SubKeyLen, pVal, ValLen, true, &rescode);

K2hdkcComRen class

This class is operation for renaming the key.
If the parent key is specified, the Subkey name is removed from the parent’s Subkey list.

Format

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Note

There are two types of CommandSend() methods, one of which has a method type that sends commands and acquires results at once.

Examples

K2hdkcComRen*    pComObj = GetOtSlaveK2hdkcComRen(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin);
bool            result = pComObj->CommandSend(pOldKey, OldKeyLen, pNewKey, NewkeyLen, pParentKey, pParentKeyLen, !is_noattr, (PassPhrase.empty() ? NULL : PassPhrase.c_str()), (-1 == Expire ? NULL : &Expire), &rescode);

K2hdkcComQPush class

This class is operation for pushing the value(or key and value) to the queue.

Format

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Note

There are two types of CommandSend() methods, one of which has a method type that sends commands and acquires results at once.

Examples

K2hdkcComQPush*    pComObj = GetOtSlaveK2hdkcComQPush(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin);
bool            result = pComObj->QueueCommandSend(pName, NameLen, reinterpret_cast<const unsigned char*>(strValue.c_str()), strValue.length() + 1, is_Fifo, NULL, 0UL, !is_noattr, (PassPhrase.empty() ? NULL : PassPhrase.c_str()), (-1 == Expire ? NULL : &Expire), &rescode);

K2hdkcComQPop class

This class is operation for popping the value(or key and value) from the queue.

Format

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Note

There are two types of CommandSend() methods, one of which has a method type that sends commands and acquires results at once.

Examples

K2hdkcComQPop*    pComObj = GetOtSlaveK2hdkcComQPop(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin);
bool            result = pComObj->KeyQueueCommandSend(pName, NameLen, is_Fifo, !is_noattr, (PassPhrase.empty() ? NULL : PassPhrase.c_str()), &pkeytmp, &keytmplen, &pvaltmp, &valtmplen, &rescode);

K2hdkcComQDel class

This class is operation for removing the value(or key and value) from the queue(can specify the number to delete).

Format

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Note

There are two types of CommandSend() methods, one of which has a method type that sends commands and acquires results at once.

Examples

K2hdkcComQDel*    pComObj = GetOtSlaveK2hdkcComQDel(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin);
bool            result = pComObj->QueueCommandSend(pName, NameLen, RmCount, is_Fifo, true, (PassPhrase.empty() ? NULL : PassPhrase.c_str()), &rescode);

K2hdkcComCasInit class

This class is operation for initializing the key for operation CAS(Compare And Swap). There are methods for the size(8 / 16 / 32 / 64 bits) of the value.

Format

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Note

There are two types of CommandSend() methods, one of which has a method type that sends commands and acquires results at once.

Examples

K2hdkcComCasInit*    pComObj = GetOtSlaveK2hdkcComCasInit(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin);
bool                 result  = pComObj->CommandSend(reinterpret_cast<const unsigned char*>(strKey.c_str()), strKey.length() + 1, val, (PassPhrase.empty() ? NULL : PassPhrase.c_str()), (-1 == Expire ? NULL : &Expire), &rescode);

K2hdkcComCasGet class

This class is operation for getting the value for operation CAS(Compare And Swap). There are methods for the size(8 / 16 / 32 / 64 bits) of the value.

Format

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Note

There are two types of CommandSend() methods, one of which has a method type that sends commands and acquires results at once.

Examples

K2hdkcComCasGet*    pComObj = GetOtSlaveK2hdkcComCasGet(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin);
bool                result = pComObj->CommandSend(reinterpret_cast<const unsigned char*>(strKey.c_str()), strKey.length() + 1, true, (PassPhrase.empty() ? NULL : PassPhrase.c_str()), &pval8, &rescode);

K2hdkcComCasSet class

This class is operation to setting the value for operation CAS(Compare And Swap). There are methods for the size(8 / 16 / 32 / 64 bits) of the value.

Format

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Note

There are two types of CommandSend() methods, one of which has a method type that sends commands and acquires results at once.

Examples

K2hdkcComCasSet*    pComObj = GetOtSlaveK2hdkcComCasSet(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin);
bool                result  = pComObj->CommandSend(reinterpret_cast<const unsigned char*>(strKey.c_str()), strKey.length() + 1, oldval, newval, true, (PassPhrase.empty() ? NULL : PassPhrase.c_str()), (-1 == Expire ? NULL : &Expire), &rescode);

K2hdkcComCasIncDec class

This class is operation to increment/decrement the value for operation CAS(Compare And Swap). There are methods for the size(8 / 16 / 32 / 64 bits) of the value.

Format

Parameters

Return Values

Returns true if it succeeds, false if it fails.

Note

There are two types of CommandSend() methods, one of which has a method type that sends commands and acquires results at once.

Examples

K2hdkcComCasIncDec* pComObj = GetOtSlaveK2hdkcComCasIncDec(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin);
bool                result  = pComObj->pComObj->IncrementCommandSend(reinterpret_cast<const unsigned char*>(strKey.c_str()), strKey.length() + 1, true, (PassPhrase.empty() ? NULL : PassPhrase.c_str()), (-1 == Expire ? NULL : &Expire), &rescode);

K2hdkcComState class

This class is operation to getting the status of all of k2hdkc nodes. This class can get the number(chmpxid, hash value, etc) in the k2hdkc cluster of chmpx and the status of k2hash data managed by each server node.

Format

Parameters

Structure

The status structure to be acquired for this class is shown below.

typedef struct k2hdkc_nodestate{
    chmpxid_t       chmpxid;                // See: CHMPX in chmpx/chmstructure.h
    char            name[NI_MAXHOST];       //
    chmhash_t       base_hash;              //
    chmhash_t       pending_hash;           //
    K2HSTATE        k2hstate;               // See: k2hash/k2hash.h
}DKC_NODESTATE, *PDKC_NODESTATE;
 
typedef struct k2h_state{
    char            version[K2H_VERSION_LENGTH];            // Version string as K2hash file
    char            hash_version[K2H_HASH_FUNC_VER_LENGTH]; // Version string as Hash Function
    char            trans_version[K2H_HASH_FUNC_VER_LENGTH];// Version string as Transaction Function
    int             trans_pool_count;                       // Transaction plugin thread pool count
    k2h_hash_t      max_mask;                               // Maximum value for cur_mask
    k2h_hash_t      min_mask;                               // Minimum value for cur_mask
    k2h_hash_t      cur_mask;                               // Current mask value for hash(This value is changed automatically)
    k2h_hash_t      collision_mask;                         // Mask value for collision when masked hash value by cur_mask(This value is not changed)
    unsigned long   max_element_count;                      // Maximum count for elements in collision key index structure(Increasing cur_mask when this value is over)
    size_t          total_size;                             // Total size of k2hash
    size_t          page_size;                              // Paging size(system)
    size_t          file_size;                              // k2hash file(memory) size
    size_t          total_used_size;                        // Total using size in k2hash
    size_t          total_map_size;                         // Total mapping size for k2hash
    size_t          total_element_size;                     // Total element area size
    size_t          total_page_size;                        // Total page area size
    long            total_area_count;                       // Total mmap area count( = MAX_K2HAREA_COUNT)
    long            total_element_count;                    // Total element count in k2hash
    long            total_page_count;                       // Total page count in k2hash
    long            assigned_area_count;                    // Assigned area count
    long            assigned_key_count;                     // Assigned key index count
    long            assigned_ckey_count;                    // Assigned collision key index count
    long            assigned_element_count;                 // Assigned element count
    long            assigned_page_count;                    // Assigned page count
    long            unassigned_element_count;               // Unassigned element count(free element count)
    long            unassigned_page_count;                  // Unassigned page count(free page count)
    struct timeval  last_update;                            // Last update of data
    struct timeval  last_area_update;                       // Last update of expanding area
}K2HSTATE, *PK2HSTATE;

Return Values

Returns true if it succeeds, false if it fails.

Examples

K2hdkcComState*    pComObj = GetOtSlaveK2hdkcComState(strConfFile.c_str(), CntlPort, NULL/* cuk is NULL */,  isAutoRejoin, isNoGiveupRejoin);
bool               result = pComObj->CommandSend(&ptmpstates, &tmpstatecount, &rescode);
Build TOP Environments