Remove unused code.

- Remove unused code in FairMQTools.
- Remove obsolete device options (now in device config).
This commit is contained in:
Alexey Rybalchenko 2017-03-07 10:52:57 +01:00 committed by Mohammad Al-Turany
parent 2293c5e417
commit b237b3f9d7
4 changed files with 42 additions and 163 deletions

View File

@ -54,11 +54,10 @@ FairMQDevice::FairMQDevice()
, fId() , fId()
, fNetworkInterface() , fNetworkInterface()
, fDefaultTransport() , fDefaultTransport()
, fMaxInitializationAttempts(120) , fInitializationTimeoutInS(120)
, fNumIoThreads(1) , fNumIoThreads(1)
, fPortRangeMin(22000) , fPortRangeMin(22000)
, fPortRangeMax(32000) , fPortRangeMax(32000)
, fLogIntervalInMs(1000)
, fTransportFactory(nullptr) , fTransportFactory(nullptr)
, fTransports() , fTransports()
, fDeviceCmdSockets() , fDeviceCmdSockets()
@ -231,9 +230,9 @@ void FairMQDevice::InitWrapper()
while (!uninitializedConnectingChannels.empty()) while (!uninitializedConnectingChannels.empty())
{ {
AttachChannels(uninitializedConnectingChannels); AttachChannels(uninitializedConnectingChannels);
if (++numAttempts > fMaxInitializationAttempts) if (++numAttempts > fInitializationTimeoutInS)
{ {
LOG(ERROR) << "could not connect all channels after " << fMaxInitializationAttempts << " attempts"; LOG(ERROR) << "could not connect all channels after " << fInitializationTimeoutInS << " attempts";
// TODO: goto ERROR state; // TODO: goto ERROR state;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -764,9 +763,6 @@ void FairMQDevice::SetProperty(const int key, const string& value)
case Id: case Id:
fId = value; fId = value;
break; break;
case NetworkInterface:
fNetworkInterface = value;
break;
default: default:
FairMQConfigurable::SetProperty(key, value); FairMQConfigurable::SetProperty(key, value);
break; break;
@ -781,18 +777,6 @@ void FairMQDevice::SetProperty(const int key, const int value)
case NumIoThreads: case NumIoThreads:
fNumIoThreads = value; fNumIoThreads = value;
break; break;
case MaxInitializationAttempts:
fMaxInitializationAttempts = value;
break;
case PortRangeMin:
fPortRangeMin = value;
break;
case PortRangeMax:
fPortRangeMax = value;
break;
case LogIntervalInMs:
fLogIntervalInMs = value;
break;
default: default:
FairMQConfigurable::SetProperty(key, value); FairMQConfigurable::SetProperty(key, value);
break; break;
@ -806,8 +790,6 @@ string FairMQDevice::GetProperty(const int key, const string& default_ /*= ""*/)
{ {
case Id: case Id:
return fId; return fId;
case NetworkInterface:
return fNetworkInterface;
default: default:
return FairMQConfigurable::GetProperty(key, default_); return FairMQConfigurable::GetProperty(key, default_);
} }
@ -821,16 +803,6 @@ string FairMQDevice::GetPropertyDescription(const int key)
return "Id: Device ID"; return "Id: Device ID";
case NumIoThreads: case NumIoThreads:
return "NumIoThreads: Number of I/O Threads (size of the 0MQ thread pool to handle I/O operations. If your application is using only the inproc transport for messaging you may set this to zero, otherwise set it to at least one.)"; return "NumIoThreads: Number of I/O Threads (size of the 0MQ thread pool to handle I/O operations. If your application is using only the inproc transport for messaging you may set this to zero, otherwise set it to at least one.)";
case MaxInitializationAttempts:
return "MaxInitializationAttempts: Maximum number of validation and initialization attempts of the channels.";
case PortRangeMin:
return "PortRangeMin: Minumum value for the port range (when binding to dynamic port).";
case PortRangeMax:
return "PortRangeMax: Maximum value for the port range (when binding to dynamic port).";
case LogIntervalInMs:
return "LogIntervalInMs: Time between socket rates logging outputs.";
case NetworkInterface:
return "NetworkInterface: Network interface to use for dynamic binding.";
default: default:
return FairMQConfigurable::GetPropertyDescription(key); return FairMQConfigurable::GetPropertyDescription(key);
} }
@ -853,14 +825,6 @@ int FairMQDevice::GetProperty(const int key, const int default_ /*= 0*/)
{ {
case NumIoThreads: case NumIoThreads:
return fNumIoThreads; return fNumIoThreads;
case MaxInitializationAttempts:
return fMaxInitializationAttempts;
case PortRangeMin:
return fPortRangeMin;
case PortRangeMax:
return fPortRangeMax;
case LogIntervalInMs:
return fLogIntervalInMs;
default: default:
return FairMQConfigurable::GetProperty(key, default_); return FairMQConfigurable::GetProperty(key, default_);
} }
@ -969,6 +933,7 @@ void FairMQDevice::SetConfig(FairMQProgOptions& config)
fId = config.GetValue<string>("id"); fId = config.GetValue<string>("id");
fNetworkInterface = config.GetValue<string>("network-interface"); fNetworkInterface = config.GetValue<string>("network-interface");
fNumIoThreads = config.GetValue<int>("io-threads"); fNumIoThreads = config.GetValue<int>("io-threads");
fInitializationTimeoutInS = config.GetValue<int>("initialization-timeout");
} }
void FairMQDevice::LogSocketRates() void FairMQDevice::LogSocketRates()

View File

@ -53,12 +53,7 @@ class FairMQDevice : public FairMQStateMachine, public FairMQConfigurable
enum enum
{ {
Id = FairMQConfigurable::Last, ///< Device ID Id = FairMQConfigurable::Last, ///< Device ID
MaxInitializationAttempts, ///< Timeout for the initialization
NumIoThreads, ///< Number of ZeroMQ I/O threads NumIoThreads, ///< Number of ZeroMQ I/O threads
PortRangeMin, ///< Minimum value for the port range (if dynamic)
PortRangeMax, ///< Maximum value for the port range (if dynamic)
LogIntervalInMs, ///< Interval for logging the socket transfer rates
NetworkInterface, ///< Network interface to use for dynamic binding
Last Last
}; };
@ -393,15 +388,13 @@ class FairMQDevice : public FairMQStateMachine, public FairMQConfigurable
std::string fNetworkInterface; ///< Network interface to use for dynamic binding std::string fNetworkInterface; ///< Network interface to use for dynamic binding
std::string fDefaultTransport; ///< Default transport for the device std::string fDefaultTransport; ///< Default transport for the device
int fMaxInitializationAttempts; ///< Timeout for the initialization int fInitializationTimeoutInS; ///< Timeout for the initialization (in seconds)
int fNumIoThreads; ///< Number of ZeroMQ I/O threads int fNumIoThreads; ///< Number of ZeroMQ I/O threads
int fPortRangeMin; ///< Minimum value for the port range (if dynamic) int fPortRangeMin; ///< Minimum value for the port range (if dynamic)
int fPortRangeMax; ///< Maximum value for the port range (if dynamic) int fPortRangeMax; ///< Maximum value for the port range (if dynamic)
int fLogIntervalInMs; ///< Interval for logging the socket transfer rates
std::shared_ptr<FairMQTransportFactory> fTransportFactory; ///< Transport factory std::shared_ptr<FairMQTransportFactory> fTransportFactory; ///< Transport factory
std::unordered_map<FairMQ::Transport, std::shared_ptr<FairMQTransportFactory>> fTransports; ///< Container for transports std::unordered_map<FairMQ::Transport, std::shared_ptr<FairMQTransportFactory>> fTransports; ///< Container for transports
std::unordered_map<FairMQ::Transport, FairMQSocketPtr> fDeviceCmdSockets; ///< Sockets used for the internal unblocking mechanism std::unordered_map<FairMQ::Transport, FairMQSocketPtr> fDeviceCmdSockets; ///< Sockets used for the internal unblocking mechanism

View File

@ -311,41 +311,50 @@ void FairMQProgOptions::InitOptionDescription()
if (fUseConfigFile) if (fUseConfigFile)
{ {
fMQOptionsInCmd.add_options() fMQOptionsInCmd.add_options()
("id", po::value<string>(), "Device ID (required argument).") ("id", po::value<string>(), "Device ID (required argument).")
("io-threads", po::value<int >()->default_value(1), "Number of I/O threads.") ("io-threads", po::value<int >()->default_value(1), "Number of I/O threads.")
("transport", po::value<string>()->default_value("zeromq"), "Transport ('zeromq'/'nanomsg').") ("transport", po::value<string>()->default_value("zeromq"), "Transport ('zeromq'/'nanomsg').")
("config", po::value<string>()->default_value("static"), "Config source ('static'/<config library filename>).") ("config", po::value<string>()->default_value("static"), "Config source ('static'/<config library filename>).")
("control", po::value<string>()->default_value("interactive"), "States control ('interactive'/'static'/<control library filename>).") ("control", po::value<string>()->default_value("interactive"), "States control ('interactive'/'static'/<control library filename>).")
("network-interface", po::value<string>()->default_value("default"), "Network interface to bind on (e.g. eth0, ib0..., default will try to detect the interface of the default route).") ("network-interface", po::value<string>()->default_value("default"), "Network interface to bind on (e.g. eth0, ib0..., default will try to detect the interface of the default route).")
("config-key", po::value<string>(), "Use provided value instead of device id for fetching the configuration from the config file") ("config-key", po::value<string>(), "Use provided value instead of device id for fetching the configuration from the config file.")
("catch-signals", po::value<int >()->default_value(1), "Enable signal handling (1/0)") ("catch-signals", po::value<int >()->default_value(1), "Enable signal handling (1/0).")
("log-to-file", po::value<string>()->default_value(""), "Log output to a file") ("initialization-timeout", po::value<int >()->default_value(120), "Timeout for the initialization in seconds (when expecting dynamic initialization).")
("port-range-min", po::value<int >()->default_value(22000), "Start of the port range for dynamic initialization.")
("port-range-max", po::value<int >()->default_value(32000), "End of the port range for dynamic initialization.")
("log-to-file", po::value<string>()->default_value(""), "Log output to a file.")
; ;
fMQOptionsInCfg.add_options() fMQOptionsInCfg.add_options()
("id", po::value<string>()->required(), "Device ID (required argument).") ("id", po::value<string>()->required(), "Device ID (required argument).")
("io-threads", po::value<int >()->default_value(1), "Number of I/O threads.") ("io-threads", po::value<int >()->default_value(1), "Number of I/O threads.")
("transport", po::value<string>()->default_value("zeromq"), "Transport ('zeromq'/'nanomsg').") ("transport", po::value<string>()->default_value("zeromq"), "Transport ('zeromq'/'nanomsg').")
("config", po::value<string>()->default_value("static"), "Config source ('static'/<config library filename>).") ("config", po::value<string>()->default_value("static"), "Config source ('static'/<config library filename>).")
("control", po::value<string>()->default_value("interactive"), "States control ('interactive'/'static'/<control library filename>).") ("control", po::value<string>()->default_value("interactive"), "States control ('interactive'/'static'/<control library filename>).")
("network-interface", po::value<string>()->default_value("default"), "Network interface to bind on (e.g. eth0, ib0..., default will try to detect the interface of the default route).") ("network-interface", po::value<string>()->default_value("default"), "Network interface to bind on (e.g. eth0, ib0..., default will try to detect the interface of the default route).")
("config-key", po::value<string>(), "Use provided value instead of device id for fetching the configuration from the config file") ("config-key", po::value<string>(), "Use provided value instead of device id for fetching the configuration from the config file.")
("catch-signals", po::value<int >()->default_value(1), "Enable signal handling (1/0)") ("catch-signals", po::value<int >()->default_value(1), "Enable signal handling (1/0).")
("log-to-file", po::value<string>()->default_value(""), "Log output to a file") ("initialization-timeout", po::value<int >()->default_value(120), "Timeout for the initialization in seconds (when expecting dynamic initialization).")
("port-range-min", po::value<int >()->default_value(22000), "Start of the port range for dynamic initialization.")
("port-range-max", po::value<int >()->default_value(32000), "End of the port range for dynamic initialization.")
("log-to-file", po::value<string>()->default_value(""), "Log output to a file.")
; ;
} }
else else
{ {
fMQOptionsInCmd.add_options() fMQOptionsInCmd.add_options()
("id", po::value<string>()->required(), "Device ID (required argument)") ("id", po::value<string>()->required(), "Device ID (required argument)")
("io-threads", po::value<int >()->default_value(1), "Number of I/O threads") ("io-threads", po::value<int >()->default_value(1), "Number of I/O threads")
("transport", po::value<string>()->default_value("zeromq"), "Transport ('zeromq'/'nanomsg').") ("transport", po::value<string>()->default_value("zeromq"), "Transport ('zeromq'/'nanomsg').")
("config", po::value<string>()->default_value("static"), "Config source ('static'/<config library filename>).") ("config", po::value<string>()->default_value("static"), "Config source ('static'/<config library filename>).")
("control", po::value<string>()->default_value("interactive"), "States control ('interactive'/'static'/<control library filename>).") ("control", po::value<string>()->default_value("interactive"), "States control ('interactive'/'static'/<control library filename>).")
("network-interface", po::value<string>()->default_value("default"), "Network interface to bind on (e.g. eth0, ib0..., default will try to detect the interface of the default route).") ("network-interface", po::value<string>()->default_value("default"), "Network interface to bind on (e.g. eth0, ib0..., default will try to detect the interface of the default route).")
("config-key", po::value<string>(), "Use provided value instead of device id for fetching the configuration from the config file") ("config-key", po::value<string>(), "Use provided value instead of device id for fetching the configuration from the config file.")
("catch-signals", po::value<int >()->default_value(1), "Enable signal handling (1/0)") ("catch-signals", po::value<int >()->default_value(1), "Enable signal handling (1/0).")
("log-to-file", po::value<string>()->default_value(""), "Log output to a file") ("initialization-timeout", po::value<int >()->default_value(120), "Timeout for the initialization in seconds (when expecting dynamic initialization).")
("port-range-min", po::value<int >()->default_value(22000), "Start of the port range for dynamic initialization.")
("port-range-max", po::value<int >()->default_value(32000), "End of the port range for dynamic initialization.")
("log-to-file", po::value<string>()->default_value(""), "Log output to a file.")
; ;
} }

View File

@ -128,95 +128,7 @@ string getDefaultRouteNetworkInterface()
return interfaceName; return interfaceName;
} }
#if defined(__GNUC__) || defined(__GNUG__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#endif
// below are SFINAE template functions to check for function member signatures of class
namespace details
{
// test, at compile time, whether T has BindSendHeader member function with returned type R and argument ...Args type
template<class T, class Sig, class=void>
struct has_BindSendHeader : false_type {};
template<class T, class R, class... Args>
struct has_BindSendHeader
<T, R(Args...), typename enable_if<
is_convertible<decltype(declval<T>().BindSendHeader(declval<Args>()...)), R>::value || is_same<R, void>::value>::type
>:true_type {};
// test, at compile time, whether T has BindGetSocketNumber member function with returned type R and argument ...Args type
template<class T, class Sig, class=void>
struct has_BindGetSocketNumber : false_type {};
template<class T, class R, class... Args>
struct has_BindGetSocketNumber
<T, R(Args...), typename enable_if<
is_convertible<decltype(declval<T>().BindGetSocketNumber(declval<Args>()...)), R>::value || is_same<R, void>::value>::type
>:true_type {};
// test, at compile time, whether T has GetHeader member function with returned type R and argument ...Args type
template<class T, class Sig, class=void>
struct has_GetHeader : false_type {};
template<class T, class R, class... Args>
struct has_GetHeader
<T, R(Args...), typename enable_if<
is_convertible<decltype(declval<T>().GetHeader(declval<Args>()...)), R>::value || is_same<R, void>::value>::type
>:true_type {};
// test, at compile time, whether T has BindGetCurrentIndex member function with returned type R and argument ...Args type
template<class T, class Sig, class=void>
struct has_BindGetCurrentIndex : false_type {};
template<class T, class R, class... Args>
struct has_BindGetCurrentIndex
<T, R(Args...), typename enable_if<
is_convertible<decltype(declval<T>().BindGetCurrentIndex(declval<Args>()...)), R>::value || is_same<R, void>::value>::type
>:true_type {};
} // end namespace details
#if defined(__GNUC__) || defined(__GNUG__)
#pragma GCC diagnostic pop
#endif
// Alias template of the above structs
template<class T, class Sig>
using has_BindSendHeader = integral_constant<bool, details::has_BindSendHeader<T, Sig>::value>;
template<class T, class Sig>
using has_BindGetSocketNumber = integral_constant<bool, details::has_BindGetSocketNumber<T, Sig>::value>;
template<class T, class Sig>
using has_GetHeader = integral_constant<bool, details::has_GetHeader<T, Sig>::value>;
template<class T, class Sig>
using has_BindGetCurrentIndex = integral_constant<bool, details::has_BindGetCurrentIndex<T, Sig>::value>;
// enable_if Alias template
template<typename T>
using enable_if_has_BindSendHeader = typename enable_if<has_BindSendHeader<T, void(int)>::value, int>::type;
template<typename T>
using enable_if_hasNot_BindSendHeader = typename enable_if<!has_BindSendHeader<T, void(int)>::value, int>::type;
template<typename T>
using enable_if_has_BindGetSocketNumber = typename enable_if<has_BindGetSocketNumber<T, int()>::value, int>::type;
template<typename T>
using enable_if_hasNot_BindGetSocketNumber = typename enable_if<!has_BindGetSocketNumber<T, int()>::value, int>::type;
template<typename T>
using enable_if_has_BindGetCurrentIndex = typename enable_if<has_BindGetCurrentIndex<T, int()>::value, int>::type;
template<typename T>
using enable_if_hasNot_BindGetCurrentIndex = typename enable_if<!has_BindGetCurrentIndex<T, int()>::value, int>::type;
template<typename T>
using enable_if_has_GetHeader = typename enable_if<has_GetHeader<T, int()>::value, int>::type;
template<typename T>
using enable_if_hasNot_GetHeader = typename enable_if<!has_GetHeader<T, int()>::value, int>::type;
} // namespace tools } // namespace tools
} // namespace FairMQ } // namespace FairMQ
#endif #endif // FAIRMQTOOLS_H_