2013-08-02 13:12:24 -07:00
|
|
|
// Gigablast, Inc., Copyright Mar 2007
|
|
|
|
|
2016-03-08 22:14:30 +01:00
|
|
|
#ifndef GB_PROCESS_H
|
|
|
|
#define GB_PROCESS_H
|
2013-08-02 13:12:24 -07:00
|
|
|
|
2016-08-10 00:10:11 +02:00
|
|
|
#include <inttypes.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2013-08-02 13:12:24 -07:00
|
|
|
#define NO_MODE 0
|
|
|
|
#define EXIT_MODE 1
|
|
|
|
#define SAVE_MODE 2
|
|
|
|
#define LOCK_MODE 3
|
|
|
|
|
|
|
|
|
|
|
|
class Process {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2016-05-04 11:10:51 +02:00
|
|
|
bool getFilesToCopy ( const char *srcDir , class SafeBuf *buf ) ;
|
2015-12-08 11:21:06 +01:00
|
|
|
bool checkFiles ( const char *dir );
|
2013-08-02 13:12:24 -07:00
|
|
|
|
|
|
|
// . the big save command
|
|
|
|
// . does not save everything, just the important stuff
|
|
|
|
bool save ( );
|
|
|
|
|
|
|
|
// . this will save everything and exit
|
|
|
|
// . urgent is true if we cored
|
2015-12-18 10:48:00 +01:00
|
|
|
bool shutdown ( bool urgent, void *state = NULL, void (*callback) (void *state ) = NULL);
|
|
|
|
|
2015-12-18 11:47:42 +01:00
|
|
|
static const char *getAbortFileName() {
|
|
|
|
return "./fatal_error";
|
|
|
|
}
|
|
|
|
|
2015-12-18 10:48:00 +01:00
|
|
|
/**
|
|
|
|
* Abort process
|
|
|
|
*
|
|
|
|
* @param save_on_abort Save data to disk on abort
|
|
|
|
*/
|
2016-05-11 16:49:47 +02:00
|
|
|
[[ noreturn ]] void shutdownAbort ( bool save_on_abort = false );
|
2013-08-02 13:12:24 -07:00
|
|
|
|
|
|
|
bool checkNTPD();
|
|
|
|
|
|
|
|
Process ( ) ;
|
|
|
|
bool init ( ) ;
|
2013-10-30 13:12:46 -07:00
|
|
|
bool isAnyTreeSaving ( ) ;
|
2013-08-02 13:12:24 -07:00
|
|
|
bool save2 ( ) ;
|
|
|
|
bool shutdown2 ( ) ;
|
2015-02-11 21:54:36 -08:00
|
|
|
void disableTreeWrites ( bool shuttingDown ) ;
|
|
|
|
void enableTreeWrites ( bool shuttingDown ) ;
|
2013-08-02 13:12:24 -07:00
|
|
|
bool isRdbDumping ( ) ;
|
|
|
|
bool isRdbMerging ( ) ;
|
2016-08-22 16:35:27 +02:00
|
|
|
bool saveRdbTrees(bool useThread, bool shuttingDown);
|
|
|
|
bool saveRdbIndexes();
|
2015-12-18 15:19:24 +01:00
|
|
|
bool saveRdbMaps();
|
2013-08-02 13:12:24 -07:00
|
|
|
bool saveBlockingFiles1 ( ) ;
|
|
|
|
bool saveBlockingFiles2 ( ) ;
|
|
|
|
void resetAll ( ) ;
|
|
|
|
void resetPageCaches ( ) ;
|
|
|
|
double getLoadAvg ( );
|
|
|
|
|
2014-10-30 13:36:39 -06:00
|
|
|
int64_t getTotalDocsIndexed();
|
|
|
|
int64_t m_totalDocsIndexed;
|
2014-02-25 12:14:51 -08:00
|
|
|
|
2013-08-02 13:12:24 -07:00
|
|
|
class Rdb *m_rdbs[32];
|
2014-11-10 14:45:11 -08:00
|
|
|
int32_t m_numRdbs;
|
2013-08-02 13:12:24 -07:00
|
|
|
bool m_urgent;
|
|
|
|
char m_mode;
|
2014-10-30 13:36:39 -06:00
|
|
|
int64_t m_lastSaveTime;
|
|
|
|
int64_t m_processStartTime;
|
2013-08-02 13:12:24 -07:00
|
|
|
bool m_sentShutdownNote;
|
|
|
|
bool m_blockersNeedSave;
|
|
|
|
bool m_repairNeedsSave;
|
2014-11-10 14:45:11 -08:00
|
|
|
int32_t m_try;
|
2014-10-30 13:36:39 -06:00
|
|
|
int64_t m_firstShutdownTime;
|
2013-08-02 13:12:24 -07:00
|
|
|
|
|
|
|
void *m_callbackState;
|
|
|
|
void (*m_callback) (void *state);
|
|
|
|
|
|
|
|
// a timestamp for the sig alarm handler in Loop.cpp
|
2014-10-30 13:36:39 -06:00
|
|
|
int64_t m_lastHeartbeatApprox;
|
2013-08-02 13:12:24 -07:00
|
|
|
|
|
|
|
void callHeartbeat ();
|
|
|
|
|
|
|
|
bool m_suspendAutoSave;
|
|
|
|
|
|
|
|
bool m_powerIsOn;
|
2014-10-30 13:36:39 -06:00
|
|
|
int64_t m_powerOffTime;
|
2013-08-02 13:12:24 -07:00
|
|
|
bool m_exiting;
|
|
|
|
bool m_calledSave;
|
|
|
|
|
2014-02-12 09:47:44 -07:00
|
|
|
float m_diskUsage;
|
2014-10-30 13:36:39 -06:00
|
|
|
int64_t m_diskAvail;
|
2013-08-02 13:12:24 -07:00
|
|
|
};
|
|
|
|
|
2016-07-26 23:01:14 +02:00
|
|
|
extern bool g_inAutoSave;
|
2013-08-02 13:12:24 -07:00
|
|
|
extern Process g_process;
|
|
|
|
|
2016-03-08 22:14:30 +01:00
|
|
|
#endif // GB_PROCESS_H
|