mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-15 17:41:45 +00:00
Several FairMQ fixes and improvements:
- FairMQ: add possibility to poll on multiple channels. - FairMQ: include command channel when polling on blocking calls (for unblocking without termination). - FairMQ: move signal handler inside of FairMQDevice class (call FairMQDevice::CatchSignals() in the main function). - FairMQ: add 'bool CheckCurrentState(statename)' (instead of 'GetCurrentState() == statename' that cannot be thread safe). - FairMQDevice: add 'InteractiveStateLoop()' method that can be used to change states from the command line. - FairMQDevice: add automatic transition to IDLE state if Run() exits without an external event. - FairMQDevice: implement device reset. - FairMQDevice: use unordered_map for device channels. - FairMQChannel: improve address validation for channels. - FairMQChannel: add ExpectsAnotherPart() method to check if another msg part is expected (old approach still works). - FairMQ: remove invalid transition from the run files. - FairMQFileSink: disable ROOT termination signal handler. - Tutorial3: spawn xterm windows from start scripts without overlapping for better visibility. - FairMQ Examples: update protobuf test and move its files to a common directory. - FairMQStateMachine: improve feedback on invalid transitions (more readable).
This commit is contained in:
committed by
Mohammad Al-Turany
parent
d1bba61939
commit
1302e77a16
@@ -1,8 +1,8 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
@@ -22,6 +22,8 @@
|
||||
#include "FairMQBinSampler.h"
|
||||
#include "FairMQLogger.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
FairMQBinSampler::FairMQBinSampler()
|
||||
: fEventSize(10000)
|
||||
, fEventRate(1)
|
||||
@@ -33,25 +35,18 @@ FairMQBinSampler::~FairMQBinSampler()
|
||||
{
|
||||
}
|
||||
|
||||
void FairMQBinSampler::Init()
|
||||
{
|
||||
}
|
||||
|
||||
void FairMQBinSampler::Run()
|
||||
{
|
||||
LOG(INFO) << ">>>>>>> Run <<<<<<<";
|
||||
// boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
|
||||
|
||||
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
||||
boost::thread resetEventCounter(boost::bind(&FairMQBinSampler::ResetEventCounter, this));
|
||||
|
||||
srand(time(NULL));
|
||||
|
||||
LOG(DEBUG) << "Message size: " << fEventSize * sizeof(Content) << " bytes.";
|
||||
|
||||
while (fState == RUNNING)
|
||||
{
|
||||
const FairMQChannel& dataOutChannel = fChannels.at("data-out").at(0);
|
||||
|
||||
while (CheckCurrentState(RUNNING))
|
||||
{
|
||||
Content* payload = new Content[fEventSize];
|
||||
|
||||
for (int i = 0; i < fEventSize; ++i)
|
||||
@@ -67,7 +62,7 @@ void FairMQBinSampler::Run()
|
||||
FairMQMessage* msg = fTransportFactory->CreateMessage(fEventSize * sizeof(Content));
|
||||
memcpy(msg->GetData(), payload, fEventSize * sizeof(Content));
|
||||
|
||||
fPayloadOutputs->at(0)->Send(msg);
|
||||
dataOutChannel.Send(msg);
|
||||
|
||||
--fEventCounter;
|
||||
|
||||
@@ -80,16 +75,13 @@ void FairMQBinSampler::Run()
|
||||
delete msg;
|
||||
}
|
||||
|
||||
rateLogger.interrupt();
|
||||
resetEventCounter.interrupt();
|
||||
|
||||
rateLogger.join();
|
||||
resetEventCounter.join();
|
||||
}
|
||||
|
||||
void FairMQBinSampler::ResetEventCounter()
|
||||
{
|
||||
while (true)
|
||||
while (GetCurrentState() == RUNNING)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -103,61 +95,26 @@ void FairMQBinSampler::ResetEventCounter()
|
||||
}
|
||||
}
|
||||
|
||||
void FairMQBinSampler::Log(int intervalInMs)
|
||||
{
|
||||
timestamp_t t0;
|
||||
timestamp_t t1;
|
||||
unsigned long bytes = fPayloadOutputs->at(0)->GetBytesTx();
|
||||
unsigned long messages = fPayloadOutputs->at(0)->GetMessagesTx();
|
||||
unsigned long bytesNew = 0;
|
||||
unsigned long messagesNew = 0;
|
||||
double megabytesPerSecond = 0;
|
||||
double messagesPerSecond = 0;
|
||||
|
||||
t0 = get_timestamp();
|
||||
|
||||
while (true)
|
||||
{
|
||||
boost::this_thread::sleep(boost::posix_time::milliseconds(intervalInMs));
|
||||
|
||||
t1 = get_timestamp();
|
||||
|
||||
bytesNew = fPayloadOutputs->at(0)->GetBytesTx();
|
||||
messagesNew = fPayloadOutputs->at(0)->GetMessagesTx();
|
||||
|
||||
timestamp_t timeSinceLastLog_ms = (t1 - t0) / 1000.0L;
|
||||
|
||||
megabytesPerSecond = ((double)(bytesNew - bytes) / (1024. * 1024.)) / (double)timeSinceLastLog_ms * 1000.;
|
||||
messagesPerSecond = (double)(messagesNew - messages) / (double)timeSinceLastLog_ms * 1000.;
|
||||
|
||||
LOG(DEBUG) << "send " << messagesPerSecond << " msg/s, " << megabytesPerSecond << " MB/s";
|
||||
|
||||
bytes = bytesNew;
|
||||
messages = messagesNew;
|
||||
t0 = t1;
|
||||
}
|
||||
}
|
||||
|
||||
void FairMQBinSampler::SetProperty(const int key, const string& value, const int slot /*= 0*/)
|
||||
void FairMQBinSampler::SetProperty(const int key, const string& value)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
default:
|
||||
FairMQDevice::SetProperty(key, value, slot);
|
||||
FairMQDevice::SetProperty(key, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
string FairMQBinSampler::GetProperty(const int key, const string& default_ /*= ""*/, const int slot /*= 0*/)
|
||||
string FairMQBinSampler::GetProperty(const int key, const string& default_ /*= ""*/)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
default:
|
||||
return FairMQDevice::GetProperty(key, default_, slot);
|
||||
return FairMQDevice::GetProperty(key, default_);
|
||||
}
|
||||
}
|
||||
|
||||
void FairMQBinSampler::SetProperty(const int key, const int value, const int slot /*= 0*/)
|
||||
void FairMQBinSampler::SetProperty(const int key, const int value)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
@@ -168,12 +125,12 @@ void FairMQBinSampler::SetProperty(const int key, const int value, const int slo
|
||||
fEventRate = value;
|
||||
break;
|
||||
default:
|
||||
FairMQDevice::SetProperty(key, value, slot);
|
||||
FairMQDevice::SetProperty(key, value);
|
||||
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*/)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
@@ -182,6 +139,6 @@ int FairMQBinSampler::GetProperty(const int key, const int default_ /*= 0*/, con
|
||||
case EventRate:
|
||||
return fEventRate;
|
||||
default:
|
||||
return FairMQDevice::GetProperty(key, default_, slot);
|
||||
return FairMQDevice::GetProperty(key, default_);
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
@@ -33,25 +33,25 @@ class FairMQBinSampler : public FairMQDevice
|
||||
public:
|
||||
enum
|
||||
{
|
||||
InputFile = FairMQDevice::Last,
|
||||
EventRate,
|
||||
EventRate = FairMQDevice::Last,
|
||||
EventSize,
|
||||
Last
|
||||
};
|
||||
FairMQBinSampler();
|
||||
virtual ~FairMQBinSampler();
|
||||
void Log(int intervalInMs);
|
||||
|
||||
void ResetEventCounter();
|
||||
virtual void SetProperty(const int key, const string& value, const int slot = 0);
|
||||
virtual string GetProperty(const int key, const string& default_ = "", const int slot = 0);
|
||||
virtual void SetProperty(const int key, const int value, const int slot = 0);
|
||||
virtual int GetProperty(const int key, const int default_ = 0, const int slot = 0);
|
||||
|
||||
virtual void SetProperty(const int key, const std::string& value);
|
||||
virtual std::string GetProperty(const int key, const std::string& default_ = "");
|
||||
virtual void SetProperty(const int key, const int value);
|
||||
virtual int GetProperty(const int key, const int default_ = 0);
|
||||
|
||||
protected:
|
||||
int fEventSize;
|
||||
int fEventRate;
|
||||
int fEventCounter;
|
||||
virtual void Init();
|
||||
|
||||
virtual void Run();
|
||||
};
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
@@ -24,15 +24,13 @@ FairMQBinSink::FairMQBinSink()
|
||||
|
||||
void FairMQBinSink::Run()
|
||||
{
|
||||
LOG(INFO) << ">>>>>>> Run <<<<<<<";
|
||||
const FairMQChannel& dataInChannel = fChannels.at("data-in").at(0);
|
||||
|
||||
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
||||
|
||||
while (fState == RUNNING)
|
||||
while (CheckCurrentState(RUNNING))
|
||||
{
|
||||
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
||||
|
||||
fPayloadInputs->at(0)->Receive(msg);
|
||||
dataInChannel.Receive(msg);
|
||||
|
||||
int inputSize = msg->GetSize();
|
||||
// int numInput = inputSize / sizeof(Content);
|
||||
@@ -44,9 +42,6 @@ void FairMQBinSink::Run()
|
||||
|
||||
delete msg;
|
||||
}
|
||||
|
||||
rateLogger.interrupt();
|
||||
rateLogger.join();
|
||||
}
|
||||
|
||||
FairMQBinSink::~FairMQBinSink()
|
||||
|
@@ -1,8 +1,8 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
|
@@ -1,8 +1,8 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
@@ -35,23 +35,16 @@ FairMQProtoSampler::~FairMQProtoSampler()
|
||||
{
|
||||
}
|
||||
|
||||
void FairMQProtoSampler::Init()
|
||||
{
|
||||
}
|
||||
|
||||
void FairMQProtoSampler::Run()
|
||||
{
|
||||
LOG(INFO) << ">>>>>>> Run <<<<<<<";
|
||||
// boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
|
||||
|
||||
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
||||
boost::thread resetEventCounter(boost::bind(&FairMQProtoSampler::ResetEventCounter, this));
|
||||
|
||||
srand(time(NULL));
|
||||
|
||||
while (fState == RUNNING)
|
||||
{
|
||||
const FairMQChannel& dataOutChannel = fChannels.at("data-out").at(0);
|
||||
|
||||
while (CheckCurrentState(RUNNING))
|
||||
{
|
||||
sampler::Payload p;
|
||||
|
||||
for (int i = 0; i < fEventSize; ++i)
|
||||
@@ -73,7 +66,7 @@ void FairMQProtoSampler::Run()
|
||||
FairMQMessage* msg = fTransportFactory->CreateMessage(size);
|
||||
memcpy(msg->GetData(), str.c_str(), size);
|
||||
|
||||
fPayloadOutputs->at(0)->Send(msg);
|
||||
dataOutChannel.Send(msg);
|
||||
|
||||
--fEventCounter;
|
||||
|
||||
@@ -85,10 +78,7 @@ void FairMQProtoSampler::Run()
|
||||
delete msg;
|
||||
}
|
||||
|
||||
rateLogger.interrupt();
|
||||
resetEventCounter.interrupt();
|
||||
|
||||
rateLogger.join();
|
||||
resetEventCounter.join();
|
||||
}
|
||||
|
||||
@@ -108,61 +98,26 @@ void FairMQProtoSampler::ResetEventCounter()
|
||||
}
|
||||
}
|
||||
|
||||
void FairMQProtoSampler::Log(int intervalInMs)
|
||||
{
|
||||
timestamp_t t0;
|
||||
timestamp_t t1;
|
||||
unsigned long bytes = fPayloadOutputs->at(0)->GetBytesTx();
|
||||
unsigned long messages = fPayloadOutputs->at(0)->GetMessagesTx();
|
||||
unsigned long bytesNew = 0;
|
||||
unsigned long messagesNew = 0;
|
||||
double megabytesPerSecond = 0;
|
||||
double messagesPerSecond = 0;
|
||||
|
||||
t0 = get_timestamp();
|
||||
|
||||
while (true)
|
||||
{
|
||||
boost::this_thread::sleep(boost::posix_time::milliseconds(intervalInMs));
|
||||
|
||||
t1 = get_timestamp();
|
||||
|
||||
bytesNew = fPayloadOutputs->at(0)->GetBytesTx();
|
||||
messagesNew = fPayloadOutputs->at(0)->GetMessagesTx();
|
||||
|
||||
timestamp_t timeSinceLastLog_ms = (t1 - t0) / 1000.0L;
|
||||
|
||||
megabytesPerSecond = ((double)(bytesNew - bytes) / (1024. * 1024.)) / (double)timeSinceLastLog_ms * 1000.;
|
||||
messagesPerSecond = (double)(messagesNew - messages) / (double)timeSinceLastLog_ms * 1000.;
|
||||
|
||||
LOG(DEBUG) << "send " << messagesPerSecond << " msg/s, " << megabytesPerSecond << " MB/s";
|
||||
|
||||
bytes = bytesNew;
|
||||
messages = messagesNew;
|
||||
t0 = t1;
|
||||
}
|
||||
}
|
||||
|
||||
void FairMQProtoSampler::SetProperty(const int key, const string& value, const int slot /*= 0*/)
|
||||
void FairMQProtoSampler::SetProperty(const int key, const string& value)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
default:
|
||||
FairMQDevice::SetProperty(key, value, slot);
|
||||
FairMQDevice::SetProperty(key, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
string FairMQProtoSampler::GetProperty(const int key, const string& default_ /*= ""*/, const int slot /*= 0*/)
|
||||
string FairMQProtoSampler::GetProperty(const int key, const string& default_ /*= ""*/)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
default:
|
||||
return FairMQDevice::GetProperty(key, default_, slot);
|
||||
return FairMQDevice::GetProperty(key, default_);
|
||||
}
|
||||
}
|
||||
|
||||
void FairMQProtoSampler::SetProperty(const int key, const int value, const int slot /*= 0*/)
|
||||
void FairMQProtoSampler::SetProperty(const int key, const int value)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
@@ -173,12 +128,12 @@ void FairMQProtoSampler::SetProperty(const int key, const int value, const int s
|
||||
fEventRate = value;
|
||||
break;
|
||||
default:
|
||||
FairMQDevice::SetProperty(key, value, slot);
|
||||
FairMQDevice::SetProperty(key, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int FairMQProtoSampler::GetProperty(const int key, const int default_ /*= 0*/, const int slot /*= 0*/)
|
||||
int FairMQProtoSampler::GetProperty(const int key, const int default_ /*= 0*/)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
@@ -187,6 +142,6 @@ int FairMQProtoSampler::GetProperty(const int key, const int default_ /*= 0*/, c
|
||||
case EventRate:
|
||||
return fEventRate;
|
||||
default:
|
||||
return FairMQDevice::GetProperty(key, default_, slot);
|
||||
return FairMQDevice::GetProperty(key, default_);
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
@@ -24,25 +24,25 @@ class FairMQProtoSampler : public FairMQDevice
|
||||
public:
|
||||
enum
|
||||
{
|
||||
InputFile = FairMQDevice::Last,
|
||||
EventRate,
|
||||
EventRate = FairMQDevice::Last,
|
||||
EventSize,
|
||||
Last
|
||||
};
|
||||
FairMQProtoSampler();
|
||||
virtual ~FairMQProtoSampler();
|
||||
void Log(int intervalInMs);
|
||||
|
||||
void ResetEventCounter();
|
||||
virtual void SetProperty(const int key, const std::string& value, const int slot = 0);
|
||||
virtual std::string GetProperty(const int key, const std::string& default_ = "", const int slot = 0);
|
||||
virtual void SetProperty(const int key, const int value, const int slot = 0);
|
||||
virtual int GetProperty(const int key, const int default_ = 0, const int slot = 0);
|
||||
|
||||
virtual void SetProperty(const int key, const std::string& value);
|
||||
virtual std::string GetProperty(const int key, const std::string& default_ = "");
|
||||
virtual void SetProperty(const int key, const int value);
|
||||
virtual int GetProperty(const int key, const int default_ = 0);
|
||||
|
||||
protected:
|
||||
int fEventSize;
|
||||
int fEventRate;
|
||||
int fEventCounter;
|
||||
virtual void Init();
|
||||
|
||||
virtual void Run();
|
||||
};
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
@@ -26,15 +26,13 @@ FairMQProtoSink::FairMQProtoSink()
|
||||
|
||||
void FairMQProtoSink::Run()
|
||||
{
|
||||
LOG(INFO) << ">>>>>>> Run <<<<<<<";
|
||||
const FairMQChannel& dataInChannel = fChannels.at("data-in").at(0);
|
||||
|
||||
boost::thread rateLogger(boost::bind(&FairMQDevice::LogSocketRates, this));
|
||||
|
||||
while (fState == RUNNING)
|
||||
while (CheckCurrentState(RUNNING))
|
||||
{
|
||||
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
||||
|
||||
fPayloadInputs->at(0)->Receive(msg);
|
||||
dataInChannel.Receive(msg);
|
||||
|
||||
sampler::Payload p;
|
||||
|
||||
@@ -47,9 +45,6 @@ void FairMQProtoSink::Run()
|
||||
|
||||
delete msg;
|
||||
}
|
||||
|
||||
rateLogger.interrupt();
|
||||
rateLogger.join();
|
||||
}
|
||||
|
||||
FairMQProtoSink::~FairMQProtoSink()
|
||||
|
@@ -1,8 +1,8 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
|
@@ -1,698 +0,0 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: payload.proto
|
||||
|
||||
#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
|
||||
#include "payload.pb.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
#include <google/protobuf/stubs/once.h>
|
||||
#include <google/protobuf/io/coded_stream.h>
|
||||
#include <google/protobuf/wire_format_lite_inl.h>
|
||||
#include <google/protobuf/descriptor.h>
|
||||
#include <google/protobuf/generated_message_reflection.h>
|
||||
#include <google/protobuf/reflection_ops.h>
|
||||
#include <google/protobuf/wire_format.h>
|
||||
// @@protoc_insertion_point(includes)
|
||||
|
||||
namespace sampler {
|
||||
|
||||
namespace {
|
||||
|
||||
const ::google::protobuf::Descriptor* Content_descriptor_ = NULL;
|
||||
const ::google::protobuf::internal::GeneratedMessageReflection*
|
||||
Content_reflection_ = NULL;
|
||||
const ::google::protobuf::Descriptor* Payload_descriptor_ = NULL;
|
||||
const ::google::protobuf::internal::GeneratedMessageReflection*
|
||||
Payload_reflection_ = NULL;
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
void protobuf_AssignDesc_payload_2eproto() {
|
||||
protobuf_AddDesc_payload_2eproto();
|
||||
const ::google::protobuf::FileDescriptor* file =
|
||||
::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
|
||||
"payload.proto");
|
||||
GOOGLE_CHECK(file != NULL);
|
||||
Content_descriptor_ = file->message_type(0);
|
||||
static const int Content_offsets_[5] = {
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Content, a_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Content, b_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Content, x_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Content, y_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Content, z_),
|
||||
};
|
||||
Content_reflection_ =
|
||||
new ::google::protobuf::internal::GeneratedMessageReflection(
|
||||
Content_descriptor_,
|
||||
Content::default_instance_,
|
||||
Content_offsets_,
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Content, _has_bits_[0]),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Content, _unknown_fields_),
|
||||
-1,
|
||||
::google::protobuf::DescriptorPool::generated_pool(),
|
||||
::google::protobuf::MessageFactory::generated_factory(),
|
||||
sizeof(Content));
|
||||
Payload_descriptor_ = file->message_type(1);
|
||||
static const int Payload_offsets_[1] = {
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Payload, data_),
|
||||
};
|
||||
Payload_reflection_ =
|
||||
new ::google::protobuf::internal::GeneratedMessageReflection(
|
||||
Payload_descriptor_,
|
||||
Payload::default_instance_,
|
||||
Payload_offsets_,
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Payload, _has_bits_[0]),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Payload, _unknown_fields_),
|
||||
-1,
|
||||
::google::protobuf::DescriptorPool::generated_pool(),
|
||||
::google::protobuf::MessageFactory::generated_factory(),
|
||||
sizeof(Payload));
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
|
||||
inline void protobuf_AssignDescriptorsOnce() {
|
||||
::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
|
||||
&protobuf_AssignDesc_payload_2eproto);
|
||||
}
|
||||
|
||||
void protobuf_RegisterTypes(const ::std::string&) {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
|
||||
Content_descriptor_, &Content::default_instance());
|
||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
|
||||
Payload_descriptor_, &Payload::default_instance());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void protobuf_ShutdownFile_payload_2eproto() {
|
||||
delete Content::default_instance_;
|
||||
delete Content_reflection_;
|
||||
delete Payload::default_instance_;
|
||||
delete Payload_reflection_;
|
||||
}
|
||||
|
||||
void protobuf_AddDesc_payload_2eproto() {
|
||||
static bool already_here = false;
|
||||
if (already_here) return;
|
||||
already_here = true;
|
||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
||||
|
||||
::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
|
||||
"\n\rpayload.proto\022\007sampler\"@\n\007Content\022\t\n\001a"
|
||||
"\030\001 \001(\001\022\t\n\001b\030\002 \001(\001\022\t\n\001x\030\003 \001(\005\022\t\n\001y\030\004 \001(\005\022"
|
||||
"\t\n\001z\030\005 \001(\005\")\n\007Payload\022\036\n\004data\030\001 \003(\0132\020.sa"
|
||||
"mpler.Content", 133);
|
||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
|
||||
"payload.proto", &protobuf_RegisterTypes);
|
||||
Content::default_instance_ = new Content();
|
||||
Payload::default_instance_ = new Payload();
|
||||
Content::default_instance_->InitAsDefaultInstance();
|
||||
Payload::default_instance_->InitAsDefaultInstance();
|
||||
::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_payload_2eproto);
|
||||
}
|
||||
|
||||
// Force AddDescriptors() to be called at static initialization time.
|
||||
struct StaticDescriptorInitializer_payload_2eproto {
|
||||
StaticDescriptorInitializer_payload_2eproto() {
|
||||
protobuf_AddDesc_payload_2eproto();
|
||||
}
|
||||
} static_descriptor_initializer_payload_2eproto_;
|
||||
|
||||
// ===================================================================
|
||||
|
||||
#ifndef _MSC_VER
|
||||
const int Content::kAFieldNumber;
|
||||
const int Content::kBFieldNumber;
|
||||
const int Content::kXFieldNumber;
|
||||
const int Content::kYFieldNumber;
|
||||
const int Content::kZFieldNumber;
|
||||
#endif // !_MSC_VER
|
||||
|
||||
Content::Content()
|
||||
: ::google::protobuf::Message() {
|
||||
SharedCtor();
|
||||
}
|
||||
|
||||
void Content::InitAsDefaultInstance() {
|
||||
}
|
||||
|
||||
Content::Content(const Content& from)
|
||||
: ::google::protobuf::Message() {
|
||||
SharedCtor();
|
||||
MergeFrom(from);
|
||||
}
|
||||
|
||||
void Content::SharedCtor() {
|
||||
_cached_size_ = 0;
|
||||
a_ = 0;
|
||||
b_ = 0;
|
||||
x_ = 0;
|
||||
y_ = 0;
|
||||
z_ = 0;
|
||||
::memset(_has_bits_, 0, sizeof(_has_bits_));
|
||||
}
|
||||
|
||||
Content::~Content() {
|
||||
SharedDtor();
|
||||
}
|
||||
|
||||
void Content::SharedDtor() {
|
||||
if (this != default_instance_) {
|
||||
}
|
||||
}
|
||||
|
||||
void Content::SetCachedSize(int size) const {
|
||||
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
|
||||
_cached_size_ = size;
|
||||
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
||||
}
|
||||
const ::google::protobuf::Descriptor* Content::descriptor() {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
return Content_descriptor_;
|
||||
}
|
||||
|
||||
const Content& Content::default_instance() {
|
||||
if (default_instance_ == NULL) protobuf_AddDesc_payload_2eproto();
|
||||
return *default_instance_;
|
||||
}
|
||||
|
||||
Content* Content::default_instance_ = NULL;
|
||||
|
||||
Content* Content::New() const {
|
||||
return new Content;
|
||||
}
|
||||
|
||||
void Content::Clear() {
|
||||
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
|
||||
a_ = 0;
|
||||
b_ = 0;
|
||||
x_ = 0;
|
||||
y_ = 0;
|
||||
z_ = 0;
|
||||
}
|
||||
::memset(_has_bits_, 0, sizeof(_has_bits_));
|
||||
mutable_unknown_fields()->Clear();
|
||||
}
|
||||
|
||||
bool Content::MergePartialFromCodedStream(
|
||||
::google::protobuf::io::CodedInputStream* input) {
|
||||
#define DO_(EXPRESSION) if (!(EXPRESSION)) return false
|
||||
::google::protobuf::uint32 tag;
|
||||
while ((tag = input->ReadTag()) != 0) {
|
||||
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
|
||||
// optional double a = 1;
|
||||
case 1: {
|
||||
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
||||
::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED64) {
|
||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
||||
double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>(
|
||||
input, &a_)));
|
||||
set_has_a();
|
||||
} else {
|
||||
goto handle_uninterpreted;
|
||||
}
|
||||
if (input->ExpectTag(17)) goto parse_b;
|
||||
break;
|
||||
}
|
||||
|
||||
// optional double b = 2;
|
||||
case 2: {
|
||||
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
||||
::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED64) {
|
||||
parse_b:
|
||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
||||
double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>(
|
||||
input, &b_)));
|
||||
set_has_b();
|
||||
} else {
|
||||
goto handle_uninterpreted;
|
||||
}
|
||||
if (input->ExpectTag(24)) goto parse_x;
|
||||
break;
|
||||
}
|
||||
|
||||
// optional int32 x = 3;
|
||||
case 3: {
|
||||
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
||||
::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
|
||||
parse_x:
|
||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
||||
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
|
||||
input, &x_)));
|
||||
set_has_x();
|
||||
} else {
|
||||
goto handle_uninterpreted;
|
||||
}
|
||||
if (input->ExpectTag(32)) goto parse_y;
|
||||
break;
|
||||
}
|
||||
|
||||
// optional int32 y = 4;
|
||||
case 4: {
|
||||
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
||||
::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
|
||||
parse_y:
|
||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
||||
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
|
||||
input, &y_)));
|
||||
set_has_y();
|
||||
} else {
|
||||
goto handle_uninterpreted;
|
||||
}
|
||||
if (input->ExpectTag(40)) goto parse_z;
|
||||
break;
|
||||
}
|
||||
|
||||
// optional int32 z = 5;
|
||||
case 5: {
|
||||
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
||||
::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
|
||||
parse_z:
|
||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
||||
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
|
||||
input, &z_)));
|
||||
set_has_z();
|
||||
} else {
|
||||
goto handle_uninterpreted;
|
||||
}
|
||||
if (input->ExpectAtEnd()) return true;
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
handle_uninterpreted:
|
||||
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
||||
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
|
||||
return true;
|
||||
}
|
||||
DO_(::google::protobuf::internal::WireFormat::SkipField(
|
||||
input, tag, mutable_unknown_fields()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
#undef DO_
|
||||
}
|
||||
|
||||
void Content::SerializeWithCachedSizes(
|
||||
::google::protobuf::io::CodedOutputStream* output) const {
|
||||
// optional double a = 1;
|
||||
if (has_a()) {
|
||||
::google::protobuf::internal::WireFormatLite::WriteDouble(1, this->a(), output);
|
||||
}
|
||||
|
||||
// optional double b = 2;
|
||||
if (has_b()) {
|
||||
::google::protobuf::internal::WireFormatLite::WriteDouble(2, this->b(), output);
|
||||
}
|
||||
|
||||
// optional int32 x = 3;
|
||||
if (has_x()) {
|
||||
::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->x(), output);
|
||||
}
|
||||
|
||||
// optional int32 y = 4;
|
||||
if (has_y()) {
|
||||
::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->y(), output);
|
||||
}
|
||||
|
||||
// optional int32 z = 5;
|
||||
if (has_z()) {
|
||||
::google::protobuf::internal::WireFormatLite::WriteInt32(5, this->z(), output);
|
||||
}
|
||||
|
||||
if (!unknown_fields().empty()) {
|
||||
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
|
||||
unknown_fields(), output);
|
||||
}
|
||||
}
|
||||
|
||||
::google::protobuf::uint8* Content::SerializeWithCachedSizesToArray(
|
||||
::google::protobuf::uint8* target) const {
|
||||
// optional double a = 1;
|
||||
if (has_a()) {
|
||||
target = ::google::protobuf::internal::WireFormatLite::WriteDoubleToArray(1, this->a(), target);
|
||||
}
|
||||
|
||||
// optional double b = 2;
|
||||
if (has_b()) {
|
||||
target = ::google::protobuf::internal::WireFormatLite::WriteDoubleToArray(2, this->b(), target);
|
||||
}
|
||||
|
||||
// optional int32 x = 3;
|
||||
if (has_x()) {
|
||||
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->x(), target);
|
||||
}
|
||||
|
||||
// optional int32 y = 4;
|
||||
if (has_y()) {
|
||||
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(4, this->y(), target);
|
||||
}
|
||||
|
||||
// optional int32 z = 5;
|
||||
if (has_z()) {
|
||||
target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(5, this->z(), target);
|
||||
}
|
||||
|
||||
if (!unknown_fields().empty()) {
|
||||
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
|
||||
unknown_fields(), target);
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
int Content::ByteSize() const {
|
||||
int total_size = 0;
|
||||
|
||||
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
|
||||
// optional double a = 1;
|
||||
if (has_a()) {
|
||||
total_size += 1 + 8;
|
||||
}
|
||||
|
||||
// optional double b = 2;
|
||||
if (has_b()) {
|
||||
total_size += 1 + 8;
|
||||
}
|
||||
|
||||
// optional int32 x = 3;
|
||||
if (has_x()) {
|
||||
total_size += 1 +
|
||||
::google::protobuf::internal::WireFormatLite::Int32Size(
|
||||
this->x());
|
||||
}
|
||||
|
||||
// optional int32 y = 4;
|
||||
if (has_y()) {
|
||||
total_size += 1 +
|
||||
::google::protobuf::internal::WireFormatLite::Int32Size(
|
||||
this->y());
|
||||
}
|
||||
|
||||
// optional int32 z = 5;
|
||||
if (has_z()) {
|
||||
total_size += 1 +
|
||||
::google::protobuf::internal::WireFormatLite::Int32Size(
|
||||
this->z());
|
||||
}
|
||||
|
||||
}
|
||||
if (!unknown_fields().empty()) {
|
||||
total_size +=
|
||||
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
|
||||
unknown_fields());
|
||||
}
|
||||
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
|
||||
_cached_size_ = total_size;
|
||||
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
||||
return total_size;
|
||||
}
|
||||
|
||||
void Content::MergeFrom(const ::google::protobuf::Message& from) {
|
||||
GOOGLE_CHECK_NE(&from, this);
|
||||
const Content* source =
|
||||
::google::protobuf::internal::dynamic_cast_if_available<const Content*>(
|
||||
&from);
|
||||
if (source == NULL) {
|
||||
::google::protobuf::internal::ReflectionOps::Merge(from, this);
|
||||
} else {
|
||||
MergeFrom(*source);
|
||||
}
|
||||
}
|
||||
|
||||
void Content::MergeFrom(const Content& from) {
|
||||
GOOGLE_CHECK_NE(&from, this);
|
||||
if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
|
||||
if (from.has_a()) {
|
||||
set_a(from.a());
|
||||
}
|
||||
if (from.has_b()) {
|
||||
set_b(from.b());
|
||||
}
|
||||
if (from.has_x()) {
|
||||
set_x(from.x());
|
||||
}
|
||||
if (from.has_y()) {
|
||||
set_y(from.y());
|
||||
}
|
||||
if (from.has_z()) {
|
||||
set_z(from.z());
|
||||
}
|
||||
}
|
||||
mutable_unknown_fields()->MergeFrom(from.unknown_fields());
|
||||
}
|
||||
|
||||
void Content::CopyFrom(const ::google::protobuf::Message& from) {
|
||||
if (&from == this) return;
|
||||
Clear();
|
||||
MergeFrom(from);
|
||||
}
|
||||
|
||||
void Content::CopyFrom(const Content& from) {
|
||||
if (&from == this) return;
|
||||
Clear();
|
||||
MergeFrom(from);
|
||||
}
|
||||
|
||||
bool Content::IsInitialized() const {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Content::Swap(Content* other) {
|
||||
if (other != this) {
|
||||
std::swap(a_, other->a_);
|
||||
std::swap(b_, other->b_);
|
||||
std::swap(x_, other->x_);
|
||||
std::swap(y_, other->y_);
|
||||
std::swap(z_, other->z_);
|
||||
std::swap(_has_bits_[0], other->_has_bits_[0]);
|
||||
_unknown_fields_.Swap(&other->_unknown_fields_);
|
||||
std::swap(_cached_size_, other->_cached_size_);
|
||||
}
|
||||
}
|
||||
|
||||
::google::protobuf::Metadata Content::GetMetadata() const {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
::google::protobuf::Metadata metadata;
|
||||
metadata.descriptor = Content_descriptor_;
|
||||
metadata.reflection = Content_reflection_;
|
||||
return metadata;
|
||||
}
|
||||
|
||||
|
||||
// ===================================================================
|
||||
|
||||
#ifndef _MSC_VER
|
||||
const int Payload::kDataFieldNumber;
|
||||
#endif // !_MSC_VER
|
||||
|
||||
Payload::Payload()
|
||||
: ::google::protobuf::Message() {
|
||||
SharedCtor();
|
||||
}
|
||||
|
||||
void Payload::InitAsDefaultInstance() {
|
||||
}
|
||||
|
||||
Payload::Payload(const Payload& from)
|
||||
: ::google::protobuf::Message() {
|
||||
SharedCtor();
|
||||
MergeFrom(from);
|
||||
}
|
||||
|
||||
void Payload::SharedCtor() {
|
||||
_cached_size_ = 0;
|
||||
::memset(_has_bits_, 0, sizeof(_has_bits_));
|
||||
}
|
||||
|
||||
Payload::~Payload() {
|
||||
SharedDtor();
|
||||
}
|
||||
|
||||
void Payload::SharedDtor() {
|
||||
if (this != default_instance_) {
|
||||
}
|
||||
}
|
||||
|
||||
void Payload::SetCachedSize(int size) const {
|
||||
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
|
||||
_cached_size_ = size;
|
||||
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
||||
}
|
||||
const ::google::protobuf::Descriptor* Payload::descriptor() {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
return Payload_descriptor_;
|
||||
}
|
||||
|
||||
const Payload& Payload::default_instance() {
|
||||
if (default_instance_ == NULL) protobuf_AddDesc_payload_2eproto();
|
||||
return *default_instance_;
|
||||
}
|
||||
|
||||
Payload* Payload::default_instance_ = NULL;
|
||||
|
||||
Payload* Payload::New() const {
|
||||
return new Payload;
|
||||
}
|
||||
|
||||
void Payload::Clear() {
|
||||
data_.Clear();
|
||||
::memset(_has_bits_, 0, sizeof(_has_bits_));
|
||||
mutable_unknown_fields()->Clear();
|
||||
}
|
||||
|
||||
bool Payload::MergePartialFromCodedStream(
|
||||
::google::protobuf::io::CodedInputStream* input) {
|
||||
#define DO_(EXPRESSION) if (!(EXPRESSION)) return false
|
||||
::google::protobuf::uint32 tag;
|
||||
while ((tag = input->ReadTag()) != 0) {
|
||||
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
|
||||
// repeated .sampler.Content data = 1;
|
||||
case 1: {
|
||||
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
||||
::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
|
||||
parse_data:
|
||||
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
|
||||
input, add_data()));
|
||||
} else {
|
||||
goto handle_uninterpreted;
|
||||
}
|
||||
if (input->ExpectTag(10)) goto parse_data;
|
||||
if (input->ExpectAtEnd()) return true;
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
handle_uninterpreted:
|
||||
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
||||
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
|
||||
return true;
|
||||
}
|
||||
DO_(::google::protobuf::internal::WireFormat::SkipField(
|
||||
input, tag, mutable_unknown_fields()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
#undef DO_
|
||||
}
|
||||
|
||||
void Payload::SerializeWithCachedSizes(
|
||||
::google::protobuf::io::CodedOutputStream* output) const {
|
||||
// repeated .sampler.Content data = 1;
|
||||
for (int i = 0; i < this->data_size(); i++) {
|
||||
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
|
||||
1, this->data(i), output);
|
||||
}
|
||||
|
||||
if (!unknown_fields().empty()) {
|
||||
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
|
||||
unknown_fields(), output);
|
||||
}
|
||||
}
|
||||
|
||||
::google::protobuf::uint8* Payload::SerializeWithCachedSizesToArray(
|
||||
::google::protobuf::uint8* target) const {
|
||||
// repeated .sampler.Content data = 1;
|
||||
for (int i = 0; i < this->data_size(); i++) {
|
||||
target = ::google::protobuf::internal::WireFormatLite::
|
||||
WriteMessageNoVirtualToArray(
|
||||
1, this->data(i), target);
|
||||
}
|
||||
|
||||
if (!unknown_fields().empty()) {
|
||||
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
|
||||
unknown_fields(), target);
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
int Payload::ByteSize() const {
|
||||
int total_size = 0;
|
||||
|
||||
// repeated .sampler.Content data = 1;
|
||||
total_size += 1 * this->data_size();
|
||||
for (int i = 0; i < this->data_size(); i++) {
|
||||
total_size +=
|
||||
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
|
||||
this->data(i));
|
||||
}
|
||||
|
||||
if (!unknown_fields().empty()) {
|
||||
total_size +=
|
||||
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
|
||||
unknown_fields());
|
||||
}
|
||||
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
|
||||
_cached_size_ = total_size;
|
||||
GOOGLE_SAFE_CONCURRENT_WRITES_END();
|
||||
return total_size;
|
||||
}
|
||||
|
||||
void Payload::MergeFrom(const ::google::protobuf::Message& from) {
|
||||
GOOGLE_CHECK_NE(&from, this);
|
||||
const Payload* source =
|
||||
::google::protobuf::internal::dynamic_cast_if_available<const Payload*>(
|
||||
&from);
|
||||
if (source == NULL) {
|
||||
::google::protobuf::internal::ReflectionOps::Merge(from, this);
|
||||
} else {
|
||||
MergeFrom(*source);
|
||||
}
|
||||
}
|
||||
|
||||
void Payload::MergeFrom(const Payload& from) {
|
||||
GOOGLE_CHECK_NE(&from, this);
|
||||
data_.MergeFrom(from.data_);
|
||||
mutable_unknown_fields()->MergeFrom(from.unknown_fields());
|
||||
}
|
||||
|
||||
void Payload::CopyFrom(const ::google::protobuf::Message& from) {
|
||||
if (&from == this) return;
|
||||
Clear();
|
||||
MergeFrom(from);
|
||||
}
|
||||
|
||||
void Payload::CopyFrom(const Payload& from) {
|
||||
if (&from == this) return;
|
||||
Clear();
|
||||
MergeFrom(from);
|
||||
}
|
||||
|
||||
bool Payload::IsInitialized() const {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Payload::Swap(Payload* other) {
|
||||
if (other != this) {
|
||||
data_.Swap(&other->data_);
|
||||
std::swap(_has_bits_[0], other->_has_bits_[0]);
|
||||
_unknown_fields_.Swap(&other->_unknown_fields_);
|
||||
std::swap(_cached_size_, other->_cached_size_);
|
||||
}
|
||||
}
|
||||
|
||||
::google::protobuf::Metadata Payload::GetMetadata() const {
|
||||
protobuf_AssignDescriptorsOnce();
|
||||
::google::protobuf::Metadata metadata;
|
||||
metadata.descriptor = Payload_descriptor_;
|
||||
metadata.reflection = Payload_reflection_;
|
||||
return metadata;
|
||||
}
|
||||
|
||||
|
||||
// @@protoc_insertion_point(namespace_scope)
|
||||
|
||||
} // namespace sampler
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
@@ -1,415 +0,0 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: payload.proto
|
||||
|
||||
#ifndef PROTOBUF_payload_2eproto__INCLUDED
|
||||
#define PROTOBUF_payload_2eproto__INCLUDED
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
|
||||
#if GOOGLE_PROTOBUF_VERSION < 2005000
|
||||
#error This file was generated by a newer version of protoc which is
|
||||
#error incompatible with your Protocol Buffer headers. Please update
|
||||
#error your headers.
|
||||
#endif
|
||||
#if 2005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
|
||||
#error This file was generated by an older version of protoc which is
|
||||
#error incompatible with your Protocol Buffer headers. Please
|
||||
#error regenerate this file with a newer version of protoc.
|
||||
#endif
|
||||
|
||||
#include <google/protobuf/generated_message_util.h>
|
||||
#include <google/protobuf/message.h>
|
||||
#include <google/protobuf/repeated_field.h>
|
||||
#include <google/protobuf/extension_set.h>
|
||||
#include <google/protobuf/unknown_field_set.h>
|
||||
// @@protoc_insertion_point(includes)
|
||||
|
||||
namespace sampler {
|
||||
|
||||
// Internal implementation detail -- do not call these.
|
||||
void protobuf_AddDesc_payload_2eproto();
|
||||
void protobuf_AssignDesc_payload_2eproto();
|
||||
void protobuf_ShutdownFile_payload_2eproto();
|
||||
|
||||
class Content;
|
||||
class Payload;
|
||||
|
||||
// ===================================================================
|
||||
|
||||
class Content : public ::google::protobuf::Message {
|
||||
public:
|
||||
Content();
|
||||
virtual ~Content();
|
||||
|
||||
Content(const Content& from);
|
||||
|
||||
inline Content& operator=(const Content& from) {
|
||||
CopyFrom(from);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
|
||||
return _unknown_fields_;
|
||||
}
|
||||
|
||||
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
|
||||
return &_unknown_fields_;
|
||||
}
|
||||
|
||||
static const ::google::protobuf::Descriptor* descriptor();
|
||||
static const Content& default_instance();
|
||||
|
||||
void Swap(Content* other);
|
||||
|
||||
// implements Message ----------------------------------------------
|
||||
|
||||
Content* New() const;
|
||||
void CopyFrom(const ::google::protobuf::Message& from);
|
||||
void MergeFrom(const ::google::protobuf::Message& from);
|
||||
void CopyFrom(const Content& from);
|
||||
void MergeFrom(const Content& from);
|
||||
void Clear();
|
||||
bool IsInitialized() const;
|
||||
|
||||
int ByteSize() const;
|
||||
bool MergePartialFromCodedStream(
|
||||
::google::protobuf::io::CodedInputStream* input);
|
||||
void SerializeWithCachedSizes(
|
||||
::google::protobuf::io::CodedOutputStream* output) const;
|
||||
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
|
||||
int GetCachedSize() const { return _cached_size_; }
|
||||
private:
|
||||
void SharedCtor();
|
||||
void SharedDtor();
|
||||
void SetCachedSize(int size) const;
|
||||
public:
|
||||
|
||||
::google::protobuf::Metadata GetMetadata() const;
|
||||
|
||||
// nested types ----------------------------------------------------
|
||||
|
||||
// accessors -------------------------------------------------------
|
||||
|
||||
// optional double a = 1;
|
||||
inline bool has_a() const;
|
||||
inline void clear_a();
|
||||
static const int kAFieldNumber = 1;
|
||||
inline double a() const;
|
||||
inline void set_a(double value);
|
||||
|
||||
// optional double b = 2;
|
||||
inline bool has_b() const;
|
||||
inline void clear_b();
|
||||
static const int kBFieldNumber = 2;
|
||||
inline double b() const;
|
||||
inline void set_b(double value);
|
||||
|
||||
// optional int32 x = 3;
|
||||
inline bool has_x() const;
|
||||
inline void clear_x();
|
||||
static const int kXFieldNumber = 3;
|
||||
inline ::google::protobuf::int32 x() const;
|
||||
inline void set_x(::google::protobuf::int32 value);
|
||||
|
||||
// optional int32 y = 4;
|
||||
inline bool has_y() const;
|
||||
inline void clear_y();
|
||||
static const int kYFieldNumber = 4;
|
||||
inline ::google::protobuf::int32 y() const;
|
||||
inline void set_y(::google::protobuf::int32 value);
|
||||
|
||||
// optional int32 z = 5;
|
||||
inline bool has_z() const;
|
||||
inline void clear_z();
|
||||
static const int kZFieldNumber = 5;
|
||||
inline ::google::protobuf::int32 z() const;
|
||||
inline void set_z(::google::protobuf::int32 value);
|
||||
|
||||
// @@protoc_insertion_point(class_scope:sampler.Content)
|
||||
private:
|
||||
inline void set_has_a();
|
||||
inline void clear_has_a();
|
||||
inline void set_has_b();
|
||||
inline void clear_has_b();
|
||||
inline void set_has_x();
|
||||
inline void clear_has_x();
|
||||
inline void set_has_y();
|
||||
inline void clear_has_y();
|
||||
inline void set_has_z();
|
||||
inline void clear_has_z();
|
||||
|
||||
::google::protobuf::UnknownFieldSet _unknown_fields_;
|
||||
|
||||
double a_;
|
||||
double b_;
|
||||
::google::protobuf::int32 x_;
|
||||
::google::protobuf::int32 y_;
|
||||
::google::protobuf::int32 z_;
|
||||
|
||||
mutable int _cached_size_;
|
||||
::google::protobuf::uint32 _has_bits_[(5 + 31) / 32];
|
||||
|
||||
friend void protobuf_AddDesc_payload_2eproto();
|
||||
friend void protobuf_AssignDesc_payload_2eproto();
|
||||
friend void protobuf_ShutdownFile_payload_2eproto();
|
||||
|
||||
void InitAsDefaultInstance();
|
||||
static Content* default_instance_;
|
||||
};
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
class Payload : public ::google::protobuf::Message {
|
||||
public:
|
||||
Payload();
|
||||
virtual ~Payload();
|
||||
|
||||
Payload(const Payload& from);
|
||||
|
||||
inline Payload& operator=(const Payload& from) {
|
||||
CopyFrom(from);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
|
||||
return _unknown_fields_;
|
||||
}
|
||||
|
||||
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
|
||||
return &_unknown_fields_;
|
||||
}
|
||||
|
||||
static const ::google::protobuf::Descriptor* descriptor();
|
||||
static const Payload& default_instance();
|
||||
|
||||
void Swap(Payload* other);
|
||||
|
||||
// implements Message ----------------------------------------------
|
||||
|
||||
Payload* New() const;
|
||||
void CopyFrom(const ::google::protobuf::Message& from);
|
||||
void MergeFrom(const ::google::protobuf::Message& from);
|
||||
void CopyFrom(const Payload& from);
|
||||
void MergeFrom(const Payload& from);
|
||||
void Clear();
|
||||
bool IsInitialized() const;
|
||||
|
||||
int ByteSize() const;
|
||||
bool MergePartialFromCodedStream(
|
||||
::google::protobuf::io::CodedInputStream* input);
|
||||
void SerializeWithCachedSizes(
|
||||
::google::protobuf::io::CodedOutputStream* output) const;
|
||||
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
|
||||
int GetCachedSize() const { return _cached_size_; }
|
||||
private:
|
||||
void SharedCtor();
|
||||
void SharedDtor();
|
||||
void SetCachedSize(int size) const;
|
||||
public:
|
||||
|
||||
::google::protobuf::Metadata GetMetadata() const;
|
||||
|
||||
// nested types ----------------------------------------------------
|
||||
|
||||
// accessors -------------------------------------------------------
|
||||
|
||||
// repeated .sampler.Content data = 1;
|
||||
inline int data_size() const;
|
||||
inline void clear_data();
|
||||
static const int kDataFieldNumber = 1;
|
||||
inline const ::sampler::Content& data(int index) const;
|
||||
inline ::sampler::Content* mutable_data(int index);
|
||||
inline ::sampler::Content* add_data();
|
||||
inline const ::google::protobuf::RepeatedPtrField< ::sampler::Content >&
|
||||
data() const;
|
||||
inline ::google::protobuf::RepeatedPtrField< ::sampler::Content >*
|
||||
mutable_data();
|
||||
|
||||
// @@protoc_insertion_point(class_scope:sampler.Payload)
|
||||
private:
|
||||
|
||||
::google::protobuf::UnknownFieldSet _unknown_fields_;
|
||||
|
||||
::google::protobuf::RepeatedPtrField< ::sampler::Content > data_;
|
||||
|
||||
mutable int _cached_size_;
|
||||
::google::protobuf::uint32 _has_bits_[(1 + 31) / 32];
|
||||
|
||||
friend void protobuf_AddDesc_payload_2eproto();
|
||||
friend void protobuf_AssignDesc_payload_2eproto();
|
||||
friend void protobuf_ShutdownFile_payload_2eproto();
|
||||
|
||||
void InitAsDefaultInstance();
|
||||
static Payload* default_instance_;
|
||||
};
|
||||
// ===================================================================
|
||||
|
||||
|
||||
// ===================================================================
|
||||
|
||||
// Content
|
||||
|
||||
// optional double a = 1;
|
||||
inline bool Content::has_a() const {
|
||||
return (_has_bits_[0] & 0x00000001u) != 0;
|
||||
}
|
||||
inline void Content::set_has_a() {
|
||||
_has_bits_[0] |= 0x00000001u;
|
||||
}
|
||||
inline void Content::clear_has_a() {
|
||||
_has_bits_[0] &= ~0x00000001u;
|
||||
}
|
||||
inline void Content::clear_a() {
|
||||
a_ = 0;
|
||||
clear_has_a();
|
||||
}
|
||||
inline double Content::a() const {
|
||||
return a_;
|
||||
}
|
||||
inline void Content::set_a(double value) {
|
||||
set_has_a();
|
||||
a_ = value;
|
||||
}
|
||||
|
||||
// optional double b = 2;
|
||||
inline bool Content::has_b() const {
|
||||
return (_has_bits_[0] & 0x00000002u) != 0;
|
||||
}
|
||||
inline void Content::set_has_b() {
|
||||
_has_bits_[0] |= 0x00000002u;
|
||||
}
|
||||
inline void Content::clear_has_b() {
|
||||
_has_bits_[0] &= ~0x00000002u;
|
||||
}
|
||||
inline void Content::clear_b() {
|
||||
b_ = 0;
|
||||
clear_has_b();
|
||||
}
|
||||
inline double Content::b() const {
|
||||
return b_;
|
||||
}
|
||||
inline void Content::set_b(double value) {
|
||||
set_has_b();
|
||||
b_ = value;
|
||||
}
|
||||
|
||||
// optional int32 x = 3;
|
||||
inline bool Content::has_x() const {
|
||||
return (_has_bits_[0] & 0x00000004u) != 0;
|
||||
}
|
||||
inline void Content::set_has_x() {
|
||||
_has_bits_[0] |= 0x00000004u;
|
||||
}
|
||||
inline void Content::clear_has_x() {
|
||||
_has_bits_[0] &= ~0x00000004u;
|
||||
}
|
||||
inline void Content::clear_x() {
|
||||
x_ = 0;
|
||||
clear_has_x();
|
||||
}
|
||||
inline ::google::protobuf::int32 Content::x() const {
|
||||
return x_;
|
||||
}
|
||||
inline void Content::set_x(::google::protobuf::int32 value) {
|
||||
set_has_x();
|
||||
x_ = value;
|
||||
}
|
||||
|
||||
// optional int32 y = 4;
|
||||
inline bool Content::has_y() const {
|
||||
return (_has_bits_[0] & 0x00000008u) != 0;
|
||||
}
|
||||
inline void Content::set_has_y() {
|
||||
_has_bits_[0] |= 0x00000008u;
|
||||
}
|
||||
inline void Content::clear_has_y() {
|
||||
_has_bits_[0] &= ~0x00000008u;
|
||||
}
|
||||
inline void Content::clear_y() {
|
||||
y_ = 0;
|
||||
clear_has_y();
|
||||
}
|
||||
inline ::google::protobuf::int32 Content::y() const {
|
||||
return y_;
|
||||
}
|
||||
inline void Content::set_y(::google::protobuf::int32 value) {
|
||||
set_has_y();
|
||||
y_ = value;
|
||||
}
|
||||
|
||||
// optional int32 z = 5;
|
||||
inline bool Content::has_z() const {
|
||||
return (_has_bits_[0] & 0x00000010u) != 0;
|
||||
}
|
||||
inline void Content::set_has_z() {
|
||||
_has_bits_[0] |= 0x00000010u;
|
||||
}
|
||||
inline void Content::clear_has_z() {
|
||||
_has_bits_[0] &= ~0x00000010u;
|
||||
}
|
||||
inline void Content::clear_z() {
|
||||
z_ = 0;
|
||||
clear_has_z();
|
||||
}
|
||||
inline ::google::protobuf::int32 Content::z() const {
|
||||
return z_;
|
||||
}
|
||||
inline void Content::set_z(::google::protobuf::int32 value) {
|
||||
set_has_z();
|
||||
z_ = value;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
// Payload
|
||||
|
||||
// repeated .sampler.Content data = 1;
|
||||
inline int Payload::data_size() const {
|
||||
return data_.size();
|
||||
}
|
||||
inline void Payload::clear_data() {
|
||||
data_.Clear();
|
||||
}
|
||||
inline const ::sampler::Content& Payload::data(int index) const {
|
||||
return data_.Get(index);
|
||||
}
|
||||
inline ::sampler::Content* Payload::mutable_data(int index) {
|
||||
return data_.Mutable(index);
|
||||
}
|
||||
inline ::sampler::Content* Payload::add_data() {
|
||||
return data_.Add();
|
||||
}
|
||||
inline const ::google::protobuf::RepeatedPtrField< ::sampler::Content >&
|
||||
Payload::data() const {
|
||||
return data_;
|
||||
}
|
||||
inline ::google::protobuf::RepeatedPtrField< ::sampler::Content >*
|
||||
Payload::mutable_data() {
|
||||
return &data_;
|
||||
}
|
||||
|
||||
|
||||
// @@protoc_insertion_point(namespace_scope)
|
||||
|
||||
} // namespace sampler
|
||||
|
||||
#ifndef SWIG
|
||||
namespace google {
|
||||
namespace protobuf {
|
||||
|
||||
|
||||
} // namespace google
|
||||
} // namespace protobuf
|
||||
#endif // SWIG
|
||||
|
||||
// @@protoc_insertion_point(global_scope)
|
||||
|
||||
#endif // PROTOBUF_payload_2eproto__INCLUDED
|
153
fairmq/prototest/runBinSampler.cxx
Normal file
153
fairmq/prototest/runBinSampler.cxx
Normal file
@@ -0,0 +1,153 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* runBenchmarkSampler.cxx
|
||||
*
|
||||
* @since 2013-04-23
|
||||
* @author D. Klein, A. Rybalchenko
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "boost/program_options.hpp"
|
||||
|
||||
#include "FairMQLogger.h"
|
||||
#include "FairMQBinSampler.h"
|
||||
|
||||
#ifdef NANOMSG
|
||||
#include "FairMQTransportFactoryNN.h"
|
||||
#else
|
||||
#include "FairMQTransportFactoryZMQ.h"
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef struct DeviceOptions
|
||||
{
|
||||
DeviceOptions() :
|
||||
id(), eventSize(0), eventRate(0), ioThreads(0),
|
||||
outputSocketType(), outputBufSize(0), outputMethod(), outputAddress() {}
|
||||
|
||||
string id;
|
||||
int eventSize;
|
||||
int eventRate;
|
||||
int ioThreads;
|
||||
string outputSocketType;
|
||||
int outputBufSize;
|
||||
string outputMethod;
|
||||
string outputAddress;
|
||||
} DeviceOptions_t;
|
||||
|
||||
inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
||||
{
|
||||
if (_options == NULL)
|
||||
throw runtime_error("Internal error: options' container is empty.");
|
||||
|
||||
namespace bpo = boost::program_options;
|
||||
bpo::options_description desc("Options");
|
||||
desc.add_options()
|
||||
("id", bpo::value<string>()->required(), "Device ID")
|
||||
("event-size", bpo::value<int>()->default_value(1000), "Event size in bytes")
|
||||
("event-rate", bpo::value<int>()->default_value(0), "Event rate limit in maximum number of events per second")
|
||||
("io-threads", bpo::value<int>()->default_value(1), "Number of I/O threads")
|
||||
("output-socket-type", bpo::value<string>()->required(), "Output socket type: pub/push")
|
||||
("output-buff-size", bpo::value<int>()->required(), "Output buffer size in number of messages (ZeroMQ)/bytes(nanomsg)")
|
||||
("output-method", bpo::value<string>()->required(), "Output method: bind/connect")
|
||||
("output-address", bpo::value<string>()->required(), "Output address, e.g.: \"tcp://*:5555\"")
|
||||
("help", "Print help messages");
|
||||
|
||||
bpo::variables_map vm;
|
||||
bpo::store(bpo::parse_command_line(_argc, _argv, desc), vm);
|
||||
|
||||
if ( vm.count("help") )
|
||||
{
|
||||
LOG(INFO) << "FairMQ Bin Sampler" << endl << desc;
|
||||
return false;
|
||||
}
|
||||
|
||||
bpo::notify(vm);
|
||||
|
||||
if ( vm.count("id") )
|
||||
_options->id = vm["id"].as<string>();
|
||||
|
||||
if ( vm.count("event-size") )
|
||||
_options->eventSize = vm["event-size"].as<int>();
|
||||
|
||||
if ( vm.count("event-rate") )
|
||||
_options->eventRate = vm["event-rate"].as<int>();
|
||||
|
||||
if ( vm.count("io-threads") )
|
||||
_options->ioThreads = vm["io-threads"].as<int>();
|
||||
|
||||
if ( vm.count("output-socket-type") )
|
||||
_options->outputSocketType = vm["output-socket-type"].as<string>();
|
||||
|
||||
if ( vm.count("output-buff-size") )
|
||||
_options->outputBufSize = vm["output-buff-size"].as<int>();
|
||||
|
||||
if ( vm.count("output-method") )
|
||||
_options->outputMethod = vm["output-method"].as<string>();
|
||||
|
||||
if ( vm.count("output-address") )
|
||||
_options->outputAddress = vm["output-address"].as<string>();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
FairMQBinSampler sampler;
|
||||
sampler.CatchSignals();
|
||||
|
||||
DeviceOptions_t options;
|
||||
try
|
||||
{
|
||||
if (!parse_cmd_line(argc, argv, &options))
|
||||
return 0;
|
||||
}
|
||||
catch (exception& e)
|
||||
{
|
||||
LOG(ERROR) << e.what();
|
||||
return 1;
|
||||
}
|
||||
|
||||
LOG(INFO) << "PID: " << getpid();
|
||||
LOG(INFO) << "CONFIG: " << "id: " << options.id << ", event size: " << options.eventSize << ", event rate: " << options.eventRate << ", I/O threads: " << options.ioThreads;
|
||||
LOG(INFO) << "OUTPUT: " << options.outputSocketType << " " << options.outputBufSize << " " << options.outputMethod << " " << options.outputAddress;
|
||||
|
||||
#ifdef NANOMSG
|
||||
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
|
||||
#else
|
||||
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
|
||||
#endif
|
||||
|
||||
sampler.SetTransport(transportFactory);
|
||||
|
||||
FairMQChannel outputChannel(options.outputSocketType, options.outputMethod, options.outputAddress);
|
||||
outputChannel.UpdateSndBufSize(options.outputBufSize);
|
||||
outputChannel.UpdateRcvBufSize(options.outputBufSize);
|
||||
outputChannel.UpdateRateLogging(1);
|
||||
|
||||
sampler.fChannels["data-out"].push_back(outputChannel);
|
||||
|
||||
sampler.SetProperty(FairMQBinSampler::Id, options.id);
|
||||
sampler.SetProperty(FairMQBinSampler::EventSize, options.eventSize);
|
||||
sampler.SetProperty(FairMQBinSampler::EventRate, options.eventRate);
|
||||
sampler.SetProperty(FairMQBinSampler::NumIoThreads, options.ioThreads);
|
||||
|
||||
sampler.ChangeState("INIT_DEVICE");
|
||||
sampler.WaitForEndOfState("INIT_DEVICE");
|
||||
|
||||
sampler.ChangeState("INIT_TASK");
|
||||
sampler.WaitForEndOfState("INIT_TASK");
|
||||
|
||||
sampler.ChangeState("RUN");
|
||||
sampler.InteractiveStateLoop();
|
||||
|
||||
return 0;
|
||||
}
|
139
fairmq/prototest/runBinSink.cxx
Normal file
139
fairmq/prototest/runBinSink.cxx
Normal file
@@ -0,0 +1,139 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* runSink.cxx
|
||||
*
|
||||
* @since 2013-01-21
|
||||
* @author D. Klein, A. Rybalchenko
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "boost/program_options.hpp"
|
||||
|
||||
#include "FairMQLogger.h"
|
||||
#include "FairMQBinSink.h"
|
||||
|
||||
#ifdef NANOMSG
|
||||
#include "FairMQTransportFactoryNN.h"
|
||||
#else
|
||||
#include "FairMQTransportFactoryZMQ.h"
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef struct DeviceOptions
|
||||
{
|
||||
DeviceOptions() :
|
||||
id(), ioThreads(0),
|
||||
inputSocketType(), inputBufSize(0), inputMethod(), inputAddress() {}
|
||||
|
||||
string id;
|
||||
int ioThreads;
|
||||
string inputSocketType;
|
||||
int inputBufSize;
|
||||
string inputMethod;
|
||||
string inputAddress;
|
||||
} DeviceOptions_t;
|
||||
|
||||
inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
||||
{
|
||||
if (_options == NULL)
|
||||
throw runtime_error("Internal error: options' container is empty.");
|
||||
|
||||
namespace bpo = boost::program_options;
|
||||
bpo::options_description desc("Options");
|
||||
desc.add_options()
|
||||
("id", bpo::value<string>()->required(), "Device ID")
|
||||
("io-threads", bpo::value<int>()->default_value(1), "Number of I/O threads")
|
||||
("input-socket-type", bpo::value<string>()->required(), "Input socket type: sub/pull")
|
||||
("input-buff-size", bpo::value<int>()->required(), "Input buffer size in number of messages (ZeroMQ)/bytes(nanomsg)")
|
||||
("input-method", bpo::value<string>()->required(), "Input method: bind/connect")
|
||||
("input-address", bpo::value<string>()->required(), "Input address, e.g.: \"tcp://*:5555\"")
|
||||
("help", "Print help messages");
|
||||
|
||||
bpo::variables_map vm;
|
||||
bpo::store(bpo::parse_command_line(_argc, _argv, desc), vm);
|
||||
|
||||
if ( vm.count("help") )
|
||||
{
|
||||
LOG(INFO) << "FairMQ Bin Sink" << endl << desc;
|
||||
return false;
|
||||
}
|
||||
|
||||
bpo::notify(vm);
|
||||
|
||||
if ( vm.count("id") )
|
||||
_options->id = vm["id"].as<string>();
|
||||
|
||||
if ( vm.count("io-threads") )
|
||||
_options->ioThreads = vm["io-threads"].as<int>();
|
||||
|
||||
if ( vm.count("input-socket-type") )
|
||||
_options->inputSocketType = vm["input-socket-type"].as<string>();
|
||||
|
||||
if ( vm.count("input-buff-size") )
|
||||
_options->inputBufSize = vm["input-buff-size"].as<int>();
|
||||
|
||||
if ( vm.count("input-method") )
|
||||
_options->inputMethod = vm["input-method"].as<string>();
|
||||
|
||||
if ( vm.count("input-address") )
|
||||
_options->inputAddress = vm["input-address"].as<string>();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
FairMQBinSink sink;
|
||||
sink.CatchSignals();
|
||||
|
||||
DeviceOptions_t options;
|
||||
try
|
||||
{
|
||||
if (!parse_cmd_line(argc, argv, &options))
|
||||
return 0;
|
||||
}
|
||||
catch (exception& e)
|
||||
{
|
||||
LOG(ERROR) << e.what();
|
||||
return 1;
|
||||
}
|
||||
|
||||
LOG(INFO) << "PID: " << getpid();
|
||||
|
||||
#ifdef NANOMSG
|
||||
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
|
||||
#else
|
||||
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
|
||||
#endif
|
||||
|
||||
sink.SetTransport(transportFactory);
|
||||
|
||||
FairMQChannel inputChannel(options.inputSocketType, options.inputMethod, options.inputAddress);
|
||||
inputChannel.UpdateSndBufSize(options.inputBufSize);
|
||||
inputChannel.UpdateRcvBufSize(options.inputBufSize);
|
||||
inputChannel.UpdateRateLogging(1);
|
||||
|
||||
sink.fChannels["data-in"].push_back(inputChannel);
|
||||
|
||||
sink.SetProperty(FairMQBinSink::Id, options.id);
|
||||
sink.SetProperty(FairMQBinSink::NumIoThreads, options.ioThreads);
|
||||
|
||||
sink.ChangeState("INIT_DEVICE");
|
||||
sink.WaitForEndOfState("INIT_DEVICE");
|
||||
|
||||
sink.ChangeState("INIT_TASK");
|
||||
sink.WaitForEndOfState("INIT_TASK");
|
||||
|
||||
sink.ChangeState("RUN");
|
||||
sink.InteractiveStateLoop();
|
||||
|
||||
return 0;
|
||||
}
|
153
fairmq/prototest/runProtoSampler.cxx
Normal file
153
fairmq/prototest/runProtoSampler.cxx
Normal file
@@ -0,0 +1,153 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* runBenchmarkSampler.cxx
|
||||
*
|
||||
* @since 2013-04-23
|
||||
* @author D. Klein, A. Rybalchenko
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "boost/program_options.hpp"
|
||||
|
||||
#include "FairMQLogger.h"
|
||||
#include "FairMQProtoSampler.h"
|
||||
|
||||
#ifdef NANOMSG
|
||||
#include "FairMQTransportFactoryNN.h"
|
||||
#else
|
||||
#include "FairMQTransportFactoryZMQ.h"
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef struct DeviceOptions
|
||||
{
|
||||
DeviceOptions() :
|
||||
id(), eventSize(0), eventRate(0), ioThreads(0),
|
||||
outputSocketType(), outputBufSize(0), outputMethod(), outputAddress() {}
|
||||
|
||||
string id;
|
||||
int eventSize;
|
||||
int eventRate;
|
||||
int ioThreads;
|
||||
string outputSocketType;
|
||||
int outputBufSize;
|
||||
string outputMethod;
|
||||
string outputAddress;
|
||||
} DeviceOptions_t;
|
||||
|
||||
inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
||||
{
|
||||
if (_options == NULL)
|
||||
throw runtime_error("Internal error: options' container is empty.");
|
||||
|
||||
namespace bpo = boost::program_options;
|
||||
bpo::options_description desc("Options");
|
||||
desc.add_options()
|
||||
("id", bpo::value<string>()->required(), "Device ID")
|
||||
("event-size", bpo::value<int>()->default_value(1000), "Event size in bytes")
|
||||
("event-rate", bpo::value<int>()->default_value(0), "Event rate limit in maximum number of events per second")
|
||||
("io-threads", bpo::value<int>()->default_value(1), "Number of I/O threads")
|
||||
("output-socket-type", bpo::value<string>()->required(), "Output socket type: pub/push")
|
||||
("output-buff-size", bpo::value<int>()->required(), "Output buffer size in number of messages (ZeroMQ)/bytes(nanomsg)")
|
||||
("output-method", bpo::value<string>()->required(), "Output method: bind/connect")
|
||||
("output-address", bpo::value<string>()->required(), "Output address, e.g.: \"tcp://*:5555\"")
|
||||
("help", "Print help messages");
|
||||
|
||||
bpo::variables_map vm;
|
||||
bpo::store(bpo::parse_command_line(_argc, _argv, desc), vm);
|
||||
|
||||
if ( vm.count("help") )
|
||||
{
|
||||
LOG(INFO) << "FairMQ Proto Sampler" << endl << desc;
|
||||
return false;
|
||||
}
|
||||
|
||||
bpo::notify(vm);
|
||||
|
||||
if ( vm.count("id") )
|
||||
_options->id = vm["id"].as<string>();
|
||||
|
||||
if ( vm.count("event-size") )
|
||||
_options->eventSize = vm["event-size"].as<int>();
|
||||
|
||||
if ( vm.count("event-rate") )
|
||||
_options->eventRate = vm["event-rate"].as<int>();
|
||||
|
||||
if ( vm.count("io-threads") )
|
||||
_options->ioThreads = vm["io-threads"].as<int>();
|
||||
|
||||
if ( vm.count("output-socket-type") )
|
||||
_options->outputSocketType = vm["output-socket-type"].as<string>();
|
||||
|
||||
if ( vm.count("output-buff-size") )
|
||||
_options->outputBufSize = vm["output-buff-size"].as<int>();
|
||||
|
||||
if ( vm.count("output-method") )
|
||||
_options->outputMethod = vm["output-method"].as<string>();
|
||||
|
||||
if ( vm.count("output-address") )
|
||||
_options->outputAddress = vm["output-address"].as<string>();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
FairMQProtoSampler sampler;
|
||||
sampler.CatchSignals();
|
||||
|
||||
DeviceOptions_t options;
|
||||
try
|
||||
{
|
||||
if (!parse_cmd_line(argc, argv, &options))
|
||||
return 0;
|
||||
}
|
||||
catch (exception& e)
|
||||
{
|
||||
LOG(ERROR) << e.what();
|
||||
return 1;
|
||||
}
|
||||
|
||||
LOG(INFO) << "PID: " << getpid();
|
||||
LOG(INFO) << "CONFIG: " << "id: " << options.id << ", event size: " << options.eventSize << ", event rate: " << options.eventRate << ", I/O threads: " << options.ioThreads;
|
||||
LOG(INFO) << "OUTPUT: " << options.outputSocketType << " " << options.outputBufSize << " " << options.outputMethod << " " << options.outputAddress;
|
||||
|
||||
#ifdef NANOMSG
|
||||
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
|
||||
#else
|
||||
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
|
||||
#endif
|
||||
|
||||
sampler.SetTransport(transportFactory);
|
||||
|
||||
FairMQChannel outputChannel(options.outputSocketType, options.outputMethod, options.outputAddress);
|
||||
outputChannel.UpdateSndBufSize(options.outputBufSize);
|
||||
outputChannel.UpdateRcvBufSize(options.outputBufSize);
|
||||
outputChannel.UpdateRateLogging(1);
|
||||
|
||||
sampler.fChannels["data-out"].push_back(outputChannel);
|
||||
|
||||
sampler.SetProperty(FairMQProtoSampler::Id, options.id);
|
||||
sampler.SetProperty(FairMQProtoSampler::EventSize, options.eventSize);
|
||||
sampler.SetProperty(FairMQProtoSampler::EventRate, options.eventRate);
|
||||
sampler.SetProperty(FairMQProtoSampler::NumIoThreads, options.ioThreads);
|
||||
|
||||
sampler.ChangeState("INIT_DEVICE");
|
||||
sampler.WaitForEndOfState("INIT_DEVICE");
|
||||
|
||||
sampler.ChangeState("INIT_TASK");
|
||||
sampler.WaitForEndOfState("INIT_TASK");
|
||||
|
||||
sampler.ChangeState("RUN");
|
||||
sampler.InteractiveStateLoop();
|
||||
|
||||
return 0;
|
||||
}
|
139
fairmq/prototest/runProtoSink.cxx
Normal file
139
fairmq/prototest/runProtoSink.cxx
Normal file
@@ -0,0 +1,139 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
/**
|
||||
* runSink.cxx
|
||||
*
|
||||
* @since 2013-01-21
|
||||
* @author D. Klein, A. Rybalchenko
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "boost/program_options.hpp"
|
||||
|
||||
#include "FairMQLogger.h"
|
||||
#include "FairMQProtoSink.h"
|
||||
|
||||
#ifdef NANOMSG
|
||||
#include "FairMQTransportFactoryNN.h"
|
||||
#else
|
||||
#include "FairMQTransportFactoryZMQ.h"
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef struct DeviceOptions
|
||||
{
|
||||
DeviceOptions() :
|
||||
id(), ioThreads(0),
|
||||
inputSocketType(), inputBufSize(0), inputMethod(), inputAddress() {}
|
||||
|
||||
string id;
|
||||
int ioThreads;
|
||||
string inputSocketType;
|
||||
int inputBufSize;
|
||||
string inputMethod;
|
||||
string inputAddress;
|
||||
} DeviceOptions_t;
|
||||
|
||||
inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
||||
{
|
||||
if (_options == NULL)
|
||||
throw runtime_error("Internal error: options' container is empty.");
|
||||
|
||||
namespace bpo = boost::program_options;
|
||||
bpo::options_description desc("Options");
|
||||
desc.add_options()
|
||||
("id", bpo::value<string>()->required(), "Device ID")
|
||||
("io-threads", bpo::value<int>()->default_value(1), "Number of I/O threads")
|
||||
("input-socket-type", bpo::value<string>()->required(), "Input socket type: sub/pull")
|
||||
("input-buff-size", bpo::value<int>()->required(), "Input buffer size in number of messages (ZeroMQ)/bytes(nanomsg)")
|
||||
("input-method", bpo::value<string>()->required(), "Input method: bind/connect")
|
||||
("input-address", bpo::value<string>()->required(), "Input address, e.g.: \"tcp://*:5555\"")
|
||||
("help", "Print help messages");
|
||||
|
||||
bpo::variables_map vm;
|
||||
bpo::store(bpo::parse_command_line(_argc, _argv, desc), vm);
|
||||
|
||||
if ( vm.count("help") )
|
||||
{
|
||||
LOG(INFO) << "FairMQ Proto Sink" << endl << desc;
|
||||
return false;
|
||||
}
|
||||
|
||||
bpo::notify(vm);
|
||||
|
||||
if ( vm.count("id") )
|
||||
_options->id = vm["id"].as<string>();
|
||||
|
||||
if ( vm.count("io-threads") )
|
||||
_options->ioThreads = vm["io-threads"].as<int>();
|
||||
|
||||
if ( vm.count("input-socket-type") )
|
||||
_options->inputSocketType = vm["input-socket-type"].as<string>();
|
||||
|
||||
if ( vm.count("input-buff-size") )
|
||||
_options->inputBufSize = vm["input-buff-size"].as<int>();
|
||||
|
||||
if ( vm.count("input-method") )
|
||||
_options->inputMethod = vm["input-method"].as<string>();
|
||||
|
||||
if ( vm.count("input-address") )
|
||||
_options->inputAddress = vm["input-address"].as<string>();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
FairMQProtoSink sink;
|
||||
sink.CatchSignals();
|
||||
|
||||
DeviceOptions_t options;
|
||||
try
|
||||
{
|
||||
if (!parse_cmd_line(argc, argv, &options))
|
||||
return 0;
|
||||
}
|
||||
catch (exception& e)
|
||||
{
|
||||
LOG(ERROR) << e.what();
|
||||
return 1;
|
||||
}
|
||||
|
||||
LOG(INFO) << "PID: " << getpid();
|
||||
|
||||
#ifdef NANOMSG
|
||||
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryNN();
|
||||
#else
|
||||
FairMQTransportFactory* transportFactory = new FairMQTransportFactoryZMQ();
|
||||
#endif
|
||||
|
||||
sink.SetTransport(transportFactory);
|
||||
|
||||
FairMQChannel inputChannel(options.inputSocketType, options.inputMethod, options.inputAddress);
|
||||
inputChannel.UpdateSndBufSize(options.inputBufSize);
|
||||
inputChannel.UpdateRcvBufSize(options.inputBufSize);
|
||||
inputChannel.UpdateRateLogging(1);
|
||||
|
||||
sink.fChannels["data-in"].push_back(inputChannel);
|
||||
|
||||
sink.SetProperty(FairMQProtoSink::Id, options.id);
|
||||
sink.SetProperty(FairMQProtoSink::NumIoThreads, options.ioThreads);
|
||||
|
||||
sink.ChangeState("INIT_DEVICE");
|
||||
sink.WaitForEndOfState("INIT_DEVICE");
|
||||
|
||||
sink.ChangeState("INIT_TASK");
|
||||
sink.WaitForEndOfState("INIT_TASK");
|
||||
|
||||
sink.ChangeState("RUN");
|
||||
sink.InteractiveStateLoop();
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user