Several FairMQ fixes and improvements:

- FairMQ: add possibility to poll on multiple channels.
- FairMQ: include command channel when polling on blocking calls (for unblocking without termination).
- FairMQ: move signal handler inside of FairMQDevice class (call FairMQDevice::CatchSignals() in the main function).
- FairMQ: add 'bool CheckCurrentState(statename)' (instead of 'GetCurrentState() == statename' that cannot be thread safe).
- FairMQDevice: add 'InteractiveStateLoop()' method that can be used to change states from the command line.
- FairMQDevice: add automatic transition to IDLE state if Run() exits without an external event.
- FairMQDevice: implement device reset.
- FairMQDevice: use unordered_map for device channels.
- FairMQChannel: improve address validation for channels.
- FairMQChannel: add ExpectsAnotherPart() method to check if another msg part is expected (old approach still works).
- FairMQ: remove invalid transition from the run files.
- FairMQFileSink: disable ROOT termination signal handler.
- Tutorial3: spawn xterm windows from start scripts without overlapping for better visibility.
- FairMQ Examples: update protobuf test and move its files to a common directory.
- FairMQStateMachine: improve feedback on invalid transitions (more readable).
This commit is contained in:
Alexey Rybalchenko
2015-07-03 22:57:36 +02:00
committed by Mohammad Al-Turany
parent d1bba61939
commit 1302e77a16
65 changed files with 1250 additions and 2234 deletions

View File

@@ -1,8 +1,8 @@
/********************************************************************************
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
* copied verbatim in the file "LICENSE" *
********************************************************************************/
/**
@@ -35,23 +35,16 @@ FairMQProtoSampler::~FairMQProtoSampler()
{
}
void FairMQProtoSampler::Init()
{
}
void FairMQProtoSampler::Run()
{
LOG(INFO) << ">>>>>>> Run <<<<<<<";
// boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
boost::thread resetEventCounter(boost::bind(&FairMQProtoSampler::ResetEventCounter, this));
srand(time(NULL));
while (fState == RUNNING)
{
const FairMQChannel& dataOutChannel = fChannels.at("data-out").at(0);
while (CheckCurrentState(RUNNING))
{
sampler::Payload p;
for (int i = 0; i < fEventSize; ++i)
@@ -73,7 +66,7 @@ void FairMQProtoSampler::Run()
FairMQMessage* msg = fTransportFactory->CreateMessage(size);
memcpy(msg->GetData(), str.c_str(), size);
fPayloadOutputs->at(0)->Send(msg);
dataOutChannel.Send(msg);
--fEventCounter;
@@ -85,10 +78,7 @@ void FairMQProtoSampler::Run()
delete msg;
}
rateLogger.interrupt();
resetEventCounter.interrupt();
rateLogger.join();
resetEventCounter.join();
}
@@ -108,61 +98,26 @@ void FairMQProtoSampler::ResetEventCounter()
}
}
void FairMQProtoSampler::Log(int intervalInMs)
{
timestamp_t t0;
timestamp_t t1;
unsigned long bytes = fPayloadOutputs->at(0)->GetBytesTx();
unsigned long messages = fPayloadOutputs->at(0)->GetMessagesTx();
unsigned long bytesNew = 0;
unsigned long messagesNew = 0;
double megabytesPerSecond = 0;
double messagesPerSecond = 0;
t0 = get_timestamp();
while (true)
{
boost::this_thread::sleep(boost::posix_time::milliseconds(intervalInMs));
t1 = get_timestamp();
bytesNew = fPayloadOutputs->at(0)->GetBytesTx();
messagesNew = fPayloadOutputs->at(0)->GetMessagesTx();
timestamp_t timeSinceLastLog_ms = (t1 - t0) / 1000.0L;
megabytesPerSecond = ((double)(bytesNew - bytes) / (1024. * 1024.)) / (double)timeSinceLastLog_ms * 1000.;
messagesPerSecond = (double)(messagesNew - messages) / (double)timeSinceLastLog_ms * 1000.;
LOG(DEBUG) << "send " << messagesPerSecond << " msg/s, " << megabytesPerSecond << " MB/s";
bytes = bytesNew;
messages = messagesNew;
t0 = t1;
}
}
void FairMQProtoSampler::SetProperty(const int key, const string& value, const int slot /*= 0*/)
void FairMQProtoSampler::SetProperty(const int key, const string& value)
{
switch (key)
{
default:
FairMQDevice::SetProperty(key, value, slot);
FairMQDevice::SetProperty(key, value);
break;
}
}
string FairMQProtoSampler::GetProperty(const int key, const string& default_ /*= ""*/, const int slot /*= 0*/)
string FairMQProtoSampler::GetProperty(const int key, const string& default_ /*= ""*/)
{
switch (key)
{
default:
return FairMQDevice::GetProperty(key, default_, slot);
return FairMQDevice::GetProperty(key, default_);
}
}
void FairMQProtoSampler::SetProperty(const int key, const int value, const int slot /*= 0*/)
void FairMQProtoSampler::SetProperty(const int key, const int value)
{
switch (key)
{
@@ -173,12 +128,12 @@ void FairMQProtoSampler::SetProperty(const int key, const int value, const int s
fEventRate = value;
break;
default:
FairMQDevice::SetProperty(key, value, slot);
FairMQDevice::SetProperty(key, value);
break;
}
}
int FairMQProtoSampler::GetProperty(const int key, const int default_ /*= 0*/, const int slot /*= 0*/)
int FairMQProtoSampler::GetProperty(const int key, const int default_ /*= 0*/)
{
switch (key)
{
@@ -187,6 +142,6 @@ int FairMQProtoSampler::GetProperty(const int key, const int default_ /*= 0*/, c
case EventRate:
return fEventRate;
default:
return FairMQDevice::GetProperty(key, default_, slot);
return FairMQDevice::GetProperty(key, default_);
}
}