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