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
36
class MSBackupInfo : public CSRefObject {
37
friend class StartDumpCleanUp;
38
friend class InsertRowCleanUp;
41
static uint32_t gMaxInfoRef;
42
static CSSyncSparseArray *gBackupInfo;
44
friend class MSBackupTable;
45
friend class MSBackup;
52
time_t completionTime;
55
CSString *backupLocation;
57
uint32_t cloudBackupNo;
63
new_(gBackupInfo, CSSyncSparseArray(5));
67
static void shutDown()
71
gBackupInfo->release();
77
static MSBackupInfo *findBackupInfo(uint32_t in_backupRefId)
84
info = (MSBackupInfo *) gBackupInfo->get(in_backupRefId);
91
static MSBackupInfo *getBackupInfo(uint32_t in_backupRefId)
93
MSBackupInfo *info = findBackupInfo(in_backupRefId);
97
snprintf(msg, 80, "Backup info with reference ID %"PRIu32" not found", in_backupRefId);
98
CSException::throwException(CS_CONTEXT, CS_ERR_GENERIC_ERROR, msg);
105
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 );
108
uint32_t getBackupRefId() { return backupRefId;}
110
const char *getName(){ return db_name->getCString(); }
112
uint32_t getDatabaseId() { return db_id;}
114
time_t getStart(){ return startTime;}
116
time_t getEnd(){ return completionTime;}
118
bool isDump(){ return dump;}
120
bool isBackupRunning(){ return isRunning;}
122
const char *getLocation() { return (backupLocation)?backupLocation->getCString():NULL; }
124
uint32_t getcloudRef(){ return cloudRef;}
125
void setcloudRef(uint32_t no){ cloudRef = no;}
127
uint32_t getcloudBackupNo(){ return cloudBackupNo;}
128
void setcloudBackupNo(uint32_t no){ cloudBackupNo = no;}
130
static MSBackupInfo *startDump(MSDatabase *db, uint32_t cloud_ref, uint32_t backup_no);
132
void startBackup(MSDatabase *pbms_db);
133
void backupCompleted(MSDatabase *db);
134
void backupTerminated(MSDatabase *db);
139
class MSOpenSystemTable;
141
class MSBackup :public CSDaemon {
146
~MSBackup(){} // Do nothing here because 'self' will no longer be valid, use completeWork().
148
virtual bool doWork();
150
virtual void *completeWork();
152
void startBackup(MSDatabase *src_db);
153
uint64_t getBackupSize() { return bu_size;}
154
uint64_t getBackupCompletedSize() { return bu_completed;}
155
bool isRunning() { return bu_BackupRunning;}
156
int getStatus() { return (bu_BackupRunning)?0:bu_State;}
157
uint32_t backupID() { return bu_ID;}
159
static MSBackup* newMSBackup(MSBackupInfo *backup_info);
161
friend class StartBackupCleanUp;
163
void completeBackup();
165
MSBackupInfo *bu_info;
167
CSVector *bu_BackupList;
168
CSDaemon *bu_Compactor;
169
bool bu_BackupRunning;
170
enum {BU_RUNNING = -1, BU_COMPLETED = 0, BU_TERMINATED = 1} bu_State;
172
MSDatabase *bu_SourceDatabase; // The source database.
173
MSDatabase *bu_Database; // The destination database.
174
MSOpenSystemTable *bu_dst_dump; // The source database's pbms_dump.
175
MSOpenSystemTable *bu_src_dump; // The source database's pbms_dump.
176
uint64_t bu_size; // The total size of the data to be backed up.
177
uint64_t bu_completed; // The amount of data that has been backed up so far.
180
uint32_t bu_start_time;
182
bool bu_TransactionManagerSuspended;
185
#endif // _BACKUP_MS_H_