~drizzle-trunk/drizzle/development

1999.6.1 by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file
1
/* Copyright (C) 2008 PrimeBase Technologies GmbH, Germany
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
2
 *
3
 * PrimeBase Media Stream for MySQL
4
 *
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.
9
 *
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.
14
 *
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
1802.10.2 by Monty Taylor
Update all of the copyright headers to include the correct address.
17
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
18
 *
19
 * Original author: Paul McCullagh
20
 * Continued development: Barry Leslie
21
 *
22
 * 2007-07-03
23
 *
24
 * H&G2JCtL
25
 *
26
 * Temporary BLOB log.
27
 *
28
 * Temporary BLOBs are BLOBs that are to be deleted after an certain
29
 * expiry time.
30
 *
31
 * The temporary log is also used to schedule asynchronous operations to be performed
32
 * on the BLOB such as uploading it to a cloud.
33
 *
34
 * Temporary BLOBs are referenced by the temporary log.
35
 */
36
37
#ifndef __TEMPLOG_MS_H__
38
#define __TEMPLOG_MS_H__
39
1548.2.2 by Barry.Leslie at PrimeBase
A lot of minor changes to clean up the code and to get it to build with Drizzle.
40
#include "cslib/CSDefs.h"
41
#include "cslib/CSFile.h"
42
#include "cslib/CSStream.h"
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
43
1841.1.3 by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger
44
#include "defs_ms.h"
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
45
46
class MSOpenTable;
47
class MSDatabase;
48
class MSTempLog;
49
50
// Change history:
51
// April 6 2009:
52
// Changed MS_TEMP_LOG_MAGIC and MS_TEMP_LOG_VERSION
53
// when the disk size of ti_type_1 was changed from
54
// CSDiskValue4 to CSDiskValue1.
55
56
#define MS_TEMP_LOG_MAGIC			0xF9E6D7C9
57
#define MS_TEMP_LOG_VERSION			3
58
#define MS_TEMP_LOG_HEAD_SIZE		32
59
60
#define MS_TL_BLOB_REF				1
61
#define MS_TL_REPO_REF				2		
62
#define MS_TL_TABLE_REF				3
63
64
typedef struct MSTempLogHead {
65
	CSDiskValue4			th_magic_4;							/* Table magic number. */
66
	CSDiskValue2			th_version_2;						/* The header version. */
67
	CSDiskValue2			th_head_size_2;						/* The size of the header. */
68
	CSDiskValue2			th_rec_size_2;						/* The size of a temp log record. */
69
	CSDiskValue4			th_reserved_4;
70
} MSTempLogHeadRec, *MSTempLogHeadPtr;
71
72
typedef struct MSTempLogItem {
73
	CSDiskValue1			ti_type_1;							/* 1 = BLOB reference, 2 = Repository reference, 3 = Table reference */
74
	CSDiskValue4			ti_table_id_4;						/* Table ID (non-zero if valid). */
75
	CSDiskValue6			ti_blob_id_6;						/* Blob ID (non-zero if valid). */
76
	CSDiskValue4			ti_auth_code_4;						/* To make sure we do not delete the wrong thing. */
77
	CSDiskValue4			ti_time_4;							/* The time of deletion/creation */
78
} MSTempLogItemRec, *MSTempLogItemPtr;
79
80
class MSTempLogFile : public CSReadBufferedFile {
81
public:
1548.2.2 by Barry.Leslie at PrimeBase
A lot of minor changes to clean up the code and to get it to build with Drizzle.
82
	uint32_t		myTempLogID;
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
83
	MSTempLog	*myTempLog;
84
85
	MSTempLogFile();
86
	~MSTempLogFile();
87
88
	friend class MSTempLog;
89
90
private:
1548.2.2 by Barry.Leslie at PrimeBase
A lot of minor changes to clean up the code and to get it to build with Drizzle.
91
	static MSTempLogFile *newTempLogFile(uint32_t id, MSTempLog *temp_log, CSFile *path);
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
92
};
93
94
class MSTempLog : public CSRefObject {
95
public:
1548.2.2 by Barry.Leslie at PrimeBase
A lot of minor changes to clean up the code and to get it to build with Drizzle.
96
	uint32_t		myLogID;
97
	off64_t		myTempLogSize;
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
98
	int			myTemplogRecSize;
99
	size_t		myTempLogHeadSize;
100
1548.2.2 by Barry.Leslie at PrimeBase
A lot of minor changes to clean up the code and to get it to build with Drizzle.
101
	MSTempLog(uint32_t id, MSDatabase *db, off64_t file_size);
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
102
	virtual ~MSTempLog();
103
104
	void deleteLog();
105
	CSPath *getLogPath();
106
	MSTempLogFile *openTempLog();
107
	
108
#ifdef DEBUG
109
//	virtual void retain() {
110
//		CSRefObject::retain();
111
//		printf("MSTempLog retained %d\n", iRefCount);
112
//	}
113
//
114
//	virtual void release() {
115
//		printf("MSTempLog released %d\n", iRefCount);
116
//		CSRefObject::release();
117
//	}
118
#endif
119
120
	friend class MSTempLogThread;
121
122
private:
123
	MSDatabase		*iLogDatabase;
124
	bool			iDeleteLog;
125
126
public:
127
128
	static time_t adjustWaitTime(time_t then, time_t now);
129
};
130
131
class MSTempLogThread : public CSDaemon {
132
public:
133
	MSTempLogThread(time_t wait_time, MSDatabase *db);
1548.2.11 by Barry.Leslie at PrimeBase
Removed libxml reqirement by using a home grown xml parser.
134
	virtual ~MSTempLogThread(){} // Do nothing here because 'self' will no longer be valid, use completeWork().
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
135
136
	void close();
137
138
	virtual bool doWork();
139
1548.2.11 by Barry.Leslie at PrimeBase
Removed libxml reqirement by using a home grown xml parser.
140
	virtual void *completeWork();
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
141
142
private:
1841.1.3 by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger
143
	bool try_ReleaseBLOBReference(CSThread *self, CSStringBuffer *buffer, uint32_t tab_id, int type, uint64_t blob_id, uint32_t auth_code);
144
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
145
	MSDatabase			*iTempLogDatabase;
146
	MSTempLogFile		*iTempLogFile;
147
	size_t				iLogRecSize;
1548.2.2 by Barry.Leslie at PrimeBase
A lot of minor changes to clean up the code and to get it to build with Drizzle.
148
	off64_t				iLogOffset;
1548.2.1 by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin.
149
	
150
};
151
152
#endif