Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions include/smax-postgres.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@
#define SMAXPQ_VERSION_STRING str_2(SMAXPQ_MAJOR_VERSION) "." str_2(SMAXPQ_MINOR_VERSION) \
"." str_2(SMAXPQ_PATCHLEVEL) SMAXPQ_RELEASE_STRING

extern boolean debug; ///< whether to show debug messages
extern XBoolean debug; ///< whether to show debug messages

/**
* A set of properties that determine how an SMA-X variable is logged into the PostgreSQL DB.
*/
typedef struct {
boolean force; ///< Whether the variable should be logged no matter what other settings.
boolean exclude; ///< Whether to exclude this variable from logging
XBoolean force; ///< Whether the variable should be logged no matter what other settings.
XBoolean exclude; ///< Whether to exclude this variable from logging
int sampling; ///< sampling step for array data (sampling every n values only)
} logger_properties;

Expand Down Expand Up @@ -150,8 +150,8 @@ int setSQLUserName(const char *name);
const char *getSQLAuth();
int setSQLAuth(const char *passwd);

boolean isUseHyperTables();
void setUseHyperTables(boolean value);
XBoolean isUseHyperTables();
void setUseHyperTables(XBoolean value);

int getUpdateInterval();
int getSnapshotInterval();
Expand Down
8 changes: 4 additions & 4 deletions src/logger-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static char *sqlServer;
static char *dbName;
static char *dbUser;
static char *dbAuth;
static boolean use_hyper_tables = FALSE;
static XBoolean use_hyper_tables = FALSE;

static int update_interval = MINUTE; ///< (s) The rate of fast updates for changing variables (min. 1m).
static int snapshot_interval = MINUTE; ///< (s) The rate of snapshotting all variables (min. 1m).
Expand Down Expand Up @@ -426,7 +426,7 @@ logger_properties *getLogProperties(const char *id) {
* @param updateTime (s) UNIX timestamp when the variable was last updated in the SMA-X database.
* @return TRUE (1) if the variable should be logged into the SQL database, or else FALSE (0)
*/
boolean isLogging(const char *id, double updateTime) {
XBoolean isLogging(const char *id, double updateTime) {
const logger_properties *p;
const time_t now = time(NULL);

Expand Down Expand Up @@ -614,7 +614,7 @@ int setSQLAuth(const char *passwd) {
*
* @sa setUseHyperTables()
*/
boolean isUseHyperTables() {
XBoolean isUseHyperTables() {
return use_hyper_tables;
}

Expand All @@ -626,7 +626,7 @@ boolean isUseHyperTables() {
*
* @sa isUseHyperTables()
*/
void setUseHyperTables(boolean value) {
void setUseHyperTables(XBoolean value) {
use_hyper_tables = (value != 0);
}

Expand Down
17 changes: 11 additions & 6 deletions src/postgres-backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ typedef struct {
int cols; ///< Number of array elements (columns)
char sqlType[SQL_TYPE_LEN]; ///< The SQL storage type

boolean hasMeta; ///< (boolean) if we have metadata available
XBoolean hasMeta; ///< (boolean) if we have metadata available
int metaVersion; ///< metadata serial number
int sampling; ///< the current sampling interval for array data
int ndim; ///< array dimensions (may be 0 for scalars)
Expand Down Expand Up @@ -620,7 +620,7 @@ static size_t appendValue(const void *data, XType type, char *dst, size_t len) {

switch (type) {

case X_BOOLEAN: return pos + x_snprintf(dst, len - pos, "%s",*(boolean *) data ? "true" : "false");
case X_BOOLEAN: return pos + x_snprintf(dst, len - pos, "%s",*(XBoolean *) data ? "true" : "false");

case X_BYTE: return pos + x_snprintf(dst, len - pos, "%hhd", *(char *) data);

Expand Down Expand Up @@ -1010,6 +1010,7 @@ static int sqlCreateMetaTable(int id) {
static int sqlAddMeta(const Variable *u, TableDescriptor *t) {
const XField *f = &u->field;
size_t l = 0;
struct tm tm = {};
int step, ndim;

if(!u || !t) {
Expand All @@ -1028,7 +1029,8 @@ static int sqlAddMeta(const Variable *u, TableDescriptor *t) {
ensureCommandCapacity(200 + META_SHAPE_LEN + META_UNIT_LEN);
l += x_snprintf(&cmd[l], cmdSize - l, "INSERT INTO " META_NAME_PATTERN " VALUES(DEFAULT" SQL_SEP, t->index);

l += strftime(&cmd[l], cmdSize - l, SQL_DATE_FORMAT, gmtime(&u->updateTime));
gmtime_r(&u->updateTime, &tm);
l += strftime(&cmd[l], cmdSize - l, SQL_DATE_FORMAT, &tm);

l += x_snprintf(&cmd[l], cmdSize - l, SQL_SEP "%d", step);
l += x_snprintf(&cmd[l], cmdSize - l, SQL_SEP "%d", ndim);
Expand Down Expand Up @@ -1108,7 +1110,7 @@ static int sqlGetLastMeta(TableDescriptor *t) {
}


static boolean isMetaUpdate(const Variable *u, const TableDescriptor *t) {
static XBoolean isMetaUpdate(const Variable *u, const TableDescriptor *t) {
const XField *f = &u->field;
int i;
int ndim = f->ndim;
Expand Down Expand Up @@ -1460,6 +1462,7 @@ static int sqlAddValues(const Variable *u) {
TableDescriptor *t;
int len;
size_t pos = 0;
struct tm tm = {};
char sqlType[SQL_TYPE_LEN];

if(!u) {
Expand Down Expand Up @@ -1511,9 +1514,11 @@ static int sqlAddValues(const Variable *u) {

ensureCommandCapacity(200 + SQL_TABLE_NAME_LEN + getSampleCount(u) * len);

gmtime_r(&u->grabTime, &tm);

/* Now insert the data */
pos += x_snprintf(&cmd[pos], cmdSize - pos, "INSERT INTO " TABLE_NAME_PATTERN " VALUES(", t->index);
pos += strftime(&cmd[pos], cmdSize - pos, SQL_DATE_FORMAT, gmtime(&u->grabTime));
pos += strftime(&cmd[pos], cmdSize - pos, SQL_DATE_FORMAT, &tm);
pos += x_snprintf(&cmd[pos], cmdSize - pos, SQL_SEP "'%d'", (int) (u->grabTime - u->updateTime));
pos += appendValues(u, &cmd[pos], cmdSize - pos);

Expand Down Expand Up @@ -1544,7 +1549,7 @@ static int sqlAddValues(const Variable *u) {
}


static boolean sqlDeleteVar(const char *id) {
static XBoolean sqlDeleteVar(const char *id) {
int tid, n = 0;

if(!id) return FALSE;
Expand Down
10 changes: 5 additions & 5 deletions src/smax-collector.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static void *GrabberThread(void *arg);
* @return X_SUCCESS (0) if successful or else an error code (<0).
*/
int initCollector() {
static boolean warned;
static XBoolean warned;

int i, status;

Expand Down Expand Up @@ -185,12 +185,12 @@ static void DestroyEntries(RedisEntry *entries, int n) {
* @return TRUE (1) if successfully queued a DB update for the variable, or else FALSE (0; errno may be
* set to indicate the type of error -- if any).
*/
static boolean SubmitUpdate(Update *u) {
static XBoolean SubmitUpdate(Update *u) {
const XMeta *m;
const logger_properties *p;
Variable *v;
XField *f;
boolean force = FALSE;
XBoolean force = FALSE;

if(!u || !u->var) {
errno = EINVAL;
Expand Down Expand Up @@ -546,7 +546,7 @@ static double GetServerTime() {
* perform an incremental update of the variable that have changed since last time.
* @return X_SUCCESS (0) or else an error code (<0)
*/
static int Grab(VarGroup *group, const time_t grabTime, boolean isSnapshot) {
static int Grab(VarGroup *group, const time_t grabTime, XBoolean isSnapshot) {
double t = GetServerTime();
int status;

Expand Down Expand Up @@ -594,7 +594,7 @@ static void *GrabberThread(void *arg) {

for(;;) {
time_t target = SleepToRound(getUpdateInterval());
boolean isSnapshot = FALSE;
XBoolean isSnapshot = FALSE;
int i;

if(getSnapshotInterval() > 0) isSnapshot = (target % getSnapshotInterval() < getUpdateInterval());
Expand Down
4 changes: 2 additions & 2 deletions src/smax-postgres.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "smax-postgres.h"

boolean debug = FALSE;
XBoolean debug = FALSE;


static void *CleanupThread(void *arg) {
Expand Down Expand Up @@ -66,7 +66,7 @@ int main(int argc, const char *argv[]) {
char *configFile = SMAXPQ_DEFAULT_CONFIG;
char *owner = "postgres";
char *ownerPasswd = NULL;
boolean bootstrap = FALSE, version = FALSE;
XBoolean bootstrap = FALSE, version = FALSE;
int c;

const struct poptOption options[] = {
Expand Down
Loading