Project
Loading...
Searching...
No Matches
PrimaryServerState.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#include "PrimaryServerState.h"
13#include <SimConfig/SimConfig.h>
14#include <fairmq/Channel.h>
15#include <fairmq/Message.h>
16#include <fairlogger/Logger.h>
17#include <FairLogger.h>
18#include <memory>
19
20namespace o2
21{
22
23bool querySimConfig(fair::mq::Channel& channel)
24{
25 std::unique_ptr<fair::mq::Message> request(channel.NewSimpleMessage((int)O2PrimaryServerInfoRequest::Config));
26 std::unique_ptr<fair::mq::Message> reply(channel.NewMessage());
27
28 int timeoutinMS = 60000; // wait for 60s max --> should be fast reply
29 if (channel.Send(request, timeoutinMS) > 0) {
30 LOG(info) << "Waiting for configuration answer ";
31 if (channel.Receive(reply, timeoutinMS) > 0) {
32 LOG(info) << "Configuration answer received, containing " << reply->GetSize() << " bytes ";
33
34 // the answer is a TMessage containing the simulation Configuration
35 auto message = std::make_unique<TMessageWrapper>(reply->GetData(), reply->GetSize());
36 auto config = static_cast<o2::conf::SimConfigData*>(message.get()->ReadObjectAny(message.get()->GetClass()));
37 if (!config) {
38 return false;
39 }
40
41 LOG(info) << "COMMUNICATED ENGINE " << config->mMCEngine;
42
43 auto& conf = o2::conf::SimConfig::Instance();
44 conf.resetFromConfigData(*config);
45 FairLogger::GetLogger()->SetLogVerbosityLevel(conf.getLogVerbosity().c_str());
46 delete config;
47 } else {
48 LOG(error) << "No configuration received within " << timeoutinMS << "ms\n";
49 return false;
50 }
51 } else {
52 LOG(error) << "Could not send configuration request within " << timeoutinMS << "ms\n";
53 return false;
54 }
55 return true;
56}
57
58} // namespace o2
static SimConfig & Instance()
Definition SimConfig.h:112
GLuint GLsizei const GLchar * message
Definition glcorearb.h:2517
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
bool querySimConfig(fair::mq::Channel &channel)
std::string mMCEngine
Definition SimConfig.h:54
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"