~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to plugin/pbms/src/temp_log_ms.h

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-10-02 14:17:48 UTC
  • mfrom: (1.1.1 upstream)
  • mto: (2.1.17 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20101002141748-m6vbfbfjhrw1153e
Tags: 2010.09.1802-1
* New upstream release.
* Removed pid-file argument hack.
* Updated GPL-2 address to be new address.
* Directly copy in drizzledump.1 since debian doesn't have sphinx 1.0 yet.
* Link to jquery from libjs-jquery. Add it as a depend.
* Add drizzled.8 symlink to the install files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 2008 PrimeBase Technologies GmbH, Germany
 
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
 
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
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
 
 
40
#include "cslib/CSDefs.h"
 
41
#include "cslib/CSFile.h"
 
42
#include "cslib/CSStream.h"
 
43
 
 
44
#include "defs_ms.h"
 
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:
 
82
        uint32_t                myTempLogID;
 
83
        MSTempLog       *myTempLog;
 
84
 
 
85
        MSTempLogFile();
 
86
        ~MSTempLogFile();
 
87
 
 
88
        friend class MSTempLog;
 
89
 
 
90
private:
 
91
        static MSTempLogFile *newTempLogFile(uint32_t id, MSTempLog *temp_log, CSFile *path);
 
92
};
 
93
 
 
94
class MSTempLog : public CSRefObject {
 
95
public:
 
96
        uint32_t                myLogID;
 
97
        off64_t         myTempLogSize;
 
98
        int                     myTemplogRecSize;
 
99
        size_t          myTempLogHeadSize;
 
100
 
 
101
        MSTempLog(uint32_t id, MSDatabase *db, off64_t file_size);
 
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);
 
134
        virtual ~MSTempLogThread(){} // Do nothing here because 'self' will no longer be valid, use completeWork().
 
135
 
 
136
        void close();
 
137
 
 
138
        virtual bool doWork();
 
139
 
 
140
        virtual void *completeWork();
 
141
 
 
142
private:
 
143
        MSDatabase                      *iTempLogDatabase;
 
144
        MSTempLogFile           *iTempLogFile;
 
145
        size_t                          iLogRecSize;
 
146
        off64_t                         iLogOffset;
 
147
        
 
148
};
 
149
 
 
150
#endif