vtkSMSessionClient.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: $RCSfile$
5 
6  Copyright (c) Kitware, Inc.
7  All rights reserved.
8  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
23 #ifndef vtkSMSessionClient_h
24 #define vtkSMSessionClient_h
25 
26 #include "vtkRemotingServerManagerModule.h" //needed for exports
27 #include "vtkSMSession.h"
28 
32 class vtkSMProxyLocator;
33 class vtkSMProxyManager;
34 
36 {
37 public:
38  static vtkSMSessionClient* New();
40  void PrintSelf(ostream& os, vtkIndent indent) override;
41 
45  const char* GetURI() override { return this->URI; };
46 
48 
67  virtual bool Connect(const char* url, int timeout = 60)
68  {
70  return this->Connect(url, timeout, nullptr, result);
71  }
72  virtual bool Connect(const char* url, int timeout, bool (*callback)(),
75 
79  bool GetIsAlive() override;
80 
87  ServerFlags GetProcessRoles() override { return CLIENT; }
88 
94 
103  vtkPVServerInformation* GetServerInformation() override { return this->ServerInformation; }
104 
110  void Initialize() override;
111 
113 
116  void PushState(vtkSMMessage* msg) override;
117  void PullState(vtkSMMessage* message) override;
118  void ExecuteStream(vtkTypeUInt32 location, const vtkClientServerStream& stream,
119  bool ignore_errors = false) override;
120  const vtkClientServerStream& GetLastResult(vtkTypeUInt32 location) override;
122 
124 
130  vtkSetMacro(AbortConnect, bool);
132 
136  void CloseSession();
137 
144  bool GatherInformation(
145  vtkTypeUInt32 location, vtkPVInformation* information, vtkTypeUInt32 globalid) override;
146 
153  int GetNumberOfProcesses(vtkTypeUInt32 servers) override;
154 
160  bool IsMPIInitialized(vtkTypeUInt32 servers) override;
161 
162  //---------------------------------------------------------------------------
163  // API for Collaboration management
164  //---------------------------------------------------------------------------
165 
166  // Called before application quit or session disconnection
167  // Used to prevent quitting client to delete proxy of a running session.
168  void PreDisconnection() override;
169 
173  virtual bool IsNotBusy();
179  virtual void StartBusyWork();
185  virtual void EndBusyWork();
186 
192 
194 
198  void PrepareProgressInternal() override;
199  void CleanupPendingProgressInternal() override;
201 
205  int GetConnectID();
206 
207  //---------------------------------------------------------------------------
208  // API for GlobalId management
209  //---------------------------------------------------------------------------
210 
217  vtkTypeUInt32 GetNextGlobalUniqueIdentifier() override;
218 
225  vtkTypeUInt32 GetNextChunkGlobalUniqueIdentifier(vtkTypeUInt32 chunkSize) override;
226 
227  void OnServerNotificationMessageRMI(void* message, int message_length);
228 
229 protected:
231  ~vtkSMSessionClient() override;
232 
233  void SetRenderServerController(vtkMultiProcessController*);
234  void SetDataServerController(vtkMultiProcessController*);
235 
236  void SetupDataServerRenderServerConnection();
237 
241  void UnRegisterSIObject(vtkSMMessage* msg) override;
242 
246  void RegisterSIObject(vtkSMMessage* msg) override;
247 
252  vtkTypeUInt32 GetRealLocation(vtkTypeUInt32);
253 
254  // Both maybe the same when connected to pvserver.
257 
262 
263  vtkSetStringMacro(URI);
264 
265  bool AbortConnect;
266  char* URI;
267 
268  // This flag allow us to disable remote Object deletion in a collaboration
269  // context when a client is leaving a visalization session.
270  // Typically we don't want this client to broadcast to the other to delete all
271  // the proxy because it does not need them anymore as it is leaving...
273 
274  // Field used to communicate with other clients
276 
281  bool OnWrongTagEvent(vtkObject* caller, unsigned long eventid, void* calldata) override;
282 
286  virtual void OnConnectionLost(vtkObject* caller, unsigned long eventid, void* calldata);
287 
288 private:
289  vtkSMSessionClient(const vtkSMSessionClient&) = delete;
290  void operator=(const vtkSMSessionClient&) = delete;
291 
292  int NotBusy;
293  vtkTypeUInt32 LastGlobalID;
294  vtkTypeUInt32 LastGlobalIDAvailable;
295 };
296 
297 #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:130
#define VTKREMOTINGSERVERMANAGER_EXPORT
virtual vtkSMCollaborationManager * GetCollaborationManager()
Return the instance of vtkSMCollaborationManager that will be lazy created at the first call...
Definition: vtkSMSession.h:52
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:34
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:164
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.