mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 08:41:16 +00:00
use clang-format for FairMQ
This commit is contained in:
parent
e80e6d4269
commit
68d51d8ed5
54
fairmq/.clang-format
Normal file
54
fairmq/.clang-format
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
#AccessModifierOffset: -4
|
||||||
|
ConstructorInitializerIndentWidth: 4
|
||||||
|
AlignEscapedNewlinesLeft: true
|
||||||
|
AlignTrailingComments: true
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: false
|
||||||
|
AllowShortIfStatementsOnASingleLine: false
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: false
|
||||||
|
AlwaysBreakTemplateDeclarations: true
|
||||||
|
|
||||||
|
# It is broken on windows. Breaks all #include "header.h"
|
||||||
|
#AlwaysBreakBeforeMultilineStrings: true
|
||||||
|
|
||||||
|
BreakBeforeBinaryOperators: false
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializersBeforeComma: true
|
||||||
|
BinPackParameters: false
|
||||||
|
ColumnLimit: 160
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||||
|
ConstructorInitializerIndentWidth: 4
|
||||||
|
DerivePointerBinding: false
|
||||||
|
ExperimentalAutoDetectBinPacking: false
|
||||||
|
IndentCaseLabels: true
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
NamespaceIndentation: All
|
||||||
|
ObjCSpaceAfterProperty: false
|
||||||
|
ObjCSpaceBeforeProtocolList: false
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 1
|
||||||
|
PenaltyBreakComment: 300
|
||||||
|
PenaltyBreakString: 1000
|
||||||
|
PenaltyBreakFirstLessLess: 120
|
||||||
|
PenaltyExcessCharacter: 1000000
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 200
|
||||||
|
PointerBindsToType: true
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
Cpp11BracedListStyle: false
|
||||||
|
Standard: Cpp11
|
||||||
|
IndentWidth: 4
|
||||||
|
TabWidth: 4
|
||||||
|
UseTab: Never
|
||||||
|
BreakBeforeBraces: Allman
|
||||||
|
IndentFunctionDeclarationAfterType: true
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInAngles: false
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInContainerLiterals: true
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
ContinuationIndentWidth: 4
|
||||||
|
CommentPragmas: '^ IWYU pragma:'
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
...
|
|
@ -13,11 +13,10 @@
|
||||||
#include "FairMQBenchmarkSampler.h"
|
#include "FairMQBenchmarkSampler.h"
|
||||||
#include "FairMQLogger.h"
|
#include "FairMQLogger.h"
|
||||||
|
|
||||||
|
FairMQBenchmarkSampler::FairMQBenchmarkSampler()
|
||||||
FairMQBenchmarkSampler::FairMQBenchmarkSampler() :
|
: fEventSize(10000)
|
||||||
fEventSize(10000),
|
, fEventRate(1)
|
||||||
fEventRate(1),
|
, fEventCounter(0)
|
||||||
fEventCounter(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,130 +26,141 @@ FairMQBenchmarkSampler::~FairMQBenchmarkSampler()
|
||||||
|
|
||||||
void FairMQBenchmarkSampler::Init()
|
void FairMQBenchmarkSampler::Init()
|
||||||
{
|
{
|
||||||
FairMQDevice::Init();
|
FairMQDevice::Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQBenchmarkSampler::Run()
|
void FairMQBenchmarkSampler::Run()
|
||||||
{
|
{
|
||||||
LOG(INFO) << ">>>>>>> Run <<<<<<<";
|
LOG(INFO) << ">>>>>>> Run <<<<<<<";
|
||||||
//boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
|
// boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
|
||||||
|
|
||||||
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
||||||
boost::thread resetEventCounter(boost::bind(&FairMQBenchmarkSampler::ResetEventCounter, this));
|
boost::thread resetEventCounter(boost::bind(&FairMQBenchmarkSampler::ResetEventCounter, this));
|
||||||
|
|
||||||
void* buffer = operator new[](fEventSize);
|
void* buffer = operator new[](fEventSize);
|
||||||
FairMQMessage* base_msg = fTransportFactory->CreateMessage(buffer, fEventSize);
|
FairMQMessage* base_msg = fTransportFactory->CreateMessage(buffer, fEventSize);
|
||||||
|
|
||||||
while ( fState == RUNNING ) {
|
while (fState == RUNNING)
|
||||||
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
{
|
||||||
msg->Copy(base_msg);
|
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
||||||
|
msg->Copy(base_msg);
|
||||||
|
|
||||||
fPayloadOutputs->at(0)->Send(msg);
|
fPayloadOutputs->at(0)->Send(msg);
|
||||||
|
|
||||||
--fEventCounter;
|
--fEventCounter;
|
||||||
|
|
||||||
while (fEventCounter == 0) {
|
while (fEventCounter == 0)
|
||||||
boost::this_thread::sleep(boost::posix_time::milliseconds(1));
|
{
|
||||||
|
boost::this_thread::sleep(boost::posix_time::milliseconds(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
delete msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete msg;
|
delete base_msg;
|
||||||
}
|
|
||||||
|
|
||||||
delete base_msg;
|
rateLogger.interrupt();
|
||||||
|
resetEventCounter.interrupt();
|
||||||
|
|
||||||
rateLogger.interrupt();
|
rateLogger.join();
|
||||||
resetEventCounter.interrupt();
|
resetEventCounter.join();
|
||||||
|
|
||||||
rateLogger.join();
|
|
||||||
resetEventCounter.join();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQBenchmarkSampler::ResetEventCounter()
|
void FairMQBenchmarkSampler::ResetEventCounter()
|
||||||
{
|
{
|
||||||
while ( true ) {
|
while (true)
|
||||||
try {
|
{
|
||||||
fEventCounter = fEventRate / 100;
|
try
|
||||||
boost::this_thread::sleep(boost::posix_time::milliseconds(10));
|
{
|
||||||
} catch (boost::thread_interrupted&) {
|
fEventCounter = fEventRate / 100;
|
||||||
break;
|
boost::this_thread::sleep(boost::posix_time::milliseconds(10));
|
||||||
|
}
|
||||||
|
catch (boost::thread_interrupted&)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQBenchmarkSampler::Log(int intervalInMs)
|
void FairMQBenchmarkSampler::Log(int intervalInMs)
|
||||||
{
|
{
|
||||||
timestamp_t t0;
|
timestamp_t t0;
|
||||||
timestamp_t t1;
|
timestamp_t t1;
|
||||||
unsigned long bytes = fPayloadOutputs->at(0)->GetBytesTx();
|
unsigned long bytes = fPayloadOutputs->at(0)->GetBytesTx();
|
||||||
unsigned long messages = fPayloadOutputs->at(0)->GetMessagesTx();
|
unsigned long messages = fPayloadOutputs->at(0)->GetMessagesTx();
|
||||||
unsigned long bytesNew = 0;
|
unsigned long bytesNew = 0;
|
||||||
unsigned long messagesNew = 0;
|
unsigned long messagesNew = 0;
|
||||||
double megabytesPerSecond = 0;
|
double megabytesPerSecond = 0;
|
||||||
double messagesPerSecond = 0;
|
double messagesPerSecond = 0;
|
||||||
|
|
||||||
t0 = get_timestamp();
|
t0 = get_timestamp();
|
||||||
|
|
||||||
while (true) {
|
while (true)
|
||||||
boost::this_thread::sleep(boost::posix_time::milliseconds(intervalInMs));
|
{
|
||||||
|
boost::this_thread::sleep(boost::posix_time::milliseconds(intervalInMs));
|
||||||
|
|
||||||
t1 = get_timestamp();
|
t1 = get_timestamp();
|
||||||
|
|
||||||
bytesNew = fPayloadOutputs->at(0)->GetBytesTx();
|
bytesNew = fPayloadOutputs->at(0)->GetBytesTx();
|
||||||
messagesNew = fPayloadOutputs->at(0)->GetMessagesTx();
|
messagesNew = fPayloadOutputs->at(0)->GetMessagesTx();
|
||||||
|
|
||||||
timestamp_t timeSinceLastLog_ms = (t1 - t0) / 1000.0L;
|
timestamp_t timeSinceLastLog_ms = (t1 - t0) / 1000.0L;
|
||||||
|
|
||||||
megabytesPerSecond = ((double) (bytesNew - bytes) / (1024. * 1024.)) / (double) timeSinceLastLog_ms * 1000.;
|
megabytesPerSecond = ((double)(bytesNew - bytes) / (1024. * 1024.)) / (double)timeSinceLastLog_ms * 1000.;
|
||||||
messagesPerSecond = (double) (messagesNew - messages) / (double) timeSinceLastLog_ms * 1000.;
|
messagesPerSecond = (double)(messagesNew - messages) / (double)timeSinceLastLog_ms * 1000.;
|
||||||
|
|
||||||
LOG(DEBUG) << "send " << messagesPerSecond << " msg/s, " << megabytesPerSecond << " MB/s";
|
LOG(DEBUG) << "send " << messagesPerSecond << " msg/s, " << megabytesPerSecond << " MB/s";
|
||||||
|
|
||||||
bytes = bytesNew;
|
bytes = bytesNew;
|
||||||
messages = messagesNew;
|
messages = messagesNew;
|
||||||
t0 = t1;
|
t0 = t1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQBenchmarkSampler::SetProperty(const int key, const string& value, const int slot/*= 0*/)
|
void FairMQBenchmarkSampler::SetProperty(const int key, const string& value, const int slot /*= 0*/)
|
||||||
{
|
{
|
||||||
switch (key) {
|
switch (key)
|
||||||
default:
|
{
|
||||||
FairMQDevice::SetProperty(key, value, slot);
|
default:
|
||||||
break;
|
FairMQDevice::SetProperty(key, value, slot);
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string FairMQBenchmarkSampler::GetProperty(const int key, const string& default_/*= ""*/, const int slot/*= 0*/)
|
string FairMQBenchmarkSampler::GetProperty(const int key, const string& default_ /*= ""*/, const int slot /*= 0*/)
|
||||||
{
|
{
|
||||||
switch (key) {
|
switch (key)
|
||||||
default:
|
{
|
||||||
return FairMQDevice::GetProperty(key, default_, slot);
|
default:
|
||||||
}
|
return FairMQDevice::GetProperty(key, default_, slot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQBenchmarkSampler::SetProperty(const int key, const int value, const int slot/*= 0*/)
|
void FairMQBenchmarkSampler::SetProperty(const int key, const int value, const int slot /*= 0*/)
|
||||||
{
|
{
|
||||||
switch (key) {
|
switch (key)
|
||||||
case EventSize:
|
{
|
||||||
fEventSize = value;
|
case EventSize:
|
||||||
break;
|
fEventSize = value;
|
||||||
case EventRate:
|
break;
|
||||||
fEventRate = value;
|
case EventRate:
|
||||||
break;
|
fEventRate = value;
|
||||||
default:
|
break;
|
||||||
FairMQDevice::SetProperty(key, value, slot);
|
default:
|
||||||
break;
|
FairMQDevice::SetProperty(key, value, slot);
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int FairMQBenchmarkSampler::GetProperty(const int key, const int default_/*= 0*/, const int slot/*= 0*/)
|
int FairMQBenchmarkSampler::GetProperty(const int key, const int default_ /*= 0*/, const int slot /*= 0*/)
|
||||||
{
|
{
|
||||||
switch (key) {
|
switch (key)
|
||||||
case EventSize:
|
{
|
||||||
return fEventSize;
|
case EventSize:
|
||||||
case EventRate:
|
return fEventSize;
|
||||||
return fEventRate;
|
case EventRate:
|
||||||
default:
|
return fEventRate;
|
||||||
return FairMQDevice::GetProperty(key, default_, slot);
|
default:
|
||||||
}
|
return FairMQDevice::GetProperty(key, default_, slot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,14 +16,15 @@
|
||||||
* Sampler to generate traffic for benchmarking.
|
* Sampler to generate traffic for benchmarking.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class FairMQBenchmarkSampler: public FairMQDevice
|
class FairMQBenchmarkSampler : public FairMQDevice
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum {
|
enum
|
||||||
InputFile = FairMQDevice::Last,
|
{
|
||||||
EventRate,
|
InputFile = FairMQDevice::Last,
|
||||||
EventSize,
|
EventRate,
|
||||||
Last
|
EventSize,
|
||||||
|
Last
|
||||||
};
|
};
|
||||||
FairMQBenchmarkSampler();
|
FairMQBenchmarkSampler();
|
||||||
virtual ~FairMQBenchmarkSampler();
|
virtual ~FairMQBenchmarkSampler();
|
||||||
|
|
|
@ -13,36 +13,36 @@
|
||||||
#include "FairMQBuffer.h"
|
#include "FairMQBuffer.h"
|
||||||
#include "FairMQLogger.h"
|
#include "FairMQLogger.h"
|
||||||
|
|
||||||
|
|
||||||
FairMQBuffer::FairMQBuffer()
|
FairMQBuffer::FairMQBuffer()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQBuffer::Run()
|
void FairMQBuffer::Run()
|
||||||
{
|
{
|
||||||
LOG(INFO) << ">>>>>>> Run <<<<<<<";
|
LOG(INFO) << ">>>>>>> Run <<<<<<<";
|
||||||
|
|
||||||
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
||||||
|
|
||||||
bool received = false;
|
bool received = false;
|
||||||
while ( fState == RUNNING ) {
|
while (fState == RUNNING)
|
||||||
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
{
|
||||||
|
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
||||||
|
|
||||||
received = fPayloadInputs->at(0)->Receive(msg);
|
received = fPayloadInputs->at(0)->Receive(msg);
|
||||||
|
|
||||||
if (received) {
|
if (received)
|
||||||
fPayloadOutputs->at(0)->Send(msg);
|
{
|
||||||
received = false;
|
fPayloadOutputs->at(0)->Send(msg);
|
||||||
|
received = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete msg;
|
rateLogger.interrupt();
|
||||||
}
|
rateLogger.join();
|
||||||
|
|
||||||
rateLogger.interrupt();
|
|
||||||
rateLogger.join();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQBuffer::~FairMQBuffer()
|
FairMQBuffer::~FairMQBuffer()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,12 @@
|
||||||
|
|
||||||
#include "FairMQDevice.h"
|
#include "FairMQDevice.h"
|
||||||
|
|
||||||
|
class FairMQBuffer : public FairMQDevice
|
||||||
class FairMQBuffer: public FairMQDevice
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FairMQBuffer();
|
FairMQBuffer();
|
||||||
virtual ~FairMQBuffer();
|
virtual ~FairMQBuffer();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Run();
|
virtual void Run();
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,27 +7,26 @@
|
||||||
|
|
||||||
#include "FairMQConfigurable.h"
|
#include "FairMQConfigurable.h"
|
||||||
|
|
||||||
|
|
||||||
FairMQConfigurable::FairMQConfigurable()
|
FairMQConfigurable::FairMQConfigurable()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQConfigurable::SetProperty(const int key, const string& value, const int slot/*= 0*/)
|
void FairMQConfigurable::SetProperty(const int key, const string& value, const int slot /*= 0*/)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
string FairMQConfigurable::GetProperty(const int key, const string& default_/*= ""*/, const int slot/*= 0*/)
|
string FairMQConfigurable::GetProperty(const int key, const string& default_ /*= ""*/, const int slot /*= 0*/)
|
||||||
{
|
{
|
||||||
return default_;
|
return default_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQConfigurable::SetProperty(const int key, const int value, const int slot/*= 0*/)
|
void FairMQConfigurable::SetProperty(const int key, const int value, const int slot /*= 0*/)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int FairMQConfigurable::GetProperty(const int key, const int default_/*= 0*/, const int slot/*= 0*/)
|
int FairMQConfigurable::GetProperty(const int key, const int default_ /*= 0*/, const int slot /*= 0*/)
|
||||||
{
|
{
|
||||||
return default_;
|
return default_;
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQConfigurable::~FairMQConfigurable()
|
FairMQConfigurable::~FairMQConfigurable()
|
||||||
|
|
|
@ -15,8 +15,9 @@ using std::string;
|
||||||
class FairMQConfigurable
|
class FairMQConfigurable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum {
|
enum
|
||||||
Last = 1
|
{
|
||||||
|
Last = 1
|
||||||
};
|
};
|
||||||
FairMQConfigurable();
|
FairMQConfigurable();
|
||||||
virtual void SetProperty(const int key, const string& value, const int slot = 0);
|
virtual void SetProperty(const int key, const string& value, const int slot = 0);
|
||||||
|
|
|
@ -11,12 +11,13 @@
|
||||||
#include "FairMQDevice.h"
|
#include "FairMQDevice.h"
|
||||||
#include "FairMQLogger.h"
|
#include "FairMQLogger.h"
|
||||||
|
|
||||||
FairMQDevice::FairMQDevice() :
|
FairMQDevice::FairMQDevice()
|
||||||
fNumIoThreads(1),
|
: fNumIoThreads(1)
|
||||||
//fPayloadContext(NULL),
|
,
|
||||||
fPayloadInputs(new vector<FairMQSocket*>()),
|
// fPayloadContext(NULL),
|
||||||
fPayloadOutputs(new vector<FairMQSocket*>()),
|
fPayloadInputs(new vector<FairMQSocket*>())
|
||||||
fLogIntervalInMs(1000)
|
, fPayloadOutputs(new vector<FairMQSocket*>())
|
||||||
|
, fLogIntervalInMs(1000)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +73,6 @@ void FairMQDevice::InitInput()
|
||||||
}
|
}
|
||||||
} catch (std::out_of_range& e) {
|
} catch (std::out_of_range& e) {
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQDevice::InitOutput()
|
void FairMQDevice::InitOutput()
|
||||||
|
@ -95,7 +95,6 @@ void FairMQDevice::InitOutput()
|
||||||
}
|
}
|
||||||
} catch (std::out_of_range& e) {
|
} catch (std::out_of_range& e) {
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQDevice::Run()
|
void FairMQDevice::Run()
|
||||||
|
@ -107,268 +106,280 @@ void FairMQDevice::Pause()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method for setting properties represented as a string.
|
// Method for setting properties represented as a string.
|
||||||
void FairMQDevice::SetProperty(const int key, const string& value, const int slot/*= 0*/)
|
void FairMQDevice::SetProperty(const int key, const string& value, const int slot /*= 0*/)
|
||||||
{
|
{
|
||||||
switch (key) {
|
switch (key)
|
||||||
case Id:
|
{
|
||||||
fId = value;
|
case Id:
|
||||||
break;
|
fId = value;
|
||||||
case InputAddress:
|
break;
|
||||||
fInputAddress->erase(fInputAddress->begin() + slot);
|
case InputAddress:
|
||||||
fInputAddress->insert(fInputAddress->begin() + slot, value);
|
fInputAddress->erase(fInputAddress->begin() + slot);
|
||||||
break;
|
fInputAddress->insert(fInputAddress->begin() + slot, value);
|
||||||
case OutputAddress:
|
break;
|
||||||
fOutputAddress->erase(fOutputAddress->begin() + slot);
|
case OutputAddress:
|
||||||
fOutputAddress->insert(fOutputAddress->begin() + slot, value);
|
fOutputAddress->erase(fOutputAddress->begin() + slot);
|
||||||
break;
|
fOutputAddress->insert(fOutputAddress->begin() + slot, value);
|
||||||
case InputMethod:
|
break;
|
||||||
fInputMethod->erase(fInputMethod->begin() + slot);
|
case InputMethod:
|
||||||
fInputMethod->insert(fInputMethod->begin() + slot, value);
|
fInputMethod->erase(fInputMethod->begin() + slot);
|
||||||
break;
|
fInputMethod->insert(fInputMethod->begin() + slot, value);
|
||||||
case OutputMethod:
|
break;
|
||||||
fOutputMethod->erase(fOutputMethod->begin() + slot);
|
case OutputMethod:
|
||||||
fOutputMethod->insert(fOutputMethod->begin() + slot, value);
|
fOutputMethod->erase(fOutputMethod->begin() + slot);
|
||||||
break;
|
fOutputMethod->insert(fOutputMethod->begin() + slot, value);
|
||||||
case InputSocketType:
|
break;
|
||||||
fInputSocketType->erase(fInputSocketType->begin() + slot);
|
case InputSocketType:
|
||||||
fInputSocketType->insert(fInputSocketType->begin() + slot, value);
|
fInputSocketType->erase(fInputSocketType->begin() + slot);
|
||||||
break;
|
fInputSocketType->insert(fInputSocketType->begin() + slot, value);
|
||||||
case OutputSocketType:
|
break;
|
||||||
fOutputSocketType->erase(fOutputSocketType->begin() + slot);
|
case OutputSocketType:
|
||||||
fOutputSocketType->insert(fOutputSocketType->begin() + slot, value);
|
fOutputSocketType->erase(fOutputSocketType->begin() + slot);
|
||||||
break;
|
fOutputSocketType->insert(fOutputSocketType->begin() + slot, value);
|
||||||
default:
|
break;
|
||||||
FairMQConfigurable::SetProperty(key, value, slot);
|
default:
|
||||||
break;
|
FairMQConfigurable::SetProperty(key, value, slot);
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method for setting properties represented as an integer.
|
// Method for setting properties represented as an integer.
|
||||||
void FairMQDevice::SetProperty(const int key, const int value, const int slot/*= 0*/)
|
void FairMQDevice::SetProperty(const int key, const int value, const int slot /*= 0*/)
|
||||||
{
|
{
|
||||||
switch (key) {
|
switch (key)
|
||||||
case NumIoThreads:
|
{
|
||||||
fNumIoThreads = value;
|
case NumIoThreads:
|
||||||
break;
|
fNumIoThreads = value;
|
||||||
case NumInputs:
|
break;
|
||||||
fNumInputs = value;
|
case NumInputs:
|
||||||
break;
|
fNumInputs = value;
|
||||||
case NumOutputs:
|
break;
|
||||||
fNumOutputs = value;
|
case NumOutputs:
|
||||||
break;
|
fNumOutputs = value;
|
||||||
case LogIntervalInMs:
|
break;
|
||||||
fLogIntervalInMs = value;
|
case LogIntervalInMs:
|
||||||
break;
|
fLogIntervalInMs = value;
|
||||||
case InputSndBufSize:
|
break;
|
||||||
fInputSndBufSize->erase(fInputSndBufSize->begin() + slot);
|
case InputSndBufSize:
|
||||||
fInputSndBufSize->insert(fInputSndBufSize->begin() + slot, value);
|
fInputSndBufSize->erase(fInputSndBufSize->begin() + slot);
|
||||||
break;
|
fInputSndBufSize->insert(fInputSndBufSize->begin() + slot, value);
|
||||||
case InputRcvBufSize:
|
break;
|
||||||
fInputRcvBufSize->erase(fInputRcvBufSize->begin() + slot);
|
case InputRcvBufSize:
|
||||||
fInputRcvBufSize->insert(fInputRcvBufSize->begin() + slot, value);
|
fInputRcvBufSize->erase(fInputRcvBufSize->begin() + slot);
|
||||||
break;
|
fInputRcvBufSize->insert(fInputRcvBufSize->begin() + slot, value);
|
||||||
case OutputSndBufSize:
|
break;
|
||||||
fOutputSndBufSize->erase(fOutputSndBufSize->begin() + slot);
|
case OutputSndBufSize:
|
||||||
fOutputSndBufSize->insert(fOutputSndBufSize->begin() + slot, value);
|
fOutputSndBufSize->erase(fOutputSndBufSize->begin() + slot);
|
||||||
break;
|
fOutputSndBufSize->insert(fOutputSndBufSize->begin() + slot, value);
|
||||||
case OutputRcvBufSize:
|
break;
|
||||||
fOutputRcvBufSize->erase(fOutputRcvBufSize->begin() + slot);
|
case OutputRcvBufSize:
|
||||||
fOutputRcvBufSize->insert(fOutputRcvBufSize->begin() + slot, value);
|
fOutputRcvBufSize->erase(fOutputRcvBufSize->begin() + slot);
|
||||||
break;
|
fOutputRcvBufSize->insert(fOutputRcvBufSize->begin() + slot, value);
|
||||||
default:
|
break;
|
||||||
FairMQConfigurable::SetProperty(key, value, slot);
|
default:
|
||||||
break;
|
FairMQConfigurable::SetProperty(key, value, slot);
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method for getting properties represented as an string.
|
// Method for getting properties represented as an string.
|
||||||
string FairMQDevice::GetProperty(const int key, const string& default_/*= ""*/, const int slot/*= 0*/)
|
string FairMQDevice::GetProperty(const int key, const string& default_ /*= ""*/, const int slot /*= 0*/)
|
||||||
{
|
{
|
||||||
switch (key) {
|
switch (key)
|
||||||
case Id:
|
{
|
||||||
return fId;
|
case Id:
|
||||||
case InputAddress:
|
return fId;
|
||||||
return fInputAddress->at(slot);
|
case InputAddress:
|
||||||
case OutputAddress:
|
return fInputAddress->at(slot);
|
||||||
return fOutputAddress->at(slot);
|
case OutputAddress:
|
||||||
case InputMethod:
|
return fOutputAddress->at(slot);
|
||||||
return fInputMethod->at(slot);
|
case InputMethod:
|
||||||
case OutputMethod:
|
return fInputMethod->at(slot);
|
||||||
return fOutputMethod->at(slot);
|
case OutputMethod:
|
||||||
case InputSocketType:
|
return fOutputMethod->at(slot);
|
||||||
return fInputSocketType->at(slot);
|
case InputSocketType:
|
||||||
case OutputSocketType:
|
return fInputSocketType->at(slot);
|
||||||
return fOutputSocketType->at(slot);
|
case OutputSocketType:
|
||||||
default:
|
return fOutputSocketType->at(slot);
|
||||||
return FairMQConfigurable::GetProperty(key, default_, slot);
|
default:
|
||||||
}
|
return FairMQConfigurable::GetProperty(key, default_, slot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method for getting properties represented as an integer.
|
// Method for getting properties represented as an integer.
|
||||||
int FairMQDevice::GetProperty(const int key, const int default_/*= 0*/, const int slot/*= 0*/)
|
int FairMQDevice::GetProperty(const int key, const int default_ /*= 0*/, const int slot /*= 0*/)
|
||||||
{
|
{
|
||||||
switch (key) {
|
switch (key)
|
||||||
case NumIoThreads:
|
{
|
||||||
return fNumIoThreads;
|
case NumIoThreads:
|
||||||
case LogIntervalInMs:
|
return fNumIoThreads;
|
||||||
return fLogIntervalInMs;
|
case LogIntervalInMs:
|
||||||
case InputSndBufSize:
|
return fLogIntervalInMs;
|
||||||
return fInputSndBufSize->at(slot);
|
case InputSndBufSize:
|
||||||
case InputRcvBufSize:
|
return fInputSndBufSize->at(slot);
|
||||||
return fInputRcvBufSize->at(slot);
|
case InputRcvBufSize:
|
||||||
case OutputSndBufSize:
|
return fInputRcvBufSize->at(slot);
|
||||||
return fOutputSndBufSize->at(slot);
|
case OutputSndBufSize:
|
||||||
case OutputRcvBufSize:
|
return fOutputSndBufSize->at(slot);
|
||||||
return fOutputRcvBufSize->at(slot);
|
case OutputRcvBufSize:
|
||||||
default:
|
return fOutputRcvBufSize->at(slot);
|
||||||
return FairMQConfigurable::GetProperty(key, default_, slot);
|
default:
|
||||||
}
|
return FairMQConfigurable::GetProperty(key, default_, slot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQDevice::SetTransport(FairMQTransportFactory* factory)
|
void FairMQDevice::SetTransport(FairMQTransportFactory* factory)
|
||||||
{
|
{
|
||||||
fTransportFactory = factory;
|
fTransportFactory = factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQDevice::LogSocketRates()
|
void FairMQDevice::LogSocketRates()
|
||||||
{
|
{
|
||||||
timestamp_t t0;
|
timestamp_t t0;
|
||||||
timestamp_t t1;
|
timestamp_t t1;
|
||||||
|
|
||||||
timestamp_t timeSinceLastLog_ms;
|
timestamp_t timeSinceLastLog_ms;
|
||||||
|
|
||||||
unsigned long* bytesInput = new unsigned long[fNumInputs];
|
unsigned long* bytesInput = new unsigned long[fNumInputs];
|
||||||
unsigned long* messagesInput = new unsigned long[fNumInputs];
|
unsigned long* messagesInput = new unsigned long[fNumInputs];
|
||||||
unsigned long* bytesOutput = new unsigned long[fNumOutputs];
|
unsigned long* bytesOutput = new unsigned long[fNumOutputs];
|
||||||
unsigned long* messagesOutput = new unsigned long[fNumOutputs];
|
unsigned long* messagesOutput = new unsigned long[fNumOutputs];
|
||||||
|
|
||||||
unsigned long* bytesInputNew = new unsigned long[fNumInputs];
|
unsigned long* bytesInputNew = new unsigned long[fNumInputs];
|
||||||
unsigned long* messagesInputNew = new unsigned long[fNumInputs];
|
unsigned long* messagesInputNew = new unsigned long[fNumInputs];
|
||||||
unsigned long* bytesOutputNew = new unsigned long[fNumOutputs];
|
unsigned long* bytesOutputNew = new unsigned long[fNumOutputs];
|
||||||
unsigned long* messagesOutputNew = new unsigned long[fNumOutputs];
|
unsigned long* messagesOutputNew = new unsigned long[fNumOutputs];
|
||||||
|
|
||||||
double* megabytesPerSecondInput = new double[fNumInputs];
|
double* megabytesPerSecondInput = new double[fNumInputs];
|
||||||
double* messagesPerSecondInput = new double[fNumInputs];
|
double* messagesPerSecondInput = new double[fNumInputs];
|
||||||
double* megabytesPerSecondOutput = new double[fNumOutputs];
|
double* megabytesPerSecondOutput = new double[fNumOutputs];
|
||||||
double* messagesPerSecondOutput = new double[fNumOutputs];
|
double* messagesPerSecondOutput = new double[fNumOutputs];
|
||||||
|
|
||||||
// Temp stuff for process termination
|
// Temp stuff for process termination
|
||||||
// bool receivedSomething = false;
|
// bool receivedSomething = false;
|
||||||
// bool sentSomething = false;
|
// bool sentSomething = false;
|
||||||
// int didNotReceiveFor = 0;
|
// int didNotReceiveFor = 0;
|
||||||
// int didNotSendFor = 0;
|
// int didNotSendFor = 0;
|
||||||
// End of temp stuff
|
// End of temp stuff
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
for ( vector<FairMQSocket*>::iterator itr = fPayloadInputs->begin(); itr != fPayloadInputs->end(); itr++ ) {
|
|
||||||
bytesInput[i] = (*itr)->GetBytesRx();
|
|
||||||
messagesInput[i] = (*itr)->GetMessagesRx();
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
for ( vector<FairMQSocket*>::iterator itr = fPayloadOutputs->begin(); itr != fPayloadOutputs->end(); itr++ ) {
|
|
||||||
bytesOutput[i] = (*itr)->GetBytesTx();
|
|
||||||
messagesOutput[i] = (*itr)->GetMessagesTx();
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
|
|
||||||
t0 = get_timestamp();
|
|
||||||
|
|
||||||
while ( true ) {
|
|
||||||
try {
|
|
||||||
t1 = get_timestamp();
|
|
||||||
|
|
||||||
timeSinceLastLog_ms = (t1 - t0) / 1000.0L;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
|
|
||||||
for ( vector<FairMQSocket*>::iterator itr = fPayloadInputs->begin(); itr != fPayloadInputs->end(); itr++ ) {
|
|
||||||
bytesInputNew[i] = (*itr)->GetBytesRx();
|
|
||||||
megabytesPerSecondInput[i] = ((double) (bytesInputNew[i] - bytesInput[i]) / (1024. * 1024.)) / (double) timeSinceLastLog_ms * 1000.;
|
|
||||||
bytesInput[i] = bytesInputNew[i];
|
|
||||||
messagesInputNew[i] = (*itr)->GetMessagesRx();
|
|
||||||
messagesPerSecondInput[i] = (double) (messagesInputNew[i] - messagesInput[i]) / (double) timeSinceLastLog_ms * 1000.;
|
|
||||||
messagesInput[i] = messagesInputNew[i];
|
|
||||||
|
|
||||||
LOG(DEBUG) << "#" << fId << "." << (*itr)->GetId() << ": " << messagesPerSecondInput[i] << " msg/s, " << megabytesPerSecondInput[i] << " MB/s";
|
|
||||||
|
|
||||||
// Temp stuff for process termination
|
|
||||||
// if ( !receivedSomething && messagesPerSecondInput[i] > 0 ) {
|
|
||||||
// receivedSomething = true;
|
|
||||||
// }
|
|
||||||
// if ( receivedSomething && messagesPerSecondInput[i] == 0 ) {
|
|
||||||
// cout << "Did not receive anything on socket " << i << " for " << didNotReceiveFor++ << " seconds." << endl;
|
|
||||||
// } else {
|
|
||||||
// didNotReceiveFor = 0;
|
|
||||||
// }
|
|
||||||
// End of temp stuff
|
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for (vector<FairMQSocket*>::iterator itr = fPayloadInputs->begin(); itr != fPayloadInputs->end(); itr++)
|
||||||
|
{
|
||||||
|
bytesInput[i] = (*itr)->GetBytesRx();
|
||||||
|
messagesInput[i] = (*itr)->GetMessagesRx();
|
||||||
++i;
|
++i;
|
||||||
}
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
|
|
||||||
for ( vector<FairMQSocket*>::iterator itr = fPayloadOutputs->begin(); itr != fPayloadOutputs->end(); itr++ )
|
|
||||||
{
|
|
||||||
bytesOutputNew[i] = (*itr)->GetBytesTx();
|
|
||||||
megabytesPerSecondOutput[i] = ((double) (bytesOutputNew[i] - bytesOutput[i]) / (1024. * 1024.)) / (double) timeSinceLastLog_ms * 1000.;
|
|
||||||
bytesOutput[i] = bytesOutputNew[i];
|
|
||||||
messagesOutputNew[i] = (*itr)->GetMessagesTx();
|
|
||||||
messagesPerSecondOutput[i] = (double) (messagesOutputNew[i] - messagesOutput[i]) / (double) timeSinceLastLog_ms * 1000.;
|
|
||||||
messagesOutput[i] = messagesOutputNew[i];
|
|
||||||
|
|
||||||
LOG(DEBUG) << "#" << fId << "." << (*itr)->GetId() << ": " << messagesPerSecondOutput[i] << " msg/s, " << megabytesPerSecondOutput[i] << " MB/s";
|
|
||||||
|
|
||||||
// Temp stuff for process termination
|
|
||||||
// if ( !sentSomething && messagesPerSecondOutput[i] > 0 ) {
|
|
||||||
// sentSomething = true;
|
|
||||||
// }
|
|
||||||
// if ( sentSomething && messagesPerSecondOutput[i] == 0 ) {
|
|
||||||
// cout << "Did not send anything on socket " << i << " for " << didNotSendFor++ << " seconds." << endl;
|
|
||||||
// } else {
|
|
||||||
// didNotSendFor = 0;
|
|
||||||
// }
|
|
||||||
// End of temp stuff
|
|
||||||
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Temp stuff for process termination
|
|
||||||
// if (receivedSomething && didNotReceiveFor > 5) {
|
|
||||||
// cout << "stopping because nothing was received for 5 seconds." << endl;
|
|
||||||
// ChangeState(STOP);
|
|
||||||
// }
|
|
||||||
// if (sentSomething && didNotSendFor > 5) {
|
|
||||||
// cout << "stopping because nothing was sent for 5 seconds." << endl;
|
|
||||||
// ChangeState(STOP);
|
|
||||||
// }
|
|
||||||
// End of temp stuff
|
|
||||||
|
|
||||||
t0 = t1;
|
|
||||||
boost::this_thread::sleep(boost::posix_time::milliseconds(fLogIntervalInMs));
|
|
||||||
} catch (boost::thread_interrupted&) {
|
|
||||||
cout << "rateLogger interrupted" << endl;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
delete[] bytesInput;
|
i = 0;
|
||||||
delete[] messagesInput;
|
for (vector<FairMQSocket*>::iterator itr = fPayloadOutputs->begin(); itr != fPayloadOutputs->end(); itr++)
|
||||||
delete[] bytesOutput;
|
{
|
||||||
delete[] messagesOutput;
|
bytesOutput[i] = (*itr)->GetBytesTx();
|
||||||
|
messagesOutput[i] = (*itr)->GetMessagesTx();
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
delete[] bytesInputNew;
|
t0 = get_timestamp();
|
||||||
delete[] messagesInputNew;
|
|
||||||
delete[] bytesOutputNew;
|
|
||||||
delete[] messagesOutputNew;
|
|
||||||
|
|
||||||
delete[] megabytesPerSecondInput;
|
while (true)
|
||||||
delete[] messagesPerSecondInput;
|
{
|
||||||
delete[] megabytesPerSecondOutput;
|
try
|
||||||
delete[] messagesPerSecondOutput;
|
{
|
||||||
|
t1 = get_timestamp();
|
||||||
|
|
||||||
LOG(INFO) << ">>>>>>> stopping rateLogger <<<<<<<";
|
timeSinceLastLog_ms = (t1 - t0) / 1000.0L;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
|
||||||
|
for (vector<FairMQSocket*>::iterator itr = fPayloadInputs->begin(); itr != fPayloadInputs->end(); itr++)
|
||||||
|
{
|
||||||
|
bytesInputNew[i] = (*itr)->GetBytesRx();
|
||||||
|
megabytesPerSecondInput[i] = ((double)(bytesInputNew[i] - bytesInput[i]) / (1024. * 1024.)) / (double)timeSinceLastLog_ms * 1000.;
|
||||||
|
bytesInput[i] = bytesInputNew[i];
|
||||||
|
messagesInputNew[i] = (*itr)->GetMessagesRx();
|
||||||
|
messagesPerSecondInput[i] = (double)(messagesInputNew[i] - messagesInput[i]) / (double)timeSinceLastLog_ms * 1000.;
|
||||||
|
messagesInput[i] = messagesInputNew[i];
|
||||||
|
|
||||||
|
LOG(DEBUG) << "#" << fId << "." << (*itr)->GetId() << ": " << messagesPerSecondInput[i] << " msg/s, " << megabytesPerSecondInput[i] << " MB/s";
|
||||||
|
|
||||||
|
// Temp stuff for process termination
|
||||||
|
// if ( !receivedSomething && messagesPerSecondInput[i] > 0 ) {
|
||||||
|
// receivedSomething = true;
|
||||||
|
// }
|
||||||
|
// if ( receivedSomething && messagesPerSecondInput[i] == 0 ) {
|
||||||
|
// cout << "Did not receive anything on socket " << i << " for " << didNotReceiveFor++ << " seconds." << endl;
|
||||||
|
// } else {
|
||||||
|
// didNotReceiveFor = 0;
|
||||||
|
// }
|
||||||
|
// End of temp stuff
|
||||||
|
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
|
||||||
|
for (vector<FairMQSocket*>::iterator itr = fPayloadOutputs->begin(); itr != fPayloadOutputs->end(); itr++)
|
||||||
|
{
|
||||||
|
bytesOutputNew[i] = (*itr)->GetBytesTx();
|
||||||
|
megabytesPerSecondOutput[i] = ((double)(bytesOutputNew[i] - bytesOutput[i]) / (1024. * 1024.)) / (double)timeSinceLastLog_ms * 1000.;
|
||||||
|
bytesOutput[i] = bytesOutputNew[i];
|
||||||
|
messagesOutputNew[i] = (*itr)->GetMessagesTx();
|
||||||
|
messagesPerSecondOutput[i] = (double)(messagesOutputNew[i] - messagesOutput[i]) / (double)timeSinceLastLog_ms * 1000.;
|
||||||
|
messagesOutput[i] = messagesOutputNew[i];
|
||||||
|
|
||||||
|
LOG(DEBUG) << "#" << fId << "." << (*itr)->GetId() << ": " << messagesPerSecondOutput[i] << " msg/s, " << megabytesPerSecondOutput[i]
|
||||||
|
<< " MB/s";
|
||||||
|
|
||||||
|
// Temp stuff for process termination
|
||||||
|
// if ( !sentSomething && messagesPerSecondOutput[i] > 0 ) {
|
||||||
|
// sentSomething = true;
|
||||||
|
// }
|
||||||
|
// if ( sentSomething && messagesPerSecondOutput[i] == 0 ) {
|
||||||
|
// cout << "Did not send anything on socket " << i << " for " << didNotSendFor++ << " seconds." << endl;
|
||||||
|
// } else {
|
||||||
|
// didNotSendFor = 0;
|
||||||
|
// }
|
||||||
|
// End of temp stuff
|
||||||
|
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Temp stuff for process termination
|
||||||
|
// if (receivedSomething && didNotReceiveFor > 5) {
|
||||||
|
// cout << "stopping because nothing was received for 5 seconds." << endl;
|
||||||
|
// ChangeState(STOP);
|
||||||
|
// }
|
||||||
|
// if (sentSomething && didNotSendFor > 5) {
|
||||||
|
// cout << "stopping because nothing was sent for 5 seconds." << endl;
|
||||||
|
// ChangeState(STOP);
|
||||||
|
// }
|
||||||
|
// End of temp stuff
|
||||||
|
|
||||||
|
t0 = t1;
|
||||||
|
boost::this_thread::sleep(boost::posix_time::milliseconds(fLogIntervalInMs));
|
||||||
|
}
|
||||||
|
catch (boost::thread_interrupted&)
|
||||||
|
{
|
||||||
|
cout << "rateLogger interrupted" << endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delete[] bytesInput;
|
||||||
|
delete[] messagesInput;
|
||||||
|
delete[] bytesOutput;
|
||||||
|
delete[] messagesOutput;
|
||||||
|
|
||||||
|
delete[] bytesInputNew;
|
||||||
|
delete[] messagesInputNew;
|
||||||
|
delete[] bytesOutputNew;
|
||||||
|
delete[] messagesOutputNew;
|
||||||
|
|
||||||
|
delete[] megabytesPerSecondInput;
|
||||||
|
delete[] messagesPerSecondInput;
|
||||||
|
delete[] megabytesPerSecondOutput;
|
||||||
|
delete[] messagesPerSecondOutput;
|
||||||
|
|
||||||
|
LOG(INFO) << ">>>>>>> stopping rateLogger <<<<<<<";
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQDevice::ListenToCommands()
|
void FairMQDevice::ListenToCommands()
|
||||||
|
@ -377,33 +388,36 @@ void FairMQDevice::ListenToCommands()
|
||||||
|
|
||||||
void FairMQDevice::Shutdown()
|
void FairMQDevice::Shutdown()
|
||||||
{
|
{
|
||||||
LOG(INFO) << ">>>>>>> closing inputs <<<<<<<";
|
LOG(INFO) << ">>>>>>> closing inputs <<<<<<<";
|
||||||
for( vector<FairMQSocket*>::iterator itr = fPayloadInputs->begin(); itr != fPayloadInputs->end(); itr++ ) {
|
for (vector<FairMQSocket*>::iterator itr = fPayloadInputs->begin(); itr != fPayloadInputs->end(); itr++)
|
||||||
(*itr)->Close();
|
{
|
||||||
}
|
(*itr)->Close();
|
||||||
|
}
|
||||||
|
|
||||||
LOG(INFO) << ">>>>>>> closing outputs <<<<<<<";
|
LOG(INFO) << ">>>>>>> closing outputs <<<<<<<";
|
||||||
for( vector<FairMQSocket*>::iterator itr = fPayloadOutputs->begin(); itr != fPayloadOutputs->end(); itr++ ) {
|
for (vector<FairMQSocket*>::iterator itr = fPayloadOutputs->begin(); itr != fPayloadOutputs->end(); itr++)
|
||||||
(*itr)->Close();
|
{
|
||||||
}
|
(*itr)->Close();
|
||||||
|
}
|
||||||
|
|
||||||
// LOG(INFO) << ">>>>>>> closing context <<<<<<<";
|
// LOG(INFO) << ">>>>>>> closing context <<<<<<<";
|
||||||
// fPayloadContext->Close();
|
// fPayloadContext->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQDevice::~FairMQDevice()
|
FairMQDevice::~FairMQDevice()
|
||||||
{
|
{
|
||||||
for( vector<FairMQSocket*>::iterator itr = fPayloadInputs->begin(); itr != fPayloadInputs->end(); itr++ ) {
|
for (vector<FairMQSocket*>::iterator itr = fPayloadInputs->begin(); itr != fPayloadInputs->end(); itr++)
|
||||||
delete (*itr);
|
{
|
||||||
}
|
delete (*itr);
|
||||||
|
}
|
||||||
|
|
||||||
for( vector<FairMQSocket*>::iterator itr = fPayloadOutputs->begin(); itr != fPayloadOutputs->end(); itr++ ) {
|
for (vector<FairMQSocket*>::iterator itr = fPayloadOutputs->begin(); itr != fPayloadOutputs->end(); itr++)
|
||||||
delete (*itr);
|
{
|
||||||
}
|
delete (*itr);
|
||||||
|
}
|
||||||
|
|
||||||
delete fInputAddress;
|
delete fInputAddress;
|
||||||
delete fOutputAddress;
|
delete fOutputAddress;
|
||||||
delete fPayloadInputs;
|
delete fPayloadInputs;
|
||||||
delete fPayloadOutputs;
|
delete fPayloadOutputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,23 +25,24 @@ using std::endl;
|
||||||
class FairMQDevice : public FairMQStateMachine, public FairMQConfigurable
|
class FairMQDevice : public FairMQStateMachine, public FairMQConfigurable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum {
|
enum
|
||||||
Id = FairMQConfigurable::Last,
|
{
|
||||||
NumIoThreads,
|
Id = FairMQConfigurable::Last,
|
||||||
NumInputs,
|
NumIoThreads,
|
||||||
NumOutputs,
|
NumInputs,
|
||||||
InputAddress,
|
NumOutputs,
|
||||||
InputMethod,
|
InputAddress,
|
||||||
InputSocketType,
|
InputMethod,
|
||||||
InputSndBufSize,
|
InputSocketType,
|
||||||
InputRcvBufSize,
|
InputSndBufSize,
|
||||||
OutputAddress,
|
InputRcvBufSize,
|
||||||
OutputMethod,
|
OutputAddress,
|
||||||
OutputSocketType,
|
OutputMethod,
|
||||||
OutputSndBufSize,
|
OutputSocketType,
|
||||||
OutputRcvBufSize,
|
OutputSndBufSize,
|
||||||
LogIntervalInMs,
|
OutputRcvBufSize,
|
||||||
Last
|
LogIntervalInMs,
|
||||||
|
Last
|
||||||
};
|
};
|
||||||
|
|
||||||
FairMQDevice();
|
FairMQDevice();
|
||||||
|
@ -66,20 +67,20 @@ class FairMQDevice : public FairMQStateMachine, public FairMQConfigurable
|
||||||
int fNumInputs;
|
int fNumInputs;
|
||||||
int fNumOutputs;
|
int fNumOutputs;
|
||||||
|
|
||||||
vector<string> *fInputAddress;
|
vector<string>* fInputAddress;
|
||||||
vector<string> *fInputMethod;
|
vector<string>* fInputMethod;
|
||||||
vector<string> *fInputSocketType;
|
vector<string>* fInputSocketType;
|
||||||
vector<int> *fInputSndBufSize;
|
vector<int>* fInputSndBufSize;
|
||||||
vector<int> *fInputRcvBufSize;
|
vector<int>* fInputRcvBufSize;
|
||||||
|
|
||||||
vector<string> *fOutputAddress;
|
vector<string>* fOutputAddress;
|
||||||
vector<string> *fOutputMethod;
|
vector<string>* fOutputMethod;
|
||||||
vector<string> *fOutputSocketType;
|
vector<string>* fOutputSocketType;
|
||||||
vector<int> *fOutputSndBufSize;
|
vector<int>* fOutputSndBufSize;
|
||||||
vector<int> *fOutputRcvBufSize;
|
vector<int>* fOutputRcvBufSize;
|
||||||
|
|
||||||
vector<FairMQSocket*> *fPayloadInputs;
|
vector<FairMQSocket*>* fPayloadInputs;
|
||||||
vector<FairMQSocket*> *fPayloadOutputs;
|
vector<FairMQSocket*>* fPayloadOutputs;
|
||||||
|
|
||||||
int fLogIntervalInMs;
|
int fLogIntervalInMs;
|
||||||
|
|
||||||
|
|
|
@ -20,44 +20,47 @@ FairMQLogger::FairMQLogger()
|
||||||
|
|
||||||
FairMQLogger::~FairMQLogger()
|
FairMQLogger::~FairMQLogger()
|
||||||
{
|
{
|
||||||
cout << os.str() << endl;
|
cout << os.str() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostringstream& FairMQLogger::Log(int type)
|
std::ostringstream& FairMQLogger::Log(int type)
|
||||||
{
|
{
|
||||||
timestamp_t tm = get_timestamp();
|
timestamp_t tm = get_timestamp();
|
||||||
timestamp_t ms = tm / 1000.0L;
|
timestamp_t ms = tm / 1000.0L;
|
||||||
timestamp_t s = ms / 1000.0L;
|
timestamp_t s = ms / 1000.0L;
|
||||||
std::time_t t = s;
|
std::time_t t = s;
|
||||||
std::size_t fractional_seconds = ms % 1000;
|
std::size_t fractional_seconds = ms % 1000;
|
||||||
char mbstr[100];
|
char mbstr[100];
|
||||||
std::strftime(mbstr, 100, "%H:%M:%S", std::localtime(&t));
|
std::strftime(mbstr, 100, "%H:%M:%S", std::localtime(&t));
|
||||||
|
|
||||||
string type_str;
|
string type_str;
|
||||||
switch (type) {
|
switch (type)
|
||||||
case DEBUG:
|
{
|
||||||
type_str = "\033[01;34mDEBUG\033[0m";
|
case DEBUG:
|
||||||
break;
|
type_str = "\033[01;34mDEBUG\033[0m";
|
||||||
case INFO:
|
break;
|
||||||
type_str = "\033[01;32mINFO\033[0m";
|
case INFO:
|
||||||
break;
|
type_str = "\033[01;32mINFO\033[0m";
|
||||||
case ERROR:
|
break;
|
||||||
type_str = "\033[01;31mERROR\033[0m";
|
case ERROR:
|
||||||
break;
|
type_str = "\033[01;31mERROR\033[0m";
|
||||||
case STATE:
|
break;
|
||||||
type_str = "\033[01;33mSTATE\033[0m";
|
case STATE:
|
||||||
default:
|
type_str = "\033[01;33mSTATE\033[0m";
|
||||||
break;
|
default:
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
os << "[\033[01;36m" << mbstr << "\033[0m]" << "[" << type_str << "]" << " ";
|
os << "[\033[01;36m" << mbstr << "\033[0m]"
|
||||||
|
<< "[" << type_str << "]"
|
||||||
|
<< " ";
|
||||||
|
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
timestamp_t get_timestamp ()
|
timestamp_t get_timestamp()
|
||||||
{
|
{
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
gettimeofday (&now, NULL);
|
gettimeofday(&now, NULL);
|
||||||
return now.tv_usec + (timestamp_t)now.tv_sec * 1000000;
|
return now.tv_usec + (timestamp_t)now.tv_sec * 1000000;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,21 +21,25 @@ using std::ostringstream;
|
||||||
class FairMQLogger
|
class FairMQLogger
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum {
|
enum
|
||||||
DEBUG, INFO, ERROR, STATE
|
{
|
||||||
|
DEBUG,
|
||||||
|
INFO,
|
||||||
|
ERROR,
|
||||||
|
STATE
|
||||||
};
|
};
|
||||||
FairMQLogger();
|
FairMQLogger();
|
||||||
virtual ~FairMQLogger();
|
virtual ~FairMQLogger();
|
||||||
ostringstream& Log(int type);
|
ostringstream& Log(int type);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ostringstream os;
|
ostringstream os;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef unsigned long long timestamp_t;
|
typedef unsigned long long timestamp_t;
|
||||||
|
|
||||||
timestamp_t get_timestamp ();
|
timestamp_t get_timestamp();
|
||||||
|
|
||||||
#define LOG(type) \
|
#define LOG(type) FairMQLogger().Log(FairMQLogger::type)
|
||||||
FairMQLogger().Log(FairMQLogger::type)
|
|
||||||
|
|
||||||
#endif /* FAIRMQLOGGER_H_ */
|
#endif /* FAIRMQLOGGER_H_ */
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include "FairMQMerger.h"
|
#include "FairMQMerger.h"
|
||||||
#include "FairMQPoller.h"
|
#include "FairMQPoller.h"
|
||||||
|
|
||||||
|
|
||||||
FairMQMerger::FairMQMerger()
|
FairMQMerger::FairMQMerger()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -23,35 +22,38 @@ FairMQMerger::~FairMQMerger()
|
||||||
|
|
||||||
void FairMQMerger::Run()
|
void FairMQMerger::Run()
|
||||||
{
|
{
|
||||||
LOG(INFO) << ">>>>>>> Run <<<<<<<";
|
LOG(INFO) << ">>>>>>> Run <<<<<<<";
|
||||||
|
|
||||||
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
||||||
|
|
||||||
FairMQPoller* poller = fTransportFactory->CreatePoller(*fPayloadInputs);
|
FairMQPoller* poller = fTransportFactory->CreatePoller(*fPayloadInputs);
|
||||||
|
|
||||||
bool received = false;
|
bool received = false;
|
||||||
|
|
||||||
while ( fState == RUNNING ) {
|
while (fState == RUNNING)
|
||||||
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
{
|
||||||
|
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
||||||
|
|
||||||
poller->Poll(100);
|
poller->Poll(100);
|
||||||
|
|
||||||
for(int i = 0; i < fNumInputs; i++) {
|
for (int i = 0; i < fNumInputs; i++)
|
||||||
if (poller->CheckInput(i)){
|
{
|
||||||
received = fPayloadInputs->at(i)->Receive(msg);
|
if (poller->CheckInput(i))
|
||||||
}
|
{
|
||||||
if (received) {
|
received = fPayloadInputs->at(i)->Receive(msg);
|
||||||
fPayloadOutputs->at(0)->Send(msg);
|
}
|
||||||
received = false;
|
if (received)
|
||||||
}
|
{
|
||||||
|
fPayloadOutputs->at(0)->Send(msg);
|
||||||
|
received = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delete msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete msg;
|
delete poller;
|
||||||
}
|
|
||||||
|
|
||||||
delete poller;
|
rateLogger.interrupt();
|
||||||
|
rateLogger.join();
|
||||||
rateLogger.interrupt();
|
|
||||||
rateLogger.join();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,12 @@
|
||||||
|
|
||||||
#include "FairMQDevice.h"
|
#include "FairMQDevice.h"
|
||||||
|
|
||||||
|
class FairMQMerger : public FairMQDevice
|
||||||
class FairMQMerger: public FairMQDevice
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FairMQMerger();
|
FairMQMerger();
|
||||||
virtual ~FairMQMerger();
|
virtual ~FairMQMerger();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Run();
|
virtual void Run();
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
#include <cstddef> // for size_t
|
#include <cstddef> // for size_t
|
||||||
|
|
||||||
|
|
||||||
class FairMQMessage
|
class FairMQMessage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -15,7 +15,6 @@ class FairMQPoller
|
||||||
virtual bool CheckInput(int index) = 0;
|
virtual bool CheckInput(int index) = 0;
|
||||||
|
|
||||||
virtual ~FairMQPoller() {};
|
virtual ~FairMQPoller() {};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FAIRMQPOLLER_H_ */
|
#endif /* FAIRMQPOLLER_H_ */
|
|
@ -21,19 +21,20 @@ FairMQProxy::~FairMQProxy()
|
||||||
|
|
||||||
void FairMQProxy::Run()
|
void FairMQProxy::Run()
|
||||||
{
|
{
|
||||||
LOG(INFO) << ">>>>>>> Run <<<<<<<";
|
LOG(INFO) << ">>>>>>> Run <<<<<<<";
|
||||||
|
|
||||||
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
||||||
|
|
||||||
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
||||||
|
|
||||||
while ( fState == RUNNING ) {
|
while (fState == RUNNING)
|
||||||
fPayloadInputs->at(0)->Receive(msg);
|
{
|
||||||
fPayloadOutputs->at(0)->Send(msg);
|
fPayloadInputs->at(0)->Receive(msg);
|
||||||
}
|
fPayloadOutputs->at(0)->Send(msg);
|
||||||
|
}
|
||||||
|
|
||||||
delete msg;
|
delete msg;
|
||||||
|
|
||||||
rateLogger.interrupt();
|
rateLogger.interrupt();
|
||||||
rateLogger.join();
|
rateLogger.join();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,12 @@
|
||||||
|
|
||||||
#include "FairMQDevice.h"
|
#include "FairMQDevice.h"
|
||||||
|
|
||||||
|
class FairMQProxy : public FairMQDevice
|
||||||
class FairMQProxy: public FairMQDevice
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FairMQProxy();
|
FairMQProxy();
|
||||||
virtual ~FairMQProxy();
|
virtual ~FairMQProxy();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Run();
|
virtual void Run();
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,23 +17,23 @@ FairMQSink::FairMQSink()
|
||||||
|
|
||||||
void FairMQSink::Run()
|
void FairMQSink::Run()
|
||||||
{
|
{
|
||||||
LOG(INFO) << ">>>>>>> Run <<<<<<<";
|
LOG(INFO) << ">>>>>>> Run <<<<<<<";
|
||||||
|
|
||||||
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
||||||
|
|
||||||
while ( fState == RUNNING ) {
|
while (fState == RUNNING)
|
||||||
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
{
|
||||||
|
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
||||||
|
|
||||||
fPayloadInputs->at(0)->Receive(msg);
|
fPayloadInputs->at(0)->Receive(msg);
|
||||||
|
|
||||||
delete msg;
|
delete msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
rateLogger.interrupt();
|
rateLogger.interrupt();
|
||||||
rateLogger.join();
|
rateLogger.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQSink::~FairMQSink()
|
FairMQSink::~FairMQSink()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,12 @@
|
||||||
|
|
||||||
#include "FairMQDevice.h"
|
#include "FairMQDevice.h"
|
||||||
|
|
||||||
|
class FairMQSink : public FairMQDevice
|
||||||
class FairMQSink: public FairMQDevice
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FairMQSink();
|
FairMQSink();
|
||||||
virtual ~FairMQSink();
|
virtual ~FairMQSink();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Run();
|
virtual void Run();
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
#include "FairMQLogger.h"
|
#include "FairMQLogger.h"
|
||||||
#include "FairMQSplitter.h"
|
#include "FairMQSplitter.h"
|
||||||
|
|
||||||
|
|
||||||
FairMQSplitter::FairMQSplitter()
|
FairMQSplitter::FairMQSplitter()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -22,30 +21,33 @@ FairMQSplitter::~FairMQSplitter()
|
||||||
|
|
||||||
void FairMQSplitter::Run()
|
void FairMQSplitter::Run()
|
||||||
{
|
{
|
||||||
LOG(INFO) << ">>>>>>> Run <<<<<<<";
|
LOG(INFO) << ">>>>>>> Run <<<<<<<";
|
||||||
|
|
||||||
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
||||||
|
|
||||||
bool received = false;
|
bool received = false;
|
||||||
int direction = 0;
|
int direction = 0;
|
||||||
|
|
||||||
while ( fState == RUNNING ) {
|
while (fState == RUNNING)
|
||||||
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
{
|
||||||
|
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
||||||
|
|
||||||
received = fPayloadInputs->at(0)->Receive(msg);
|
received = fPayloadInputs->at(0)->Receive(msg);
|
||||||
|
|
||||||
if (received) {
|
if (received)
|
||||||
fPayloadOutputs->at(direction)->Send(msg);
|
{
|
||||||
direction++;
|
fPayloadOutputs->at(direction)->Send(msg);
|
||||||
if (direction >= fNumOutputs) {
|
direction++;
|
||||||
direction = 0;
|
if (direction >= fNumOutputs)
|
||||||
}
|
{
|
||||||
received = false;
|
direction = 0;
|
||||||
|
}
|
||||||
|
received = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete msg;
|
rateLogger.interrupt();
|
||||||
}
|
rateLogger.join();
|
||||||
|
|
||||||
rateLogger.interrupt();
|
|
||||||
rateLogger.join();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,12 @@
|
||||||
|
|
||||||
#include "FairMQDevice.h"
|
#include "FairMQDevice.h"
|
||||||
|
|
||||||
|
class FairMQSplitter : public FairMQDevice
|
||||||
class FairMQSplitter: public FairMQDevice
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FairMQSplitter();
|
FairMQSplitter();
|
||||||
virtual ~FairMQSplitter();
|
virtual ~FairMQSplitter();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Run();
|
virtual void Run();
|
||||||
};
|
};
|
||||||
|
|
3
fairmq/apply-clang-format.sh
Executable file
3
fairmq/apply-clang-format.sh
Executable file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
find . -type f \( -iname "*.h" ! -iname "*.pb.h" -o -iname "*.cxx" \) -execdir clang-format -i {} \;
|
|
@ -12,125 +12,139 @@
|
||||||
#include "FairMQMessageNN.h"
|
#include "FairMQMessageNN.h"
|
||||||
#include "FairMQLogger.h"
|
#include "FairMQLogger.h"
|
||||||
|
|
||||||
FairMQMessageNN::FairMQMessageNN() :
|
FairMQMessageNN::FairMQMessageNN()
|
||||||
fSize(0),
|
: fSize(0)
|
||||||
fMessage(NULL),
|
, fMessage(NULL)
|
||||||
fReceiving(false)
|
, fReceiving(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQMessageNN::FairMQMessageNN(size_t size)
|
FairMQMessageNN::FairMQMessageNN(size_t size)
|
||||||
{
|
{
|
||||||
fMessage = nn_allocmsg(size, 0);
|
fMessage = nn_allocmsg(size, 0);
|
||||||
if (!fMessage){
|
if (!fMessage)
|
||||||
LOG(ERROR) << "failed allocating message, reason: " << nn_strerror(errno);
|
{
|
||||||
}
|
LOG(ERROR) << "failed allocating message, reason: " << nn_strerror(errno);
|
||||||
fSize = size;
|
}
|
||||||
fReceiving = false;
|
fSize = size;
|
||||||
|
fReceiving = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQMessageNN::FairMQMessageNN(void* data, size_t size)
|
FairMQMessageNN::FairMQMessageNN(void* data, size_t size)
|
||||||
{
|
{
|
||||||
fMessage = nn_allocmsg(size, 0);
|
fMessage = nn_allocmsg(size, 0);
|
||||||
if (!fMessage){
|
if (!fMessage)
|
||||||
LOG(ERROR) << "failed allocating message, reason: " << nn_strerror(errno);
|
{
|
||||||
}
|
LOG(ERROR) << "failed allocating message, reason: " << nn_strerror(errno);
|
||||||
memcpy (fMessage, data, size);
|
}
|
||||||
fSize = size;
|
memcpy(fMessage, data, size);
|
||||||
fReceiving = false;
|
fSize = size;
|
||||||
|
fReceiving = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQMessageNN::Rebuild()
|
void FairMQMessageNN::Rebuild()
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
fSize = 0;
|
fSize = 0;
|
||||||
fMessage = NULL;
|
fMessage = NULL;
|
||||||
fReceiving = false;
|
fReceiving = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQMessageNN::Rebuild(size_t size)
|
void FairMQMessageNN::Rebuild(size_t size)
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
fMessage = nn_allocmsg(size, 0);
|
fMessage = nn_allocmsg(size, 0);
|
||||||
if (!fMessage){
|
if (!fMessage)
|
||||||
LOG(ERROR) << "failed allocating message, reason: " << nn_strerror(errno);
|
{
|
||||||
}
|
LOG(ERROR) << "failed allocating message, reason: " << nn_strerror(errno);
|
||||||
fSize = size;
|
}
|
||||||
fReceiving = false;
|
fSize = size;
|
||||||
|
fReceiving = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQMessageNN::Rebuild(void* data, size_t size)
|
void FairMQMessageNN::Rebuild(void* data, size_t size)
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
fMessage = nn_allocmsg(size, 0);
|
fMessage = nn_allocmsg(size, 0);
|
||||||
if (!fMessage){
|
if (!fMessage)
|
||||||
LOG(ERROR) << "failed allocating message, reason: " << nn_strerror(errno);
|
{
|
||||||
}
|
LOG(ERROR) << "failed allocating message, reason: " << nn_strerror(errno);
|
||||||
memcpy (fMessage, data, size);
|
}
|
||||||
fSize = size;
|
memcpy(fMessage, data, size);
|
||||||
fReceiving = false;
|
fSize = size;
|
||||||
|
fReceiving = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* FairMQMessageNN::GetMessage()
|
void* FairMQMessageNN::GetMessage()
|
||||||
{
|
{
|
||||||
return fMessage;
|
return fMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* FairMQMessageNN::GetData()
|
void* FairMQMessageNN::GetData()
|
||||||
{
|
{
|
||||||
return fMessage;
|
return fMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t FairMQMessageNN::GetSize()
|
size_t FairMQMessageNN::GetSize()
|
||||||
{
|
{
|
||||||
return fSize;
|
return fSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQMessageNN::SetMessage(void* data, size_t size)
|
void FairMQMessageNN::SetMessage(void* data, size_t size)
|
||||||
{
|
{
|
||||||
fMessage = data;
|
fMessage = data;
|
||||||
fSize = size;
|
fSize = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQMessageNN::Copy(FairMQMessage* msg)
|
void FairMQMessageNN::Copy(FairMQMessage* msg)
|
||||||
{
|
{
|
||||||
if (fMessage){
|
if (fMessage)
|
||||||
int rc = nn_freemsg(fMessage);
|
{
|
||||||
if ( rc < 0 ){
|
int rc = nn_freemsg(fMessage);
|
||||||
LOG(ERROR) << "failed freeing message, reason: " << nn_strerror(errno);
|
if (rc < 0)
|
||||||
|
{
|
||||||
|
LOG(ERROR) << "failed freeing message, reason: " << nn_strerror(errno);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
size_t size = msg->GetSize();
|
size_t size = msg->GetSize();
|
||||||
|
|
||||||
fMessage = nn_allocmsg(size, 0);
|
fMessage = nn_allocmsg(size, 0);
|
||||||
if (!fMessage){
|
if (!fMessage)
|
||||||
LOG(ERROR) << "failed allocating message, reason: " << nn_strerror(errno);
|
{
|
||||||
}
|
LOG(ERROR) << "failed allocating message, reason: " << nn_strerror(errno);
|
||||||
std::memcpy (fMessage, msg->GetMessage(), size);
|
}
|
||||||
fSize = size;
|
std::memcpy(fMessage, msg->GetMessage(), size);
|
||||||
|
fSize = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void FairMQMessageNN::Clear()
|
inline void FairMQMessageNN::Clear()
|
||||||
{
|
{
|
||||||
int rc = nn_freemsg(fMessage);
|
int rc = nn_freemsg(fMessage);
|
||||||
if (rc < 0) {
|
if (rc < 0)
|
||||||
LOG(ERROR) << "failed freeing message, reason: " << nn_strerror(errno);
|
{
|
||||||
} else {
|
LOG(ERROR) << "failed freeing message, reason: " << nn_strerror(errno);
|
||||||
fMessage = NULL;
|
}
|
||||||
fSize = 0;
|
else
|
||||||
}
|
{
|
||||||
|
fMessage = NULL;
|
||||||
|
fSize = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQMessageNN::~FairMQMessageNN()
|
FairMQMessageNN::~FairMQMessageNN()
|
||||||
{
|
{
|
||||||
if(fReceiving){
|
if (fReceiving)
|
||||||
int rc = nn_freemsg(fMessage);
|
{
|
||||||
if (rc < 0) {
|
int rc = nn_freemsg(fMessage);
|
||||||
LOG(ERROR) << "failed freeing message, reason: " << nn_strerror(errno);
|
if (rc < 0)
|
||||||
} else {
|
{
|
||||||
fMessage = NULL;
|
LOG(ERROR) << "failed freeing message, reason: " << nn_strerror(errno);
|
||||||
fSize = 0;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fMessage = NULL;
|
||||||
|
fSize = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
|
|
||||||
#include "FairMQMessage.h"
|
#include "FairMQMessage.h"
|
||||||
|
|
||||||
|
|
||||||
class FairMQMessageNN : public FairMQMessage
|
class FairMQMessageNN : public FairMQMessage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -11,29 +11,31 @@
|
||||||
|
|
||||||
FairMQPollerNN::FairMQPollerNN(const vector<FairMQSocket*>& inputs)
|
FairMQPollerNN::FairMQPollerNN(const vector<FairMQSocket*>& inputs)
|
||||||
{
|
{
|
||||||
fNumItems = inputs.size();
|
fNumItems = inputs.size();
|
||||||
items = new nn_pollfd[fNumItems];
|
items = new nn_pollfd[fNumItems];
|
||||||
|
|
||||||
for (int i = 0; i < fNumItems; i++) {
|
for (int i = 0; i < fNumItems; i++)
|
||||||
items[i].fd = inputs.at(i)->GetSocket(1);
|
{
|
||||||
items[i].events = NN_POLLIN;
|
items[i].fd = inputs.at(i)->GetSocket(1);
|
||||||
}
|
items[i].events = NN_POLLIN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQPollerNN::Poll(int timeout)
|
void FairMQPollerNN::Poll(int timeout)
|
||||||
{
|
{
|
||||||
nn_poll(items, fNumItems, timeout);
|
nn_poll(items, fNumItems, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FairMQPollerNN::CheckInput(int index)
|
bool FairMQPollerNN::CheckInput(int index)
|
||||||
{
|
{
|
||||||
if (items[index].revents & NN_POLLIN)
|
if (items[index].revents & NN_POLLIN)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQPollerNN::~FairMQPollerNN()
|
FairMQPollerNN::~FairMQPollerNN()
|
||||||
{
|
{
|
||||||
if (items != NULL) delete [] items;
|
if (items != NULL)
|
||||||
|
delete[] items;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,9 @@ FairMQSocketNN::FairMQSocketNN(const string& type, int num, int numIoThreads) :
|
||||||
fMessagesTx(0),
|
fMessagesTx(0),
|
||||||
fMessagesRx(0)
|
fMessagesRx(0)
|
||||||
{
|
{
|
||||||
stringstream id;
|
stringstream id;
|
||||||
id << type << "." << num;
|
id << type << "." << num;
|
||||||
fId = id.str();
|
fId = id.str();
|
||||||
|
|
||||||
if ( numIoThreads > 1 ) {
|
if ( numIoThreads > 1 ) {
|
||||||
LOG(INFO) << "number of I/O threads is not used in nanomsg";
|
LOG(INFO) << "number of I/O threads is not used in nanomsg";
|
||||||
|
@ -30,123 +30,140 @@ FairMQSocketNN::FairMQSocketNN(const string& type, int num, int numIoThreads) :
|
||||||
nn_setsockopt(fSocket, NN_SUB, NN_SUB_SUBSCRIBE, NULL, 0);
|
nn_setsockopt(fSocket, NN_SUB, NN_SUB_SUBSCRIBE, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(INFO) << "created socket #" << fId;
|
LOG(INFO) << "created socket #" << fId;
|
||||||
}
|
}
|
||||||
|
|
||||||
string FairMQSocketNN::GetId()
|
string FairMQSocketNN::GetId()
|
||||||
{
|
{
|
||||||
return fId;
|
return fId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQSocketNN::Bind(const string& address)
|
void FairMQSocketNN::Bind(const string& address)
|
||||||
{
|
{
|
||||||
LOG(INFO) << "bind socket #" << fId << " on " << address;
|
LOG(INFO) << "bind socket #" << fId << " on " << address;
|
||||||
|
|
||||||
int eid = nn_bind(fSocket, address.c_str());
|
int eid = nn_bind(fSocket, address.c_str());
|
||||||
if (eid < 0) {
|
if (eid < 0)
|
||||||
LOG(ERROR) << "failed binding socket #" << fId << ", reason: " << nn_strerror(errno);
|
{
|
||||||
}
|
LOG(ERROR) << "failed binding socket #" << fId << ", reason: " << nn_strerror(errno);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQSocketNN::Connect(const string& address)
|
void FairMQSocketNN::Connect(const string& address)
|
||||||
{
|
{
|
||||||
LOG(INFO) << "connect socket #" << fId << " to " << address;
|
LOG(INFO) << "connect socket #" << fId << " to " << address;
|
||||||
|
|
||||||
int eid = nn_connect(fSocket, address.c_str());
|
int eid = nn_connect(fSocket, address.c_str());
|
||||||
if (eid < 0) {
|
if (eid < 0)
|
||||||
LOG(ERROR) << "failed connecting socket #" << fId << ", reason: " << nn_strerror(errno);
|
{
|
||||||
}
|
LOG(ERROR) << "failed connecting socket #" << fId << ", reason: " << nn_strerror(errno);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t FairMQSocketNN::Send(FairMQMessage* msg)
|
size_t FairMQSocketNN::Send(FairMQMessage* msg)
|
||||||
{
|
{
|
||||||
void* ptr = msg->GetMessage();
|
void* ptr = msg->GetMessage();
|
||||||
int rc = nn_send(fSocket, &ptr, NN_MSG, 0);
|
int rc = nn_send(fSocket, &ptr, NN_MSG, 0);
|
||||||
if (rc < 0) {
|
if (rc < 0)
|
||||||
LOG(ERROR) << "failed sending on socket #" << fId << ", reason: " << nn_strerror(errno);
|
{
|
||||||
} else {
|
LOG(ERROR) << "failed sending on socket #" << fId << ", reason: " << nn_strerror(errno);
|
||||||
fBytesTx += rc;
|
}
|
||||||
++fMessagesTx;
|
else
|
||||||
static_cast<FairMQMessageNN*>(msg)->fReceiving = false;
|
{
|
||||||
}
|
fBytesTx += rc;
|
||||||
|
++fMessagesTx;
|
||||||
|
static_cast<FairMQMessageNN*>(msg)->fReceiving = false;
|
||||||
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t FairMQSocketNN::Receive(FairMQMessage* msg)
|
size_t FairMQSocketNN::Receive(FairMQMessage* msg)
|
||||||
{
|
{
|
||||||
void* ptr = NULL;
|
void* ptr = NULL;
|
||||||
int rc = nn_recv(fSocket, &ptr, NN_MSG, 0);
|
int rc = nn_recv(fSocket, &ptr, NN_MSG, 0);
|
||||||
if (rc < 0) {
|
if (rc < 0)
|
||||||
LOG(ERROR) << "failed receiving on socket #" << fId << ", reason: " << nn_strerror(errno);
|
{
|
||||||
} else {
|
LOG(ERROR) << "failed receiving on socket #" << fId << ", reason: " << nn_strerror(errno);
|
||||||
fBytesRx += rc;
|
}
|
||||||
++fMessagesRx;
|
else
|
||||||
msg->SetMessage(ptr, rc);
|
{
|
||||||
static_cast<FairMQMessageNN*>(msg)->fReceiving = true;
|
fBytesRx += rc;
|
||||||
}
|
++fMessagesRx;
|
||||||
|
msg->SetMessage(ptr, rc);
|
||||||
|
static_cast<FairMQMessageNN*>(msg)->fReceiving = true;
|
||||||
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* FairMQSocketNN::GetSocket()
|
void* FairMQSocketNN::GetSocket()
|
||||||
{
|
{
|
||||||
return NULL; // dummy method to comply with the interface. functionality not possible in zeromq.
|
return NULL; // dummy method to comply with the interface. functionality not possible in zeromq.
|
||||||
}
|
}
|
||||||
|
|
||||||
int FairMQSocketNN::GetSocket(int nothing)
|
int FairMQSocketNN::GetSocket(int nothing)
|
||||||
{
|
{
|
||||||
return fSocket;
|
return fSocket;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQSocketNN::Close()
|
void FairMQSocketNN::Close()
|
||||||
{
|
{
|
||||||
nn_close(fSocket);
|
nn_close(fSocket);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQSocketNN::SetOption(const string& option, const void* value, size_t valueSize)
|
void FairMQSocketNN::SetOption(const string& option, const void* value, size_t valueSize)
|
||||||
{
|
{
|
||||||
int rc = nn_setsockopt(fSocket, NN_SOL_SOCKET, GetConstant(option), value, valueSize);
|
int rc = nn_setsockopt(fSocket, NN_SOL_SOCKET, GetConstant(option), value, valueSize);
|
||||||
if (rc < 0) {
|
if (rc < 0)
|
||||||
LOG(ERROR) << "failed setting socket option, reason: " << nn_strerror(errno);
|
{
|
||||||
}
|
LOG(ERROR) << "failed setting socket option, reason: " << nn_strerror(errno);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long FairMQSocketNN::GetBytesTx()
|
unsigned long FairMQSocketNN::GetBytesTx()
|
||||||
{
|
{
|
||||||
return fBytesTx;
|
return fBytesTx;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long FairMQSocketNN::GetBytesRx()
|
unsigned long FairMQSocketNN::GetBytesRx()
|
||||||
{
|
{
|
||||||
return fBytesRx;
|
return fBytesRx;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long FairMQSocketNN::GetMessagesTx()
|
unsigned long FairMQSocketNN::GetMessagesTx()
|
||||||
{
|
{
|
||||||
return fMessagesTx;
|
return fMessagesTx;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long FairMQSocketNN::GetMessagesRx()
|
unsigned long FairMQSocketNN::GetMessagesRx()
|
||||||
{
|
{
|
||||||
return fMessagesRx;
|
return fMessagesRx;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FairMQSocketNN::GetConstant(const string& constant)
|
int FairMQSocketNN::GetConstant(const string& constant)
|
||||||
{
|
{
|
||||||
if (constant == "sub") return NN_SUB;
|
if (constant == "sub")
|
||||||
if (constant == "pub") return NN_PUB;
|
return NN_SUB;
|
||||||
if (constant == "xsub") return NN_SUB; // TODO: is there XPUB, XSUB for nanomsg?
|
if (constant == "pub")
|
||||||
if (constant == "xpub") return NN_PUB;
|
return NN_PUB;
|
||||||
if (constant == "push") return NN_PUSH;
|
if (constant == "xsub")
|
||||||
if (constant == "pull") return NN_PULL;
|
return NN_SUB; // TODO: is there XPUB, XSUB for nanomsg?
|
||||||
if (constant == "snd-hwm") return NN_SNDBUF;
|
if (constant == "xpub")
|
||||||
if (constant == "rcv-hwm") return NN_RCVBUF;
|
return NN_PUB;
|
||||||
|
if (constant == "push")
|
||||||
|
return NN_PUSH;
|
||||||
|
if (constant == "pull")
|
||||||
|
return NN_PULL;
|
||||||
|
if (constant == "snd-hwm")
|
||||||
|
return NN_SNDBUF;
|
||||||
|
if (constant == "rcv-hwm")
|
||||||
|
return NN_RCVBUF;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQSocketNN::~FairMQSocketNN()
|
FairMQSocketNN::~FairMQSocketNN()
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
#include "FairMQSocket.h"
|
#include "FairMQSocket.h"
|
||||||
|
|
||||||
|
|
||||||
class FairMQSocketNN : public FairMQSocket
|
class FairMQSocketNN : public FairMQSocket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -9,22 +9,22 @@
|
||||||
|
|
||||||
FairMQTransportFactoryNN::FairMQTransportFactoryNN()
|
FairMQTransportFactoryNN::FairMQTransportFactoryNN()
|
||||||
{
|
{
|
||||||
LOG(INFO) << "Using nanonsg library";
|
LOG(INFO) << "Using nanonsg library";
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQMessage* FairMQTransportFactoryNN::CreateMessage()
|
FairMQMessage* FairMQTransportFactoryNN::CreateMessage()
|
||||||
{
|
{
|
||||||
return new FairMQMessageNN();
|
return new FairMQMessageNN();
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQMessage* FairMQTransportFactoryNN::CreateMessage(size_t size)
|
FairMQMessage* FairMQTransportFactoryNN::CreateMessage(size_t size)
|
||||||
{
|
{
|
||||||
return new FairMQMessageNN(size);
|
return new FairMQMessageNN(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQMessage* FairMQTransportFactoryNN::CreateMessage(void* data, size_t size)
|
FairMQMessage* FairMQTransportFactoryNN::CreateMessage(void* data, size_t size)
|
||||||
{
|
{
|
||||||
return new FairMQMessageNN(data, size);
|
return new FairMQMessageNN(data, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQSocket* FairMQTransportFactoryNN::CreateSocket(const string& type, int num, int numIoThreads)
|
FairMQSocket* FairMQTransportFactoryNN::CreateSocket(const string& type, int num, int numIoThreads)
|
||||||
|
@ -34,5 +34,5 @@ FairMQSocket* FairMQTransportFactoryNN::CreateSocket(const string& type, int num
|
||||||
|
|
||||||
FairMQPoller* FairMQTransportFactoryNN::CreatePoller(const vector<FairMQSocket*>& inputs)
|
FairMQPoller* FairMQTransportFactoryNN::CreatePoller(const vector<FairMQSocket*>& inputs)
|
||||||
{
|
{
|
||||||
return new FairMQPollerNN(inputs);
|
return new FairMQPollerNN(inputs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@ class FairMQTransportFactoryNN : public FairMQTransportFactory
|
||||||
virtual FairMQSocket* CreateSocket(const string& type, int num, int numIoThreads);
|
virtual FairMQSocket* CreateSocket(const string& type, int num, int numIoThreads);
|
||||||
virtual FairMQPoller* CreatePoller(const vector<FairMQSocket*>& inputs);
|
virtual FairMQPoller* CreatePoller(const vector<FairMQSocket*>& inputs);
|
||||||
|
|
||||||
|
|
||||||
virtual ~FairMQTransportFactoryNN() {};
|
virtual ~FairMQTransportFactoryNN() {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <stdlib.h> /* srand, rand */
|
#include <stdlib.h> /* srand, rand */
|
||||||
#include <time.h> /* time */
|
#include <time.h> /* time */
|
||||||
|
|
||||||
#include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
@ -15,11 +15,10 @@
|
||||||
#include "FairMQBinSampler.h"
|
#include "FairMQBinSampler.h"
|
||||||
#include "FairMQLogger.h"
|
#include "FairMQLogger.h"
|
||||||
|
|
||||||
|
FairMQBinSampler::FairMQBinSampler()
|
||||||
FairMQBinSampler::FairMQBinSampler() :
|
: fEventSize(10000)
|
||||||
fEventSize(10000),
|
, fEventRate(1)
|
||||||
fEventRate(1),
|
, fEventCounter(0)
|
||||||
fEventCounter(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,142 +28,154 @@ FairMQBinSampler::~FairMQBinSampler()
|
||||||
|
|
||||||
void FairMQBinSampler::Init()
|
void FairMQBinSampler::Init()
|
||||||
{
|
{
|
||||||
FairMQDevice::Init();
|
FairMQDevice::Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQBinSampler::Run()
|
void FairMQBinSampler::Run()
|
||||||
{
|
{
|
||||||
LOG(INFO) << ">>>>>>> Run <<<<<<<";
|
LOG(INFO) << ">>>>>>> Run <<<<<<<";
|
||||||
//boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
|
// boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
|
||||||
|
|
||||||
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
||||||
boost::thread resetEventCounter(boost::bind(&FairMQBinSampler::ResetEventCounter, this));
|
boost::thread resetEventCounter(boost::bind(&FairMQBinSampler::ResetEventCounter, this));
|
||||||
|
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
|
|
||||||
LOG(DEBUG) << "Message size: " << fEventSize * sizeof(Content) << " bytes.";
|
LOG(DEBUG) << "Message size: " << fEventSize * sizeof(Content) << " bytes.";
|
||||||
|
|
||||||
while ( fState == RUNNING ) {
|
while (fState == RUNNING)
|
||||||
|
{
|
||||||
|
|
||||||
Content* payload = new Content[fEventSize];
|
Content* payload = new Content[fEventSize];
|
||||||
|
|
||||||
for (int i = 0; i < fEventSize; ++i) {
|
for (int i = 0; i < fEventSize; ++i)
|
||||||
(&payload[i])->x = rand() % 100 + 1;
|
{
|
||||||
(&payload[i])->y = rand() % 100 + 1;
|
(&payload[i])->x = rand() % 100 + 1;
|
||||||
(&payload[i])->z = rand() % 100 + 1;
|
(&payload[i])->y = rand() % 100 + 1;
|
||||||
(&payload[i])->a = (rand() % 100 + 1) / (rand() % 100 + 1);
|
(&payload[i])->z = rand() % 100 + 1;
|
||||||
(&payload[i])->b = (rand() % 100 + 1) / (rand() % 100 + 1);
|
(&payload[i])->a = (rand() % 100 + 1) / (rand() % 100 + 1);
|
||||||
// LOG(INFO) << (&payload[i])->x << " " << (&payload[i])->y << " " << (&payload[i])->z << " " << (&payload[i])->a << " " << (&payload[i])->b;
|
(&payload[i])->b = (rand() % 100 + 1) / (rand() % 100 + 1);
|
||||||
|
// LOG(INFO) << (&payload[i])->x << " " << (&payload[i])->y << " " << (&payload[i])->z << " " << (&payload[i])->a << " " << (&payload[i])->b;
|
||||||
|
}
|
||||||
|
|
||||||
|
FairMQMessage* msg = fTransportFactory->CreateMessage(fEventSize * sizeof(Content));
|
||||||
|
memcpy(msg->GetData(), payload, fEventSize * sizeof(Content));
|
||||||
|
|
||||||
|
fPayloadOutputs->at(0)->Send(msg);
|
||||||
|
|
||||||
|
--fEventCounter;
|
||||||
|
|
||||||
|
while (fEventCounter == 0)
|
||||||
|
{
|
||||||
|
boost::this_thread::sleep(boost::posix_time::milliseconds(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
delete[] payload;
|
||||||
|
delete msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQMessage* msg = fTransportFactory->CreateMessage(fEventSize * sizeof(Content));
|
rateLogger.interrupt();
|
||||||
memcpy(msg->GetData(), payload, fEventSize * sizeof(Content));
|
resetEventCounter.interrupt();
|
||||||
|
|
||||||
fPayloadOutputs->at(0)->Send(msg);
|
rateLogger.join();
|
||||||
|
resetEventCounter.join();
|
||||||
--fEventCounter;
|
|
||||||
|
|
||||||
while (fEventCounter == 0) {
|
|
||||||
boost::this_thread::sleep(boost::posix_time::milliseconds(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
delete[] payload;
|
|
||||||
delete msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateLogger.interrupt();
|
|
||||||
resetEventCounter.interrupt();
|
|
||||||
|
|
||||||
rateLogger.join();
|
|
||||||
resetEventCounter.join();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQBinSampler::ResetEventCounter()
|
void FairMQBinSampler::ResetEventCounter()
|
||||||
{
|
{
|
||||||
while ( true ) {
|
while (true)
|
||||||
try {
|
{
|
||||||
fEventCounter = fEventRate / 100;
|
try
|
||||||
boost::this_thread::sleep(boost::posix_time::milliseconds(10));
|
{
|
||||||
} catch (boost::thread_interrupted&) {
|
fEventCounter = fEventRate / 100;
|
||||||
break;
|
boost::this_thread::sleep(boost::posix_time::milliseconds(10));
|
||||||
|
}
|
||||||
|
catch (boost::thread_interrupted&)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQBinSampler::Log(int intervalInMs)
|
void FairMQBinSampler::Log(int intervalInMs)
|
||||||
{
|
{
|
||||||
timestamp_t t0;
|
timestamp_t t0;
|
||||||
timestamp_t t1;
|
timestamp_t t1;
|
||||||
unsigned long bytes = fPayloadOutputs->at(0)->GetBytesTx();
|
unsigned long bytes = fPayloadOutputs->at(0)->GetBytesTx();
|
||||||
unsigned long messages = fPayloadOutputs->at(0)->GetMessagesTx();
|
unsigned long messages = fPayloadOutputs->at(0)->GetMessagesTx();
|
||||||
unsigned long bytesNew = 0;
|
unsigned long bytesNew = 0;
|
||||||
unsigned long messagesNew = 0;
|
unsigned long messagesNew = 0;
|
||||||
double megabytesPerSecond = 0;
|
double megabytesPerSecond = 0;
|
||||||
double messagesPerSecond = 0;
|
double messagesPerSecond = 0;
|
||||||
|
|
||||||
t0 = get_timestamp();
|
t0 = get_timestamp();
|
||||||
|
|
||||||
while (true) {
|
while (true)
|
||||||
boost::this_thread::sleep(boost::posix_time::milliseconds(intervalInMs));
|
{
|
||||||
|
boost::this_thread::sleep(boost::posix_time::milliseconds(intervalInMs));
|
||||||
|
|
||||||
t1 = get_timestamp();
|
t1 = get_timestamp();
|
||||||
|
|
||||||
bytesNew = fPayloadOutputs->at(0)->GetBytesTx();
|
bytesNew = fPayloadOutputs->at(0)->GetBytesTx();
|
||||||
messagesNew = fPayloadOutputs->at(0)->GetMessagesTx();
|
messagesNew = fPayloadOutputs->at(0)->GetMessagesTx();
|
||||||
|
|
||||||
timestamp_t timeSinceLastLog_ms = (t1 - t0) / 1000.0L;
|
timestamp_t timeSinceLastLog_ms = (t1 - t0) / 1000.0L;
|
||||||
|
|
||||||
megabytesPerSecond = ((double) (bytesNew - bytes) / (1024. * 1024.)) / (double) timeSinceLastLog_ms * 1000.;
|
megabytesPerSecond = ((double)(bytesNew - bytes) / (1024. * 1024.)) / (double)timeSinceLastLog_ms * 1000.;
|
||||||
messagesPerSecond = (double) (messagesNew - messages) / (double) timeSinceLastLog_ms * 1000.;
|
messagesPerSecond = (double)(messagesNew - messages) / (double)timeSinceLastLog_ms * 1000.;
|
||||||
|
|
||||||
LOG(DEBUG) << "send " << messagesPerSecond << " msg/s, " << megabytesPerSecond << " MB/s";
|
LOG(DEBUG) << "send " << messagesPerSecond << " msg/s, " << megabytesPerSecond << " MB/s";
|
||||||
|
|
||||||
bytes = bytesNew;
|
bytes = bytesNew;
|
||||||
messages = messagesNew;
|
messages = messagesNew;
|
||||||
t0 = t1;
|
t0 = t1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQBinSampler::SetProperty(const int key, const string& value, const int slot/*= 0*/)
|
void FairMQBinSampler::SetProperty(const int key, const string& value, const int slot /*= 0*/)
|
||||||
{
|
{
|
||||||
switch (key) {
|
switch (key)
|
||||||
default:
|
{
|
||||||
FairMQDevice::SetProperty(key, value, slot);
|
default:
|
||||||
break;
|
FairMQDevice::SetProperty(key, value, slot);
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string FairMQBinSampler::GetProperty(const int key, const string& default_/*= ""*/, const int slot/*= 0*/)
|
string FairMQBinSampler::GetProperty(const int key, const string& default_ /*= ""*/, const int slot /*= 0*/)
|
||||||
{
|
{
|
||||||
switch (key) {
|
switch (key)
|
||||||
default:
|
{
|
||||||
return FairMQDevice::GetProperty(key, default_, slot);
|
default:
|
||||||
}
|
return FairMQDevice::GetProperty(key, default_, slot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQBinSampler::SetProperty(const int key, const int value, const int slot/*= 0*/)
|
void FairMQBinSampler::SetProperty(const int key, const int value, const int slot /*= 0*/)
|
||||||
{
|
{
|
||||||
switch (key) {
|
switch (key)
|
||||||
case EventSize:
|
{
|
||||||
fEventSize = value;
|
case EventSize:
|
||||||
break;
|
fEventSize = value;
|
||||||
case EventRate:
|
break;
|
||||||
fEventRate = value;
|
case EventRate:
|
||||||
break;
|
fEventRate = value;
|
||||||
default:
|
break;
|
||||||
FairMQDevice::SetProperty(key, value, slot);
|
default:
|
||||||
break;
|
FairMQDevice::SetProperty(key, value, slot);
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int FairMQBinSampler::GetProperty(const int key, const int default_/*= 0*/, const int slot/*= 0*/)
|
int FairMQBinSampler::GetProperty(const int key, const int default_ /*= 0*/, const int slot /*= 0*/)
|
||||||
{
|
{
|
||||||
switch (key) {
|
switch (key)
|
||||||
case EventSize:
|
{
|
||||||
return fEventSize;
|
case EventSize:
|
||||||
case EventRate:
|
return fEventSize;
|
||||||
return fEventRate;
|
case EventRate:
|
||||||
default:
|
return fEventRate;
|
||||||
return FairMQDevice::GetProperty(key, default_, slot);
|
default:
|
||||||
}
|
return FairMQDevice::GetProperty(key, default_, slot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,22 +12,24 @@
|
||||||
|
|
||||||
#include "FairMQDevice.h"
|
#include "FairMQDevice.h"
|
||||||
|
|
||||||
struct Content {
|
struct Content
|
||||||
double a;
|
{
|
||||||
double b;
|
double a;
|
||||||
int x;
|
double b;
|
||||||
int y;
|
int x;
|
||||||
int z;
|
int y;
|
||||||
|
int z;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FairMQBinSampler: public FairMQDevice
|
class FairMQBinSampler : public FairMQDevice
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum {
|
enum
|
||||||
InputFile = FairMQDevice::Last,
|
{
|
||||||
EventRate,
|
InputFile = FairMQDevice::Last,
|
||||||
EventSize,
|
EventRate,
|
||||||
Last
|
EventSize,
|
||||||
|
Last
|
||||||
};
|
};
|
||||||
FairMQBinSampler();
|
FairMQBinSampler();
|
||||||
virtual ~FairMQBinSampler();
|
virtual ~FairMQBinSampler();
|
||||||
|
|
|
@ -17,28 +17,29 @@ FairMQBinSink::FairMQBinSink()
|
||||||
|
|
||||||
void FairMQBinSink::Run()
|
void FairMQBinSink::Run()
|
||||||
{
|
{
|
||||||
LOG(INFO) << ">>>>>>> Run <<<<<<<";
|
LOG(INFO) << ">>>>>>> Run <<<<<<<";
|
||||||
|
|
||||||
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
||||||
|
|
||||||
while ( fState == RUNNING ) {
|
while (fState == RUNNING)
|
||||||
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
{
|
||||||
|
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
||||||
|
|
||||||
fPayloadInputs->at(0)->Receive(msg);
|
fPayloadInputs->at(0)->Receive(msg);
|
||||||
|
|
||||||
int inputSize = msg->GetSize();
|
int inputSize = msg->GetSize();
|
||||||
int numInput = inputSize / sizeof(Content);
|
int numInput = inputSize / sizeof(Content);
|
||||||
Content* input = reinterpret_cast<Content*>(msg->GetData());
|
Content* input = reinterpret_cast<Content*>(msg->GetData());
|
||||||
|
|
||||||
// for (int i = 0; i < numInput; ++i) {
|
// for (int i = 0; i < numInput; ++i) {
|
||||||
// LOG(INFO) << (&input[i])->x << " " << (&input[i])->y << " " << (&input[i])->z << " " << (&input[i])->a << " " << (&input[i])->b;
|
// LOG(INFO) << (&input[i])->x << " " << (&input[i])->y << " " << (&input[i])->z << " " << (&input[i])->a << " " << (&input[i])->b;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
delete msg;
|
delete msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
rateLogger.interrupt();
|
rateLogger.interrupt();
|
||||||
rateLogger.join();
|
rateLogger.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQBinSink::~FairMQBinSink()
|
FairMQBinSink::~FairMQBinSink()
|
||||||
|
|
|
@ -10,19 +10,21 @@
|
||||||
|
|
||||||
#include "FairMQDevice.h"
|
#include "FairMQDevice.h"
|
||||||
|
|
||||||
struct Content {
|
struct Content
|
||||||
double a;
|
{
|
||||||
double b;
|
double a;
|
||||||
int x;
|
double b;
|
||||||
int y;
|
int x;
|
||||||
int z;
|
int y;
|
||||||
|
int z;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FairMQBinSink: public FairMQDevice
|
class FairMQBinSink : public FairMQDevice
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FairMQBinSink();
|
FairMQBinSink();
|
||||||
virtual ~FairMQBinSink();
|
virtual ~FairMQBinSink();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Run();
|
virtual void Run();
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,11 +15,10 @@
|
||||||
|
|
||||||
#include "payload.pb.h"
|
#include "payload.pb.h"
|
||||||
|
|
||||||
|
FairMQProtoSampler::FairMQProtoSampler()
|
||||||
FairMQProtoSampler::FairMQProtoSampler() :
|
: fEventSize(10000)
|
||||||
fEventSize(10000),
|
, fEventRate(1)
|
||||||
fEventRate(1),
|
, fEventCounter(0)
|
||||||
fEventCounter(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,145 +28,157 @@ FairMQProtoSampler::~FairMQProtoSampler()
|
||||||
|
|
||||||
void FairMQProtoSampler::Init()
|
void FairMQProtoSampler::Init()
|
||||||
{
|
{
|
||||||
FairMQDevice::Init();
|
FairMQDevice::Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQProtoSampler::Run()
|
void FairMQProtoSampler::Run()
|
||||||
{
|
{
|
||||||
LOG(INFO) << ">>>>>>> Run <<<<<<<";
|
LOG(INFO) << ">>>>>>> Run <<<<<<<";
|
||||||
//boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
|
// boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
|
||||||
|
|
||||||
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
||||||
boost::thread resetEventCounter(boost::bind(&FairMQProtoSampler::ResetEventCounter, this));
|
boost::thread resetEventCounter(boost::bind(&FairMQProtoSampler::ResetEventCounter, this));
|
||||||
|
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
|
|
||||||
while ( fState == RUNNING ) {
|
while (fState == RUNNING)
|
||||||
|
{
|
||||||
|
|
||||||
sampler::Payload p;
|
sampler::Payload p;
|
||||||
|
|
||||||
for (int i = 0; i < fEventSize; ++i) {
|
for (int i = 0; i < fEventSize; ++i)
|
||||||
sampler::Content* content = p.add_data();
|
{
|
||||||
|
sampler::Content* content = p.add_data();
|
||||||
|
|
||||||
content->set_x(rand() % 100 + 1);
|
content->set_x(rand() % 100 + 1);
|
||||||
content->set_y(rand() % 100 + 1);
|
content->set_y(rand() % 100 + 1);
|
||||||
content->set_z(rand() % 100 + 1);
|
content->set_z(rand() % 100 + 1);
|
||||||
content->set_a((rand() % 100 + 1) / (rand() % 100 + 1));
|
content->set_a((rand() % 100 + 1) / (rand() % 100 + 1));
|
||||||
content->set_b((rand() % 100 + 1) / (rand() % 100 + 1));
|
content->set_b((rand() % 100 + 1) / (rand() % 100 + 1));
|
||||||
// LOG(INFO) << content->x() << " " << content->y() << " " << content->z() << " " << content->a() << " " << content->b();
|
// LOG(INFO) << content->x() << " " << content->y() << " " << content->z() << " " << content->a() << " " << content->b();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string str;
|
||||||
|
p.SerializeToString(&str);
|
||||||
|
size_t size = str.length();
|
||||||
|
|
||||||
|
FairMQMessage* msg = fTransportFactory->CreateMessage(size);
|
||||||
|
memcpy(msg->GetData(), str.c_str(), size);
|
||||||
|
|
||||||
|
fPayloadOutputs->at(0)->Send(msg);
|
||||||
|
|
||||||
|
--fEventCounter;
|
||||||
|
|
||||||
|
while (fEventCounter == 0)
|
||||||
|
{
|
||||||
|
boost::this_thread::sleep(boost::posix_time::milliseconds(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
delete msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string str;
|
rateLogger.interrupt();
|
||||||
p.SerializeToString(&str);
|
resetEventCounter.interrupt();
|
||||||
size_t size = str.length();
|
|
||||||
|
|
||||||
FairMQMessage* msg = fTransportFactory->CreateMessage(size);
|
rateLogger.join();
|
||||||
memcpy(msg->GetData(), str.c_str(), size);
|
resetEventCounter.join();
|
||||||
|
|
||||||
fPayloadOutputs->at(0)->Send(msg);
|
|
||||||
|
|
||||||
--fEventCounter;
|
|
||||||
|
|
||||||
while (fEventCounter == 0) {
|
|
||||||
boost::this_thread::sleep(boost::posix_time::milliseconds(1));
|
|
||||||
}
|
|
||||||
|
|
||||||
delete msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateLogger.interrupt();
|
|
||||||
resetEventCounter.interrupt();
|
|
||||||
|
|
||||||
rateLogger.join();
|
|
||||||
resetEventCounter.join();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQProtoSampler::ResetEventCounter()
|
void FairMQProtoSampler::ResetEventCounter()
|
||||||
{
|
{
|
||||||
while ( true ) {
|
while (true)
|
||||||
try {
|
{
|
||||||
fEventCounter = fEventRate / 100;
|
try
|
||||||
boost::this_thread::sleep(boost::posix_time::milliseconds(10));
|
{
|
||||||
} catch (boost::thread_interrupted&) {
|
fEventCounter = fEventRate / 100;
|
||||||
break;
|
boost::this_thread::sleep(boost::posix_time::milliseconds(10));
|
||||||
|
}
|
||||||
|
catch (boost::thread_interrupted&)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQProtoSampler::Log(int intervalInMs)
|
void FairMQProtoSampler::Log(int intervalInMs)
|
||||||
{
|
{
|
||||||
timestamp_t t0;
|
timestamp_t t0;
|
||||||
timestamp_t t1;
|
timestamp_t t1;
|
||||||
unsigned long bytes = fPayloadOutputs->at(0)->GetBytesTx();
|
unsigned long bytes = fPayloadOutputs->at(0)->GetBytesTx();
|
||||||
unsigned long messages = fPayloadOutputs->at(0)->GetMessagesTx();
|
unsigned long messages = fPayloadOutputs->at(0)->GetMessagesTx();
|
||||||
unsigned long bytesNew = 0;
|
unsigned long bytesNew = 0;
|
||||||
unsigned long messagesNew = 0;
|
unsigned long messagesNew = 0;
|
||||||
double megabytesPerSecond = 0;
|
double megabytesPerSecond = 0;
|
||||||
double messagesPerSecond = 0;
|
double messagesPerSecond = 0;
|
||||||
|
|
||||||
t0 = get_timestamp();
|
t0 = get_timestamp();
|
||||||
|
|
||||||
while (true) {
|
while (true)
|
||||||
boost::this_thread::sleep(boost::posix_time::milliseconds(intervalInMs));
|
{
|
||||||
|
boost::this_thread::sleep(boost::posix_time::milliseconds(intervalInMs));
|
||||||
|
|
||||||
t1 = get_timestamp();
|
t1 = get_timestamp();
|
||||||
|
|
||||||
bytesNew = fPayloadOutputs->at(0)->GetBytesTx();
|
bytesNew = fPayloadOutputs->at(0)->GetBytesTx();
|
||||||
messagesNew = fPayloadOutputs->at(0)->GetMessagesTx();
|
messagesNew = fPayloadOutputs->at(0)->GetMessagesTx();
|
||||||
|
|
||||||
timestamp_t timeSinceLastLog_ms = (t1 - t0) / 1000.0L;
|
timestamp_t timeSinceLastLog_ms = (t1 - t0) / 1000.0L;
|
||||||
|
|
||||||
megabytesPerSecond = ((double) (bytesNew - bytes) / (1024. * 1024.)) / (double) timeSinceLastLog_ms * 1000.;
|
megabytesPerSecond = ((double)(bytesNew - bytes) / (1024. * 1024.)) / (double)timeSinceLastLog_ms * 1000.;
|
||||||
messagesPerSecond = (double) (messagesNew - messages) / (double) timeSinceLastLog_ms * 1000.;
|
messagesPerSecond = (double)(messagesNew - messages) / (double)timeSinceLastLog_ms * 1000.;
|
||||||
|
|
||||||
LOG(DEBUG) << "send " << messagesPerSecond << " msg/s, " << megabytesPerSecond << " MB/s";
|
LOG(DEBUG) << "send " << messagesPerSecond << " msg/s, " << megabytesPerSecond << " MB/s";
|
||||||
|
|
||||||
bytes = bytesNew;
|
bytes = bytesNew;
|
||||||
messages = messagesNew;
|
messages = messagesNew;
|
||||||
t0 = t1;
|
t0 = t1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQProtoSampler::SetProperty(const int key, const string& value, const int slot/*= 0*/)
|
void FairMQProtoSampler::SetProperty(const int key, const string& value, const int slot /*= 0*/)
|
||||||
{
|
{
|
||||||
switch (key) {
|
switch (key)
|
||||||
default:
|
{
|
||||||
FairMQDevice::SetProperty(key, value, slot);
|
default:
|
||||||
break;
|
FairMQDevice::SetProperty(key, value, slot);
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string FairMQProtoSampler::GetProperty(const int key, const string& default_/*= ""*/, const int slot/*= 0*/)
|
string FairMQProtoSampler::GetProperty(const int key, const string& default_ /*= ""*/, const int slot /*= 0*/)
|
||||||
{
|
{
|
||||||
switch (key) {
|
switch (key)
|
||||||
default:
|
{
|
||||||
return FairMQDevice::GetProperty(key, default_, slot);
|
default:
|
||||||
}
|
return FairMQDevice::GetProperty(key, default_, slot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQProtoSampler::SetProperty(const int key, const int value, const int slot/*= 0*/)
|
void FairMQProtoSampler::SetProperty(const int key, const int value, const int slot /*= 0*/)
|
||||||
{
|
{
|
||||||
switch (key) {
|
switch (key)
|
||||||
case EventSize:
|
{
|
||||||
fEventSize = value;
|
case EventSize:
|
||||||
break;
|
fEventSize = value;
|
||||||
case EventRate:
|
break;
|
||||||
fEventRate = value;
|
case EventRate:
|
||||||
break;
|
fEventRate = value;
|
||||||
default:
|
break;
|
||||||
FairMQDevice::SetProperty(key, value, slot);
|
default:
|
||||||
break;
|
FairMQDevice::SetProperty(key, value, slot);
|
||||||
}
|
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*/, const int slot /*= 0*/)
|
||||||
{
|
{
|
||||||
switch (key) {
|
switch (key)
|
||||||
case EventSize:
|
{
|
||||||
return fEventSize;
|
case EventSize:
|
||||||
case EventRate:
|
return fEventSize;
|
||||||
return fEventRate;
|
case EventRate:
|
||||||
default:
|
return fEventRate;
|
||||||
return FairMQDevice::GetProperty(key, default_, slot);
|
default:
|
||||||
}
|
return FairMQDevice::GetProperty(key, default_, slot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,14 +12,15 @@
|
||||||
|
|
||||||
#include "FairMQDevice.h"
|
#include "FairMQDevice.h"
|
||||||
|
|
||||||
class FairMQProtoSampler: public FairMQDevice
|
class FairMQProtoSampler : public FairMQDevice
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum {
|
enum
|
||||||
InputFile = FairMQDevice::Last,
|
{
|
||||||
EventRate,
|
InputFile = FairMQDevice::Last,
|
||||||
EventSize,
|
EventRate,
|
||||||
Last
|
EventSize,
|
||||||
|
Last
|
||||||
};
|
};
|
||||||
FairMQProtoSampler();
|
FairMQProtoSampler();
|
||||||
virtual ~FairMQProtoSampler();
|
virtual ~FairMQProtoSampler();
|
||||||
|
|
|
@ -19,29 +19,30 @@ FairMQProtoSink::FairMQProtoSink()
|
||||||
|
|
||||||
void FairMQProtoSink::Run()
|
void FairMQProtoSink::Run()
|
||||||
{
|
{
|
||||||
LOG(INFO) << ">>>>>>> Run <<<<<<<";
|
LOG(INFO) << ">>>>>>> Run <<<<<<<";
|
||||||
|
|
||||||
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
||||||
|
|
||||||
while ( fState == RUNNING ) {
|
while (fState == RUNNING)
|
||||||
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
{
|
||||||
|
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
||||||
|
|
||||||
fPayloadInputs->at(0)->Receive(msg);
|
fPayloadInputs->at(0)->Receive(msg);
|
||||||
|
|
||||||
sampler::Payload p;
|
sampler::Payload p;
|
||||||
|
|
||||||
p.ParseFromArray(msg->GetData(), msg->GetSize());
|
p.ParseFromArray(msg->GetData(), msg->GetSize());
|
||||||
|
|
||||||
// for (int i = 0; i < p.data_size(); ++i) {
|
// for (int i = 0; i < p.data_size(); ++i) {
|
||||||
// const sampler::Payload::Content& content = p.data(i);
|
// const sampler::Payload::Content& content = p.data(i);
|
||||||
// LOG(INFO) << content.x() << " " << content.y() << " " << content.z() << " " << content.a() << " " << content.b();
|
// LOG(INFO) << content.x() << " " << content.y() << " " << content.z() << " " << content.a() << " " << content.b();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
delete msg;
|
delete msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
rateLogger.interrupt();
|
rateLogger.interrupt();
|
||||||
rateLogger.join();
|
rateLogger.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQProtoSink::~FairMQProtoSink()
|
FairMQProtoSink::~FairMQProtoSink()
|
||||||
|
|
|
@ -10,19 +10,21 @@
|
||||||
|
|
||||||
#include "FairMQDevice.h"
|
#include "FairMQDevice.h"
|
||||||
|
|
||||||
struct Content {
|
struct Content
|
||||||
double a;
|
{
|
||||||
double b;
|
double a;
|
||||||
int x;
|
double b;
|
||||||
int y;
|
int x;
|
||||||
int z;
|
int y;
|
||||||
|
int z;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FairMQProtoSink: public FairMQDevice
|
class FairMQProtoSink : public FairMQDevice
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FairMQProtoSink();
|
FairMQProtoSink();
|
||||||
virtual ~FairMQProtoSink();
|
virtual ~FairMQProtoSink();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Run();
|
virtual void Run();
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,9 +12,9 @@
|
||||||
#include "FairMQBenchmarkSampler.h"
|
#include "FairMQBenchmarkSampler.h"
|
||||||
|
|
||||||
#ifdef NANOMSG
|
#ifdef NANOMSG
|
||||||
#include "FairMQTransportFactoryNN.h"
|
#include "FairMQTransportFactoryNN.h"
|
||||||
#else
|
#else
|
||||||
#include "FairMQTransportFactoryZMQ.h"
|
#include "FairMQTransportFactoryZMQ.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
|
@ -22,102 +22,95 @@ using std::cin;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using std::stringstream;
|
using std::stringstream;
|
||||||
|
|
||||||
|
|
||||||
FairMQBenchmarkSampler sampler;
|
FairMQBenchmarkSampler sampler;
|
||||||
|
|
||||||
static void s_signal_handler (int signal)
|
static void s_signal_handler(int signal)
|
||||||
{
|
{
|
||||||
cout << endl << "Caught signal " << signal << endl;
|
cout << endl << "Caught signal " << signal << endl;
|
||||||
|
|
||||||
sampler.ChangeState(FairMQBenchmarkSampler::STOP);
|
sampler.ChangeState(FairMQBenchmarkSampler::STOP);
|
||||||
sampler.ChangeState(FairMQBenchmarkSampler::END);
|
sampler.ChangeState(FairMQBenchmarkSampler::END);
|
||||||
|
|
||||||
cout << "Shutdown complete. Bye!" << endl;
|
cout << "Shutdown complete. Bye!" << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void s_catch_signals (void)
|
static void s_catch_signals(void)
|
||||||
{
|
{
|
||||||
struct sigaction action;
|
struct sigaction action;
|
||||||
action.sa_handler = s_signal_handler;
|
action.sa_handler = s_signal_handler;
|
||||||
action.sa_flags = 0;
|
action.sa_flags = 0;
|
||||||
sigemptyset(&action.sa_mask);
|
sigemptyset(&action.sa_mask);
|
||||||
sigaction(SIGINT, &action, NULL);
|
sigaction(SIGINT, &action, NULL);
|
||||||
sigaction(SIGTERM, &action, NULL);
|
sigaction(SIGTERM, &action, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
if ( argc != 9 ) {
|
if (argc != 9)
|
||||||
cout << "Usage: bsampler ID eventSize eventRate numIoTreads\n"
|
{
|
||||||
<< "\t\toutputSocketType outputSndBufSize outputMethod outputAddress\n"
|
cout << "Usage: bsampler ID eventSize eventRate numIoTreads\n"
|
||||||
<< endl;
|
<< "\t\toutputSocketType outputSndBufSize outputMethod outputAddress\n" << endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
s_catch_signals();
|
s_catch_signals();
|
||||||
|
|
||||||
LOG(INFO) << "PID: " << getpid();
|
LOG(INFO) << "PID: " << getpid();
|
||||||
|
|
||||||
#ifdef NANOMSG
|
#ifdef NANOMSG
|
||||||
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
|
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
|
||||||
#else
|
#else
|
||||||
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
|
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sampler.SetTransport(transportFactory);
|
sampler.SetTransport(transportFactory);
|
||||||
|
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
sampler.SetProperty(FairMQBenchmarkSampler::Id, argv[i]);
|
sampler.SetProperty(FairMQBenchmarkSampler::Id, argv[i]);
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
int eventSize;
|
int eventSize;
|
||||||
stringstream(argv[i]) >> eventSize;
|
stringstream(argv[i]) >> eventSize;
|
||||||
sampler.SetProperty(FairMQBenchmarkSampler::EventSize, eventSize);
|
sampler.SetProperty(FairMQBenchmarkSampler::EventSize, eventSize);
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
int eventRate;
|
int eventRate;
|
||||||
stringstream(argv[i]) >> eventRate;
|
stringstream(argv[i]) >> eventRate;
|
||||||
sampler.SetProperty(FairMQBenchmarkSampler::EventRate, eventRate);
|
sampler.SetProperty(FairMQBenchmarkSampler::EventRate, eventRate);
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
int numIoThreads;
|
int numIoThreads;
|
||||||
stringstream(argv[i]) >> numIoThreads;
|
stringstream(argv[i]) >> numIoThreads;
|
||||||
sampler.SetProperty(FairMQBenchmarkSampler::NumIoThreads, numIoThreads);
|
sampler.SetProperty(FairMQBenchmarkSampler::NumIoThreads, numIoThreads);
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
sampler.SetProperty(FairMQBenchmarkSampler::NumInputs, 0);
|
sampler.SetProperty(FairMQBenchmarkSampler::NumInputs, 0);
|
||||||
sampler.SetProperty(FairMQBenchmarkSampler::NumOutputs, 1);
|
sampler.SetProperty(FairMQBenchmarkSampler::NumOutputs, 1);
|
||||||
|
|
||||||
|
sampler.ChangeState(FairMQBenchmarkSampler::INIT);
|
||||||
|
|
||||||
sampler.ChangeState(FairMQBenchmarkSampler::INIT);
|
sampler.SetProperty(FairMQBenchmarkSampler::OutputSocketType, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
int outputSndBufSize;
|
||||||
|
stringstream(argv[i]) >> outputSndBufSize;
|
||||||
|
sampler.SetProperty(FairMQBenchmarkSampler::OutputSndBufSize, outputSndBufSize, 0);
|
||||||
|
++i;
|
||||||
|
sampler.SetProperty(FairMQBenchmarkSampler::OutputMethod, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
sampler.SetProperty(FairMQBenchmarkSampler::OutputAddress, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
|
||||||
|
sampler.ChangeState(FairMQBenchmarkSampler::SETOUTPUT);
|
||||||
|
sampler.ChangeState(FairMQBenchmarkSampler::SETINPUT);
|
||||||
|
sampler.ChangeState(FairMQBenchmarkSampler::RUN);
|
||||||
|
|
||||||
sampler.SetProperty(FairMQBenchmarkSampler::OutputSocketType, argv[i], 0);
|
char ch;
|
||||||
++i;
|
cin.get(ch);
|
||||||
int outputSndBufSize;
|
|
||||||
stringstream(argv[i]) >> outputSndBufSize;
|
|
||||||
sampler.SetProperty(FairMQBenchmarkSampler::OutputSndBufSize, outputSndBufSize, 0);
|
|
||||||
++i;
|
|
||||||
sampler.SetProperty(FairMQBenchmarkSampler::OutputMethod, argv[i], 0);
|
|
||||||
++i;
|
|
||||||
sampler.SetProperty(FairMQBenchmarkSampler::OutputAddress, argv[i], 0);
|
|
||||||
++i;
|
|
||||||
|
|
||||||
|
sampler.ChangeState(FairMQBenchmarkSampler::STOP);
|
||||||
|
sampler.ChangeState(FairMQBenchmarkSampler::END);
|
||||||
|
|
||||||
sampler.ChangeState(FairMQBenchmarkSampler::SETOUTPUT);
|
return 0;
|
||||||
sampler.ChangeState(FairMQBenchmarkSampler::SETINPUT);
|
|
||||||
sampler.ChangeState(FairMQBenchmarkSampler::RUN);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char ch;
|
|
||||||
cin.get(ch);
|
|
||||||
|
|
||||||
sampler.ChangeState(FairMQBenchmarkSampler::STOP);
|
|
||||||
sampler.ChangeState(FairMQBenchmarkSampler::END);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,9 @@
|
||||||
#include "FairMQBinSampler.h"
|
#include "FairMQBinSampler.h"
|
||||||
|
|
||||||
#ifdef NANOMSG
|
#ifdef NANOMSG
|
||||||
#include "FairMQTransportFactoryNN.h"
|
#include "FairMQTransportFactoryNN.h"
|
||||||
#else
|
#else
|
||||||
#include "FairMQTransportFactoryZMQ.h"
|
#include "FairMQTransportFactoryZMQ.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
|
@ -22,102 +22,95 @@ using std::cin;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using std::stringstream;
|
using std::stringstream;
|
||||||
|
|
||||||
|
|
||||||
FairMQBinSampler sampler;
|
FairMQBinSampler sampler;
|
||||||
|
|
||||||
static void s_signal_handler (int signal)
|
static void s_signal_handler(int signal)
|
||||||
{
|
{
|
||||||
cout << endl << "Caught signal " << signal << endl;
|
cout << endl << "Caught signal " << signal << endl;
|
||||||
|
|
||||||
sampler.ChangeState(FairMQBinSampler::STOP);
|
sampler.ChangeState(FairMQBinSampler::STOP);
|
||||||
sampler.ChangeState(FairMQBinSampler::END);
|
sampler.ChangeState(FairMQBinSampler::END);
|
||||||
|
|
||||||
cout << "Shutdown complete. Bye!" << endl;
|
cout << "Shutdown complete. Bye!" << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void s_catch_signals (void)
|
static void s_catch_signals(void)
|
||||||
{
|
{
|
||||||
struct sigaction action;
|
struct sigaction action;
|
||||||
action.sa_handler = s_signal_handler;
|
action.sa_handler = s_signal_handler;
|
||||||
action.sa_flags = 0;
|
action.sa_flags = 0;
|
||||||
sigemptyset(&action.sa_mask);
|
sigemptyset(&action.sa_mask);
|
||||||
sigaction(SIGINT, &action, NULL);
|
sigaction(SIGINT, &action, NULL);
|
||||||
sigaction(SIGTERM, &action, NULL);
|
sigaction(SIGTERM, &action, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
if ( argc != 9 ) {
|
if (argc != 9)
|
||||||
cout << "Usage: bsampler ID eventSize eventRate numIoTreads\n"
|
{
|
||||||
<< "\t\toutputSocketType outputSndBufSize outputMethod outputAddress\n"
|
cout << "Usage: bsampler ID eventSize eventRate numIoTreads\n"
|
||||||
<< endl;
|
<< "\t\toutputSocketType outputSndBufSize outputMethod outputAddress\n" << endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
s_catch_signals();
|
s_catch_signals();
|
||||||
|
|
||||||
LOG(INFO) << "PID: " << getpid();
|
LOG(INFO) << "PID: " << getpid();
|
||||||
|
|
||||||
#ifdef NANOMSG
|
#ifdef NANOMSG
|
||||||
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
|
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
|
||||||
#else
|
#else
|
||||||
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
|
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sampler.SetTransport(transportFactory);
|
sampler.SetTransport(transportFactory);
|
||||||
|
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
sampler.SetProperty(FairMQBinSampler::Id, argv[i]);
|
sampler.SetProperty(FairMQBinSampler::Id, argv[i]);
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
int eventSize;
|
int eventSize;
|
||||||
stringstream(argv[i]) >> eventSize;
|
stringstream(argv[i]) >> eventSize;
|
||||||
sampler.SetProperty(FairMQBinSampler::EventSize, eventSize);
|
sampler.SetProperty(FairMQBinSampler::EventSize, eventSize);
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
int eventRate;
|
int eventRate;
|
||||||
stringstream(argv[i]) >> eventRate;
|
stringstream(argv[i]) >> eventRate;
|
||||||
sampler.SetProperty(FairMQBinSampler::EventRate, eventRate);
|
sampler.SetProperty(FairMQBinSampler::EventRate, eventRate);
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
int numIoThreads;
|
int numIoThreads;
|
||||||
stringstream(argv[i]) >> numIoThreads;
|
stringstream(argv[i]) >> numIoThreads;
|
||||||
sampler.SetProperty(FairMQBinSampler::NumIoThreads, numIoThreads);
|
sampler.SetProperty(FairMQBinSampler::NumIoThreads, numIoThreads);
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
sampler.SetProperty(FairMQBinSampler::NumInputs, 0);
|
sampler.SetProperty(FairMQBinSampler::NumInputs, 0);
|
||||||
sampler.SetProperty(FairMQBinSampler::NumOutputs, 1);
|
sampler.SetProperty(FairMQBinSampler::NumOutputs, 1);
|
||||||
|
|
||||||
|
sampler.ChangeState(FairMQBinSampler::INIT);
|
||||||
|
|
||||||
sampler.ChangeState(FairMQBinSampler::INIT);
|
sampler.SetProperty(FairMQBinSampler::OutputSocketType, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
int outputSndBufSize;
|
||||||
|
stringstream(argv[i]) >> outputSndBufSize;
|
||||||
|
sampler.SetProperty(FairMQBinSampler::OutputSndBufSize, outputSndBufSize, 0);
|
||||||
|
++i;
|
||||||
|
sampler.SetProperty(FairMQBinSampler::OutputMethod, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
sampler.SetProperty(FairMQBinSampler::OutputAddress, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
|
||||||
|
sampler.ChangeState(FairMQBinSampler::SETOUTPUT);
|
||||||
|
sampler.ChangeState(FairMQBinSampler::SETINPUT);
|
||||||
|
sampler.ChangeState(FairMQBinSampler::RUN);
|
||||||
|
|
||||||
sampler.SetProperty(FairMQBinSampler::OutputSocketType, argv[i], 0);
|
char ch;
|
||||||
++i;
|
cin.get(ch);
|
||||||
int outputSndBufSize;
|
|
||||||
stringstream(argv[i]) >> outputSndBufSize;
|
|
||||||
sampler.SetProperty(FairMQBinSampler::OutputSndBufSize, outputSndBufSize, 0);
|
|
||||||
++i;
|
|
||||||
sampler.SetProperty(FairMQBinSampler::OutputMethod, argv[i], 0);
|
|
||||||
++i;
|
|
||||||
sampler.SetProperty(FairMQBinSampler::OutputAddress, argv[i], 0);
|
|
||||||
++i;
|
|
||||||
|
|
||||||
|
sampler.ChangeState(FairMQBinSampler::STOP);
|
||||||
|
sampler.ChangeState(FairMQBinSampler::END);
|
||||||
|
|
||||||
sampler.ChangeState(FairMQBinSampler::SETOUTPUT);
|
return 0;
|
||||||
sampler.ChangeState(FairMQBinSampler::SETINPUT);
|
|
||||||
sampler.ChangeState(FairMQBinSampler::RUN);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char ch;
|
|
||||||
cin.get(ch);
|
|
||||||
|
|
||||||
sampler.ChangeState(FairMQBinSampler::STOP);
|
|
||||||
sampler.ChangeState(FairMQBinSampler::END);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,9 @@
|
||||||
#include "FairMQBinSink.h"
|
#include "FairMQBinSink.h"
|
||||||
|
|
||||||
#ifdef NANOMSG
|
#ifdef NANOMSG
|
||||||
#include "FairMQTransportFactoryNN.h"
|
#include "FairMQTransportFactoryNN.h"
|
||||||
#else
|
#else
|
||||||
#include "FairMQTransportFactoryZMQ.h"
|
#include "FairMQTransportFactoryZMQ.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
|
@ -22,91 +22,85 @@ using std::cin;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using std::stringstream;
|
using std::stringstream;
|
||||||
|
|
||||||
|
|
||||||
FairMQBinSink sink;
|
FairMQBinSink sink;
|
||||||
|
|
||||||
static void s_signal_handler (int signal)
|
static void s_signal_handler(int signal)
|
||||||
{
|
{
|
||||||
cout << endl << "Caught signal " << signal << endl;
|
cout << endl << "Caught signal " << signal << endl;
|
||||||
|
|
||||||
sink.ChangeState(FairMQBinSink::STOP);
|
sink.ChangeState(FairMQBinSink::STOP);
|
||||||
sink.ChangeState(FairMQBinSink::END);
|
sink.ChangeState(FairMQBinSink::END);
|
||||||
|
|
||||||
cout << "Shutdown complete. Bye!" << endl;
|
cout << "Shutdown complete. Bye!" << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void s_catch_signals (void)
|
static void s_catch_signals(void)
|
||||||
{
|
{
|
||||||
struct sigaction action;
|
struct sigaction action;
|
||||||
action.sa_handler = s_signal_handler;
|
action.sa_handler = s_signal_handler;
|
||||||
action.sa_flags = 0;
|
action.sa_flags = 0;
|
||||||
sigemptyset(&action.sa_mask);
|
sigemptyset(&action.sa_mask);
|
||||||
sigaction(SIGINT, &action, NULL);
|
sigaction(SIGINT, &action, NULL);
|
||||||
sigaction(SIGTERM, &action, NULL);
|
sigaction(SIGTERM, &action, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
if ( argc != 7 ) {
|
if (argc != 7)
|
||||||
cout << "Usage: sink \tID numIoTreads\n"
|
{
|
||||||
<< "\t\tinputSocketType inputRcvBufSize inputMethod inputAddress\n"
|
cout << "Usage: sink \tID numIoTreads\n"
|
||||||
<< endl;
|
<< "\t\tinputSocketType inputRcvBufSize inputMethod inputAddress\n" << endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
s_catch_signals();
|
s_catch_signals();
|
||||||
|
|
||||||
LOG(INFO) << "PID: " << getpid();
|
LOG(INFO) << "PID: " << getpid();
|
||||||
|
|
||||||
#ifdef NANOMSG
|
#ifdef NANOMSG
|
||||||
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
|
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
|
||||||
#else
|
#else
|
||||||
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
|
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sink.SetTransport(transportFactory);
|
sink.SetTransport(transportFactory);
|
||||||
|
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
sink.SetProperty(FairMQBinSink::Id, argv[i]);
|
sink.SetProperty(FairMQBinSink::Id, argv[i]);
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
int numIoThreads;
|
int numIoThreads;
|
||||||
stringstream(argv[i]) >> numIoThreads;
|
stringstream(argv[i]) >> numIoThreads;
|
||||||
sink.SetProperty(FairMQBinSink::NumIoThreads, numIoThreads);
|
sink.SetProperty(FairMQBinSink::NumIoThreads, numIoThreads);
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
sink.SetProperty(FairMQBinSink::NumInputs, 1);
|
sink.SetProperty(FairMQBinSink::NumInputs, 1);
|
||||||
sink.SetProperty(FairMQBinSink::NumOutputs, 0);
|
sink.SetProperty(FairMQBinSink::NumOutputs, 0);
|
||||||
|
|
||||||
|
sink.ChangeState(FairMQBinSink::INIT);
|
||||||
|
|
||||||
sink.ChangeState(FairMQBinSink::INIT);
|
sink.SetProperty(FairMQBinSink::InputSocketType, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
int inputRcvBufSize;
|
||||||
|
stringstream(argv[i]) >> inputRcvBufSize;
|
||||||
|
sink.SetProperty(FairMQBinSink::InputRcvBufSize, inputRcvBufSize, 0);
|
||||||
|
++i;
|
||||||
|
sink.SetProperty(FairMQBinSink::InputMethod, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
sink.SetProperty(FairMQBinSink::InputAddress, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
|
||||||
|
sink.ChangeState(FairMQBinSink::SETOUTPUT);
|
||||||
|
sink.ChangeState(FairMQBinSink::SETINPUT);
|
||||||
|
sink.ChangeState(FairMQBinSink::RUN);
|
||||||
|
|
||||||
sink.SetProperty(FairMQBinSink::InputSocketType, argv[i], 0);
|
char ch;
|
||||||
++i;
|
cin.get(ch);
|
||||||
int inputRcvBufSize;
|
|
||||||
stringstream(argv[i]) >> inputRcvBufSize;
|
|
||||||
sink.SetProperty(FairMQBinSink::InputRcvBufSize, inputRcvBufSize, 0);
|
|
||||||
++i;
|
|
||||||
sink.SetProperty(FairMQBinSink::InputMethod, argv[i], 0);
|
|
||||||
++i;
|
|
||||||
sink.SetProperty(FairMQBinSink::InputAddress, argv[i], 0);
|
|
||||||
++i;
|
|
||||||
|
|
||||||
|
sink.ChangeState(FairMQBinSink::STOP);
|
||||||
|
sink.ChangeState(FairMQBinSink::END);
|
||||||
|
|
||||||
sink.ChangeState(FairMQBinSink::SETOUTPUT);
|
return 0;
|
||||||
sink.ChangeState(FairMQBinSink::SETINPUT);
|
|
||||||
sink.ChangeState(FairMQBinSink::RUN);
|
|
||||||
|
|
||||||
|
|
||||||
char ch;
|
|
||||||
cin.get(ch);
|
|
||||||
|
|
||||||
sink.ChangeState(FairMQBinSink::STOP);
|
|
||||||
sink.ChangeState(FairMQBinSink::END);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,9 @@
|
||||||
#include "FairMQBuffer.h"
|
#include "FairMQBuffer.h"
|
||||||
|
|
||||||
#ifdef NANOMSG
|
#ifdef NANOMSG
|
||||||
#include "FairMQTransportFactoryNN.h"
|
#include "FairMQTransportFactoryNN.h"
|
||||||
#else
|
#else
|
||||||
#include "FairMQTransportFactoryZMQ.h"
|
#include "FairMQTransportFactoryZMQ.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
|
@ -22,102 +22,96 @@ using std::cin;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using std::stringstream;
|
using std::stringstream;
|
||||||
|
|
||||||
|
|
||||||
FairMQBuffer buffer;
|
FairMQBuffer buffer;
|
||||||
|
|
||||||
static void s_signal_handler (int signal)
|
static void s_signal_handler(int signal)
|
||||||
{
|
{
|
||||||
cout << endl << "Caught signal " << signal << endl;
|
cout << endl << "Caught signal " << signal << endl;
|
||||||
|
|
||||||
buffer.ChangeState(FairMQBuffer::STOP);
|
buffer.ChangeState(FairMQBuffer::STOP);
|
||||||
buffer.ChangeState(FairMQBuffer::END);
|
buffer.ChangeState(FairMQBuffer::END);
|
||||||
|
|
||||||
cout << "Shutdown complete. Bye!" << endl;
|
cout << "Shutdown complete. Bye!" << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void s_catch_signals (void)
|
static void s_catch_signals(void)
|
||||||
{
|
{
|
||||||
struct sigaction action;
|
struct sigaction action;
|
||||||
action.sa_handler = s_signal_handler;
|
action.sa_handler = s_signal_handler;
|
||||||
action.sa_flags = 0;
|
action.sa_flags = 0;
|
||||||
sigemptyset(&action.sa_mask);
|
sigemptyset(&action.sa_mask);
|
||||||
sigaction(SIGINT, &action, NULL);
|
sigaction(SIGINT, &action, NULL);
|
||||||
sigaction(SIGTERM, &action, NULL);
|
sigaction(SIGTERM, &action, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
if ( argc != 11 ) {
|
if (argc != 11)
|
||||||
cout << "Usage: buffer \tID numIoTreads\n"
|
{
|
||||||
<< "\t\tinputSocketType inputRcvBufSize inputMethod inputAddress\n"
|
cout << "Usage: buffer \tID numIoTreads\n"
|
||||||
<< "\t\toutputSocketType outputSndBufSize outputMethod outputAddress\n" << endl;
|
<< "\t\tinputSocketType inputRcvBufSize inputMethod inputAddress\n"
|
||||||
return 1;
|
<< "\t\toutputSocketType outputSndBufSize outputMethod outputAddress\n" << endl;
|
||||||
}
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
s_catch_signals();
|
s_catch_signals();
|
||||||
|
|
||||||
LOG(INFO) << "PID: " << getpid();
|
LOG(INFO) << "PID: " << getpid();
|
||||||
|
|
||||||
#ifdef NANOMSG
|
#ifdef NANOMSG
|
||||||
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
|
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
|
||||||
#else
|
#else
|
||||||
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
|
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
buffer.SetTransport(transportFactory);
|
buffer.SetTransport(transportFactory);
|
||||||
|
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
buffer.SetProperty(FairMQBuffer::Id, argv[i]);
|
buffer.SetProperty(FairMQBuffer::Id, argv[i]);
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
int numIoThreads;
|
int numIoThreads;
|
||||||
stringstream(argv[i]) >> numIoThreads;
|
stringstream(argv[i]) >> numIoThreads;
|
||||||
buffer.SetProperty(FairMQBuffer::NumIoThreads, numIoThreads);
|
buffer.SetProperty(FairMQBuffer::NumIoThreads, numIoThreads);
|
||||||
++i;
|
++i;
|
||||||
buffer.SetProperty(FairMQBuffer::NumInputs, 1);
|
buffer.SetProperty(FairMQBuffer::NumInputs, 1);
|
||||||
buffer.SetProperty(FairMQBuffer::NumOutputs, 1);
|
buffer.SetProperty(FairMQBuffer::NumOutputs, 1);
|
||||||
|
|
||||||
|
buffer.ChangeState(FairMQBuffer::INIT);
|
||||||
|
|
||||||
buffer.ChangeState(FairMQBuffer::INIT);
|
buffer.SetProperty(FairMQBuffer::InputSocketType, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
int inputRcvBufSize;
|
||||||
|
stringstream(argv[i]) >> inputRcvBufSize;
|
||||||
|
buffer.SetProperty(FairMQBuffer::InputRcvBufSize, inputRcvBufSize, 0);
|
||||||
|
++i;
|
||||||
|
buffer.SetProperty(FairMQBuffer::InputMethod, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
buffer.SetProperty(FairMQBuffer::InputAddress, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
|
||||||
|
buffer.SetProperty(FairMQBuffer::OutputSocketType, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
int outputSndBufSize;
|
||||||
|
stringstream(argv[i]) >> outputSndBufSize;
|
||||||
|
buffer.SetProperty(FairMQBuffer::OutputSndBufSize, outputSndBufSize, 0);
|
||||||
|
++i;
|
||||||
|
buffer.SetProperty(FairMQBuffer::OutputMethod, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
buffer.SetProperty(FairMQBuffer::OutputAddress, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
|
||||||
buffer.SetProperty(FairMQBuffer::InputSocketType, argv[i], 0);
|
buffer.ChangeState(FairMQBuffer::SETOUTPUT);
|
||||||
++i;
|
buffer.ChangeState(FairMQBuffer::SETINPUT);
|
||||||
int inputRcvBufSize;
|
buffer.ChangeState(FairMQBuffer::RUN);
|
||||||
stringstream(argv[i]) >> inputRcvBufSize;
|
|
||||||
buffer.SetProperty(FairMQBuffer::InputRcvBufSize, inputRcvBufSize, 0);
|
|
||||||
++i;
|
|
||||||
buffer.SetProperty(FairMQBuffer::InputMethod, argv[i], 0);
|
|
||||||
++i;
|
|
||||||
buffer.SetProperty(FairMQBuffer::InputAddress, argv[i], 0);
|
|
||||||
++i;
|
|
||||||
|
|
||||||
buffer.SetProperty(FairMQBuffer::OutputSocketType, argv[i], 0);
|
char ch;
|
||||||
++i;
|
cin.get(ch);
|
||||||
int outputSndBufSize;
|
|
||||||
stringstream(argv[i]) >> outputSndBufSize;
|
|
||||||
buffer.SetProperty(FairMQBuffer::OutputSndBufSize, outputSndBufSize, 0);
|
|
||||||
++i;
|
|
||||||
buffer.SetProperty(FairMQBuffer::OutputMethod, argv[i], 0);
|
|
||||||
++i;
|
|
||||||
buffer.SetProperty(FairMQBuffer::OutputAddress, argv[i], 0);
|
|
||||||
++i;
|
|
||||||
|
|
||||||
|
buffer.ChangeState(FairMQBuffer::STOP);
|
||||||
|
buffer.ChangeState(FairMQBuffer::END);
|
||||||
|
|
||||||
buffer.ChangeState(FairMQBuffer::SETOUTPUT);
|
return 0;
|
||||||
buffer.ChangeState(FairMQBuffer::SETINPUT);
|
|
||||||
buffer.ChangeState(FairMQBuffer::RUN);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char ch;
|
|
||||||
cin.get(ch);
|
|
||||||
|
|
||||||
buffer.ChangeState(FairMQBuffer::STOP);
|
|
||||||
buffer.ChangeState(FairMQBuffer::END);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,9 @@
|
||||||
#include "FairMQMerger.h"
|
#include "FairMQMerger.h"
|
||||||
|
|
||||||
#ifdef NANOMSG
|
#ifdef NANOMSG
|
||||||
#include "FairMQTransportFactoryNN.h"
|
#include "FairMQTransportFactoryNN.h"
|
||||||
#else
|
#else
|
||||||
#include "FairMQTransportFactoryZMQ.h"
|
#include "FairMQTransportFactoryZMQ.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
|
@ -22,108 +22,106 @@ using std::cin;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using std::stringstream;
|
using std::stringstream;
|
||||||
|
|
||||||
|
|
||||||
FairMQMerger merger;
|
FairMQMerger merger;
|
||||||
|
|
||||||
static void s_signal_handler (int signal)
|
static void s_signal_handler(int signal)
|
||||||
{
|
{
|
||||||
cout << endl << "Caught signal " << signal << endl;
|
cout << endl << "Caught signal " << signal << endl;
|
||||||
|
|
||||||
merger.ChangeState(FairMQMerger::STOP);
|
merger.ChangeState(FairMQMerger::STOP);
|
||||||
merger.ChangeState(FairMQMerger::END);
|
merger.ChangeState(FairMQMerger::END);
|
||||||
|
|
||||||
cout << "Shutdown complete. Bye!" << endl;
|
cout << "Shutdown complete. Bye!" << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void s_catch_signals (void)
|
static void s_catch_signals(void)
|
||||||
{
|
{
|
||||||
struct sigaction action;
|
struct sigaction action;
|
||||||
action.sa_handler = s_signal_handler;
|
action.sa_handler = s_signal_handler;
|
||||||
action.sa_flags = 0;
|
action.sa_flags = 0;
|
||||||
sigemptyset(&action.sa_mask);
|
sigemptyset(&action.sa_mask);
|
||||||
sigaction(SIGINT, &action, NULL);
|
sigaction(SIGINT, &action, NULL);
|
||||||
sigaction(SIGTERM, &action, NULL);
|
sigaction(SIGTERM, &action, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
if ( argc < 16 || (argc - 8) % 4 != 0 ) {
|
if (argc < 16 || (argc - 8) % 4 != 0)
|
||||||
cout << "Usage: merger \tID numIoTreads numInputs\n"
|
{
|
||||||
<< "\t\tinputSocketType inputRcvBufSize inputMethod inputAddress\n"
|
cout << "Usage: merger \tID numIoTreads numInputs\n"
|
||||||
<< "\t\tinputSocketType inputRcvBufSize inputMethod inputAddress\n"
|
<< "\t\tinputSocketType inputRcvBufSize inputMethod inputAddress\n"
|
||||||
<< "\t\t...\n"
|
<< "\t\tinputSocketType inputRcvBufSize inputMethod inputAddress\n"
|
||||||
<< "\t\toutputSocketType outputSndBufSize outputMethod outputAddress\n"
|
<< "\t\t...\n"
|
||||||
<< argc << " arguments provided" << endl;
|
<< "\t\toutputSocketType outputSndBufSize outputMethod outputAddress\n" << argc << " arguments provided" << endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
s_catch_signals();
|
s_catch_signals();
|
||||||
|
|
||||||
LOG(INFO) << "PID: " << getpid();
|
LOG(INFO) << "PID: " << getpid();
|
||||||
|
|
||||||
#ifdef NANOMSG
|
#ifdef NANOMSG
|
||||||
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
|
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
|
||||||
#else
|
#else
|
||||||
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
|
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
merger.SetTransport(transportFactory);
|
merger.SetTransport(transportFactory);
|
||||||
|
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
merger.SetProperty(FairMQMerger::Id, argv[i]);
|
merger.SetProperty(FairMQMerger::Id, argv[i]);
|
||||||
++i;
|
|
||||||
|
|
||||||
int numIoThreads;
|
|
||||||
stringstream(argv[i]) >> numIoThreads;
|
|
||||||
merger.SetProperty(FairMQMerger::NumIoThreads, numIoThreads);
|
|
||||||
++i;
|
|
||||||
|
|
||||||
int numInputs;
|
|
||||||
stringstream(argv[i]) >> numInputs;
|
|
||||||
merger.SetProperty(FairMQMerger::NumInputs, numInputs);
|
|
||||||
++i;
|
|
||||||
|
|
||||||
merger.SetProperty(FairMQMerger::NumOutputs, 1);
|
|
||||||
|
|
||||||
merger.ChangeState(FairMQMerger::INIT);
|
|
||||||
|
|
||||||
for (int iInput = 0; iInput < numInputs; iInput++ ) {
|
|
||||||
merger.SetProperty(FairMQMerger::InputSocketType, argv[i], iInput);
|
|
||||||
++i;
|
++i;
|
||||||
int inputRcvBufSize;
|
|
||||||
stringstream(argv[i]) >> inputRcvBufSize;
|
int numIoThreads;
|
||||||
merger.SetProperty(FairMQMerger::InputRcvBufSize, inputRcvBufSize, iInput);
|
stringstream(argv[i]) >> numIoThreads;
|
||||||
|
merger.SetProperty(FairMQMerger::NumIoThreads, numIoThreads);
|
||||||
++i;
|
++i;
|
||||||
merger.SetProperty(FairMQMerger::InputMethod, argv[i], iInput);
|
|
||||||
|
int numInputs;
|
||||||
|
stringstream(argv[i]) >> numInputs;
|
||||||
|
merger.SetProperty(FairMQMerger::NumInputs, numInputs);
|
||||||
++i;
|
++i;
|
||||||
merger.SetProperty(FairMQMerger::InputAddress, argv[i], iInput);
|
|
||||||
|
merger.SetProperty(FairMQMerger::NumOutputs, 1);
|
||||||
|
|
||||||
|
merger.ChangeState(FairMQMerger::INIT);
|
||||||
|
|
||||||
|
for (int iInput = 0; iInput < numInputs; iInput++)
|
||||||
|
{
|
||||||
|
merger.SetProperty(FairMQMerger::InputSocketType, argv[i], iInput);
|
||||||
|
++i;
|
||||||
|
int inputRcvBufSize;
|
||||||
|
stringstream(argv[i]) >> inputRcvBufSize;
|
||||||
|
merger.SetProperty(FairMQMerger::InputRcvBufSize, inputRcvBufSize, iInput);
|
||||||
|
++i;
|
||||||
|
merger.SetProperty(FairMQMerger::InputMethod, argv[i], iInput);
|
||||||
|
++i;
|
||||||
|
merger.SetProperty(FairMQMerger::InputAddress, argv[i], iInput);
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
merger.SetProperty(FairMQMerger::OutputSocketType, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
int outputSndBufSize;
|
||||||
|
stringstream(argv[i]) >> outputSndBufSize;
|
||||||
|
merger.SetProperty(FairMQMerger::OutputSndBufSize, outputSndBufSize, 0);
|
||||||
|
++i;
|
||||||
|
merger.SetProperty(FairMQMerger::OutputMethod, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
merger.SetProperty(FairMQMerger::OutputAddress, argv[i], 0);
|
||||||
++i;
|
++i;
|
||||||
}
|
|
||||||
|
|
||||||
merger.SetProperty(FairMQMerger::OutputSocketType, argv[i], 0);
|
merger.ChangeState(FairMQMerger::SETOUTPUT);
|
||||||
++i;
|
merger.ChangeState(FairMQMerger::SETINPUT);
|
||||||
int outputSndBufSize;
|
merger.ChangeState(FairMQMerger::RUN);
|
||||||
stringstream(argv[i]) >> outputSndBufSize;
|
|
||||||
merger.SetProperty(FairMQMerger::OutputSndBufSize, outputSndBufSize, 0);
|
|
||||||
++i;
|
|
||||||
merger.SetProperty(FairMQMerger::OutputMethod, argv[i], 0);
|
|
||||||
++i;
|
|
||||||
merger.SetProperty(FairMQMerger::OutputAddress, argv[i], 0);
|
|
||||||
++i;
|
|
||||||
|
|
||||||
merger.ChangeState(FairMQMerger::SETOUTPUT);
|
char ch;
|
||||||
merger.ChangeState(FairMQMerger::SETINPUT);
|
cin.get(ch);
|
||||||
merger.ChangeState(FairMQMerger::RUN);
|
|
||||||
|
|
||||||
|
merger.ChangeState(FairMQMerger::STOP);
|
||||||
|
merger.ChangeState(FairMQMerger::END);
|
||||||
|
|
||||||
char ch;
|
return 0;
|
||||||
cin.get(ch);
|
|
||||||
|
|
||||||
merger.ChangeState(FairMQMerger::STOP);
|
|
||||||
merger.ChangeState(FairMQMerger::END);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,9 @@
|
||||||
#include "FairMQProtoSampler.h"
|
#include "FairMQProtoSampler.h"
|
||||||
|
|
||||||
#ifdef NANOMSG
|
#ifdef NANOMSG
|
||||||
#include "FairMQTransportFactoryNN.h"
|
#include "FairMQTransportFactoryNN.h"
|
||||||
#else
|
#else
|
||||||
#include "FairMQTransportFactoryZMQ.h"
|
#include "FairMQTransportFactoryZMQ.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
|
@ -22,102 +22,95 @@ using std::cin;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using std::stringstream;
|
using std::stringstream;
|
||||||
|
|
||||||
|
|
||||||
FairMQProtoSampler sampler;
|
FairMQProtoSampler sampler;
|
||||||
|
|
||||||
static void s_signal_handler (int signal)
|
static void s_signal_handler(int signal)
|
||||||
{
|
{
|
||||||
cout << endl << "Caught signal " << signal << endl;
|
cout << endl << "Caught signal " << signal << endl;
|
||||||
|
|
||||||
sampler.ChangeState(FairMQProtoSampler::STOP);
|
sampler.ChangeState(FairMQProtoSampler::STOP);
|
||||||
sampler.ChangeState(FairMQProtoSampler::END);
|
sampler.ChangeState(FairMQProtoSampler::END);
|
||||||
|
|
||||||
cout << "Shutdown complete. Bye!" << endl;
|
cout << "Shutdown complete. Bye!" << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void s_catch_signals (void)
|
static void s_catch_signals(void)
|
||||||
{
|
{
|
||||||
struct sigaction action;
|
struct sigaction action;
|
||||||
action.sa_handler = s_signal_handler;
|
action.sa_handler = s_signal_handler;
|
||||||
action.sa_flags = 0;
|
action.sa_flags = 0;
|
||||||
sigemptyset(&action.sa_mask);
|
sigemptyset(&action.sa_mask);
|
||||||
sigaction(SIGINT, &action, NULL);
|
sigaction(SIGINT, &action, NULL);
|
||||||
sigaction(SIGTERM, &action, NULL);
|
sigaction(SIGTERM, &action, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
if ( argc != 9 ) {
|
if (argc != 9)
|
||||||
cout << "Usage: bsampler ID eventSize eventRate numIoTreads\n"
|
{
|
||||||
<< "\t\toutputSocketType outputSndBufSize outputMethod outputAddress\n"
|
cout << "Usage: bsampler ID eventSize eventRate numIoTreads\n"
|
||||||
<< endl;
|
<< "\t\toutputSocketType outputSndBufSize outputMethod outputAddress\n" << endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
s_catch_signals();
|
s_catch_signals();
|
||||||
|
|
||||||
LOG(INFO) << "PID: " << getpid();
|
LOG(INFO) << "PID: " << getpid();
|
||||||
|
|
||||||
#ifdef NANOMSG
|
#ifdef NANOMSG
|
||||||
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
|
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
|
||||||
#else
|
#else
|
||||||
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
|
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sampler.SetTransport(transportFactory);
|
sampler.SetTransport(transportFactory);
|
||||||
|
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
sampler.SetProperty(FairMQProtoSampler::Id, argv[i]);
|
sampler.SetProperty(FairMQProtoSampler::Id, argv[i]);
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
int eventSize;
|
int eventSize;
|
||||||
stringstream(argv[i]) >> eventSize;
|
stringstream(argv[i]) >> eventSize;
|
||||||
sampler.SetProperty(FairMQProtoSampler::EventSize, eventSize);
|
sampler.SetProperty(FairMQProtoSampler::EventSize, eventSize);
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
int eventRate;
|
int eventRate;
|
||||||
stringstream(argv[i]) >> eventRate;
|
stringstream(argv[i]) >> eventRate;
|
||||||
sampler.SetProperty(FairMQProtoSampler::EventRate, eventRate);
|
sampler.SetProperty(FairMQProtoSampler::EventRate, eventRate);
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
int numIoThreads;
|
int numIoThreads;
|
||||||
stringstream(argv[i]) >> numIoThreads;
|
stringstream(argv[i]) >> numIoThreads;
|
||||||
sampler.SetProperty(FairMQProtoSampler::NumIoThreads, numIoThreads);
|
sampler.SetProperty(FairMQProtoSampler::NumIoThreads, numIoThreads);
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
sampler.SetProperty(FairMQProtoSampler::NumInputs, 0);
|
sampler.SetProperty(FairMQProtoSampler::NumInputs, 0);
|
||||||
sampler.SetProperty(FairMQProtoSampler::NumOutputs, 1);
|
sampler.SetProperty(FairMQProtoSampler::NumOutputs, 1);
|
||||||
|
|
||||||
|
sampler.ChangeState(FairMQProtoSampler::INIT);
|
||||||
|
|
||||||
sampler.ChangeState(FairMQProtoSampler::INIT);
|
sampler.SetProperty(FairMQProtoSampler::OutputSocketType, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
int outputSndBufSize;
|
||||||
|
stringstream(argv[i]) >> outputSndBufSize;
|
||||||
|
sampler.SetProperty(FairMQProtoSampler::OutputSndBufSize, outputSndBufSize, 0);
|
||||||
|
++i;
|
||||||
|
sampler.SetProperty(FairMQProtoSampler::OutputMethod, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
sampler.SetProperty(FairMQProtoSampler::OutputAddress, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
|
||||||
|
sampler.ChangeState(FairMQProtoSampler::SETOUTPUT);
|
||||||
|
sampler.ChangeState(FairMQProtoSampler::SETINPUT);
|
||||||
|
sampler.ChangeState(FairMQProtoSampler::RUN);
|
||||||
|
|
||||||
sampler.SetProperty(FairMQProtoSampler::OutputSocketType, argv[i], 0);
|
char ch;
|
||||||
++i;
|
cin.get(ch);
|
||||||
int outputSndBufSize;
|
|
||||||
stringstream(argv[i]) >> outputSndBufSize;
|
|
||||||
sampler.SetProperty(FairMQProtoSampler::OutputSndBufSize, outputSndBufSize, 0);
|
|
||||||
++i;
|
|
||||||
sampler.SetProperty(FairMQProtoSampler::OutputMethod, argv[i], 0);
|
|
||||||
++i;
|
|
||||||
sampler.SetProperty(FairMQProtoSampler::OutputAddress, argv[i], 0);
|
|
||||||
++i;
|
|
||||||
|
|
||||||
|
sampler.ChangeState(FairMQProtoSampler::STOP);
|
||||||
|
sampler.ChangeState(FairMQProtoSampler::END);
|
||||||
|
|
||||||
sampler.ChangeState(FairMQProtoSampler::SETOUTPUT);
|
return 0;
|
||||||
sampler.ChangeState(FairMQProtoSampler::SETINPUT);
|
|
||||||
sampler.ChangeState(FairMQProtoSampler::RUN);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char ch;
|
|
||||||
cin.get(ch);
|
|
||||||
|
|
||||||
sampler.ChangeState(FairMQProtoSampler::STOP);
|
|
||||||
sampler.ChangeState(FairMQProtoSampler::END);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,9 @@
|
||||||
#include "FairMQProtoSink.h"
|
#include "FairMQProtoSink.h"
|
||||||
|
|
||||||
#ifdef NANOMSG
|
#ifdef NANOMSG
|
||||||
#include "FairMQTransportFactoryNN.h"
|
#include "FairMQTransportFactoryNN.h"
|
||||||
#else
|
#else
|
||||||
#include "FairMQTransportFactoryZMQ.h"
|
#include "FairMQTransportFactoryZMQ.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
|
@ -22,91 +22,85 @@ using std::cin;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using std::stringstream;
|
using std::stringstream;
|
||||||
|
|
||||||
|
|
||||||
FairMQProtoSink sink;
|
FairMQProtoSink sink;
|
||||||
|
|
||||||
static void s_signal_handler (int signal)
|
static void s_signal_handler(int signal)
|
||||||
{
|
{
|
||||||
cout << endl << "Caught signal " << signal << endl;
|
cout << endl << "Caught signal " << signal << endl;
|
||||||
|
|
||||||
sink.ChangeState(FairMQProtoSink::STOP);
|
sink.ChangeState(FairMQProtoSink::STOP);
|
||||||
sink.ChangeState(FairMQProtoSink::END);
|
sink.ChangeState(FairMQProtoSink::END);
|
||||||
|
|
||||||
cout << "Shutdown complete. Bye!" << endl;
|
cout << "Shutdown complete. Bye!" << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void s_catch_signals (void)
|
static void s_catch_signals(void)
|
||||||
{
|
{
|
||||||
struct sigaction action;
|
struct sigaction action;
|
||||||
action.sa_handler = s_signal_handler;
|
action.sa_handler = s_signal_handler;
|
||||||
action.sa_flags = 0;
|
action.sa_flags = 0;
|
||||||
sigemptyset(&action.sa_mask);
|
sigemptyset(&action.sa_mask);
|
||||||
sigaction(SIGINT, &action, NULL);
|
sigaction(SIGINT, &action, NULL);
|
||||||
sigaction(SIGTERM, &action, NULL);
|
sigaction(SIGTERM, &action, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
if ( argc != 7 ) {
|
if (argc != 7)
|
||||||
cout << "Usage: sink \tID numIoTreads\n"
|
{
|
||||||
<< "\t\tinputSocketType inputRcvBufSize inputMethod inputAddress\n"
|
cout << "Usage: sink \tID numIoTreads\n"
|
||||||
<< endl;
|
<< "\t\tinputSocketType inputRcvBufSize inputMethod inputAddress\n" << endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
s_catch_signals();
|
s_catch_signals();
|
||||||
|
|
||||||
LOG(INFO) << "PID: " << getpid();
|
LOG(INFO) << "PID: " << getpid();
|
||||||
|
|
||||||
#ifdef NANOMSG
|
#ifdef NANOMSG
|
||||||
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
|
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
|
||||||
#else
|
#else
|
||||||
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
|
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sink.SetTransport(transportFactory);
|
sink.SetTransport(transportFactory);
|
||||||
|
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
sink.SetProperty(FairMQProtoSink::Id, argv[i]);
|
sink.SetProperty(FairMQProtoSink::Id, argv[i]);
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
int numIoThreads;
|
int numIoThreads;
|
||||||
stringstream(argv[i]) >> numIoThreads;
|
stringstream(argv[i]) >> numIoThreads;
|
||||||
sink.SetProperty(FairMQProtoSink::NumIoThreads, numIoThreads);
|
sink.SetProperty(FairMQProtoSink::NumIoThreads, numIoThreads);
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
sink.SetProperty(FairMQProtoSink::NumInputs, 1);
|
sink.SetProperty(FairMQProtoSink::NumInputs, 1);
|
||||||
sink.SetProperty(FairMQProtoSink::NumOutputs, 0);
|
sink.SetProperty(FairMQProtoSink::NumOutputs, 0);
|
||||||
|
|
||||||
|
sink.ChangeState(FairMQProtoSink::INIT);
|
||||||
|
|
||||||
sink.ChangeState(FairMQProtoSink::INIT);
|
sink.SetProperty(FairMQProtoSink::InputSocketType, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
int inputRcvBufSize;
|
||||||
|
stringstream(argv[i]) >> inputRcvBufSize;
|
||||||
|
sink.SetProperty(FairMQProtoSink::InputRcvBufSize, inputRcvBufSize, 0);
|
||||||
|
++i;
|
||||||
|
sink.SetProperty(FairMQProtoSink::InputMethod, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
sink.SetProperty(FairMQProtoSink::InputAddress, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
|
||||||
|
sink.ChangeState(FairMQProtoSink::SETOUTPUT);
|
||||||
|
sink.ChangeState(FairMQProtoSink::SETINPUT);
|
||||||
|
sink.ChangeState(FairMQProtoSink::RUN);
|
||||||
|
|
||||||
sink.SetProperty(FairMQProtoSink::InputSocketType, argv[i], 0);
|
char ch;
|
||||||
++i;
|
cin.get(ch);
|
||||||
int inputRcvBufSize;
|
|
||||||
stringstream(argv[i]) >> inputRcvBufSize;
|
|
||||||
sink.SetProperty(FairMQProtoSink::InputRcvBufSize, inputRcvBufSize, 0);
|
|
||||||
++i;
|
|
||||||
sink.SetProperty(FairMQProtoSink::InputMethod, argv[i], 0);
|
|
||||||
++i;
|
|
||||||
sink.SetProperty(FairMQProtoSink::InputAddress, argv[i], 0);
|
|
||||||
++i;
|
|
||||||
|
|
||||||
|
sink.ChangeState(FairMQProtoSink::STOP);
|
||||||
|
sink.ChangeState(FairMQProtoSink::END);
|
||||||
|
|
||||||
sink.ChangeState(FairMQProtoSink::SETOUTPUT);
|
return 0;
|
||||||
sink.ChangeState(FairMQProtoSink::SETINPUT);
|
|
||||||
sink.ChangeState(FairMQProtoSink::RUN);
|
|
||||||
|
|
||||||
|
|
||||||
char ch;
|
|
||||||
cin.get(ch);
|
|
||||||
|
|
||||||
sink.ChangeState(FairMQProtoSink::STOP);
|
|
||||||
sink.ChangeState(FairMQProtoSink::END);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,9 @@
|
||||||
#include "FairMQProxy.h"
|
#include "FairMQProxy.h"
|
||||||
|
|
||||||
#ifdef NANOMSG
|
#ifdef NANOMSG
|
||||||
#include "FairMQTransportFactoryNN.h"
|
#include "FairMQTransportFactoryNN.h"
|
||||||
#else
|
#else
|
||||||
#include "FairMQTransportFactoryZMQ.h"
|
#include "FairMQTransportFactoryZMQ.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
|
@ -22,102 +22,97 @@ using std::cin;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using std::stringstream;
|
using std::stringstream;
|
||||||
|
|
||||||
|
|
||||||
FairMQProxy proxy;
|
FairMQProxy proxy;
|
||||||
|
|
||||||
static void s_signal_handler (int signal)
|
static void s_signal_handler(int signal)
|
||||||
{
|
{
|
||||||
cout << endl << "Caught signal " << signal << endl;
|
cout << endl << "Caught signal " << signal << endl;
|
||||||
|
|
||||||
proxy.ChangeState(FairMQProxy::STOP);
|
proxy.ChangeState(FairMQProxy::STOP);
|
||||||
proxy.ChangeState(FairMQProxy::END);
|
proxy.ChangeState(FairMQProxy::END);
|
||||||
|
|
||||||
cout << "Shutdown complete. Bye!" << endl;
|
cout << "Shutdown complete. Bye!" << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void s_catch_signals (void)
|
static void s_catch_signals(void)
|
||||||
{
|
{
|
||||||
struct sigaction action;
|
struct sigaction action;
|
||||||
action.sa_handler = s_signal_handler;
|
action.sa_handler = s_signal_handler;
|
||||||
action.sa_flags = 0;
|
action.sa_flags = 0;
|
||||||
sigemptyset(&action.sa_mask);
|
sigemptyset(&action.sa_mask);
|
||||||
sigaction(SIGINT, &action, NULL);
|
sigaction(SIGINT, &action, NULL);
|
||||||
sigaction(SIGTERM, &action, NULL);
|
sigaction(SIGTERM, &action, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
if ( argc != 11 ) {
|
if (argc != 11)
|
||||||
cout << "Usage: proxy \tID numIoTreads\n"
|
{
|
||||||
<< "\t\tinputSocketType inputRcvBufSize inputMethod inputAddress\n"
|
cout << "Usage: proxy \tID numIoTreads\n"
|
||||||
<< "\t\toutputSocketType outputSndBufSize outputMethod outputAddress\n" << endl;
|
<< "\t\tinputSocketType inputRcvBufSize inputMethod inputAddress\n"
|
||||||
return 1;
|
<< "\t\toutputSocketType outputSndBufSize outputMethod outputAddress\n" << endl;
|
||||||
}
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
s_catch_signals();
|
s_catch_signals();
|
||||||
|
|
||||||
LOG(INFO) << "PID: " << getpid();
|
LOG(INFO) << "PID: " << getpid();
|
||||||
|
|
||||||
#ifdef NANOMSG
|
#ifdef NANOMSG
|
||||||
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
|
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
|
||||||
#else
|
#else
|
||||||
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
|
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
proxy.SetTransport(transportFactory);
|
proxy.SetTransport(transportFactory);
|
||||||
|
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
proxy.SetProperty(FairMQProxy::Id, argv[i]);
|
proxy.SetProperty(FairMQProxy::Id, argv[i]);
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
int numIoThreads;
|
int numIoThreads;
|
||||||
stringstream(argv[i]) >> numIoThreads;
|
stringstream(argv[i]) >> numIoThreads;
|
||||||
proxy.SetProperty(FairMQProxy::NumIoThreads, numIoThreads);
|
proxy.SetProperty(FairMQProxy::NumIoThreads, numIoThreads);
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
proxy.SetProperty(FairMQProxy::NumInputs, 1);
|
proxy.SetProperty(FairMQProxy::NumInputs, 1);
|
||||||
proxy.SetProperty(FairMQProxy::NumOutputs, 1);
|
proxy.SetProperty(FairMQProxy::NumOutputs, 1);
|
||||||
|
|
||||||
|
proxy.ChangeState(FairMQProxy::INIT);
|
||||||
|
|
||||||
proxy.ChangeState(FairMQProxy::INIT);
|
proxy.SetProperty(FairMQProxy::InputSocketType, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
int inputRcvBufSize;
|
||||||
|
stringstream(argv[i]) >> inputRcvBufSize;
|
||||||
|
proxy.SetProperty(FairMQProxy::InputRcvBufSize, inputRcvBufSize, 0);
|
||||||
|
++i;
|
||||||
|
proxy.SetProperty(FairMQProxy::InputMethod, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
proxy.SetProperty(FairMQProxy::InputAddress, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
|
||||||
|
proxy.SetProperty(FairMQProxy::OutputSocketType, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
int outputSndBufSize;
|
||||||
|
stringstream(argv[i]) >> outputSndBufSize;
|
||||||
|
proxy.SetProperty(FairMQProxy::OutputSndBufSize, outputSndBufSize, 0);
|
||||||
|
++i;
|
||||||
|
proxy.SetProperty(FairMQProxy::OutputMethod, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
proxy.SetProperty(FairMQProxy::OutputAddress, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
|
||||||
proxy.SetProperty(FairMQProxy::InputSocketType, argv[i], 0);
|
proxy.ChangeState(FairMQProxy::SETOUTPUT);
|
||||||
++i;
|
proxy.ChangeState(FairMQProxy::SETINPUT);
|
||||||
int inputRcvBufSize;
|
proxy.ChangeState(FairMQProxy::RUN);
|
||||||
stringstream(argv[i]) >> inputRcvBufSize;
|
|
||||||
proxy.SetProperty(FairMQProxy::InputRcvBufSize, inputRcvBufSize, 0);
|
|
||||||
++i;
|
|
||||||
proxy.SetProperty(FairMQProxy::InputMethod, argv[i], 0);
|
|
||||||
++i;
|
|
||||||
proxy.SetProperty(FairMQProxy::InputAddress, argv[i], 0);
|
|
||||||
++i;
|
|
||||||
|
|
||||||
proxy.SetProperty(FairMQProxy::OutputSocketType, argv[i], 0);
|
char ch;
|
||||||
++i;
|
cin.get(ch);
|
||||||
int outputSndBufSize;
|
|
||||||
stringstream(argv[i]) >> outputSndBufSize;
|
|
||||||
proxy.SetProperty(FairMQProxy::OutputSndBufSize, outputSndBufSize, 0);
|
|
||||||
++i;
|
|
||||||
proxy.SetProperty(FairMQProxy::OutputMethod, argv[i], 0);
|
|
||||||
++i;
|
|
||||||
proxy.SetProperty(FairMQProxy::OutputAddress, argv[i], 0);
|
|
||||||
++i;
|
|
||||||
|
|
||||||
|
proxy.ChangeState(FairMQProxy::STOP);
|
||||||
|
proxy.ChangeState(FairMQProxy::END);
|
||||||
|
|
||||||
proxy.ChangeState(FairMQProxy::SETOUTPUT);
|
return 0;
|
||||||
proxy.ChangeState(FairMQProxy::SETINPUT);
|
|
||||||
proxy.ChangeState(FairMQProxy::RUN);
|
|
||||||
|
|
||||||
|
|
||||||
char ch;
|
|
||||||
cin.get(ch);
|
|
||||||
|
|
||||||
proxy.ChangeState(FairMQProxy::STOP);
|
|
||||||
proxy.ChangeState(FairMQProxy::END);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,9 @@
|
||||||
#include "FairMQSink.h"
|
#include "FairMQSink.h"
|
||||||
|
|
||||||
#ifdef NANOMSG
|
#ifdef NANOMSG
|
||||||
#include "FairMQTransportFactoryNN.h"
|
#include "FairMQTransportFactoryNN.h"
|
||||||
#else
|
#else
|
||||||
#include "FairMQTransportFactoryZMQ.h"
|
#include "FairMQTransportFactoryZMQ.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
|
@ -22,91 +22,85 @@ using std::cin;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using std::stringstream;
|
using std::stringstream;
|
||||||
|
|
||||||
|
|
||||||
FairMQSink sink;
|
FairMQSink sink;
|
||||||
|
|
||||||
static void s_signal_handler (int signal)
|
static void s_signal_handler(int signal)
|
||||||
{
|
{
|
||||||
cout << endl << "Caught signal " << signal << endl;
|
cout << endl << "Caught signal " << signal << endl;
|
||||||
|
|
||||||
sink.ChangeState(FairMQSink::STOP);
|
sink.ChangeState(FairMQSink::STOP);
|
||||||
sink.ChangeState(FairMQSink::END);
|
sink.ChangeState(FairMQSink::END);
|
||||||
|
|
||||||
cout << "Shutdown complete. Bye!" << endl;
|
cout << "Shutdown complete. Bye!" << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void s_catch_signals (void)
|
static void s_catch_signals(void)
|
||||||
{
|
{
|
||||||
struct sigaction action;
|
struct sigaction action;
|
||||||
action.sa_handler = s_signal_handler;
|
action.sa_handler = s_signal_handler;
|
||||||
action.sa_flags = 0;
|
action.sa_flags = 0;
|
||||||
sigemptyset(&action.sa_mask);
|
sigemptyset(&action.sa_mask);
|
||||||
sigaction(SIGINT, &action, NULL);
|
sigaction(SIGINT, &action, NULL);
|
||||||
sigaction(SIGTERM, &action, NULL);
|
sigaction(SIGTERM, &action, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
if ( argc != 7 ) {
|
if (argc != 7)
|
||||||
cout << "Usage: sink \tID numIoTreads\n"
|
{
|
||||||
<< "\t\tinputSocketType inputRcvBufSize inputMethod inputAddress\n"
|
cout << "Usage: sink \tID numIoTreads\n"
|
||||||
<< endl;
|
<< "\t\tinputSocketType inputRcvBufSize inputMethod inputAddress\n" << endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
s_catch_signals();
|
s_catch_signals();
|
||||||
|
|
||||||
LOG(INFO) << "PID: " << getpid();
|
LOG(INFO) << "PID: " << getpid();
|
||||||
|
|
||||||
#ifdef NANOMSG
|
#ifdef NANOMSG
|
||||||
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
|
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
|
||||||
#else
|
#else
|
||||||
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
|
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sink.SetTransport(transportFactory);
|
sink.SetTransport(transportFactory);
|
||||||
|
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
sink.SetProperty(FairMQSink::Id, argv[i]);
|
sink.SetProperty(FairMQSink::Id, argv[i]);
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
int numIoThreads;
|
int numIoThreads;
|
||||||
stringstream(argv[i]) >> numIoThreads;
|
stringstream(argv[i]) >> numIoThreads;
|
||||||
sink.SetProperty(FairMQSink::NumIoThreads, numIoThreads);
|
sink.SetProperty(FairMQSink::NumIoThreads, numIoThreads);
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
sink.SetProperty(FairMQSink::NumInputs, 1);
|
sink.SetProperty(FairMQSink::NumInputs, 1);
|
||||||
sink.SetProperty(FairMQSink::NumOutputs, 0);
|
sink.SetProperty(FairMQSink::NumOutputs, 0);
|
||||||
|
|
||||||
|
sink.ChangeState(FairMQSink::INIT);
|
||||||
|
|
||||||
sink.ChangeState(FairMQSink::INIT);
|
sink.SetProperty(FairMQSink::InputSocketType, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
int inputRcvBufSize;
|
||||||
|
stringstream(argv[i]) >> inputRcvBufSize;
|
||||||
|
sink.SetProperty(FairMQSink::InputRcvBufSize, inputRcvBufSize, 0);
|
||||||
|
++i;
|
||||||
|
sink.SetProperty(FairMQSink::InputMethod, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
sink.SetProperty(FairMQSink::InputAddress, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
|
||||||
|
sink.ChangeState(FairMQSink::SETOUTPUT);
|
||||||
|
sink.ChangeState(FairMQSink::SETINPUT);
|
||||||
|
sink.ChangeState(FairMQSink::RUN);
|
||||||
|
|
||||||
sink.SetProperty(FairMQSink::InputSocketType, argv[i], 0);
|
char ch;
|
||||||
++i;
|
cin.get(ch);
|
||||||
int inputRcvBufSize;
|
|
||||||
stringstream(argv[i]) >> inputRcvBufSize;
|
|
||||||
sink.SetProperty(FairMQSink::InputRcvBufSize, inputRcvBufSize, 0);
|
|
||||||
++i;
|
|
||||||
sink.SetProperty(FairMQSink::InputMethod, argv[i], 0);
|
|
||||||
++i;
|
|
||||||
sink.SetProperty(FairMQSink::InputAddress, argv[i], 0);
|
|
||||||
++i;
|
|
||||||
|
|
||||||
|
sink.ChangeState(FairMQSink::STOP);
|
||||||
|
sink.ChangeState(FairMQSink::END);
|
||||||
|
|
||||||
sink.ChangeState(FairMQSink::SETOUTPUT);
|
return 0;
|
||||||
sink.ChangeState(FairMQSink::SETINPUT);
|
|
||||||
sink.ChangeState(FairMQSink::RUN);
|
|
||||||
|
|
||||||
|
|
||||||
char ch;
|
|
||||||
cin.get(ch);
|
|
||||||
|
|
||||||
sink.ChangeState(FairMQSink::STOP);
|
|
||||||
sink.ChangeState(FairMQSink::END);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,9 @@
|
||||||
#include "FairMQSplitter.h"
|
#include "FairMQSplitter.h"
|
||||||
|
|
||||||
#ifdef NANOMSG
|
#ifdef NANOMSG
|
||||||
#include "FairMQTransportFactoryNN.h"
|
#include "FairMQTransportFactoryNN.h"
|
||||||
#else
|
#else
|
||||||
#include "FairMQTransportFactoryZMQ.h"
|
#include "FairMQTransportFactoryZMQ.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
|
@ -22,108 +22,106 @@ using std::cin;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using std::stringstream;
|
using std::stringstream;
|
||||||
|
|
||||||
|
|
||||||
FairMQSplitter splitter;
|
FairMQSplitter splitter;
|
||||||
|
|
||||||
static void s_signal_handler (int signal)
|
static void s_signal_handler(int signal)
|
||||||
{
|
{
|
||||||
cout << endl << "Caught signal " << signal << endl;
|
cout << endl << "Caught signal " << signal << endl;
|
||||||
|
|
||||||
splitter.ChangeState(FairMQSplitter::STOP);
|
splitter.ChangeState(FairMQSplitter::STOP);
|
||||||
splitter.ChangeState(FairMQSplitter::END);
|
splitter.ChangeState(FairMQSplitter::END);
|
||||||
|
|
||||||
cout << "Shutdown complete. Bye!" << endl;
|
cout << "Shutdown complete. Bye!" << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void s_catch_signals (void)
|
static void s_catch_signals(void)
|
||||||
{
|
{
|
||||||
struct sigaction action;
|
struct sigaction action;
|
||||||
action.sa_handler = s_signal_handler;
|
action.sa_handler = s_signal_handler;
|
||||||
action.sa_flags = 0;
|
action.sa_flags = 0;
|
||||||
sigemptyset(&action.sa_mask);
|
sigemptyset(&action.sa_mask);
|
||||||
sigaction(SIGINT, &action, NULL);
|
sigaction(SIGINT, &action, NULL);
|
||||||
sigaction(SIGTERM, &action, NULL);
|
sigaction(SIGTERM, &action, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
if ( argc < 16 || (argc - 8) % 4 != 0 ) {
|
if (argc < 16 || (argc - 8) % 4 != 0)
|
||||||
cout << "Usage: splitter \tID numIoTreads numOutputs\n"
|
{
|
||||||
<< "\t\tinputSocketType inputRcvBufSize inputMethod inputAddress\n"
|
cout << "Usage: splitter \tID numIoTreads numOutputs\n"
|
||||||
<< "\t\toutputSocketType outputSndBufSize outputMethod outputAddress\n"
|
<< "\t\tinputSocketType inputRcvBufSize inputMethod inputAddress\n"
|
||||||
<< "\t\toutputSocketType outputSndBufSize outputMethod outputAddress\n"
|
<< "\t\toutputSocketType outputSndBufSize outputMethod outputAddress\n"
|
||||||
<< "\t\t..."
|
<< "\t\toutputSocketType outputSndBufSize outputMethod outputAddress\n"
|
||||||
<< argc << " arguments provided" << endl;
|
<< "\t\t..." << argc << " arguments provided" << endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
s_catch_signals();
|
s_catch_signals();
|
||||||
|
|
||||||
LOG(INFO) << "PID: " << getpid();
|
LOG(INFO) << "PID: " << getpid();
|
||||||
|
|
||||||
#ifdef NANOMSG
|
#ifdef NANOMSG
|
||||||
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
|
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
|
||||||
#else
|
#else
|
||||||
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
|
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
splitter.SetTransport(transportFactory);
|
splitter.SetTransport(transportFactory);
|
||||||
|
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
splitter.SetProperty(FairMQSplitter::Id, argv[i]);
|
splitter.SetProperty(FairMQSplitter::Id, argv[i]);
|
||||||
++i;
|
|
||||||
|
|
||||||
int numIoThreads;
|
|
||||||
stringstream(argv[i]) >> numIoThreads;
|
|
||||||
splitter.SetProperty(FairMQSplitter::NumIoThreads, numIoThreads);
|
|
||||||
++i;
|
|
||||||
|
|
||||||
splitter.SetProperty(FairMQSplitter::NumInputs, 1);
|
|
||||||
|
|
||||||
int numOutputs;
|
|
||||||
stringstream(argv[i]) >> numOutputs;
|
|
||||||
splitter.SetProperty(FairMQSplitter::NumOutputs, numOutputs);
|
|
||||||
++i;
|
|
||||||
|
|
||||||
splitter.ChangeState(FairMQSplitter::INIT);
|
|
||||||
|
|
||||||
splitter.SetProperty(FairMQSplitter::InputSocketType, argv[i], 0);
|
|
||||||
++i;
|
|
||||||
int inputRcvBufSize;
|
|
||||||
stringstream(argv[i]) >> inputRcvBufSize;
|
|
||||||
splitter.SetProperty(FairMQSplitter::InputRcvBufSize, inputRcvBufSize, 0);
|
|
||||||
++i;
|
|
||||||
splitter.SetProperty(FairMQSplitter::InputMethod, argv[i], 0);
|
|
||||||
++i;
|
|
||||||
splitter.SetProperty(FairMQSplitter::InputAddress, argv[i], 0);
|
|
||||||
++i;
|
|
||||||
|
|
||||||
int outputSndBufSize;
|
|
||||||
for (int iOutput = 0; iOutput < numOutputs; iOutput++) {
|
|
||||||
splitter.SetProperty(FairMQSplitter::OutputSocketType, argv[i], iOutput);
|
|
||||||
++i;
|
++i;
|
||||||
stringstream(argv[i]) >> outputSndBufSize;
|
|
||||||
splitter.SetProperty(FairMQSplitter::OutputSndBufSize, outputSndBufSize, iOutput);
|
int numIoThreads;
|
||||||
|
stringstream(argv[i]) >> numIoThreads;
|
||||||
|
splitter.SetProperty(FairMQSplitter::NumIoThreads, numIoThreads);
|
||||||
++i;
|
++i;
|
||||||
splitter.SetProperty(FairMQSplitter::OutputMethod, argv[i], iOutput);
|
|
||||||
|
splitter.SetProperty(FairMQSplitter::NumInputs, 1);
|
||||||
|
|
||||||
|
int numOutputs;
|
||||||
|
stringstream(argv[i]) >> numOutputs;
|
||||||
|
splitter.SetProperty(FairMQSplitter::NumOutputs, numOutputs);
|
||||||
++i;
|
++i;
|
||||||
splitter.SetProperty(FairMQSplitter::OutputAddress, argv[i], iOutput);
|
|
||||||
|
splitter.ChangeState(FairMQSplitter::INIT);
|
||||||
|
|
||||||
|
splitter.SetProperty(FairMQSplitter::InputSocketType, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
int inputRcvBufSize;
|
||||||
|
stringstream(argv[i]) >> inputRcvBufSize;
|
||||||
|
splitter.SetProperty(FairMQSplitter::InputRcvBufSize, inputRcvBufSize, 0);
|
||||||
|
++i;
|
||||||
|
splitter.SetProperty(FairMQSplitter::InputMethod, argv[i], 0);
|
||||||
|
++i;
|
||||||
|
splitter.SetProperty(FairMQSplitter::InputAddress, argv[i], 0);
|
||||||
++i;
|
++i;
|
||||||
}
|
|
||||||
|
|
||||||
splitter.ChangeState(FairMQSplitter::SETOUTPUT);
|
int outputSndBufSize;
|
||||||
splitter.ChangeState(FairMQSplitter::SETINPUT);
|
for (int iOutput = 0; iOutput < numOutputs; iOutput++)
|
||||||
splitter.ChangeState(FairMQSplitter::RUN);
|
{
|
||||||
|
splitter.SetProperty(FairMQSplitter::OutputSocketType, argv[i], iOutput);
|
||||||
|
++i;
|
||||||
|
stringstream(argv[i]) >> outputSndBufSize;
|
||||||
|
splitter.SetProperty(FairMQSplitter::OutputSndBufSize, outputSndBufSize, iOutput);
|
||||||
|
++i;
|
||||||
|
splitter.SetProperty(FairMQSplitter::OutputMethod, argv[i], iOutput);
|
||||||
|
++i;
|
||||||
|
splitter.SetProperty(FairMQSplitter::OutputAddress, argv[i], iOutput);
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
splitter.ChangeState(FairMQSplitter::SETOUTPUT);
|
||||||
|
splitter.ChangeState(FairMQSplitter::SETINPUT);
|
||||||
|
splitter.ChangeState(FairMQSplitter::RUN);
|
||||||
|
|
||||||
char ch;
|
char ch;
|
||||||
cin.get(ch);
|
cin.get(ch);
|
||||||
|
|
||||||
splitter.ChangeState(FairMQSplitter::STOP);
|
splitter.ChangeState(FairMQSplitter::STOP);
|
||||||
splitter.ChangeState(FairMQSplitter::END);
|
splitter.ChangeState(FairMQSplitter::END);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,37 +11,41 @@
|
||||||
|
|
||||||
FairMQContextZMQ::FairMQContextZMQ(int numIoThreads)
|
FairMQContextZMQ::FairMQContextZMQ(int numIoThreads)
|
||||||
{
|
{
|
||||||
fContext = zmq_ctx_new ();
|
fContext = zmq_ctx_new();
|
||||||
if (fContext == NULL){
|
if (fContext == NULL)
|
||||||
LOG(ERROR) << "failed creating context, reason: " << zmq_strerror(errno);
|
{
|
||||||
}
|
LOG(ERROR) << "failed creating context, reason: " << zmq_strerror(errno);
|
||||||
|
}
|
||||||
|
|
||||||
int rc = zmq_ctx_set (fContext, ZMQ_IO_THREADS, numIoThreads);
|
int rc = zmq_ctx_set(fContext, ZMQ_IO_THREADS, numIoThreads);
|
||||||
if (rc != 0){
|
if (rc != 0)
|
||||||
LOG(ERROR) << "failed configuring context, reason: " << zmq_strerror(errno);
|
{
|
||||||
}
|
LOG(ERROR) << "failed configuring context, reason: " << zmq_strerror(errno);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQContextZMQ::~FairMQContextZMQ()
|
FairMQContextZMQ::~FairMQContextZMQ()
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void* FairMQContextZMQ::GetContext()
|
void* FairMQContextZMQ::GetContext()
|
||||||
{
|
{
|
||||||
return fContext;
|
return fContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQContextZMQ::Close()
|
void FairMQContextZMQ::Close()
|
||||||
{
|
{
|
||||||
if (fContext == NULL){
|
if (fContext == NULL)
|
||||||
return;
|
{
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int rc = zmq_ctx_destroy (fContext);
|
int rc = zmq_ctx_destroy(fContext);
|
||||||
if (rc != 0) {
|
if (rc != 0)
|
||||||
LOG(ERROR) << "failed closing context, reason: " << zmq_strerror(errno);
|
{
|
||||||
}
|
LOG(ERROR) << "failed closing context, reason: " << zmq_strerror(errno);
|
||||||
|
}
|
||||||
|
|
||||||
fContext = NULL;
|
fContext = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,104 +11,110 @@
|
||||||
#include "FairMQMessageZMQ.h"
|
#include "FairMQMessageZMQ.h"
|
||||||
#include "FairMQLogger.h"
|
#include "FairMQLogger.h"
|
||||||
|
|
||||||
|
|
||||||
FairMQMessageZMQ::FairMQMessageZMQ()
|
FairMQMessageZMQ::FairMQMessageZMQ()
|
||||||
{
|
{
|
||||||
int rc = zmq_msg_init (&fMessage);
|
int rc = zmq_msg_init(&fMessage);
|
||||||
if (rc != 0) {
|
if (rc != 0)
|
||||||
LOG(ERROR) << "failed initializing message, reason: " << zmq_strerror(errno);
|
{
|
||||||
}
|
LOG(ERROR) << "failed initializing message, reason: " << zmq_strerror(errno);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQMessageZMQ::FairMQMessageZMQ(size_t size)
|
FairMQMessageZMQ::FairMQMessageZMQ(size_t size)
|
||||||
{
|
{
|
||||||
int rc = zmq_msg_init_size (&fMessage, size);
|
int rc = zmq_msg_init_size(&fMessage, size);
|
||||||
if (rc != 0) {
|
if (rc != 0)
|
||||||
LOG(ERROR) << "failed initializing message with size, reason: " << zmq_strerror(errno);
|
{
|
||||||
}
|
LOG(ERROR) << "failed initializing message with size, reason: " << zmq_strerror(errno);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQMessageZMQ::FairMQMessageZMQ(void* data, size_t size)
|
FairMQMessageZMQ::FairMQMessageZMQ(void* data, size_t size)
|
||||||
{
|
{
|
||||||
int rc = zmq_msg_init_data (&fMessage, data, size, &CleanUp, NULL);
|
int rc = zmq_msg_init_data(&fMessage, data, size, &CleanUp, NULL);
|
||||||
if (rc != 0) {
|
if (rc != 0)
|
||||||
LOG(ERROR) << "failed initializing message with data, reason: " << zmq_strerror(errno);
|
{
|
||||||
}
|
LOG(ERROR) << "failed initializing message with data, reason: " << zmq_strerror(errno);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQMessageZMQ::Rebuild()
|
void FairMQMessageZMQ::Rebuild()
|
||||||
{
|
{
|
||||||
CloseMessage();
|
CloseMessage();
|
||||||
int rc = zmq_msg_init (&fMessage);
|
int rc = zmq_msg_init(&fMessage);
|
||||||
if (rc != 0) {
|
if (rc != 0)
|
||||||
LOG(ERROR) << "failed initializing message, reason: " << zmq_strerror(errno);
|
{
|
||||||
}
|
LOG(ERROR) << "failed initializing message, reason: " << zmq_strerror(errno);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQMessageZMQ::Rebuild(size_t size)
|
void FairMQMessageZMQ::Rebuild(size_t size)
|
||||||
{
|
{
|
||||||
CloseMessage();
|
CloseMessage();
|
||||||
int rc = zmq_msg_init_size (&fMessage, size);
|
int rc = zmq_msg_init_size(&fMessage, size);
|
||||||
if (rc != 0) {
|
if (rc != 0)
|
||||||
LOG(ERROR) << "failed initializing message with size, reason: " << zmq_strerror(errno);
|
{
|
||||||
}
|
LOG(ERROR) << "failed initializing message with size, reason: " << zmq_strerror(errno);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQMessageZMQ::Rebuild(void* data, size_t size)
|
void FairMQMessageZMQ::Rebuild(void* data, size_t size)
|
||||||
{
|
{
|
||||||
CloseMessage();
|
CloseMessage();
|
||||||
int rc = zmq_msg_init_data (&fMessage, data, size, &CleanUp, NULL);
|
int rc = zmq_msg_init_data(&fMessage, data, size, &CleanUp, NULL);
|
||||||
if (rc != 0) {
|
if (rc != 0)
|
||||||
LOG(ERROR) << "failed initializing message with data, reason: " << zmq_strerror(errno);
|
{
|
||||||
}
|
LOG(ERROR) << "failed initializing message with data, reason: " << zmq_strerror(errno);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void* FairMQMessageZMQ::GetMessage()
|
void* FairMQMessageZMQ::GetMessage()
|
||||||
{
|
{
|
||||||
return &fMessage;
|
return &fMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* FairMQMessageZMQ::GetData()
|
void* FairMQMessageZMQ::GetData()
|
||||||
{
|
{
|
||||||
return zmq_msg_data (&fMessage);
|
return zmq_msg_data(&fMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t FairMQMessageZMQ::GetSize()
|
size_t FairMQMessageZMQ::GetSize()
|
||||||
{
|
{
|
||||||
return zmq_msg_size (&fMessage);
|
return zmq_msg_size(&fMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQMessageZMQ::SetMessage(void* data, size_t size)
|
void FairMQMessageZMQ::SetMessage(void* data, size_t size)
|
||||||
{
|
{
|
||||||
// dummy method to comply with the interface. functionality not allowed in zeromq.
|
// dummy method to comply with the interface. functionality not allowed in zeromq.
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQMessageZMQ::Copy(FairMQMessage* msg)
|
void FairMQMessageZMQ::Copy(FairMQMessage* msg)
|
||||||
{
|
{
|
||||||
CloseMessage();
|
CloseMessage();
|
||||||
size_t size = msg->GetSize();
|
size_t size = msg->GetSize();
|
||||||
zmq_msg_init_size(&fMessage, size);
|
zmq_msg_init_size(&fMessage, size);
|
||||||
std::memcpy(zmq_msg_data(&fMessage), msg->GetData(), size);
|
std::memcpy(zmq_msg_data(&fMessage), msg->GetData(), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void FairMQMessageZMQ::CloseMessage()
|
inline void FairMQMessageZMQ::CloseMessage()
|
||||||
{
|
{
|
||||||
int rc = zmq_msg_close (&fMessage);
|
int rc = zmq_msg_close(&fMessage);
|
||||||
if (rc != 0) {
|
if (rc != 0)
|
||||||
LOG(ERROR) << "failed closing message, reason: " << zmq_strerror(errno);
|
{
|
||||||
}
|
LOG(ERROR) << "failed closing message, reason: " << zmq_strerror(errno);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FairMQMessageZMQ::CleanUp(void* data, void* hint)
|
void FairMQMessageZMQ::CleanUp(void* data, void* hint)
|
||||||
{
|
{
|
||||||
free (data);
|
free(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQMessageZMQ::~FairMQMessageZMQ()
|
FairMQMessageZMQ::~FairMQMessageZMQ()
|
||||||
{
|
{
|
||||||
int rc = zmq_msg_close (&fMessage);
|
int rc = zmq_msg_close(&fMessage);
|
||||||
if (rc != 0) {
|
if (rc != 0)
|
||||||
LOG(ERROR) << "failed closing message with data, reason: " << zmq_strerror(errno);
|
{
|
||||||
}
|
LOG(ERROR) << "failed closing message with data, reason: " << zmq_strerror(errno);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
#include "FairMQMessage.h"
|
#include "FairMQMessage.h"
|
||||||
|
|
||||||
|
|
||||||
class FairMQMessageZMQ : public FairMQMessage
|
class FairMQMessageZMQ : public FairMQMessage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -11,31 +11,33 @@
|
||||||
|
|
||||||
FairMQPollerZMQ::FairMQPollerZMQ(const vector<FairMQSocket*>& inputs)
|
FairMQPollerZMQ::FairMQPollerZMQ(const vector<FairMQSocket*>& inputs)
|
||||||
{
|
{
|
||||||
fNumItems = inputs.size();
|
fNumItems = inputs.size();
|
||||||
items = new zmq_pollitem_t[fNumItems];
|
items = new zmq_pollitem_t[fNumItems];
|
||||||
|
|
||||||
for (int i = 0; i < fNumItems; i++) {
|
for (int i = 0; i < fNumItems; i++)
|
||||||
items[i].socket = inputs.at(i)->GetSocket();
|
{
|
||||||
items[i].fd = 0;
|
items[i].socket = inputs.at(i)->GetSocket();
|
||||||
items[i].events = ZMQ_POLLIN;
|
items[i].fd = 0;
|
||||||
items[i].revents = 0;
|
items[i].events = ZMQ_POLLIN;
|
||||||
}
|
items[i].revents = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQPollerZMQ::Poll(int timeout)
|
void FairMQPollerZMQ::Poll(int timeout)
|
||||||
{
|
{
|
||||||
zmq_poll(items, fNumItems, timeout);
|
zmq_poll(items, fNumItems, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FairMQPollerZMQ::CheckInput(int index)
|
bool FairMQPollerZMQ::CheckInput(int index)
|
||||||
{
|
{
|
||||||
if (items[index].revents & ZMQ_POLLIN)
|
if (items[index].revents & ZMQ_POLLIN)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQPollerZMQ::~FairMQPollerZMQ()
|
FairMQPollerZMQ::~FairMQPollerZMQ()
|
||||||
{
|
{
|
||||||
if (items != NULL) delete [] items;
|
if (items != NULL)
|
||||||
|
delete[] items;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,131 +39,156 @@ FairMQSocketZMQ::FairMQSocketZMQ(const string& type, int num, int numIoThreads)
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
LOG(ERROR) << "failed setting socket option, reason: " << zmq_strerror(errno);
|
LOG(ERROR) << "failed setting socket option, reason: " << zmq_strerror(errno);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
LOG(INFO) << "created socket #" << fId;
|
if (type == "sub")
|
||||||
|
{
|
||||||
|
rc = zmq_setsockopt(fSocket, ZMQ_SUBSCRIBE, NULL, 0);
|
||||||
|
if (rc != 0)
|
||||||
|
{
|
||||||
|
LOG(ERROR) << "failed setting socket option, reason: " << zmq_strerror(errno);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG(INFO) << "created socket #" << fId;
|
||||||
}
|
}
|
||||||
|
|
||||||
string FairMQSocketZMQ::GetId()
|
string FairMQSocketZMQ::GetId()
|
||||||
{
|
{
|
||||||
return fId;
|
return fId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQSocketZMQ::Bind(const string& address)
|
void FairMQSocketZMQ::Bind(const string& address)
|
||||||
{
|
{
|
||||||
LOG(INFO) << "bind socket #" << fId << " on " << address;
|
LOG(INFO) << "bind socket #" << fId << " on " << address;
|
||||||
|
|
||||||
int rc = zmq_bind (fSocket, address.c_str());
|
int rc = zmq_bind(fSocket, address.c_str());
|
||||||
if (rc != 0) {
|
if (rc != 0)
|
||||||
LOG(ERROR) << "failed binding socket #" << fId << ", reason: " << zmq_strerror(errno);
|
{
|
||||||
}
|
LOG(ERROR) << "failed binding socket #" << fId << ", reason: " << zmq_strerror(errno);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQSocketZMQ::Connect(const string& address)
|
void FairMQSocketZMQ::Connect(const string& address)
|
||||||
{
|
{
|
||||||
LOG(INFO) << "connect socket #" << fId << " on " << address;
|
LOG(INFO) << "connect socket #" << fId << " on " << address;
|
||||||
|
|
||||||
int rc = zmq_connect (fSocket, address.c_str());
|
int rc = zmq_connect(fSocket, address.c_str());
|
||||||
if (rc != 0) {
|
if (rc != 0)
|
||||||
LOG(ERROR) << "failed connecting socket #" << fId << ", reason: " << zmq_strerror(errno);
|
{
|
||||||
}
|
LOG(ERROR) << "failed connecting socket #" << fId << ", reason: " << zmq_strerror(errno);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t FairMQSocketZMQ::Send(FairMQMessage* msg)
|
size_t FairMQSocketZMQ::Send(FairMQMessage* msg)
|
||||||
{
|
{
|
||||||
int nbytes = zmq_msg_send (static_cast<zmq_msg_t*>(msg->GetMessage()), fSocket, 0);
|
int nbytes = zmq_msg_send(static_cast<zmq_msg_t*>(msg->GetMessage()), fSocket, 0);
|
||||||
if (nbytes >= 0){
|
if (nbytes >= 0)
|
||||||
fBytesTx += nbytes;
|
{
|
||||||
++fMessagesTx;
|
fBytesTx += nbytes;
|
||||||
|
++fMessagesTx;
|
||||||
|
return nbytes;
|
||||||
|
}
|
||||||
|
if (zmq_errno() == EAGAIN)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
LOG(ERROR) << "failed sending on socket #" << fId << ", reason: " << zmq_strerror(errno);
|
||||||
return nbytes;
|
return nbytes;
|
||||||
}
|
|
||||||
if (zmq_errno() == EAGAIN){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
LOG(ERROR) << "failed sending on socket #" << fId << ", reason: " << zmq_strerror(errno);
|
|
||||||
return nbytes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t FairMQSocketZMQ::Receive(FairMQMessage* msg)
|
size_t FairMQSocketZMQ::Receive(FairMQMessage* msg)
|
||||||
{
|
{
|
||||||
int nbytes = zmq_msg_recv (static_cast<zmq_msg_t*>(msg->GetMessage()), fSocket, 0);
|
int nbytes = zmq_msg_recv(static_cast<zmq_msg_t*>(msg->GetMessage()), fSocket, 0);
|
||||||
if (nbytes >= 0){
|
if (nbytes >= 0)
|
||||||
fBytesRx += nbytes;
|
{
|
||||||
++fMessagesRx;
|
fBytesRx += nbytes;
|
||||||
|
++fMessagesRx;
|
||||||
|
return nbytes;
|
||||||
|
}
|
||||||
|
if (zmq_errno() == EAGAIN)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
LOG(ERROR) << "failed receiving on socket #" << fId << ", reason: " << zmq_strerror(errno);
|
||||||
return nbytes;
|
return nbytes;
|
||||||
}
|
|
||||||
if (zmq_errno() == EAGAIN){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
LOG(ERROR) << "failed receiving on socket #" << fId << ", reason: " << zmq_strerror(errno);
|
|
||||||
return nbytes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQSocketZMQ::Close()
|
void FairMQSocketZMQ::Close()
|
||||||
{
|
{
|
||||||
if (fSocket == NULL){
|
if (fSocket == NULL)
|
||||||
return;
|
{
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int rc = zmq_close (fSocket);
|
int rc = zmq_close(fSocket);
|
||||||
if (rc != 0) {
|
if (rc != 0)
|
||||||
LOG(ERROR) << "failed closing socket, reason: " << zmq_strerror(errno);
|
{
|
||||||
}
|
LOG(ERROR) << "failed closing socket, reason: " << zmq_strerror(errno);
|
||||||
|
}
|
||||||
|
|
||||||
fSocket = NULL;
|
fSocket = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* FairMQSocketZMQ::GetSocket()
|
void* FairMQSocketZMQ::GetSocket()
|
||||||
{
|
{
|
||||||
return fSocket;
|
return fSocket;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FairMQSocketZMQ::GetSocket(int nothing)
|
int FairMQSocketZMQ::GetSocket(int nothing)
|
||||||
{
|
{
|
||||||
// dummy method to comply with the interface. functionality not possible in zeromq.
|
// dummy method to comply with the interface. functionality not possible in zeromq.
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQSocketZMQ::SetOption(const string& option, const void* value, size_t valueSize)
|
void FairMQSocketZMQ::SetOption(const string& option, const void* value, size_t valueSize)
|
||||||
{
|
{
|
||||||
int rc = zmq_setsockopt(fSocket, GetConstant(option), value, valueSize);
|
int rc = zmq_setsockopt(fSocket, GetConstant(option), value, valueSize);
|
||||||
if (rc < 0) {
|
if (rc < 0)
|
||||||
LOG(ERROR) << "failed setting socket option, reason: " << zmq_strerror(errno);
|
{
|
||||||
}
|
LOG(ERROR) << "failed setting socket option, reason: " << zmq_strerror(errno);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long FairMQSocketZMQ::GetBytesTx()
|
unsigned long FairMQSocketZMQ::GetBytesTx()
|
||||||
{
|
{
|
||||||
return fBytesTx;
|
return fBytesTx;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long FairMQSocketZMQ::GetBytesRx()
|
unsigned long FairMQSocketZMQ::GetBytesRx()
|
||||||
{
|
{
|
||||||
return fBytesRx;
|
return fBytesRx;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long FairMQSocketZMQ::GetMessagesTx()
|
unsigned long FairMQSocketZMQ::GetMessagesTx()
|
||||||
{
|
{
|
||||||
return fMessagesTx;
|
return fMessagesTx;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long FairMQSocketZMQ::GetMessagesRx()
|
unsigned long FairMQSocketZMQ::GetMessagesRx()
|
||||||
{
|
{
|
||||||
return fMessagesRx;
|
return fMessagesRx;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FairMQSocketZMQ::GetConstant(const string& constant)
|
int FairMQSocketZMQ::GetConstant(const string& constant)
|
||||||
{
|
{
|
||||||
if (constant == "sub") return ZMQ_SUB;
|
if (constant == "sub")
|
||||||
if (constant == "pub") return ZMQ_PUB;
|
return ZMQ_SUB;
|
||||||
if (constant == "xsub") return ZMQ_XSUB;
|
if (constant == "pub")
|
||||||
if (constant == "xpub") return ZMQ_XPUB;
|
return ZMQ_PUB;
|
||||||
if (constant == "push") return ZMQ_PUSH;
|
if (constant == "xsub")
|
||||||
if (constant == "pull") return ZMQ_PULL;
|
return ZMQ_XSUB;
|
||||||
if (constant == "snd-hwm") return ZMQ_SNDHWM;
|
if (constant == "xpub")
|
||||||
if (constant == "rcv-hwm") return ZMQ_RCVHWM;
|
return ZMQ_XPUB;
|
||||||
|
if (constant == "push")
|
||||||
|
return ZMQ_PUSH;
|
||||||
|
if (constant == "pull")
|
||||||
|
return ZMQ_PULL;
|
||||||
|
if (constant == "snd-hwm")
|
||||||
|
return ZMQ_SNDHWM;
|
||||||
|
if (constant == "rcv-hwm")
|
||||||
|
return ZMQ_RCVHWM;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQSocketZMQ::~FairMQSocketZMQ()
|
FairMQSocketZMQ::~FairMQSocketZMQ()
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include "FairMQSocket.h"
|
#include "FairMQSocket.h"
|
||||||
#include "FairMQContextZMQ.h"
|
#include "FairMQContextZMQ.h"
|
||||||
|
|
||||||
|
|
||||||
class FairMQSocketZMQ : public FairMQSocket
|
class FairMQSocketZMQ : public FairMQSocket
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -11,24 +11,24 @@
|
||||||
|
|
||||||
FairMQTransportFactoryZMQ::FairMQTransportFactoryZMQ()
|
FairMQTransportFactoryZMQ::FairMQTransportFactoryZMQ()
|
||||||
{
|
{
|
||||||
int major, minor, patch;
|
int major, minor, patch;
|
||||||
zmq_version (&major, &minor, &patch);
|
zmq_version(&major, &minor, &patch);
|
||||||
LOG(INFO) << "Using ZeroMQ library, version: " << major << "." << minor << "." << patch;
|
LOG(INFO) << "Using ZeroMQ library, version: " << major << "." << minor << "." << patch;
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQMessage* FairMQTransportFactoryZMQ::CreateMessage()
|
FairMQMessage* FairMQTransportFactoryZMQ::CreateMessage()
|
||||||
{
|
{
|
||||||
return new FairMQMessageZMQ();
|
return new FairMQMessageZMQ();
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQMessage* FairMQTransportFactoryZMQ::CreateMessage(size_t size)
|
FairMQMessage* FairMQTransportFactoryZMQ::CreateMessage(size_t size)
|
||||||
{
|
{
|
||||||
return new FairMQMessageZMQ(size);
|
return new FairMQMessageZMQ(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQMessage* FairMQTransportFactoryZMQ::CreateMessage(void* data, size_t size)
|
FairMQMessage* FairMQTransportFactoryZMQ::CreateMessage(void* data, size_t size)
|
||||||
{
|
{
|
||||||
return new FairMQMessageZMQ(data, size);
|
return new FairMQMessageZMQ(data, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQSocket* FairMQTransportFactoryZMQ::CreateSocket(const string& type, int num, int numIoThreads)
|
FairMQSocket* FairMQTransportFactoryZMQ::CreateSocket(const string& type, int num, int numIoThreads)
|
||||||
|
@ -38,5 +38,5 @@ FairMQSocket* FairMQTransportFactoryZMQ::CreateSocket(const string& type, int nu
|
||||||
|
|
||||||
FairMQPoller* FairMQTransportFactoryZMQ::CreatePoller(const vector<FairMQSocket*>& inputs)
|
FairMQPoller* FairMQTransportFactoryZMQ::CreatePoller(const vector<FairMQSocket*>& inputs)
|
||||||
{
|
{
|
||||||
return new FairMQPollerZMQ(inputs);
|
return new FairMQPollerZMQ(inputs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@ class FairMQTransportFactoryZMQ : public FairMQTransportFactory
|
||||||
virtual FairMQSocket* CreateSocket(const string& type, int num, int numIoThreads);
|
virtual FairMQSocket* CreateSocket(const string& type, int num, int numIoThreads);
|
||||||
virtual FairMQPoller* CreatePoller(const vector<FairMQSocket*>& inputs);
|
virtual FairMQPoller* CreatePoller(const vector<FairMQSocket*>& inputs);
|
||||||
|
|
||||||
|
|
||||||
virtual ~FairMQTransportFactoryZMQ() {};
|
virtual ~FairMQTransportFactoryZMQ() {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user