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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
37
class MSBackupInfo : public CSRefObject {
38
friend class StartDumpCleanUp;
39
friend class InsertRowCleanUp;
42
static uint32_t gMaxInfoRef;
43
static CSSyncSparseArray *gBackupInfo;
45
friend class MSBackupTable;
46
friend class MSBackup;
53
time_t completionTime;
56
CSString *backupLocation;
58
uint32_t cloudBackupNo;
64
new_(gBackupInfo, CSSyncSparseArray(5));
68
static void shutDown()
72
gBackupInfo->release();
78
static MSBackupInfo *findBackupInfo(uint32_t in_backupRefId)
85
info = (MSBackupInfo *) gBackupInfo->get(in_backupRefId);
92
static MSBackupInfo *getBackupInfo(uint32_t in_backupRefId)
94
MSBackupInfo *info = findBackupInfo(in_backupRefId);
98
snprintf(msg, 80, "Backup info with reference ID %"PRIu32" not found", in_backupRefId);
99
CSException::throwException(CS_CONTEXT, CS_ERR_GENERIC_ERROR, msg);
106
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 );
109
uint32_t getBackupRefId() { return backupRefId;}
111
const char *getName(){ return db_name->getCString(); }
113
uint32_t getDatabaseId() { return db_id;}
115
time_t getStart(){ return startTime;}
117
time_t getEnd(){ return completionTime;}
119
bool isDump(){ return dump;}
121
bool isBackupRunning(){ return isRunning;}
123
const char *getLocation() { return (backupLocation)?backupLocation->getCString():NULL; }
125
uint32_t getcloudRef(){ return cloudRef;}
126
void setcloudRef(uint32_t no){ cloudRef = no;}
128
uint32_t getcloudBackupNo(){ return cloudBackupNo;}
129
void setcloudBackupNo(uint32_t no){ cloudBackupNo = no;}
131
static MSBackupInfo *startDump(MSDatabase *db, uint32_t cloud_ref, uint32_t backup_no);
133
void startBackup(MSDatabase *pbms_db);
134
void backupCompleted(MSDatabase *db);
135
void backupTerminated(MSDatabase *db);
140
class MSOpenSystemTable;
142
class MSBackup :public CSDaemon {
147
~MSBackup(){} // Do nothing here because 'self' will no longer be valid, use completeWork().
149
virtual bool doWork();
151
virtual void *completeWork();
153
void startBackup(MSDatabase *src_db);
154
uint64_t getBackupSize() { return bu_size;}
155
uint64_t getBackupCompletedSize() { return bu_completed;}
156
bool isRunning() { return bu_BackupRunning;}
157
int getStatus() { return (bu_BackupRunning)?0:bu_State;}
158
uint32_t backupID() { return bu_ID;}
160
static MSBackup* newMSBackup(MSBackupInfo *backup_info);
162
friend class StartBackupCleanUp;
164
void completeBackup();
166
MSBackupInfo *bu_info;
168
CSVector *bu_BackupList;
169
CSDaemon *bu_Compactor;
170
bool bu_BackupRunning;
171
enum {BU_RUNNING = -1, BU_COMPLETED = 0, BU_TERMINATED = 1} bu_State;
173
MSDatabase *bu_SourceDatabase; // The source database.
174
MSDatabase *bu_Database; // The destination database.
175
MSOpenSystemTable *bu_dst_dump; // The source database's pbms_dump.
176
MSOpenSystemTable *bu_src_dump; // The source database's pbms_dump.
177
uint64_t bu_size; // The total size of the data to be backed up.
178
uint64_t bu_completed; // The amount of data that has been backed up so far.
181
uint32_t bu_start_time;
183
bool bu_TransactionManagerSuspended;
186
#endif // _BACKUP_MS_H_