privacore-open-source-searc.../Process.h

95 lines
2.0 KiB
C
Raw Normal View History

2013-08-02 16:12:24 -04:00
// Gigablast, Inc., Copyright Mar 2007
2016-03-08 16:14:30 -05:00
#ifndef GB_PROCESS_H
#define GB_PROCESS_H
2013-08-02 16:12:24 -04:00
#include <inttypes.h>
#include <stddef.h>
2017-04-21 06:44:35 -04:00
#include <atomic>
2013-08-02 16:12:24 -04:00
class Process {
public:
2016-05-04 05:10:51 -04:00
bool getFilesToCopy ( const char *srcDir , class SafeBuf *buf ) ;
bool checkFiles ( const char *dir );
2013-08-02 16:12:24 -04: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
bool shutdown ( bool urgent, void *state = NULL, void (*callback) (void *state ) = NULL);
2015-12-18 05:47:42 -05:00
static const char *getAbortFileName() {
return "./fatal_error";
}
/**
* Abort process
*
* @param save_on_abort Save data to disk on abort
*/
2016-05-11 10:49:47 -04:00
[[ noreturn ]] void shutdownAbort ( bool save_on_abort = false );
2013-08-02 16:12:24 -04:00
bool checkNTPD();
Process ( ) ;
bool init ( ) ;
bool isAnyTreeSaving ( ) ;
2013-08-02 16:12:24 -04:00
bool save2 ( ) ;
bool shutdown2 ( ) ;
bool isShuttingDown() const { return m_mode == EXIT_MODE; }
2013-08-02 16:12:24 -04:00
bool isRdbDumping ( ) ;
bool isRdbMerging ( ) ;
bool saveRdbTrees(bool shuttingDown);
bool saveRdbIndexes();
bool saveRdbMaps();
2013-08-02 16:12:24 -04:00
bool saveBlockingFiles1 ( ) ;
bool saveBlockingFiles2 ( ) ;
void resetAll ( ) ;
void resetPageCaches ( ) ;
double getLoadAvg ( );
2014-10-30 15:36:39 -04:00
int64_t getTotalDocsIndexed();
int64_t m_totalDocsIndexed;
2013-08-02 16:12:24 -04:00
class Rdb *m_rdbs[32];
2014-11-10 17:45:11 -05:00
int32_t m_numRdbs;
2013-08-02 16:12:24 -04:00
bool m_urgent;
2017-04-21 06:44:35 -04:00
enum ProcessMode {
2016-10-31 06:51:56 -04:00
NO_MODE = 0,
EXIT_MODE = 1,
SAVE_MODE = 2,
LOCK_MODE = 3
2017-04-21 06:44:35 -04:00
};
std::atomic<ProcessMode> m_mode;
2014-10-30 15:36:39 -04:00
int64_t m_lastSaveTime;
int64_t m_processStartTime;
2013-08-02 16:12:24 -04:00
bool m_sentShutdownNote;
bool m_blockersNeedSave;
bool m_repairNeedsSave;
2014-11-10 17:45:11 -05:00
int32_t m_try;
2014-10-30 15:36:39 -04:00
int64_t m_firstShutdownTime;
2013-08-02 16:12:24 -04:00
void *m_callbackState;
void (*m_callback) (void *state);
// a timestamp for the sig alarm handler in Loop.cpp
2014-10-30 15:36:39 -04:00
int64_t m_lastHeartbeatApprox;
2013-08-02 16:12:24 -04:00
bool m_suspendAutoSave;
bool m_exiting;
bool m_calledSave;
};
extern bool g_inAutoSave;
2013-08-02 16:12:24 -04:00
extern Process g_process;
2016-03-08 16:14:30 -05:00
#endif // GB_PROCESS_H