1
/* Copyright (c) 2009 PrimeBase Technologies GmbH, Germany
3
* PrimeBase Media Stream for MySQL
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
36
class MSBackupInfo : public CSRefObject {
38
static uint32_t gMaxInfoRef;
39
static CSSyncSparseArray *gBackupInfo;
41
friend class MSBackupTable;
42
friend class MSBackup;
49
time_t completionTime;
52
CSString *backupLocation;
54
uint32_t cloudBackupNo;
60
new_(gBackupInfo, CSSyncSparseArray(5));
64
static void shutDown()
68
gBackupInfo->release();
74
static MSBackupInfo *findBackupInfo(uint32_t backupRefId)
81
info = (MSBackupInfo *) gBackupInfo->get(backupRefId);
88
static MSBackupInfo *getBackupInfo(uint32_t backupRefId)
90
MSBackupInfo *info = findBackupInfo(backupRefId);
94
snprintf(msg, 80, "Backup info with reference ID %"PRIu32" not found", backupRefId);
95
CSException::throwException(CS_CONTEXT, CS_ERR_GENERIC_ERROR, msg);
102
MSBackupInfo(uint32_t id, const char *name, uint32_t db_id, time_t start, time_t end, bool isDump, const char *location, uint32_t cloudRef_arg, uint32_t cloudBackupNo_arg );
105
uint32_t getBackupRefId() { return backupRefId;}
107
const char *getName(){ return db_name->getCString(); }
109
uint32_t getDatabaseId() { return db_id;}
111
time_t getStart(){ return startTime;}
113
time_t getEnd(){ return completionTime;}
115
bool isDump(){ return dump;}
117
bool isBackupRunning(){ return isRunning;}
119
const char *getLocation() { return (backupLocation)?backupLocation->getCString():NULL; }
121
uint32_t getcloudRef(){ return cloudRef;}
122
void setcloudRef(uint32_t no){ cloudRef = no;}
124
uint32_t getcloudBackupNo(){ return cloudBackupNo;}
125
void setcloudBackupNo(uint32_t no){ cloudBackupNo = no;}
127
static MSBackupInfo *startDump(MSDatabase *db, uint32_t cloud_ref, uint32_t backup_no);
129
void startBackup(MSDatabase *pbms_db);
130
void backupCompleted(MSDatabase *db);
131
void backupTerminated(MSDatabase *db);
136
class MSOpenSystemTable;
138
class MSBackup :public CSDaemon {
145
virtual bool doWork();
147
virtual void *finalize();
149
void startBackup(MSDatabase *src_db);
150
uint64_t getBackupSize() { return bu_size;}
151
uint64_t getBackupCompletedSize() { return bu_completed;}
152
bool isRunning() { return bu_BackupRunning;}
153
int getStatus() { return (bu_BackupRunning)?0:bu_State;}
154
uint32_t backupID() { return bu_ID;}
156
static MSBackup* newMSBackup(MSBackupInfo *backup_info);
159
void completeBackup();
161
MSBackupInfo *bu_info;
163
CSVector *bu_BackupList;
164
CSDaemon *bu_Compactor;
165
bool bu_BackupRunning;
166
enum {BU_RUNNING = -1, BU_COMPLETED = 0, BU_TERMINATED = 1} bu_State;
168
MSDatabase *bu_SourceDatabase; // The source database.
169
MSDatabase *bu_Database; // The destination database.
170
MSOpenSystemTable *bu_dst_dump; // The source database's pbms_dump.
171
MSOpenSystemTable *bu_src_dump; // The source database's pbms_dump.
172
uint64_t bu_size; // The total size of the data to be backed up.
173
uint64_t bu_completed; // The amount of data that has been backed up so far.
176
uint32_t bu_start_time;
178
bool bu_TransactionManagerSuspended;
181
#endif // _BACKUP_MS_H_