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