rasdaman complete source
rpcclientcomm.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 /
33 // Everything commented out with /* RNP RNP*/ is done because of the switch to RNP
34 
35 #ifndef RPCCLIENTCOMM_HH
36 #define RPCCLIENTCOMM_HH
37 
38 #include "clientcomm.hh"
39 
40 /* RNP
41 #include "raslib/rminit.hh"
42 #include "raslib/error.hh"
43 #include "rasodmg/oqlquery.hh"
44 #include "rasodmg/marray.hh"
45 
46 #include "raslib/primitivetype.hh"
47 RNP */
48 
49 #ifdef __VISUALC__
50 extern "C"
51 {
52 #include <rpc/rpc.h>
53 }
54 #else
55 #include <rpc/rpc.h>
56 #endif
57 
58 #ifndef _RPCIF_
59 #define _RPCIF_
60 #include "clientcomm/rpcif.h"
61 #endif
62 
63 
64 /* RNP
65 template <class T> class r_Set;
66 class r_Ref_Any;
67 class r_Base_Type;
68 class r_Parse_Params;
69 RNP */
70 
71 
87 class RpcClientComm : public ClientComm
88 {
89 public:
91  RpcClientComm( const char* rasmgrHost, int rasmgrPort = RASMGRPORT ) throw( r_Error );
92 
93  /*@Doc:
94  May throw an exception of type {\tt r_Error_HostInvalid} if the hostname
95  cannot be successfully resolved and an exception of type {\tt r_Error_ServerInvalid}
96  if there is no RasDaMan RPC server running on the designated host.
97  */
98 
100  ~RpcClientComm() throw();
101 
102  bool effectivTypeIsRNP() throw();
103 
104  //@Man: Database methods
106 
109  int openDB( const char* database );
111  int closeDB();
113  int createDB( const char* name ) throw(r_Error);
115  int destroyDB( const char* name ) throw(r_Error);
116 
118 
119 
120  //@Man: Transaction methods
122 
125  int openTA( unsigned short readOnly = 0 ) throw(r_Error);
127  int commitTA() throw(r_Error);
129  int abortTA();
130 
132 
133 
134  //@Man: MDD methods
136 
139  void insertMDD( const char* collName, r_GMarray* mar ) throw( r_Error );
141  r_Ref_Any getMDDByOId( const r_OId& oid ) throw( r_Error );
142 
144 
145 
146  //@Man: Collection methods
148 
151  void insertColl( const char* collName, const char* typeName, const r_OId& oid ) throw( r_Error );
153  void deleteCollByName( const char* collName ) throw( r_Error );
155  void deleteObjByOId( const r_OId& oid ) throw( r_Error );
157  void removeObjFromColl( const char* name, const r_OId& oid ) throw ( r_Error );
159  r_Ref_Any getCollByName( const char* name ) throw( r_Error );
161  r_Ref_Any getCollByOId ( const r_OId& oid ) throw( r_Error );
163  r_Ref_Any getCollOIdsByName( const char* name ) throw( r_Error );
165  r_Ref_Any getCollOIdsByOId ( const r_OId& oid ) throw( r_Error );
166 
168 
169 
170  //@Man: Query methods
172 
175  void executeQuery( const r_OQL_Query& query, r_Set< r_Ref_Any >& result ) throw( r_Error );
176  /*@Doc:
177  Executes a retrieval query of type \Ref{r_OQL_Query} and returns the result. Every
178  MDD object of the MDD collection is fetched from the server and inserted
179  in the resulting \Ref{r_Set}.
180  */
181 
183  void executeQuery( const r_OQL_Query& query ) throw( r_Error );
184  /*@Doc:
185  Executes an update query of type \Ref{r_OQL_Query}.
186  */
187 
189 
190 
191 
192  //@Man: System methods
194 
197  r_OId getNewOId( unsigned short objType ) throw(r_Error);
198 
200  unsigned short getObjectType( const r_OId& oid ) throw(r_Error);
201 
204  char* getTypeStructure( const char* typeName, r_Type_Type typeType ) throw(r_Error);
205 
207 
208 
210  inline unsigned long getClientID() const;
211 
213  inline CLIENT* getBindingHandle() const;
214 
215  //@Man: Methods for asynchronious alive signal concept
217 
219  void triggerAliveSignal();
226  void sendAliveSignal();
234  int setTransferFormat( r_Data_Format format, const char* formatParams=NULL );
236 
237  int writeWholeMessage(int socket,char *destBuffer,int buffSize);
238  int readWholeMessage(int socket,char *destBuffer,int buffSize);
239 
241  int setStorageFormat( r_Data_Format format, const char *formatParams=NULL );
242 
244  void setRPCActive();
245 
247  void setRPCInactive();
248 
250  int checkRPCActive();
251 
253  const char *getExtendedErrorInfo() throw(r_Error);
254 
256  const char* getServerName();
257 
259  void setUserIdentification(const char *userName, const char *plainTextPassword);
260 
262  void setMaxRetry(unsigned int newMaxRetry);
263 
265  unsigned int getMaxRetry();
266 
268 
269 
270  void setTimeoutInterval(int seconds);
271 
272  int getTimeoutInterval();
273 
274 private:
275  // binding handle
276  CLIENT* binding_h;
277 
279  unsigned long clientID;
280 
281 #ifdef __VISUALC__
282  // save the timerid for later killing it
283  UINT timerid;
284 #endif
285 
286  // status variable of the last RPC library function call
287  unsigned long status;
288 
290  int serverUp;
291 
293  int rpcActive;
294 
296  int aliveSignalRemaining;
297 
299  unsigned short getMDDCore( r_Ref<r_GMarray> &mdd, GetMDDRes *thisResult, unsigned int isQuery ) throw( r_Error );
300 
302  int concatArrayData( const char *source, unsigned long srcSize, char *&dest,
303  unsigned long &destSize, unsigned long &destLevel );
304 
306  void getMarRpcRepresentation( const r_GMarray* mar, RPCMarray*& rpcMarray,
307  r_Data_Format initStorageFormat = r_Array,
308  const r_Base_Type *bt = NULL);
309 
311  void freeMarRpcRepresentation( const r_GMarray* mar, RPCMarray* rpcMarray );
312 
314  void getMDDCollection( r_Set< r_Ref_Any >& result, unsigned int isQuery ) throw(r_Error);
315 
317  void getElementCollection( r_Set< r_Ref_Any >& result ) throw(r_Error);
318 
320  int endianServer;
321  int endianClient;
322 
324  int serverRPCversion;
325 
327  r_Data_Format transferFormat;
329  r_Data_Format storageFormat;
331  char* transferFormatParams;
333  char *storageFormatParams;
335  r_Parse_Params *clientParams;
347  int serverCompresses;
350  int exactFormat;
351 
353  int connectToServer(unsigned short readOnly);
354 
356  int disconnectFromServer() throw();
357 
359  int getFreeServer(unsigned short readOnly);
360 
362  int executeGetFreeServer(unsigned short readOnly);
363 
365  int executeOpenDB( const char* database );
366 
368  int executeCloseDB();
369 
371  int executeOpenTA( unsigned short readOnly = 0 );
372 
374  int executeCommitTA();
375 
377  int executeAbortTA();
378 
380  char *rasmgrHost;
381 
383  int rasmgrPort;
384 
386  char serverHost[100]; //can't be just a pointer, it's never stored elsewhere
387 
389  unsigned long RPCIF_PARA;
390 
393  char dataBase[100];
394 
395  // the capability
396  char capability[100];
397 
399  char identificationString[100];
400 
401 };
402 
403 //RNP #include "clientcomm.icc"
404 
405 
406 #endif
Definition: rpcif.h:22
Definition: rpcif.h:148
const int RASMGRPORT
Definition: rminit.hh:59