pvserver_common.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
3 
4 #include "vtkCLIOptions.h"
6 #include "vtkLogger.h"
9 #include "vtkPVPluginTracker.h"
10 #include "vtkPVSessionServer.h"
11 #include "vtkProcessModule.h"
14 #include "vtkSMProxyManager.h"
15 #include "vtkSmartPointer.h"
16 
17 #if PARAVIEW_USE_PYTHON
18 extern "C"
19 {
21 }
22 #endif
23 
25 
26 static int RealMain(int argc, char* argv[], vtkProcessModule::ProcessTypes type)
27 {
28  auto cliApp = vtk::TakeSmartPointer(vtkCLIOptions::New());
29  cliApp->SetAllowExtras(false);
30  cliApp->SetStopOnUnrecognizedArgument(false);
31  switch (type)
32  {
34  cliApp->SetDescription(
35  "pvdataserver: the ParaView data-server\n"
36  "=============================\n"
37  "This is the ParaView data-server executable. Together with the render-server "
38  "(pvrenderserver), "
39  "this can be used for client-server use-cases. "
40  "This process handles all the rendering requests. \n\n"
41  "Typically, one connects a ParaView client (either a graphical client, or a Python-based "
42  "client) to this process to drive the data analysis and visualization pipelines.");
43  break;
44 
46  cliApp->SetDescription(
47  "pvrenderserver: the ParaView render-server\n"
48  "=============================\n"
49  "This is the ParaView render-server executable. Together with the data-server "
50  "(pvdataserver), "
51  "this can be used for client-server use-cases. "
52  "This process handles all the data-processing requests. \n\n"
53  "Typically, one connects a ParaView client (either a graphical client, or a Python-based "
54  "client) to this process to drive the data analysis and visualization pipelines.");
55  break;
56 
58  cliApp->SetDescription(
59  "pvserver: the ParaView server\n"
60  "=============================\n"
61  "This is the ParaView server executable. This is intended for client-server use-cases "
62  "which require the client and server to be on different processes, potentially on "
63  "different systems.\n\n"
64  "Typically, one connects a ParaView client (either a graphical client, or a Python-based "
65  "client) to this process to drive the data analysis and visualization pipelines.");
66  break;
67  default:
68  vtkLogF(ERROR, "process type not supported!");
69  abort();
70  }
71 
72  // Init current process type
73  auto status = vtkInitializationHelper::Initialize(argc, argv, type, cliApp);
74  cliApp = nullptr;
75  if (!status)
76  {
78  }
79 
81 
82 #if PARAVIEW_USE_PYTHON
83  // register callback to initialize modules statically. The callback is
84  // empty when BUILD_SHARED_LIBS is ON.
86 #endif
87 
88  // register static plugins
90 
92 
95 
97  session->SetMultipleConnection(config->GetMultiClientMode());
98  session->SetDisableFurtherConnections(config->GetDisableFurtherConnections());
99 
100  int process_id = controller->GetLocalProcessId();
101  if (process_id == 0)
102  {
103  // Report status:
104  if (config->GetReverseConnection())
105  {
106  cout << "Connecting to client (reverse connection requested)..." << endl;
107  }
108  else
109  {
110  cout << "Waiting for client..." << endl;
111  }
112  }
113  bool success = false;
114  if (session->Connect())
115  {
116  success = true;
117  pm->RegisterSession(session);
118  if (controller->GetLocalProcessId() == 0)
119  {
120  while (pm->GetNetworkAccessManager()->ProcessEvents(0) != -1)
121  {
122  }
123  }
124  else
125  {
126  controller->ProcessRMIs();
127  }
128  pm->UnRegisterSession(session);
129  }
130 
131  cout << "Exiting..." << endl;
132  session->Delete();
133  // Exit application
135  return success ? vtkInitializationHelper::GetExitCode() : EXIT_FAILURE;
136 }
void LoadPluginConfigurationXMLs(const char *appname)
Called to load application-specific configuration xml.
virtual bool Connect(const char *url)
Connects a remote server.
static int GetExitCode()
Returns the exit code after Initialize.
static vtkCLIOptions * New()
int ProcessRMIs(int reportErrors, int dont_loop=0)
void SetDisableFurtherConnections(bool disable)
Enable or Disable further connections in multiple connection mode.
static vtkPVSessionServer * New()
static void Finalize()
Finalizes the server manager.
static vtkProcessModule * GetProcessModule()
Provides access to the global ProcessModule.
virtual int ProcessEvents(unsigned long timeout_msecs)=0
Process any network activity.
static vtkPVPluginTracker * GetInstance()
Provides access to the singleton.
vtkMultiProcessController * GetGlobalController()
Provides access to the global MPI controller, if any.
vtkIdType RegisterSession(vtkSession *)
Registers a new session.
static bool Initialize(int argc, char **argv, int processType, vtkCLIOptions *options=nullptr, bool enableStandardArgs=true)
Initializes ParaView engine.
static int RealMain(int argc, char *argv[], vtkProcessModule::ProcessTypes type)
virtual void SetMultipleConnection(bool)
Enable or Disable multi-connection support.
vtkSMSessionServer is a session used on data and/or render servers.
virtual vtkNetworkAccessManager * GetNetworkAccessManager()
Get/Set the network access manager.
void vtkPVInitializePythonModules()
static void ParaView_paraview_plugins_initialize()
process initialization and management core for ParaView processes.
virtual void Delete()
static vtkRemotingCoreConfiguration * GetInstance()
Provides access to the singleton.
bool UnRegisterSession(vtkIdType sessionID)
Unregister a session given its ID.