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 
23 class VTKREMOTINGSERVERMANAGER_EXPORT vtkSMSessionClient : public vtkSMSession
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 
81  vtkMultiProcessController* GetController(ServerFlags processType) override;
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
vtkSMSessionClient::ServerLastInvokeResult
vtkClientServerStream * ServerLastInvokeResult
Definition: vtkSMSessionClient.h:249
vtkSMSessionClient::GetURI
const char * GetURI() override
Return the url used to connect the current session to a server.
Definition: vtkSMSessionClient.h:33
vtkPVServerInformation
Gets features of the server.
Definition: vtkPVServerInformation.h:22
vtkPVSessionBase::GetNextChunkGlobalUniqueIdentifier
virtual vtkTypeUInt32 GetNextChunkGlobalUniqueIdentifier(vtkTypeUInt32 chunkSize)
Return the first Id of the requested chunk.
vtkSMSession::GetCollaborationManager
virtual vtkSMCollaborationManager * GetCollaborationManager()
Return the instance of vtkSMCollaborationManager that will be lazy created at the first call.
Definition: vtkSMSession.h:40
vtkSMSession::PushState
void PushState(vtkSMMessage *msg) override
Push the state message.
vtkPVSessionBase::PullState
virtual void PullState(vtkSMMessage *msg)
Pull the state message.
vtkSMSessionClient::CollaborationCommunicator
vtkSMCollaborationManager * CollaborationCommunicator
Definition: vtkSMSessionClient.h:263
vtkSMSession::New
static vtkSMSession * New()
vtkSMSessionClient
Definition: vtkSMSessionClient.h:23
vtkSMSessionClient::DataServerController
vtkMultiProcessController * DataServerController
Definition: vtkSMSessionClient.h:244
vtkClientServerStream
Store messages for the interpreter.
Definition: vtkClientServerStream.h:23
vtkSMSessionClient::RenderServerController
vtkMultiProcessController * RenderServerController
Definition: vtkSMSessionClient.h:243
vtkObject
vtkSMProxyManager
singleton/facade to vtkSMSessionProxyManager
Definition: vtkSMProxyManager.h:35
vtkSMSessionClient::AbortConnect
bool AbortConnect
Definition: vtkSMSessionClient.h:251
vtkPVSessionBase::CleanupPendingProgressInternal
void CleanupPendingProgressInternal() override
Should be called to begin/end receiving progresses on this session.
vtkSMSessionClient::URI
char * URI
Definition: vtkSMSessionClient.h:254
vtkPVSessionBase::RegisterSIObject
virtual void RegisterSIObject(vtkSMMessage *msg)
Register server side object.
vtkPVSessionBase::UnRegisterSIObject
virtual void UnRegisterSIObject(vtkSMMessage *msg)
Unregister server side object.
vtkNetworkAccessManager::ConnectionResult
ConnectionResult
Possible result of connection when creating a new connection CONNECTION_SUCCESS: Connection was suces...
Definition: vtkNetworkAccessManager.h:34
vtkSMSessionClient::ServerInformation
vtkPVServerInformation * ServerInformation
Definition: vtkSMSessionClient.h:248
vtkPVSession::GetController
virtual vtkMultiProcessController * GetController(ServerFlags processType)
Returns the controller used to communicate with the process.
vtkSMSessionClient::GetProcessRoles
ServerFlags GetProcessRoles() override
Returns a ServerFlags indicate the nature of the current processes.
Definition: vtkSMSessionClient.h:75
vtkPVSession::ServerFlags
ServerFlags
Definition: vtkPVSession.h:29
vtkMultiProcessController
vtkSMSession
Definition: vtkSMSession.h:22
vtkPVSessionBase::ExecuteStream
virtual void ExecuteStream(vtkTypeUInt32 location, const vtkClientServerStream &stream, bool ignore_errors=false)
Execute a command on the given processes.
vtkIndent
vtkSMSession::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
vtkSMMessage
vtkPVSessionBase::PrepareProgressInternal
void PrepareProgressInternal() override
Should be called to begin/end receiving progresses on this session.
vtkSMSessionClient::Connect
virtual bool Connect(const char *url, int timeout=60)
Connects a remote server.
Definition: vtkSMSessionClient.h:55
vtkSMSession::GetIsAlive
bool GetIsAlive() override
Builtin session is always alive.
Definition: vtkSMSession.h:118
vtkSMSessionClient::NoMoreDelete
bool NoMoreDelete
Definition: vtkSMSessionClient.h:260
url
url
vtkPVSession::CLIENT
@ CLIENT
Definition: vtkPVSession.h:37
vtkSMCollaborationManager
Class used to broadcast message from one client to the others.
Definition: vtkSMCollaborationManager.h:36
vtkPVInformation
Superclass for information objects.
Definition: vtkPVInformation.h:19
vtkPVSession::OnWrongTagEvent
virtual bool OnWrongTagEvent(vtkObject *caller, unsigned long eventid, void *calldata)
Callback when any vtkMultiProcessController subclass fires a WrongTagEvent.
vtkSMSessionClient::DataServerInformation
vtkPVServerInformation * DataServerInformation
Definition: vtkSMSessionClient.h:246
vtkSMSession::Initialize
virtual void Initialize()
Initialize various internal classes after the session has been setup correctly.
vtkSMProxyLocator
is used to locate proxies referred to in state xmls while loading state files.
Definition: vtkSMProxyLocator.h:24
vtkSMSessionClient::GetServerInformation
vtkPVServerInformation * GetServerInformation() override
vtkPVServerInformation is an information-object that provides information about the server processes.
Definition: vtkSMSessionClient.h:91
vtkSMSession.h
vtkSMSession::GetNumberOfProcesses
virtual int GetNumberOfProcesses(vtkTypeUInt32 servers)
Returns the number of processes on the given server/s.
vtkPVSessionBase::GetNextGlobalUniqueIdentifier
virtual vtkTypeUInt32 GetNextGlobalUniqueIdentifier()
Provides the next available identifier.
vtkPVSessionBase::GetLastResult
virtual const vtkClientServerStream & GetLastResult(vtkTypeUInt32 location)
Returns the response of the ExecuteStream() call from the location.
vtkSMSessionClient::RenderServerInformation
vtkPVServerInformation * RenderServerInformation
Definition: vtkSMSessionClient.h:247
vtkSMSession::PreDisconnection
virtual void PreDisconnection()
Definition: vtkSMSession.h:152
vtkPVSessionBase::GatherInformation
virtual bool GatherInformation(vtkTypeUInt32 location, vtkPVInformation *information, vtkTypeUInt32 globalid)
Gather information about an object referred by the globalid.
vtkSMSession::IsMPIInitialized
virtual bool IsMPIInitialized(vtkTypeUInt32 servers)
Returns whether or not MPI is initialized on the specified server/s.