smax-clib v0.9
A C/C++ client library for SMA-X
|
Data Structures | |
struct | XCoordinateAxis |
Structure that defines a coordinate axis in an XCoordinateSystem for an SMA-X data array. More... | |
struct | XCoordinateSystem |
Structure that defines a coordinate system, with one or more XCoordinateAxis. More... | |
struct | XMessage |
SMA-X program message. More... | |
struct | XMeta |
SMA-X standard metadata. More... | |
struct | XSyncPoint |
Synchronization point that can be waited upon when queueing pipelined pulls. More... | |
Macros | |
#define | META_COORDS "<coords>" |
Redis hash table in which data coordinates system descriptions are stored. | |
#define | META_DESCRIPTION "<descriptions>" |
Redis hash table in which variable descriptions are stored. | |
#define | META_UNIT "<units>" |
Redis hash table in which data physical unit names are stored. | |
#define | SMAX_DEFAULT_HOSTNAME "smax" |
Host name of Redis server used for SMA-X. | |
#define | SMAX_DEFAULT_MAX_QUEUED 1024 |
Maximum number of pull requests allowed to be queued at once. | |
#define | SMAX_DEFAULT_PIPELINE_ENABLED TRUE |
Whether pipelining is enabled by default. | |
#define | SMAX_DIMS "<dims>" |
Redis meta table where variable dimensions are stored. | |
#define | SMAX_MAJOR_VERSION 0 |
API major version. | |
#define | SMAX_MINOR_VERSION 9 |
API minor version. | |
#define | SMAX_MSG_DEBUG "debug" |
Program debug messages (also e.g. traces). | |
#define | SMAX_MSG_DETAIL "detail" |
Additional program detail provided (e.g. for verbose mode) | |
#define | SMAX_MSG_ERROR "error" |
Program errors. | |
#define | SMAX_MSG_INFO "info" |
Informational program message. | |
#define | SMAX_MSG_PROGRESS "progress" |
Program progress update. | |
#define | SMAX_MSG_STATUS "status" |
Program status update. | |
#define | SMAX_MSG_WARNING "warning" |
Program warnings. | |
#define | SMAX_ORIGIN_LENGTH 80 |
(bytes) Maximum length of 'origin' meatdata, including termination. | |
#define | SMAX_ORIGINS "<origins>" |
Redis meta table where variable origins are stored. | |
#define | SMAX_PATCHLEVEL 0 |
Integer sub version of the release. | |
#define | SMAX_PIPE_READ_TIMEOUT_MILLIS 3000 |
(ms) Timeout for pipelined (queued) pull requests | |
#define | SMAX_READS "<reads>" |
Redis meta table where the number of times a variable has been read is stored. | |
#define | SMAX_RECONNECT_RETRY_SECONDS 3 |
(s) Time between reconnection attempts on lost SMA-X connections. | |
#define | SMAX_RELEASE_STRING "-devel" |
Additional release information in version, e.g. "-1", or "-rc1". | |
#define | SMAX_RESTORE_QUEUE_ON_RECONNECT TRUE |
Whether read queues are restored if SMA-X is disconnected/reconnected. | |
#define | SMAX_SCRIPTS "scripts" |
Redis table in which the built-in LUA script hashes are stored. | |
#define | SMAX_TIMESTAMPS "<timestamps>" |
Redis meta table where variable timestamps are stored. | |
#define | SMAX_TYPES |
Redis meta table where variable types are stored. | |
#define | SMAX_UPDATES SMAX_UPDATES_ROOT X_SEP |
PUB/SUB message channel heade for hash table updates. | |
#define | SMAX_UPDATES_LENGTH |
String length of SMA-X update channel prefix. | |
#define | SMAX_UPDATES_ROOT "smax" |
Notification class for SMA-X updates. | |
#define | SMAX_VERSION_STRING |
#define | SMAX_WRITES "<writes>" |
Redis meta table where the number of times a variable has been written is stored. | |
#define | X_META_INIT { 0, X_UNKNOWN, -1, {0}, -1, {'\0'}, {0}, 0 } |
Functions | |
int | smax2xField (XField *f) |
int | smax2xStruct (XStructure *s) |
int | smaxAddConnectHook (void(*setupCall)(void)) |
int | smaxAddDefaultMessageProcessor (const char *host, const char *prog, const char *type) |
int | smaxAddDisconnectHook (void(*cleanupCall)(void)) |
int | smaxAddMessageProcessor (const char *host, const char *prog, const char *type, void(*f)(XMessage *)) |
int | smaxAddSubscriber (const char *stem, RedisSubscriberCall f) |
int | smaxConnect () |
int | smaxConnectTo (const char *server) |
XField * | smaxCreate1DField (const char *name, XType type, int size, const void *value) |
XField * | smaxCreateBooleanField (const char *name, boolean value) |
XCoordinateSystem * | smaxCreateCoordinateSystem (int nAxis) |
XField * | smaxCreateDoubleField (const char *name, double value) |
XField * | smaxCreateField (const char *name, XType type, int ndim, const int *sizes, const void *value) |
XField * | smaxCreateIntField (const char *name, int value) |
XField * | smaxCreateLongField (const char *name, long long value) |
XMeta * | smaxCreateMeta () |
XField * | smaxCreateScalarField (const char *name, XType type, const void *value) |
XField * | smaxCreateStringField (const char *name, const char *value) |
XSyncPoint * | smaxCreateSyncPoint () |
void | smaxDestroyCoordinateSystem (XCoordinateSystem *coords) |
void | smaxDestroySyncPoint (XSyncPoint *sync) |
int | smaxDisconnect () |
int | smaxError (const char *func, int errorCode) |
const char * | smaxErrorDescription (int code) |
int | smaxGetArrayField (const XStructure *s, const char *name, void *dst, XType type, int count) |
boolean | smaxGetBooleanField (const XStructure *s, const char *name, boolean defaultValue) |
XCoordinateAxis * | smaxGetCoordinateAxis (const char *id, int n) |
XCoordinateSystem * | smaxGetCoordinateSystem (const char *table, const char *key) |
char * | smaxGetDescription (const char *table, const char *key) |
double | smaxGetDoubleField (const XStructure *s, const char *name, double defaultValue) |
char * | smaxGetHostName () |
char ** | smaxGetKeys (const char *table, int *n) |
int | smaxGetLazyCached (const char *table, const char *key, XType type, int count, void *value, XMeta *meta) |
int | smaxGetLazyUpdateCount (const char *table, const char *key) |
long long | smaxGetLongField (const XStructure *s, const char *name, long long defaultValue) |
int | smaxGetMetaCount (const XMeta *m) |
char * | smaxGetProgramID () |
char * | smaxGetRawField (const XStructure *s, const char *name, char *defaultValue) |
Redis * | smaxGetRedis () |
char * | smaxGetScriptSHA1 (const char *scriptName, int *status) |
int | smaxGetServerTime (struct timespec *t) |
double | smaxGetTime (const char *timestamp) |
char * | smaxGetUnits (const char *table, const char *key) |
int | smaxIsConnected () |
boolean | smaxIsPipelined () |
boolean | smaxIsResilient () |
boolean | smaxIsVerbose () |
int | smaxKeyCount (const char *table) |
int | smaxLazyCache (const char *table, const char *key, XType type) |
int | smaxLazyEnd (const char *table, const char *key) |
int | smaxLazyFlush () |
int | smaxLazyPull (const char *table, const char *key, XType type, int count, void *value, XMeta *meta) |
int | smaxLazyPullChars (const char *table, const char *key, char *buf, int n) |
double | smaxLazyPullDouble (const char *table, const char *key) |
double | smaxLazyPullDoubleDefault (const char *table, const char *key, double defaultValue) |
long long | smaxLazyPullLong (const char *table, const char *key, long long defaultValue) |
char * | smaxLazyPullString (const char *table, const char *key) |
int | smaxLazyPullStruct (const char *id, XStructure *s) |
int | smaxParseTime (const char *timestamp, time_t *secs, long *nanosecs) |
int | smaxPull (const char *table, const char *key, XType type, int count, void *value, XMeta *meta) |
double | smaxPullDouble (const char *table, const char *key) |
double | smaxPullDoubleDefault (const char *table, const char *key, double defaultValue) |
double * | smaxPullDoubles (const char *table, const char *key, XMeta *meta, int *n) |
int | smaxPullInt (const char *table, const char *key, int defaultValue) |
int * | smaxPullInts (const char *table, const char *key, XMeta *meta, int *n) |
long long | smaxPullLong (const char *table, const char *key, long long defaultValue) |
long long * | smaxPullLongs (const char *table, const char *key, XMeta *meta, int *n) |
char * | smaxPullMeta (const char *meta, const char *table, const char *key, int *status) |
char * | smaxPullRaw (const char *table, const char *key, XMeta *meta, int *status) |
char * | smaxPullString (const char *table, const char *key) |
char ** | smaxPullStrings (const char *table, const char *key, XMeta *meta, int *n) |
XStructure * | smaxPullStruct (const char *name, XMeta *meta, int *status) |
double | smaxPullTime (const char *table, const char *key) |
XType | smaxPullTypeDimension (const char *table, const char *key, int *ndim, int *sizes) |
int | smaxPushMeta (const char *meta, const char *table, const char *key, const char *value) |
int | smaxQueue (const char *table, const char *key, XType type, int count, void *value, XMeta *meta) |
int | smaxQueueCallback (void(*f)(void *), void *arg) |
int | smaxReconnect () |
int | smaxReleaseWaits () |
int | smaxRemoveConnectHook (void(*setupCall)(void)) |
int | smaxRemoveDisconnectHook (void(*cleanupCall)(void)) |
int | smaxRemoveMessageProcessor (int id) |
int | smaxRemoveSubscribers (RedisSubscriberCall f) |
void | smaxResetMeta (XMeta *m) |
int | smaxSendDebug (const char *msg,...) |
int | smaxSendDetail (const char *msg,...) |
int | smaxSendError (const char *msg,...) |
int | smaxSendInfo (const char *msg,...) |
int | smaxSendProgress (double fraction, const char *msg,...) |
int | smaxSendStatus (const char *msg,...) |
int | smaxSendWarning (const char *msg,...) |
int | smaxSetAuth (const char *username, const char *password) |
int | smaxSetCoordinateAxis (const char *id, int n, const XCoordinateAxis *axis) |
int | smaxSetCoordinateSystem (const char *table, const char *key, const XCoordinateSystem *coords) |
int | smaxSetDB (int idx) |
int | smaxSetDescription (const char *table, const char *key, const char *description) |
void | smaxSetHostName (const char *name) |
int | smaxSetMaxPendingPulls (int n) |
void | smaxSetMessageSenderID (const char *id) |
void | smaxSetOrigin (XMeta *m, const char *origin) |
int | smaxSetPipelineConsumer (void(*f)(RESP *)) |
int | smaxSetPipelined (boolean isEnabled) |
void | smaxSetResilient (boolean value) |
void | smaxSetResilientExit (boolean value) |
int | smaxSetServer (const char *host, int port) |
int | smaxSetTcpBuf (int size) |
int | smaxSetUnits (const char *table, const char *key, const char *unit) |
void | smaxSetVerbose (boolean value) |
int | smaxShare (const char *table, const char *key, const void *value, XType type, int count) |
int | smaxShareArray (const char *table, const char *key, const void *value, XType type, int ndim, const int *sizes) |
int | smaxShareBoolean (const char *table, const char *key, boolean value) |
int | smaxShareBooleans (const char *table, const char *key, const boolean *values, int n) |
int | smaxShareBytes (const char *table, const char *key, const char *values, int n) |
int | smaxShareDouble (const char *table, const char *key, double value) |
int | smaxShareDoubles (const char *table, const char *key, const double *values, int n) |
int | smaxShareField (const char *table, const XField *f) |
int | smaxShareFloats (const char *table, const char *key, const float *values, int n) |
int | smaxShareHex (const char *table, const char *key, long long value) |
int | smaxShareInt (const char *table, const char *key, long long value) |
int | smaxShareInts (const char *table, const char *key, const int *values, int n) |
int | smaxShareLongs (const char *table, const char *key, const long long *values, int n) |
int | smaxShareShorts (const char *table, const char *key, const short *values, int n) |
int | smaxShareString (const char *table, const char *key, const char *sValue) |
int | smaxShareStrings (const char *table, const char *key, const char **sValues, int n) |
int | smaxShareStruct (const char *id, const XStructure *s) |
int | smaxStringToValues (const char *str, void *value, XType type, int count, int *parsed) |
char * | smaxStringType (XType type) |
int | smaxSubscribe (const char *table, const char *key) |
int | smaxSync (XSyncPoint *sync, int timeoutMillis) |
int | smaxTimestamp (char *buf) |
int | smaxTimeToString (const struct timespec *time, char *buf) |
*/ | |
XType | smaxTypeForString (const char *type) |
int | smaxUnpackStrings (const char *data, int len, int count, char **dst) |
int | smaxUnsubscribe (const char *table, const char *key) |
char * | smaxValuesToString (const void *value, XType type, int count, char *trybuf, int trylength) |
int | smaxWaitOnAnySubscribed (char **changedTable, char **changedKey, int timeout) |
int | smaxWaitOnSubscribed (const char *table, const char *key, int timeout) |
int | smaxWaitOnSubscribedGroup (const char *matchTable, char **changedKey, int timeout) |
int | smaxWaitOnSubscribedVar (const char *matchKey, char **changedTable, int timeout) |
int | smaxWaitQueueComplete (int timeoutMillis) |
int | x2smaxField (XField *f) |
int | x2smaxStruct (XStructure *s) |
#define SMAX_TYPES |
Redis meta table where variable types are stored.
Character arrays a treated somewhat differently, with the element size bundled in the type, to allow variable length strings to be properly parsed into them without overflow...
#define SMAX_VERSION_STRING |
The version string for this library
#define X_META_INIT { 0, X_UNKNOWN, -1, {0}, -1, {'\0'}, {0}, 0 } |
Default initialized for SMA-X medatadata structure. You should always initialize local metadata with this.
int smax2xField | ( | XField * | f | ) |
Converts SMA-X field with serialized string value storage to a standard xchange field with a native value storage.
f | Pointer to field to convert |
References FALSE, XField::isSerialized, smax2xStruct(), smaxStringToValues(), XField::type, XField::value, x_error(), X_NULL, X_RAW, X_SIZE_INVALID, X_STRUCT, X_SUCCESS, x_trace(), X_TYPE_INVALID, xElementSizeOf(), and xGetFieldCount().
int smax2xStruct | ( | XStructure * | s | ) |
Converts an SMA-X structure with serialized string value storage to a standard xchange structure with a native value storage.
s | Pointer to structure to convert |
References XStructure::firstField, XField::next, smax2xField(), x_error(), X_STRUCT_INVALID, and X_SUCCESS.
int smaxAddConnectHook | ( | void(*)(void) | setupCall | ) |
Add a callback function for when SMA-X is connected. It's a wrapper to redisxAddConnectHook().
setupCall | Callback function |
References redisxAddConnectHook(), smaxError(), smaxGetRedis(), X_NO_INIT, and X_SUCCESS.
int smaxAddDefaultMessageProcessor | ( | const char * | host, |
const char * | prog, | ||
const char * | type | ||
) |
Report messages to stdout/stderr in default formats.
host | Host name where messages originate from, or "*" or NULL if any. |
prog | Program name of message originator, or "*" or NULL if any. |
type | Message type, or "*" or NULL if any. |
References smaxAddMessageProcessor().
int smaxAddDisconnectHook | ( | void(*)(void) | cleanupCall | ) |
Add a callback function for when SMA-X is disconnected. It's a wrapper to redisxAddDisconnectHook().
cleanupCall | Callback function |
References redisxAddDisconnectHook(), smaxError(), smaxGetRedis(), X_NO_INIT, and X_SUCCESS.
int smaxAddMessageProcessor | ( | const char * | host, |
const char * | prog, | ||
const char * | type, | ||
void(*)(XMessage *) | f | ||
) |
Adds a message processor function for a specific host (or all hosts), a specific program (or all programs), and a specific message type (or all message types).
host | Host name where messages originate from, or "*" or NULL if any. |
prog | Program name of message originator, or "*" or NULL if any. |
type | Message type, or "*" or NULL if any. |
f | Callback function |
References MESSAGES_PREFIX, redisxAddSubscriber(), redisxSubscribe(), smaxError(), smaxGetRedis(), smaxRemoveMessageProcessor(), x_error(), X_NO_INIT, X_NULL, X_SEP, X_SEP_LENGTH, X_SUCCESS, x_trace(), and xStringCopyOf().
int smaxAddSubscriber | ( | const char * | idStem, |
RedisSubscriberCall | f | ||
) |
Add a subcriber (callback) function to process incoming PUB/SUB messages for a given SMA-X table (or id). The function should itself check that the channel receiving notification is indeed what it expectes before acting on it, as the callback routine will be invoked for any update inside the specified table, unless the table argument refers to a specific aggregate ID of a single variable. This call only registers the callback routine for SMA-X update notifications for variables that begin with the specified stem. You will still have to subscrive to any relevant variables with smaxSubscribe() to enable delivering update notifications for the variables of your choice.
idStem | Table name or ID stem for which the supplied callback function will be invoked as long as the beginning of the PUB/SUB update channel matches the given stem. Alternatively, it can be a fully qualified SMA-X ID (of the form table:key) f a single variable. |
f | The function to call when there is an incoming PUB/SUB update to a channel starting with stem. |
References redisxAddSubscriber(), SMAX_UPDATES_ROOT, smaxError(), smaxGetRedis(), X_NO_INIT, X_SUCCESS, and xGetAggregateID().
int smaxConnect | ( | ) |
Initializes the SMA-X sharing library in this runtime instance.
References FALSE, redisxConnect(), redisxInit(), redisxSelectDB(), redisxSetPassword(), redisxSetPort(), redisxSetTcpBuf(), redisxSetTransmitErrorHandler(), redisxSetUser(), SMAX_DEFAULT_HOSTNAME, smaxAddConnectHook(), smaxAddDisconnectHook(), smaxAddSubscriber(), smaxGetProgramID(), smaxIsConnected(), smaxLazyFlush(), smaxReleaseWaits(), smaxSetPipelineConsumer(), smaxSetResilient(), smaxTransmitErrorHandler(), TRUE, X_NO_INIT, X_SUCCESS, x_trace(), and xvprintf.
int smaxConnectTo | ( | const char * | server | ) |
Initializes the SMA-X sharing library in this runtime instance with the specified Redis server. SMA-X is initialized in resilient mode, so that we'll automatically attempt to reconnect to the Redis server if the connection is severed (once it was established). If that is not the desired behavior, you should call smaxSetResilient(FALSE)
after connecting.
server | SMA-X Redis server name or IP address, e.g. "127.0.0.1". |
References smaxConnect(), smaxSetServer(), and X_SUCCESS.
Creates a field for 1-D array of a given name and type using specified native values. It is like xCreate1DField()
except that the field is created in serialized form.
name | Field name |
type | Storage type, e.g. X_INT. |
size | Array size. |
value | Pointer to the native array in memory. |
References smaxCreateField(), and x_trace_null().
Creates a field holding a single boolean value. It is like xCreateBooleanField()
except that the field is created in serialized form.
name | Field name |
value | Associated value |
References smaxCreateScalarField(), X_BOOLEAN, and x_trace_null().
XCoordinateSystem * smaxCreateCoordinateSystem | ( | int | nAxis | ) |
Creates a coordinate system with the desired dimension, and standard Cartesian coordinates with no labels, or units specified (NULL).
nAxis | Dimension of the coordiante system, i.e. number of axes. |
References XCoordinateSystem::axis, XCoordinateSystem::nAxis, XCoordinateAxis::step, x_error(), and X_MAX_DIMS.
XField * smaxCreateDoubleField | ( | const char * | name, |
double | value | ||
) |
Creates a field holding a single double-precision value. It is like xCreateDoubleField()
except that the field is created in serialized form.
name | Field name |
value | Associated value |
References smaxCreateScalarField(), X_DOUBLE, and x_trace_null().
XField * smaxCreateField | ( | const char * | name, |
XType | type, | ||
int | ndim, | ||
const int * | sizes, | ||
const void * | value | ||
) |
Creates a generic field of a given name and type and dimensions using the specified native values. It is like xCreateField()
except that the field is created in serialized form for SMA-X.
name | Field name |
type | Storage type, e.g. X_INT. |
ndim | Number of dimensionas (1:20). If ndim < 1, it will be reinterpreted as ndim=1, size[0]=1; |
sizes | Array of sizes along each dimensions, with at least ndim elements, or NULL with ndim<1. |
value | Pointer to the native data location in memory. Unless it is of type X_STRUCT, the data stored in the field is a copy (for type X_RAW) or serialized string (otherwise). |
References XField::isSerialized, smaxValuesToString(), TRUE, XField::value, X_RAW, X_STRING, X_STRUCT, x_trace_null(), xCreateField(), xGetElementCount(), and xStringElementSizeOf().
XField * smaxCreateIntField | ( | const char * | name, |
int | value | ||
) |
Creates a field holding a single integer value. It is like xCreateIntField()
except that the field is created in serialized form.
name | Field name |
value | Associated value |
References smaxCreateScalarField(), X_INT, and x_trace_null().
XField * smaxCreateLongField | ( | const char * | name, |
long long | value | ||
) |
Creates a field holding a single wide (64-bit) integer value. It is like xCreateLongField()
except that the field is created in serialized form.
name | Field name |
value | Associated value |
References smaxCreateScalarField(), X_LONG, and x_trace_null().
XMeta * smaxCreateMeta | ( | ) |
Creates a new SMA-X metadata object with defaults. Effectively the same as calling calloc() followed by xResetMeta().
References smaxResetMeta().
Creates a scalar field of a given name and type using the specified native value. It is like xCreateScalarField()
except that the field is created in serialized form.
name | Field name |
type | Storage type, e.g. X_INT. |
value | Pointer to the native data location in memory. |
References smaxCreate1DField(), and x_trace_null().
XField * smaxCreateStringField | ( | const char * | name, |
const char * | value | ||
) |
Creates a field holding a single string value. It is like xCreateStringField()
except that the field is created in serialized form.
name | Field name |
value | Associated value |
References smaxCreateScalarField(), X_STRING, and x_trace_null().
XSyncPoint * smaxCreateSyncPoint | ( | ) |
Creates a synchronization point that can be waited upon until all elements queued prior to creation are processed (retrieved from the database.
References XSyncPoint::isComplete, XSyncPoint::lock, XSyncPoint::status, X_INCOMPLETE, and X_SUCCESS.
void smaxDestroyCoordinateSystem | ( | XCoordinateSystem * | coords | ) |
Deallocates a coordinate system structure.
coords | Pointer to the coordinate system to discard. |
References XCoordinateSystem::axis.
void smaxDestroySyncPoint | ( | XSyncPoint * | s | ) |
Destroys a synchronization point, releasing the memory space allocated to it.
s | Pointer to the synchronization point to discard. |
References XSyncPoint::isComplete, and XSyncPoint::lock.
int smaxDisconnect | ( | ) |
Disables the SMA-X sharing capability, closing underlying network connections.
References redisxDisconnect(), smaxIsConnected(), x_error(), X_NO_INIT, X_SUCCESS, and xvprintf.
int smaxError | ( | const char * | func, |
int | errorCode | ||
) |
Prints a descriptive error message to stderr, and returns the error code.
func | String that describes the function or location where the error occurred. |
errorCode | Error code that describes the failure. |
References redisxError(), smaxErrorDescription(), X_NO_SERVICE, and xDebug.
const char * smaxErrorDescription | ( | int | code | ) |
Returns a string description for one of the RM error codes.
References redisxErrorDescription().
int smaxGetArrayField | ( | const XStructure * | s, |
const char * | name, | ||
void * | dst, | ||
XType | type, | ||
int | count | ||
) |
Gets the data of an SMA-X structure field as an array of values of the specified type and element count. The field's data will be truncated or padded with zeroes to provide the requested element count always.
s | Pointer to SMA-X structure | |
name | Field name | |
[out] | dst | Array to return values in. |
type | Type of data. | |
count | Number of elements in return array. The field data will be truncated or padded as necessary. |
References smaxStringToValues(), XField::value, x_error(), X_NAME_INVALID, X_NULL, X_SIZE_INVALID, X_STRUCT_INVALID, X_SUCCESS, and xGetField().
boolean smaxGetBooleanField | ( | const XStructure * | s, |
const char * | name, | ||
boolean | defaultValue | ||
) |
Returns the first value in a structure's field as an integer, or the specified default value if there is no such field in the structure, or the content cannot be parse into an integer.
s | Pointer to the XStructure. |
name | Field name |
defaultValue | Value to return if no corresponding integer field value. |
References XField::value, xGetField(), and xParseBoolean().
XCoordinateAxis * smaxGetCoordinateAxis | ( | const char * | id, |
int | n | ||
) |
Returns the n'th coordinate axis for a given SMA-X coordinate system table id.
id | Fully qualified SMA-X coordinate system ID. |
n | The (0-based) index of the coordinate axis |
References RedisEntry::key, XCoordinateAxis::name, redisxGetTable(), XCoordinateAxis::refIndex, XCoordinateAxis::refValue, smaxError(), smaxGetRedis(), XCoordinateAxis::step, XCoordinateAxis::unit, RedisEntry::value, x_error(), X_NO_INIT, x_trace_null(), and xGetAggregateID().
XCoordinateSystem * smaxGetCoordinateSystem | ( | const char * | table, |
const char * | key | ||
) |
Returns the coordinate system, if any, associated to a given SMA-X variable.
table | Hash table name. |
key | Variable / field name in table. |
References XCoordinateSystem::axis, META_COORDS, XCoordinateSystem::nAxis, smaxGetCoordinateAxis(), X_MAX_DIMS, x_trace_null(), and xGetAggregateID().
char * smaxGetDescription | ( | const char * | table, |
const char * | key | ||
) |
Returns a concise description of a variable.
table | Hash table name. |
key | Variable / field name in table. |
References META_DESCRIPTION, smaxPullMeta(), X_SUCCESS, and x_trace_null().
double smaxGetDoubleField | ( | const XStructure * | s, |
const char * | name, | ||
double | defaultValue | ||
) |
Returns the first value in a structure's field as a double precision float, or the specified default value if there is no such field in the structure, or the content cannot be parse into an double.
s | Pointer to the XStructure. |
name | Field name |
defaultValue | Value to return if no corresponding integer field value. |
References XField::value, and xGetField().
char * smaxGetHostName | ( | ) |
Returns the host name on which this program is running. It returns a reference to the same static variable every time. As such you should never call free() on the returned value. Note, that only the leading part of the host name is returned, so for a host that is registered as 'somenode.somedomain' only 'somenode' is returned.
References xStringCopyOf().
char ** smaxGetKeys | ( | const char * | table, |
int * | n | ||
) |
Returns a snapshot of the key names stored in a given Redis hash table, ot NULL if there was an error.
table | Host name or owner ID whose variable to count. | |
[out] | n | Pointer to which the number of keys (>=0) or an error (<0) is returned. An error returned by redisxGetKeys(), or else: |
X_NO_INIT if the SMA-X sharing was not initialized, e.g. via smaxConnect(). X_GROUP_INVALID if the table name is invalid. X_NULL if the output 'n' pointer is NULL.
References redisxGetKeys(), smaxError(), smaxGetRedis(), x_error(), X_NO_INIT, x_trace_null(), and xvprintf.
int smaxGetLazyCached | ( | const char * | table, |
const char * | key, | ||
XType | type, | ||
int | count, | ||
void * | value, | ||
XMeta * | meta | ||
) |
Retrieve a variable from the local cache (if available), or else pull from the SMA-X database. If local caching was not previously eanbled, it will be enabled with this call, so that subsequent calls will always return data from the locally updated cache with minimal overhead and effectively no latency.
table | The hash table name. |
key | The variable name under which the data is stored. |
type | The SMA-X variable type, e.g. X_FLOAT or X_CHARS(40), of the buffer. |
count | The number of elements to retrieve |
value | Pointer to the native data buffer in which to restore values |
meta | Optional metadata pointer, or NULL if metadata is not required. |
References TRUE, X_NO_SERVICE, X_SUCCESS, and x_trace().
int smaxGetLazyUpdateCount | ( | const char * | table, |
const char * | key | ||
) |
Returns the actual number of times a variable has been updated from SMA-X. It may be useful information when deciding if lazy pulling is appropriate (it is if the number of pull requests exceeds the actual number of transfers significantly).
table | The hash table name. |
key | The variable name under which the data is stored. |
long long smaxGetLongField | ( | const XStructure * | s, |
const char * | name, | ||
long long | defaultValue | ||
) |
Returns the first value in a structure's field as an integer, or the specified default value if there is no such field in the structure, or the content cannot be parse into an integer.
s | Pointer to the XStructure. |
name | Field name |
defaultValue | Value to return if no corresponding integer field value. |
References XField::value, and xGetField().
int smaxGetMetaCount | ( | const XMeta * | m | ) |
Returns the number of elements stored from a metadata.
m | pointer to metadata that defines the dimension and shape of elements. |
References XMeta::storeDim, XMeta::storeSizes, and xGetElementCount().
char * smaxGetProgramID | ( | ) |
Returns the SMA-X program ID.
References smaxGetHostName(), and xGetAggregateID().
char * smaxGetRawField | ( | const XStructure * | s, |
const char * | name, | ||
char * | defaultValue | ||
) |
Returns the string value in a structure's field, or the specified default value if there is no such field in the structure.
s | Pointer to the XStructure. |
name | Field name |
defaultValue | Value to return if no corresponding integer field value. |
References XField::value, and xGetField().
Redis * smaxGetRedis | ( | ) |
char * smaxGetScriptSHA1 | ( | const char * | scriptName, |
int * | status | ||
) |
Gets the SHA1 script ID for the currently loaded script with the specified name.
scriptName | Case-sensitive name of the script, e.g. "GetStruct". |
status | Pointer int which to return status, which is X_SUCCESS if the SHA1 id was successfully obtained, or else an appropriate error code. |
References redisxCheckDestroyRESP(), redisxDestroyRESP(), redisxRequest(), RESP_BULK_STRING, SMAX_SCRIPTS, smaxError(), smaxGetRedis(), RESP::value, x_error(), X_NAME_INVALID, X_NO_INIT, and x_trace_null().
int smaxGetServerTime | ( | struct timespec * | t | ) |
Returns the current time on the Redis server instance.
t | Pointer to a timespec structure in which to return the server time. |
References redisxGetTime(), smaxError(), smaxGetRedis(), X_NO_INIT, and X_SUCCESS.
double smaxGetTime | ( | const char * | timestamp | ) |
Returns the a sub-second precision UNIX time value for the given SMA-X timestamp
timestamp | The string timestamp returned by SMA-X |
References NAN, smaxParseTime(), x_error(), X_NULL, and x_trace().
char * smaxGetUnits | ( | const char * | table, |
const char * | key | ||
) |
Returns the physical unit name, if any, for the given variable.
table | Hash table name. |
key | Variable / field name in table. |
References META_UNIT, smaxPullMeta(), X_SUCCESS, and x_trace_null().
int smaxIsConnected | ( | ) |
Checks whether SMA-X sharing is currently open (by a preceding call to smaxConnect() call.
References redisxIsConnected().
boolean smaxIsPipelined | ( | ) |
Check if SMA-X is configured with pipeline mode enabled.
boolean smaxIsResilient | ( | ) |
Checks whether the resiliency feature has been enabled.
boolean smaxIsVerbose | ( | ) |
Checks id verbose reporting is enabled.
References redisxIsVerbose().
int smaxKeyCount | ( | const char * | table | ) |
Retrieve the current number of variables stored on host (or owner ID).
table | Hash table name. |
References RESP::n, redisxCheckRESP(), redisxDestroyRESP(), redisxRequest(), RESP_INT, smaxError(), smaxGetRedis(), x_error(), X_GROUP_INVALID, X_NO_INIT, x_trace(), and xvprintf.
int smaxLazyCache | ( | const char * | table, |
const char * | key, | ||
XType | type | ||
) |
Specify that a specific variable should be cached for minimum overhead lazy access. When a variable is lazy cached its local copy is automatically updated in the background so that accessing it is always nearly instantaneous. Lazy caching is a good choice for variables that change less frequently than they are polled typically. For variables that change frequently (ans used less frequently), lazy caching is not a great choice since it consumes network bandwidth even when the variable is not being accessed.
Once a variable is lazy cached, it can be accessed instantaneously via smaxGetLazyCached() without any blocking network operations.
table | The hash table name. |
key | The variable name under which the data is stored. |
type | The SMA-X variable type, e.g. X_FLOAT or X_CHARS(40), of the buffer. |
References FALSE, TRUE, X_NO_SERVICE, X_SUCCESS, and x_trace().
int smaxLazyEnd | ( | const char * | table, |
const char * | key | ||
) |
Stops processing lazy updates in the background for a given variable.
table | The hash table name. |
key | The variable name under which the data is stored. |
References X_SUCCESS.
int smaxLazyFlush | ( | ) |
Discards caches for all lazy variables (i.e. stops all subscriptions to variable updates, at least until the next smaxLazyPull() call). Generally speaking, it's a good idea to call this routine when one is done using a set of lazy variables for the time being, but want to avoid the tedium of calling smaxLazyEnd() individually for each of them. Note however, that after flushing the lazy caches, the fist lazy call following for each variable will inevitably result in a real SMA-X pull. So use it carefully!
References smaxRemoveSubscribers().
int smaxLazyPull | ( | const char * | table, |
const char * | key, | ||
XType | type, | ||
int | count, | ||
void * | value, | ||
XMeta * | meta | ||
) |
Poll an infrequently changing variable without stressing out the network or the SMA-X database. The first lazy pull for a variable will fetch its value from SMA-X and subscribe to update notifications. Subsequent smaxLazyPull() calls to the same variable will retrieve its value from a local cache (without contacting SMA-X) as long as it is unchanged.
Note, after you are done using a variable that has been lazy pulled, you should call smaxLazyEnd() to signal that it no longer requires to be cached and updated in the background, or call smaxLazyFlush() to flush all lazy caches for all lazy variables (if that is what you want).
table | The hash table name. |
key | The variable name under which the data is stored. |
type | The SMA-X variable type, e.g. X_FLOAT or X_CHARS(40), of the buffer. |
count | The number of points to retrieve into the buffer. |
value | Pointer to the buffer to which the data is to be retrieved. |
meta | Pointer to metadata or NULL if no metadata is needed. |
References x_error(), X_NO_SERVICE, X_NULL, X_SUCCESS, and x_trace().
int smaxLazyPullChars | ( | const char * | table, |
const char * | key, | ||
char * | buf, | ||
int | n | ||
) |
Lazy pulls a string value into the specified string buffer.
table | The hash table name. |
key | The variable name under which the data is stored. |
buf | Buffer to fill with stored data |
n | Number of bytes to fill in buffer. The retrieved data will be truncated as necessary. |
References smaxLazyPull(), X_CHARS, and X_SUCCESS.
double smaxLazyPullDouble | ( | const char * | table, |
const char * | key | ||
) |
Returns a single double-precision value for a given SMA-X variable, or NAN if the value could not be retrieved.
table | The hash table name. |
key | The variable name under which the data is stored. |
References NAN, and smaxLazyPullDoubleDefault().
double smaxLazyPullDoubleDefault | ( | const char * | table, |
const char * | key, | ||
double | defaultValue | ||
) |
Returns a single double-precision value for a given SMA-X variable, or a default value if the value could not be retrieved.
table | The hash table name. |
key | The variable name under which the data is stored. |
defaultValue | The value to return in case of an error. |
References smaxLazyPull(), and X_DOUBLE.
long long smaxLazyPullLong | ( | const char * | table, |
const char * | key, | ||
long long | defaultValue | ||
) |
Returns a single integer value for a given SMA-X variable, or a default value if the value could not be retrieved.
table | The hash table name. |
key | The variable name under which the data is stored. |
defaultValue | The value to return in case of an error. |
References smaxLazyPull(), and X_LONG.
char * smaxLazyPullString | ( | const char * | table, |
const char * | key | ||
) |
Returns a single string value for a given SMA-X variable, or a NULL if the value could not be retrieved.
table | Hash table name. |
key | Variable name under which the data is stored. |
References smaxLazyPull(), X_STRING, and x_trace_null().
int smaxLazyPullStruct | ( | const char * | id, |
XStructure * | s | ||
) |
Lazy pulls data into a structure, discarding any prior data that the structure might contain.
[in] | id | Aggregate structure ID. |
[out] | s | Destination structure to populate with the retrieved fields |
References smaxLazyPull(), X_STRUCT, and X_SUCCESS.
int smaxParseTime | ( | const char * | timestamp, |
time_t * | secs, | ||
long * | nanosecs | ||
) |
Parses a timestamp into broken-down UNIX time.
[in] | timestamp | Timestamp string as returned in redis queries; |
[out] | secs | Pointer to the returned UNIX time (seconds). |
[out] | nanosecs | Pointer to the retuned sub-second remainder as nanoseconds, or NULL if nor requested. |
secs
argument is NULL. X_PARSE_ERROR if the seconds could not be parsed. 1 if there was an error parsing the nanosec part. X_NULL if the secs arhument is NULL References x_error(), X_NULL, X_PARSE_ERROR, and X_SUCCESS.
int smaxPull | ( | const char * | table, |
const char * | key, | ||
XType | type, | ||
int | count, | ||
void * | value, | ||
XMeta * | meta | ||
) |
Pull data from the specified hash table. This calls data via the interactive client to Redis.
[in] | table | Hash table name. |
[in] | key | Variable name under which the data is stored. |
[in] | type | SMA-X variable type, e.g. X_FLOAT or X_CHARS(40), of the buffer. |
[in] | count | Number of points to retrieve into the buffer. |
[out] | value | Pointer to the buffer to which the data is to be retrieved. |
[out] | meta | Pointer to metadata or NULL if no metadata is needed. |
References REDISX_INTERACTIVE_CHANNEL, X_NULL, X_STRUCT, X_SUCCESS, x_trace(), xGetAggregateID(), and xStringCopyOf().
double smaxPullDouble | ( | const char * | table, |
const char * | key | ||
) |
Returns a single floating-point value for a given SMA-X variable, or a NAN if the value could not be retrieved.
table | Hash table name. |
key | Variable name under which the data is stored. |
References NAN, and smaxPullDoubleDefault().
double smaxPullDoubleDefault | ( | const char * | table, |
const char * | key, | ||
double | defaultValue | ||
) |
Returns a single floating-point value for a given SMA-X variable, or a specified default value if the SMA-X value could not be retrieved.
table | Hash table name. |
key | Variable name under which the data is stored. |
defaultValue | The value to return in case of an error. |
References smaxPull(), and X_DOUBLE.
double * smaxPullDoubles | ( | const char * | table, |
const char * | key, | ||
XMeta * | meta, | ||
int * | n | ||
) |
Returns a dynamically allocated array of doubles stored in an SMA-X variable.
[in] | table | The hash table name. |
[in] | key | The variable name under which the data is stored. |
[out] | meta | (optional) Pointer to metadata to be filled or NULL if not required. |
[out] | n | Pointer to which the number of double is returned (if *n > 0) or else an error code. |
References X_DOUBLE, and x_trace_null().
int smaxPullInt | ( | const char * | table, |
const char * | key, | ||
int | defaultValue | ||
) |
Returns a single integer value for a given SMA-X variable, or a default value if the value could not be retrieved.
table | The hash table name. |
key | The variable name under which the data is stored. |
defaultValue | The value to return in case of an error. |
References smaxPull(), and X_INT.
int * smaxPullInts | ( | const char * | table, |
const char * | key, | ||
XMeta * | meta, | ||
int * | n | ||
) |
Returns a dynamically allocated array of integers stored in an SMA-X variable.
[in] | table | The hash table name. |
[in] | key | The variable name under which the data is stored. |
[out] | meta | (optional) Pointer to metadata to be filled or NULL if not required. |
[out] | n | Pointer to which the number of integers is returned (if *n > 0) or else an error code. |
References X_INT, and x_trace_null().
long long smaxPullLong | ( | const char * | table, |
const char * | key, | ||
long long | defaultValue | ||
) |
Returns a single integer value for a given SMA-X variable, or a default value if the value could not be retrieved.
table | The hash table name. |
key | The variable name under which the data is stored. |
defaultValue | The value to return in case of an error. |
References smaxPull(), and X_LONG.
long long * smaxPullLongs | ( | const char * | table, |
const char * | key, | ||
XMeta * | meta, | ||
int * | n | ||
) |
Returns a dynamically allocated array of long long (int64) integers stored in an SMA-X variable.
[in] | table | The hash table name. |
[in] | key | The variable name under which the data is stored. |
[out] | meta | (optional) Pointer to metadata to be filled or NULL if not required. |
[out] | n | Pointer to which the number of integers is returned (if *n > 0) or else an error code. |
References X_INT, and x_trace_null().
char * smaxPullMeta | ( | const char * | meta, |
const char * | table, | ||
const char * | key, | ||
int * | status | ||
) |
Retrieves a metadata string value for a given variable from the database
meta | Root meta table name, usually something like "<metaname>". |
table | Hash table name. |
key | Variable / field name in table. |
status | Pointer to int in which to return a X_SUCCESS or an error code. |
References redisxGetStringValue(), smaxError(), smaxGetRedis(), x_error(), X_GROUP_INVALID, X_NO_INIT, x_trace_null(), and xGetAggregateID().
char * smaxPullRaw | ( | const char * | table, |
const char * | key, | ||
XMeta * | meta, | ||
int * | status | ||
) |
Returns a dynamically allocated buffer with the raw string value stored in SMA-X. This call can also be used to get single string values from SMA-X, since for single string the stored raw value is simply the string itself. However, to properly retrieve string arrays, you want to use smaxPullStrings() instead.
[in] | table | The hash table name. |
[in] | key | The variable name under which the data is stored. |
[out] | meta | (optional) Pointer to metadata to be filled or NULL if not required. |
[out] | status | Pointer int which an error status is returned. |
References smaxPull(), x_error(), X_RAW, and x_trace_null().
char * smaxPullString | ( | const char * | table, |
const char * | key | ||
) |
Returns a single string value for a given SMA-X variable, or a NULL if the value could not be retrieved.
table | Hash table name. |
key | Variable name under which the data is stored. |
References smaxPull(), X_STRING, and x_trace_null().
char ** smaxPullStrings | ( | const char * | table, |
const char * | key, | ||
XMeta * | meta, | ||
int * | n | ||
) |
Returns an array of pointers to individuals strings inside the retrieved contiguous data buffer. Thus, to discard the returned data after use, you must first discard the underlying buffer (as pointed by the first element) before discarding the array of pointers themselves. E.g.:
char **array = smaxPullStrings("mygroup", "myfield", &meta); ... if(array != NULL) { free(array[0]); // discards the underlying contiguous buffer free(array); // discards the array of pointers. }
[in] | table | The hash table name. |
[in] | key | The variable name under which the data is stored. |
[out] | meta | (optional) Pointer to metadata to be filled or NULL if not required. |
[out] | n | Pointer to which the number of double is returned (if *n > 0) or else an error code. |
References smaxGetMetaCount(), smaxPullRaw(), XMeta::storeBytes, x_error(), X_META_INIT, and x_trace_null().
XStructure * smaxPullStruct | ( | const char * | id, |
XMeta * | meta, | ||
int * | status | ||
) |
Returns a dynamically allocated XStrucure for the specified hashtable in SMA-X.
[in] | id | Aggregated structure ID. |
[out] | meta | (optional) Pointer to metadata to be filled or NULL if not required. |
[out] | status | Pointer int which an error status is returned. |
References smaxPull(), x_error(), X_STRUCT, and x_trace_null().
double smaxPullTime | ( | const char * | table, |
const char * | key | ||
) |
Retrieves the timestamp for a given variable from the database.
[in] | table | Hash table name (or NULL if key is an aggregate ID). |
[in] | key | Variable / field name in table. |
References NAN, SMAX_TIMESTAMPS, smaxPullMeta(), x_error(), and x_trace_null().
XType smaxPullTypeDimension | ( | const char * | table, |
const char * | key, | ||
int * | ndim, | ||
int * | sizes | ||
) |
Retrieves the timestamp for a given variable from the database.
[in] | table | Hash table name (or NULL if key is an aggregate ID). |
[in] | key | Variable / field name in table. |
[out] | ndim | Pointer to integer in which to return the dimensionality of the variable, or NULL if not requested. |
[out] | sizes | Array to store sizes along each dimension, which should hold X_MAX_DIMS integers, or NULL if dimensions are not requested. |
References SMAX_DIMS, SMAX_TYPES, smaxPullMeta(), smaxTypeForString(), x_trace(), X_UNKNOWN, and xParseDims().
int smaxPushMeta | ( | const char * | meta, |
const char * | table, | ||
const char * | key, | ||
const char * | value | ||
) |
Adds/updates metadata associated with an SMA-X variable. The data will be pushed via the Redis pipeline channel.
meta | Root meta table name, usually something like "<metaname>". |
table | Hash table name. |
key | Variable / field name in table. |
value | Metadata string value. |
References FALSE, redisxNotify(), redisxSetValue(), smaxError(), smaxGetProgramID(), smaxGetRedis(), x_error(), X_GROUP_INVALID, X_INCOMPLETE, X_NO_INIT, X_NULL, X_SUCCESS, x_trace(), and xGetAggregateID().
int smaxQueue | ( | const char * | table, |
const char * | key, | ||
XType | type, | ||
int | count, | ||
void * | value, | ||
XMeta * | meta | ||
) |
Queues a pull requests for pipelined data retrieval. Because pipelined pulls are executed on a separate Redis client from the one used for sharing values, e.g. via smaxShare(), there is no guarantee as to the order of this pull operation and previously initiated shares from the same thread. This would only be an issue if you are trying to use queued read to read back a value you have just shared – which is not really a good use case anyway, as it generates network traffic for not real reason. But, if you must read back a value you have shared, you probably should use a regular smaxPull() call to ensure ordering.
table | Hash table name. | |
key | Variable name under which the data is stored. | |
type | SMA-X variable type, e.g. X_FLOAT or X_CHARS(40), of the buffer. | |
count | Number of points to retrieve into the buffer. | |
[out] | value | Pointer to the buffer to which the data is to be retrieved. |
[out] | meta | Pointer to the corresponding metadata structure, or NULL. |
References REDISX_PIPELINE_CHANNEL, SMAX_PIPE_READ_TIMEOUT_MILLIS, x_error(), X_GROUP_INVALID, X_NAME_INVALID, X_NO_SERVICE, X_NULL, X_SUCCESS, x_trace(), and xStringCopyOf().
int smaxQueueCallback | ( | void(*)(void *) | f, |
void * | arg | ||
) |
Adds a callback function to the queue to be called with the specified argument once all prior requests in the queue have been fullfilled (retrieved from the database).
As a general rule callbacks added to the pipeline should return very fast, and avoid blocking operations for the most part (using mutexes that may block for very short periods only may be excepted). If the user needs to do more processing, or make blocking calls (e.g. IO operartions) that may not return for longer periods, the callback should fire off processing in a separate thread, or else simply move the result into another asynchronous processing queue.
f | The callback function that takes a pointer argument |
arg | Argument to call the specified function with. |
int smaxReconnect | ( | ) |
Reconnects to the SMA-X server. It will try connecting repeatedly at regular intervals until the connection is made. If resilient mode is enabled, then locally accumulated shares will be sent to the Redis server upon reconnection. However, subscriptions are not automatically re-established. The caller is responsible for reinstate any necessary subscriptions after the reconnection or via an approproate connection hook.
or the error returned by redisxReconnect().
References redisxReconnect(), SMAX_RECONNECT_RETRY_SECONDS, x_error(), X_NO_INIT, X_SUCCESS, and xvprintf.
int smaxReleaseWaits | ( | ) |
Unblocks all smax_wait*() calls, which will return X_REL_PREMATURE, as a result.
int smaxRemoveConnectHook | ( | void(*)(void) | setupCall | ) |
Remove a post-connection callback function. It's a wrapper to redisxRemoveConnectHook().
setupCall | Callback function |
References redisxRemoveConnectHook(), smaxError(), smaxGetRedis(), X_NO_INIT, and X_SUCCESS.
int smaxRemoveDisconnectHook | ( | void(*)(void) | cleanupCall | ) |
Remove a post-cdisconnect callback function. It's a wrapper to redisxRemiveDisconnectHook().
cleanupCall | Callback function |
References redisxRemoveDisconnectHook(), smaxError(), smaxGetRedis(), X_NO_INIT, and X_SUCCESS.
int smaxRemoveMessageProcessor | ( | int | id | ) |
Stops a running message processor.
id | Message processor ID, as returned by smaxAddMessageProcessor() |
References redisxRemoveSubscribers(), redisxUnsubscribe(), smaxError(), smaxGetRedis(), X_NO_INIT, X_NULL, and X_SUCCESS.
int smaxRemoveSubscribers | ( | RedisSubscriberCall | f | ) |
Remove all instances of a subscriber callback function from the current list of functions processing PUB/SUB messages. This call only deactivates the callback routine, but does not stop the delivery of update notifications from the Redis server. You should therefore also call smaxUnsubscribe() as appropriate to stop notifications for variables that no longer have associated callbacks.
f | Function to remove |
References redisxRemoveSubscribers(), smaxError(), smaxGetRedis(), X_NO_INIT, and X_SUCCESS.
void smaxResetMeta | ( | XMeta * | m | ) |
Set metadata to their default values. After resetting the supplied metadata will have exactly the same content as if it were initialized with the X_META_INIT macro.
m | Pointer to the metadata that is to be cleared. |
References X_META_INIT.
int smaxSendDebug | ( | const char * | msg, |
... | |||
) |
Broadcast a debugging message via SMA-X (e.g. program traces). Works just like printf()
.
msg | Message text (may include format specifications for additional vararg parameters) |
References SMAX_MSG_DEBUG, and X_SUCCESS.
int smaxSendDetail | ( | const char * | msg, |
... | |||
) |
Broadcast non-essential verbose informational detail via SMA-X. Works just like printf()
.
msg | Message text (may include format specifications for additional vararg parameters) |
References SMAX_MSG_DETAIL, and X_SUCCESS.
int smaxSendError | ( | const char * | msg, |
... | |||
) |
Broadcast an error message via SMA-X. Errors should be used for an issues that impair program functionality. Works just like printf()
.
msg | Message text (may include format specifications for additional vararg parameters) |
References SMAX_MSG_ERROR, and X_SUCCESS.
int smaxSendInfo | ( | const char * | msg, |
... | |||
) |
Broadcast an informational message via SMA-X. These should be confirmations or essential information reported back to users. Non-essential information should be sent with sendDetail() instead. Works just like printf()
.
msg | Message text (may include format specifications for additional vararg parameters) |
References SMAX_MSG_INFO, and X_SUCCESS.
int smaxSendProgress | ( | double | fraction, |
const char * | msg, | ||
... | |||
) |
Broadcast a progress update over SMA-X. Apart from the progress fraction argument, it works just like printf()
.
fraction | (0.0:1.0) Completion fraction. |
msg | Message text (may include format specifications for additional vararg parameters) |
References SMAX_MSG_DETAIL, x_error(), X_NULL, and X_SUCCESS.
int smaxSendStatus | ( | const char * | msg, |
... | |||
) |
Broadcast a program status update via SMA-X. Works just like printf()
.
msg | Message text (may include format specifications for additional vararg parameters) |
References SMAX_MSG_STATUS, and X_SUCCESS.
int smaxSendWarning | ( | const char * | msg, |
... | |||
) |
Broadcast a warning message via SMA-X. Warnings should be used for any potentially problematic issues that nonetheless do not impair program functionality. Works just like printf()
.
msg | Message text (may include format specifications for additional vararg parameters) |
References SMAX_MSG_WARNING, and X_SUCCESS.
int smaxSetAuth | ( | const char * | username, |
const char * | password | ||
) |
Sets the SMA-X database authentication parameters (if any) before connecting to the SMA-X server.
username | Redis ACL user name (if any), or NULL for no user-based authentication |
password | Redis database password (if any), or NULL if the database is not password protected |
References smaxIsConnected(), X_ALREADY_OPEN, x_error(), X_SUCCESS, and xStringCopyOf().
int smaxSetCoordinateAxis | ( | const char * | id, |
int | n, | ||
const XCoordinateAxis * | axis | ||
) |
Defines the n'th coordinate axis for a given SMA-X coordinate system table id.
id | Fully qualified SMA-X coordinate system ID. |
n | The (0-based) index of the coordinate axis |
axis | Pointer to the structure describing the coordinate axis. |
References FALSE, RedisEntry::key, XCoordinateAxis::name, redisxMultiSet(), XCoordinateAxis::refIndex, XCoordinateAxis::refValue, smaxGetRedis(), XCoordinateAxis::step, XCoordinateAxis::unit, RedisEntry::value, X_FAILURE, X_SUCCESS, x_trace(), and xGetAggregateID().
int smaxSetCoordinateSystem | ( | const char * | table, |
const char * | key, | ||
const XCoordinateSystem * | coords | ||
) |
Sets the coordinate system metadata for data in the database.
table | Hash table name. |
key | Variable / field name in table. |
coords | Pointer to the coordinate system structure associated to this variable. |
References XCoordinateSystem::axis, META_COORDS, XCoordinateSystem::nAxis, smaxSetCoordinateAxis(), X_NULL, X_SUCCESS, x_trace(), and xGetAggregateID().
int smaxSetDB | ( | int | idx | ) |
Sets a non-default Redis database index to use for SMA-X before connecting to the SMA-X server.
idx | The Redis database index to use (if not the default one) |
References smaxIsConnected(), X_ALREADY_OPEN, x_error(), and X_SUCCESS.
int smaxSetDescription | ( | const char * | table, |
const char * | key, | ||
const char * | description | ||
) |
Sets the static description for a given SMA-X variable.
table | Hash table name. |
key | Variable / field name in table. |
description | Concise but descriptive summary of the meaning of the variable. |
References META_DESCRIPTION, smaxPushMeta(), and X_SUCCESS.
void smaxSetHostName | ( | const char * | name | ) |
Changes the host name to the user-specified value instead of the default (leading component of the value returned by gethostname()). Subsequent calls to smaxGetHostName() will return the newly set value. An argument of NULL resets to the default.
name | the host name to use, or NULL to revert to the default (leading component of gethostname()). |
References xStringCopyOf().
int smaxSetMaxPendingPulls | ( | int | n | ) |
Configures how many pull requests can be queued in when piped pulls are enabled. If the queue reaches the specified limit, no new pull requests can be submitted until responses arrive, draining the queue somewhat.
n | The maximum number of pull requests that can be queued. |
void smaxSetMessageSenderID | ( | const char * | id | ) |
Sets the sender ID for outgoing program messages. By default the sender ID is <host>:<program> for the program that calls this function, but it can be modified to use some other SMA-X style hierarchical ID also.
id | The new sender ID for outgoing program messages, or NULL to reinstate the default <host>:<program> style ID. The argument is not referenced and can be deallocated as desired after the call without affecting the newly defined message ID. |
References xStringCopyOf().
void smaxSetOrigin | ( | XMeta * | m, |
const char * | origin | ||
) |
Sets the 'origin' field of an SMA-X metadata to the specified value, truncating as necessary to fit into the allotted fixed storage.
origin | The origination information, usually as hostname:progname |
m | Pointer to metadata to set. |
References XMeta::origin, and SMAX_ORIGIN_LENGTH.
int smaxSetPipelineConsumer | ( | void(*)(RESP *) | f | ) |
Change the pipeline response consumer function (from it's default or other previous consumer). It is a wrapper for redisxSetPipelineConsumer().
f | The function to process ALL pipeline responses from Redis. |
References redisxSetPipelineConsumer(), smaxError(), smaxGetRedis(), X_NO_INIT, and X_SUCCESS.
int smaxSetPipelined | ( | boolean | isEnabled | ) |
Enable or disable pipelined write operations (enabled by default). When pipelining, share calls will return as soon as the request is sent to the Redis server, without waiting for a response. Instead, responses are consumed asynchronously by a dedicated thread, which will report errors to stderr. Pipelined writes can have a significant performance advantage over handshaking at the cost of one extra socket connection to Redis (dedicated to pipelining) and the extra thread consuming responses.
The default state of pipelined writes might vary by platform (e.g. enabled on Linux, disabled on LynxOS).
IMPORTANT: calls to smaxSetPipelined() must precede the call to smaxConnect().
isEnabled | TRUE to enable pipelined writes, FALSE to disable (default is enabled). |
References smaxIsConnected(), X_ALREADY_OPEN, x_error(), and X_SUCCESS.
void smaxSetResilient | ( | boolean | value | ) |
Enables the resiliency feature of the library, which keeps track of local changes destined to the database when the database is not reachable, and sending all locally stored updates once the database comes online again. However, after sending all pending updates to the remote server, the program may exit (default behavior), unless smaxSetResilientExit() is set to FALSE (0), so that it can be restarted in a fresh state, setting up subscriptions and scripts again as necessary.
value | TRUE (non-zero) to enable, or FALSE (0) to disable resiliency. |
References FALSE, smaxAddConnectHook(), smaxRemoveConnectHook(), TRUE, and xvprintf.
void smaxSetResilientExit | ( | boolean | value | ) |
Sets whether the program should exit in resilient mode, after having pushed all local updates. The default is to exit since the reconnecting in resilient mode does not by itself re-establish existing subscriptions. However, when subscriptions aren't used, or if they are set up as a connect hook, the user may want the program to simply continue. This is possible by passing FALSE (0) as the argument to this call. This setting only takes effect when resilient mode is enabled. Otherwise, the exit policy is set by the RedisX library.
value | Whether to exit the program after all local updates have been pushed to SMA-X after a recovering from an outage. |
int smaxSetServer | ( | const char * | host, |
int | port | ||
) |
Configures the SMA-X server before connecting.
host | The SMA-X REdis server host name or IP address. |
port | The Redis port number on the SMA-X server, or <=0 to use the default |
References REDISX_TCP_PORT, smaxIsConnected(), X_ALREADY_OPEN, x_error(), X_SUCCESS, and xStringCopyOf().
int smaxSetTcpBuf | ( | int | size | ) |
Set the size of the TCP/IP buffers (send and receive) for future client connections.
size | (bytes) requested buffer size, or <= 0 to use default value |
References smaxIsConnected(), X_ALREADY_OPEN, x_error(), and X_SUCCESS.
int smaxSetUnits | ( | const char * | table, |
const char * | key, | ||
const char * | unit | ||
) |
Sets the physical unit name for a given SMA-X variable.
table | Hash table name. |
key | Variable / field name in table. |
unit | Standard unit specification, e.g. "W / Hz" or "W Hz**{-1}". |
References META_UNIT, smaxPushMeta(), and X_SUCCESS.
void smaxSetVerbose | ( | boolean | value | ) |
Enable or disable verbose reporting of all SMA-X operations (and possibly some details of them). Reporting is done on the standard output (stdout). It may be useful when debugging programs that use the SMA-X interface. Verbose reporting is DISABLED by default.
value | TRUE to enable verbose reporting, or FALSE to disable. |
References redisxSetVerbose().
int smaxShare | ( | const char * | table, |
const char * | key, | ||
const void * | value, | ||
XType | type, | ||
int | count | ||
) |
Share the data into a Redis hash table over the interactive Redis client. It's a fire-and-forget type implementation, which sends the data to Redis, without waiting for confirmation of its arrival. The choice improves the efficiency and throughput, and minimizes execution time, of the call, but it also means that a pipelined pull request in quick succession, e.g. via smaxQueue(), may return a value on the pipeline client before this call is fully executed on the interactive Redis client.
(It is generally unlikely that you will follow this share call with a pipelined pull of the same variable. It would not only create superflous network traffic for no good reason, but it also would have unpredictable results. So, don't.)
table | Hash table name in which to share entry. |
key | Variable name under which the data is stored. |
value | Pointer to the buffer whose data is to be shared. |
type | SMA-X variable type, e.g. X_FLOAT or X_CHARS(40), of the buffer. |
count | Number of 1D elements. |
References smaxShareArray(), and X_SUCCESS.
int smaxShareArray | ( | const char * | table, |
const char * | key, | ||
const void * | ptr, | ||
XType | type, | ||
int | ndim, | ||
const int * | sizes | ||
) |
Share a multidimensional array, such as an int[][][]
, or float[][]
, in a single atomic transaction.
table | Hash table in which to write entry. |
key | Variable name under which the data is stored. |
ptr | Pointer to the data buffer, such as an int[][][] or float[][] . |
type | SMA-X variable type, e.g. X_FLOAT or X_CHARS(40), of the buffer. |
ndim | Dimensionality of the data (0 <= ndim <= X_MAX_DIMS). |
sizes | An array of ints containing the sizes along each dimension. |
References XField::isSerialized, XField::name, XField::ndim, REDISX_CMDBUF_SIZE, XField::sizes, smaxShareField(), smaxValuesToString(), TRUE, XField::type, XField::value, x_error(), X_MAX_ELEMENTS, X_NULL, X_RAW, X_SIZE_INVALID, X_STRUCT, X_SUCCESS, x_trace(), and xGetElementCount().
int smaxShareBoolean | ( | const char * | table, |
const char * | key, | ||
boolean | value | ||
) |
Shares a single boolean value to SMA-X. All non-zero values are mapped to "1".
table | The hash table name. |
key | The variable name under which the data is stored. |
value | A boolean value. |
References smaxShareBooleans(), and X_SUCCESS.
int smaxShareBooleans | ( | const char * | table, |
const char * | key, | ||
const boolean * | values, | ||
int | n | ||
) |
Shares an array of boolean values to SMA-X. All non-zero values are mapped to "1".
table | Hash table name. |
key | Variable name under which the data is stored. |
values | Pointer to boolean[] array. |
n | Number of elements in array to share. |
References smaxShare(), X_BOOLEAN, and X_SUCCESS.
int smaxShareBytes | ( | const char * | table, |
const char * | key, | ||
const char * | values, | ||
int | n | ||
) |
Shares a binary sequence to SMA-X.
table | The hash table name. |
key | The variable name under which the data is stored. |
values | pointer to the byte buffer. |
n | Number of bytes in buffer to share. |
References smaxShare(), X_BYTE, and X_SUCCESS.
int smaxShareDouble | ( | const char * | table, |
const char * | key, | ||
double | value | ||
) |
Shares a single floating point value to SMA-X.
table | The hash table name. |
key | The variable name under which the data is stored. |
value | floating-point value. |
References smaxShareDoubles(), and X_SUCCESS.
int smaxShareDoubles | ( | const char * | table, |
const char * | key, | ||
const double * | values, | ||
int | n | ||
) |
Shares an array of doubles to SMA-X.
table | The hash table name. |
key | The variable name under which the data is stored. |
values | Pointer to double[] array. |
n | Number of elements in array to share. |
References smaxShare(), X_DOUBLE, and X_SUCCESS.
int smaxShareField | ( | const char * | table, |
const XField * | f | ||
) |
Share a field object, which may contain any SMA-X data type.
table | Hash table in which to write entry. |
f | Pointer for XField holding the data to share. |
References XField::name, smaxShareStruct(), XField::type, XField::value, X_NO_SERVICE, X_STRUCT, X_SUCCESS, x_trace(), and xGetAggregateID().
int smaxShareFloats | ( | const char * | table, |
const char * | key, | ||
const float * | values, | ||
int | n | ||
) |
Shares an array of floats to SMA-X.
table | The hash table name. |
key | The variable name under which the data is stored. |
values | Pointer to float[] array. |
n | Number of elements in array to share. |
References smaxShare(), X_FLOAT, and X_SUCCESS.
int smaxShareHex | ( | const char * | table, |
const char * | key, | ||
long long | value | ||
) |
Shares a single integer value to SMA-X in a hexadecimal representatin.
table | The hash table name. |
key | The variable name under which the data is stored. |
value | Integer value. |
References smaxShare(), X_LONG_HEX, and X_SUCCESS.
int smaxShareInt | ( | const char * | table, |
const char * | key, | ||
long long | value | ||
) |
Shares a single integer value to SMA-X.
table | Hash table name. |
key | Variable name under which the data is stored. |
value | Integer value. |
References smaxShareLongs(), and X_SUCCESS.
int smaxShareInts | ( | const char * | table, |
const char * | key, | ||
const int * | values, | ||
int | n | ||
) |
Shares an array of long integers to SMA-X.
table | The hash table name. |
key | The variable name under which the data is stored. |
values | Pointer to int[] array. |
n | Number of elements in array to share. |
References smaxShare(), X_INT, and X_SUCCESS.
int smaxShareLongs | ( | const char * | table, |
const char * | key, | ||
const long long * | values, | ||
int | n | ||
) |
Shares an array of wide integers to SMA-X.
table | The hash table name. |
key | The variable name under which the data is stored. |
values | Pointer to long long[] array. |
n | Number of elements in array to share. |
References smaxShare(), X_LONG, and X_SUCCESS.
int smaxShareShorts | ( | const char * | table, |
const char * | key, | ||
const short * | values, | ||
int | n | ||
) |
Shares an array of shorts to SMA-X.
table | The hash table name. |
key | The variable name under which the data is stored. |
values | Pointer to short[] array. |
n | Number of elements in array to share. |
References smaxShare(), X_SHORT, and X_SUCCESS.
int smaxShareString | ( | const char * | table, |
const char * | key, | ||
const char * | sValue | ||
) |
Shares a single string value to SMA-X.
table | The hash table name. |
key | The variable name under which the data is stored. |
sValue | Pointer to string. |
References smaxShare(), X_RAW, and X_SUCCESS.
int smaxShareStrings | ( | const char * | table, |
const char * | key, | ||
const char ** | sValues, | ||
int | n | ||
) |
Shares an array of strings to SMA-X.
table | The hash table name. |
key | The variable name under which the data is stored. |
sValues | Pointer to array of string pointers. |
n | Number of elements in array to share. |
References smaxShare(), x_error(), X_NULL, X_RAW, and X_SUCCESS.
int smaxShareStruct | ( | const char * | id, |
const XStructure * | s | ||
) |
Share a structure, and all its data including recursive sub-structures, in a single atromic transaction.
id | Structure's ID, i.e. its own aggregated hash table name. |
s | Pointer to the structure data. |
References smaxCreateField(), X_NO_SERVICE, X_STRUCT, and X_SUCCESS.
int smaxStringToValues | ( | const char * | str, |
void * | value, | ||
XType | type, | ||
int | eCount, | ||
int * | pos | ||
) |
Deserializes a string to binary values.
[in] | str | Serialized ASCII representation of the data (as stored by Redis). |
[out] | value | Pointer to the buffer that will hold the binary values. The caller is responsible for ensuring the buffer is sufficiently sized for holding the data for the given variable. |
[in] | type | Share type, e.g. X_INT. The types X_RAW, X_STRUCT are not supported by this function. |
[in] | eCount | Number of elements to retrieve. Ignored for X_STRUCT. |
[out] | pos | Parse position, i.e. the number of characters parsed from the input string... |
X_NULL If the value or str argument is NULL. X_TYPE_INVALID If the type is not supported. X_SIZE_INVALID If size is invalid (e.g. X_RAW, X_STRUCT) X_PARSE_ERROR If the tokens could not be parsed in the format expected
References smaxUnpackStrings(), X_BOOLEAN, X_BYTE, X_BYTE_HEX, X_DOUBLE, x_error(), X_FLOAT, X_INT, X_INT_HEX, X_LONG, X_LONG_HEX, X_NULL, X_RAW, X_SHORT, X_SHORT_HEX, X_SIZE_INVALID, X_STRING, X_STRUCT, x_trace(), X_TYPE_INVALID, xElementSizeOf(), xIsCharSequence(), xParseBoolean(), xParseDouble(), and xZero().
char * smaxStringType | ( | XType | type | ) |
Returns the string type for a given XType argument as a constant expression. For examples X_LONG -> "int64".
type | SMA-X type, e.g. X_FLOAT |
References X_BOOLEAN, X_BYTE, X_BYTE_HEX, X_DOUBLE, x_error(), X_FLOAT, X_INT, X_INT_HEX, X_LONG, X_LONG_HEX, X_RAW, X_SHORT, X_SHORT_HEX, X_STRING, X_STRUCT, and X_UNKNOWN.
int smaxSubscribe | ( | const char * | table, |
const char * | key | ||
) |
Subscribes to a specific key(s) in specific group(s). Both the group and key names may contain Redis subscription patterns, e.g. '*' or '?', or bound characters in square-brackets, e.g. '[ab]'. The subscription only enables receiving update notifications from Redis for the specified variable or variables. After subscribing, you can either wait on the subscribed variables to change, or add callback functions to process subscribed variables changes, via smaxAddSubscriber().
table | Variable group pattern, i.e. hash-table names. (NULL is the same as '*'). |
key | Variable name pattern. (if NULL then subscribes only to the table stem). |
References redisxSubscribe(), smaxError(), smaxGetRedis(), X_NO_INIT, and X_SUCCESS.
int smaxSync | ( | XSyncPoint * | sync, |
int | timeoutMillis | ||
) |
Waits for the queue to reach the specified sync point, up to an optional timeout limit.
sync | Pointer to a queued synchronization point. |
timeoutMillis | An optional timeout in milliseconds. When set to a positive value The call will be guaranteed to return in the specified interval, whether or not the pipelined reads all succeeded. The return value can be used to check for errors or if the call timed out before all data were collected. If X_TIMEDOUT is returned, smax_end_bulk_pulls() may be called again to allow more time for the queued read operations to complete. 0 or negative timeout values will cause the call to wait indefinitely until reads are complete. |
or the first pull error encountered in the queue since the current batch began.
References XSyncPoint::isComplete, XSyncPoint::lock, XSyncPoint::status, x_error(), X_FAILURE, X_INCOMPLETE, X_NULL, X_SUCCESS, X_TIMEDOUT, x_trace(), and xvprintf.
int smaxTimestamp | ( | char * | buf | ) |
Prints the current time into the supplied buffer with subsecond precision.
[out] | buf | Pointer to string buffer, must be at least X_TIMESTAMP_LENGTH in size. |
buf
argument is NULL. References smaxTimeToString().
int smaxTimeToString | ( | const struct timespec * | time, |
char * | buf | ||
) |
*/
Prints the given UNIX time into the supplied buffer with subsecond precision.
[in] | time | Pointer to time value. |
[out] | buf | Pointer to string buffer, must be at least X_TIMESTAMP_LENGTH in size. |
buf
argument is NULL. XType smaxTypeForString | ( | const char * | type | ) |
Returns the XType for a given case-sensitive type string. For example "float" -> X_FLOAT. The value "raw" will return X_RAW.
type | String type, e.g. "struct". |
References X_BOOLEAN, X_BYTE, X_DOUBLE, x_error(), X_FLOAT, X_INT, X_LONG, X_RAW, X_SHORT, X_STRING, X_STRUCT, and X_UNKNOWN.
int smaxUnpackStrings | ( | const char * | data, |
int | len, | ||
int | count, | ||
char ** | dst | ||
) |
Returns an array of dynamically allocated strings from a packed buffer of consecutive 0-terminated or '\r'-separated string elements.
[in] | data | Pointer to the packed string data buffer. |
[in] | len | length of packed string (excl. termination). |
[in] | count | Number of string elements expected. If fewer than that are found in the packed data, then the returned array of pointers will be padded with NULL. |
[out] | dst | An array of string pointers (of size 'count') which will point to dynamically allocated string (char*) elements. The array is assumed to be uninitialized, and elements will be allocated as necessary. |
References x_error(), X_INCOMPLETE, X_NULL, and X_SUCCESS.
int smaxUnsubscribe | ( | const char * | table, |
const char * | key | ||
) |
Unsubscribes from a specific key(s) in specific group(s). Both the group and key names may contain Redis subscription patterns, e.g. '*' or '?', or bound characters in square-brackets, e.g. '[ab]'. Unsubscribing will only stops the delivery of update notifications for the affected varuiables, but does not deactivate the associated callbacks for these added via smaxAddSubscriber(). Therefore you should also call smaxRemovesubscribers() as appropriate to deactivate actions that can no longer get triggered by updates.
table | Variable group pattern, i.e. structure or hash-table name(s) (NULL is the same as '*'). |
key | Variable name pattern. (if NULL then unsubscribes only from the table stem). |
References redisxUnsubscribe(), smaxError(), smaxGetRedis(), X_NO_INIT, and X_SUCCESS.
char * smaxValuesToString | ( | const void * | value, |
XType | type, | ||
int | eCount, | ||
char * | trybuf, | ||
int | trylength | ||
) |
Serializes binary values into a string representation (for Redis).
[in] | value | Pointer to an array of values, or NULL to produce all zeroes. If type is X_STRING value should be a pointer to a char** (array of string pointers), as opposed to X_CHAR(n), which expects a contiguous char* buffer with [n * eCount] length (Note, a char[eCount][n] is equivalent to such a char* buffer). |
[in] | type | Share type, e.g. X_DOUBLE. All type except X_STRUCT are supported. |
[in] | eCount | Number of elements (ignored for X_RAW). |
[in,out] | trybuf | (optional) An optional pointer to a buffer that will be used if sufficient (can be NULL). |
[in] | trylength | (optional) Size of the optional buffer. |
References X_BOOLEAN, X_BYTE, X_BYTE_HEX, X_DOUBLE, x_error(), X_FLOAT, X_INT, X_INT_HEX, X_LONG, X_LONG_HEX, X_RAW, X_SHORT, X_SHORT_HEX, X_STRING, X_STRUCT, x_trace_null(), X_UNKNOWN, xElementSizeOf(), xIsCharSequence(), xPrintDouble(), xPrintFloat(), and xStringElementSizeOf().
int smaxWaitOnAnySubscribed | ( | char ** | changedTable, |
char ** | changedKey, | ||
int | timeout | ||
) |
Waits until any variable was pushed on any host, returning both the host and variable name for the updated value. The variable must be already subscribed to with smaxSubscribe(), or else the wait will not receive update notifications.
[out] | changedTable | Pointer to the variable that points to the string buffer for the returned table name or NULL. The lease of the buffer is for the call only. |
[out] | changedKey | Pointer to the variable that points to the string buffer for the returned variable name or NULL. The lease of the buffer is for the call only. |
[in] | timeout | (s) Timeout value. 0 or negative values result in an indefinite wait. |
References RELEASEID, smaxError(), smaxGetRedis(), smaxIsConnected(), x_error(), X_GROUP_INVALID, X_INCOMPLETE, X_INTERRUPTED, X_NAME_INVALID, X_NO_INIT, X_NO_SERVICE, X_SEP_LENGTH, X_SUCCESS, xdprintf, xLastSeparator(), xStringCopyOf(), and xvprintf.
int smaxWaitOnSubscribed | ( | const char * | table, |
const char * | key, | ||
int | timeout | ||
) |
Waits for a specific pushed entry. There must be an active subscription that includes the specified group & variable, or else the call will block indefinitely.
table | Hash table name |
key | Variable name to wait on. |
timeout | (s) Timeout value. 0 or negative values result in an indefinite wait. |
References x_error(), X_GROUP_INVALID, X_NAME_INVALID, and X_SUCCESS.
int smaxWaitOnSubscribedGroup | ( | const char * | matchTable, |
char ** | changedKey, | ||
int | timeout | ||
) |
Waits for changes on a specific group. The must be an active subscription including that group, or else the call will block indefinitely.
[in] | matchTable | Hash table name (e.g. owner ID) to wait on. |
[out] | changedKey | Pointer to the string that holds the name of the variable which unblocked the wait or which is set to NULL. The lease of the buffer is for the call only. The caller should copy its content if persistent storage is required. |
[in] | timeout | (s) Timeout value. 0 or negative values result in an indefinite wait. |
References x_error(), X_GROUP_INVALID, and X_SUCCESS.
int smaxWaitOnSubscribedVar | ( | const char * | matchKey, |
char ** | changedTable, | ||
int | timeout | ||
) |
Waits for a specific pushed variable from any group/table. There must be an active subscription that includes the specified variable in one or more groups/tables, or else the call will block indefinitely.
[in] | matchKey | Variable name to wait on. |
[out] | changedTable | Pointer to the string that holds the name of the table which unblocked the wait or which is set to NULL. The lease of the buffer is for the call only. The caller should copy its content if persistent storage is required. |
[in] | timeout | (s) Timeout value. 0 or negative values result in an indefinite wait. |
References x_error(), X_NAME_INVALID, and X_SUCCESS.
int smaxWaitQueueComplete | ( | int | timeoutMillis | ) |
Waits until all queued pull requests have been retrieved from the database, or until the specified timeout it reached.
timeoutMillis | An optional timeout in milliseconds. When set to a positive value The call will be guaranteed to return in the specified interval, whether or not the pipelined reads all succeeded. The return value can be used to check for errors or if the call timed out before all data were collected. If X_TIMEDOUT is returned, smax_end_bulk_pulls() may be called again to allow more time for the queued read operations to complete. 0 or negative timeout values will cause the call to wait indefinitely until reads are complete. |
References XSyncPoint::isComplete, XSyncPoint::lock, smaxSync(), XSyncPoint::status, X_INCOMPLETE, and X_SUCCESS.
int x2smaxField | ( | XField * | f | ) |
Converts a standard xchange field (with a native value storage) to an SMA-X field with serialized string value storage.
[in,out] | f | Pointer to field to convert |
References XField::isSerialized, smaxValuesToString(), TRUE, XField::type, XField::value, x2smaxStruct(), x_error(), X_NULL, X_RAW, X_STRUCT, X_SUCCESS, x_trace(), and xGetFieldCount().
int x2smaxStruct | ( | XStructure * | s | ) |
Converts a standard xchange structure (with a native value storage) to an SMA-X structure with serialized string value storage.
s | Pointer to structure to convert |
References XStructure::firstField, XField::next, x2smaxField(), x_error(), X_STRUCT_INVALID, and X_SUCCESS.