From b237b3f9d7d8f703f3f0e441fdeb16d441767dcf Mon Sep 17 00:00:00 2001 From: Alexey Rybalchenko Date: Tue, 7 Mar 2017 10:52:57 +0100 Subject: [PATCH] Remove unused code. - Remove unused code in FairMQTools. - Remove obsolete device options (now in device config). --- fairmq/FairMQDevice.cxx | 43 ++----------- fairmq/FairMQDevice.h | 9 +-- fairmq/options/FairMQProgOptions.cxx | 63 ++++++++++--------- fairmq/tools/FairMQTools.h | 90 +--------------------------- 4 files changed, 42 insertions(+), 163 deletions(-) diff --git a/fairmq/FairMQDevice.cxx b/fairmq/FairMQDevice.cxx index bdb81cab..148578bb 100644 --- a/fairmq/FairMQDevice.cxx +++ b/fairmq/FairMQDevice.cxx @@ -54,11 +54,10 @@ FairMQDevice::FairMQDevice() , fId() , fNetworkInterface() , fDefaultTransport() - , fMaxInitializationAttempts(120) + , fInitializationTimeoutInS(120) , fNumIoThreads(1) , fPortRangeMin(22000) , fPortRangeMax(32000) - , fLogIntervalInMs(1000) , fTransportFactory(nullptr) , fTransports() , fDeviceCmdSockets() @@ -231,9 +230,9 @@ void FairMQDevice::InitWrapper() while (!uninitializedConnectingChannels.empty()) { 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; exit(EXIT_FAILURE); } @@ -764,9 +763,6 @@ void FairMQDevice::SetProperty(const int key, const string& value) case Id: fId = value; break; - case NetworkInterface: - fNetworkInterface = value; - break; default: FairMQConfigurable::SetProperty(key, value); break; @@ -781,18 +777,6 @@ void FairMQDevice::SetProperty(const int key, const int value) case NumIoThreads: fNumIoThreads = value; break; - case MaxInitializationAttempts: - fMaxInitializationAttempts = value; - break; - case PortRangeMin: - fPortRangeMin = value; - break; - case PortRangeMax: - fPortRangeMax = value; - break; - case LogIntervalInMs: - fLogIntervalInMs = value; - break; default: FairMQConfigurable::SetProperty(key, value); break; @@ -806,8 +790,6 @@ string FairMQDevice::GetProperty(const int key, const string& default_ /*= ""*/) { case Id: return fId; - case NetworkInterface: - return fNetworkInterface; default: return FairMQConfigurable::GetProperty(key, default_); } @@ -821,16 +803,6 @@ string FairMQDevice::GetPropertyDescription(const int key) return "Id: Device ID"; 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.)"; - 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: return FairMQConfigurable::GetPropertyDescription(key); } @@ -853,14 +825,6 @@ int FairMQDevice::GetProperty(const int key, const int default_ /*= 0*/) { case NumIoThreads: return fNumIoThreads; - case MaxInitializationAttempts: - return fMaxInitializationAttempts; - case PortRangeMin: - return fPortRangeMin; - case PortRangeMax: - return fPortRangeMax; - case LogIntervalInMs: - return fLogIntervalInMs; default: return FairMQConfigurable::GetProperty(key, default_); } @@ -969,6 +933,7 @@ void FairMQDevice::SetConfig(FairMQProgOptions& config) fId = config.GetValue("id"); fNetworkInterface = config.GetValue("network-interface"); fNumIoThreads = config.GetValue("io-threads"); + fInitializationTimeoutInS = config.GetValue("initialization-timeout"); } void FairMQDevice::LogSocketRates() diff --git a/fairmq/FairMQDevice.h b/fairmq/FairMQDevice.h index 2d35c862..e0c6c30a 100644 --- a/fairmq/FairMQDevice.h +++ b/fairmq/FairMQDevice.h @@ -53,12 +53,7 @@ class FairMQDevice : public FairMQStateMachine, public FairMQConfigurable enum { Id = FairMQConfigurable::Last, ///< Device ID - MaxInitializationAttempts, ///< Timeout for the initialization 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 }; @@ -393,15 +388,13 @@ class FairMQDevice : public FairMQStateMachine, public FairMQConfigurable std::string fNetworkInterface; ///< Network interface to use for dynamic binding 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 fPortRangeMin; ///< Minimum 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 fTransportFactory; ///< Transport factory std::unordered_map> fTransports; ///< Container for transports std::unordered_map fDeviceCmdSockets; ///< Sockets used for the internal unblocking mechanism diff --git a/fairmq/options/FairMQProgOptions.cxx b/fairmq/options/FairMQProgOptions.cxx index fc5ff61b..5e7805e9 100644 --- a/fairmq/options/FairMQProgOptions.cxx +++ b/fairmq/options/FairMQProgOptions.cxx @@ -311,41 +311,50 @@ void FairMQProgOptions::InitOptionDescription() if (fUseConfigFile) { fMQOptionsInCmd.add_options() - ("id", po::value(), "Device ID (required argument).") - ("io-threads", po::value()->default_value(1), "Number of I/O threads.") - ("transport", po::value()->default_value("zeromq"), "Transport ('zeromq'/'nanomsg').") - ("config", po::value()->default_value("static"), "Config source ('static'/).") - ("control", po::value()->default_value("interactive"), "States control ('interactive'/'static'/).") - ("network-interface", po::value()->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(), "Use provided value instead of device id for fetching the configuration from the config file") - ("catch-signals", po::value()->default_value(1), "Enable signal handling (1/0)") - ("log-to-file", po::value()->default_value(""), "Log output to a file") + ("id", po::value(), "Device ID (required argument).") + ("io-threads", po::value()->default_value(1), "Number of I/O threads.") + ("transport", po::value()->default_value("zeromq"), "Transport ('zeromq'/'nanomsg').") + ("config", po::value()->default_value("static"), "Config source ('static'/).") + ("control", po::value()->default_value("interactive"), "States control ('interactive'/'static'/).") + ("network-interface", po::value()->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(), "Use provided value instead of device id for fetching the configuration from the config file.") + ("catch-signals", po::value()->default_value(1), "Enable signal handling (1/0).") + ("initialization-timeout", po::value()->default_value(120), "Timeout for the initialization in seconds (when expecting dynamic initialization).") + ("port-range-min", po::value()->default_value(22000), "Start of the port range for dynamic initialization.") + ("port-range-max", po::value()->default_value(32000), "End of the port range for dynamic initialization.") + ("log-to-file", po::value()->default_value(""), "Log output to a file.") ; fMQOptionsInCfg.add_options() - ("id", po::value()->required(), "Device ID (required argument).") - ("io-threads", po::value()->default_value(1), "Number of I/O threads.") - ("transport", po::value()->default_value("zeromq"), "Transport ('zeromq'/'nanomsg').") - ("config", po::value()->default_value("static"), "Config source ('static'/).") - ("control", po::value()->default_value("interactive"), "States control ('interactive'/'static'/).") - ("network-interface", po::value()->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(), "Use provided value instead of device id for fetching the configuration from the config file") - ("catch-signals", po::value()->default_value(1), "Enable signal handling (1/0)") - ("log-to-file", po::value()->default_value(""), "Log output to a file") + ("id", po::value()->required(), "Device ID (required argument).") + ("io-threads", po::value()->default_value(1), "Number of I/O threads.") + ("transport", po::value()->default_value("zeromq"), "Transport ('zeromq'/'nanomsg').") + ("config", po::value()->default_value("static"), "Config source ('static'/).") + ("control", po::value()->default_value("interactive"), "States control ('interactive'/'static'/).") + ("network-interface", po::value()->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(), "Use provided value instead of device id for fetching the configuration from the config file.") + ("catch-signals", po::value()->default_value(1), "Enable signal handling (1/0).") + ("initialization-timeout", po::value()->default_value(120), "Timeout for the initialization in seconds (when expecting dynamic initialization).") + ("port-range-min", po::value()->default_value(22000), "Start of the port range for dynamic initialization.") + ("port-range-max", po::value()->default_value(32000), "End of the port range for dynamic initialization.") + ("log-to-file", po::value()->default_value(""), "Log output to a file.") ; } else { fMQOptionsInCmd.add_options() - ("id", po::value()->required(), "Device ID (required argument)") - ("io-threads", po::value()->default_value(1), "Number of I/O threads") - ("transport", po::value()->default_value("zeromq"), "Transport ('zeromq'/'nanomsg').") - ("config", po::value()->default_value("static"), "Config source ('static'/).") - ("control", po::value()->default_value("interactive"), "States control ('interactive'/'static'/).") - ("network-interface", po::value()->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(), "Use provided value instead of device id for fetching the configuration from the config file") - ("catch-signals", po::value()->default_value(1), "Enable signal handling (1/0)") - ("log-to-file", po::value()->default_value(""), "Log output to a file") + ("id", po::value()->required(), "Device ID (required argument)") + ("io-threads", po::value()->default_value(1), "Number of I/O threads") + ("transport", po::value()->default_value("zeromq"), "Transport ('zeromq'/'nanomsg').") + ("config", po::value()->default_value("static"), "Config source ('static'/).") + ("control", po::value()->default_value("interactive"), "States control ('interactive'/'static'/).") + ("network-interface", po::value()->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(), "Use provided value instead of device id for fetching the configuration from the config file.") + ("catch-signals", po::value()->default_value(1), "Enable signal handling (1/0).") + ("initialization-timeout", po::value()->default_value(120), "Timeout for the initialization in seconds (when expecting dynamic initialization).") + ("port-range-min", po::value()->default_value(22000), "Start of the port range for dynamic initialization.") + ("port-range-max", po::value()->default_value(32000), "End of the port range for dynamic initialization.") + ("log-to-file", po::value()->default_value(""), "Log output to a file.") ; } diff --git a/fairmq/tools/FairMQTools.h b/fairmq/tools/FairMQTools.h index 8d6ad468..702ca809 100644 --- a/fairmq/tools/FairMQTools.h +++ b/fairmq/tools/FairMQTools.h @@ -128,95 +128,7 @@ string getDefaultRouteNetworkInterface() 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 -struct has_BindSendHeader : false_type {}; - -template -struct has_BindSendHeader - ().BindSendHeader(declval()...)), R>::value || is_same::value>::type - >:true_type {}; - -// test, at compile time, whether T has BindGetSocketNumber member function with returned type R and argument ...Args type -template -struct has_BindGetSocketNumber : false_type {}; - -template -struct has_BindGetSocketNumber - ().BindGetSocketNumber(declval()...)), R>::value || is_same::value>::type - >:true_type {}; - -// test, at compile time, whether T has GetHeader member function with returned type R and argument ...Args type -template -struct has_GetHeader : false_type {}; - -template -struct has_GetHeader - ().GetHeader(declval()...)), R>::value || is_same::value>::type - >:true_type {}; - -// test, at compile time, whether T has BindGetCurrentIndex member function with returned type R and argument ...Args type -template -struct has_BindGetCurrentIndex : false_type {}; - -template -struct has_BindGetCurrentIndex - ().BindGetCurrentIndex(declval()...)), R>::value || is_same::value>::type - >:true_type {}; - - - -} // end namespace details -#if defined(__GNUC__) || defined(__GNUG__) -#pragma GCC diagnostic pop -#endif - -// Alias template of the above structs -template -using has_BindSendHeader = integral_constant::value>; - -template -using has_BindGetSocketNumber = integral_constant::value>; - -template -using has_GetHeader = integral_constant::value>; - -template -using has_BindGetCurrentIndex = integral_constant::value>; - -// enable_if Alias template -template -using enable_if_has_BindSendHeader = typename enable_if::value, int>::type; -template -using enable_if_hasNot_BindSendHeader = typename enable_if::value, int>::type; - -template -using enable_if_has_BindGetSocketNumber = typename enable_if::value, int>::type; -template -using enable_if_hasNot_BindGetSocketNumber = typename enable_if::value, int>::type; - -template -using enable_if_has_BindGetCurrentIndex = typename enable_if::value, int>::type; -template -using enable_if_hasNot_BindGetCurrentIndex = typename enable_if::value, int>::type; - -template -using enable_if_has_GetHeader = typename enable_if::value, int>::type; -template -using enable_if_hasNot_GetHeader = typename enable_if::value, int>::type; - } // namespace tools } // namespace FairMQ -#endif +#endif // FAIRMQTOOLS_H_