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  const vtkClientServerStream& GetLastResult(vtkTypeUInt32 location) override;
108 
116  void ExecuteStream(vtkTypeUInt32 location, const vtkClientServerStream& stream,
117  bool ignoreErrors = false, bool sendReply = false) override;
118 
120 
126  vtkSetMacro(AbortConnect, bool);
128 
132  void CloseSession();
133 
140  bool GatherInformation(
141  vtkTypeUInt32 location, vtkPVInformation* information, vtkTypeUInt32 globalid) override;
142 
149  int GetNumberOfProcesses(vtkTypeUInt32 servers) override;
150 
156  bool IsMPIInitialized(vtkTypeUInt32 servers) override;
157 
158  //---------------------------------------------------------------------------
159  // API for Collaboration management
160  //---------------------------------------------------------------------------
161 
162  // Called before application quit or session disconnection
163  // Used to prevent quitting client to delete proxy of a running session.
164  void PreDisconnection() override;
165 
169  virtual bool IsNotBusy();
175  virtual void StartBusyWork();
181  virtual void EndBusyWork();
182 
188 
190 
194  void PrepareProgressInternal() override;
195  void CleanupPendingProgressInternal() override;
197 
201  int GetConnectID();
202 
203  //---------------------------------------------------------------------------
204  // API for GlobalId management
205  //---------------------------------------------------------------------------
206 
213  vtkTypeUInt32 GetNextGlobalUniqueIdentifier() override;
214 
221  vtkTypeUInt32 GetNextChunkGlobalUniqueIdentifier(vtkTypeUInt32 chunkSize) override;
222 
223  void OnServerNotificationMessageRMI(void* message, int message_length);
224 
225 protected:
227  ~vtkSMSessionClient() override;
228 
229  void SetRenderServerController(vtkMultiProcessController*);
230  void SetDataServerController(vtkMultiProcessController*);
231 
232  void SetupDataServerRenderServerConnection();
233 
237  void UnRegisterSIObject(vtkSMMessage* msg) override;
238 
242  void RegisterSIObject(vtkSMMessage* msg) override;
243 
248  vtkTypeUInt32 GetRealLocation(vtkTypeUInt32);
249 
250  // Both maybe the same when connected to pvserver.
253 
258 
259  vtkSetStringMacro(URI);
260 
261  bool AbortConnect;
262  char* URI;
263 
264  // This flag allow us to disable remote Object deletion in a collaboration
265  // context when a client is leaving a visalization session.
266  // Typically we don't want this client to broadcast to the other to delete all
267  // the proxy because it does not need them anymore as it is leaving...
269 
270  // Field used to communicate with other clients
272 
277  bool OnWrongTagEvent(vtkObject* caller, unsigned long eventid, void* calldata) override;
278 
282  virtual void OnConnectionLost(vtkObject* caller, unsigned long eventid, void* calldata);
283 
284 private:
285  vtkSMSessionClient(const vtkSMSessionClient&) = delete;
286  void operator=(const vtkSMSessionClient&) = delete;
287 
288  int NotBusy;
289  vtkTypeUInt32 LastGlobalID;
290  vtkTypeUInt32 LastGlobalIDAvailable;
291 };
292 
293 #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:123
#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.
virtual void ExecuteStream(vtkTypeUInt32 location, const vtkClientServerStream &stream, bool ignoreErrors=false, bool sendReply=false)
Execute a command on the given processes.
singleton/facade to vtkSMSessionProxyManager
virtual void PreDisconnection()
Definition: vtkSMSession.h:157
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.
ConnectionResult
Possible result of connection when creating a new connection CONNECTION_SUCCESS: Connection was suces...
Superclass for information objects.