rasdaman complete source
rasmgr_host.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_HOST_HH
35 #define RASMGR_HOST_HH
36 
37 #include "rasmgr.hh"
38 #include "rasmgr_config.hh"
39 
40 //In normal release there can be just one RasMGR on a host
41 //But for testing we provide the possibility to put more than one on a host
42 //Just for fun, we call the unique RasMGR on a host the HIGHLANDER (thanks to Peter Zoller)
43 //So, for normal release, just...
44 //#define HIGHLANDER
45 
49 class ServerHost
50 {
51 public:
52  ServerHost();
53  ~ServerHost();
54  void init(const char* hostName,const char *netwName,int listenport,bool isInternal);
55  const char *getName();
56  const char *getNetworkName();
57  long getListenPort();
58  bool isInternal();
59  bool checkStatus();
60 
61  int getStartedServers();
62  int getLicensedServers();
63 
64  bool isUp();
65  bool downHost();
66 
67  static char* getDescriptionHeader(char *destBuffer);
68  char* getDescription(char *destBuffer);
69 
70  int countDefinedServers();
71  int getConnectionSocket();
72  void regStartServer();
73  void regDownServer();
74  void setIsUp(bool);
75 
76  void useLocalHost(bool);
77  bool useLocalHost();
78 
79  void changeName(const char*);
80  void changeNetName(const char*);
81  void changeListenPort(int);
82 
83  bool isValid();
84  bool reset();
85 private:
86  void setNotUp();
87  char hostName[100];
88  char netwName[100];
89  int listenPort;
90  int startedServers;
91  bool isup;
92  bool isinternal;
93  bool isuseLocalHost; // if internal, use localhost instead of network name, default on!
94 
95  bool valid;
96 };
97 
101 class HostManager
102 {
103 public:
104  HostManager();
105  ~HostManager();
106  bool insertInternalHost();
107  bool checkAcceptAnotherHost();
108  bool insertNewHost(const char* hostName,const char *netwName,int listenport);
109  bool removeHost(const char *hostName);
110  int countHosts();
111  int countUpHosts();
112  ServerHost& operator[](int);
113  ServerHost& operator[](const char* hostName);
114 
115  int postSlaveMGR(char *body,char *outBuffer);
116  bool reset();
117  bool acceptChangeName(const char *oldName,const char *newName);
118 private:
119  bool testUniqueness(const char* srvName);
120  list<ServerHost> hostList;
121  ServerHost protElem;
122 };
123 
124 extern HostManager hostmanager;
125 
126 
127 #endif
128