rasdaman complete source
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
rasmgr
rasmgr_srv.hh
Go to the documentation of this file.
1
/*
2
* This file is part of rasdaman community.
3
*
4
* Rasdaman community is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation, either version 3 of the License, or
7
* (at your option) any later version.
8
*
9
* Rasdaman community is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16
*
17
* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
18
rasdaman GmbH.
19
*
20
* For more information please see <http://www.rasdaman.org>
21
* or contact Peter Baumann via <baumann@rasdaman.com>.
22
/
34
#ifndef RASMGR_SRV_HH
35
#define RASMGR_SRV_HH
36
37
#include "rasmgr.hh"
38
#include "rasmgr_config.hh"
39
#include "rasmgr_host.hh"
40
#include "rasmgr_dbm.hh"
41
42
//#define RASEXECUTABLE "rst"
43
#define RASEXECUTABLE BINDIR"rasserver"
44
#define MAXREGULARCOUNTER 3
45
47
const unsigned int RASSERVER_OK = 0;
48
const unsigned int RASSERVER_NODATABASEHOST = -1;
49
const unsigned int RASSERVER_CANNOTSTARTSRV = -2;
50
const unsigned int RASSERVER_NOREMOTERASMGR = -3;
51
const unsigned int RASSERVER_INCOMPLETESEND = -4;
52
const unsigned int RASSERVER_SRVNOTUP = -5;
53
const unsigned int RASSERVER_CMDLINEOFLO = -6;
54
55
59
class RasServer
60
{
61
public:
62
RasServer();
63
~RasServer();
64
void init(const char *srvName,const char* hostName,char serverType,long listenPort);
65
const char *getName();
66
const char *getHostName();
67
const char *getHostNetwName();
68
long getPort();
69
char getType();
70
void changeName(const char *newName);
71
void changeType(const char newType); // char not char*!!
72
73
void changePort(long newPort);
74
void changeExtraParam(const char *extraParam);
75
void changeCountDown(int);
76
void changeAutoRestart(bool);
77
const char *getExtraParams();
78
int getCountDown();
79
80
bool connectToDBHost(const char *dbHostName);//,const char *connString);
81
bool disconnectFromDBHost();
82
const char *getDBHostName();
83
84
static char* getDescriptionHeader(char *destBuffer);
85
char* getDescription(char *destBuffer);
86
static char* getDescriptionExecHeader(char *destBuffer);
87
char* getDescriptionExec(char *destBuffer);
88
static char* getDescriptionPortHeader(char *destBuffer);
89
char* getDescriptionPort(char *destBuffer);
90
91
int startServer();
92
int startServerInDebugger(char *command); // test modus only
93
94
int downServer(bool forced);
95
int killServer();
96
97
void changeStatus(int,long);
98
bool isUp();
99
bool isStarting();
100
bool isValid();
101
bool isAvailable();
102
bool forceAvailable();
103
104
bool isConnectedToDBHost();
105
bool isAutoRestart();
106
107
void setNotAvailable();
108
void startWriteTransaction(Database& dataBase);
109
void startReadTransaction(Database& dataBase);
110
void changeExecutableName(const char*);
111
const char* getExecutableName();
112
private:
113
int downNow();
114
void clearPendingTransaction();
115
116
char serverName[ARG_MAX];
117
ServerHost *ptrServerHost;
118
bool isinternal;
119
char serverType; //'r','h'
120
long listenPort; // 'r' ->rpc prognum; 'h' ->TCP/IP port
121
char extraParam[ARG_MAX];
122
123
char executableName[ARG_MAX];
124
125
DatabaseHost *ptrDatabaseHost;
126
//char connStr[100];
127
128
bool downReq;
129
bool available;
130
bool isup;
131
bool isstarting;
132
bool activityExpected; // to avoid the possibility of starting rasserver by hand
133
134
int regularSignalCounter; // how namy times should a nonavailable server signal before we put it available again
135
unsigned long activityCounter; // counts "activities" per server, i.e., actions that are noticeable by the server
136
137
int initialCountDown;
138
int currentCountDown;
139
int crashCount;
140
bool autorestart;
141
142
bool writeTransaction;
143
bool readTransaction;
144
Database *connDatabase;
145
146
bool valid;
147
};
148
152
class RasServerManager
153
{
154
public:
155
RasServerManager();
156
~RasServerManager();
157
bool insertNewServer(const char *srvName,const char* hostName,char serverType,long listenPort);
158
bool removeServer(const char *srvName);
159
int countServers();
160
RasServer& operator[](int);
161
RasServer& operator[](const char*srvName);
162
RasServer& last();
163
164
int changeServerStatus(char *reqMessage);
165
void disconnectAllServersFromDBH(const char *dbhName);
166
167
int countUpServers();
168
void printStatus();
169
bool reset(); // test modus only
170
bool acceptChangeName(const char *oldName,const char *newName);
171
private:
172
bool testUniqueness(const char* srvName);
173
list<RasServer> srvList;
174
RasServer protElem;
175
};
176
177
extern RasServerManager rasManager;
178
179
#endif
180
181
Generated on Sat Mar 7 2015 23:10:27 for rasdaman complete source by
1.8.8