mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 08:41:16 +00:00
Initialize initialization timeout in InitWrapper()
This commit is contained in:
parent
937c9e8921
commit
48e04b636b
|
@ -104,6 +104,7 @@ FairMQDevice::FairMQDevice(ProgOptions* config, const tools::Version version)
|
||||||
, fVersion(version)
|
, fVersion(version)
|
||||||
, fRate(DefaultRate)
|
, fRate(DefaultRate)
|
||||||
, fMaxRunRuntimeInS(DefaultMaxRunTime)
|
, fMaxRunRuntimeInS(DefaultMaxRunTime)
|
||||||
|
, fInitializationTimeoutInS(DefaultInitTimeout)
|
||||||
, fRawCmdLineArgs()
|
, fRawCmdLineArgs()
|
||||||
{
|
{
|
||||||
SubscribeToNewTransition("device", [&](Transition transition) {
|
SubscribeToNewTransition("device", [&](Transition transition) {
|
||||||
|
@ -204,6 +205,7 @@ void FairMQDevice::InitWrapper()
|
||||||
|
|
||||||
fRate = fConfig->GetProperty<float>("rate", DefaultRate);
|
fRate = fConfig->GetProperty<float>("rate", DefaultRate);
|
||||||
fMaxRunRuntimeInS = fConfig->GetProperty<uint64_t>("max-run-time", DefaultMaxRunTime);
|
fMaxRunRuntimeInS = fConfig->GetProperty<uint64_t>("max-run-time", DefaultMaxRunTime);
|
||||||
|
fInitializationTimeoutInS = fConfig->GetProperty<int>("init-timeout", DefaultInitTimeout);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fDefaultTransportType = fair::mq::TransportTypes.at(fConfig->GetProperty<string>("transport", DefaultTransportName));
|
fDefaultTransportType = fair::mq::TransportTypes.at(fConfig->GetProperty<string>("transport", DefaultTransportName));
|
||||||
|
@ -280,12 +282,10 @@ void FairMQDevice::BindWrapper()
|
||||||
|
|
||||||
void FairMQDevice::ConnectWrapper()
|
void FairMQDevice::ConnectWrapper()
|
||||||
{
|
{
|
||||||
int initializationTimeoutInS = fConfig->GetProperty<int>("init-timeout", DefaultInitTimeout);
|
|
||||||
|
|
||||||
// go over the list of channels until all are initialized (and removed from the uninitialized list)
|
// go over the list of channels until all are initialized (and removed from the uninitialized list)
|
||||||
int numAttempts = 1;
|
int numAttempts = 1;
|
||||||
auto sleepTimeInMS = 50;
|
auto sleepTimeInMS = 50;
|
||||||
auto maxAttempts = initializationTimeoutInS * 1000 / sleepTimeInMS;
|
auto maxAttempts = fInitializationTimeoutInS * 1000 / sleepTimeInMS;
|
||||||
// first attempt
|
// first attempt
|
||||||
AttachChannels(fUninitializedConnectingChannels);
|
AttachChannels(fUninitializedConnectingChannels);
|
||||||
// if not all channels could be connected, update their address values from config and retry
|
// if not all channels could be connected, update their address values from config and retry
|
||||||
|
@ -301,8 +301,8 @@ void FairMQDevice::ConnectWrapper()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numAttempts++ > maxAttempts) {
|
if (numAttempts++ > maxAttempts) {
|
||||||
LOG(error) << "could not connect all channels after " << initializationTimeoutInS << " attempts";
|
LOG(error) << "could not connect all channels after " << fInitializationTimeoutInS << " attempts";
|
||||||
throw runtime_error(tools::ToString("could not connect all channels after ", initializationTimeoutInS, " attempts"));
|
throw runtime_error(tools::ToString("could not connect all channels after ", fInitializationTimeoutInS, " attempts"));
|
||||||
}
|
}
|
||||||
|
|
||||||
AttachChannels(fUninitializedConnectingChannels);
|
AttachChannels(fUninitializedConnectingChannels);
|
||||||
|
|
|
@ -576,6 +576,7 @@ class FairMQDevice
|
||||||
const fair::mq::tools::Version fVersion;
|
const fair::mq::tools::Version fVersion;
|
||||||
float fRate; ///< Rate limiting for ConditionalRun
|
float fRate; ///< Rate limiting for ConditionalRun
|
||||||
uint64_t fMaxRunRuntimeInS; ///< Maximum runtime for the Running state handler, after which state will change to Ready (in seconds, 0 for no limit).
|
uint64_t fMaxRunRuntimeInS; ///< Maximum runtime for the Running state handler, after which state will change to Ready (in seconds, 0 for no limit).
|
||||||
|
int fInitializationTimeoutInS;
|
||||||
std::vector<std::string> fRawCmdLineArgs;
|
std::vector<std::string> fRawCmdLineArgs;
|
||||||
|
|
||||||
std::queue<fair::mq::State> fStates;
|
std::queue<fair::mq::State> fStates;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user