vtkSMSessionClient.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
11 #ifndef vtkSMSessionClient_h
12 #define vtkSMSessionClient_h
13 
14 #include "vtkRemotingServerManagerModule.h" //needed for exports
15 #include "vtkSMSession.h"
16 
20 class vtkSMProxyLocator;
21 class vtkSMProxyManager;
22 
24 {
25 public:
26  static vtkSMSessionClient* New();
28  void PrintSelf(ostream& os, vtkIndent indent) override;
29 
33  const char* GetURI() override { return this->URI; };
34 
36 
55  virtual bool Connect(const char* url, int timeout = 60)
56  {
58  return this->Connect(url, timeout, nullptr, result);
59  }
60  virtual bool Connect(const char* url, int timeout, bool (*callback)(),
63 
67  bool GetIsAlive() override;
68 
75  ServerFlags GetProcessRoles() override { return CLIENT; }
76 
82 
91  vtkPVServerInformation* GetServerInformation() override { return this->ServerInformation; }
92 
98  void Initialize() override;
99 
101 
104  void PushState(vtkSMMessage* msg) override;
105  void PullState(vtkSMMessage* message) override;
106  void ExecuteStream(vtkTypeUInt32 location, const vtkClientServerStream& stream,
107  bool ignore_errors = false) override;
108  const vtkClientServerStream& GetLastResult(vtkTypeUInt32 location) override;
110 
112 
118  vtkSetMacro(AbortConnect, bool);
120 
124  void CloseSession();
125 
132  bool GatherInformation(
133  vtkTypeUInt32 location, vtkPVInformation* information, vtkTypeUInt32 globalid) override;
134 
141  int GetNumberOfProcesses(vtkTypeUInt32 servers) override;
142 
148  bool IsMPIInitialized(vtkTypeUInt32 servers) override;
149 
150  //---------------------------------------------------------------------------
151  // API for Collaboration management
152  //---------------------------------------------------------------------------
153 
154  // Called before application quit or session disconnection
155  // Used to prevent quitting client to delete proxy of a running session.
156  void PreDisconnection() override;
157 
161  virtual bool IsNotBusy();
167  virtual void StartBusyWork();
173  virtual void EndBusyWork();
174 
180 
182 
186  void PrepareProgressInternal() override;
187  void CleanupPendingProgressInternal() override;
189 
193  int GetConnectID();
194 
195  //---------------------------------------------------------------------------
196  // API for GlobalId management
197  //---------------------------------------------------------------------------
198 
205  vtkTypeUInt32 GetNextGlobalUniqueIdentifier() override;
206 
213  vtkTypeUInt32 GetNextChunkGlobalUniqueIdentifier(vtkTypeUInt32 chunkSize) override;
214 
215  void OnServerNotificationMessageRMI(void* message, int message_length);
216 
217 protected:
219  ~vtkSMSessionClient() override;
220 
221  void SetRenderServerController(vtkMultiProcessController*);
222  void SetDataServerController(vtkMultiProcessController*);
223 
224  void SetupDataServerRenderServerConnection();
225 
229  void UnRegisterSIObject(vtkSMMessage* msg) override;
230 
234  void RegisterSIObject(vtkSMMessage* msg) override;
235 
240  vtkTypeUInt32 GetRealLocation(vtkTypeUInt32);
241 
242  // Both maybe the same when connected to pvserver.
245 
250 
251  vtkSetStringMacro(URI);
252 
253  bool AbortConnect;
254  char* URI;
255 
256  // This flag allow us to disable remote Object deletion in a collaboration
257  // context when a client is leaving a visalization session.
258  // Typically we don't want this client to broadcast to the other to delete all
259  // the proxy because it does not need them anymore as it is leaving...
261 
262  // Field used to communicate with other clients
264 
269  bool OnWrongTagEvent(vtkObject* caller, unsigned long eventid, void* calldata) override;
270 
274  virtual void OnConnectionLost(vtkObject* caller, unsigned long eventid, void* calldata);
275 
276 private:
277  vtkSMSessionClient(const vtkSMSessionClient&) = delete;
278  void operator=(const vtkSMSessionClient&) = delete;
279 
280  int NotBusy;
281  vtkTypeUInt32 LastGlobalID;
282  vtkTypeUInt32 LastGlobalIDAvailable;
283 };
284 
285 #endif
void PrepareProgressInternal() override
Should be called to begin/end receiving progresses on this session.
vtkPVServerInformation * RenderServerInformation
void PrintSelf(ostream &os, vtkIndent indent) override
location
vtkPVServerInformation * ServerInformation
vtkPVServerInformation * DataServerInformation
bool GetIsAlive() override
Builtin session is always alive.
Definition: vtkSMSession.h:118
#define VTKREMOTINGSERVERMANAGER_EXPORT
virtual vtkSMCollaborationManager * GetCollaborationManager()
Return the instance of vtkSMCollaborationManager that will be lazy created at the first call...
Definition: vtkSMSession.h:40
virtual const vtkClientServerStream & GetLastResult(vtkTypeUInt32 location)
Returns the response of the ExecuteStream() call from the location.
vtkSMSession is the default ParaView session.
Definition: vtkSMSession.h:22
Gets features of the server.
vtkMultiProcessController * RenderServerController
virtual bool GatherInformation(vtkTypeUInt32 location, vtkPVInformation *information, vtkTypeUInt32 globalid)
Gather information about an object referred by the globalid.
Class used to broadcast message from one client to the others.
Store messages for the interpreter.
singleton/facade to vtkSMSessionProxyManager
virtual void PreDisconnection()
Definition: vtkSMSession.h:152
virtual bool Connect(const char *url, int timeout=60)
Connects a remote server.
virtual bool IsMPIInitialized(vtkTypeUInt32 servers)
Returns whether or not MPI is initialized on the specified server/s.
vtkSMSessionClient is a remote-session that connects to a remote server.
vtkMultiProcessController * DataServerController
Header class that setup every thing in order to use Protobuf messages in a transparent manner...
virtual vtkTypeUInt32 GetNextGlobalUniqueIdentifier()
Provides the next available identifier.
virtual void Initialize()
Initialize various internal classes after the session has been setup correctly.
url
static vtkSMSession * New()
void PushState(vtkSMMessage *msg) override
Push the state message.
void CleanupPendingProgressInternal() override
Should be called to begin/end receiving progresses on this session.
virtual void UnRegisterSIObject(vtkSMMessage *msg)
Unregister server side object.
vtkPVServerInformation * GetServerInformation() override
vtkPVServerInformation is an information-object that provides information about the server processes...
virtual void RegisterSIObject(vtkSMMessage *msg)
Register server side object.
is used to locate proxies referred to in state xmls while loading state files.
virtual int GetNumberOfProcesses(vtkTypeUInt32 servers)
Returns the number of processes on the given server/s.
virtual vtkTypeUInt32 GetNextChunkGlobalUniqueIdentifier(vtkTypeUInt32 chunkSize)
Return the first Id of the requested chunk.
vtkClientServerStream * ServerLastInvokeResult
virtual void PullState(vtkSMMessage *msg)
Pull the state message.
const char * GetURI() override
Return the url used to connect the current session to a server.
ServerFlags GetProcessRoles() override
Returns a ServerFlags indicate the nature of the current processes.
vtkSMCollaborationManager * CollaborationCommunicator
virtual bool OnWrongTagEvent(vtkObject *caller, unsigned long eventid, void *calldata)
Callback when any vtkMultiProcessController subclass fires a WrongTagEvent.
virtual vtkMultiProcessController * GetController(ServerFlags processType)
Returns the controller used to communicate with the process.
virtual void ExecuteStream(vtkTypeUInt32 location, const vtkClientServerStream &stream, bool ignore_errors=false)
Execute a command on the given processes.
ConnectionResult
Possible result of connection when creating a new connection CONNECTION_SUCCESS: Connection was suces...
Superclass for information objects.