mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-15 17:41:45 +00:00
Remove GetSocket interface that exposes transport details
This commit is contained in:
committed by
Dennis Klein
parent
f8824335a5
commit
ce4062f3a0
@@ -15,6 +15,7 @@
|
||||
#include <zmq.h>
|
||||
|
||||
#include "FairMQPollerZMQ.h"
|
||||
#include "FairMQSocketZMQ.h"
|
||||
#include "FairMQLogger.h"
|
||||
|
||||
using namespace std;
|
||||
@@ -29,13 +30,13 @@ FairMQPollerZMQ::FairMQPollerZMQ(const vector<FairMQChannel>& channels)
|
||||
|
||||
for (int i = 0; i < fNumItems; ++i)
|
||||
{
|
||||
fItems[i].socket = channels.at(i).GetSocket().GetSocket();
|
||||
fItems[i].socket = static_cast<const FairMQSocketZMQ*>(&(channels.at(i).GetSocket()))->GetSocket();
|
||||
fItems[i].fd = 0;
|
||||
fItems[i].revents = 0;
|
||||
|
||||
int type = 0;
|
||||
size_t size = sizeof(type);
|
||||
zmq_getsockopt(channels.at(i).GetSocket().GetSocket(), ZMQ_TYPE, &type, &size);
|
||||
zmq_getsockopt(static_cast<const FairMQSocketZMQ*>(&(channels.at(i).GetSocket()))->GetSocket(), ZMQ_TYPE, &type, &size);
|
||||
|
||||
SetItemEvents(fItems[i], type);
|
||||
}
|
||||
@@ -52,13 +53,13 @@ FairMQPollerZMQ::FairMQPollerZMQ(const std::vector<const FairMQChannel*>& channe
|
||||
|
||||
for (int i = 0; i < fNumItems; ++i)
|
||||
{
|
||||
fItems[i].socket = channels.at(i)->GetSocket().GetSocket();
|
||||
fItems[i].socket = static_cast<const FairMQSocketZMQ*>(&(channels.at(i)->GetSocket()))->GetSocket();
|
||||
fItems[i].fd = 0;
|
||||
fItems[i].revents = 0;
|
||||
|
||||
int type = 0;
|
||||
size_t size = sizeof(type);
|
||||
zmq_getsockopt(channels.at(i)->GetSocket().GetSocket(), ZMQ_TYPE, &type, &size);
|
||||
zmq_getsockopt(static_cast<const FairMQSocketZMQ*>(&(channels.at(i)->GetSocket()))->GetSocket(), ZMQ_TYPE, &type, &size);
|
||||
|
||||
SetItemEvents(fItems[i], type);
|
||||
}
|
||||
@@ -89,13 +90,13 @@ FairMQPollerZMQ::FairMQPollerZMQ(const unordered_map<string, vector<FairMQChanne
|
||||
{
|
||||
index = fOffsetMap[channel] + i;
|
||||
|
||||
fItems[index].socket = channelsMap.at(channel).at(i).GetSocket().GetSocket();
|
||||
fItems[index].socket = static_cast<const FairMQSocketZMQ*>(&(channelsMap.at(channel).at(i).GetSocket()))->GetSocket();
|
||||
fItems[index].fd = 0;
|
||||
fItems[index].revents = 0;
|
||||
|
||||
int type = 0;
|
||||
size_t size = sizeof(type);
|
||||
zmq_getsockopt(channelsMap.at(channel).at(i).GetSocket().GetSocket(), ZMQ_TYPE, &type, &size);
|
||||
zmq_getsockopt(static_cast<const FairMQSocketZMQ*>(&(channelsMap.at(channel).at(i).GetSocket()))->GetSocket(), ZMQ_TYPE, &type, &size);
|
||||
|
||||
SetItemEvents(fItems[index], type);
|
||||
}
|
||||
@@ -109,29 +110,6 @@ FairMQPollerZMQ::FairMQPollerZMQ(const unordered_map<string, vector<FairMQChanne
|
||||
}
|
||||
}
|
||||
|
||||
FairMQPollerZMQ::FairMQPollerZMQ(const FairMQSocket& cmdSocket, const FairMQSocket& dataSocket)
|
||||
: fItems()
|
||||
, fNumItems(2)
|
||||
, fOffsetMap()
|
||||
{
|
||||
fItems = new zmq_pollitem_t[fNumItems];
|
||||
|
||||
fItems[0].socket = cmdSocket.GetSocket();
|
||||
fItems[0].fd = 0;
|
||||
fItems[0].events = ZMQ_POLLIN;
|
||||
fItems[0].revents = 0;
|
||||
|
||||
fItems[1].socket = dataSocket.GetSocket();
|
||||
fItems[1].fd = 0;
|
||||
fItems[1].revents = 0;
|
||||
|
||||
int type = 0;
|
||||
size_t size = sizeof(type);
|
||||
zmq_getsockopt(dataSocket.GetSocket(), ZMQ_TYPE, &type, &size);
|
||||
|
||||
SetItemEvents(fItems[1], type);
|
||||
}
|
||||
|
||||
void FairMQPollerZMQ::SetItemEvents(zmq_pollitem_t& item, const int type)
|
||||
{
|
||||
if (type == ZMQ_REQ || type == ZMQ_REP || type == ZMQ_PAIR || type == ZMQ_DEALER || type == ZMQ_ROUTER)
|
||||
|
@@ -51,8 +51,6 @@ class FairMQPollerZMQ final : public FairMQPoller
|
||||
~FairMQPollerZMQ() override;
|
||||
|
||||
private:
|
||||
FairMQPollerZMQ(const FairMQSocket& cmdSocket, const FairMQSocket& dataSocket);
|
||||
|
||||
zmq_pollitem_t* fItems;
|
||||
int fNumItems;
|
||||
|
||||
|
@@ -382,12 +382,6 @@ void* FairMQSocketZMQ::GetSocket() const
|
||||
return fSocket;
|
||||
}
|
||||
|
||||
int FairMQSocketZMQ::GetSocket(int) const
|
||||
{
|
||||
// dummy method to comply with the interface. functionality not possible in zeromq.
|
||||
return -1;
|
||||
}
|
||||
|
||||
void FairMQSocketZMQ::SetOption(const string& option, const void* value, size_t valueSize)
|
||||
{
|
||||
if (zmq_setsockopt(fSocket, GetConstant(option), value, valueSize) < 0)
|
||||
@@ -414,7 +408,7 @@ void FairMQSocketZMQ::SetLinger(const int value)
|
||||
int FairMQSocketZMQ::GetLinger() const
|
||||
{
|
||||
int value = 0;
|
||||
size_t valueSize;
|
||||
size_t valueSize = sizeof(value);
|
||||
if (zmq_getsockopt(fSocket, ZMQ_LINGER, &value, &valueSize) < 0) {
|
||||
throw SocketError(tools::ToString("failed getting ZMQ_LINGER, reason: ", zmq_strerror(errno)));
|
||||
}
|
||||
@@ -431,7 +425,7 @@ void FairMQSocketZMQ::SetSndBufSize(const int value)
|
||||
int FairMQSocketZMQ::GetSndBufSize() const
|
||||
{
|
||||
int value = 0;
|
||||
size_t valueSize;
|
||||
size_t valueSize = sizeof(value);
|
||||
if (zmq_getsockopt(fSocket, ZMQ_SNDHWM, &value, &valueSize) < 0) {
|
||||
throw SocketError(tools::ToString("failed getting ZMQ_SNDHWM, reason: ", zmq_strerror(errno)));
|
||||
}
|
||||
@@ -448,7 +442,7 @@ void FairMQSocketZMQ::SetRcvBufSize(const int value)
|
||||
int FairMQSocketZMQ::GetRcvBufSize() const
|
||||
{
|
||||
int value = 0;
|
||||
size_t valueSize;
|
||||
size_t valueSize = sizeof(value);
|
||||
if (zmq_getsockopt(fSocket, ZMQ_RCVHWM, &value, &valueSize) < 0) {
|
||||
throw SocketError(tools::ToString("failed getting ZMQ_RCVHWM, reason: ", zmq_strerror(errno)));
|
||||
}
|
||||
@@ -465,7 +459,7 @@ void FairMQSocketZMQ::SetSndKernelSize(const int value)
|
||||
int FairMQSocketZMQ::GetSndKernelSize() const
|
||||
{
|
||||
int value = 0;
|
||||
size_t valueSize;
|
||||
size_t valueSize = sizeof(value);
|
||||
if (zmq_getsockopt(fSocket, ZMQ_SNDBUF, &value, &valueSize) < 0) {
|
||||
throw SocketError(tools::ToString("failed getting ZMQ_SNDBUF, reason: ", zmq_strerror(errno)));
|
||||
}
|
||||
@@ -482,7 +476,7 @@ void FairMQSocketZMQ::SetRcvKernelSize(const int value)
|
||||
int FairMQSocketZMQ::GetRcvKernelSize() const
|
||||
{
|
||||
int value = 0;
|
||||
size_t valueSize;
|
||||
size_t valueSize = sizeof(value);
|
||||
if (zmq_getsockopt(fSocket, ZMQ_RCVBUF, &value, &valueSize) < 0) {
|
||||
throw SocketError(tools::ToString("failed getting ZMQ_RCVBUF, reason: ", zmq_strerror(errno)));
|
||||
}
|
||||
|
@@ -38,8 +38,7 @@ class FairMQSocketZMQ final : public FairMQSocket
|
||||
int64_t TrySend(std::vector<std::unique_ptr<FairMQMessage>>& msgVec) override;
|
||||
int64_t TryReceive(std::vector<std::unique_ptr<FairMQMessage>>& msgVec) override;
|
||||
|
||||
void* GetSocket() const override;
|
||||
int GetSocket(int nothing) const override;
|
||||
void* GetSocket() const;
|
||||
|
||||
void Close() override;
|
||||
|
||||
|
@@ -90,11 +90,6 @@ FairMQPollerPtr FairMQTransportFactoryZMQ::CreatePoller(const unordered_map<stri
|
||||
return unique_ptr<FairMQPoller>(new FairMQPollerZMQ(channelsMap, channelList));
|
||||
}
|
||||
|
||||
FairMQPollerPtr FairMQTransportFactoryZMQ::CreatePoller(const FairMQSocket& cmdSocket, const FairMQSocket& dataSocket) const
|
||||
{
|
||||
return unique_ptr<FairMQPoller>(new FairMQPollerZMQ(cmdSocket, dataSocket));
|
||||
}
|
||||
|
||||
FairMQUnmanagedRegionPtr FairMQTransportFactoryZMQ::CreateUnmanagedRegion(const size_t size, FairMQRegionCallback callback) const
|
||||
{
|
||||
return unique_ptr<FairMQUnmanagedRegion>(new FairMQUnmanagedRegionZMQ(size, callback));
|
||||
|
@@ -44,7 +44,6 @@ class FairMQTransportFactoryZMQ final : public FairMQTransportFactory
|
||||
FairMQPollerPtr CreatePoller(const std::vector<FairMQChannel>& channels) const override;
|
||||
FairMQPollerPtr CreatePoller(const std::vector<const FairMQChannel*>& channels) const override;
|
||||
FairMQPollerPtr CreatePoller(const std::unordered_map<std::string, std::vector<FairMQChannel>>& channelsMap, const std::vector<std::string>& channelList) const override;
|
||||
FairMQPollerPtr CreatePoller(const FairMQSocket& cmdSocket, const FairMQSocket& dataSocket) const override;
|
||||
|
||||
FairMQUnmanagedRegionPtr CreateUnmanagedRegion(const size_t size, FairMQRegionCallback callback) const override;
|
||||
|
||||
|
Reference in New Issue
Block a user