34 using namespace Generator;
35 using namespace Data_Structure;
45 application->setStatusWriteBlock(
false);
47 if (!application->getEnabled())
61 if (!admin->isServerEnabled(appId))
63 admin->enableServer(appId,
true);
65 if (admin->getServerState(appId) != IceGrid::Active)
67 admin->startServer(appId);
71 application->setPid(admin->getServerPid(appId));
77 application->setPid(-1);
80 catch (IceGrid::ServerNotExistException& ex)
82 ARMARX_ERROR_S <<
"There is no Server for " << application->getName() <<
" - please make sure the Scenario is correctly deployed";
85 catch (IceGrid::ServerStartException& ex)
87 ARMARX_ERROR_S <<
"Could not start Server " << application->getName() <<
" Reason: " << ex.reason;
90 catch (IceGrid::NodeUnreachableException& ex)
92 ARMARX_ERROR_S <<
"Could not connect to the Node of " << application->getName() <<
" - please make sure the Scenario is correctly deployed";
95 catch (IceGrid::DeploymentException& ex)
97 ARMARX_ERROR_S <<
"Could not connect deploy " << application->getName() <<
" - please make sure the Scenario is correctly deployed";
107 application->setStatusWriteBlock(
false);
109 if (!application->getEnabled())
114 IceGridXmlGenerator generator;
116 IceGrid::ServerInstanceDescriptor serverInstanceDescriptor = generator.generateComponentNode(application);
117 std::vector<std::string> appNames = admin->getAllApplicationNames();
119 if (std::find(appNames.begin(), appNames.end(), application->getScenario()->getName()) != appNames.end())
121 IceGrid::ApplicationInfo appInfo = admin->getApplicationInfo(application->getScenario()->getName());
122 IceGrid::ApplicationDescriptor appDescriptor = appInfo.descriptor;
125 appDescriptor.nodes[application->getEffectiveNodeName()].serverInstances.clear();
126 appDescriptor.nodes[application->getEffectiveNodeName()].serverInstances.push_back(serverInstanceDescriptor);
127 IceGrid::ApplicationUpdateDescriptor appUpdate = generator.generateUpdateDescriptor(appDescriptor);
128 admin->updateApplication(appUpdate);
132 ARMARX_INFO << application->getName() <<
" on node " << application->getEffectiveNodeName();
134 IceGrid::ApplicationDescriptor appDescriptor;
137 appDescriptor = generator.generateEmptyLocalApplicationDescriptor(application->getScenario(), admin);
141 appDescriptor = generator.generateEmptyRemoteApplicationDescriptor(application->getScenario(), admin);
143 appDescriptor.nodes[application->getEffectiveNodeName()].serverInstances.push_back(serverInstanceDescriptor);
144 admin->addApplication(appDescriptor);
150 application->setPid(admin->getServerPid(application->getName()));
155 application->setPid(-1);
164 scenario->setStatusWriteBlock(
false);
166 IceGridXmlGenerator generator;
168 IceGrid::ApplicationDescriptor appDescriptor;
171 appDescriptor = generator.generateLocalApplicationDescriptor(scenario, admin);
175 appDescriptor = generator.generateRemoteApplicationDescriptor(scenario, admin);
180 std::vector<std::string> appNames = admin->getAllApplicationNames();
181 std::vector<std::string> nodeNames = admin->getAllNodeNames();
182 for (
auto nodeName : scenario->getAllDeploymendNodeNames())
184 if (std::find(nodeNames.begin(), nodeNames.end(), nodeName) == nodeNames.end())
186 ARMARX_ERROR_S <<
"You are launching an Scenario with applications on an unlaunched Node. Either start the node or change the launch Nodes of the curresponding applications. Nodename is: " + nodeName;
188 throw IceGrid::DeploymentException(
"You are launching an Scenario with applications on an unlaunched Node. Either start the node or change the launch Nodes of the curresponding applications. Nodename is: " + nodeName);
192 if (std::find(appNames.begin(), appNames.end(), scenario->getName()) != appNames.end())
194 admin->updateApplication(generator.generateUpdateDescriptor(appDescriptor));
198 admin->addApplication(appDescriptor);
200 for (
auto& node : appDescriptor.nodes)
202 for (IceGrid::ServerInstanceDescriptor& server : node.second.serverInstances)
204 auto name = server.parameterValues[
"componentId"];
205 admin->enableServer(name,
false);
209 catch (IceGrid::AccessDeniedException& ex)
211 ARMARX_ERROR_S <<
"Error while deploying Scenario " << scenario->getName() <<
" another application has the accesss rights to the IceGridAdmin. (Please try again)";
214 catch (IceGrid::DeploymentException& ex)
227 std::vector<std::string> appNames = admin->getAllApplicationNames();
229 auto admin = this->admin;
236 scenario->setStatusWriteBlock(
false);
238 std::map<Data_Structure::ApplicationInstancePtr, ::Ice::AsyncResultPtr> asyncResultMap;
240 if (std::find(appNames.begin(), appNames.end(), scenario->getName()) != appNames.end())
242 for (
auto app : *scenario->getApplications())
247 if (admin->getServerState(appId) == IceGrid::ServerState::Inactive)
250 admin->enableServer(appId,
true);
252 asyncResultMap[app] = admin->begin_startServer(appId);
255 catch (IceGrid::ServerNotExistException& ex)
257 ARMARX_INFO_S <<
"Could not start Server " << appId <<
" because it is not existent";
259 catch (IceGrid::ServerStartException& ex)
261 ARMARX_INFO_S <<
"Could not start Server " << appId <<
" because it had an starting error. \nReason :" << ex.reason;
264 IceGridXmlGenerator generator;
265 ARMARX_INFO_S <<
"Often this is related to an unknown launching path. The ScenarioManager thinks to find the binary on the host of " << app->getEffectiveNodeName() <<
" at: " << generator.getDefaultSyncFile() <<
"/bin";
269 catch (IceGrid::NodeUnreachableException& ex)
271 ARMARX_INFO_S <<
"Could not start Server " << appId <<
" because the node is unreachable";
273 catch (IceGrid::DeploymentException& ex)
275 ARMARX_INFO_S <<
"Could not start Server " << appId <<
" because there was an deployment error";
278 for (
auto pair : asyncResultMap)
280 auto app = pair.first;
284 admin->end_startServer(pair.second);
288 catch (IceGrid::ServerNotExistException& ex)
290 ARMARX_INFO_S <<
"Could not start Server " << appId <<
" because it is not existent";
292 catch (IceGrid::ServerStartException& ex)
294 ARMARX_INFO_S <<
"Could not start Server " << appId <<
" because it had an starting error. \nReason :" << ex.reason;
297 IceGridXmlGenerator generator;
298 ARMARX_INFO_S <<
"Often this is related to an unknown launching path. The ScenarioManager thinks to find the binary on the host of " << app->getEffectiveNodeName() <<
" at: " << generator.getDefaultSyncFile() <<
"/bin";
302 catch (IceGrid::NodeUnreachableException& ex)
304 ARMARX_INFO_S <<
"Could not start Server " << appId <<
" because the node is unreachable";
306 catch (IceGrid::DeploymentException& ex)
308 ARMARX_INFO_S <<
"Could not start Server " << appId <<
" because there was an deployment error";
314 ARMARX_ERROR_S <<
"There is no deployed IceApplication for scenario " << scenario->getName() <<
" - please deploy it before starting";
321 for (
auto app : *scenario->getApplications())
326 ARMARX_INFO <<
" PID of " << app->getName() <<
" is " << app->getPid();
357 return statusReader.
getStatus(application);
364 std::vector<std::string> appNames = admin->getAllApplicationNames();
366 if (std::find(appNames.begin(), appNames.end(), application->getScenario()->getName()) != appNames.end())
368 IceGrid::ApplicationInfo info = admin->getApplicationInfo(application->getScenario()->getName());
369 IceGrid::ServerInstanceDescriptorSeq serverInstances = info.descriptor.nodes[application->getEffectiveNodeName()].serverInstances;
370 if (std::find_if(serverInstances.begin(), serverInstances.end(), [application](
const IceGrid::ServerInstanceDescriptor & d)
372 return d.parameterValues.at(
"component") == application->getName()
373 && d.parameterValues.at(
"componentId") == application->getInstanceName();
374 }) != serverInstances.end())
391 std::vector<std::string> appNames = admin->getAllApplicationNames();
393 if (std::find(appNames.begin(), appNames.end(), scenario->getName()) != appNames.end())