1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
// --------------------------------------------------------------------------
//
// File
// Name: BackupStoreDaemon.h
// Purpose: Backup store daemon
// Created: 2003/08/20
//
// --------------------------------------------------------------------------
#ifndef BACKUPSTOREDAEMON__H
#define BACKUPSTOREDAEMON__H
#include "ServerTLS.h"
#include "BoxPortsAndFiles.h"
#include "BackupConstants.h"
#include "BackupStoreContext.h"
#include "HousekeepStoreAccount.h"
#include "IOStreamGetLine.h"
class BackupStoreAccounts;
class BackupStoreAccountDatabase;
// --------------------------------------------------------------------------
//
// Class
// Name: BackupStoreDaemon
// Purpose: Backup store daemon implementation
// Created: 2003/08/20
//
// --------------------------------------------------------------------------
class BackupStoreDaemon : public ServerTLS<BOX_PORT_BBSTORED>,
HousekeepingInterface, HousekeepingCallback
{
public:
BackupStoreDaemon();
~BackupStoreDaemon();
private:
BackupStoreDaemon(const BackupStoreDaemon &rToCopy);
public:
// For BackupStoreContext to communicate with housekeeping process
void SendMessageToHousekeepingProcess(const void *Msg, int MsgLen)
{
#ifndef WIN32
mInterProcessCommsSocket.Write(Msg, MsgLen);
#endif
}
protected:
virtual void SetupInInitialProcess();
virtual void Run();
virtual void Connection(std::auto_ptr<SocketStreamTLS> apStream);
void Connection2(std::auto_ptr<SocketStreamTLS> apStream);
virtual const char *DaemonName() const;
virtual std::string DaemonBanner() const;
const ConfigurationVerify *GetConfigVerify() const;
// Housekeeping functions
void HousekeepingProcess();
void LogConnectionStats(uint32_t accountId,
const std::string& accountName, const BackupProtocolServer &server);
public:
// HousekeepingInterface implementation
virtual bool CheckForInterProcessMsg(int AccountNum = 0, int MaximumWaitTime = 0);
void RunHousekeepingIfNeeded();
private:
BackupStoreAccountDatabase *mpAccountDatabase;
BackupStoreAccounts *mpAccounts;
bool mExtendedLogging;
bool mHaveForkedHousekeeping;
bool mIsHousekeepingProcess;
bool mHousekeepingInited;
SocketStream mInterProcessCommsSocket;
IOStreamGetLine mInterProcessComms;
virtual void OnIdle();
void HousekeepingInit();
int64_t mLastHousekeepingRun;
public:
void SetTestHook(BackupStoreContext::TestHook& rTestHook)
{
mpTestHook = &rTestHook;
}
private:
BackupStoreContext::TestHook* mpTestHook;
};
#endif // BACKUPSTOREDAEMON__H
|