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 {
29 
30  auto cliApp = vtk::TakeSmartPointer(vtkCLIOptions::New());
31  cliApp->SetAllowExtras(false);
32  cliApp->SetStopOnUnrecognizedArgument(true);
33  switch (type)
34  {
36  cliApp->SetDescription(
37  "pvdataserver: the ParaView data-server\n"
38  "=============================\n"
39  "This is the ParaView data-server executable. Together with the render-server "
40  "(pvrenderserver), "
41  "this can be used for client-server use-cases. "
42  "This process handles all the rendering requests. \n\n"
43  "Typically, one connects a ParaView client (either a graphical client, or a Python-based "
44  "client) to this process to drive the data analysis and visualization pipelines.");
45  break;
46 
48  cliApp->SetDescription(
49  "pvrenderserver: the ParaView render-server\n"
50  "=============================\n"
51  "This is the ParaView render-server executable. Together with the data-server "
52  "(pvdataserver), "
53  "this can be used for client-server use-cases. "
54  "This process handles all the data-processing requests. \n\n"
55  "Typically, one connects a ParaView client (either a graphical client, or a Python-based "
56  "client) to this process to drive the data analysis and visualization pipelines.");
57  break;
58 
60  cliApp->SetDescription(
61  "pvserver: the ParaView server\n"
62  "=============================\n"
63  "This is the ParaView server executable. This is intended for client-server use-cases "
64  "which require the client and server to be on different processes, potentially on "
65  "different systems.\n\n"
66  "Typically, one connects a ParaView client (either a graphical client, or a Python-based "
67  "client) to this process to drive the data analysis and visualization pipelines.");
68  break;
69  default:
70  vtkLogF(ERROR, "process type not supported!");
71  abort();
72  }
73 
74  // Init current process type
75  auto status = vtkInitializationHelper::Initialize(argc, argv, type, cliApp);
76  cliApp = nullptr;
77  if (!status)
78  {
80  }
81 
83 
84 #if PARAVIEW_USE_PYTHON
85  // register callback to initialize modules statically. The callback is
86  // empty when BUILD_SHARED_LIBS is ON.
88 #endif
89 
90  // register static plugins
92 
94 
97 
99  session->SetMultipleConnection(config->GetMultiClientMode());
100  session->SetDisableFurtherConnections(config->GetDisableFurtherConnections());
101 
102  int process_id = controller->GetLocalProcessId();
103  if (process_id == 0)
104  {
105  // Report status:
106  if (config->GetReverseConnection())
107  {
108  cout << "Connecting to client (reverse connection requested)..." << endl;
109  }
110  else
111  {
112  cout << "Waiting for client..." << endl;
113  }
114  }
115  bool success = false;
116  if (session->Connect())
117  {
118  success = true;
119  pm->RegisterSession(session);
120  if (controller->GetLocalProcessId() == 0)
121  {
122  while (pm->GetNetworkAccessManager()->ProcessEvents(0) != -1)
123  {
124  }
125  }
126  else
127  {
128  controller->ProcessRMIs();
129  }
130  pm->UnRegisterSession(session);
131  }
132 
133  cout << "Exiting..." << endl;
134  session->Delete();
135  // Exit application
137  return success ? vtkInitializationHelper::GetExitCode() : EXIT_FAILURE;
138 }
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 void SetApplicationName(const std::string &appName)
Sets the name of the application.
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.