| 1 | /* |
| 2 | * This Source Code Form is subject to the terms of the Mozilla Public |
| 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 5 | * |
| 6 | * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V. |
| 7 | */ |
| 8 | |
| 9 | #ifndef _SEEN_SABAOTH_H |
| 10 | #define _SEEN_SABAOTH_H 1 |
| 11 | |
| 12 | typedef struct Ssablist { |
| 13 | char *val; /* list value */ |
| 14 | struct Ssablist* next; /* pointer to the next available value*/ |
| 15 | } sablist; |
| 16 | |
| 17 | /* only append to this enum, as its numbers are used in |
| 18 | * serialise/deserialise */ |
| 19 | typedef enum { |
| 20 | SABdbIllegal = 0, |
| 21 | SABdbRunning, |
| 22 | SABdbCrashed, |
| 23 | SABdbInactive, |
| 24 | SABdbStarting |
| 25 | } SABdbState; |
| 26 | |
| 27 | typedef struct Ssabdb { |
| 28 | char *dbname; /* database name */ |
| 29 | char *path; /* path to this database */ |
| 30 | bool locked; /* whether this database is under maintenance */ |
| 31 | SABdbState state; /* current database state */ |
| 32 | sablist* scens; /* scenarios available for this database */ |
| 33 | sablist* conns; /* connections available for this database */ |
| 34 | struct Ssabuplog *uplog; /* sabuplog struct for this database */ |
| 35 | char *uri; /* URI to connect to this database */ |
| 36 | struct Ssabdb* next; /* next database */ |
| 37 | } sabdb; |
| 38 | |
| 39 | typedef struct Ssabuplog { |
| 40 | int startcntr; /* the number of start attempts */ |
| 41 | int stopcntr; /* the number of successful stop attempts */ |
| 42 | int crashcntr; /* startcntr - stopcntr (for convenience) */ |
| 43 | time_t avguptime; /* number of seconds up when not crashing */ |
| 44 | time_t maxuptime; /* longest uptime when not crashing */ |
| 45 | time_t minuptime; /* shortest uptime when not crashing */ |
| 46 | time_t lastcrash; /* time of last crash, -1 if none */ |
| 47 | time_t laststart; /* time of last start */ |
| 48 | time_t laststop; /* time of last stop, -1 if running */ |
| 49 | int crashavg1; /* if there was a crash in the last start attempt */ |
| 50 | double crashavg10; /* average of crashes in the last 10 start attempts */ |
| 51 | double crashavg30; /* average of crashes in the last 30 start attempts */ |
| 52 | } sabuplog; |
| 53 | |
| 54 | #ifdef WIN32 |
| 55 | #if !defined(LIBMAL) && !defined(LIBATOMS) && !defined(LIBKERNEL) && !defined(LIBMAL) && !defined(LIBOPTIMIZER) && !defined(LIBSCHEDULER) && !defined(LIBMONETDB5) && !defined(LIBMSABAOTH) |
| 56 | #define msab_export extern __declspec(dllimport) |
| 57 | #else |
| 58 | #define msab_export extern __declspec(dllexport) |
| 59 | #endif |
| 60 | #else |
| 61 | #define msab_export extern |
| 62 | #endif |
| 63 | |
| 64 | msab_export void msab_dbpathinit(const char *dbpath); |
| 65 | msab_export void msab_dbfarminit(const char *dbfarm); |
| 66 | msab_export char *msab_getDBfarm(char **ret); |
| 67 | msab_export char *msab_getDBname(char **ret); |
| 68 | msab_export char *msab_getUUID(char **ret); |
| 69 | msab_export char *msab_marchScenario(const char *lang); |
| 70 | msab_export char *msab_retreatScenario(const char *lang); |
| 71 | msab_export char *msab_marchConnection(const char *host, const int port); |
| 72 | msab_export char *msab_wildRetreat(void); |
| 73 | msab_export char *msab_registerStarting(void); |
| 74 | msab_export char *msab_registerStarted(void); |
| 75 | msab_export char *msab_registerStop(void); |
| 76 | msab_export char *msab_getMyStatus(sabdb** ret); |
| 77 | msab_export char *msab_getStatus(sabdb** ret, char *dbname); |
| 78 | msab_export void msab_freeStatus(sabdb** ret); |
| 79 | msab_export char *msab_getUplogInfo(sabuplog *ret, const sabdb *db); |
| 80 | msab_export char *msab_serialise(char **ret, const sabdb *db); |
| 81 | msab_export char *msab_deserialise(sabdb **ret, char *sabdb); |
| 82 | |
| 83 | #endif |
| 84 | |