24 #ifndef RASNETCLIENTCOMM_HH
25 #define RASNETCLIENTCOMM_HH
30 #include "common/thread/threadutil.hh"
32 #include "common/macros/compilerdefs.hh"
33 #include "rasnet/messages/rasmgr_client_service.grpc.pb.h"
34 #include "rasnet/messages/client_rassrvr_service.grpc.pb.h"
35 #include "common/grpc/messages/health_service.grpc.pb.h"
41 #include <google/protobuf/service.h>
42 #include <google/protobuf/stubs/common.h>
58 explicit RasnetClientComm(
const std::string &rasmgrHost,
int rasmgrPort = DEFAULT_PORT);
62 int connectClient(const std::
string &userName, const std::
string &passwordHash);
70 int openTA(
unsigned short readOnly) override;
77 void insertColl(const
char *collName, const
char *typeName, const
r_OId &oid) override;
108 std::uint32_t clientId{};
113 std::uint32_t remoteClientId{};
114 std::uint32_t sessionId{};
118 char capability[100];
123 std::string rasmgrHostname;
125 std::string rasmgrHost;
127 std::string rasServerHost;
135 char *transferFormatParams{
nullptr};
137 char *storageFormatParams{
nullptr};
146 std::shared_ptr<rasnet::service::RasmgrClientService::Stub> rasmgrService;
147 bool initializedRasMgrService{
false};
148 std::mutex rasMgrServiceMtx;
149 std::shared_ptr<common::HealthService::Stub> rasmgrHealthService;
151 std::shared_ptr<rasnet::service::RasmgrClientService::Stub> getRasMgrService(
bool throwIfConnectionFailed =
true);
152 void initRasmgrService();
153 void closeRasmgrService();
157 std::shared_ptr<rasnet::service::ClientRassrvrService::Stub> rasserverService;
158 bool initializedRasServerService{
false};
159 std::mutex rasServerServiceMtx;
160 std::shared_ptr<common::HealthService::Stub> rasserverHealthService;
162 std::shared_ptr<rasnet::service::ClientRassrvrService::Stub> getRasServerService(
bool throwIfConnectionFailed =
true);
163 void initRasserverService();
164 void closeRasserverService();
168 int64_t keepAliveTimeout{};
171 std::unique_ptr<common::PeriodicTaskExecutor> rasMgrKeepAlive;
172 void startRasMgrKeepAlive();
174 void clientRasMgrKeepAliveRunner();
177 std::unique_ptr<common::PeriodicTaskExecutor> rasSrvKeepAlive;
178 void startRasServerKeepAlive();
180 void clientRasServerKeepAliveRunner();
186 NORETURN
static void handleError(
const std::string &error) noexcept(
false);
188 static void handleStatusCode(
int status,
const std::string &method) noexcept(
false);
192 int executeStartInsertPersMDD(
const char *collName,
r_GMarray *mar);
193 int executeInsertTile(
bool persistent, RPCMarray *tile);
194 void executeEndInsertMDD(
bool persistent);
195 int executeEndTransfer();
196 r_Ref_Any executeGetCollByNameOrOId(
const char *collName,
const r_OId &oid);
197 r_Ref_Any executeGetCollOIdsByNameOrOId(
const char *collName,
const r_OId &oid);
198 int executeStartInsertTransMDD(
r_GMarray *mdd);
199 int executeInitUpdate();
200 GetMDDRes *executeGetNextMDD();
201 GetTileRes *executeGetNextTile();
203 GetElementRes *executeGetNextElement();
204 int executeExecuteUpdateQuery(
const char *query);
206 int executeSetFormat(
bool lTransferFormat,
r_Data_Format format,
const char *formatParams);
209 unsigned short getMDDCore(
r_Ref<r_GMarray> &mdd, GetMDDRes *thisResult,
unsigned int isQuery);
213 int concatArrayData(
const char *source,
unsigned long srcSize,
char *&dest,
214 unsigned long &destSize,
unsigned long &destLevel);
215 void freeGetTileRes(GetTileRes *ptr);
217 void freeMarRpcRepresentation(
const r_GMarray *mar, RPCMarray *rpcMarray);
218 void getMarRpcRepresentation(
220 void checkForRwTransaction();
The class ClientComm represents one connection between one client entity (for example an object of cl...
Definition: clientcomm.hh:51
r_Database * database
reference to the database that created this client communicator
Definition: clientcomm.hh:202
r_Type_Type
Definition: clientcomm.hh:153
Definition: rasnetclientcomm.hh:56
int openTA(unsigned short readOnly) override
Transaction methods.
void deleteCollByName(const char *collName) override
deletes an MDD collection by name
int closeDB() override
close current database
int connectClient(const std::string &userName, const std::string &passwordHash)
r_Ref_Any getMDDByOId(const r_OId &oid) override
gets MDD object by oid
unsigned short getObjectType(const r_OId &oid) override
get oid type
int openDB(const char *database) override
Database methods.
RasnetClientComm(const std::string &rasmgrHost, int rasmgrPort=DEFAULT_PORT)
int setTransferFormat(r_Data_Format format, const char *formatParams=nullptr) override
Configuration methods.
void insertColl(const char *collName, const char *typeName, const r_OId &oid) override
Collection methods.
~RasnetClientComm() noexcept override
unsigned int getMaxRetry() override
get maximum retry to get a server
r_Ref_Any getCollByName(const char *name) override
gets collection by name
void setTimeoutInterval(int seconds) override
set communication timeout interval in seconds.
r_OId getNewOId(unsigned short objType) override
System methods.
void setMaxRetry(unsigned int newMaxRetry) override
set maximum retry to get a server
void removeObjFromColl(const char *name, const r_OId &oid) override
removes an object from a collection
int commitTA() override
commit current transaction
int getTimeoutInterval() override
get communication timeout interval in seconds.
r_Ref_Any getCollOIdsByOId(const r_OId &oid) override
gets collection references by oid
r_Ref_Any getCollOIdsByName(const char *name) override
gets collection references by name
void executeQuery(const r_OQL_Query &query, r_Set< r_Ref_Any > &result) override
Query methods.
int destroyDB(const char *name) override
destroy a database
r_Ref_Any getCollByOId(const r_OId &oid) override
gets collection by oid
int setStorageFormat(r_Data_Format format, const char *formatParams=nullptr) override
set the preferred storage format
int abortTA() override
abort current transaction
char * getTypeStructure(const char *typeName, r_Type_Type typeType) override
get type structure deallocate using delete []
void insertMDD(const char *collName, r_GMarray *mar) override
MDD methods.
void deleteObjByOId(const r_OId &oid) override
deletes an object by oid (right now, objects are collection only)
void setUserIdentification(const char *userName, const char *plainTextPassword) override
user identification for RasMGR
int createDB(const char *name) override
create a database
This class is the superclass of the types r_Structure_Type and r_Primitive_Type in the representation...
Definition: basetype.hh:40
The class represents a generic MDD in the sense that it is independent of the cell base type.
Definition: gmarray.hh:66
Class r_OId represents an object identifier.
Definition: oid.hh:39
The global function r_oql_execute() is used to invoke RasML queries.
Definition: oqlquery.hh:71
Class for parsing a string consisting of key=value pairs separated by ",".
Definition: parseparams.hh:40
The class r_Ref_Any is defined to support a reference to any type.
Definition: ref.hh:65
References of type r_Ref in many respects behave like C++ pointers but provide an additional mechanis...
Definition: ref.hh:198
The class implements a set container.
Definition: set.hh:42
r_Data_Format
\begin{tabular}{ll} <tt>r_Array</tt> && no compression, row-major memory representation\...
Definition: mddtypes.hh:94
@ r_Array
Definition: mddtypes.hh:95