diff --git a/.gitattributes b/.gitattributes index b51b76407976d442c6ae9ed06c5f067e3a191309..5726dc2a1c847e9b2e31d2d2656c366cd726c120 100644 --- a/.gitattributes +++ b/.gitattributes @@ -475,20 +475,6 @@ CEP/MS/src/makemsdistr-part -text CEP/MS/test/tcombinevds.in_vds1 -text CEP/MS/test/tcombinevds.in_vds2 -text CEP/MS/test/tmakems.in_antenna.tgz -text svneol=unset#application/x-compressed-tar -CEP/MWCommon/src/rundist -text -CEP/MWCommon/src/rundist-part -text -CEP/MWCommon/src/runlogpid -text -CEP/MWCommon/src/socketrun -text -CEP/MWCommon/src/startdistproc -text -CEP/MWCommon/test/tClusterDesc.in_parset2 -text -CEP/MWCommon/test/tfinddproc.in_cd -text -CEP/MWCommon/test/tfinddproc.in_vd -text -CEP/MWCommon/test/trundist.in_cd -text -CEP/MWCommon/test/trundist.in_vd -text -CEP/MWCommon/test/tstartdproc.in_cd -text -CEP/MWCommon/test/tstartdproc.in_cd1 -text -CEP/MWCommon/test/tstartdproc.in_run -text -CEP/MWCommon/test/tstartdproc.in_vd -text CEP/ParmDB/src/parmdbremote-scr -text CEP/ParmDB/src/setupparmdb -text CEP/ParmDB/src/setupparmdb-part -text diff --git a/.gitignore b/.gitignore index 5d2611f0d07f999c9c03bc8f1d430b80b75818ed..67ff735d21a557966122c67ad49756fa88d7d538 100644 --- a/.gitignore +++ b/.gitignore @@ -25,9 +25,6 @@ CEP/LMWCommon/lofarconf CEP/MS/Makefile.common CEP/MS/autoconf_share CEP/MS/lofarconf -CEP/MWCommon/Makefile.common -CEP/MWCommon/autoconf_share -CEP/MWCommon/lofarconf CEP/ParmDB/Makefile.common CEP/ParmDB/autoconf_share CEP/ParmDB/lofarconf diff --git a/CEP/MWCommon/CMakeLists.txt b/CEP/MWCommon/CMakeLists.txt deleted file mode 100644 index 6936e9af2af3b4f04019a5f9a3762d11849c41aa..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -# $Id$ - -lofar_package(MWCommon 0.1 DEPENDS Common Blob) - -include(LofarFindPackage) -lofar_find_package(Boost REQUIRED) -lofar_find_package(Casacore COMPONENTS casa REQUIRED) - -add_subdirectory(include/MWCommon) -add_subdirectory(src) -add_subdirectory(test) diff --git a/CEP/MWCommon/include/LMWCommon/CMakeLists.txt b/CEP/MWCommon/include/LMWCommon/CMakeLists.txt deleted file mode 100644 index 540b50908002d984f43b31d78419cf249c114e62..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/CMakeLists.txt +++ /dev/null @@ -1,46 +0,0 @@ -# $Id$ - -# List of header files that will be installed. -set(inst_HEADERS - ClusterDesc.h - ControllerBase.h - Controller.h - DomainShape.h - MPIConnection.h - MPIConnectionSet.h - MWBlobIO.h - MWConnection.h - MWConnectionSet.h - MWError.h - MWGlobalStep.h - MWIos.h - MWLocalStep.h - MWMultiStep.h - MWStep.h - MWStepFactory.h - MWStepVisitor.h - MasterControl.h - MemConnection.h - MemConnectionSet.h - NodeDesc.h - ObsDomain.h - ParameterHandler.h - SocketConnection.h - SocketConnectionSet.h - SocketListener.h - VdsDesc.h - VdsPartDesc.h - WorkDomainSpec.h - WorkerControl.h - WorkerFactory.h - WorkerInfo.h - WorkerProxy.h - WorkersDesc.h) - -# Create symbolic link to include directory. -execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_BINARY_DIR}/include/${PACKAGE_NAME}) - -# Install header files. -install(FILES ${inst_HEADERS} DESTINATION include/${PACKAGE_NAME}) diff --git a/CEP/MWCommon/include/LMWCommon/ClusterDesc.h b/CEP/MWCommon/include/LMWCommon/ClusterDesc.h deleted file mode 100644 index a57c06118fd1a5301d3842aed887f2b594303a4c..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/ClusterDesc.h +++ /dev/null @@ -1,124 +0,0 @@ -//# ClusterDesc.h: Description of a cluster and the nodes in it -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ -//# - -#ifndef LOFAR_MWCOMMON_CLUSTERDESC_H -#define LOFAR_MWCOMMON_CLUSTERDESC_H - -// @file -// @brief Description of a cluster and the nodes in it. -// @author Ger van Diepen <diepen AT astron nl> - -//# Includes -#include <MWCommon/NodeDesc.h> -#include <string> -#include <vector> -#include <iosfwd> - -//# Forard Declarations; -namespace LOFAR { - class ParameterSet; -} - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief Description of a cluster and the nodes in it. - - // This class holds the basic description of a cluster. - // It defines which nodes are part of the cluster and which file systems - // each node has access to. - // If a data set is distributed over many file systems, the cluster - // description tells which node can handle a data set part on a particular - // file system. - // - // Currently the information is made persistent in a LOFAR .parset file. - // In the future it needs to use the Centrol Processor Resource Manager. - - class ClusterDesc - { - public: - // Construct an empty object. - ClusterDesc() - {} - - // Construct from the given parameterset. - explicit ClusterDesc (const std::string& parsetName); - - // Set cluster name. - void setName (const std::string& name) - { itsName = name; } - - // Add a node description. - // A node with an already existing name is not added. - // If <src>canExist=false</src>, an exception is thrown if existing. - void addNode (const NodeDesc& node, bool canExist=false); - - // Write it in parset format. - void write (std::ostream& os) const; - - // Get the cluster name. - const std::string& getName() const - { return itsName; } - - // Get a specific node. An exception is thrown if not found. - const NodeDesc& getNode (const std::string& nodeName) const; - - // Get all nodes. - const std::vector<NodeDesc>& getNodes() const - { return itsNodes; } - - // Get the map of file system to node index. - const std::map<std::string, std::vector<int> >& getMap() const - { return itsFS2Nodes; } - - private: - // Fill the object from the given parset file. - void init (const std::string& parsetName); - - // Get the description of a homogeneous cluster. - void getHomCluster (const ParameterSet& parset); - - // Add nodes for a homogeneous cluster. - void addNodes (const ParameterSet& parset, - NodeDesc::NodeType type); - - // Get the description of a heterogeneous cluster. - void getHetCluster (const ParameterSet& parset); - - // Fill the object from the subcluster definitions. - // Use the given directory for relative clusterdesc names. - void getSubClusters (const std::vector<std::string>& parsetNames, - const std::string& defaultDir); - - // Add entries to the mapping of FileSys to Nodes. - void add2Map (int nodeIndex); - - std::string itsName; - std::vector<NodeDesc> itsNodes; - std::map<std::string, int> itsNodeMap; - std::map<std::string, std::vector<int> > itsFS2Nodes; - }; - -}} // end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/Controller.h b/CEP/MWCommon/include/LMWCommon/Controller.h deleted file mode 100644 index d3ad2bbb9e70fa35214cc23eaae4588540dfbfe6..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/Controller.h +++ /dev/null @@ -1,157 +0,0 @@ -//# Controller.h: Class to execute the master and the workers -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_CONTROLLER_H -#define LOFAR_MWCOMMON_CONTROLLER_H - -// @file -// @brief Class to execute the master and the workers -// @author Ger van Diepen (diepen AT astron nl) - -//# Includes -#include <MWCommon/ControllerBase.h> - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief Class to execute the master and the workers - - // This templated class does the execution of the master and the local and - // global workers. A local worker is the worker that operates on the data. - // A global worker is used to combine results from local workers (e.g. - // to do a global solve). - // The class is used by the master as well as the workers. The process rank - // determines if it is used as the master (rank 0) or a worker. - // The <tt>execute</tt> functions does most of the work. A so-called - // Runner object (the template parameter) is used to do application - // specific operations. - // The <tt>execute</tt> function operates in several stages: - // <ol> - // <li> It uses the Runner object to ask for the data set to process. - // Such a data set is a description file (handled by VdsDesc) telling - // the number of data set parts and where each part resides. - // <li> The connections between master and workers are set up. It will use - // MPI if compiled in and required. Otherwise it can use sockets. - // If there is only one process, everything will run in that single - // process and memory connections will be used. This is particularly - // useful for debugging. - // It is checked if there is a local worker for each data set part. - // <li> The processes will start executing. The workers wait for messages - // and act upon it. A message contains a type (see MasterControl) and - // usually an MWStep object. That object tells the worker what to do. - // A factory (WorkerFactory) is used to create the correct MWStep object. - // In this way the framework is very general and any step can be used. - // <br>The master will do the following: - // <ol> - // <li> Obtain the domain of the data set and send it with the - // ParameterSet obtained from the Runner to the workers to let - // them initialise themselves. - // <li> Ask all workers what kind of work they can perform. - // <li> Ask the Runner to do the application-specific work. This is - // done by calling the appropriate functions in MasterControl. - // They will send commands to the workers and act upon their replies. - // <li> After the Runner has finished, it quits MasterControl which - // sends quit messages to the workers. - // </ol> - // </ol> - - // <example> - // Here follows an example of a Runner class taken from the test - // program tMWControl. It shows the functions which have to be - // defined in the class. Also the copy constructor must be available - // (in this example it is implemented by the compiler). - // <srcblock> - // class Runner - // { - // public: - // explicit Runner (const string& parsetName) - // : itsParams (ParameterSet(parsetName)) - // { - // // Define the functions creating the proxy workers. - // // The names localWorker and globalWorker are mandatory. - // itsFactory.push_back ("LocalWorker", PredifferTest::create); - // itsFactory.push_back ("GlobalWorker", SolverTest::create); - // } - // - // string getDataSetName() const - // { return itsParams.getDataSetName(); } - // - // const WorkerFactory& getFactory() const - // { return itsFactory; } - // - // ParameterSet getParSet() const - // { return itsParams; } - // - // void run (MasterControl& mc) - // { - // // Assemble all steps defined in the parameters into a single spec. - // vector<MWStrategySpec> strategySpecs = itsParams.getStrategies(); - // // Loop through all strategies. - // for (vector<MWStrategySpec>::const_iterator iter=strategySpecs.begin(); - // iter!=strategySpecs.end(); - // ++iter) { - // mc.setWorkDomainSpec (iter->getWorkDomainSpec()); - // // Execute the steps. - // mc.processSteps (iter->getSteps()); - // } - // } - // - // private: - // MWParameterHandler itsParams; - // WorkerFactory itsFactory; - // }; - // </srcblock> - // </example> - - template<typename Runner> - class Controller : public ControllerBase - { - public: - // Construct the controller to process the given (distributed) data set - // on the given cluster (using its cluster description name). - // Standard output is logged in the given log file. - Controller (const Runner& runner, - const string& clusterName, - const string& logFileName) - : ControllerBase (runner.getFactory(), - runner.getParSet(), - runner.getDataSetName(), - clusterName, - logFileName), - itsRunner (runner) - {} - - virtual ~Controller() - {} - - // Let the Runner run. - virtual void run (MasterControl& mc) - { itsRunner.run (mc); } - - private: - //# Data members - Runner itsRunner; - }; - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/ControllerBase.h b/CEP/MWCommon/include/LMWCommon/ControllerBase.h deleted file mode 100644 index e80849a30d39007347b5073bfdfcb133df5b62d2..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/ControllerBase.h +++ /dev/null @@ -1,112 +0,0 @@ -//# ControllerBase.h: Base class to execute the master and the workers -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_CONTROLLERBASE_H -#define LOFAR_MWCOMMON_CONTROLLERBASE_H - -// @file Base class to execute the master and the workers -// @brief -// @author Ger van Diepen (diepen AT astron nl) - -//# Includes -#include <MWCommon/MWConnectionSet.h> -#include <MWCommon/WorkerFactory.h> -#include <MWCommon/MasterControl.h> -#include <MWCommon/VdsDesc.h> -#include <MWCommon/MWIos.h> - -namespace LOFAR { namespace CEP { - - //# Forward Declarations. - class VdsDesc; - - // @ingroup MWCommon - // @brief Base class to execute the master and the workers - - // This non-templated class factors out all non-templated code of - // the Controller class. - - class ControllerBase - { - public: - // Construct the controller to process the given (distributed) data set - // on the given cluster (using its cluster description name). - // Standard output is logged in the given log file. - ControllerBase (const WorkerFactory&, - const ParameterSet&, - const string& dsDescName, - const string& clusterDescName, - const string& logFileName); - - virtual ~ControllerBase(); - - // Execute the run using sockets or a single process. - // If the host or port name is empty, a single process is used. - // If sockets are used, it is assumed that <tt>nproc</tt> identical - // processes (including master) have been started. Each process should - // have a unique rank, where rank 0 will be the master. - // <br>It returns a non-zero value on failure. - int execute (const string& host, const string& port, - int nproc, int rank); - - // Execute the run using MPI or a single process. - // <br>It returns a non-zero value on failure. - int execute(); - - private: - // Let the Runner in the derived class run. - virtual void run (MasterControl&) = 0; - - // Do the execute using MPI, sockets, or single process. - int doExecute (const string& host, const string& port, - int nrNode, int rank, bool useMPI); - - // Run the master process. - void runMaster (const string& port, - int globalWorkerRank, - int nworkers, int nparts); - - // Run a local worker. - void runLocalWorker (const string& host, const string& port); - - // Run a global worker. - void runGlobalWorker (const string& host, const string& port); - - // Setup all the workers. - // Find out what they can do, i.e. if they work locally or globally. - // It returns a vector telling which data part is handled by local worker i. - std::vector<std::string> setAllWorkers (MWConnectionSet& workers, - int nworkers); - - //# Data members - WorkerFactory itsFactory; - ParameterSet itsParSet; - VdsDesc itsDsDesc; - std::string itsClusterName; - std::string itsLogName; - MWConnectionSet::ShPtr itsLocalWorkers; - MWConnectionSet::ShPtr itsGlobalWorkers; - }; - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/DomainShape.h b/CEP/MWCommon/include/LMWCommon/DomainShape.h deleted file mode 100644 index 957437db407ac08455c65c06c67fd81f03a35a9d..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/DomainShape.h +++ /dev/null @@ -1,81 +0,0 @@ -//# DomainShape.h: Define the shape of a domain -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_DOMAINSHAPE_H -#define LOFAR_MWCOMMON_DOMAINSHAPE_H - -// @file -// @brief Define the shape of a domain. -// @author Ger van Diepen (diepen AT astron nl) - -#include <Blob/BlobOStream.h> -#include <Blob/BlobIStream.h> -#include <iosfwd> - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief Define the shape of a domain. - - // This class defines the shape of a domain. - // Currently this can only be done for time and frequency. - // - // This object can be used by ObsDomain to iterate over its observation - // domain in chunk of this domain shape. - - class DomainShape - { - public: - // Set default shape to all frequencies and times. - DomainShape(); - - // Set from frequency in Hz and time in sec. - DomainShape (double freqSize, double timeSize); - - // Get the shape. - // @{ - double getFreqSize() const - { return itsFreqSize; } - double getTimeSize() const - { return itsTimeSize; } - // @} - - // Convert to/from blob. - // @{ - friend LOFAR::BlobOStream& operator<< (LOFAR::BlobOStream&, - const DomainShape&); - friend LOFAR::BlobIStream& operator>> (LOFAR::BlobIStream&, - DomainShape&); - // @} - - // Print. - friend std::ostream& operator<< (std::ostream&, - const DomainShape&); - - private: - double itsFreqSize; - double itsTimeSize; - }; - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/MPIConnection.h b/CEP/MWCommon/include/LMWCommon/MPIConnection.h deleted file mode 100644 index 31a4d65741d1f195176632b6734e1de563c972d9..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/MPIConnection.h +++ /dev/null @@ -1,95 +0,0 @@ -//# MPIConnection.h: Connection to workers based on MPI -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_MPICONNECTION_H -#define LOFAR_MWCOMMON_MPICONNECTION_H - -// @file -// @brief Connection to workers based on MPI. -// @author Ger van Diepen (diepen AT astron nl) - -#include <MWCommon/MWConnection.h> -#include <boost/shared_ptr.hpp> - - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief Connection to workers based on MPI. - - // This class handles the MPI connection between two processes by - // giving it the correct MPI rank of the other (destination) process. - // - // The length of a message to receive is determined using \a MPI_Probe. - // - // It has some static methods to do the basic MPI handling - // (init, finalize, get nrnodes, get rank). - // - // This class requires compile variable HAVE_MPI to be set in order to - // use MPI. If not set, it will compile fine, but cannot really be used. - // Only the static functions can be used which will nothing and return - // a default value. - - class MPIConnection: public MWConnection - { - public: - // Define a shared pointer to this object. - typedef boost::shared_ptr<MPIConnection> ShPtr; - - // Set up a connection to the given destination. - // The tag can be used to define the type of destination - // (e.g. prediffer or solver). - MPIConnection (int destinationRank, int tag); - - virtual ~MPIConnection(); - - // Check the state of the connection. Default is true. - virtual bool isConnected() const; - - // Get the length of the message. - virtual int getMessageLength(); - - // Receive the data sent by the destination - // and wait until data has been received into buf. - virtual void receive (void* buf, unsigned size); - - // Send the data to the destination - // and wait until the data has been sent. - virtual void send (const void* buf, unsigned size); - - // Functions to access MPI. - // If no MPI available, getRank returns 0 and getNrNodes returns 1. - // @{ - static void initMPI (int argc, const char**& argv); - static void endMPI(); - static int getRank(); - static int getNrNodes(); - // @} - - private: - int itsDestRank; - int itsTag; - }; - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/MPIConnectionSet.h b/CEP/MWCommon/include/LMWCommon/MPIConnectionSet.h deleted file mode 100644 index 5e741c988a31c86ff38317eb7051248b7b266a6c..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/MPIConnectionSet.h +++ /dev/null @@ -1,95 +0,0 @@ -//# MPIConnectionSet.h: Class to hold a set of MPI connections -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_MPICONNECTIONSET_H -#define LOFAR_MWCOMMON_MPICONNECTIONSET_H - -// @file -// @brief Class to hold a set of MPI connections. -// @author Ger van Diepen (diepen AT astron nl) - -#include <MWCommon/MWConnectionSet.h> -#include <MWCommon/MPIConnection.h> -#include <vector> - - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief Class to hold a set of MPI connections. - - // This class represents a set of MPI connections. Typically it is used - // to group connections to workers of a specific type. - // The main reason for having this class is the ability to check if any - // connection in the group is ready to receive data (i.e. if the other - // side of the connection has sent data). This is done using MPI_Probe - // with the tag of the first connection, so all connections in the group - // should have the same (and unique) tag. - // - // @todo Implement getReadyConnection. - - class MPIConnectionSet: public MWConnectionSet - { - public: - // Define a shared pointer to this object. - typedef boost::shared_ptr<MPIConnectionSet> ShPtr; - - // Set up a connection set to destinations using MPI. - MPIConnectionSet(); - - virtual ~MPIConnectionSet(); - - // Clone the derived object to contain only the connections - // as indexed in the given vector. - virtual MWConnectionSet::ShPtr clone(const std::vector<int>&) const; - - // Add a connection to the given rank using the tag. - // The tag can be used to define the type of destination - // (e.g. prediffer or solver). - // It returns the sequence nr of the connection. - int addConnection (int rank, int tag); - - // Get the number of connections. - virtual int size() const; - - // Get seqnr of connection that is ready to receive. - // <0 means no connection ready yet. - virtual int getReadyConnection(); - - // Read the data into the BlobString buffer using the connection - // with the given sequence nr. - virtual void read (int seqnr, LOFAR::BlobString&); - - // Write the data from the BlobString buffer using the connection - // with the given sequence nr. - virtual void write (int seqnr, const LOFAR::BlobString&); - - // Write the data from the BlobString buffer to all connections. - virtual void writeAll (const LOFAR::BlobString&); - - private: - std::vector<MPIConnection::ShPtr> itsConns; - }; - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/MWBlobIO.h b/CEP/MWCommon/include/LMWCommon/MWBlobIO.h deleted file mode 100644 index d81e60439fa064fa3b8d150d6bad945b132fc4e6..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/MWBlobIO.h +++ /dev/null @@ -1,151 +0,0 @@ -//# MWBlobIO.h: Class to convert a message from a blob -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_MWBLOBIO_H -#define LOFAR_MWCOMMON_MWBLOBIO_H - -// @file -// @brief Classes to convert a message to/from a blob. -// @author Ger van Diepen (diepen AT astron nl) - -#include <Blob/BlobString.h> -#include <Blob/BlobOBufString.h> -#include <Blob/BlobIBufString.h> -#include <Blob/BlobOStream.h> -#include <Blob/BlobIStream.h> -#include <casa/OS/Timer.h> -#include <Common/Timer.h> - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief Class to convert a message from a blob. - - // This class is the opposite of MWBlobOut. - // It can be used to obtain operation and streamId and to read the message. - - class MWBlobIn - { - public: - // Start reading back a message from the buffer. It reads the operation - // and streamId which can be obtained using their \a get functions. - // The message itself can be read from the \a blobStream(). - explicit MWBlobIn (const LOFAR::BlobString& buf); - - // Get the operation, streamId, or workerId. - // @{ - int getOperation() const - { return itsOper; } - int getStreamId() const - { return itsStreamId; } - int getWorkerId() const - { return itsWorkerId; } - // @} - - // Get the timings which can be the low-precision elapsed, system, - // and user time, and the high-precision elapsed time. - // All times are in seconds. - // @{ - float getElapsedTime() const; - float getSystemTime() const; - float getUserTime() const; - double getPrecTime() const; - // @} - - // Get the blobstream to read the data from. - LOFAR::BlobIStream& blobStream() - { return itsStream; } - - // End the Blob processing. - void finish() - { itsStream.getEnd(); } - - private: - LOFAR::BlobIBufString itsBuf; - LOFAR::BlobIStream itsStream; - LOFAR::int32 itsOper; - LOFAR::int32 itsStreamId; - LOFAR::int32 itsWorkerId; - float itsElapsedTime; - float itsSystemTime; - float itsUserTime; - double itsPrecTime; - }; - - - // @ingroup mwcommon - // @brief Class to convert a message to a blob. - - // This class forms the envelope of messages used in the MW framework. - // MW messages are transmitted as blobs. - // The envelope consist of the basic blob header with type 'mw'. The - // blob header defines things like endianness, version, and length. - // The envelope also contains the operation type and streamId. - // The operation type tells the worker what is has to do. - // The streamId is for future use to make it possible to have parallel - // work streams in a worker to keep it busy. - // The workerId gives the id of the worker. - // - // The envelope has room for timings. In this way the master can know - // how much time it took for a worker to execute a command. - // The \a setTimes function can be used to set the timings. It uses - // the casa Timer class to get the low-precision elapsed, user, and system - // times. The LOFAR NSTimer class is used for high-precision elapsed time. - // - // The message proper has to be written by the user of this class - // into the supplied \a blobStream. - // After all data are written, the \a finish function has to be called. - - class MWBlobOut - { - public: - // Start a message blob in the buffer and put the given operation, - // streamId, and workerId into it. - // The message itself can be put into the \a blobStream(). - MWBlobOut (LOFAR::BlobString& buf, - int operation, int streamId, int workerId=-1); - - // Reset the operation. - void setOperation (int operation); - - // Set the times it took to do the operation. - void setTimes (const casa::Timer&, const LOFAR::NSTimer&); - - // Get the blobstream to write the data in. - LOFAR::BlobOStream& blobStream() - { return itsStream; } - - // End the Blob processing. - void finish() - { itsStream.putEnd(); } - - private: - LOFAR::BlobOBufString itsBuf; - LOFAR::BlobOStream itsStream; - //# Remember where to put operation or times. - int itsOperOffset; - int itsTimeOffset; - }; - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/MWConnection.h b/CEP/MWCommon/include/LMWCommon/MWConnection.h deleted file mode 100644 index 83ed801e05eefa84148903bf27e1e44a6f35fd59..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/MWConnection.h +++ /dev/null @@ -1,116 +0,0 @@ -//# MWConnection.h: Abstract base class for all MWConnections -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_MWCONNECTION_H -#define LOFAR_MWCOMMON_MWCONNECTION_H - -// @file -// @brief Abstract base class for all MWConnections. -// @author Ger van Diepen (diepen AT astron nl) - -#include <boost/shared_ptr.hpp> - -//# Forward Declarations -namespace LOFAR { - class BlobString; -} - - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief Abstract base class for all MWConnections. - - // This class defines the base class for classes to transport data. - // Actually, the data transport is done between two MWConnection objects - // of the same type. - // - // The data are packed in LOFAR Blob objects to support heterogeneous - // machines (with different endianness). It also makes it possible to - // version the data to make future upgrades possible. Finally as blob - // contains a length making it easily possible to support varying length - // messages. - // - // To support varying length messages for both socket and MPI connections, - // the length can be determined first. If found, the message length is - // known. Otherwise the blob header is read to find the message length. - // This is needed because in MPI a message has to be read in one receive, - // while sockets have no direct means to determine the message length. - // - // Derived classes (e.g. MPIConnection) implement the concrete transport - // classes. - - class MWConnection - { - public: - // Define a shared pointer to this object. - typedef boost::shared_ptr<MWConnection> ShPtr; - - MWConnection() - {} - - virtual ~MWConnection(); - - // Initialize the Transport; this may for instance open a file, - // port or dbms connection. - // Default does nothing. - virtual void init(); - - // Check the state of this MWConnection. Default is true. - virtual bool isConnected() const; - - // Receive the data blob sent by the connected MWConnection - // and wait until data has been received into \a buf. - // The buffer is resized as needed. - // By default it uses the functions \a getMessageLength and \a receive - // to determine the length of the message and to receive the data. - virtual void read (LOFAR::BlobString& buf); - - // Send the data to the connected MWConnection - // and wait until the data has been sent. - // By default is uses function \a send to send the data. - virtual void write (const LOFAR::BlobString& buf); - - private: - // Cannot make a copy of this object (thus also of derived classes). - // @{ - MWConnection (const MWConnection&); - MWConnection& operator=(const MWConnection&); - // @} - - // Try to get the length of the message. - // -1 is returned if it could not determine it. - // In such a case the length needs to be read from the blob header. - virtual int getMessageLength() = 0; - - // Receive the given amount of data in the buffer. - // and wait until data has been received into buf. - virtual void receive (void* buf, unsigned size) = 0; - - // Send the fixed sized data to the connected MWConnection - // and wait until the data has been sent. - virtual void send (const void* buf, unsigned size) = 0; - }; - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/MWConnectionSet.h b/CEP/MWCommon/include/LMWCommon/MWConnectionSet.h deleted file mode 100644 index d1a8b5089c41679bad2ba7c4b160e191abc59ea5..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/MWConnectionSet.h +++ /dev/null @@ -1,88 +0,0 @@ -//# MWConnectionSet.h: Abstract base class for all MWConnectionSets -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_MWCONNECTIONSET_H -#define LOFAR_MWCOMMON_MWCONNECTIONSET_H - -// @file -// @brief Abstract base class for all MWConnectionSets. -// @author Ger van Diepen (diepen AT astron nl) - -#include <Blob/BlobString.h> -#include <boost/shared_ptr.hpp> -#include <vector> - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief Abstract base class for all MWConnectionSets. - - // This class defines the abstract base class for all MWConnectionSet - // classes. - // The object can be cloned, where it is possible to only use the - // given connections. In this way connections can be regrouped asd needed. - // Note that a cloned object uses the same MWConnection objects as - // the original. - // - // See class MWConnection for a description of connections. - - class MWConnectionSet - { - public: - // Define a shared pointer to this object. - typedef boost::shared_ptr<MWConnectionSet> ShPtr; - - MWConnectionSet() - {} - - virtual ~MWConnectionSet(); - - // Clone the derived object, optionally to contain only the connections - // as indexed in the given vector. - // It uses the same connections as the original. - // @{ - MWConnectionSet::ShPtr clone() const; - virtual MWConnectionSet::ShPtr clone(const std::vector<int>&) const = 0; - // @} - - // Get the number of connections. - virtual int size() const = 0; - - // Get seqnr of connection that is ready to receive. - // <0 means no connection ready yet. - virtual int getReadyConnection() = 0; - - // Read the data into the BlobString buffer using the connection - // with the given sequence nr. - virtual void read (int seqnr, LOFAR::BlobString&) = 0; - - // Write the data from the BlobString buffer using the connection - // with the given sequence nr. - virtual void write (int seqnr, const LOFAR::BlobString&) = 0; - - // Write the data from the BlobString buffer to all connections. - virtual void writeAll (const LOFAR::BlobString&) = 0; - }; - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/MWError.h b/CEP/MWCommon/include/LMWCommon/MWError.h deleted file mode 100644 index ba977288d690c8f3cd1870e104198c11096fc0d7..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/MWError.h +++ /dev/null @@ -1,44 +0,0 @@ -//# MWError.h: Basic exception for master/worker related errors -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_MWERROR_H -#define LOFAR_MWCOMMON_MWERROR_H - -// @file -// @brief Basic exception for master/worker related errors. -// @author Ger van Diepen (diepen AT astron nl) - -#include <Common/Exception.h> - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief Basic exception for master/worker related errors. - - // This class defines the basic MW exception. - // Only this basic exception is defined so far. In the future, some more - // fine-grained exceptions might be derived from it. - EXCEPTION_CLASS(MWError, LOFAR::Exception); - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/MWGlobalStep.h b/CEP/MWCommon/include/LMWCommon/MWGlobalStep.h deleted file mode 100644 index c49c35a2d15f4bff7d85cfd2d0eb08441d28cf63..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/MWGlobalStep.h +++ /dev/null @@ -1,58 +0,0 @@ -//# MWGlobalStep.h: Base classes for global MW commands (like subtract) -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_MWGLOBALSTEP_H -#define LOFAR_MWCOMMON_MWGLOBALSTEP_H - -// @file -// @brief Base classes for global MW commands (like subtract) -// @author Ger van Diepen (diepen AT astron nl) - -#include <MWCommon/MWStep.h> - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief Base class for a step to process a global MW command. - - // This class defines a class that serves as the base class for a - // global MW step. A global MW step is a step that cannot be executed - // directly by a worker without the need of interaction between workers. - - class MWGlobalStep: public MWStep - { - public: - MWGlobalStep() - {} - - virtual ~MWGlobalStep(); - - // Visit the object, so the visitor can process it. - // The default implementation uses the MWStepVisitor::visitGlobal - // function. - virtual void visit (MWStepVisitor&) const; - }; - - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/MWIos.h b/CEP/MWCommon/include/LMWCommon/MWIos.h deleted file mode 100644 index 4337595f27bfb8bccaffa8b52326f896eb996f70..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/MWIos.h +++ /dev/null @@ -1,97 +0,0 @@ -//# MWIos.h: IO stream to a unique file -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Foundation for Research in Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl -//# -//# This program is free software; you can redistribute it and/or modify -//# it under the terms of the GNU General Public License as published by -//# the Free Software Foundation; either version 2 of the License, or -//# (at your option) any later version. -//# -//# This program is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License -//# along with this program; if not, write to the Free Software -//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -//# -//# MWIos.h: -//# -//# Copyright (C) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_MWIOSTREAM_H -#define LOFAR_MWCOMMON_MWIOSTREAM_H - -// @file -// @brief IO stream to a unique file -// @author Ger van Diepen (diepen AT astron nl) - -#include <iostream> -#include <fstream> -#include <string> - -#define MWCOUT MWIos::os() - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief IO stream to a unique file - - // MPI has the problem that the output of cout is unpredictable. - // Therefore the output of tMWControl is using a separate output - // file for each rank. - // This class makes this possible. The alias MWCOUT can be used for it. - // - // Note that everything is static, so no destructor is called. - // The clear function can be called at the end of the program to - // delete the internal object, otherwise tools like valgrind will - // complain about a memory leak. - - class MWIos - { - public: - // Define the name of the output file. - static void setName (const std::string& name) - { itsName = name; } - - // Get access to its ostream. - // It creates the ostream if not done yet. - static std::ofstream& os() - { if (!itsIos) makeIos(); return *itsIos; } - - // Remove the ostream (otherwise there'll be a memory leak). - static void clear() - { delete itsIos; } - - private: - // Make the ostream if not done yet. - static void makeIos(); - - static std::string itsName; - static std::ofstream* itsIos; - }; - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/MWLocalStep.h b/CEP/MWCommon/include/LMWCommon/MWLocalStep.h deleted file mode 100644 index 6fa24c885ceaf57432ae5ac19a63335ea1319ba2..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/MWLocalStep.h +++ /dev/null @@ -1,60 +0,0 @@ -//# MWLocalStep.h: Base class for a step to process a local MW command -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_MWLOCALSTEP_H -#define LOFAR_MWCOMMON_MWLOCALSTEP_H - -// @file -// @brief Base classes for local MW commands -// @author Ger van Diepen (diepen AT astron nl) - -#include <MWCommon/MWStep.h> - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief Base class for a step to process a local MW command. - - // This class defines a class that serves as the base class for a - // local MW step. A local MW step is a step that can be executed - // directly by a worker without the need of interaction between workers. - // An example is a subtract or correct. A solve is not a local step, - // because it requires interaction between workers. - - class MWLocalStep: public MWStep - { - public: - MWLocalStep() - {} - - virtual ~MWLocalStep(); - - // Visit the object, so the visitor can process it. - // The default implementation uses the MWStepVisitor::visitlocal - // function. - virtual void visit (MWStepVisitor&) const; - }; - - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/MWMultiStep.h b/CEP/MWCommon/include/LMWCommon/MWMultiStep.h deleted file mode 100644 index 76df439b2b42d9edff9fff18d1d6db7041a09e2b..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/MWMultiStep.h +++ /dev/null @@ -1,98 +0,0 @@ -//# MWMultiStep.h: A step consisting of several other steps -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_MWMULTISTEP_H -#define LOFAR_MWCOMMON_MWMULTISTEP_H - -// @file -// @brief A step consisting of several other steps. -// @author Ger van Diepen (diepen AT astron nl) - -#include <MWCommon/MWStep.h> -#include <list> - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief A step consisting of several other steps. - - // This class makes it possible to form a list of MWStep objects. - // Note that the class itself is an MWStep, so the list can be nested. - // The \a visit function will call \a visit of each step in the list. - // - // It uses the standard MWStep functionality (factory and visitor) to - // create and process the object. - // The object can be converted to/from blob, so it can be sent to workers. - - class MWMultiStep: public MWStep - { - public: - virtual ~MWMultiStep(); - - // Clone the step object. - virtual MWMultiStep* clone() const; - - // Create a new object of this type. - static MWStep::ShPtr create(); - - // Register the create function in the MWStepFactory. - static void registerCreate(); - - // Add a clone of a step object. - void push_back (const MWStep&); - - // Add a step object. - void push_back (const MWStep::ShPtr&); - - // Give the (unique) class name of the MWStep. - virtual std::string className() const; - - // Visit the object, which visits each step. - virtual void visit (MWStepVisitor&) const; - - // Convert to/from blob. - // Note that reading back from a blob uses MWStepFactory to - // create the correct objects. - // @{ - virtual void toBlob (LOFAR::BlobOStream&) const; - virtual void fromBlob (LOFAR::BlobIStream&); - // @} - - // Print the contents and type. Indent as needed. - virtual void print (std::ostream& os, const std::string& indent) const; - - // Define functions and so to iterate in the STL way. - // @{ - typedef std::list<MWStep::ShPtr>::const_iterator const_iterator; - const_iterator begin() const - { return itsSteps.begin(); } - const_iterator end() const - { return itsSteps.end(); } - // @} - - private: - std::list<MWStep::ShPtr> itsSteps; - }; - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/MWStep.h b/CEP/MWCommon/include/LMWCommon/MWStep.h deleted file mode 100644 index 6455bb20b9d0cd4d65da441ae8b9f8645630eed0..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/MWStep.h +++ /dev/null @@ -1,103 +0,0 @@ -//# MWStep.h: Abstract base class for steps to process MW commands -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_MWSTEP_H -#define LOFAR_MWCOMMON_MWSTEP_H - -// @file -// @brief Abstract base class for steps to process MW commands. -// @author Ger van Diepen (diepen AT astron nl) - -#include <MWCommon/MWStepVisitor.h> -#include <MWCommon/ParameterHandler.h> -#include <Blob/BlobOStream.h> -#include <Blob/BlobIStream.h> -#include <boost/shared_ptr.hpp> - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief Abstract base class for steps to process MW commands. - - // This class is the abstract base class for all possible steps that - // can be executed in the Master-Control framework. - // A step must be able to store and retrieve itself into/from a blob. - // - // The \a visit function uses the visitor pattern to get access to - // a concrete MWStep object, for example to execute the step. - // It means that a function needs to be added to the visitor classes - // for each newly derived MWStep class. - // - // The MWStepFactory class is a class containing a map of type name to - // a \a create function that can create an MWStep object of the required - // type. At the beginning of a program the required create functions have - // to be registered in the factory. Note that the user can choose which - // create function maps to a given name, which makes it possible to - // use different implementations of similar functionality. - - class MWStep - { - public: - // Define a shared pointer to this object. - typedef boost::shared_ptr<MWStep> ShPtr; - - virtual ~MWStep(); - - // Clone the step object. - virtual MWStep* clone() const = 0; - - // Give the (unique) class name of the MWStep. - virtual std::string className() const = 0; - - // Get the parameter set. - // The default implementation returns an empty set. - virtual ParameterSet getParms() const; - - // Visit the object, so the visitor can process it. - // The default implementation uses the MWStepVisitor::visit function. - virtual void visit (MWStepVisitor&) const; - - // Print the contents and type. Indent as needed. - // The default implementation does nothing. - virtual void print (std::ostream& os, const std::string& indent) const; - - // Convert to/from blob. - // @{ - virtual void toBlob (LOFAR::BlobOStream&) const = 0; - virtual void fromBlob (LOFAR::BlobIStream&) = 0; - // @} - - // Convert to/from blob. - // @{ - friend LOFAR::BlobOStream& operator<< (LOFAR::BlobOStream& bs, - const MWStep& step) - { step.toBlob(bs); return bs; } - friend LOFAR::BlobIStream& operator>> (LOFAR::BlobIStream& bs, - MWStep& step) - { step.fromBlob(bs); return bs; } - // @} - }; - - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/MWStepFactory.h b/CEP/MWCommon/include/LMWCommon/MWStepFactory.h deleted file mode 100644 index 4f752e74e03f8b97353493541cffb76a379b2302..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/MWStepFactory.h +++ /dev/null @@ -1,65 +0,0 @@ -//# MWStepFactory.h: Factory pattern to make the correct MWStep object -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_MWSTEPFACTORY_H -#define LOFAR_MWCOMMON_MWSTEPFACTORY_H - -// @file -// @brief Factory pattern to make the correct MWStep object -// @author Ger van Diepen (diepen AT astron nl) - -#include <MWCommon/MWStep.h> -#include <map> - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief Factory pattern to make the correct MWStep object - - // This class contains a map of names to \a create functions - // of derived MWStep objects. It is used to reconstruct the correct - // MWStep object when reading it back from a blob. - // - // The map is static, so there is only one instance in a program. - // Usually the functions will be registered at the beginning of a program. - - class MWStepFactory - { - public: - // Define the signature of the function to create an MWStep object. - typedef MWStep::ShPtr Creator(); - - // Add a creator function. - static void push_back (const std::string& name, Creator*); - - // Create the derived MWStep object with the given name. - // An exception is thrown if the name is not in the map. - static MWStep::ShPtr create (const std::string& name); - - private: - static std::map<std::string, Creator*> itsMap; - }; - - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/MWStepVisitor.h b/CEP/MWCommon/include/LMWCommon/MWStepVisitor.h deleted file mode 100644 index a9e7b3fc3fb4640deaf9fcdab366c6ae93ef33ec..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/MWStepVisitor.h +++ /dev/null @@ -1,102 +0,0 @@ -//# MWStepVisitor.h: Base visitor class to visit an MWStep hierarchy -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_MWSTEPVISITOR_H -#define LOFAR_MWCOMMON_MWSTEPVISITOR_H - -// @file -// @brief Base visitor class to visit an MWStep hierarchy. -// @author Ger van Diepen (diepen AT astron nl) - -#include <boost/shared_ptr.hpp> -#include <string> -#include <map> - -namespace LOFAR { namespace CEP { - - //# Forward Declarations - class MWStep; - class MWMultiStep; - class MWGlobalStep; - class MWLocalStep; - - - // @ingroup MWCommon - // @brief Base visitor class to visit an MWStep hierarchy. - - // This is a class to traverse a MWStep composite using the visitor - // pattern (see Design Patterns, Gamma et al, 1995). - // It is the base class for all visitor classes. - // - // For each step in the composite, a visitXXX function is called where - // XXX is the step type. In this way many different visitors can be - // used without the need of implementing such functions in the MWStep - // classes. The downside is that a visitYYY function needs to be added - // to all visitor classes if an new step type YYY is created. - - class MWStepVisitor - { - public: - // Define the visit function for an arbitrary MWStep object. - typedef void VisitFunc (MWStepVisitor&, const MWStep&); - - // Destructor. - virtual ~MWStepVisitor(); - - // Visit the different predefined step types. - // The default implementation throws an exception that the step cannot - // be handled. - virtual void visitMulti (const MWMultiStep&); - virtual void visitGlobal (const MWGlobalStep&); - virtual void visitLocal (const MWLocalStep&); - - // Visit for an arbitrary \a MWStep type. - // The default implementation calls the \a VisitFunc function which - // is registered for the type name of the \a MWStep object. - // If not registered, it calls visitStep. - virtual void visit (const MWStep&); - - // Visit for an arbitrary \a MWStep type. - // The default implementation throws an exception that the step cannot - // be handled. - virtual void visitStep (const MWStep&); - - // Register a visit function for an MWStep with the given name. - // This can be used for other types of MWStep objects. - // The given function will usually be a static function in a derived - // visitor class calling a class member function. It can look like: - // <pre> - // void MyVisitor::doXXX (MWStepVisitor& visitor, const MWStep& step) - // { dynamic_cast<MyVisitor&>(visitor).visitXXX( - // dynamic_cast<const MWSTepXXX&>(step)); } - // </pre> - // The casts are kind of ugly, but unavoidable. - // The doXXX functions can be registered by the constructor. - void registerVisit (const std::string& name, VisitFunc*); - - private: - std::map<std::string, VisitFunc*> itsMap; - }; - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/MasterControl.h b/CEP/MWCommon/include/LMWCommon/MasterControl.h deleted file mode 100644 index 6921998ebc52d2a0e2fb59897e610935a02d2df5..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/MasterControl.h +++ /dev/null @@ -1,143 +0,0 @@ -//# MasterControl.h: Master control of a distributed process -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_MASTERCONTROL_H -#define LOFAR_MWCOMMON_MASTERCONTROL_H - -// @file -// @brief Master control of a distributed process. -// @author Ger van Diepen (diepen AT astron nl) - -#include <MWCommon/MWStepVisitor.h> -#include <MWCommon/MWStep.h> -#include <MWCommon/ObsDomain.h> -#include <MWCommon/WorkDomainSpec.h> -#include <MWCommon/MWConnectionSet.h> -#include <MWCommon/ParameterHandler.h> -#include <string> - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief Master control of a distributed process. - - // This class does the overall control of the master/worker framework. - // It defines the basic operations (see the enum) that can be done by the - // workers. - // - // Its operations are as follows: - // <ol> - // <li> The \a setInitInfo function sends the basic info to all - // workers like the name of the VDS to be used. - // <li> The \a setWorkDomain function defines the work domain info - // in a WorkDomainSpec object. - // <li> The processSteps function does the actual processing. - // It loops over the entire observation domain in work domain chunks. - // For each work domain it loops over the steps to be processed. - // This is done by using the MasterControl as a visitor to an MWStep. - // <li> After all steps are processed, it sends a quit command to the - // workers. - // </ol> - // As said above, a step is processed by using the MasterControl as - // an MWStepVisitor object. Usually step maps directly to an operation - // and prcoessing the step simply consists of sending a single command - // to the workers. - // However, in case of a solve it is more ivolved. - // It consists of sending multiple operations to localWorkers and globalWorker - // and testing if the globalWorker has converged. This is all handled in the - // \a visitSolve function. - // - // Instead of using MasterControl as the visitor, it might also be - // possible to pass a visitor object to the MasterControl. However, - // apart from processing the steps the MasterControl is doing hardly - // anything at all, so it might be better to have anther XXXControl - // class resembling this one. - // (It might be better to rename MasterControl to BBSControl as it is - // modeled after the BBSKernel functionality). - - class MasterControl: public MWStepVisitor - { - public: - // Define the possible standard operations. - enum Operation { - // initialize - Init=1, - // set work domain - SetWd, - // process a step - Step, - // global initial info (e.g. solvable parm info) - GlobalInit, - // get all iteration info (e.g. normal equations) - GlobalInfo, - // execute a global iteration (e.g. solve) - GlobalExec, - // end the processing of a work domain - EndWd - }; - - // Provide a descriptive string for the standard operations - // @param op Enumeration to be described - friend std::ostream& operator<<(std::ostream& os, MasterControl::Operation op); - - // Create the master control with the given localWorker and globalWorker - // connections. - MasterControl (const MWConnectionSet::ShPtr& localWorkers, - const MWConnectionSet::ShPtr& globalWorkers); - - ~MasterControl(); - - // Set the MS name to process. - void setInitInfo (const ParameterSet& parms, - const std::vector<std::string>& dataPartNames, - const ObsDomain&); - - // Set the work domain specification. - void setWorkDomainSpec (const WorkDomainSpec&); - - // Process a step (which can consist of multiple steps). - void processSteps (const MWStep&); - - // End the processing. - void quit(); - - private: - // Process the various MWStep types. - // @{ - virtual void visitGlobal (const MWGlobalStep&); - virtual void visitLocal (const MWLocalStep&); - // @} - - // Read the result from all localWorkers and/or globalWorkers. - // This is merely to see if the workers have performed the step. - void readAllWorkers (bool localWorkers, bool globalWorkers); - - //# Data members. - ObsDomain itsFullDomain; - WorkDomainSpec itsWds; - MWConnectionSet::ShPtr itsLocalWorkers; - MWConnectionSet::ShPtr itsGlobalWorkers; - }; - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/MemConnection.h b/CEP/MWCommon/include/LMWCommon/MemConnection.h deleted file mode 100644 index a90d8667be2ef9476b57395b161b82fb19d9d422..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/MemConnection.h +++ /dev/null @@ -1,87 +0,0 @@ -//# MemConnection.h: Connection to workers based on memory -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_MEMCONNECTION_H -#define LOFAR_MWCOMMON_MEMCONNECTION_H - -// @file -// @brief Connection to workers based on memory. -// @author Ger van Diepen (diepen AT astron nl) - -#include <MWCommon/MWConnection.h> -#include <MWCommon/WorkerProxy.h> -#include <Blob/BlobString.h> -#include <boost/shared_ptr.hpp> - - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief Connection to workers based on memory. - - // This class acts as the MW communication mechanism in memory. - // It makes it possible to use the MW framework in a single process - // which makes debugging easier. - // - // It is used in the same way as a SocketConnection or MPIConnection, but - // because everything is synchronous in a single process, a WorkerProxy - // object must be registered with the connection. Its \a handleData function - // function is immediately called when data are sent. - // The result is stored in a buffer in the MemConnection object, which - // can thereafter be read. - // After a read the buffer is cleared to ensure it is not read twice - // (as is also the case in a 'normal' connection). - - class MemConnection: public MWConnection - { - public: - // Define a shared pointer to this object. - typedef boost::shared_ptr<MemConnection> ShPtr; - - // Set up a connection to the given destination and attach a worker. - explicit MemConnection (const WorkerProxy::ShPtr& worker); - - virtual ~MemConnection(); - - // Get the length of the message. - // It returns the length of the data in the result buffer. - virtual int getMessageLength(); - - // Receive the data (i.e. the result of a worker from \a itsResult). - // The \a itsResult buffer is cleared hereafter. - virtual void receive (void* buf, unsigned size); - - // Write the data and process it by the worker. - // The result is stored in \a itsResult. - virtual void write (const LOFAR::BlobString& buf); - - private: - // This function cannot be called as \a write is implemented. - virtual void send (const void* buf, unsigned size); - - WorkerProxy::ShPtr itsWorker; - LOFAR::BlobString itsResult; - }; - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/MemConnectionSet.h b/CEP/MWCommon/include/LMWCommon/MemConnectionSet.h deleted file mode 100644 index ddbfae5c2d3e6f0d469bb25dd1ea30adbb59b845..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/MemConnectionSet.h +++ /dev/null @@ -1,87 +0,0 @@ -//# MemConnectionSet.h: Set of Memory connections -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_MEMCONNECTIONSET_H -#define LOFAR_MWCOMMON_MEMCONNECTIONSET_H - -// @file -// @brief Set of Memory connections. -// @author Ger van Diepen (diepen AT astron nl) - -#include <MWCommon/MWConnectionSet.h> -#include <MWCommon/MemConnection.h> -#include <vector> - - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief Set of Memory connections. - - // This class represents a set of memory connections. Typically it is used - // to group connections to workers of a specific type. - // In practice memory connections will hardly be used, but they come - // in handy for debugging purposes. - - class MemConnectionSet: public MWConnectionSet - { - public: - // Set up a connection set to destinations with the given tag. - // The tag can be used to define the type of destination - // (e.g. prediffer or solver). - explicit MemConnectionSet(); - - virtual ~MemConnectionSet(); - - // Clone the derived object to contain only the connections - // as indexed in the given vector. - virtual MWConnectionSet::ShPtr clone(const std::vector<int>&) const; - - // Add a connection to the given worker. - // It returns the sequence nr of the connection. - int addConnection (const WorkerProxy::ShPtr& worker); - - // Get the number of connections. - virtual int size() const; - - // Get seqnr of connection that is ready to receive. - // Is not really useful for this type of connection, so always returns 0. - virtual int getReadyConnection(); - - // Read the data into the BlobString buffer using the connection - // with the given sequence nr. - virtual void read (int seqnr, LOFAR::BlobString&); - - // Write the data from the BlobString buffer using the connection - // with the given sequence nr. - virtual void write (int seqnr, const LOFAR::BlobString&); - - // Write the data from the BlobString buffer to all connections. - virtual void writeAll (const LOFAR::BlobString&); - - private: - std::vector<MemConnection::ShPtr> itsConns; - }; - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/NodeDesc.h b/CEP/MWCommon/include/LMWCommon/NodeDesc.h deleted file mode 100644 index 5c62b10b9ba4b528ddfa54c9e69c70ac23d4e0aa..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/NodeDesc.h +++ /dev/null @@ -1,112 +0,0 @@ -//# NodeDesc.h: Description of a node in a cluster -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_NODEDESC_H -#define LOFAR_MWCOMMON_NODEDESC_H - -// @file -// @brief Description of a node in a cluster. -// @author Ger van Diepen (diepen AT astron nl) - -//# Includes -#include <MWCommon/ParameterHandler.h> -#include <string> -#include <vector> -#include <iosfwd> - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief Description of a node in a cluster. - - // This class holds the basic description of a node. - // It tells the name of the node and which file systems it has access to. - // - // Currently the information is made persistent in a LOFAR .parset file. - // In the future it needs to use the Central Processor Resource Manager. - - class NodeDesc - { - public: - // Define the node types. - enum NodeType { - Compute, - Storage, - Head, - Any - }; - - // Construct an empty object. - // By default its type is Any. - NodeDesc() - : itsType(Any) {} - - // Construct from the given parameterset. - explicit NodeDesc (const ParameterSet&); - - // Set node name. - void setName (const std::string& name) - { itsName = name; } - - // Set node type. - void setType (NodeType type) - { itsType = type; } - - // Add a file system the node has access to. - // A possible leading /auto is removed from the mountPoint. - void addFileSys (const std::string& fsName, const string& mountPoint); - - // Write it in parset format. - void write (std::ostream& os, const std::string& prefix) const; - - // Get the name. - const std::string& getName() const - { return itsName; } - - // Get the type. - NodeType getType() const - { return itsType; } - - // Get the file systems it has access to. - const std::vector<std::string>& getFileSys() const - { return itsFileSys; } - - // Get the mount points of the file systems. - const std::vector<std::string>& getMountPoints() const - { return itsMounts; } - - // Find the file system a file is on. - // The file must be given with its absolute file name. - // It does it by comparing the mount points with the leading part - // of the file name. - std::string findFileSys (const std::string& fileName) const; - - private: - std::string itsName; //# full name of the node - NodeType itsType; - std::vector<std::string> itsFileSys; //# names of file systems - std::vector<std::string> itsMounts; //# and their mount points - }; - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/ObsDomain.h b/CEP/MWCommon/include/LMWCommon/ObsDomain.h deleted file mode 100644 index e591ef955ebe416be724120eccd5d0c69c68ef62..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/ObsDomain.h +++ /dev/null @@ -1,103 +0,0 @@ -//# ObsDomain.h: Define the boundary values of a domain -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_OBSDOMAIN_H -#define LOFAR_MWCOMMON_OBSDOMAIN_H - -// @file -// @brief Define the boundary values of a domain. -// @author Ger van Diepen (diepen AT astron nl) - -#include <MWCommon/DomainShape.h> -#include <Blob/BlobOStream.h> -#include <Blob/BlobIStream.h> -#include <iosfwd> - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief Define the boundary values of a domain. - - // This class defines the boundaries of an observation domain. - // Currently it only defines a single range in time and freq. - // In the future it will probably need to be extended to multiple bands. - // - // Furthermore it offers a function to get the next work domain - // given a work domain shape defined by a DomainShape object. - // The master control uses this function to iterate over work domains. - - class ObsDomain - { - public: - // Set default shape to all frequencies and times. - ObsDomain(); - - // Form the starting work domain from the full observation domain - // and the work domain shape. - ObsDomain (const ObsDomain& fullDomain, - const DomainShape& workDomainShape); - - // Set frequency range (in Hz). - void setFreq (double startFreq, double endFreq); - - // Set time range (in sec). - void setTime (double startTime, double endTime); - - // Get the values. - // @{ - double getStartFreq() const - { return itsStartFreq; } - double getEndFreq() const - { return itsEndFreq; } - double getStartTime() const - { return itsStartTime; } - double getEndTime() const - { return itsEndTime; } - // @} - - // Go to the next work domain. - // Return false if no more work domains. - bool getNextWorkDomain (ObsDomain& workDomain, - const DomainShape& workDomainShape) const; - - // Convert to/from blob. - // @{ - friend LOFAR::BlobOStream& operator<< (LOFAR::BlobOStream& bs, - const ObsDomain& ds); - friend LOFAR::BlobIStream& operator>> (LOFAR::BlobIStream& bs, - ObsDomain&); - // @} - - // Print the object. - friend std::ostream& operator<< (std::ostream& os, - const ObsDomain& ds); - - private: - double itsStartFreq; - double itsEndFreq; - double itsStartTime; - double itsEndTime; - }; - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/ParameterHandler.h b/CEP/MWCommon/include/LMWCommon/ParameterHandler.h deleted file mode 100644 index 383cf0ca183dff76a2741dd4b8a89dfb6736615a..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/ParameterHandler.h +++ /dev/null @@ -1,121 +0,0 @@ -//# ParameterHandler.h: Handle a LOFAR .parset file -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_PARAMETERHANDLER_H -#define LOFAR_MWCOMMON_PARAMETERHANDLER_H - -// @file -// @brief Handle a LOFAR .parset file -// @author Ger van Diepen (diepen AT astron nl) - -#include <Common/ParameterSet.h> -#include <Blob/BlobIStream.h> -#include <Blob/BlobOStream.h> - -namespace LOFAR { namespace CEP { - - //# Put ParameterSet into LOFAR::CEP namespace for ease of use. - - // @ingroup MWCommon - // @brief Handle a LOFAR .parset file - - // This class handles the processing of a LOFAR .parset file - // It augments the LOFAR ParameterSet class with functions that can deal - // with undefined parameters. There is a set of functions that return - // a default value if undefined and a set of functions that leave the - // value untouched if undefined. - - class ParameterHandler - { - public: - ParameterHandler (const ParameterSet&); - - // Get a parameter value. - // An exception is thrown if it does not exist. - // @{ - std::string getString (const std::string& parm) const; - double getDouble (const std::string& parm) const; - unsigned getUint (const std::string& parm) const; - bool getBool (const std::string& parm) const; - std::vector<std::string> getStringVector (const std::string& parm) const; - // @} - - // Get a parameter value. - // If it does not exist, the default value is used instead. - // @{ - std::string getString (const std::string& parm, - const std::string& defVal) const; - double getDouble (const std::string& parm, - double defVal) const; - unsigned getUint (const std::string& parm, - unsigned defVal) const; - bool getBool (const std::string& parm, - bool defVal) const; - std::vector<std::string> getStringVector - (const std::string& parm, const std::vector<std::string>& defVal) const; - // @} - - // Get a parameter value and fill \a value with it. - // If it does not exist, nothing is done. - // @{ - void fillString (const std::string& parm, - std::string& value) const; - void fillDouble (const std::string& parm, - double& value) const; - void fillUint (const std::string& parm, - unsigned& value) const; - void fillBool (const std::string& parm, - bool& value) const; - void fillStringVector (const std::string& parm, - std::vector<std::string>& value) const; - // @} - - // Convert automatically to a ParameterSet. - operator const ParameterSet& () const - { return itsParms; } - - protected: - ParameterSet itsParms; - }; - - - // Write/read a ParameterSet into/from a blob. - // @{ - LOFAR::BlobOStream& operator<< (LOFAR::BlobOStream&, const ParameterSet&); - LOFAR::BlobIStream& operator>> (LOFAR::BlobIStream&, ParameterSet&); - // @} - - inline std::string ParameterHandler::getString (const std::string& parm) const - { return itsParms.getString (parm); } - inline double ParameterHandler::getDouble (const std::string& parm) const - { return itsParms.getDouble (parm); } - inline unsigned ParameterHandler::getUint (const std::string& parm) const - { return itsParms.getUint32 (parm); } - inline bool ParameterHandler::getBool (const std::string& parm) const - { return itsParms.getBool (parm); } - inline std::vector<std::string> ParameterHandler::getStringVector - (const std::string& parm) const - { return itsParms.getStringVector (parm); } - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/SocketConnection.h b/CEP/MWCommon/include/LMWCommon/SocketConnection.h deleted file mode 100644 index 0c65a29aae3110a495e0b85115310ac4d910e739..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/SocketConnection.h +++ /dev/null @@ -1,99 +0,0 @@ -//# SocketConnection.h: Connection to workers based on a socket -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_SOCKETCONNECTION_H -#define LOFAR_MWCOMMON_SOCKETCONNECTION_H - -// @file -// @brief Connection to workers based on a socket. -// @author Ger van Diepen (diepen AT astron nl) - -#include <MWCommon/MWConnection.h> -#include <Common/Net/Socket.h> -#include <boost/shared_ptr.hpp> -#include <string> - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief Connection to workers based on a socket. - - // This class handles the socket connection between two processes. - // For a client it can set up the connection to a server on a given - // host and port. - // For a server it can hold the connection created by SocketListener. - // - // It is meant to send and receive blobs. The length of a message to - // receive is read (by base class MWConnection) from the blob header. - - class SocketConnection: public MWConnection - { - public: - // Define a shared pointer to this object. - typedef boost::shared_ptr<SocketConnection> ShPtr; - - // Set up the client side of a connection. - // Upon the first send or receive it connects to the server - // on the given host and port. - // If making the connection fails, it will sleep one second and try - // again for up to 60 attempts. In this way the case is handled - // where a server is started a bit later than a client. - SocketConnection (const std::string& hostName, const std::string& port); - - // Add a socket from the server when it accepted a connection - // (used by SocketListener). - // It takes over the ownership of the pointer. - explicit SocketConnection (LOFAR::Socket*); - - virtual ~SocketConnection(); - - // Check the state of the connection. - virtual bool isConnected() const; - - // Get the length of the message. - // Always returns -1 indicating that the length has to be read - // from the header. - virtual int getMessageLength(); - - // Receive the data sent by the destination - // and wait until data has been received into buf. - virtual void receive (void* buf, unsigned size); - - // Send the data to the destination - // and wait until the data has been sent. - virtual void send (const void* buf, unsigned size); - - // Get the name of the host this process is running on. - // If sockets are not supported (e.g. Cray), it returns an empty string. - static std::string getHostName(); - - private: - // Initialize the connection. - void init(); - - LOFAR::Socket itsConnSocket; - LOFAR::Socket* itsDataSocket; - }; - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/SocketConnectionSet.h b/CEP/MWCommon/include/LMWCommon/SocketConnectionSet.h deleted file mode 100644 index 40296e2bc2ab93f58c76927100a85126df194243..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/SocketConnectionSet.h +++ /dev/null @@ -1,99 +0,0 @@ -//# SocketConnectionSet.h: Set of socket connections -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_SOCKETCONNECTIONSET_H -#define LOFAR_MWCOMMON_SOCKETCONNECTIONSET_H - -// @file -// @brief Set of socket connections. -// @author Ger van Diepen (diepen AT astron nl) - -#include <MWCommon/MWConnectionSet.h> -#include <MWCommon/SocketListener.h> -#include <MWCommon/SocketConnection.h> -#include <vector> - - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief Set of socket connections. - - // This class represents a set of socket connections. Typically it is used - // to group connections to workers of a specific type. - // The main reason for having this class is the ability to check if any - // connection in the group is ready to receive data (i.e. if the other - // side of the connection has sent data). This is done using the \a select - // function on the fd-s of the sockets in the set. - // - // The SocketConnectionSet class creates a socket listener. Thus it is - // the server side of a connection and is typically used by the master - // control. - // - // @todo Implement getReadyConnection. - - class SocketConnectionSet: public MWConnectionSet - { - public: - // Set up a connection set for a server. - // It creates a SocketListener object on the given port. - explicit SocketConnectionSet (const std::string& port); - - // Set up a connection from an existing SocketListener. - // It makes a (shallow) copy of the listener object. - explicit SocketConnectionSet (const SocketListener&); - - virtual ~SocketConnectionSet(); - - // Clone the derived object to contain only the connections - // as indexed in the given vector. - virtual MWConnectionSet::ShPtr clone(const std::vector<int>&) const; - - // Accept connections from the given number of clients to the server. - void addConnections (int nr); - - // Get the number of connections. - virtual int size() const; - - // Get seqnr of connection that is ready to receive. - // <0 means no connection ready yet. - virtual int getReadyConnection(); - - // Read the data into the BlobString buffer using the connection - // with the given sequence nr. - virtual void read (int seqnr, LOFAR::BlobString&); - - // Write the data from the BlobString buffer using the connection - // with the given sequence nr. - virtual void write (int seqnr, const LOFAR::BlobString&); - - // Write the data from the BlobString buffer to all connections. - virtual void writeAll (const LOFAR::BlobString&); - - private: - SocketListener itsListener; - std::vector<SocketConnection::ShPtr> itsConns; - }; - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/SocketListener.h b/CEP/MWCommon/include/LMWCommon/SocketListener.h deleted file mode 100644 index 71cd6c7cfa62ac00fe23ba3f6da46517a7aa7a8b..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/SocketListener.h +++ /dev/null @@ -1,63 +0,0 @@ -//# SocketListener.h: Class that creates a socket and accepts connections -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_SOCKETLISTENER_H -#define LOFAR_MWCOMMON_SOCKETLISTENER_H - -// @file -// @brief Class that creates a socket and accepts connections. -// @author Ger van Diepen (diepen AT astron nl) - -#include <MWCommon/SocketConnection.h> -#include <Common/Net/Socket.h> -#include <boost/shared_ptr.hpp> -#include <string> - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief Class that creates a socket and accepts connections. - - // This class sets up a socket listener. It is used by SocketConnectionSet - // to accept connection requests from workers. - // - // Internally the class uses a shared pointer to a socket object. - // It means that a copy of a SocketListener object can be made, but that - // copies share the same underlying socket object. - - class SocketListener - { - public: - // Set up the server side of a listener. - explicit SocketListener (const std::string& port); - - // Listen to a connection and accept it. - // It blocks until another process wants to connect. - SocketConnection::ShPtr accept(); - - private: - boost::shared_ptr<LOFAR::Socket> itsConnSocket; - }; - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/VdsDesc.h b/CEP/MWCommon/include/LMWCommon/VdsDesc.h deleted file mode 100644 index 42e3e4c1bcdb1724cfcbd9797a56ea1471e5732d..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/VdsDesc.h +++ /dev/null @@ -1,96 +0,0 @@ -//# VdsDesc.h: Describe an entire visibility data set -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_VDSDESC_H -#define LOFAR_MWCOMMON_VDSDESC_H - -// @file -// @brief Describe an entire visibility data set -// @author Ger van Diepen (diepen AT astron nl) - -//# Includes -#include <MWCommon/VdsPartDesc.h> -#include <MWCommon/ParameterHandler.h> -#include <casa/Utilities/Regex.h> - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief Describe an entire visibility data set - - // This class holds the description of an entire visibility data set (VDS). - // In VdsPartDesc objects it describes the parts it consists of and - // on which file systems they are located. - // A VdsPartDesc object is also used to describe the entire VDS. - // Furthermore it contains the names of all antennae, which can be used - // to map the antenna name to the antenna number when a selection on - // antenna names is done. - // - // Currently the information is made persistent in a LOFAR .parset file. - // In the future it needs to use the Centrol Processor Resource Manager. - - class VdsDesc - { - public: - // Construct with a description of the entire visibility data set. - // The description can be empty and set later using setDesc. - explicit VdsDesc (const VdsPartDesc& = VdsPartDesc()); - - // Construct from the given parameterset. - // @{ - explicit VdsDesc (const std::string& parsetName); - explicit VdsDesc (const ParameterSet& parset) - { init (parset); } - // @} - - // Add a part. - void addPart (const VdsPartDesc& part) - { itsParts.push_back (part); } - - // Get the description of the parts. - const std::vector<VdsPartDesc>& getParts() const - { return itsParts; } - - // Get the description of the VDS. - const VdsPartDesc& getDesc() const - { return itsDesc; } - - // Set the description of the VDS. - // Usually the description is set in the constructor, but this offers - // another way of doing it. - void setDesc (const VdsPartDesc& desc) - { itsDesc = desc; } - - // Write it in parset format. - void write (std::ostream& os) const; - - private: - // Fill the object from the given parset file. - void init (const ParameterSet& parset); - - VdsPartDesc itsDesc; - std::vector<VdsPartDesc> itsParts; - }; - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/VdsPartDesc.h b/CEP/MWCommon/include/LMWCommon/VdsPartDesc.h deleted file mode 100644 index ebc52d96d9d08585af52c1ba03fbd83904d98d48..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/VdsPartDesc.h +++ /dev/null @@ -1,170 +0,0 @@ -//# VdsPartDesc.h: Description of a visibility data set or part thereof -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_VDSPARTDESC_H -#define LOFAR_MWCOMMON_VDSPARTDESC_H - -// @file -// @brief Description of a visibility data set or part thereof. -// @author Ger van Diepen (diepen AT astron nl) - -//# Includes -#include <Common/ParameterSet.h> -#include <Blob/BlobOStream.h> -#include <Blob/BlobIStream.h> -#include <string> -#include <vector> -#include <iosfwd> - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief Description of a visibility data set or part thereof. - - // This class holds the description of a visibility data set (VDS) part. - // It defines the name of the part and on which file system it is located. - // Using the ClusterDesc object it can be derived on which node this - // VDS part can be processed best. This is done by the WorkersDesc - // class. - // - // The description of the VDS also contains info about the time, - // frequency, and baseline domain of the visibility data. - // - // The information is made persistent in a LOFAR .parset file. - - class VdsPartDesc - { - public: - // Construct an empty object. - VdsPartDesc() - : itsStartTime(0), itsEndTime(1), itsStepTime(1) - {} - - // Construct from the given parameterset. - explicit VdsPartDesc (const ParameterSet&); - - // Set VDS name and file system. - void setName (const std::string& name, const std::string& fileSys); - - // Set the original file name. - void setFileName (const std::string& name) - { itsFileName = name; } - - // Set the name of the ClusterDesc file used. - void setClusterDescName (const std::string& cdName) - { itsCDescName = cdName; } - - // Change the base part of the name. - void changeBaseName (const string& newBaseName); - - // Set the observation start and end time. - // Optionally the start and end per time interval can be set. - void setTimes (double startTime, double endTime, double stepTime, - const vector<double>& starts = vector<double>(), - const vector<double>& ends = vector<double>()); - - // Add a band. - // <group> - void addBand (int nchan, double startFreq, double endFreq); - void addBand (int nchan, const vector<double>& startFreq, - const vector<double>& endFreq); - // </group> - - // Add an extra parameter. It is added to the subset 'Extra.'. - // If the parameter already exists, it is replaced. - void addParm (const std::string& key, const std::string& value) - { return itsParms.add (key, value); } - - // Get access to the extra parameters. - const ParameterSet& getParms() const - { return itsParms; } - - // Clear the extra parameters. - void clearParms() - { itsParms.clear(); } - - // Write the VdsPartDesc object in parset format. - void write (std::ostream& os, const std::string& prefix) const; - - // Get the values. - // @{ - const std::string& getName() const - { return itsName; } - const std::string& getFileName() const - { return itsFileName; } - const std::string& getFileSys() const - { return itsFileSys; } - const std::string& getClusterDescName() const - { return itsCDescName; } - double getStartTime() const - { return itsStartTime; } - double getEndTime() const - { return itsEndTime; } - double getStepTime() const - { return itsStepTime; } - const vector<double>& getStartTimes() const - { return itsStartTimes; } - const vector<double>& getEndTimes() const - { return itsEndTimes; } - int getNBand() const - { return itsNChan.size(); } - const std::vector<int>& getNChan() const - { return itsNChan; } - const std::vector<double>& getStartFreqs() const - { return itsStartFreqs; } - const std::vector<double>& getEndFreqs() const - { return itsEndFreqs; } - // @} - - // Put/get the object to/from a blob. - // <group> - BlobOStream& toBlob (BlobOStream&) const; - BlobIStream& fromBlob (BlobIStream&); - // </group> - - private: - std::string itsName; //# full name of the VDS desc - std::string itsFileName; //# full name of the VDS (data set name) - std::string itsFileSys; //# name of file system the VDS resides on - std::string itsCDescName; //# name of ClusterDesc file used - double itsStartTime; - double itsEndTime; - double itsStepTime; - std::vector<double> itsStartTimes; - std::vector<double> itsEndTimes; - std::vector<int32> itsNChan; //# nr of channels per band - std::vector<double> itsStartFreqs; //# start freq of each channel - std::vector<double> itsEndFreqs; //# end freq of each channel - ParameterSet itsParms; //# extra parameters - }; - - // Put/get the object to/from a blob. - // <group> - inline BlobOStream& operator<< (BlobOStream& bs, const VdsPartDesc& vpd) - { return vpd.toBlob (bs); } - inline BlobIStream& operator>> (BlobIStream& bs, VdsPartDesc& vpd) - { return vpd.fromBlob (bs); } - // </group> - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/WorkDomainSpec.h b/CEP/MWCommon/include/LMWCommon/WorkDomainSpec.h deleted file mode 100644 index 859f368ee8784245793dfd343328e2e00747722c..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/WorkDomainSpec.h +++ /dev/null @@ -1,145 +0,0 @@ -//# WorkDomainSpec.h: Define the specifications of the work domain -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_WORKDOMAINSPEC_H -#define LOFAR_MWCOMMON_WORKDOMAINSPEC_H - -// @file -// @brief Define the specifications of the work domain. -// @author Ger van Diepen (diepen AT astron nl) - -#include <MWCommon/DomainShape.h> -#include <Blob/BlobOStream.h> -#include <Blob/BlobIStream.h> -#include <vector> -#include <string> - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief Define the specifications of the work domain. - - // This class defines the properties of a work domain. It contains: - // <ul> - // <li> The size in time and freq. - // <li> The integration to be done in time and/or freq. - // <li> The input data column. - // <li> The antenna numbers or names to be selected. - // <li> If autocorrelations between antennas are to be selected. - // <li> The polarisation correlations to be selected. - // </ul> - // A work domain defines the amount of data a worker can hold in memory. - // - // The control will iterate over the entire data set in chunk of the - // work domain size. For each chunk it will perform the steps as defined - // by an MWMultiStep object on the data in the work domain or a subset - // of them. - - class WorkDomainSpec - { - public: - // Default constructor (for containers). - WorkDomainSpec() - : itsInColumn("DATA"), - itsAutoCorr(false) - {} - - // Set/get work domain shape. - // @{ - void setShape (const DomainShape& shape) - { itsShape = shape; } - const DomainShape& getShape() const - { return itsShape; } - // @} - - // Set/get integration interval in frequency or time. - // @{ - void setFreqIntegration (double hz) - { itsFreqInt = hz; } - void setTimeIntegration (double sec) - { itsTimeInt = sec; } - double getFreqIntegration() const - { return itsFreqInt; } - double getTImeIntegration() const - { return itsTimeInt; } - // @} - - // Set/get the input data column to use. - // @{ - void setInColumn (const std::string& inColumn) - { itsInColumn = inColumn; } - const std::string& getInColumn() const - { return itsInColumn; } - // @} - - // Set/get the antennas to use (0-based numbers). - // @{ - void setAntennas (const std::vector<int>& antNrs); - const std::vector<int>& getAntennas() const - { return itsAntNrs; } - // @} - - // Set/get antennas by name patterns. - // Each name can be a filename-like pattern. - // @{ - void setAntennaNames (const std::vector<std::string>& antNamePatterns); - const std::vector<std::string>& getAntennaNames() const - { return itsAntNames; } - // @} - - // Set/get the autocorrelations flag. - // @{ - void setAutoCorr (bool autoCorr) - { itsAutoCorr = autoCorr; } - bool getAutoCorr() const - { return itsAutoCorr; } - // @} - - // Set/get the correlations to use. - // @{ - void setCorr (const std::vector<bool>& corr); - const std::vector<bool>& getCorr() const - { return itsCorr; } - // @} - - // Write or read the object into/from a blob stream. - // @{ - friend LOFAR::BlobOStream& operator<< (LOFAR::BlobOStream&, - const WorkDomainSpec&); - friend LOFAR::BlobIStream& operator>> (LOFAR::BlobIStream&, - WorkDomainSpec&); - // @} - - private: - std::string itsInColumn; - std::vector<int> itsAntNrs; - std::vector<std::string> itsAntNames; - bool itsAutoCorr; - std::vector<bool> itsCorr; - DomainShape itsShape; - double itsFreqInt; - double itsTimeInt; - }; - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/WorkerControl.h b/CEP/MWCommon/include/LMWCommon/WorkerControl.h deleted file mode 100644 index 9538ba5caab0157d54feec1ebdac455ee94c2fa0..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/WorkerControl.h +++ /dev/null @@ -1,64 +0,0 @@ -//# WorkerControl.h: High level worker control -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_WORKERCONTROL_H -#define LOFAR_MWCOMMON_WORKERCONTROL_H - -// @file -// @brief High level worker control. -// @author Ger van Diepen (diepen AT astron nl) - -#include <MWCommon/WorkerProxy.h> -#include <MWCommon/MWConnection.h> - - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief High level worker control. - - // This class if the high level control of a proxy worker. - // The \a init function sets up the connection and does the initialisation. - // The \a run function receives commands from the master - // control, lets the proxy execute them, and sends replies back. - // When the quit command is received, the \a run function will end. - - class WorkerControl - { - public: - // Construct with the given proxy, that will execute the commands. - WorkerControl (const WorkerProxy::ShPtr& proxy); - - // Initialise the connection and send an init message to the master. - void init (const MWConnection::ShPtr& connection); - - // Receive and execute messages until an end message is received. - void run(); - - private: - MWConnection::ShPtr itsConnection; - WorkerProxy::ShPtr itsProxy; - }; - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/WorkerFactory.h b/CEP/MWCommon/include/LMWCommon/WorkerFactory.h deleted file mode 100644 index a5a599c5e76c2999d32e8678076305e2b9cd506c..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/WorkerFactory.h +++ /dev/null @@ -1,66 +0,0 @@ -//# WorkerFactory.h: Factory pattern to generate a WorkerProxy object -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_WORKERFACTORY_H -#define LOFAR_MWCOMMON_WORKERFACTORY_H - -// @file -// @brief Factory pattern to generate a WorkerProxy object. -// @author Ger van Diepen (diepen AT astron nl) - -#include <MWCommon/WorkerProxy.h> -#include <map> -#include <string> - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief Factory pattern to generate a WorkerProxy object. - - // This class contains a map of names to \a create functions - // of derived WorkerProxy objects. It is used to construct the correct - // WorkerProxy object given a type name. - // In this way one can choose which worker to use. For example, it makes - // it possible to use simple test workers to process prediffer and - // solver operations to check the control logic. - - class WorkerFactory - { - public: - // Define the signature of the function to create the worker. - typedef WorkerProxy::ShPtr Creator (); - - // Add a creator function. - void push_back (const std::string& name, Creator*); - - // Create the object of the given name. - // An exception is thrown if the name is not in the map. - WorkerProxy::ShPtr create (const std::string& name) const; - - private: - std::map<std::string, Creator*> itsMap; - }; - - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/WorkerInfo.h b/CEP/MWCommon/include/LMWCommon/WorkerInfo.h deleted file mode 100644 index 736d52a83797a53bc7dcf231b83524431bb5b4be..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/WorkerInfo.h +++ /dev/null @@ -1,90 +0,0 @@ -//# WorkerInfo.h: Information about a worker -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_WORKERINFO_H -#define LOFAR_MWCOMMON_WORKERINFO_H - -// @file -// @brief Information about a worker. -// @author Ger van Diepen (diepen AT astron nl) - -#include <string> -#include <vector> - -//# Forward Declarations. -namespace LOFAR { - class BlobOStream; - class BlobIStream; -} - - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief Information about a worker. - - // This class contains the information describing a worker. - // It contains the name of the host it is running on and a vector - // with the types of work in can perform. Currently only the first - // work type is taken into account. - // - // @todo Take all work types into account. - - class WorkerInfo - { - public: - // Creatye empty object. - WorkerInfo(); - - // Construct the object from the given info. - WorkerInfo (const std::string& hostName, - const std::vector<int>& workTypes); - - ~WorkerInfo(); - - // Get the host name. - const std::string& getHostName() const - { return itsHostName; } - - // Get the work types. - const std::vector<int>& getWorkTypes() const - { return itsWorkTypes; } - - // Get the first work type. Returns 0 if no work types. - int getWorkType() const; - - // Read or write the info from/into a blob. - // @{ - friend LOFAR::BlobOStream& operator<< (LOFAR::BlobOStream& bs, - const WorkerInfo& info); - friend LOFAR::BlobIStream& operator>> (LOFAR::BlobIStream& bs, - WorkerInfo& info); - // @} - - private: - std::string itsHostName; - std::vector<int> itsWorkTypes; - }; - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/WorkerProxy.h b/CEP/MWCommon/include/LMWCommon/WorkerProxy.h deleted file mode 100644 index 40d8531f0d7d2de178407b8efcc549245e9f912e..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/WorkerProxy.h +++ /dev/null @@ -1,111 +0,0 @@ -//# WorkerProxy.h: Abstract base class for all worker proxies -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_WORKERPROXY_H -#define LOFAR_MWCOMMON_WORKERPROXY_H - -// @file -// @brief Abstract base class for all worker proxies. -// @author Ger van Diepen (diepen AT astron nl) - -#include <MWCommon/WorkerInfo.h> -#include <MWCommon/ParameterHandler.h> -#include <string> -#include <vector> -#include <boost/shared_ptr.hpp> - -//# Forward Declarations. -namespace LOFAR { - class BlobString; - class BlobIStream; -} - - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief Abstract base class for all worker proxies. - - // This class is the abstract base class for the possible workers. - // Usually a worker is a proxy class to a class doing the actual work. - // The WorkerControl class uses a WorkerProxy to do the actual work. - // - // Functions to create a worker proxy from a given type name can be - // registered in a WorkerFactory object. It gives the user the freedom - // to choose which function is registered making it possible to use - // some simple test classes instead of the full-blown real classes to - // test the control flow. - - class WorkerProxy - { - public: - // Define a shared pointer to this object. - typedef boost::shared_ptr<WorkerProxy> ShPtr; - - WorkerProxy(); - - virtual ~WorkerProxy(); - - // Fill the buffer with the worker proxy info (like host and work types). - // This is used at initialisation time to make the worker capabilities - // known to the master. - void putWorkerInfo (LOFAR::BlobString& out); - - // Get the worker info from the blob string. It is used by the master - // to extract it from a message. - static WorkerInfo getWorkerInfo (LOFAR::BlobString& in); - - // Process the command and data that has been received in the input - // buffer and write the possible result into the output buffer. - // If the input buffer contains the \a quit command, the \a quit function - // is called and the status \a false is returned. - // Otherwise the \a process function is called to do the actual - // processing. - bool handleMessage (const LOFAR::BlobString& in, LOFAR::BlobString& out); - - private: - // Get the work types supported by the proxy. - virtual std::vector<int> getWorkTypes() const = 0; - - // Let a derived class set the initial info. - virtual void setInitInfo (const ParameterSet&, - const std::string& dataPartName) = 0; - - // Let a derived class process the received data. - // The returned operation will be put into the reply message. - // If the returned operation is < 0, no reply message will be sent. - virtual int process (int operation, int streamId, - LOFAR::BlobIStream& in, - LOFAR::BlobOStream& out) = 0; - - // Let a derived class end its processing. - // The default implementation does nothing. - virtual void quit(); - - - // The workerId is set at the beginning. - int itsWorkerId; - }; - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/include/LMWCommon/WorkersDesc.h b/CEP/MWCommon/include/LMWCommon/WorkersDesc.h deleted file mode 100644 index 49e23970c487efded132d6c490b8fbcb1a2f105e..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/include/LMWCommon/WorkersDesc.h +++ /dev/null @@ -1,99 +0,0 @@ -//# WorkerDesc.h: Description of all workers -//# -//# Copyright (C) 2005 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#ifndef LOFAR_MWCOMMON_WORKERSDESC_H -#define LOFAR_MWCOMMON_WORKERSDESC_H - -// @file -// @brief Description of all workers. -// @author Ger van Diepen (diepen AT astron nl) - -//# Includes -#include <MWCommon/ClusterDesc.h> -#include <string> -#include <vector> - -namespace LOFAR { namespace CEP { - - // @ingroup MWCommon - // @brief Description of all workers. - - // This class holds the description of the workers in an MW run. - // For each worker it describes on which node it runs and which types - // of work it can perform. - // Combined with the cluster description, this information is used - // to determine which worker can be used to perform a given type of work - // on data on a given file system. In determining this, it keeps track of - // the workload to avoid that the same worker is selected again and again. - - class WorkersDesc - { - public: - // Construct from the given cluster description. - WorkersDesc (const ClusterDesc&); - - // Add a worker with the given id. - // It can do the work types given in the vector on the given node. - void addWorker (unsigned id, const std::string& node, - const std::vector<int>& workTypes); - - // Increase or decrease the load for the given worker. - // Return the new load. - // @{ - int incrLoad (unsigned worker) - { return ++itsLoad[worker]; } - int decrLoad (unsigned worker) - { return --itsLoad[worker]; } - // @} - - // Find the worker with the lowest load that can perform the given - // work type for data on the given file system on a given type of node. - // By default it looks for Compute Nodes. - // The given file system can be empty indicating that any worker can do it. - // It returns -1 if no suitable worker could be found. - // Otherwise the worker id is returned. - int findWorker (int workType, const std::string& fileSystem, - NodeDesc::NodeType type = NodeDesc::Compute) const; - - private: - // Map giving the workers on each node. - typedef std::map<std::string, std::vector<unsigned> > MapN2W; - // Map given the nodes with access to a file system. - typedef std::map<std::string, std::vector<int> > MapF2N; - - // Find worker with lowest load. - // @{ - int findLowest (const MapN2W& workMap, - NodeDesc::NodeType type) const; - int findLowest (const MapN2W& workMap, - const std::string& fileSystem, - NodeDesc::NodeType type) const; - // @} - - const ClusterDesc& itsClusterDesc; - std::map<int,MapN2W> itsMap; //# map worktype to nodename/workerid - std::vector<int> itsLoad; //# load of each worker (#times used) - }; - -}} //# end namespaces - -#endif diff --git a/CEP/MWCommon/package.dox b/CEP/MWCommon/package.dox deleted file mode 100644 index 7b6573d398bca67ecf64fe9a609e8555f41fb084..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/package.dox +++ /dev/null @@ -1,12 +0,0 @@ -// \ingroup Imager - -// \defgroup MWCommon MWCommon -// MWCommon contains the common code for the Master/Worker framework. -// It consists of code to send/receive commands and data, but also -// code that describe the various part of the system. These ar: -// <ul> -// <li> A descripton of the cluster telling which nodes are available -// and which file ssytems they have access to. -// <li> A description of a distributed data set telling -// which parts it consists of and where they are located. -// </ul> diff --git a/CEP/MWCommon/src/CMakeLists.txt b/CEP/MWCommon/src/CMakeLists.txt deleted file mode 100644 index 07eec6d95f2b236b3bb1db386e527765475cc8f7..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/CMakeLists.txt +++ /dev/null @@ -1,49 +0,0 @@ -# $Id$ - -include(LofarPackageVersion) - -lofar_add_library(mwcommon - Package__Version.cc - ClusterDesc.cc - ControllerBase.cc - DomainShape.cc - MPIConnection.cc - MPIConnectionSet.cc - MWBlobIO.cc - MWConnection.cc - MWConnectionSet.cc - MWGlobalStep.cc - MWIos.cc - MWLocalStep.cc - MWMultiStep.cc - MWStep.cc - MWStepFactory.cc - MWStepVisitor.cc - MasterControl.cc - MemConnection.cc - MemConnectionSet.cc - NodeDesc.cc - ObsDomain.cc - ParameterHandler.cc - SocketConnection.cc - SocketConnectionSet.cc - SocketListener.cc - VdsDesc.cc - VdsPartDesc.cc - WorkDomainSpec.cc - WorkerControl.cc - WorkerFactory.cc - WorkerInfo.cc - WorkerProxy.cc - WorkersDesc.cc) - -lofar_add_bin_program(versionmwcommon versionmwcommon.cc) -lofar_add_bin_program(finddproc finddproc.cc) - -install(PROGRAMS - rundist - rundist-part - startdistproc - socketrun - runlogpid - DESTINATION bin) diff --git a/CEP/MWCommon/src/ClusterDesc.cc b/CEP/MWCommon/src/ClusterDesc.cc deleted file mode 100644 index 3d277eb7373390f524a13bed567b460016eae1ef..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/ClusterDesc.cc +++ /dev/null @@ -1,237 +0,0 @@ -//# ClusterDesc.cc: Description of a cluster -//# -//# Copyright (C) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ -//# -//# @author Ger van Diepen <diepen AT astron nl> - -#include <lofar_config.h> - -#include <MWCommon/ClusterDesc.h> -#include <MWCommon/MWError.h> -#include <Common/LofarLogger.h> -#include <casa/OS/Path.h> - -using namespace std; -using namespace casa; - -namespace LOFAR { namespace CEP { - - ClusterDesc::ClusterDesc (const string& parsetName) - { - init (parsetName); - } - - void ClusterDesc::init (const string& parsetName) - { - // Get absolute file name (it expands possible ~ and $ in the file name). - String fullName = Path(parsetName).absoluteName(); - ParameterSet parset(fullName); - itsName = parset.getString ("ClusterName"); - if (parset.isDefined ("Node0.NodeName")) { - // The cluster can be heterogeneous and is described in detail. - getHetCluster (parset); - } else if (parset.isDefined ("SubClusters")) { - // Get subclusters; use parent's directory as default directory. - getSubClusters (parset.getStringVector ("SubClusters", true), - Path(fullName).dirName()); - } else { - // The cluster is homogeneous and is described in a concise way. - getHomCluster (parset); - } - } - - void ClusterDesc::getHetCluster (const ParameterSet& parset) - { - // Iterate sequentially until no node with that number is found. - int i=0; - while (true) { - ostringstream prefix; - prefix << "Node" << i << '.'; - if (! parset.isDefined (prefix.str() + "NodeName")) { - break; - } - ParameterSet subset = parset.makeSubset (prefix.str()); - NodeDesc node(subset); - addNode (node); - ++i; - } - } - - void ClusterDesc::getHomCluster (const ParameterSet& parset) - { - vector<string> defVal; - // Add the different kind of nodes. - addNodes (parset.makeSubset("Compute."), NodeDesc::Compute); - addNodes (parset.makeSubset("Storage."), NodeDesc::Storage); - addNodes (parset.makeSubset("Head."), NodeDesc::Head); - if (parset.isDefined ("Nodes")) { - addNodes (parset, NodeDesc::Any); - } - } - - void ClusterDesc::addNodes (const ParameterSet& parset, - NodeDesc::NodeType type) - { - if (parset.empty()) { - return; - } - vector<string> defVal; - vector<string> names = parset.getStringVector ("Nodes", true); - vector<string> localDisks = - parset.getStringVector ("LocalDisks", defVal, true); - vector<string> remoteDisks = - parset.getStringVector ("RemoteDisks", defVal, true); - vector<string> remoteFilesys = - parset.getStringVector ("RemoteFileSys", defVal, true); - if (remoteFilesys.empty()) { - remoteFilesys = remoteDisks; - } else { - ASSERTSTR (remoteFilesys.size() == remoteDisks.size(), - "RemoteFileSys must be empty or have equal length as RemoteDisks"); - } - for (uint i=0; i<names.size(); ++i) { - vector<string> rdisks, rfilesys, lfilesys, ldisks; - const vector<string>* ldiskp = &localDisks; - const vector<string>* rdiskp = &remoteDisks; - const vector<string>* rfsysp = &remoteFilesys; - // It is possible to override disk specifications on a per node basis. - string key = "LocalDisks." + names[i]; - if (parset.isDefined (key)) { - ldisks = parset.getStringVector (key, true); - ldiskp = &ldisks; - } - key = string("RemoteDisks." + names[i]); - if (parset.isDefined (key)) { - rdisks = parset.getStringVector (key, true); - rdiskp = &rdisks; - rfilesys = parset.getStringVector ("RemoteFileSys." + names[i], - defVal, true); - if (rfilesys.empty()) { - rfilesys = rdisks; - } else { - ASSERTSTR (rfilesys.size() == rdisks.size(), - "RemoteFileSys," + names[i] + - " must be empty or have equal length as RemoteDisks." + - names[i]); - } - rfsysp = &rfilesys; - } - NodeDesc node; - node.setName (names[i]); - node.setType (type); - for (uint j=0; j<rdiskp->size(); ++j) { - node.addFileSys ((*rfsysp)[j], (*rdiskp)[j]); - } - // Add node name to local filesys to make it unique. - for (uint j=0; j<ldiskp->size(); ++j) { - node.addFileSys (names[i] + ':' + (*ldiskp)[j], - (*ldiskp)[j]); - } - addNode (node); - } - } - - void ClusterDesc::getSubClusters (const vector<string>& parsetNames, - const string& defaultDir) - { - for (uint i=0; i<parsetNames.size(); ++i) { - // Expand possible ~ and $. - string name = Path(parsetNames[i]).expandedName(); - // Add directory of parent parset if name is not absolute. - if (name[0] != '/') { - name = defaultDir + '/' + name; - } - ClusterDesc cdesc(name); - const vector<NodeDesc>& nodes =cdesc.getNodes(); - for (uint j=0; j<nodes.size(); ++j) { - // The same nodes can occur in multiple subclusters. - addNode (nodes[j], true); - } - } - } - - void ClusterDesc::write (ostream& os) const - { - os << "ClusterName = " << itsName << endl; - os << "NNodes = " << itsNodes.size() << endl; - for (unsigned i=0; i<itsNodes.size(); ++i) { - ostringstream prefix; - prefix << "Node" << i << '.'; - itsNodes[i].write (os, prefix.str()); - } - } - - void ClusterDesc::addNode (const NodeDesc& node, bool canExist) - { - // Check if node name does not exist yet. - map<string,int>::const_iterator loc = itsNodeMap.find (node.getName()); - if (loc != itsNodeMap.end()) { - if (!canExist) { - THROW (MWError, "Node name " << node.getName() - << " multiply specified in clusterdesc " << itsName); - } - } else { - int inx = itsNodes.size(); - itsNodeMap[node.getName()] = inx; - itsNodes.push_back (node); - add2Map (inx); - } - } - - void ClusterDesc::add2Map (int nodeIndex) - { - const NodeDesc& node = itsNodes[nodeIndex]; - for (vector<string>::const_iterator iter = node.getFileSys().begin(); - iter != node.getFileSys().end(); - ++iter) { - vector<int>& vec = itsFS2Nodes[*iter]; - vec.push_back (nodeIndex); - } - } - - const NodeDesc& ClusterDesc::getNode (const string& nodeName) const - { - map<string,int>::const_iterator loc = itsNodeMap.find (nodeName); - if (loc == itsNodeMap.end()) { - THROW (MWError, "Node name " << nodeName - << " not found in clusterdesc " << itsName); - } - return itsNodes[loc->second]; - } - -// string ClusterDesc::findNode (const string& fileSystem, -// const map<string,int>& done) const -// { -// map<string,vector<string> >::const_iterator iter = -// itsFS2Nodes.find(fileSystem); -// if (iter == itsFS2Nodes.end()) { -// return ""; -// } -// const vector<string>& nodes = iter->second; -// for (unsigned i=0; i<nodes.size(); ++i) { -// if (done.find(nodes[i]) == done.end()) { -// return nodes[i]; -// } -// } -// return ""; -// } - -}} // end namespaces diff --git a/CEP/MWCommon/src/Controller.cc b/CEP/MWCommon/src/Controller.cc deleted file mode 100644 index e89eb52a351b150e63652af815f475f09fc4c4b1..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/Controller.cc +++ /dev/null @@ -1,223 +0,0 @@ -//# Controller.cc: Class to execute the master and workers -//# -//# Copyright (C) 2008 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> -#include <MWCommon/Controller.h> -#include <MWCommon/MemConnectionSet.h> -#include <MWCommon/SocketConnectionSet.h> -#include <MWCommon/MPIConnectionSet.h> -#include <MWCommon/WorkerControl.h> -#include <MWCommon/VdsDesc.h> -#include <MWCommon/MWError.h> -#include <MWCommon/MWIos.h> -#include <Common/LofarLogger.h> -#include <iostream> - -using namespace LOFAR::CEP; -using namespace LOFAR; -using namespace std; - -namespace LOFAR { namespace CEP { - - template<typename Runner> - Controller::Controller (const Runner& runner, - const string& clusterName, - const string& logFileName) - : itsRunner (runner), - itsClusterName (clusterName), - itsLogName (logFileName) - {} - - int Controller::execute() - { - return doExecute (string(), string(), 0, 0, true); - } - - int Controller::execute (const string& host, const string& port, - int nproc, int procRank) - { - return doExecute (host, port, nproc, procRank, false); - } - - int Controller::doExecute (const string& host, const string& port, - int nproc, int procRank, bool useMPI) - { - int status = 0; - try { - // Find nr of nodes (processes) and rank. - int nnode = 0; - int rank = 0; - if (useMPI) { - nnode = MPIConnection::getNrNodes(); - rank = MPIConnection::getRank(); - } - // If only one MPI node, we may run in a single process - // or in multiple processes connected via sockets (a port is given). - if (nnode <= 1 && !port.empty()) { - nnode = nproc; - rank = procRank; - } - { - // Set the name of the output stream. - std::ostringstream ostr; - ostr << rank; - MWIos::setName (itsLogName + ostr.str()); - } - // Open the parameter set and get nr of VDS parts. - VdsDesc dsDesc(itsRunner.getDataSetName()); - int nparts = dsDesc.getParts().size(); - // Find out if this process is master, globalWorker, or localWorker. - int globalWorkerRank = 0; - if (nnode > nparts+1) { - // The master and globalWorker can run on different nodes. - globalWorkerRank = 1; - } - // Initialize and run the controls. - if (rank == 0) { - runMaster (dsDesc, port, globalWorkerRank, nnode-1, nparts); - } else if (rank > globalWorkerRank) { - runLocalWorker (host, port); - } else { - runGlobalWorker (host, port); - } - } catch (std::exception& x) { - cerr << "Unexpected exception in Controller::doExecute: " - << x.what() << endl; - status = 1; - } - return status; - } - - void Controller::runMaster (const VdsDesc& dsDesc, - const string& port, - int globalWorkerRank, - int nworkers, int nparts) - { - // Get the full observation domain for this data set. - const VdsPartDesc& vdsDesc = dsDesc.getDesc(); - ObsDomain fullDomain; - fullDomain.setTime (vdsDesc.getStartTime(), - vdsDesc.getEndTime()); - fullDomain.setFreq (vdsDesc.getStartFreqs()[0], - vdsDesc.getEndFreqs()[vdsDesc.getNBand() - 1]); - // Setup connections for the localWorkers and globalWorkers. - MWConnectionSet::ShPtr workers; - // Set up the connection for all workers. - // Use socket connection if required, otherwise MPI connection if possible. - // If MPI is impossible, use memory connection for a localWorker per VDS part. - if (! port.empty()) { - SocketConnectionSet* workConns (new SocketConnectionSet(port)); - workers = MWConnectionSet::ShPtr (workConns); - workConns->addConnections (nworkers); - } else if (nworkers > 0) { - MPIConnectionSet* workConns (new MPIConnectionSet()); - workers = MWConnectionSet::ShPtr (workConns); - for (int i=0; i<nworkers; ++i) { - // A globalWorker has MPI tag 1. - int tag = (i>=globalWorkerRank ? 0:1); - workConns->addConnection (i+1, tag); - } - } else { - MemConnectionSet* workConns (new MemConnectionSet()); - workers = MWConnectionSet::ShPtr (workConns); - for (int i=0; i<nparts; ++i) { - workConns->addConnection (itsFactory.create("LocalWorker")); - } - } - // Find out what all remote workers can do. - // They send a message with their capabilities after the connection is made. - // So read from all workers and put in appropriate set. - setAllWorkers (*workers, nworkers); - // Check if there are enough localWorkers. - if (itsLocalWorkers->size() < nparts) { - THROW(MWError, "The Visibility Data Set is split into " - << nparts << " parts, so mwcontrol has to have at least " - << nparts+1 << " localWorkers, but only " - << itsLocalWorkers->size() << " are available"); - } - // Create the master control and initialize it. - MasterControl mc (itsLocalWorkers, itsGlobalWorkers); - // Send the initial info. - mc.setInitInfo (itsRunner.getParSet(), fullDomain); - // Let the caller execute. - itsRunner.run (mc); - mc.quit(); - } - - void Controller::runLocalWorker (const string& host, const string& port) - { - MWCOUT << "localWorker rank " << MPIConnection::getRank() << endl; - WorkerControl pc(itsFactory.create ("LocalWorker")); - // Connect to master on rank 0. - if (port.empty()) { - pc.init (MWConnection::ShPtr(new MPIConnection(0, 0))); - } else { - pc.init (MWConnection::ShPtr(new SocketConnection(host, port))); - } - pc.run(); - } - - void Controller::runGlobalWorker (const string& host, const string& port) - { - MWCOUT << "globalWorker rank " << MPIConnection::getRank() << endl; - WorkerControl sc(itsFactory.create ("GlobalWorker")); - // Connect to master on rank 0. - if (port.empty()) { - sc.init (MWConnection::ShPtr(new MPIConnection(0, 1))); - } else { - sc.init (MWConnection::ShPtr(new SocketConnection(host, port))); - } - sc.run(); - } - - void Controller::setAllWorkers (MWConnectionSet& workers, int nworkers) - { - // If there are no remote workers, just copy the workers to localWorkers. - if (nworkers == 0) { - itsLocalWorkers = workers.clone(); - } else { - vector<int> localInx; - vector<int> globalInx; - localInx.reserve (nworkers); - // We have to read from every worker and see what it can do. - BlobString buf; - for (int i=0; i<nworkers; ++i) { - workers.read (i, buf); - WorkerInfo info = WorkerProxy::getWorkerInfo (buf); - if (info.getWorkType() == 0) { - localInx.push_back(i); - } else { - globalInx.push_back(i); - } - } - itsLocalWorkers = workers.clone (localInx); - itsGlobalWorkers = workers.clone (globalInx); - } - // If there are no globalWorkers, make a globalWorker in the master process. - if (!itsGlobalWorkers || itsGlobalWorkers->size() == 0) { - MemConnectionSet* sv = new MemConnectionSet(); - itsGlobalWorkers = MWConnectionSet::ShPtr(sv); - sv->addConnection (itsFactory.create("GlobalWorker")); - } - } - -}} //# end namespaces diff --git a/CEP/MWCommon/src/ControllerBase.cc b/CEP/MWCommon/src/ControllerBase.cc deleted file mode 100644 index 07ad7186a73d36407e891f2a11892a36f3ed4375..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/ControllerBase.cc +++ /dev/null @@ -1,269 +0,0 @@ -//# ControllerBase.cc: Base class to execute the master and workers -//# -//# Copyright (C) 2008 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> -#include <MWCommon/ControllerBase.h> -#include <MWCommon/MemConnectionSet.h> -#include <MWCommon/SocketConnectionSet.h> -#include <MWCommon/MPIConnectionSet.h> -#include <MWCommon/WorkerControl.h> -#include <MWCommon/WorkersDesc.h> -#include <MWCommon/ClusterDesc.h> -#include <MWCommon/MWError.h> -#include <MWCommon/MWIos.h> -#include <Common/LofarLogger.h> -#include <iostream> - -using namespace LOFAR::CEP; -using namespace LOFAR; -using namespace std; - -namespace LOFAR { namespace CEP { - - ControllerBase::ControllerBase (const WorkerFactory& factory, - const ParameterSet& parSet, - const string& dsDescName, - const string& clusterName, - const string& logFileName) - : itsFactory (factory), - itsParSet (parSet), - itsDsDesc (dsDescName), - itsClusterName (clusterName), - itsLogName (logFileName) - {} - - ControllerBase::~ControllerBase() - {} - - int ControllerBase::execute() - { - return doExecute (string(), string(), 0, 0, true); - } - - int ControllerBase::execute (const string& host, const string& port, - int nproc, int procRank) - { - return doExecute (host, port, nproc, procRank, false); - } - - int ControllerBase::doExecute (const string& host, const string& port, - int nproc, int procRank, bool useMPI) - { - int status = 0; - try { - // Find nr of nodes (processes) and rank. - int nnode = 0; - int rank = 0; - if (useMPI) { - nnode = MPIConnection::getNrNodes(); - rank = MPIConnection::getRank(); - } - // If only one MPI node, we may run in a single process - // or in multiple processes connected via sockets. - // Find out from arguments. - if (nnode <= 1 && !port.empty()) { - nnode = nproc; - rank = procRank; - } - ASSERT (rank < nnode); - { - // Set the name of the output stream. - std::ostringstream ostr; - ostr << rank; - MWIos::setName (itsLogName + ostr.str()); - } - // Open the parameter set and get nr of VDS parts. - int nparts = itsDsDesc.getParts().size(); - // Find out if this process is master, globalWorker, or localWorker. - int globalWorkerRank = 0; - if (nnode > nparts+1) { - // More workers than data parts, so the master and globalWorker - // can run on different nodes. - globalWorkerRank = 1; - } - // Initialize and run the controls. - if (rank == 0) { - runMaster (port, globalWorkerRank, nnode-1, nparts); - } else if (rank > globalWorkerRank) { - runLocalWorker (host, port); - } else { - runGlobalWorker (host, port); - } - } catch (std::exception& x) { - cerr << "Unexpected exception in Controller::doExecute: " - << x.what() << endl; - status = 1; - } - return status; - } - - void ControllerBase::runMaster (const string& port, - int globalWorkerRank, - int nworkers, int nparts) - { - // Get the full observation domain for this data set. - const VdsPartDesc& vdsDesc = itsDsDesc.getDesc(); - ObsDomain fullDomain; - fullDomain.setTime (vdsDesc.getStartTime(), - vdsDesc.getEndTime()); - fullDomain.setFreq (vdsDesc.getStartFreqs()[0], - vdsDesc.getEndFreqs()[vdsDesc.getNBand() - 1]); - // Setup connections for the localWorkers and globalWorkers. - MWConnectionSet::ShPtr workers; - // Set up the connection for all workers. - // Use socket connection if required, otherwise MPI connection if possible. - // If MPI is impossible, use memory connection for a localWorker per - // data set part. - if (! port.empty()) { - SocketConnectionSet* workConns (new SocketConnectionSet(port)); - workers = MWConnectionSet::ShPtr (workConns); - workConns->addConnections (nworkers); - } else if (nworkers > 0) { - MPIConnectionSet* workConns (new MPIConnectionSet()); - workers = MWConnectionSet::ShPtr (workConns); - for (int i=0; i<nworkers; ++i) { - // A globalWorker has MPI tag 1. - int tag = (i>=globalWorkerRank ? 0:1); - workConns->addConnection (i+1, tag); - } - } else { - MemConnectionSet* workConns (new MemConnectionSet()); - workers = MWConnectionSet::ShPtr (workConns); - for (int i=0; i<nparts; ++i) { - workConns->addConnection (itsFactory.create("LocalWorker")); - } - } - // Find out what all remote workers can do. - // They send a message with their capabilities after the connection is made. - // So read from all workers and put in appropriate set. - // It returns a vector telling which data part is handled by local worker i. - vector<string> dataParts = setAllWorkers (*workers, nworkers); - // Check if there are enough localWorkers. - if (itsLocalWorkers->size() < nparts) { - THROW(MWError, "Data Set " << itsDsDesc.getDesc().getName() - << " is split into " << nparts << " parts, but only " - << itsLocalWorkers->size() << " localWorkers are available"); - } - // Create the master control and initialize it. - MasterControl mc (itsLocalWorkers, itsGlobalWorkers); - // Send the initial info. - mc.setInitInfo (itsParSet, dataParts, fullDomain); - // Let the the Runner execute. - run (mc); - // We have finished, so tell that all workers. - mc.quit(); - } - - void ControllerBase::runLocalWorker (const string& host, - const string& port) - { - MWCOUT << "localWorker rank " << MPIConnection::getRank() << endl; - WorkerControl pc(itsFactory.create ("LocalWorker")); - // Connect to master on rank 0. - if (port.empty()) { - pc.init (MWConnection::ShPtr(new MPIConnection(0, 0))); - } else { - pc.init (MWConnection::ShPtr(new SocketConnection(host, port))); - } - pc.run(); - } - - void ControllerBase::runGlobalWorker (const string& host, - const string& port) - { - MWCOUT << "globalWorker rank " << MPIConnection::getRank() << endl; - WorkerControl sc(itsFactory.create ("GlobalWorker")); - // Connect to master on rank 0. - if (port.empty()) { - sc.init (MWConnection::ShPtr(new MPIConnection(0, 1))); - } else { - sc.init (MWConnection::ShPtr(new SocketConnection(host, port))); - } - sc.run(); - } - - vector<string> ControllerBase::setAllWorkers (MWConnectionSet& workers, - int nworkers) - { - // Create the workers description object which will be used to - // determine which local worker to use for which data part. - WorkersDesc workDesc((ClusterDesc(itsClusterName))); - // If there are no remote workers (thus single process), - // all workers are localWorkers. - if (nworkers == 0) { - itsLocalWorkers = workers.clone(); - string host = SocketConnection::getHostName(); - vector<int> workTypes(1,0); - for (int i=0; i<itsLocalWorkers->size(); ++i) { - workDesc.addWorker (i, host, workTypes); - } - } else { - // The workers are remote. Find out what they can do. - vector<int> localInx; - vector<int> globalInx; - localInx.reserve (nworkers); - // We read the info from each worker. - BlobString buf; - for (int i=0; i<nworkers; ++i) { - workers.read (i, buf); - WorkerInfo info = WorkerProxy::getWorkerInfo (buf); - if (info.getWorkType() == 0) { - // Remember local workers in work desc. - workDesc.addWorker (localInx.size(), info.getHostName(), - info.getWorkTypes()); - localInx.push_back(i); - } else { - globalInx.push_back(i); - } - } - itsLocalWorkers = workers.clone (localInx); - itsGlobalWorkers = workers.clone (globalInx); - } - // If there are no globalWorkers, make a globalWorker in the master process. - if (!itsGlobalWorkers || itsGlobalWorkers->size() == 0) { - MemConnectionSet* sv = new MemConnectionSet(); - itsGlobalWorkers = MWConnectionSet::ShPtr(sv); - sv->addConnection (itsFactory.create("GlobalWorker")); - } - // Now find out which data part can be handled by which local worker - // by looking which worker has access to the data's file system. - const vector<VdsPartDesc> parts = itsDsDesc.getParts(); - // Initialize vector telling which data part is handled by a local worker. - vector<string> dataParts(parts.size()); - for (vector<VdsPartDesc>::const_iterator iter = parts.begin(); - iter != parts.end(); - ++iter) { - int inx = workDesc.findWorker (0, iter->getFileSys()); - // We do not accept that a worker gets more than one data part. - if (inx < 0 || !dataParts[inx].empty()) { - THROW (MWError, "No suitable worker could be found" << - " to process dataset part " << iter->getName() << - " on file system " << iter->getFileSys()); - } - // Tell this worker has something to do. - workDesc.incrLoad (inx); - dataParts[inx] = iter->getName(); // data part i handled by worker inx - } - return dataParts; - } - -}} //# end namespaces diff --git a/CEP/MWCommon/src/DomainShape.cc b/CEP/MWCommon/src/DomainShape.cc deleted file mode 100644 index f554366fa70ae2c9c011d5f4059f7996bbcbf11e..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/DomainShape.cc +++ /dev/null @@ -1,60 +0,0 @@ -//# DomainShape.cc: Define the shape of a domain -//# -//# Copyright (c) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/DomainShape.h> - -namespace LOFAR { namespace CEP { - - DomainShape::DomainShape() - : itsFreqSize (1e30), - itsTimeSize (1e30) - {} - - DomainShape::DomainShape (double freqSize, double timeSize) - : itsFreqSize (freqSize), - itsTimeSize (timeSize) - {} - - LOFAR::BlobOStream& operator<< (LOFAR::BlobOStream& bs, - const DomainShape& ds) - { - bs << ds.itsFreqSize << ds.itsTimeSize; - return bs; - } - - LOFAR::BlobIStream& operator>> (LOFAR::BlobIStream& bs, - DomainShape& ds) - { - bs >> ds.itsFreqSize >> ds.itsTimeSize; - return bs; - } - - std::ostream& operator<< (std::ostream& os, - const DomainShape& ds) - { - os << ds.itsFreqSize << " Hz, " << ds.itsTimeSize << " s"; - return os; - } - -}} // end namespaces diff --git a/CEP/MWCommon/src/MPIConnection.cc b/CEP/MWCommon/src/MPIConnection.cc deleted file mode 100644 index 9917cbed32b0cae4ecc47edfd0228490da4a1990..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/MPIConnection.cc +++ /dev/null @@ -1,173 +0,0 @@ -//# MPIConnection.cc: Connection to workers based on MPI -//# -//# Copyright (c) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/MPIConnection.h> -#include <MWCommon/MWError.h> - -#ifdef HAVE_MPI -# include <mpi.h> -#endif - -#include <iostream> -using namespace std; - -namespace LOFAR { namespace CEP { - - MPIConnection::MPIConnection (int destinationRank, int tag) - : itsDestRank (destinationRank), - itsTag (tag) - {} - - MPIConnection::~MPIConnection() - {} - - -#ifdef HAVE_MPI - - int MPIConnection::getMessageLength() - { - int result = MPI_SUCCESS; - MPI_Status status; - result = MPI_Probe (itsDestRank, itsTag, MPI_COMM_WORLD, &status); - int size; - MPI_Get_count (&status, MPI_BYTE, &size); - return size; - } - - void MPIConnection::receive (void* buf, unsigned size) - { - //cout << "MPI receive " << size << " bytes on rank " << getRank() - // << " from rank " << itsDestRank << ", tag " << itsTag << endl; - int result = MPI_SUCCESS; - MPI_Status status; - result = MPI_Recv (buf, size, MPI_BYTE, - itsDestRank, itsTag, MPI_COMM_WORLD, &status); - if (result != MPI_SUCCESS) { - THROW (MWError, "MPIConnection::receive on rank " << getRank() - << " failed: " << size << " bytes from rank " << itsDestRank - << " using tag " << itsTag); - } - } - - void MPIConnection::send (const void* buf, unsigned size) - { - //cout << "MPI send " << size << " bytes on rank " << getRank() - // << " to rank " << itsDestRank << ", tag " << itsTag << endl; - int result = MPI_SUCCESS; - result = MPI_Send (const_cast<void*>(buf), size, MPI_BYTE, - itsDestRank, itsTag, MPI_COMM_WORLD); - if (result != MPI_SUCCESS) { - THROW (MWError, "MPIConnection::send on rank " << getRank() - << " failed: " << size << " bytes to rank " << itsDestRank - << " using tag " << itsTag); - } - } - - bool MPIConnection::isConnected() const - { - return true; - } - - void MPIConnection::initMPI (int argc, const char**& argv) - { - // Only initialize if not done yet. - int initialized = 0; - MPI_Initialized (&initialized); - if (!initialized) { - MPI_Init (&argc, &const_cast<char**&>(argv)); - } - } - - void MPIConnection::endMPI() - { - // Only finalize if not done yet. - int finalized = 0; - MPI_Finalized (&finalized); - if (!finalized) { - MPI_Finalize(); - } - } - - int MPIConnection::getRank() - { - int rank; - MPI_Comm_rank (MPI_COMM_WORLD, &rank); - return rank; - } - - int MPIConnection::getNrNodes() - { - int size; - MPI_Comm_size (MPI_COMM_WORLD, &size); - return size; - } - - -#else - - - int MPIConnection::getMessageLength() - { - THROW (MWError, "MPIConnection::getMessageLength cannot be used: " - "configured without MPI"); - } - - void MPIConnection::receive (void*, unsigned) - { - THROW (MWError, "MPIConnection::receive cannot be used: " - "configured without MPI"); - } - - void MPIConnection::send (const void*, unsigned) - { - THROW (MWError, "MPIConnection::send cannot be used: " - "configured without MPI"); - } - - bool MPIConnection::isConnected() const - { - return false; - } - - void MPIConnection::initMPI (int, const char**&) - {} - - void MPIConnection::endMPI() - {} - - int MPIConnection::getRank() - { - return 0; - } - - int MPIConnection::getNrNodes() - { - return 1; - } - - -#endif - - -}} // end namespaces diff --git a/CEP/MWCommon/src/MPIConnectionSet.cc b/CEP/MWCommon/src/MPIConnectionSet.cc deleted file mode 100644 index 67c969d4ea76a1dafba43ae195d44142ff515b0f..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/MPIConnectionSet.cc +++ /dev/null @@ -1,88 +0,0 @@ -//# MPIConnectionSet.cc: Set of MPI connections -//# -//# Copyright (c) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/MPIConnectionSet.h> -#include <MWCommon/MWError.h> -#include <Common/LofarLogger.h> - -namespace LOFAR { namespace CEP { - - MPIConnectionSet::MPIConnectionSet() - {} - - MPIConnectionSet::~MPIConnectionSet() - {} - - MWConnectionSet::ShPtr - MPIConnectionSet::clone (const std::vector<int>& inx) const - { - int nrconn = size(); - MPIConnectionSet* set = new MPIConnectionSet(); - MWConnectionSet::ShPtr mwset(set); - for (std::vector<int>::const_iterator it=inx.begin(); - it!=inx.end(); - ++it) { - int i = *it; - ASSERT (i>=0 && i<nrconn); - set->itsConns.push_back (itsConns[i]); - } - return mwset; - } - - int MPIConnectionSet::addConnection (int rank, int tag) - { - int seqnr = itsConns.size(); - MPIConnection::ShPtr ptr(new MPIConnection (rank, tag)); - itsConns.push_back (ptr); - return seqnr; - } - - int MPIConnectionSet::size() const - { - return itsConns.size(); - } - - int MPIConnectionSet::getReadyConnection() - { - return -1; - } - - void MPIConnectionSet::read (int seqnr, LOFAR::BlobString& buf) - { - itsConns[seqnr]->read (buf); - } - - void MPIConnectionSet::write (int seqnr, const LOFAR::BlobString& buf) - { - itsConns[seqnr]->write (buf); - } - - void MPIConnectionSet::writeAll (const LOFAR::BlobString& buf) - { - for (unsigned i=0; i<itsConns.size(); ++i) { - itsConns[i]->write (buf); - } - } - -}} // end namespaces diff --git a/CEP/MWCommon/src/MWBlobIO.cc b/CEP/MWCommon/src/MWBlobIO.cc deleted file mode 100644 index 39d10efdad0c0b2caf2c1753fee96e51404f8182..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/MWBlobIO.cc +++ /dev/null @@ -1,86 +0,0 @@ -//# MWBlobIO.cc: -//# -//# Copyright (c) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - - -#include <MWCommon/MWBlobIO.h> -#include <MWCommon/MWError.h> -#include <Blob/BlobOStream.h> -#include <Blob/BlobIStream.h> - -namespace LOFAR { namespace CEP { - - MWBlobOut::MWBlobOut (LOFAR::BlobString& buf, int operation, int streamId, - int workerId) - : itsBuf (buf), - itsStream (itsBuf) - { - itsStream.putStart ("mw", 1); - itsOperOffset = buf.size(); - itsStream << static_cast<LOFAR::int32>(operation) - << static_cast<LOFAR::int32>(streamId) - << static_cast<LOFAR::int32>(workerId); - ASSERT (buf.size() == itsOperOffset + 3*sizeof(LOFAR::int32)); - itsTimeOffset = buf.size(); - // Put empty times. They will be set later by setTimes. - itsStream << float(0) << float(0) << float(0) << double(0); - ASSERT (buf.size() == itsTimeOffset - + 3*sizeof(float) + sizeof(double)); - } - - void MWBlobOut::setOperation (int operation) - { - using LOFAR::uchar; - LOFAR::int32 oper = operation; - uchar* ptr = const_cast<uchar*>(itsBuf.getBuffer()) + itsOperOffset; - // Use memcpy, because in buffer it might be unaligned. - memcpy (ptr, &oper, sizeof(LOFAR::int32)); - } - - void MWBlobOut::setTimes (const casa::Timer& low, const LOFAR::NSTimer& high) - { - using LOFAR::uchar; - float t[3]; - t[0] = low.real(); - t[1] = low.system(); - t[2] = low.user(); - uchar* ptr = const_cast<uchar*>(itsBuf.getBuffer()) + itsTimeOffset; - // Use memcpy, because in buffer it might be unaligned. - memcpy (ptr, t, 3*sizeof(float)); - double d = high.getElapsed(); - memcpy (ptr + 3*sizeof(float), &d, sizeof(double)); - } - - - MWBlobIn::MWBlobIn (const LOFAR::BlobString& buf) - : itsBuf (buf), - itsStream (itsBuf) - { - int version = itsStream.getStart ("mw"); - ASSERT (version==1); - itsStream >> itsOper >> itsStreamId >> itsWorkerId - >> itsElapsedTime >> itsSystemTime >> itsUserTime >> itsPrecTime; - } - - -}} //end namespaces diff --git a/CEP/MWCommon/src/MWConnection.cc b/CEP/MWCommon/src/MWConnection.cc deleted file mode 100644 index 7fe1a9418c684c36ac3894bb8cfa041948eb1f77..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/MWConnection.cc +++ /dev/null @@ -1,67 +0,0 @@ -//# MWConnection.cc: Abstract base class for all MWConnections -//# -//# Copyright (c) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/MWConnection.h> -#include <Blob/BlobString.h> -#include <Blob/BlobHeader.h> - - -namespace LOFAR { namespace CEP { - - MWConnection::~MWConnection() - {} - - void MWConnection::init() - {} - - bool MWConnection::isConnected() const - { - return true; - } - - void MWConnection::read (LOFAR::BlobString& buf) - { - // Try to get the length of the message. - // If it succeeds, read the data. - int msgLen = getMessageLength(); - if (msgLen > 0) { - buf.resize (msgLen); - receive (buf.data(), msgLen); - } else { - // Otherwise read blob header first to get the length. - LOFAR::BlobHeader hdr; - receive (&hdr, sizeof(hdr)); - msgLen = hdr.getLength(); - buf.resize (msgLen); - memcpy (buf.data(), &hdr, sizeof(hdr)); - receive (buf.data() + sizeof(hdr), msgLen-sizeof(hdr)); - } - } - - void MWConnection::write (const LOFAR::BlobString& buf) - { - send (buf.data(), buf.size()); - } - -}} // end namespaces diff --git a/CEP/MWCommon/src/MWConnectionSet.cc b/CEP/MWCommon/src/MWConnectionSet.cc deleted file mode 100644 index 98128c40cbdbd985d4645ca5f70ccbf8d8f7385e..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/MWConnectionSet.cc +++ /dev/null @@ -1,44 +0,0 @@ -//# MWConnectionSet.cc: Abstract base class for all MWConnectionSets -//# -//# Copyright (c) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/MWConnectionSet.h> - -namespace LOFAR { namespace CEP { - - MWConnectionSet::~MWConnectionSet() - {} - - MWConnectionSet::ShPtr MWConnectionSet::clone() const - { - // Clone all connections, so fill a vector with all indices. - std::vector<int> inx; - int nr = size(); - inx.resize(nr); - for (int i=0; i<nr; ++i) { - inx[i] = i; - } - return clone(inx); - } - -}} // end namespaces diff --git a/CEP/MWCommon/src/MWGlobalStep.cc b/CEP/MWCommon/src/MWGlobalStep.cc deleted file mode 100644 index 7a9fb65cf2c43b5c3e5d8b148b504f471b8319e7..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/MWGlobalStep.cc +++ /dev/null @@ -1,37 +0,0 @@ -//# MWGlobalStep.cc: Base classes for global MW commands -//# -//# Copyright (c) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/MWGlobalStep.h> - -namespace LOFAR { namespace CEP { - - MWGlobalStep::~MWGlobalStep() - {} - - void MWGlobalStep::visit (MWStepVisitor& visitor) const - { - visitor.visitGlobal (*this); - } - -}} // end namespaces diff --git a/CEP/MWCommon/src/MWIos.cc b/CEP/MWCommon/src/MWIos.cc deleted file mode 100644 index 3b6273a7fbca440120454496e29e6d9f0ea66392..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/MWIos.cc +++ /dev/null @@ -1,39 +0,0 @@ -//# MWIos.cc: -//# -//# Copyright (C) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/MWIos.h> - -namespace LOFAR { namespace CEP { - - std::string MWIos::itsName = std::string("pgm.out"); - std::ofstream* MWIos::itsIos = 0; - - void MWIos::makeIos() - { - delete itsIos; - itsIos = 0; - itsIos = new std::ofstream (itsName.c_str()); - } - -}} // end namespaces diff --git a/CEP/MWCommon/src/MWLocalStep.cc b/CEP/MWCommon/src/MWLocalStep.cc deleted file mode 100644 index c6fcb702a13f2e6d3b8b57dfe4a5cc713a87eba5..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/MWLocalStep.cc +++ /dev/null @@ -1,37 +0,0 @@ -//# MWLocalStep.cc: Base classes for local MW commands -//# -//# Copyright (c) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/MWLocalStep.h> - -namespace LOFAR { namespace CEP { - - MWLocalStep::~MWLocalStep() - {} - - void MWLocalStep::visit (MWStepVisitor& visitor) const - { - visitor.visitLocal (*this); - } - -}} // end namespaces diff --git a/CEP/MWCommon/src/MWMultiStep.cc b/CEP/MWCommon/src/MWMultiStep.cc deleted file mode 100644 index b15d094b69ff05ee83fbea0e709a4dd4b01aa8ad..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/MWMultiStep.cc +++ /dev/null @@ -1,108 +0,0 @@ -//# MWMultiStep.cc: A step consisting of several other steps. -//# -//# Copyright (c) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/MWMultiStep.h> -#include <MWCommon/MWStepFactory.h> -#include <MWCommon/MWError.h> -#include <Common/LofarLogger.h> - -using namespace LOFAR; - -namespace LOFAR { namespace CEP { - - MWMultiStep::~MWMultiStep() - {} - - MWMultiStep* MWMultiStep::clone() const - { - return new MWMultiStep(*this); - } - - void MWMultiStep::push_back (const MWStep& step) - { - itsSteps.push_back (MWStep::ShPtr(step.clone())); - } - - void MWMultiStep::push_back (const MWStep::ShPtr& step) - { - itsSteps.push_back (step); - } - - MWStep::ShPtr MWMultiStep::create() - { - return MWStep::ShPtr (new MWMultiStep()); - } - - void MWMultiStep::registerCreate() - { - MWStepFactory::push_back ("MWMultiStep", &create); - } - - std::string MWMultiStep::className() const - { - static std::string name("MWMultiStep"); - return name; - } - - void MWMultiStep::visit (MWStepVisitor& visitor) const - { - visitor.visitMulti (*this); - } - - void MWMultiStep::toBlob (BlobOStream& bs) const - { - bs.putStart ("MWMultiStep", 1); - bs << static_cast<uint32>(itsSteps.size()); - for (std::list<MWStep::ShPtr>::const_iterator iter=itsSteps.begin(); - iter!=itsSteps.end(); - ++iter) { - (*iter)->toBlob (bs); - } - bs.putEnd(); - } - - void MWMultiStep::fromBlob (BlobIStream& bs) - { - int vers = bs.getStart ("MWMultiStep"); - ASSERT (vers == 1); - uint32 nr; - bs >> nr; - for (uint32 i=0; i<nr; ++i) { - MWStep::ShPtr step = MWStepFactory::create (bs.getNextType()); - step->fromBlob (bs); - itsSteps.push_back (step); - } - bs.getEnd(); - } - - void MWMultiStep::print (ostream& os, const string& indent) const - { - for (std::list<MWStep::ShPtr>::const_iterator iter=itsSteps.begin(); - iter!=itsSteps.end(); - ++iter) { - (*iter)->print (os, indent+". "); - } - } - -}} // end namespaces diff --git a/CEP/MWCommon/src/MWStep.cc b/CEP/MWCommon/src/MWStep.cc deleted file mode 100644 index cb9ec6d0b3e95740d5b6ad88ecd66c720c3a0f1f..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/MWStep.cc +++ /dev/null @@ -1,45 +0,0 @@ -//# MWStep.cc: Step to process the MW commands -//# -//# Copyright (c) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/MWStep.h> - -namespace LOFAR { namespace CEP { - - MWStep::~MWStep() - {} - - ParameterSet MWStep::getParms() const - { - return ParameterSet(); - } - - void MWStep::visit (MWStepVisitor& visitor) const - { - visitor.visit (*this); - } - - void MWStep::print (std::ostream&, const std::string&) const - {} - -}} // end namespaces diff --git a/CEP/MWCommon/src/MWStepFactory.cc b/CEP/MWCommon/src/MWStepFactory.cc deleted file mode 100644 index 2db50d581f043842b414a768b8a663b2ea6b3aaf..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/MWStepFactory.cc +++ /dev/null @@ -1,47 +0,0 @@ -//# MWStepFactory.cc: Factory pattern to make the correct MWStep object -//# -//# Copyright (c) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/MWStepFactory.h> -#include <MWCommon/MWError.h> -#include <Common/LofarLogger.h> - -namespace LOFAR { namespace CEP { - - std::map<std::string, MWStepFactory::Creator*> MWStepFactory::itsMap; - - - void MWStepFactory::push_back (const std::string& name, Creator* creator) - { - itsMap[name] = creator; - } - - MWStep::ShPtr MWStepFactory::create (const std::string& name) - { - std::map<std::string,Creator*>::const_iterator iter = itsMap.find(name); - ASSERTSTR (iter != itsMap.end(), - "MWStep " << name << " is unknown"); - return (*iter->second)(); - } - -}} // end namespaces diff --git a/CEP/MWCommon/src/MWStepVisitor.cc b/CEP/MWCommon/src/MWStepVisitor.cc deleted file mode 100644 index e97f2150c7d4f599204c720373a8b4eac8461d64..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/MWStepVisitor.cc +++ /dev/null @@ -1,79 +0,0 @@ -//# MWStepVisitor.cc: Base visitor class to visit an MWStep hierarchy -//# -//# Copyright (c) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/MWStepVisitor.h> -#include <MWCommon/MWMultiStep.h> -#include <MWCommon/MWGlobalStep.h> -#include <MWCommon/MWLocalStep.h> -#include <MWCommon/MWError.h> - -namespace LOFAR { namespace CEP { - - MWStepVisitor::~MWStepVisitor() - {} - - void MWStepVisitor::registerVisit (const std::string& name, VisitFunc* func) - { - itsMap[name] = func; - } - - void MWStepVisitor::visitMulti (const MWMultiStep& mws) - { - for (MWMultiStep::const_iterator it = mws.begin(); - it != mws.end(); - ++it) { - (*it)->visit (*this); - } - } - - void MWStepVisitor::visitGlobal (const MWGlobalStep& step) - { - THROW (MWError, "No visitGlobal function available for MWStep of type " - << step.className()); - } - - void MWStepVisitor::visitLocal (const MWLocalStep& step) - { - THROW (MWError, "No visitLocal function available for MWStep of type " - << step.className()); - } - - void MWStepVisitor::visit (const MWStep& step) - { - std::string name = step.className(); - std::map<std::string,VisitFunc*>::const_iterator iter = itsMap.find(name); - if (iter == itsMap.end()) { - visitStep (step); - } else { - (*iter->second)(*this, step); - } - } - - void MWStepVisitor::visitStep (const MWStep& step) - { - THROW (MWError, "No visit function available for MWStep of type " - << step.className()); - } - -}} // end namespaces diff --git a/CEP/MWCommon/src/MasterControl.cc b/CEP/MWCommon/src/MasterControl.cc deleted file mode 100644 index 1b3f9e07df730253c0d8f8f906540ad753fc421a..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/MasterControl.cc +++ /dev/null @@ -1,209 +0,0 @@ -//# MasterControl.cc: Master controller of distributed VDS processing -//# -//# Copyright (c) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/MasterControl.h> -#include <MWCommon/MWGlobalStep.h> -#include <MWCommon/MWLocalStep.h> -#include <MWCommon/MWBlobIO.h> - -using namespace std; - - -namespace LOFAR { namespace CEP { - - std::ostream& operator<<(std::ostream& os, MasterControl::Operation op) - { - switch(op) { - case MasterControl::Init: - os << string("Init: Initialize"); - break; - case MasterControl::SetWd: - os << string("SetWd: Set working domain"); - break; - case MasterControl::Step: - os << string("Step: Process a step"); - break; - case MasterControl::GlobalInit: - os << string("GlobalInit: Global initial step info"); - break; - case MasterControl::GlobalInfo: - os << string("GlobalInfo: Get all global iteration info"); - break; - case MasterControl::GlobalExec: - os << string("GlobalExec: Execute global iteration"); - break; - case MasterControl::EndWd: - os << string("EndWd: End processing working domain"); - break; - } - return os; - }; - - MasterControl::MasterControl (const MWConnectionSet::ShPtr& localWorkers, - const MWConnectionSet::ShPtr& globalWorkers) - : itsLocalWorkers (localWorkers), - itsGlobalWorkers (globalWorkers) - {} - - MasterControl::~MasterControl() - {} - - void MasterControl::setInitInfo (const ParameterSet& parms, - const vector<string>& dataPartNames, - const ObsDomain& fullDomain) - { - itsFullDomain = fullDomain; - // Fill the DataHolder as much as possible. - LOFAR::BlobString buf; - int workerId = 0; - for (int i=0; i<itsLocalWorkers->size(); ++i) { - buf.resize (0); - MWBlobOut out(buf, MasterControl::Init, 0, workerId); - out.blobStream() << parms << dataPartNames[i]; - out.finish(); - itsLocalWorkers->write (i, buf); - ++workerId; - } - for (int i=0; i<itsGlobalWorkers->size(); ++i) { - buf.resize (0); - MWBlobOut out(buf, MasterControl::Init, 0, workerId); - out.blobStream() << parms << ""; - out.finish(); - itsGlobalWorkers->write (i, buf); - ++workerId; - } - // Now read the replies back. They contain no info, but merely show - // the worker is alive. - readAllWorkers (true, true); - } - - void MasterControl::setWorkDomainSpec (const WorkDomainSpec& wds) - { - itsWds = wds; - } - - void MasterControl::processSteps (const MWStep& step) - { - // Iterate through the full observation domain. - ObsDomain workDomain; - while (itsFullDomain.getNextWorkDomain (workDomain, itsWds.getShape())) { - // Send WorkDomain to all localWorkers and globalWorker. - LOFAR::BlobString buf; - MWBlobOut out(buf, MasterControl::SetWd, 0); - out.blobStream() << workDomain; - out.finish(); - itsLocalWorkers->writeAll (buf); - itsGlobalWorkers->writeAll (buf); - readAllWorkers (true, true); - // Iterate through all steps and execute them. - step.visit (*this); - } - } - - void MasterControl::quit() - { - // Send an end command. - LOFAR::BlobString buf; - MWBlobOut out(buf, -1, 0); - out.finish(); - itsLocalWorkers->writeAll (buf); - itsGlobalWorkers->writeAll (buf); - } - - void MasterControl::visitGlobal (const MWGlobalStep& step) - { - // Send the global step info to all localWorkers and globalWorker. - LOFAR::BlobString buf; - { - // Write command into buffer. - MWBlobOut out (buf, MasterControl::Step, 0); - step.toBlob (out.blobStream()); - out.finish(); - } - itsLocalWorkers->writeAll (buf); - itsGlobalWorkers->write (0, buf); - // Read reply back from globalWorker. - itsGlobalWorkers->read (0, buf); - // Read the reply back from each localWorker and send that to the globalWorker. - for (int i=0; i<itsLocalWorkers->size(); ++i) { - itsLocalWorkers->read (i, buf); - itsGlobalWorkers->write (0, buf); - } - // Iterate as long as the globalWorker has not converged. - bool converged = false; - while (!converged) { - // Tell localWorkers to form the equations. - buf.resize (0); - { - MWBlobOut out (buf, MasterControl::GlobalInfo, 0); - out.finish(); - } - itsLocalWorkers->writeAll (buf); - // Read the reply back from each localWorker and send that to the globalWorker. - for (int i=0; i<itsLocalWorkers->size(); ++i) { - itsLocalWorkers->read (i, buf); - itsGlobalWorkers->write (0, buf); - } - // Tell the globalWorker to do the solve, get the solution and send that - // to each localWorker. - buf.resize (0); - { - MWBlobOut out (buf, MasterControl::GlobalExec, 0); - out.finish(); - } - itsGlobalWorkers->write (0, buf); - itsGlobalWorkers->read (0, buf); - itsLocalWorkers->writeAll (buf); - // Interpret the result to see if we have converged. - MWBlobIn bin(buf); - bin.blobStream() >> converged; - } - } - - void MasterControl::visitLocal (const MWLocalStep& step) - { - LOFAR::BlobString buf; - MWBlobOut out (buf, MasterControl::Step, 0); - step.toBlob (out.blobStream()); - out.finish(); - itsLocalWorkers->writeAll (buf); - readAllWorkers (true, false); - } - - void MasterControl::readAllWorkers (bool localWorkers, bool globalWorkers) - { - LOFAR::BlobString buf; - if (localWorkers) { - for (int i=0; i<itsLocalWorkers->size(); ++i) { - itsLocalWorkers->read (i, buf); - } - } - if (globalWorkers) { - for (int i=0; i<itsGlobalWorkers->size(); ++i) { - itsGlobalWorkers->read (i, buf); - } - } - } - -}} // end namespaces diff --git a/CEP/MWCommon/src/MemConnection.cc b/CEP/MWCommon/src/MemConnection.cc deleted file mode 100644 index 10c4c4051df21ed071c11fd8be0f7be610824d21..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/MemConnection.cc +++ /dev/null @@ -1,67 +0,0 @@ -//# MemConnection.cc: Memory connection to a worker -//# -//# Copyright (c) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/MemConnection.h> -#include <MWCommon/MWError.h> -#include <Common/LofarLogger.h> - -namespace LOFAR { namespace CEP { - - MemConnection::MemConnection (const WorkerProxy::ShPtr& worker) - : itsWorker (worker) - {} - - MemConnection::~MemConnection() - {} - - int MemConnection::getMessageLength() - { - ASSERTSTR (itsResult.size() > 0, - "MemConnection: no result has been received"); - return itsResult.size(); - } - - void MemConnection::receive (void* buf, unsigned size) - { - ASSERT (itsResult.size() == size); - memcpy (buf, itsResult.data(), size); - // Clear buffer to make sure data cannot be read twice. - itsResult.resize (0); - } - - void MemConnection::write (const LOFAR::BlobString& data) - { - // Internal buffer must be empty, otherwise no read was done. - ASSERTSTR (itsResult.size() == 0, - "MemConnection: received result has not been read"); - // Let the worker process the data and keep its result. - itsWorker->handleMessage (data, itsResult); - } - - void MemConnection::send (const void*, unsigned) - { - THROW (MWError, "MemConnection::send should not be called"); - } - -}} // end namespaces diff --git a/CEP/MWCommon/src/MemConnectionSet.cc b/CEP/MWCommon/src/MemConnectionSet.cc deleted file mode 100644 index 460fc3a5c3b714c4986df884ceb5b3ed0b30abf2..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/MemConnectionSet.cc +++ /dev/null @@ -1,88 +0,0 @@ -//# MemConnectionSet.cc: Set of Memory connections -//# -//# Copyright (c) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/MemConnectionSet.h> -#include <MWCommon/MWError.h> -#include <Common/LofarLogger.h> - - -namespace LOFAR { namespace CEP { - - MemConnectionSet::MemConnectionSet() - {} - - MemConnectionSet::~MemConnectionSet() - {} - - MWConnectionSet::ShPtr - MemConnectionSet::clone (const std::vector<int>& inx) const - { - int nrconn = size(); - MemConnectionSet* set = new MemConnectionSet(); - MWConnectionSet::ShPtr mwset(set); - for (std::vector<int>::const_iterator it=inx.begin(); - it!=inx.end(); - ++it) { - int i = *it; - ASSERT (i>=0 && i<nrconn); - set->itsConns.push_back (itsConns[i]); - } - return mwset; - } - - int MemConnectionSet::addConnection (const WorkerProxy::ShPtr& worker) - { - int seqnr = itsConns.size(); - itsConns.push_back (MemConnection::ShPtr (new MemConnection(worker))); - return seqnr; - } - - int MemConnectionSet::size() const - { - return itsConns.size(); - } - - int MemConnectionSet::getReadyConnection() - { - return -1; - } - - void MemConnectionSet::read (int seqnr, LOFAR::BlobString& buf) - { - itsConns[seqnr]->read (buf); - } - - void MemConnectionSet::write (int seqnr, const LOFAR::BlobString& buf) - { - itsConns[seqnr]->write (buf); - } - - void MemConnectionSet::writeAll (const LOFAR::BlobString& buf) - { - for (unsigned i=0; i<itsConns.size(); ++i) { - itsConns[i]->write (buf); - } - } - -}} // end namespaces diff --git a/CEP/MWCommon/src/NodeDesc.cc b/CEP/MWCommon/src/NodeDesc.cc deleted file mode 100644 index a6f1d204024e16ff549d03ddf7ded96dac00a7c7..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/NodeDesc.cc +++ /dev/null @@ -1,142 +0,0 @@ -//# NodeDesc.cc: Description of a node -//# -//# Copyright (C) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ -//# -//# @author Ger van Diepen <diepen AT astron nl> - -#include <lofar_config.h> - -#include <MWCommon/NodeDesc.h> -#include <Common/StreamUtil.h> -#include <Common/StringUtil.h> -#include <Common/LofarLogger.h> -#include <ostream> - -namespace std { - using LOFAR::operator<<; -} -using namespace std; - -namespace LOFAR { namespace CEP { - - NodeDesc::NodeDesc (const ParameterSet& parset) - { - itsName = parset.getString ("NodeName"); - string type (toLower (parset.getString ("NodeType", "Compute"))); - if (type == "compute") { - itsType = Compute; - } else if (type == "storage") { - itsType = Storage; - } else if (type == "head") { - itsType = Head; - } else { - itsType = Any; - } - itsMounts = parset.getStringVector ("NodeMountPoints", true); - itsFileSys = parset.getStringVector ("NodeFileSys", itsMounts, true); - ASSERT (itsFileSys.size() == itsMounts.size()); - for (uint i=0; i<itsMounts.size(); ++i) { - ASSERT (itsFileSys[i].size() > 0); - ASSERT (itsMounts[i].size() > 0 && itsMounts[i][0] == '/'); - } - } - - void NodeDesc::addFileSys (const string& fsName, - const string& mountPoint) - { - ASSERT (fsName.size() > 0); - string mp(mountPoint); - if (mp.size() > 5 && mp.substr(0,5) == "/auto") { - mp = mp.substr(5); - } - ASSERT (mp.size() > 0 && mp[0] == '/'); - itsFileSys.push_back (fsName); - itsMounts.push_back (mp); - } - - string NodeDesc::findFileSys (const string& fileName) const - { - // The file name must be absolute. - ASSERT (fileName.size() > 1 && fileName[0] == '/'); - // Determine the max nr of parts in the mount point. - // Remember the root filesys (a single /). - int nrp = 0; - int rootfs = -1; - for (uint i=0; i<itsMounts.size(); ++i) { - int nr=0; - const string& str = itsMounts[i]; - // A single / counts as no part. - if (str.size() == 1) { - rootfs = i; - } else { - for (uint j=0; j<str.size(); ++j) { - if (str[j] == '/') { - ++nr; - } - } - } - if (nr > nrp) { - nrp = nr; - } - } - // Find the slashes in the file name for each part. - vector<int> pos(nrp, -1); - int nr = 0; - for (uint i=1; i<fileName.size() && nr<nrp; ++i) { - if (fileName[i] == '/') { - pos[nr++] = i; - } - } - // Now compare if it matches the file name. - // Start with the longest possible string. - for (int p=nr-1; p>=0; --p) { - string filePart = fileName.substr(0,pos[p]); - for (uint i=0; i<itsMounts.size(); ++i) { - if (filePart == itsMounts[i]) { - return itsFileSys[i]; - } - } - } - // No match, so return root file system if there. - // Otherwise return empty string. - if (rootfs >= 0) { - return itsFileSys[rootfs]; - } - return ""; - } - - void NodeDesc::write (ostream& os, const string& prefix) const - { - string type = "Any"; - if (itsType == Compute) { - type = "Compute"; - } else if (itsType == Storage) { - type = "Storage"; - } else if (itsType == Head) { - type = "Head"; - } - os << prefix << "NodeName = " << itsName << endl; - os << prefix << "NodeType = " << type << endl; - os << prefix << "NodeFileSys = " << itsFileSys << endl; - os << prefix << "NodeMountPoints = " << itsMounts << endl; - } - -}} // end namespaces diff --git a/CEP/MWCommon/src/ObsDomain.cc b/CEP/MWCommon/src/ObsDomain.cc deleted file mode 100644 index 2bd5bb204f331a629964438eb5507ecd559d95ae..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/ObsDomain.cc +++ /dev/null @@ -1,117 +0,0 @@ -//# ObsDomain.cc: Define the shape of a domain -//# -//# Copyright (c) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/ObsDomain.h> - -namespace LOFAR { namespace CEP { - - ObsDomain::ObsDomain() - : itsStartFreq (-1), - itsEndFreq (1e30), - itsStartTime (-1), - itsEndTime (1e30) - {} - - ObsDomain::ObsDomain (const ObsDomain& fullDomain, - const DomainShape& workDomainShape) - { - // Construct the first work domain from the full observation domain - // and the work domain shape. - double freqLen = workDomainShape.getFreqSize(); - double timeLen = workDomainShape.getTimeSize(); - itsStartFreq = fullDomain.getStartFreq(); - itsEndFreq = std::min(fullDomain.getEndFreq(), - itsStartFreq+freqLen); - itsStartTime = fullDomain.getStartTime(); - itsEndTime = std::min(fullDomain.getEndTime(), - itsStartTime+timeLen); - } - - void ObsDomain::setFreq (double startFreq, double endFreq) - { - itsStartFreq = startFreq; - itsEndFreq = endFreq; - } - - void ObsDomain::setTime (double startTime, double endTime) - { - itsStartTime = startTime; - itsEndTime = endTime; - } - - bool ObsDomain::getNextWorkDomain (ObsDomain& workDomain, - const DomainShape& workDomainShape) const - { - double freqLen = workDomainShape.getFreqSize(); - double timeLen = workDomainShape.getTimeSize(); - // First time? - if (workDomain.getStartFreq() < 0) { - workDomain.setFreq (itsStartFreq, - std::min(itsEndFreq, itsStartFreq+freqLen)); - workDomain.setTime (itsStartTime, - std::min(itsEndTime, itsStartTime+timeLen)); - return true; - } - // Increment in frequency if possible. - double sfreq = workDomain.getStartFreq() + freqLen; - if (sfreq < itsEndFreq) { - workDomain.setFreq (sfreq, std::min(itsEndFreq, sfreq+freqLen)); - return true; - } - double stime = workDomain.getStartTime() + timeLen; - if (stime < itsEndTime) { - // Reset work domain (for freq) and set times. - workDomain = ObsDomain(*this, workDomainShape); - workDomain.setTime (stime, std::min(itsEndTime, stime+timeLen)); - return true; - } - return false; - } - - LOFAR::BlobOStream& operator<< (LOFAR::BlobOStream& bs, - const ObsDomain& domain) - { - bs << domain.itsStartFreq << domain.itsEndFreq - << domain.itsStartTime << domain.itsEndTime; - return bs; - } - - LOFAR::BlobIStream& operator>> (LOFAR::BlobIStream& bs, - ObsDomain& domain) - { - bs >> domain.itsStartFreq >> domain.itsEndFreq - >> domain.itsStartTime >> domain.itsEndTime; - return bs; - } - - std::ostream& operator<< (std::ostream& os, - const ObsDomain& domain) - { - os << '[' << domain.itsStartFreq << " Hz, " << domain.itsEndFreq - << " Hz, " << domain.itsStartTime << ", " << domain.itsEndTime << ']'; - return os; - } - - -}} // end namespaces diff --git a/CEP/MWCommon/src/ParameterHandler.cc b/CEP/MWCommon/src/ParameterHandler.cc deleted file mode 100644 index 27dfa915a46d21caaacc464f865b07ccb5622593..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/ParameterHandler.cc +++ /dev/null @@ -1,149 +0,0 @@ -//# ParameterHandler.cc: -//# -//# Copyright (C) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/ParameterHandler.h> - -using namespace std; - -namespace LOFAR { namespace CEP { - - ParameterHandler::ParameterHandler (const ParameterSet& parSet) - : itsParms (parSet) - {} - - string ParameterHandler::getString (const string& parm, - const string& defVal) const - { - if (itsParms.isDefined(parm)) { - return itsParms.getString (parm); - } - return defVal; - } - - double ParameterHandler::getDouble (const string& parm, - double defVal) const - { - if (itsParms.isDefined(parm)) { - return itsParms.getDouble (parm); - } - return defVal; - } - - unsigned ParameterHandler::getUint (const string& parm, - unsigned defVal) const - { - if (itsParms.isDefined(parm)) { - return itsParms.getUint32 (parm); - } - return defVal; - } - - bool ParameterHandler::getBool (const string& parm, - bool defVal) const - { - if (itsParms.isDefined(parm)) { - return itsParms.getBool (parm); - } - return defVal; - } - - vector<string> ParameterHandler::getStringVector - (const string& parm, const vector<string>& defVal) const - { - if (itsParms.isDefined(parm)) { - return itsParms.getStringVector (parm); - } - return defVal; - } - - void ParameterHandler::fillString (const string& parm, - string& value) const - { - if (itsParms.isDefined(parm)) { - value = itsParms.getString (parm); - } - } - - void ParameterHandler::fillDouble (const string& parm, - double& value) const - { - if (itsParms.isDefined(parm)) { - value = itsParms.getDouble (parm); - } - } - - void ParameterHandler::fillUint (const string& parm, - unsigned& value) const - { - if (itsParms.isDefined(parm)) { - value = itsParms.getUint32 (parm); - } - } - - void ParameterHandler::fillBool (const string& parm, - bool& value) const - { - if (itsParms.isDefined(parm)) { - value = itsParms.getBool (parm); - } - } - - void ParameterHandler::fillStringVector (const string& parm, - vector<string>& value) const - { - if (itsParms.isDefined(parm)) { - value = itsParms.getStringVector (parm); - } - } - - - LOFAR::BlobOStream& operator<< (LOFAR::BlobOStream& bs, const ParameterSet& m) - { - bs.putStart ("ParameterSet", 1); - bs << static_cast<LOFAR::uint32>(m.size()); - for (ParameterSet::const_iterator it=m.begin(); - it!=m.end(); - ++it) { - bs << it->first << it->second.get(); - } - bs.putEnd(); - return bs; - } - - LOFAR::BlobIStream& operator>> (LOFAR::BlobIStream& bs, ParameterSet& m) - { - bs.getStart ("ParameterSet"); - m.clear(); - LOFAR::uint32 size; - bs >> size; - std::string k,v; - for (LOFAR::uint32 i=0; i<size; ++i) { - bs >> k >> v; - m.add (k, v); - } - bs.getEnd(); - return bs; - } - -}} // end namespaces diff --git a/CEP/MWCommon/src/SocketConnection.cc b/CEP/MWCommon/src/SocketConnection.cc deleted file mode 100644 index 37c8ac5c5a085b857988947de102637c16628fe0..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/SocketConnection.cc +++ /dev/null @@ -1,114 +0,0 @@ -//# SocketConnection.cc: Connection to workers based on a socket -//# -//# Copyright (c) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/SocketConnection.h> -#include <MWCommon/MWError.h> -#include <Common/LofarLogger.h> -#include <unistd.h> // for gethostname - - -namespace LOFAR { namespace CEP { - - SocketConnection::SocketConnection (const std::string& hostName, - const std::string& port) - : itsConnSocket ("mwsck", hostName, port), - itsDataSocket (0) - {} - - SocketConnection::SocketConnection (LOFAR::Socket* conn) - : itsDataSocket (conn) - {} - - SocketConnection::~SocketConnection() - { - if (itsDataSocket != &itsConnSocket) { - delete itsDataSocket; - } - } - - bool SocketConnection::isConnected() const - { - return itsDataSocket && itsDataSocket->isConnected(); - } - - int SocketConnection::getMessageLength() - { - return -1; - } - - void SocketConnection::receive (void* buf, unsigned size) - { - if (!itsDataSocket) { - init(); - } - char* cbuf = static_cast<char*>(buf); - while (size > 0) { - int sz = itsDataSocket->read (cbuf, size); - ASSERTSTR (sz>=0, - "Read on socket failed: " << itsDataSocket->errstr()); - cbuf += sz; - size -= sz; - } - } - - void SocketConnection::send (const void* buf, unsigned size) - { - if (!itsDataSocket) { - init(); - } - itsDataSocket->writeBlocking (buf, size); - } - - void SocketConnection::init() - { - // Create a client socket. - // Try to connect: may fail if no listener started yet. - // So retry during one minute. - int status; - for (int i=0; i<60; ++i) { - status = itsConnSocket.connect(); - if (status == LOFAR::Socket::SK_OK) { - // Connected, so socket can be used to send/receive data. - itsDataSocket = &itsConnSocket; - break; - } - sleep (1); - } - ASSERTSTR (status == LOFAR::Socket::SK_OK, - "SocketConnection client could not connect to host " - << itsConnSocket.host() << ", port " - << itsConnSocket.port() - << ", LOFAR::Socket status " << status << ' ' - << itsConnSocket.errstr()); - ASSERT (isConnected()); - } - - std::string SocketConnection::getHostName() - { - char nm[256]; - ::gethostname(nm, sizeof(nm)); - return std::string(nm); - } - -}} // end namespaces diff --git a/CEP/MWCommon/src/SocketConnectionSet.cc b/CEP/MWCommon/src/SocketConnectionSet.cc deleted file mode 100644 index 1d3e59723097732a7ce0cdbbb84fef20ac04b90a..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/SocketConnectionSet.cc +++ /dev/null @@ -1,94 +0,0 @@ -//# SocketConnectionSet.cc: Set of socket connections -//# -//# Copyright (c) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/SocketConnectionSet.h> -#include <MWCommon/MWError.h> -#include <Common/LofarLogger.h> - - -namespace LOFAR { namespace CEP { - - SocketConnectionSet::SocketConnectionSet (const std::string& port) - : itsListener (port) - {} - - SocketConnectionSet::SocketConnectionSet (const SocketListener& listener) - : itsListener (listener) - {} - - SocketConnectionSet::~SocketConnectionSet() - {} - - MWConnectionSet::ShPtr - SocketConnectionSet::clone (const std::vector<int>& inx) const - { - int nrconn = size(); - SocketConnectionSet* set = new SocketConnectionSet(itsListener); - MWConnectionSet::ShPtr mwset(set); - for (std::vector<int>::const_iterator it=inx.begin(); - it!=inx.end(); - ++it) { - int i = *it; - ASSERT (i>=0 && i<nrconn); - set->itsConns.push_back (itsConns[i]); - } - return mwset; - } - - void SocketConnectionSet::addConnections (int nr) - { - itsConns.reserve (itsConns.size() + nr); - for (int i=0; i<nr; ++i) { - itsConns.push_back (itsListener.accept()); - } - } - - int SocketConnectionSet::size() const - { - return itsConns.size(); - } - - int SocketConnectionSet::getReadyConnection() - { - return -1; - } - - void SocketConnectionSet::read (int seqnr, LOFAR::BlobString& buf) - { - itsConns[seqnr]->read (buf); - } - - void SocketConnectionSet::write (int seqnr, const LOFAR::BlobString& buf) - { - itsConns[seqnr]->write (buf); - } - - void SocketConnectionSet::writeAll (const LOFAR::BlobString& buf) - { - for (unsigned i=0; i<itsConns.size(); ++i) { - itsConns[i]->write (buf); - } - } - -}} // end namespaces diff --git a/CEP/MWCommon/src/SocketListener.cc b/CEP/MWCommon/src/SocketListener.cc deleted file mode 100644 index 7153cb3a7908c3e1f711125c01e9463267a99ebc..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/SocketListener.cc +++ /dev/null @@ -1,50 +0,0 @@ -//# SocketListener.cc: Class that creates a socket and accepts connections -//# -//# Copyright (c) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/SocketListener.h> -#include <MWCommon/MWError.h> -#include <Common/LofarLogger.h> - - -namespace LOFAR { namespace CEP { - - SocketListener::SocketListener (const std::string& port) - : itsConnSocket (new LOFAR::Socket("mwsck", port)) - {} - - SocketConnection::ShPtr SocketListener::accept() - { - LOFAR::Socket* socket = itsConnSocket->accept(); - SocketConnection::ShPtr dataConn(new SocketConnection(socket)); - int status = itsConnSocket->errcode(); - ASSERTSTR (socket && status == LOFAR::Socket::SK_OK, - "SocketConnection server did not accept on host " - << itsConnSocket->host() << ", port " << itsConnSocket->port() - << ", LOFAR::Socket status " << status << ' ' - << itsConnSocket->errstr()); - ASSERT (dataConn->isConnected()); - return dataConn; - } - -}} // end namespaces diff --git a/CEP/MWCommon/src/VdsDesc.cc b/CEP/MWCommon/src/VdsDesc.cc deleted file mode 100644 index 14908043e50486379837f77a8b5d049972c252bf..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/VdsDesc.cc +++ /dev/null @@ -1,81 +0,0 @@ -//# VdsDesc.cc: Describe an entire visibility data set -//# -//# Copyright (C) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ -//# -//# @author Ger van Diepen <diepen AT astron nl> - -#include <lofar_config.h> - -#include <MWCommon/VdsDesc.h> -#include <Common/StreamUtil.h> -#include <ostream> - -namespace std { - using LOFAR::operator<<; -} -using namespace std; - -namespace LOFAR { namespace CEP { - - VdsDesc::VdsDesc (const VdsPartDesc& desc) - : itsDesc (desc) - {} - - VdsDesc::VdsDesc (const string& parsetName) - { - init (ParameterSet (parsetName)); - } - - void VdsDesc::init (const ParameterSet& parset) - { - itsDesc = VdsPartDesc (parset); - int npart = parset.getInt32 ("NParts"); - for (int i=0; i<npart; ++i) { - ostringstream prefix; - prefix << "Part" << i << '.'; - ParameterSet subset = parset.makeSubset (prefix.str()); - itsParts.push_back (VdsPartDesc(subset)); - } - } - - void VdsDesc::write (ostream& os) const - { - itsDesc.write (os, ""); - os << "NParts = " << itsParts.size() << endl; - for (unsigned i=0; i<itsParts.size(); ++i) { - ostringstream prefix; - prefix << "Part" << i << '.'; - itsParts[i].write (os, prefix.str()); - } - } - -// int VdsDesc::findPart (const string& fileSystem, -// const vector<int>& done) const -// { -// for (unsigned i=0; i<itsParts.size(); ++i) { -// if (done[i] < 0 && itsParts[i].getFileSys() == fileSystem) { -// return i; -// } -// } -// return -1; -// } - -}} // end namespaces diff --git a/CEP/MWCommon/src/VdsPartDesc.cc b/CEP/MWCommon/src/VdsPartDesc.cc deleted file mode 100644 index 5276e0bad091a9f2d1c9c650cd7490c9e01bc210..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/VdsPartDesc.cc +++ /dev/null @@ -1,203 +0,0 @@ -//# VdsPartDesc.cc: Description of a visibility data set or part thereof -//# -//# Copyright (C) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ -//# -//# @author Ger van Diepen <diepen AT astron nl> - -#include <lofar_config.h> - -#include <MWCommon/VdsPartDesc.h> -#include <MWCommon/ParameterHandler.h> -#include <Blob/BlobArray.h> -#include <Common/StreamUtil.h> -#include <Common/LofarLogger.h> -#include <casa/Quanta/MVTime.h> -#include <ostream> - -namespace std { - using LOFAR::operator<<; -} -using namespace std; -using namespace casa; - -namespace LOFAR { namespace CEP { - - VdsPartDesc::VdsPartDesc (const ParameterSet& parset) - { - itsName = parset.getString ("Name"); - itsFileName = parset.getString ("FileName", ""); - itsFileSys = parset.getString ("FileSys", ""); - itsCDescName = parset.getString ("ClusterDesc", ""); - itsStepTime = parset.getDouble ("StepTime"); - itsNChan = parset.getInt32Vector ("NChan", vector<int32>()); - itsStartFreqs = parset.getDoubleVector ("StartFreqs", vector<double>()); - itsEndFreqs = parset.getDoubleVector ("EndFreqs", vector<double>()); - itsParms = parset.makeSubset ("Extra."); - string timeStr; - Quantity q; - timeStr = parset.getString ("StartTime"); - ASSERT (MVTime::read (q, timeStr, true)); - itsStartTime = q.getValue ("s"); - timeStr = parset.getString ("EndTime"); - ASSERT (MVTime::read (q, timeStr, true)); - itsEndTime = q.getValue ("s"); - itsStartTimes = parset.getDoubleVector ("StartTimesDiff", vector<double>()); - itsEndTimes = parset.getDoubleVector ("EndTimesDiff", vector<double>()); - ASSERT (itsStartTimes.size() == itsEndTimes.size()); - double diff = itsStartTime; - for (uint i=0; i<itsStartTimes.size(); ++i) { - itsStartTimes[i] += diff; - diff += itsStepTime; - itsEndTimes[i] += diff; - } - } - - void VdsPartDesc::write (std::ostream& os, const std::string& prefix) const - { - os << prefix << "Name = " << itsName << endl; - if (! itsFileName.empty()) { - os << prefix << "FileName = " << itsFileName << endl; - } - if (! itsFileSys.empty()) { - os << prefix << "FileSys = " << itsFileSys << endl; - } - if (! itsCDescName.empty()) { - os << prefix << "ClusterDesc= " << itsCDescName << endl; - } - os << prefix << "StartTime = " - << MVTime::Format(MVTime::YMD,9) << MVTime(itsStartTime/86400) << endl; - os << prefix << "EndTime = " - << MVTime::Format(MVTime::YMD,9) << MVTime(itsEndTime/86400) << endl; - os << prefix << "StepTime = " << itsStepTime << endl; - if (! itsStartTimes.empty()) { - os << prefix << "StartTimesDiff=["; - streamsize oldPrec = os.precision (5); - double diff = itsStartTime; - for (uint i=0; i<itsStartTimes.size(); ++i) { - if (i!=0) os << ','; - os << itsStartTimes[i] - diff; - diff += itsStepTime; - } - os << ']' << endl; - os.precision (oldPrec); - } - if (! itsEndTimes.empty()) { - os << prefix << "EndTimesDiff=["; - streamsize oldPrec = os.precision (5); - double diff = itsStartTime; - for (uint i=0; i<itsEndTimes.size(); ++i) { - if (i!=0) os << ','; - diff += itsStepTime; - os << itsEndTimes[i] - diff; - } - os << ']' << endl; - os.precision (oldPrec); - } - if (! itsNChan.empty()) { - os << prefix << "NChan = " << itsNChan << endl; - streamsize oldPrec = os.precision (12); - os << prefix << "StartFreqs = " << itsStartFreqs << endl; - os << prefix << "EndFreqs = " << itsEndFreqs << endl; - os.precision (oldPrec); - } - // Prepend the extra parameters with Extra.. - ParameterSet parms; - parms.adoptCollection (itsParms, prefix+"Extra."); - parms.writeStream (os); - } - - void VdsPartDesc::setName (const std::string& name, - const std::string& fileSys) - { - itsName = name; - itsFileSys = fileSys; - } - - void VdsPartDesc::changeBaseName (const string& newBaseName) - { - string::size_type pos = itsName.rfind ('/'); - if (pos == string::npos) { - itsName = newBaseName; - } else { - itsName = itsName.substr (0, pos+1) + newBaseName; - } - } - - void VdsPartDesc::setTimes (double startTime, double endTime, double stepTime, - const vector<double>& startTimes, - const vector<double>& endTimes) - { - ASSERT (itsStartTimes.size() == itsEndTimes.size()); - itsStartTime = startTime; - itsEndTime = endTime; - itsStepTime = stepTime; - itsStartTimes = startTimes; - itsEndTimes = endTimes; - } - - void VdsPartDesc::addBand (int nchan, double startFreq, double endFreq) - { - itsNChan.push_back (nchan); - double step = (endFreq-startFreq)/nchan; - for (int i=0; i<nchan; ++i) { - itsStartFreqs.push_back (startFreq); - startFreq += step; - itsEndFreqs.push_back (startFreq); - } - } - - void VdsPartDesc::addBand (int nchan, const vector<double>& startFreq, - const vector<double>& endFreq) - { - ASSERT (startFreq.size() == endFreq.size()); - ASSERT (int(startFreq.size())==nchan || startFreq.size() == 1); - itsNChan.push_back (nchan); - for (uint i=0; i<startFreq.size(); ++i) { - itsStartFreqs.push_back (startFreq[i]); - itsEndFreqs.push_back (endFreq[i]); - } - } - - BlobOStream& VdsPartDesc::toBlob (BlobOStream& bs) const - { - bs.putStart ("VdsPartDesc", 1); - bs << itsName << itsFileName << itsFileSys << itsCDescName - << itsStartTime << itsEndTime << itsStepTime - << itsStartTimes << itsEndTimes - << itsNChan << itsStartFreqs << itsEndFreqs - << itsParms; - bs.putEnd(); - return bs; - } - - BlobIStream& VdsPartDesc::fromBlob (BlobIStream& bs) - { - bs.getStart ("VdsPartDesc"); - bs >> itsName >> itsFileName >> itsFileSys >> itsCDescName - >> itsStartTime >> itsEndTime >> itsStepTime - >> itsStartTimes >> itsEndTimes - >> itsNChan >> itsStartFreqs >> itsEndFreqs - >> itsParms; - bs.getEnd(); - return bs; - } - -}} // end namespaces diff --git a/CEP/MWCommon/src/WorkDomainSpec.cc b/CEP/MWCommon/src/WorkDomainSpec.cc deleted file mode 100644 index 843cceae171bb1804fd636011c31ae79cce1006a..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/WorkDomainSpec.cc +++ /dev/null @@ -1,81 +0,0 @@ -//# WorkDomainSpec.cc: Define the specifications of the work domain -//# -//# Copyright (c) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/WorkDomainSpec.h> -#include <MWCommon/MWError.h> -#include <Blob/BlobArray.h> - -using namespace std; - - -namespace LOFAR { namespace CEP { - - void WorkDomainSpec::setAntennas (const vector<int>& antNrs) - { - itsAntNrs = antNrs; - } - - void WorkDomainSpec::setAntennaNames (const vector<string>& antNames) - { - itsAntNames = antNames; - } - - void WorkDomainSpec::setCorr (const vector<bool>& corr) - { - itsCorr = corr; - } - - LOFAR::BlobOStream& operator<< (LOFAR::BlobOStream& bs, - const WorkDomainSpec& wds) - { - bs.putStart ("WDS", 1); - bs << wds.itsInColumn - << wds.itsAntNrs - << wds.itsAntNames - << wds.itsAutoCorr - << wds.itsCorr - << wds.itsShape - << wds.itsFreqInt - << wds.itsTimeInt; - return bs; - } - - LOFAR::BlobIStream& operator>> (LOFAR::BlobIStream& bs, - WorkDomainSpec& wds) - { - int vers = bs.getStart ("WDS"); - ASSERT (vers == 1); - bs >> wds.itsInColumn - >> wds.itsAntNrs - >> wds.itsAntNames - >> wds.itsAutoCorr - >> wds.itsCorr - >> wds.itsShape - >> wds.itsFreqInt - >> wds.itsTimeInt; - return bs; - } - - -}} // end namespaces diff --git a/CEP/MWCommon/src/WorkerControl.cc b/CEP/MWCommon/src/WorkerControl.cc deleted file mode 100644 index 15c7d9e3b19885ddb89c7d934ed1e3cdb5a39acf..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/WorkerControl.cc +++ /dev/null @@ -1,62 +0,0 @@ -//# WorkerControl.cc: Worker connection of distributed VDS processing -//# -//# Copyright (c) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/WorkerControl.h> -#include <Blob/BlobString.h> - -using namespace std; - - -namespace LOFAR { namespace CEP { - - WorkerControl::WorkerControl (const WorkerProxy::ShPtr& proxy) - : itsProxy (proxy) - {} - - void WorkerControl::init (const MWConnection::ShPtr& connection) - { - itsConnection = connection; - } - - void WorkerControl::run() - { - LOFAR::BlobString bufIn, bufOut; - // Start with sending the work types. - itsProxy->putWorkerInfo (bufOut); - itsConnection->write (bufOut); - // Read data until an end command is received. - while (true) { - bufIn.resize (0); - bufOut.resize (0); - itsConnection->read (bufIn); - if (! itsProxy->handleMessage (bufIn, bufOut)) { - break; - } - if (bufOut.size() > 0) { - itsConnection->write (bufOut); - } - } - } - -}} // end namespaces diff --git a/CEP/MWCommon/src/WorkerFactory.cc b/CEP/MWCommon/src/WorkerFactory.cc deleted file mode 100644 index 16ff7b096ce1643244542a36e66b29ff47d24dd6..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/WorkerFactory.cc +++ /dev/null @@ -1,44 +0,0 @@ -//# WorkerFactory.cc: Factory pattern to generate a workerproxy object -//# -//# Copyright (c) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/WorkerFactory.h> -#include <MWCommon/MWError.h> -#include <Common/LofarLogger.h> - -namespace LOFAR { namespace CEP { - - void WorkerFactory::push_back (const std::string& name, Creator* creator) - { - itsMap[name] = creator; - } - - WorkerProxy::ShPtr WorkerFactory::create (const std::string& name) const - { - std::map<std::string,Creator*>::const_iterator iter = itsMap.find(name); - ASSERTSTR (iter != itsMap.end(), - "WorkerProxy " << name << " is unknown"); - return (*iter->second)(); - } - -}} // end namespaces diff --git a/CEP/MWCommon/src/WorkerInfo.cc b/CEP/MWCommon/src/WorkerInfo.cc deleted file mode 100644 index 2cadee69d2b49da4526c7f3415e0a7f9cdf1bfd2..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/WorkerInfo.cc +++ /dev/null @@ -1,69 +0,0 @@ -//# WorkerInfo.cc: -//# -//# Copyright (c) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/WorkerInfo.h> -#include <MWCommon/MWError.h> -#include <Blob/BlobIStream.h> -#include <Blob/BlobOStream.h> -#include <Blob/BlobArray.h> - -using namespace LOFAR; - -namespace LOFAR { namespace CEP { - - WorkerInfo::WorkerInfo() - {} - - WorkerInfo::WorkerInfo (const std::string& hostName, - const std::vector<int>& workTypes) - : itsHostName (hostName), - itsWorkTypes (workTypes) - {} - - WorkerInfo::~WorkerInfo() - {} - - int WorkerInfo::getWorkType() const - { - return (itsWorkTypes.size() == 0 ? 0 : itsWorkTypes[0]); - } - - BlobOStream& operator<< (BlobOStream& bs, const WorkerInfo& info) - { - bs.putStart ("info", 1); - bs << info.itsHostName << info.itsWorkTypes; - bs.putEnd(); - return bs; - } - - BlobIStream& operator>> (BlobIStream& bs, WorkerInfo& info) - { - int version = bs.getStart ("info"); - ASSERT (version == 1); - bs >> info.itsHostName >> info.itsWorkTypes; - bs.getEnd(); - return bs; - } - -}} // end namespaces diff --git a/CEP/MWCommon/src/WorkerProxy.cc b/CEP/MWCommon/src/WorkerProxy.cc deleted file mode 100644 index 2d73e469c8da793b3b2b971706def1ec5e5ef506..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/WorkerProxy.cc +++ /dev/null @@ -1,113 +0,0 @@ -//# WorkerProxy.cc: Base class for the proxy of a worker -//# -//# Copyright (c) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/WorkerProxy.h> -#include <MWCommon/WorkerInfo.h> -#include <MWCommon/MasterControl.h> -#include <MWCommon/MWBlobIO.h> -#include <MWCommon/SocketConnection.h> -#include <MWCommon/MWError.h> -#include <Blob/BlobArray.h> - - -namespace LOFAR { namespace CEP { - - WorkerProxy::WorkerProxy() - : itsWorkerId (-1) - {} - - WorkerProxy::~WorkerProxy() - {} - - void WorkerProxy::putWorkerInfo (LOFAR::BlobString& out) - { - // Write the work types and the host name of the worker. - MWBlobOut bout(out, 0, 0); - WorkerInfo info(SocketConnection::getHostName(), getWorkTypes()); - bout.blobStream() << info; - bout.finish(); - } - - WorkerInfo WorkerProxy::getWorkerInfo (LOFAR::BlobString& in) - { - // Read back from blob string. - MWBlobIn bin(in); - ASSERT (bin.getOperation() == 0); - WorkerInfo info; - bin.blobStream() >> info; - return info; - } - - bool WorkerProxy::handleMessage (const LOFAR::BlobString& in, - LOFAR::BlobString& out) - { - MWBlobIn bin(in); - int operation = bin.getOperation(); - if (operation < 0) { - quit(); - } else { - // Set the (unique) worker id when initializing. - if (operation == MasterControl::Init) { - itsWorkerId = bin.getWorkerId(); - } - // Create the output blob using the operation of the input. - // The process function can reset the operation. - // Do timings of the process functions and put them into the blob. - MWBlobOut bout(out, operation, bin.getStreamId(), itsWorkerId); - casa::Timer timer; - LOFAR::NSTimer precTimer; - precTimer.start(); - int oper = operation; - if (operation == MasterControl::Init) { - ParameterSet parset; - string dataPartName; - /// bin.blobStream() >> parset >> dataPartName; - bin.blobStream() >> parset >> dataPartName; - setInitInfo (parset, dataPartName); - } else { - oper = process (operation, bin.getStreamId(), - bin.blobStream(), bout.blobStream()); - } - // Set the timings. - precTimer.stop(); - if (oper < 0) { - // Do not send a reply. - out.resize (0); - } else { - bout.setTimes (timer, precTimer); - // Reset operation if changed. - if (oper != bin.getOperation()) { - bout.setOperation (oper); - } - bout.finish(); - } - } - bin.finish(); - return operation >= 0; - } - - void WorkerProxy::quit() - {} - -}} // end namespaces diff --git a/CEP/MWCommon/src/WorkersDesc.cc b/CEP/MWCommon/src/WorkersDesc.cc deleted file mode 100644 index 2045c90680dcf6bd5b48ec708ec3df4271841469..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/WorkersDesc.cc +++ /dev/null @@ -1,162 +0,0 @@ -//# WorkersDesc.cc: Description of a workers -//# -//# Copyright (C) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ -//# -//# @author Ger van Diepen <diepen AT astron nl> - -#include <lofar_config.h> - -#include <MWCommon/WorkersDesc.h> -#include <algorithm> - -using namespace std; - -namespace LOFAR { namespace CEP { - - WorkersDesc::WorkersDesc (const ClusterDesc& cd) - : itsClusterDesc (cd) - { - // Reserve for 128 workers; might get more. - itsLoad.reserve (128); - } - - void WorkersDesc::addWorker (unsigned workerId, const string& nodeName, - const vector<int>& workTypes) - { - // Resize load vector if needed. - // Initialize load for this worker. - if (workerId >= itsLoad.size()) { - itsLoad.resize (workerId+1); - } - itsLoad[workerId] = 0; - // Add the worker to the list of nodes per worker type. - for (vector<int>::const_iterator iter=workTypes.begin(); - iter != workTypes.end(); - ++iter) { - // Get worker map for this worker type; gets created if not existing. - MapN2W& mnw = itsMap[*iter]; - // Append to list of workers for this node. - vector<unsigned>& vec = mnw[nodeName]; - vec.push_back (workerId); - } - } - - int WorkersDesc::findWorker (int workType, const string& fileSystem, - NodeDesc::NodeType type) const - { - // Find the worker type. - map<int,MapN2W>::const_iterator workMap = itsMap.find(workType); - if (workMap == itsMap.end()) { - return -1; - } - // The worker has to operate on a given file system, so only nodes - // with access to it will be considered. - // If the file system is empty, no specific file system is needed and - // any node may do. - if (fileSystem.empty()) { - return findLowest (workMap->second, type); - } - return findLowest (workMap->second, fileSystem, type); - } - - int WorkersDesc::findLowest (const MapN2W& workMap, - NodeDesc::NodeType type) const - { - // Find worker with lowest load. - int worker = -1; - int load = 1000000; - // Loop over all nodes and find worker with lowest load - // for which the node type matches. - for (MapN2W::const_iterator workers = workMap.begin(); - workers != workMap.end(); - ++workers) { - // Only use node if its type matches. - bool use = true; - if (type != NodeDesc::Any) { - const vector<NodeDesc>& nodes = itsClusterDesc.getNodes(); - for (vector<NodeDesc>::const_iterator niter = nodes.begin(); - niter != nodes.end(); ++niter) { - if (workers->first == niter->getName()) { - use = niter->getType() == NodeDesc::Any || niter->getType() == type; - break; - } - } - } - if (use) { - const vector<unsigned>& workTypes = workers->second; - for (vector<unsigned>::const_iterator witer=workTypes.begin(); - witer != workTypes.end(); - ++witer) { - // We can stop if a worker with load 0 is found. - if (itsLoad[*witer] < load) { - worker = *witer; - load = itsLoad[*witer]; - if (load == 0) break; - } - } - if (load == 0) break; - } - } - return worker; - } - - int WorkersDesc::findLowest (const MapN2W& workMap, - const string& fileSystem, - NodeDesc::NodeType type) const - { - // Find worker with lowest load. - int worker = -1; - int load = 1000000; - // Get all nodes with access to the file system. - const MapF2N& fs2Nodes = itsClusterDesc.getMap(); - MapF2N::const_iterator nodes = fs2Nodes.find(fileSystem); - if (nodes == fs2Nodes.end()) { - return -1; - } - const vector<int>& nodesVec = nodes->second; - for (vector<int>::const_iterator iter=nodesVec.begin(); - iter != nodesVec.end(); - ++iter) { - // Loop over all suitable nodes and find worker with lowest load. - const NodeDesc& node = itsClusterDesc.getNodes()[*iter]; - if (node.getType() == type - || node.getType() == NodeDesc::Any || type == NodeDesc::Any) { - MapN2W::const_iterator workers = workMap.find(node.getName()); - if (workers != workMap.end()) { - const vector<unsigned>& workTypes = workers->second; - for (vector<unsigned>::const_iterator witer=workTypes.begin(); - witer != workTypes.end(); - ++witer) { - // We can stop if a worker with load 0 is found. - if (itsLoad[*witer] < load) { - worker = *witer; - load = itsLoad[*witer]; - if (load == 0) break; - } - } - if (load == 0) break; - } - } - } - return worker; - } - -}} // end namespaces diff --git a/CEP/MWCommon/src/finddproc.cc b/CEP/MWCommon/src/finddproc.cc deleted file mode 100644 index 61036b9d87b23a77dbed3ed5cfeaa588afc53753..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/finddproc.cc +++ /dev/null @@ -1,206 +0,0 @@ -//# finddproc.cc: Create machinefile based on -//# -//# Copyright (C) 2006 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> -#include <MWCommon/VdsDesc.h> -#include <MWCommon/ClusterDesc.h> -#include <MWCommon/WorkersDesc.h> -#include <MWCommon/MWError.h> -#include <Common/StringUtil.h> -#include <Common/LofarLogger.h> -#include <iostream> - -using namespace LOFAR::CEP; -using namespace LOFAR; -using namespace std; - - -void makeFile (const vector<string>& fileSys, const vector<string>& fileNames, - const vector<string>& names, WorkersDesc& workers, - const ClusterDesc& cluster, NodeDesc::NodeType type) -{ - const vector<NodeDesc>& nodes = cluster.getNodes(); - // Loop through fileSys. - for (uint i=0; i<fileSys.size(); ++i) { - // Find a worker that can deal with the file system the dataset part is on. - int winx = workers.findWorker (0, fileSys[i], type); - if (winx < 0) { - THROW (MWError, "finddproc: no suitable host could be found" << - " for dataset part " << names[i] << - " on file system " << fileSys[i]); - } - cout << nodes[winx].getName() << '#' << fileNames[i] << ',' - << fileSys[i] << ',' << names[i] << endl; - // Increment the load to indicate it is already in use. In that way it - // will only be used again if all other possible nodes are used as well. - workers.incrLoad (winx); - } -} - -// List the nodes to be used for processes on head nodes. -void makeFromHead (int nhead, WorkersDesc& workers) -{ - // List the head nodes to use. - int winx = 0; - for (int i=0; i<nhead; ++i) { - winx = workers.findWorker (0, string(), NodeDesc::Head); - if (winx < 0) { - break; - } - workers.incrLoad (winx); - } - // If no head nodes found, try any nodes. - for (int i=0; i<nhead; ++i) { - winx = workers.findWorker (0, string(), NodeDesc::Any); - if (winx < 0) { - THROW (MWError, "finddproc: no suitable hosts could be found" << - " for " << nhead << " processes to run on head nodes"); - } - workers.incrLoad (winx); - } -} - -// Make the machine file for the data parts given in a global VDS file. -void makeFromFile (const string& vdsName, WorkersDesc& workers, - const ClusterDesc& cluster, NodeDesc::NodeType type) -{ - // Read in the vds and cluster desc. - VdsDesc vds(vdsName); - // Loop through all parts of the dataset. - const vector<VdsPartDesc>& parts = vds.getParts(); - vector<string> fileSys, fileNames, names; - fileSys.reserve (parts.size()); - fileNames.reserve (parts.size()); - names.reserve (parts.size()); - for (vector<VdsPartDesc>::const_iterator iter = parts.begin(); - iter != parts.end(); - ++iter) { - fileSys.push_back (iter->getFileSys()); - fileNames.push_back (iter->getFileName()); - names.push_back (iter->getName()); - } - // Find the hosts to processes the data parts. - makeFile (fileSys, fileNames, names, workers, cluster, type); -} - -void makeFromDirs (const string& dirStr, WorkersDesc& workers, - const ClusterDesc& cluster, NodeDesc::NodeType type) -{ - const vector<NodeDesc>& nodes = cluster.getNodes(); - // Split string. - vector<string> dirs = StringUtil::split(dirStr, ','); - // Create a list of FileSys from the dirs. - vector<string> fileSys, fileNames; - fileSys.reserve (dirs.size()); - fileNames.reserve (dirs.size()); - for (uint i=0; i<dirs.size(); ++i) { - string nodeName; - string mountName(dirs[i]); - string::size_type colon = dirs[i].find(':'); - if (colon != string::npos) { - nodeName = dirs[i].substr (0, colon); - mountName = dirs[i].substr (colon+1); - } - // Find the mountpoint by looping over all nodes. - // If a node name is given, only that one is considered. - // Add a dummy file name to the mountName for findFileSys. - for (uint j=0; j<nodes.size(); ++j) { - if (nodeName.empty() || nodeName == nodes[j].getName()) { - fileSys.push_back (nodes[j].findFileSys (mountName+"/xx")); - break; - } - } - fileNames.push_back (mountName); - } - makeFile (fileSys, fileNames, fileNames, workers, cluster, type); -} - -int main (int argc, const char* argv[]) -{ - try { - int nhead = 0; - bool useDirs = false; - NodeDesc::NodeType type = NodeDesc::Compute; - int st = 1; - if (argc > st && string(argv[st]) == "-storage") { - type = NodeDesc::Storage; - ++st; - } - if (argc > st+1 && string(argv[st]) == "-nhead") { - istringstream istr(argv[st+1]); - istr >> nhead; - st += 2; - } - if (argc > st && string(argv[st]) == "-dirs") { - useDirs = true; - ++st; - } - if (argc < st+2) { - cerr << "Run as: finddproc [-storage] [-nhead n] vdsdescname clusterdescname" - << endl; - cerr << " or finddproc [-storage] [-nhead n] -dirs directories clusterdescname" - << endl; - cerr << " directories is a single argument separated by commas." - << endl; - cerr << " -storage indicates that storage nodes are to be used." <<endl; - cerr << " Otherwise compute nodes are used." << endl; - cerr << " -nhead gives the number of processes to start on head nodes." - << endl; - cerr << " They are listed first in the resulting machinefile." - << endl; - cerr << " (they represent master and e.g. solvers)" << endl; - cerr << " Options must be given in the order mentioned above." << endl; - cerr << "" << endl; - cerr << "For backward compatibility extra hosts can be given at the end." - << endl; - cerr << "They are listed first for master processes and the like." << endl; - cerr << "The preferred option is to use -nhead for these purposes." << endl; - return 1; - } - - // First list the other hosts (master and extra). - for (int i=st+2; i<argc; ++i) { - cout << argv[i] << endl; - } - - // Make a worker for each node in the cluster. - // Create a fake work type for them. - ClusterDesc cluster(argv[st+1]); - WorkersDesc workers(cluster); - vector<int> workTypes(1, 0); // Use work type 0 - const vector<NodeDesc>& nodes = cluster.getNodes(); - for (unsigned i=0; i<nodes.size(); ++i) { - workers.addWorker (i, nodes[i].getName(), workTypes); - } - // First list the processes on head nodes. - makeFromHead (nhead, workers); - if (useDirs) { - makeFromDirs (argv[st], workers, cluster, type); - } else { - makeFromFile (argv[st], workers, cluster, type); - } - } catch (std::exception& x) { - cerr << "Unexpected exception: " << x.what() << endl; - return 1; - } - return 0; -} diff --git a/CEP/MWCommon/src/rundist b/CEP/MWCommon/src/rundist deleted file mode 100755 index 0c8ffb4a88a1d1cd615cead885133af6d8eadc16..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/rundist +++ /dev/null @@ -1,199 +0,0 @@ -#!/bin/sh - -# rundist: Script to run a program in a distributed way -# -# Copyright (C) 2009 -# ASTRON (Netherlands Institute for Radio Astronomy) -# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -# -# This file is part of the LOFAR software suite. -# The LOFAR software suite is free software: you can redistribute it and/or -# modify it under the terms of the GNU General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# The LOFAR software suite is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -# -# $Id$ - -# This script is a front-end for startdistproc. -# It adds the following: -# - the environment for the distributed process is setup -# - it makes all paths absolute -# - it can create an output VDS file based on the input VDS file -# This is useful for processes that create output (e.g. combineFacets) -# -# The distributed processes are started with the following arguments -# 1. rank (0-relative) -# 2. name of dataset part to process -# >2 extra arguments given - - -# Find the path used to start the script. -pgmpath=`dirname $0` -pgmpath=`cd $pgmpath > /dev/null 2>&1 && pwd` - -# Get possible options. -help=0 -dry= -logfile= -cdn=$HOME/CEP.clusterdesc -wd= -hfn= -gdsout= -overwrite=1 -useenv='-useenv' -while [ $# != 0 ] -do - # Accept both one and two leading hyphens - opt=`echo $1 | sed 's/^--/-/'` - if [ "$opt" = "-h" -o "$1" = "-help" ]; then - help=1 - break - elif [ "$opt" = "-dry" ]; then - dry="-dry" - shift - elif [ "$opt" = "-nodry" ]; then - dry= - shift - elif [ "$opt" = "-logfile" ]; then - shift - logfile="$1" - shift - elif [ "$opt" = "-clusterdesc" -o "$opt" = "-cdn" ]; then - shift - cdn="$1" - shift - elif [ "$opt" = "-wd" ]; then - shift - wd="$1" - shift - elif [ "$opt" = "-envfile" ]; then - shift - dn=`dirname $1` - envf=`cd $dn > /dev/null; pwd`/`basename $1` # absolute path - useenv="-useenv $envf" - shift - elif [ "$opt" = "-machinefile" -o "$opt" = "-hfn" ]; then - shift - hfn="$1" - shift - elif [ "$opt" = "-gdsout" ]; then - shift - gdsout="$1" - shift - elif [ "$opt" = "-overwrite" ]; then - overwrite=1 - shift - elif [ "$opt" = "-nooverwrite" ]; then - overwrite=0 - shift - else - break - fi -done - -# Check arguments. -if test $# = 0; then - help=1 -fi -if test $help = 1; then - echo "run as: rundist [-dry] [-clusterdesc] [-logfile] [-wd] [-machinefile]" - echo " prog gds [args]" - echo " -dry do a dry run, i.e. only print commands" - echo " -clusterdesc name of clusterdesc file" - echo " default is $HOME/CEP.clusterdesc" - echo " -logfile root name of logfile of each subprocess" - echo " A sequence number gets appended to it" - echo " default is setupparmdb.log" - echo " -machinefile name of the hostfile (machinefile) created" - echo " by startdistproc" - echo " Usually only needed for test purposes" - echo " -wd working directory to use on remote hosts" - echo " default is same directory as MS part" - echo " -envfile name of envfile to use by startdistproc's -useenv" - echo " -gdsout extension of the global VDS file to create" - echo " The name of this file will be the same as the input VDS" - echo " with its the extension replaced by the given one." - echo " If not given, not global VDS file will be created." - echo " -overwrite If global VDS file is created, it will be overwritten." - echo " Otherwise an error is reported if the file exists." - echo " Default is -overwrite" - echo "" - echo " prog program or script to start on remote hosts" - echo " gds name of global VDS file of the dataset to process" - echo " args optional further arguments for the remote processes" - exit 1 -fi - -prog=$1 -shift -msvds=$1 -shift -if test "$cdn" = ""; then - echo "No clusterdesc file given using -cdn" - exit 1 -fi - -# Create the name of the output GDS file. -# It is the same as the input GDS but with the given extension. -if test "$gdsout" != ""; then - vdsname=`echo $msvds | sed -e "s%\([^.]*\)\.[^/]*$%\1.$gdsout%"` -fi - -# Make all file names absolute. -dn=`dirname $msvds` -msvds=`cd $dn > /dev/null; pwd`/`basename $msvds` -dn=`dirname $cdn` -cdn=`cd $dn > /dev/null; pwd`/`basename $cdn` -if test "$hfn" != ""; then - dn=`dirname $hfn` - hfn=`cd $dn > /dev/null; pwd`/`basename $hfn` -fi -# Make name of program absolute. -# First test if it contains a slash. If so, it has a path; make it absolute. -progx=`echo $prog | sed -e 's%/%%'` -if test "$prog" != "$progx"; then - dn=`dirname $prog` - prog=`cd $dn > /dev/null; pwd`/`basename $prog` -else - # Find the program; which returns an error string if not found. - # If not found, it can be a builtin command, so leave it. - # Note that which always succeeds, even if not found. So test its output. - progx=`which $prog` - if test -e "$progx"; then - dn=`dirname $progx` - prog=`cd $dn > /dev/null; pwd`/`basename $progx` - fi -fi - - -# Start the processes on the various machines. -echo "startdistproc $useenv -mode 0 -nomasterhost -dsn '$msvds' -hfn '$hfn' -cdn '$cdn' -logfile '$logfile' $dry $prog '$wd' $*" -startdistproc $useenv -mode 0 -nomasterhost -dsn "$msvds" -hfn "$hfn" -cdn "$cdn" -logfile "$logfile" $dry $pgmpath/rundist-part $prog "$wd" "$@" || exit 1 - -# Optionally create a GDS file for output created by the remote processes. -# Its name is the input GDS with the extension replaced by $pdb. -# Refer in it to the actual pdb filename. -if test "$vdsname" != ""; then - if test -e $vdsname; then - if test -d $vdsname; then - echo "Error, global VDS file $vdsname already exists as a directory" - exit 1 - fi - if test $overwrite = 0; then - echo "Error, global VDS file $vdsname already exists" - exit 1 - fi - fi - echo "Creating global VDS file $vdsname" - if test "$dry" = ""; then - sed -e "s%\(Part.*\.FileName *= *[^ #.]*\)\.[^/ #]*%\1.$gdsout%" $msvds > $vdsname - fi -fi diff --git a/CEP/MWCommon/src/rundist-part b/CEP/MWCommon/src/rundist-part deleted file mode 100755 index 9fac7ea205415d51c0e5ad4a7a9d8f45ec5d817a..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/rundist-part +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/sh - -# rundist-part: The rundist part run in a distributed way -# -# Copyright (C) 2009 -# ASTRON (Netherlands Institute for Radio Astronomy) -# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -# -# This file is part of the LOFAR software suite. -# The LOFAR software suite is free software: you can redistribute it and/or -# modify it under the terms of the GNU General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# The LOFAR software suite is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -# -# $Id$ - -# This script is sarted by rundist by means of startdistproc/socketrun. -# It setups the environment for the distributed process and sets working directory. -# Thereafter the program is started with arguments: -# 1. rank (0-relative) -# 2. name of dataset part to process -# >2 extra arguments given - - -if test $# -lt 11; then - echo "run as: rundist-part 'socket' masterhost masterport nproc rank" - echo " img-part filesys img-part-vds envfile" - echo " prog wd [arg]" - exit 1 -fi - -shift -shift -shift -shift -rank=$1 -shift -dataset=$1 -shift -shift -shift -envfile=$1 -shift -prog=$1 -shift -wd=$1 -shift - - -# Initialize environment. -if test "$envfile" != ""; then - . $envfile -fi - -# Set the working directory. -test "$wd" != "" || wd=`dirname $dataset` -cd $wd - -# Start the program with its arguments. -$prog $rank $dataset "$@" diff --git a/CEP/MWCommon/src/runlogpid b/CEP/MWCommon/src/runlogpid deleted file mode 100755 index df7f49563cf119e8293342e113706d1042cc99b0..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/runlogpid +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh - -# runlogpid: Start a process and log its pid and exit status. -# -# Copyright (C) 2009 -# ASTRON (Netherlands Institute for Radio Astronomy) -# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -# -# This file is part of the LOFAR software suite. -# The LOFAR software suite is free software: you can redistribute it and/or -# modify it under the terms of the GNU General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# The LOFAR software suite is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -# -# @author Ger van Diepen <diepen AT astron nl> -# -# $Id$ - - -# run as: runlogpid logfile program [arg1 arg2 ...] -# -# logfile name of the log file to use. -# program program to start -# arg-i extra arguments directly passed to the program started. -# - -# Get name of logfile and program. -envfile=$1 -shift -rank=$1 -shift -program=$1 -shift -logfile=$envfile.pid-$rank - - -# Start the program and log its pid (in a separate file). -$program "$@" & -pid=$! -echo "$program $*" > $logfile -echo "pid=$pid" >> $logfile - -# Wait for the program to end and log its exit status. -wait $pid >> $logfile 2>&1 -status=$? -echo "status=$status" >> $logfile -exit $status diff --git a/CEP/MWCommon/src/showclusterdesc.cc b/CEP/MWCommon/src/showclusterdesc.cc deleted file mode 100644 index 8daa7ebedaacb79eb135241c973736cd653e18c7..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/showclusterdesc.cc +++ /dev/null @@ -1,42 +0,0 @@ -//# showclusterdesc.cc: show the (expanded) ClusterDesc -//# Copyright (C) 2009 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> -#include <MWCommon/ClusterDesc.h> - -using namespace LOFAR::CEP; -using namespace std; - -int main (int argc, char* argv[]) -{ - try { - if (argc < 2) { - cerr << "Run as: showclusterdesc clusterdesc-file" << endl; - return 1; - } - ClusterDesc cdesc (argv[1]); - cdesc.write (cout); - } catch (const std::exception& x) { - cerr << "Error: " << x.what() << endl; - return 1; - } - return 0; -} diff --git a/CEP/MWCommon/src/socketrun b/CEP/MWCommon/src/socketrun deleted file mode 100755 index 3ee1cd9341688b52c94863b1068b2e21ac695285..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/socketrun +++ /dev/null @@ -1,191 +0,0 @@ -#!/bin/sh - -# socketrun: Start a distributed process using socket connections -# -# Copyright (C) 2008 -# ASTRON (Netherlands Institute for Radio Astronomy) -# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -# -# This file is part of the LOFAR software suite. -# The LOFAR software suite is free software: you can redistribute it and/or -# modify it under the terms of the GNU General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# The LOFAR software suite is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -# -# @author Ger van Diepen <diepen AT astron nl> -# -# $Id$ - - -# This script starts a distributed process to process a dataset. -# The processes will use sockets for communication. -# The processed are started in the MPI-style; a machinefile tells on which -# hosts to start a process; they also get a rank (0..n). -# -# This script is a helper script for startdistproc, but it could be used -# stand-alone as well. -# -# run as: socketrun dry hfn masterhost port wait killfail logfile program envfile -# [arg1 arg2 ...] -# -# dry!=0 means that the command is only printed, not executed. -# hfn is the name of an MPI-style machinefile. Each line in it -# looks like: host#part,filesys,partvds -# host name of the host to start a process on -# part name of the dataset part to process on the host -# filesys the file system the dataset part is on -# partvds name of the VDS-file of the dataset part -# masterhost the host the master process is running on; if empty, the first -# host in the machine file is the master host. -# port the port the master host process is using and where the workers -# can connect to. -# Note that it is up to implementation to use a masterhost/port. -# E.g. mwimager only starts distributed processes, but they do -# not communicate, so there is no master. -# wait=1 means that socketrun waits for all processes to end. -# killfail=1 means that all other remote processes are killed if one fails. -# It is only used if wait=1. -# logfile name of the log file to use; It will be suffixed with '-rank' -# where rank is the process rank. -# program name of the program to start. -# envfile name of the envfile generated by startdistproc. -# arg-i extra arguments directly passed to the program started. -# -# The processes are started with the following fixed arguments: -# socket a string with the value 'socket'. -# masterhost name of the master host -# port port on master host -# np number of processes started -# rank process rank (0..np-1) -# part name of dataset part to process -# filesys file system dataset part is on -# partvds name of VDS-file describing dataset part -# Thereafter the variable arguments (passed to socketrun) are given. - - -dry=$1 -shift -hfn=$1 -shift -masterhost=$1 -shift -port=$1 -shift -wait=$1 -shift -killfail=$1 -shift -logfile=$1 -shift -program=$1 -shift -envfile=$1 -shift - -np=`wc -l $hfn | awk '{print $1}'` - -# The first host is the master one. -pidlist= -rank=0 -for inline in `cat $hfn` -do - host=`echo $inline | awk -F'#' '{print $1'}` - rest=`echo $inline | awk -F'#' '{print $2'}` - part=`echo $rest | awk -F',' '{print $1'}` - fsys=`echo $rest | awk -F',' '{print $2'}` - partvds=`echo $rest | awk -F',' '{print $3'}` - if test "$part" = ""; then - part=. - fi - if test "$fsys" = ""; then - fsys=. - fi - if test "$partvds" = ""; then - partvds=. - fi - if test "$masterhost" = ""; then - masterhost=$host - fi - # Quote all arguments ("$@" does not work over ssh). - arg= - for a in "$@" - do - arg="$arg '$a'" - done - echo "ssh -x -n $host $program socket $masterhost $port $np $rank '$part' '$fsys' '$partvds' '$envfile' $arg" " &" - if test "$dry" = 0; then - if test "$logfile" = ""; then - ssh -x -n $host $program socket $masterhost $port $np $rank "$part" "$fsys" "$partvds" $envfile $arg & - else - ssh -x -n $host $program socket $masterhost $port $np $rank "$part" "$fsys" "$partvds" $envfile $arg > $logfile-$rank 2>&1 & - fi - pidlist="$pidlist $!" - fi - rank=`expr $rank + 1` -done - -# If needed, wait for the processes to end. -# If a process ended unsuccessfully, kill the others if needed. -if test "$wait" = 1; then - if test $killfail = 1; then - # If killonfail, wait for the first process to end. - # Poll every second. - cont=1 - while test $cont = 1 - do - sleep 1 - seqnr=0 - for pid in $pidlist - do - if ! kill -0 $pid > /dev/null 2>&1; then - cont=0 - break - fi - seqnr=`expr $seqnr + 1` - done - done - status=0 - if test -f $envfile.pid-$seqnr; then - status=`grep '^status=' $envfile.pid-$seqnr | sed -e 's/status=//'` - fi - if test $status != 0; then - echo "Remote process (pid=$pid) with rank $seqnr ended with error status $status" - echo "Killing the other remote processes ..." - rank=0 - for inline in `cat $hfn` - do - if test $rank != $seqnr -a -f $envfile.pid-$rank; then - host=`echo $inline | awk -F'#' '{print $1'}` - rempid=`grep '^pid=' $envfile.pid-$rank | sed -e 's/pid=//'` - echo "ssh -x $host kill -9 $rempid" - if test "$logfile" = ""; then - ssh -x $host kill -9 $rempid - else - ssh -x $host kill -9 $rempid >> $logfile-$rank - fi - fi - rank=`expr $rank + 1` - done - fi - fi - # Wait for all processes. - # Ignore status in case the pid does not exist anymore (error 127). - for pid in $pidlist - do - wait $pid > /dev/null 2>&1 - stat=$? - if test $stat != 0 -a $stat != 127; then - status=1 - fi - done -fi - -exit $status diff --git a/CEP/MWCommon/src/startdistproc b/CEP/MWCommon/src/startdistproc deleted file mode 100755 index a7e417eb7beec968a582c498a845f004340c0b89..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/src/startdistproc +++ /dev/null @@ -1,330 +0,0 @@ -#!/bin/sh - -# startdistproc: Start a distributed process -# -# Copyright (C) 2008 -# ASTRON (Netherlands Institute for Radio Astronomy) -# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -# -# This file is part of the LOFAR software suite. -# The LOFAR software suite is free software: you can redistribute it and/or -# modify it under the terms of the GNU General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# The LOFAR software suite is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -# -# @author Ger van Diepen <diepen AT astron nl> -# -# $Id$ - - -# This script starts a distributed process to process a dataset. -# It can use sockets or MPI. -# The VdsDesc and ClusterDesc files are used to determine on which nodes -# the various processes need to be started. -# Possible arguments can be given after the program name. They are given as -# arguments to the distributed programs. - - -# Find the path used to start the script. -pgmpath=`dirname $0` -pgmpath=`cd $pgmpath > /dev/null 2>&1 && pwd` - -# Set default options. - -useenv=0 -killfail=0 -envfile= -modxx=single -wait=1 -dsn= -cdn= -hfn= -dirs= -fdp= -master=localhost -startmaster=1 -extra= -dry=0 -logfile= -help=0 -program= -if [ $# = 0 ]; then - help=1 -fi - -# Handle possible options. -while [ $# != 0 ] -do - if [ "$1" = "-h" -o "$1" = "-help" -o "$1" = "--help" ]; then - help=1 - break - elif [ "$1" = "-useenv" ]; then - shift - useenv=1 - case "$1" in - -*) - ;; - *) - # file name given - envfile=$1 - shift - ;; - esac - elif [ "$1" = "-nouseenv" ]; then - shift - useenv=0 - elif [ "$1" = "-killonfail" ]; then - shift - killfail=1 - elif [ "$1" = "-nokillonfail" ]; then - shift - killfail=0 - elif [ "$1" = "-dsn" ]; then - shift - dsn="$1" - shift - elif [ "$1" = "-cdn" ]; then - shift - cdn="$1" - shift - elif [ "$1" = "-hfn" ]; then - shift - hfn="$1" - shift - elif [ "$1" = "-nohfn" ]; then - shift - hfn= - elif [ "$1" = "-dirs" ]; then - shift - dirs="$1" - shift - elif [ "$1" = "-nodirs" ]; then - shift - dirs= - elif [ "$1" = "-fdp" ]; then - shift - fdp="$1" - shift - elif [ "$1" = "-dry" ]; then - shift - dry=1 - elif [ "$1" = "-nodry" ]; then - shift - dry=0 - elif [ "$1" = "-logfile" ]; then - shift - logfile="$1" - shift - elif [ "$1" = "-nologfile" ]; then - shift - logfile= - elif [ "$1" = "-mode" ]; then - shift - modxx="$1" - shift - elif [ "$1" = "-wait" ]; then - shift - wait=1 - elif [ "$1" = "-nowait" ]; then - shift - wait=0 - elif [ "$1" = "-masterhost" ]; then - shift - master="$1" - shift - elif [ "$1" = "-nomasterhost" ]; then - shift - master= - elif [ "$1" = "-startmaster" ]; then - shift - startmaster=1 - elif [ "$1" = "-nostartmaster" ]; then - shift - startmaster=0 - elif [ "$1" = "-extrahosts" ]; then - shift - extra="$1" - shift - elif [ "$1" = "-noextrahosts" ]; then - shift - extra= - else - case "$1" in - -*) - echo "$1 is an unknown startdistproc option" - exit 1 - ;; - *) - # A program name has been found, so stop parsing options. - program=$1 - shift - break - ;; - esac - fi -done - -if [ $help = 1 ]; then - echo '' - echo 'startdistproc starts distributed processes to process a given dataset.' - echo 'The mode tells if it is started through MPI, sockets, or as a single process.' - echo '' - echo 'Run as:' - echo ' startdistproc [-useenv [envfilename]] [-wait] [-killonfail]' - echo ' [-cdn clusterdescname] [-dsn datasetname]' - echo ' [-dirs directories] [-mode mode]' - echo ' [-hfn hostfilename] [-fdp finddproc-path]' - echo ' [-logfile logfilename] [-dry]' - echo ' [-extrahosts "host1 host2 ..."] [-noextrahosts]' - echo ' [-masterhost host] [-startmaster] program [arg1 arg2 ...]' - echo '' - echo ' -useenv Copy *PATH and *ROOT environment variables to distributed' - echo ' processes; otherwise they source lofarinit.sh.' - echo ' Preferred behaviour is -useenv, but for backward' - echo ' compatibility it is not standard yet.' - echo ' They are passed in a file; its name can be given after -useenv.' - echo ' It defaults to "$HOME/startdistproc_$pid.envfile"' - echo ' If -useenv is given as the last option, a (possibly empty)' - echo ' file name must given, othwrwise the next argument is used.' - echo ' -wait wait for all processes to finish.' - echo ' -killonfail kill all other processes if one fails.' - echo ' It requires that -useenv is given.' - echo ' -cdn clusterdescname The name of the file describing the cluster.' - echo ' -dsn datasetname The name of the file describing the distributed dataset.' - echo ' -dirs directories Directories to use if -dsn is not given.' - echo ' Each directory can be preceeded by host: (a la scp).' - echo ' This is useful if a distributed dataset has' - echo ' to be created for which no VDS file exists yet.' - echo ' -dsn and dirs cannot be given both.' - echo ' -hfn hostfilename The name of the generated hostfile.' - echo ' It defaults to /tmp/machinefile_$USER_$$' - echo ' -fdp finddproc-path Path where to find finddproc.' - echo ' Default is empty.' - echo ' -logfile logfilename The general name of the subprocesses log files.' - echo ' They are suffixed with a sequence number.' - echo ' -dry Do a dry run (default is -nodry).' - echo ' -mode mode mode can be mpi, single, or a number.' - echo ' A number means that ssh is used to start the programs and' - echo ' defines the socket port the programs can use (if needed).' - echo ' Single means a single process is started using memory' - echo ' communication.' - echo ' -masterhost host The name of the host the master runs on.' - echo ' The default is localhost.' - echo ' -nomasterhost means that no master process is started.' - echo ' -startmaster Start the master process (which is the default).' - echo ' -nostartmaster can be used to indicate that the' - echo ' master process is running already. In that case' - echo ' only a socket connection mode can be used.' - echo ' -extrahosts hosts The hosts to be used for extra processes (e.g. solvers).' - echo ' Multiple hosts have to be separated by whitespace' - echo ' and enclosed in quotes.' - echo ' program name of the program to start.' - echo ' arg1 arg2 .. Optional extra arguments which are passed to' - echo ' the program to start.' - echo ' -h -help --help This help text.' - exit 0 -fi - -if [ "$program" = "" ]; then - echo "Error: no program name given ('startdistproc -h' gives help)" - exit 1 -fi -if test "$dsn" = "" -a "$dirs" = ""; then - echo "Error: dataset name nor directories given (use -dsn or -dirs)" - exit 1 -fi -if test "$dsn" != "" -a "$dirs" != ""; then - echo "Error: dataset name and directories given both (use -dsn or -dirs)" - exit 1 -fi -if test "$cdn" = ""; then - echo "Error: no clusterdesc name given (use -cdn)" - exit 1 -fi -if test $startmaster = 0; then - if test $modxx = "mpi" -o $modxx = "single"; then - echo "Error: -nostartmaster cannot be used with mode=mpi or single" - exit 1 - fi -fi -if test ! -f "$cdn"; then - echo "Error: clusterdesc $cdn not found" - exit 1 -fi -hfnorg=$hfn -if test "$hfn" = ""; then - hfn="/tmp/machinefile_$USER_$$" -fi -if test "$fdp" != ""; then - fdp="$fdp/" -fi -if test $modxx = "mpi" -o $modxx = "single"; then - killfail=0 -fi -if test $killfail = 1 -a $useenv != 1; then - echo "-useenv is mandatory if -killonfail is given" - exit 1 -fi - -# Prepend the hosts with the master and extra hosts. -# Only give a master if it needs to be started. -masterh=$master -if test $startmaster = 0; then - masterh= -fi -# If a dataset name is given, find out where to process it. -if test "$dsn" != ""; then - if test ! -f "$dsn"; then - echo "Error: dataset $dsn not found" - exit 1 - fi - ${fdp}finddproc $dsn $cdn $masterh $extra > $hfn || exit 1 -else - ${fdp}finddproc -dirs "$dirs" $cdn $masterh $extra > $hfn || exit 1 -fi -np=`wc -l $hfn | awk '{print $1}'` - -# Find all PATH and ROOT variables and store in a file with the pid in its name. -# Note that $envfile is empty if $useenv is not set. That is exactly what we need -# in the mpirun and socketrun lines. -if [ "$useenv" = 1 ]; then - if test "$envfile" = ""; then - envfile=$HOME/startdistproc_$$.envfile - fi - grex='[^=]*(PATH|ROOT)' - printenv | egrep "^$grex=" | sed -e "s/^\([^=]*\)=\(.*\)/\1='\2'; export \1/;" > $envfile -fi - -# Run the program as needed. -if test "$modxx" = "mpi"; then - sed -e "s/#.*//" $hfn > ${hfn}_tmp - mv ${hfn}_tmp $hfn - echo "mpirun -np $np -machinefile $hfn $program $envfile" "$@" - if test $dry = 0; then - mpirun -np $np -machinefile $hfn $program $envfile "$@" || exit 1 - fi -elif test "$modxx" = "single"; then - echo "$program $@" - if test $dry = 0; then - $program "$@" || exit 1 - fi -else - echo "socketrun $dry $hfn '$master' $modxx $wait $killfail $logfile $program $envfile" "$@" - $pgmpath/socketrun $dry $hfn "$master" $modxx $wait $killfail "$logfile" $program $envfile "$@" || exit 1 -fi -# The envfile can be deleted if it waited for the subprocesses to end. -if test $wait = 1 -a "$envfile" != ""; then - rm -f $envfile -fi -# Delete hfn if default name was used (it needs to be kept for tstartdproc). -if test "$hfnorg" = ""; then - rm -f $hfn -fi diff --git a/CEP/MWCommon/test/CMakeLists.txt b/CEP/MWCommon/test/CMakeLists.txt deleted file mode 100644 index 2fb18c6adea5a40d1dee8c9ffbde1a687a3273e6..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -# $Id$ - -include(LofarCTest) - -lofar_add_test(tClusterDesc tClusterDesc.cc) -lofar_add_test(tNodeDesc tNodeDesc.cc) -lofar_add_test(tVdsDesc tVdsDesc.cc) -lofar_add_test(tVdsPartDesc tVdsPartDesc.cc) -lofar_add_test(tWorkersDesc tWorkersDesc.cc) -lofar_add_test(tSocketConnection tSocketConnection.cc) -lofar_add_test(tSocketConnectionSet tSocketConnectionSet.cc) -lofar_add_test(tfinddproc DEPENDS finddproc) -lofar_add_test(tstartdproc tstartdproc.cc) -lofar_add_test(trundist) diff --git a/CEP/MWCommon/test/tClusterDesc.cc b/CEP/MWCommon/test/tClusterDesc.cc deleted file mode 100644 index e0345065afd6077dd06dee6173d40e681a1fb9c9..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tClusterDesc.cc +++ /dev/null @@ -1,153 +0,0 @@ -//# tClusterDesc.cc: Test program for class ClusterDesc -//# -//# Copyright (C) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/ClusterDesc.h> -#include <Common/LofarLogger.h> -#include <Common/ParameterSet.h> -#include <ostream> -#include <fstream> - -using namespace std; -using namespace LOFAR; -using namespace LOFAR::CEP; - -void check (const ClusterDesc& cl) -{ - ASSERT (cl.getName() == "cl"); - ASSERT (cl.getNodes().size() == 2); - const vector<NodeDesc>& nodes = cl.getNodes(); - ASSERT (nodes[0].getName() == "node1"); - ASSERT (nodes[1].getName() == "node2"); - ASSERT (nodes[0].getType() == NodeDesc::Any); - ASSERT (nodes[1].getType() == NodeDesc::Any); - ASSERT (nodes[0].getFileSys().size() == 2); - ASSERT (nodes[0].getFileSys()[0] == "fs0"); - ASSERT (nodes[0].getFileSys()[1] == "fs1"); - ASSERT (nodes[1].getFileSys().size() == 2); - ASSERT (nodes[1].getFileSys()[0] == "fs1"); - ASSERT (nodes[1].getFileSys()[1] == "fs2"); - ASSERT (cl.getMap().size() == 3); - map<string,vector<int> >::const_iterator fsmap; - fsmap = cl.getMap().find("fs0"); - ASSERT (fsmap->second.size() == 1); - ASSERT (nodes[fsmap->second[0]].getName() == "node1"); - fsmap = cl.getMap().find("fs1"); - ASSERT (fsmap->second.size() == 2); - ASSERT (nodes[fsmap->second[0]].getName() == "node1"); - ASSERT (nodes[fsmap->second[1]].getName() == "node2"); - fsmap = cl.getMap().find("fs2"); - ASSERT (fsmap->second.size() == 1); - ASSERT (nodes[fsmap->second[0]].getName() == "node2"); -} - -void doIt() -{ - cout << "Creating ClusterDesc ..." << endl; - ClusterDesc cl; - cl.setName ("cl"); - NodeDesc node1; - node1.setName ("node1"); - node1.addFileSys ("fs0", "/auto/fs0"); - node1.addFileSys ("fs1", "/fs1"); - cl.addNode (node1); - NodeDesc node2; - node2.setName ("node2"); - node2.addFileSys ("fs1", "/auto/fs1"); - node2.addFileSys ("fs2", "/fs2"); - cl.addNode (node2); - cout << "Checking ClusterDesc ..." << endl; - check(cl); - // Write into parset file. - cout << "Writing ClusterDesc ..." << endl; - ofstream fos("tClusterDesc_tmp.fil"); - cl.write (fos); - // Read back. - cout << "Reading ClusterDesc ..." << endl; - ClusterDesc cl2("tClusterDesc_tmp.fil"); - cout << "Checking ClusterDesc ..." << endl; - check(cl2); - cout << "Copying ClusterDesc ..." << endl; - cl = cl2; - cout << "Checking ClusterDesc ..." << endl; - check(cl); -} - -void check1 (const ClusterDesc& cl, const string& expectedName) -{ - ASSERT (cl.getName() == expectedName); - const vector<NodeDesc>& nodes = cl.getNodes(); - ASSERT (nodes.size() == 4); - ASSERT (nodes[0].getName() == "lifs001"); - ASSERT (nodes[1].getName() == "lifs002"); - ASSERT (nodes[2].getName() == "lifs003"); - ASSERT (nodes[3].getName() == "lifsfen"); - for (uint i=0; i<3; ++i) { - ASSERT (nodes[i].getFileSys().size() == 3); - ASSERT (nodes[i].getFileSys()[0] == "/lifs014"); - ASSERT (nodes[i].getFileSys()[1] == "/lifs015"); - ASSERT (nodes[i].getFileSys()[2] == nodes[i].getName() + ":/data"); - ASSERT (nodes[i].getMountPoints()[0] == "/lifs014"); - ASSERT (nodes[i].getMountPoints()[1] == "/lifs015"); - ASSERT (nodes[i].getMountPoints()[2] == "/data"); - } - ASSERT (nodes[3].getFileSys().size() == 2); - ASSERT (nodes[3].getMountPoints().size() == 2); - ASSERT (nodes[3].getFileSys()[0] == "/abc"); - ASSERT (nodes[3].getFileSys()[1] == "lifsfen:/data"); - ASSERT (nodes[3].getMountPoints()[0] == "/abc"); - ASSERT (nodes[3].getMountPoints()[1] == "/data"); -} - -void doParset() -{ - cout << "Reading from tClusterDesc.parset ..." << endl; - // Read from a shorthand parset. - ClusterDesc cdesc("tClusterDesc.parset"); - check1 (cdesc, "lifs"); - // Write into full-blown parset file. - cout << "Writing into tClusterDesc_tmp.file ..." << endl; - ofstream fos("tClusterDesc_tmp.fil2"); - cdesc.write (fos); - // Read back. - cout << "Reading back from tClusterDesc_tmp.file ..." << endl; - ClusterDesc cl2("tClusterDesc_tmp.fil2"); - check1 (cl2, "lifs"); - // Read from a subcluster parset. - cout << "Reading from tClusterDesc.in_parset2 ..." << endl; - ClusterDesc cdesc2("tClusterDesc.in_parset2"); - check1 (cdesc2, "lifs1"); -} - -int main() -{ - try { - doIt(); - doParset(); - } catch (std::exception& x) { - cout << "Unexpected exception: " << x.what() << endl; - return 1; - } - cout << "OK" << endl; - return 0; -} diff --git a/CEP/MWCommon/test/tClusterDesc.in_parset2 b/CEP/MWCommon/test/tClusterDesc.in_parset2 deleted file mode 100644 index 36cafe6ce661525283823532157eb2f63a63638d..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tClusterDesc.in_parset2 +++ /dev/null @@ -1,4 +0,0 @@ -# Test cluster definition file. - -ClusterName = lifs1 -SubClusters = [ tClusterDesc.parset, tClusterDesc.parset ] diff --git a/CEP/MWCommon/test/tClusterDesc.parset b/CEP/MWCommon/test/tClusterDesc.parset deleted file mode 100644 index ff6bbaa291a9cd53b50916d1d7bb43c60b06f12f..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tClusterDesc.parset +++ /dev/null @@ -1,10 +0,0 @@ -# Test cluster definition file. - -ClusterName = lifs -Head.Nodes = lifsfen -Head.LocalDisks = [ /data ] -Head.RemoteDisks.lifsfen = /abc - -Compute.Nodes = [ lifs001..lifs003 ] -Compute.LocalDisks = [ /data ] -Compute.RemoteDisks = [ /lifs014../lifs015 ] diff --git a/CEP/MWCommon/test/tClusterDesc.sh b/CEP/MWCommon/test/tClusterDesc.sh deleted file mode 100755 index 7f628d80133e89ec9a8af35972b2b57963afc941..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tClusterDesc.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./runctest.sh tClusterDesc > tClusterDesc.log 2>&1 diff --git a/CEP/MWCommon/test/tNodeDesc.cc b/CEP/MWCommon/test/tNodeDesc.cc deleted file mode 100644 index b590db6dd1ab9993012d9e2e2d200647b1675997..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tNodeDesc.cc +++ /dev/null @@ -1,82 +0,0 @@ -//# tNodeDesc.cc: Test program for class NodeDesc -//# -//# Copyright (C) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/NodeDesc.h> -#include <Common/LofarLogger.h> -#include <Common/ParameterSet.h> -#include <ostream> -#include <fstream> - -using namespace std; -using namespace LOFAR; -using namespace LOFAR::CEP; - -void check (const NodeDesc& node) -{ - ASSERT (node.getName() == "node1"); - ASSERT (node.getFileSys().size() == 2); - ASSERT (node.getFileSys()[0] == "fs0"); - ASSERT (node.getFileSys()[1] == "fs1"); - ASSERT (node.getMountPoints()[0] == "/fs0/fs1"); - ASSERT (node.getMountPoints()[1] == "/fs1"); - - ASSERT (node.findFileSys ("/fs1/abc") == "fs1"); - ASSERT (node.findFileSys ("/fs0/fs1/abc") == "fs0"); - ASSERT (node.findFileSys ("/fs0/abc") == ""); -} - -void doIt() -{ - NodeDesc node; - node.setName ("node1"); - node.addFileSys ("fs0", "/auto/fs0/fs1"); - node.addFileSys ("fs1", "/fs1"); - check(node); - // Write into parset file. - ofstream fos("tNodeDesc_tmp.fil"); - node.write (fos, ""); - // Read back. - ParameterSet parset("tNodeDesc_tmp.fil"); - NodeDesc node2(parset); - check(node2); - node = node2; - check(node); - // Chck that findFileSys handles a single / correctly. - node.addFileSys ("fs2", "/"); - ASSERT (node.findFileSys ("/fs1/abc") == "fs1"); - ASSERT (node.findFileSys ("/fs0/fs1/abc") == "fs0"); - ASSERT (node.findFileSys ("/fs0/abc") == "fs2"); -} - -int main() -{ - try { - doIt(); - } catch (std::exception& x) { - cout << "Unexpected exception: " << x.what() << endl; - return 1; - } - cout << "OK" << endl; - return 0; -} diff --git a/CEP/MWCommon/test/tNodeDesc.sh b/CEP/MWCommon/test/tNodeDesc.sh deleted file mode 100755 index 92c361a54822fd9f7a52f3a53980a87a2ed39b8f..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tNodeDesc.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./runctest.sh tNodeDesc > tNodeDesc.log 2>&1 diff --git a/CEP/MWCommon/test/tSocketConnection.cc b/CEP/MWCommon/test/tSocketConnection.cc deleted file mode 100644 index b5eadde203a0fa2bd96fb0b4a57a080c82b2c4ef..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tSocketConnection.cc +++ /dev/null @@ -1,94 +0,0 @@ -//# tSocketConnection.cc: Program to test SocketConnection -//# -//# Copyright (C) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/SocketConnection.h> -#include <MWCommon/SocketListener.h> -#include <Common/LofarLogger.h> -#include <iostream> -#include <unistd.h> - -using namespace LOFAR::CEP; -using namespace std; - -void doClient (const string& host, const string& port) -{ - // sleep (2); - cout << "Client connection on host " << host - << ", port " << port << endl; - SocketConnection socket(host, port); - double dv = 1; - socket.send (&dv, sizeof(dv)); - cout << "sent " << dv << endl; - float fv = 0; - socket.receive (&fv, sizeof(fv)); - ASSERT (fv == 2); - cout << "received " << fv << endl; - sleep(2); - socket.receive (&fv, sizeof(fv)); - ASSERT (fv == 3); - cout << "received " << fv << endl; - dv = 2; - socket.send (&dv, sizeof(dv)); - cout << "sent " << dv << endl; -} - -void doServer (const string& port) -{ - cout << "Server connection on port " << port << endl; - SocketListener listener(port); - SocketConnection::ShPtr socket = listener.accept(); - double dv = 0; - socket->receive (&dv, sizeof(dv)); - ASSERT (dv == 1); - cout << "received " << dv << endl; - float fv = 2; - socket->send (&fv, sizeof(fv)); - cout << "sent " << fv << endl; - fv = 3; - socket->send (&fv, sizeof(fv)); - cout << "sent " << fv << endl; - socket->receive (&dv, sizeof(dv)); - ASSERT (dv == 2); - cout << "received " << dv << endl; -} - -int main(int argc, const char* argv[]) -{ - int status = 0; - try { - if (argc < 2) { - cerr << "Run as:" << endl; - cerr << " as server: tSocketConnection port" << endl; - cerr << " as client: tSocketConnection port host" << endl; - } else if (argc == 2) { - doServer (argv[1]); - } else { - doClient (argv[2], argv[1]); - } - } catch (std::exception& x) { - cout << "Unexpected exception in " << argv[0] << ": " << x.what() << endl; - status = 1; - } - exit(status); -} diff --git a/CEP/MWCommon/test/tSocketConnection.run b/CEP/MWCommon/test/tSocketConnection.run deleted file mode 100755 index 1264cdcc0d45b2bab35cf972a3e48ad6f2f7acc7..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tSocketConnection.run +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh - -# tSocketConnection: Test class SocketConnection in various ways -# -# Copyright (C) 2008 -# ASTRON (Netherlands Institute for Radio Astronomy) -# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -# -# This file is part of the LOFAR software suite. -# The LOFAR software suite is free software: you can redistribute it and/or -# modify it under the terms of the GNU General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# The LOFAR software suite is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -# -# @author Ger van Diepen <diepen AT astron nl> -# -# $Id$ - - -# Run the tSocketConnection test program by starting it twice, -# once as server and once as client. -./tSocketConnection 3851 > tSocketConnection_tmp.outs1 & -./tSocketConnection 3851 localhost > tSocketConnection_tmp.outc1 - -# If something went wrong, kill the background process (if it's still running) -# and exit. -STATUS=$? -if [ $STATUS != 0 ]; then - if kill -0 $! 2>/dev/null; then - kill -9 $! 2>/dev/null - fi - exit $STATUS -fi - -# Output the result in order. -sleep 1 -echo "Run1 ..." -cat tSocketConnection_tmp.outs1 tSocketConnection_tmp.outc1 - - -# Do another run, now starting the client before the server. -./tSocketConnection 3851 localhost > tSocketConnection_tmp.outc2 & -./tSocketConnection 3851 > tSocketConnection_tmp.outs2 - -# If something went wrong, kill the background process (if it's still running) -# and exit. -STATUS=$? -if [ $STATUS != 0 ]; then - if kill -0 $! 2>/dev/null; then - kill -9 $! 2>/dev/null - fi - exit $STATUS -fi - -# Output the result in order. -sleep 1 -echo "Run2 ..." -cat tSocketConnection_tmp.outs2 tSocketConnection_tmp.outc2 -exit 0 diff --git a/CEP/MWCommon/test/tSocketConnection.sh b/CEP/MWCommon/test/tSocketConnection.sh deleted file mode 100755 index 7b340dea21812c253f20894e2e73390414dbb8cf..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tSocketConnection.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./runctest.sh tSocketConnection > tSocketConnection.log 2>&1 diff --git a/CEP/MWCommon/test/tSocketConnection.stdout b/CEP/MWCommon/test/tSocketConnection.stdout deleted file mode 100644 index d6a1f5e09bb3fe2ad27c8f911f1caf80fc1c6b00..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tSocketConnection.stdout +++ /dev/null @@ -1,22 +0,0 @@ -Run1 ... -Server connection on port 3851 -received 1 -sent 2 -sent 3 -received 2 -Client connection on host localhost, port 3851 -sent 1 -received 2 -received 3 -sent 2 -Run2 ... -Server connection on port 3851 -received 1 -sent 2 -sent 3 -received 2 -Client connection on host localhost, port 3851 -sent 1 -received 2 -received 3 -sent 2 diff --git a/CEP/MWCommon/test/tSocketConnectionSet.cc b/CEP/MWCommon/test/tSocketConnectionSet.cc deleted file mode 100644 index 06024e7c1dcb2757d7e00714d4865298e93a20b9..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tSocketConnectionSet.cc +++ /dev/null @@ -1,100 +0,0 @@ -//# tSocketConnection.cc: Program to test SocketConnection -//# -//# Copyright (C) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/SocketConnectionSet.h> -#include <MWCommon/MWBlobIO.h> -#include <Common/LofarLogger.h> -#include <iostream> -#include <unistd.h> - -using namespace LOFAR::CEP; -using namespace LOFAR; -using namespace std; - -void doClient (const string& host, const string& port, const string& name) -{ - cout << "Client connection on host " << host - << ", port " << port << ", name=" << name << endl; - SocketConnection conn(host, port); - BlobString buf; - MWBlobOut bbo(buf, 1, 2, 3); - bbo.blobStream() << name; - bbo.finish(); - cout << "client " << name << " sends " << buf.size() << " bytes" << endl; - conn.write(buf); - conn.read (buf); - cout << "client " << name << " received " << buf.size() << " bytes" << endl; - MWBlobIn bbi(buf); - double dv; - int32 iv; - bbi.blobStream() >> dv >> iv; - bbi.finish(); - ASSERT (dv == 1 && iv == 4); -} - -void doServer (const string& port) -{ - SocketListener listener(port); - SocketConnectionSet sockSet(listener); - cout << "Server connectionset on port " << port << endl; - sockSet.addConnections (2); - cout << ">>>" << endl; - for (int i=0; i<sockSet.size(); ++i) { - BlobString buf; - sockSet.read (i, buf); - cout << "server received " << buf.size() << " bytes" << endl; - MWBlobIn bbi(buf); - string name; - bbi.blobStream() >> name; - bbi.finish(); - cout << "name=" << name << endl; - } - cout << "<<<" << endl; - BlobString buf; - MWBlobOut bbo(buf, 2, 3, 4); - bbo.blobStream() << double(1) << int32(4); - bbo.finish(); - cout << "server sends " << buf.size() << " bytes" << endl; - sockSet.writeAll (buf); -} - -int main(int argc, const char* argv[]) -{ - int status = 0; - try { - if (argc < 2) { - cerr << "Run as:" << endl; - cerr << " as server: tSocketConnection port" << endl; - cerr << " as client: tSocketConnection port host name" << endl; - } else if (argc == 2) { - doServer (argv[1]); - } else { - doClient (argv[2], argv[1], argv[3]); - } - } catch (std::exception& x) { - cout << "Unexpected exception in " << argv[0] << ": " << x.what() << endl; - status = 1; - } - exit(status); -} diff --git a/CEP/MWCommon/test/tSocketConnectionSet.run b/CEP/MWCommon/test/tSocketConnectionSet.run deleted file mode 100755 index 25d83e03a344b5985ac1dc3f9c98eb60ac65effb..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tSocketConnectionSet.run +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/sh - -# tSocketConnectionSet: Test class SocketConnectionSet in various ways -# -# Copyright (C) 2008 -# ASTRON (Netherlands Institute for Radio Astronomy) -# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -# -# This file is part of the LOFAR software suite. -# The LOFAR software suite is free software: you can redistribute it and/or -# modify it under the terms of the GNU General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# The LOFAR software suite is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -# -# @author Ger van Diepen <diepen AT astron nl> -# -# $Id$ - - -# Run the tSocketConnectionSet test program by starting it thrice, -# once as server and twice as client. -./tSocketConnectionSet 3851 > tSocketConnectionSet_tmp.outs1 & -pid1=$! -./tSocketConnectionSet 3851 localhost cl1> tSocketConnectionSet_tmp.outc1 & -pid2=$! -./tSocketConnectionSet 3851 localhost client2 > tSocketConnectionSet_tmp.outc2 - -# If something went wrong, kill the background processes (if still running) -# and exit. -STATUS=$? -if [ $STATUS != 0 ]; then - for pid in $pid1 $pid2 - do - if kill -0 $pid 2>/dev/null; then - kill -9 $pid 2>/dev/null - fi - done - exit $STATUS -fi - -# Output the result in order. -sleep 1 -echo "Run1 ..." -cat tSocketConnectionSet_tmp.outs1 tSocketConnectionSet_tmp.outc1 tSocketConnectionSet_tmp.outc2 - - -# Do another run, now starting the clients before the server. -./tSocketConnectionSet 3851 localhost client1 > tSocketConnectionSet_tmp.outc3 & -pid1=$! -./tSocketConnectionSet 3851 localhost clien2 > tSocketConnectionSet_tmp.outc4 & -pid2=$! -./tSocketConnectionSet 3851 > tSocketConnectionSet_tmp.outs2 - -# If something went wrong, kill the background processes (if still running) -# and exit. -STATUS=$? -if [ $STATUS != 0 ]; then - for pid in $pid1 $pid2 - do - if kill -0 $pid 2>/dev/null; then - kill -9 $pid 2>/dev/null - fi - done - exit $STATUS -fi - -# Output the result in order. -sleep 1 -echo "Run2 ..." -cat tSocketConnectionSet_tmp.outs2 tSocketConnectionSet_tmp.outc3 tSocketConnectionSet_tmp.outc4 -exit 0 diff --git a/CEP/MWCommon/test/tSocketConnectionSet.sh b/CEP/MWCommon/test/tSocketConnectionSet.sh deleted file mode 100755 index 2c072ba125321f98a574731680c0fe96731222fb..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tSocketConnectionSet.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./runctest.sh tSocketConnectionSet > tSocketConnectionSet.log 2>&1 diff --git a/CEP/MWCommon/test/tSocketConnectionSet.stdout b/CEP/MWCommon/test/tSocketConnectionSet.stdout deleted file mode 100644 index 62207f5280685104e4f55058b9f8991cc78ba8bd..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tSocketConnectionSet.stdout +++ /dev/null @@ -1,30 +0,0 @@ -Run1 ... -Server connectionset on port 3851 ->>> -server received 65 bytes -name=cl1 -server received 69 bytes -name=client2 -<<< -server sends 66 bytes -Client connection on host localhost, port 3851, name=cl1 -client cl1 sends 65 bytes -client cl1 received 66 bytes -Client connection on host localhost, port 3851, name=client2 -client client2 sends 69 bytes -client client2 received 66 bytes -Run2 ... -Server connectionset on port 3851 ->>> -server received 68 bytes -name=clien2 -server received 69 bytes -name=client1 -<<< -server sends 66 bytes -Client connection on host localhost, port 3851, name=client1 -client client1 sends 69 bytes -client client1 received 66 bytes -Client connection on host localhost, port 3851, name=clien2 -client clien2 sends 68 bytes -client clien2 received 66 bytes diff --git a/CEP/MWCommon/test/tVdsDesc.cc b/CEP/MWCommon/test/tVdsDesc.cc deleted file mode 100644 index 9f26db2cacb49cdfc45b0a57ce5d92b5b3818e8a..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tVdsDesc.cc +++ /dev/null @@ -1,98 +0,0 @@ -//# tVdsDesc.cc: Test program for class VdsDesc -//# -//# Copyright (C) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/VdsDesc.h> -#include <Common/LofarLogger.h> -#include <Common/ParameterSet.h> -#include <ostream> -#include <fstream> - -using namespace std; -using namespace casa; -using namespace LOFAR; -using namespace LOFAR::CEP; - -void checkVds (const VdsPartDesc& vds, double endTime) -{ - ASSERT (vds.getName() == "/usr/local/xyx"); - ASSERT (vds.getFileSys() == "node1:/usr"); - ASSERT (vds.getStartTime() == 0); - ASSERT (vds.getStepTime() == 0.5); - ASSERT (vds.getEndTime() == endTime); - ASSERT (vds.getNChan().size() == 2); - ASSERT (vds.getNChan()[0] == 2); - ASSERT (vds.getNChan()[1] == 3); - ASSERT (vds.getStartFreqs().size() == 5); - ASSERT (vds.getStartFreqs()[0] == 20); - ASSERT (vds.getStartFreqs()[1] == 60); - ASSERT (vds.getStartFreqs()[2] == 120); - ASSERT (vds.getStartFreqs()[3] == 180); - ASSERT (vds.getStartFreqs()[4] == 240); - ASSERT (vds.getEndFreqs().size() == 5); - ASSERT (vds.getEndFreqs()[0] == 60); - ASSERT (vds.getEndFreqs()[1] == 100); - ASSERT (vds.getEndFreqs()[2] == 180); - ASSERT (vds.getEndFreqs()[3] == 240); - ASSERT (vds.getEndFreqs()[4] == 300); -} - -void check (const VdsDesc& vfds) -{ - checkVds (vfds.getDesc(), 1); - checkVds (vfds.getParts()[0], 2); -} - -void doIt() -{ - VdsPartDesc vds; - vds.setName ("/usr/local/xyx", "node1:/usr"); - vds.setTimes (0, 1, 0.5); - vds.addBand (2, 20, 100); - vds.addBand (3, 120, 300); - VdsDesc vfds(vds); - vds.setTimes(0, 2, 0.5); - vfds.addPart (vds); - check(vfds); - // Write into parset file. - ofstream fos("tVdsDesc_tmp.fil"); - vfds.write (fos); - // Read back. - ParameterSet parset("tVdsDesc_tmp.fil"); - VdsDesc vfds2(parset); - check(vfds2); - vfds = vfds2; - check(vfds); -} - -int main() -{ - try { - doIt(); - } catch (std::exception& x) { - cout << "Unexpected exception: " << x.what() << endl; - return 1; - } - cout << "OK" << endl; - return 0; -} diff --git a/CEP/MWCommon/test/tVdsDesc.sh b/CEP/MWCommon/test/tVdsDesc.sh deleted file mode 100755 index 4bb37dafdae010183321f83d2ebbd77da4b7b84c..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tVdsDesc.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./runctest.sh tVdsDesc > tVdsDesc.log 2>&1 diff --git a/CEP/MWCommon/test/tVdsPartDesc.cc b/CEP/MWCommon/test/tVdsPartDesc.cc deleted file mode 100644 index 337c102a1124f61c5792fa6a07a4f2aeffe373e1..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tVdsPartDesc.cc +++ /dev/null @@ -1,128 +0,0 @@ -//# tVdsPartDesc.cc: Test program for class VdsPartDesc -//# -//# Copyright (C) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/VdsPartDesc.h> -#include <Blob/BlobString.h> -#include <Blob/BlobOBufString.h> -#include <Blob/BlobIBufString.h> -#include <Common/LofarLogger.h> -#include <Common/ParameterSet.h> -#include <ostream> -#include <fstream> - -using namespace LOFAR; -using namespace LOFAR::CEP; -using namespace std; - -void check (const VdsPartDesc& vds, uint nTimes=0) -{ - ASSERT (vds.getName() == "/usr/local/xyx"); - ASSERT (vds.getFileName() == "/usr/local/abcd"); - ASSERT (vds.getFileSys() == "node1:/usr"); - ASSERT (vds.getClusterDescName() == "/usr/local/cdesc.dat"); - ASSERT (vds.getStartTime() == 0.5); - ASSERT (vds.getEndTime() == 1); - ASSERT (vds.getStepTime() == 0.25); - ASSERT (vds.getStartTimes().size() == nTimes); - ASSERT (vds.getEndTimes().size() == nTimes); - if (nTimes > 0) { - ASSERT (vds.getStartTimes()[0] == 1); - ASSERT (vds.getStartTimes()[nTimes-1] == 1); - ASSERT (vds.getEndTimes()[0] == 2); - ASSERT (vds.getEndTimes()[nTimes-1] == 2); - } - ASSERT (vds.getNChan().size() == 2); - ASSERT (vds.getNChan()[0] == 2); - ASSERT (vds.getNChan()[1] == 3); - ASSERT (vds.getStartFreqs().size() == 5); - ASSERT (vds.getStartFreqs()[0] == 20); - ASSERT (vds.getStartFreqs()[1] == 60); - ASSERT (vds.getStartFreqs()[2] == 123456789); - ASSERT (vds.getStartFreqs()[3] == 123456790); - ASSERT (vds.getStartFreqs()[4] == 123456791); - ASSERT (vds.getEndFreqs().size() == 5); - ASSERT (vds.getEndFreqs()[0] == 60); - ASSERT (vds.getEndFreqs()[1] == 100); - ASSERT (vds.getEndFreqs()[2] == 123456790); - ASSERT (vds.getEndFreqs()[3] == 123456791); - ASSERT (vds.getEndFreqs()[4] == 123456792); - ASSERT (vds.getParms().size() == 1); - ASSERT (vds.getParms().getString("key1") == "value1"); -} - -void doIt() -{ - VdsPartDesc vds; - vds.setName ("/usr/local/abcd", "node1:/usr"); - ASSERT (vds.getFileName().empty()); - vds.setFileName ("/usr/local/abcd"); - vds.setClusterDescName ("/usr/local/cdesc.dat"); - vds.changeBaseName ("xyx"); - vds.setTimes (0.5, 1, 0.25); - vds.addBand (2, 20, 100); - vds.addBand (3, 123456789, 123456792); - vds.addParm ("key1", "value1"); - check(vds); - // Write into parset file. - ofstream fos("tVdsPartDesc_tmp.fil"); - vds.write (fos, ""); - // Read back. - ParameterSet parset("tVdsPartDesc_tmp.fil"); - VdsPartDesc vds2(parset); - check(vds2); - vds = vds2; - check(vds); - // Check writing/reading from/to blob. - BlobString bstr; - BlobOBufString bobs(bstr); - BlobOStream bos(bobs); - bos << vds; - BlobIBufString bibs(bstr); - BlobIStream bis(bibs); - VdsPartDesc vdsb; - bis >> vdsb; - check (vdsb); - // Add some times and check again. - vdsb.setTimes (0.5, 1, 0.25, vector<double>(10,1), vector<double>(10,2)); - check (vdsb, 10); - // Check if times are written as well. - ofstream fos2("tVdsPartDesc_tmp.fil2"); - vdsb.write (fos2, ""); - VdsPartDesc vdsb2(ParameterSet("tVdsPartDesc_tmp.fil2")); - check(vdsb2, 10); - vdsb.clearParms(); - ASSERT (vdsb.getParms().size() == 0); -} - -int main() -{ - try { - doIt(); - } catch (std::exception& x) { - cout << "Unexpected exception: " << x.what() << endl; - return 1; - } - cout << "OK" << endl; - return 0; -} diff --git a/CEP/MWCommon/test/tVdsPartDesc.sh b/CEP/MWCommon/test/tVdsPartDesc.sh deleted file mode 100755 index 4ad5168fe7362b22c72a49ca3cf2228fc8b6397a..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tVdsPartDesc.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./runctest.sh tVdsPartDesc > tVdsPartDesc.log 2>&1 diff --git a/CEP/MWCommon/test/tWorkersDesc.cc b/CEP/MWCommon/test/tWorkersDesc.cc deleted file mode 100644 index 812be5f32f891eccdbc2c72dbc46bf37b5e68de7..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tWorkersDesc.cc +++ /dev/null @@ -1,168 +0,0 @@ -//# tWorkersDesc.cc: Test program for class WorkersDesc -//# -//# Copyright (C) 2007 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# $Id$ - -#include <lofar_config.h> - -#include <MWCommon/WorkersDesc.h> -#include <Common/LofarLogger.h> -#include <ostream> - -using namespace LOFAR::CEP; -using namespace std; - -void doIt1() -{ - // First define the cluster. - // File systems can be accessed from multiple nodes. - ClusterDesc cl; - cl.setName ("cl"); - NodeDesc node0; - node0.setName ("node0"); - node0.addFileSys ("fs0", "/fs0"); - node0.addFileSys ("fs1", "/fs1"); - cl.addNode (node0); - NodeDesc node1; - node1.setName ("node1"); - node1.addFileSys ("fs1", "/fs1"); - node1.addFileSys ("fs2", "/fs2"); - cl.addNode (node1); - NodeDesc node2; - node2.setName ("node2"); - node2.setType (NodeDesc::Storage); - node2.addFileSys ("fs0", "/fs0"); - node2.addFileSys ("fs1", "/fs1"); - node2.addFileSys ("fs2", "/fs2"); - cl.addNode (node2); - WorkersDesc wdesc(cl); - // Now define all workers which can perform 2 work types. - vector<int> wtypes(2); - wtypes[0] = 0; - wtypes[1] = 1; - wdesc.addWorker (0, "node0", wtypes); - wdesc.addWorker (1, "node1", wtypes); - wdesc.addWorker (2, "node2", wtypes); - // Now find a worker for a specific task on a file system. - int worker; - worker = wdesc.findWorker (0, "fs0"); - ASSERT (worker == 0); - wdesc.incrLoad (worker); - worker = wdesc.findWorker (0, "fs2"); - ASSERT (worker == 1); - wdesc.incrLoad (worker); - worker = wdesc.findWorker (0, "fs1", NodeDesc::Any); - ASSERT (worker == 2); - wdesc.incrLoad (worker); - worker = wdesc.findWorker (0, "fs2"); - ASSERT (worker == 1); - wdesc.incrLoad (worker); - // Test the difference between asking for Compute or Any. - worker = wdesc.findWorker (0, "fs2", NodeDesc::Compute); - ASSERT (worker == 1); - worker = wdesc.findWorker (0, "fs2", NodeDesc::Any); - ASSERT (worker == 2); - worker = wdesc.findWorker (0, "fs1"); - ASSERT (worker == 0); - worker = wdesc.findWorker (0, "fs0"); - ASSERT (worker == 0); - wdesc.incrLoad (worker); - worker = wdesc.findWorker (0, "fs0", NodeDesc::Any); - ASSERT (worker == 2); - wdesc.incrLoad (worker); - wdesc.incrLoad (0); - wdesc.incrLoad (1); - // At this point worker 0 and 1 have load 3, while worker 3 has load 2. - // Do tests without giving a file system. - // Test the difference between asking for Compute or Any. - worker = wdesc.findWorker (1, "", NodeDesc::Compute); - ASSERT (worker == 0); - worker = wdesc.findWorker (1, "", NodeDesc::Any); - ASSERT (worker == 2); - wdesc.incrLoad (worker); - ASSERT (wdesc.findWorker (2, "") == -1); - ASSERT (wdesc.findWorker (0, "fs3") == -1); -} - -void doIt2() -{ - // First define the cluster. - // FIle systems can be accessed from a single node. - ClusterDesc cl; - cl.setName ("cl"); - NodeDesc node0; - node0.setName ("node0"); - node0.addFileSys ("fs0", "/fs0"); - cl.addNode (node0); - NodeDesc node1; - node1.setName ("node1"); - node1.addFileSys ("fs1", "/fs1"); - cl.addNode (node1); - NodeDesc node2; - node2.setName ("node2"); - node2.addFileSys ("fs2", "/fs2"); - cl.addNode (node2); - WorkersDesc wdesc(cl); - // Now define all workers which can perform 2 work types. - vector<int> wtypes(2); - wtypes[0] = 0; - wtypes[1] = 1; - wdesc.addWorker (0, "node0", wtypes); - wdesc.addWorker (1, "node1", wtypes); - wdesc.addWorker (2, "node2", wtypes); - // Now find a worker for a specific task on a file system. - int worker; - worker = wdesc.findWorker (0, "fs0"); - ASSERT (worker == 0); - wdesc.incrLoad (worker); - worker = wdesc.findWorker (0, "fs0"); - ASSERT (worker == 0); - wdesc.incrLoad (worker); - worker = wdesc.findWorker (0, "fs2"); - ASSERT (worker == 2); - wdesc.incrLoad (worker); - worker = wdesc.findWorker (0, "fs1"); - ASSERT (worker == 1); - wdesc.incrLoad (worker); - worker = wdesc.findWorker (1, ""); - ASSERT (worker == 1); - wdesc.incrLoad (worker); - worker = wdesc.findWorker (1, ""); - ASSERT (worker == 2); - wdesc.incrLoad (worker); - worker = wdesc.findWorker (1, ""); - ASSERT (worker == 0); - wdesc.incrLoad (worker); - ASSERT (wdesc.findWorker (2, "") == -1); - ASSERT (wdesc.findWorker (0, "fs4") == -1); -} - -int main() -{ - try { - doIt1(); - doIt2(); - } catch (std::exception& x) { - cout << "Unexpected exception: " << x.what() << endl; - return 1; - } - cout << "OK" << endl; - return 0; -} diff --git a/CEP/MWCommon/test/tWorkersDesc.sh b/CEP/MWCommon/test/tWorkersDesc.sh deleted file mode 100755 index 500a2eb31dd1e9973c7d11b83ae4d0bf00a2b27b..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tWorkersDesc.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./runctest.sh tWorkersDesc > tWorkersDesc.log 2>&1 diff --git a/CEP/MWCommon/test/tfinddproc.in_cd b/CEP/MWCommon/test/tfinddproc.in_cd deleted file mode 100644 index 7f3bae0d1a313d46ab3818b0316cf304ae1b0629..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tfinddproc.in_cd +++ /dev/null @@ -1,12 +0,0 @@ -ClusterName = cl -NNodes = 3 -Node0.NodeName = node0 -Node0.NodeType = Head -Node0.NodeFileSys = [node1:/usr] -Node0.NodeMountPoints = [/usr] -Node1.NodeName = node1 -Node1.NodeFileSys = [node1:/usr] -Node1.NodeMountPoints = [/usr] -Node2.NodeName = node2 -Node2.NodeFileSys = [node1:/usr] -Node2.NodeMountPoints = [/usr] diff --git a/CEP/MWCommon/test/tfinddproc.in_vd b/CEP/MWCommon/test/tfinddproc.in_vd deleted file mode 100644 index 9a768cad51a18248e12cdadbefda9918a11ef115..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tfinddproc.in_vd +++ /dev/null @@ -1,39 +0,0 @@ -Name = /usr/local/xyx -FileSys = -StartTime = 0 -EndTime = 2 -StepTime = 0.5 -NChan = [64,128] -StartFreqs = [20,120] -EndFreqs = [100,300] -NParts = 3 - -Part0.Name = /usr/local/xyx0.vds -Part0.FileName = /usr/local/xyx0 -Part0.FileSys = node1:/usr -Part0.StartTime = 0 -Part0.EndTime = 2 -Part0.StepTime = 0.5 -Part0.NChan = [64,128] -Part0.StartFreqs = [20,120] -Part0.EndFreqs = [100,300] - -Part1.Name = /usr/local/xyx1.vds -Part1.FileName = /usr/local/xyx1 -Part1.FileSys = node1:/usr -Part1.StartTime = 0 -Part1.EndTime = 2 -Part1.StepTime = 0.5 -Part1.NChan = [64,128] -Part1.StartFreqs = [20,120] -Part1.EndFreqs = [100,300] - -Part2.Name = /usr/local/xyx2.vds -Part2.FileName = /usr/local/xyx2 -Part2.FileSys = node1:/usr -Part2.StartTime = 0 -Part2.EndTime = 2 -Part2.StepTime = 0.5 -Part2.NChan = [64,128] -Part2.StartFreqs = [20,120] -Part2.EndFreqs = [100,300] diff --git a/CEP/MWCommon/test/tfinddproc.run b/CEP/MWCommon/test/tfinddproc.run deleted file mode 100755 index 20592019ea41951c64e7d20ded3980cf17b0c1b7..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tfinddproc.run +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh - -# tfinddproc: Test program finddproc -# -# Copyright (C) 2008 -# ASTRON (Netherlands Institute for Radio Astronomy) -# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -# -# This file is part of the LOFAR software suite. -# The LOFAR software suite is free software: you can redistribute it and/or -# modify it under the terms of the GNU General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# The LOFAR software suite is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -# -# @author Ger van Diepen <diepen AT astron nl> -# -# $Id$ - - -../src/finddproc tfinddproc.in_vd tfinddproc.in_cd diff --git a/CEP/MWCommon/test/tfinddproc.sh b/CEP/MWCommon/test/tfinddproc.sh deleted file mode 100755 index 62afda5ee26e411074521af4c75e859651c6b161..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tfinddproc.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./runctest.sh tfinddproc > tfinddproc.log 2>&1 diff --git a/CEP/MWCommon/test/tfinddproc.stdout b/CEP/MWCommon/test/tfinddproc.stdout deleted file mode 100644 index dfe62a6d0a84c547e5a8e76c91fe362a4761b8f3..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tfinddproc.stdout +++ /dev/null @@ -1,3 +0,0 @@ -node1#/usr/local/xyx0,node1:/usr,/usr/local/xyx0.vds -node2#/usr/local/xyx1,node1:/usr,/usr/local/xyx1.vds -node1#/usr/local/xyx2,node1:/usr,/usr/local/xyx2.vds diff --git a/CEP/MWCommon/test/trundist.in_cd b/CEP/MWCommon/test/trundist.in_cd deleted file mode 100644 index a40dd724469b645d7d550014121bc340ee336878..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/trundist.in_cd +++ /dev/null @@ -1,5 +0,0 @@ -ClusterName = cl -NNodes = 1 -Node0.NodeName = localhost -Node0.NodeFileSys = [node1:/usr] -Node0.NodeMountPoints = [/usr] diff --git a/CEP/MWCommon/test/trundist.in_vd b/CEP/MWCommon/test/trundist.in_vd deleted file mode 100644 index 4738e5b042fdbeeb351773c01327829c1423377a..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/trundist.in_vd +++ /dev/null @@ -1,39 +0,0 @@ -Name = /usr/local/xyx.gds -FileSys = -StartTime = 0 -EndTime = 2 -StepTime = 0.5 -NChan = [64,128] -StartFreqs = [20,120] -EndFreqs = [100,300] -NParts = 3 - -Part0.Name = /usr/local/xyx0.ms.vds -Part0.FileName = /usr/local/xyx0.ms -Part0.FileSys = node1:/usr -Part0.StartTime = 0 -Part0.EndTime = 2 -Part0.StepTime = 0.5 -Part0.NChan = [64,128] -Part0.StartFreqs = [20,120] -Part0.EndFreqs = [100,300] - -Part1.Name = /usr/local/xyx1.ms.vds -Part1.FileName = /usr/local/xyx1.ms -Part1.FileSys = node1:/usr -Part1.StartTime = 0 -Part1.EndTime = 2 -Part1.StepTime = 0.5 -Part1.NChan = [64,128] -Part1.StartFreqs = [20,120] -Part1.EndFreqs = [100,300] - -Part2.Name = /usr/local/xyx2.ms.vds -Part2.FileName = /usr/local/xyx2.ms -Part2.FileSys = node1:/usr -Part2.StartTime = 0 -Part2.EndTime = 2 -Part2.StepTime = 0.5 -Part2.NChan = [64,128] -Part2.StartFreqs = [20,120] -Part2.EndFreqs = [100,300] diff --git a/CEP/MWCommon/test/trundist.run b/CEP/MWCommon/test/trundist.run deleted file mode 100755 index 17d20063fcc5ea61706a641f36c701ce730dc3b0..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/trundist.run +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh - -# trundist.run: Test script for rundist -# -# Copyright (C) 2009 -# ASTRON (Netherlands Institute for Radio Astronomy) -# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -# -# This file is part of the LOFAR software suite. -# The LOFAR software suite is free software: you can redistribute it and/or -# modify it under the terms of the GNU General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# The LOFAR software suite is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -# -# @author Ger van Diepen <diepen AT astron nl> -# -# $Id$ - - -# Set srcdir if not set. -if test "$srcdir" = ""; then - srcdir=../../../test -fi -curdir=`pwd` -# Set the src and make it absolute. -ssdir=`cd $srcdir/../src > /dev/null 2>&1; pwd` -sedir=`cd ../src > /dev/null 2>&1; pwd` - -# Add srcdir to PATH, so runlogpid can be found. -# Add ../src to PATH, so finddproc can be found -# Add test to PATH, so tstartdproc can be found. -PATH=$ssdir:$sedir:$curdir:$PATH -export PATH - -# Run in dry mode. -echo 'echo "argc=$#"' > trundist_tmp.sh -echo 'echo "argv=$*"' >> trundist_tmp.sh -chmod 755 trundist_tmp.sh -rundist -dry -cdn trundist.in_cd -hfn trundist_tmp.hfn -envfile trundist_tmp.env \ -$curdir/trundist_tmp.sh trundist.in_vd -arg "a b c d" > trundist_tmp.log -echo "status=$?" -cat trundist_tmp.hfn -# Remove absolute directory path from logfiles. -sed -e "s%$curdir%curdir%g" -e "s%$ssdir%ssdir%g" trundist_tmp.log - -# Run in real mode and create output GDS. -echo 'echo "argc=$#"' > trundist_tmp.sh -echo 'echo "argv=$*"' >> trundist_tmp.sh -chmod 755 trundist_tmp.sh -rundist -cdn trundist.in_cd -hfn trundist_tmp.hfn -envfile trundist_tmp.env \ --logfile trundist_tmp.logx -gdsout img \ -$curdir/trundist_tmp.sh trundist.in_vd -arg "a b c d" > trundist_tmp.log -echo "status=$?" -cat trundist_tmp.hfn -# Remove absolute directory path from logfile. -sed -e "s%$curdir%curdir%g" -e "s%$ssdir%ssdir%g" trundist_tmp.log -sed -e "s%$curdir%curdir%g" -e "s%$ssdir%ssdir%g" trundist_tmp.logx-0 trundist_tmp.logx-1 trundist_tmp.logx-2 -cat trundist.img -rm -f trundist.img diff --git a/CEP/MWCommon/test/trundist.sh b/CEP/MWCommon/test/trundist.sh deleted file mode 100755 index e68bf177efc621865b208039a5eb956177165ca7..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/trundist.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./runctest.sh trundist > trundist.log 2>&1 diff --git a/CEP/MWCommon/test/trundist.stdout b/CEP/MWCommon/test/trundist.stdout deleted file mode 100644 index c3cfde2c204618eb5fa62c797b6f585eced7cfcd..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/trundist.stdout +++ /dev/null @@ -1,64 +0,0 @@ -status=0 -localhost#/usr/local/xyx0.ms,node1:/usr,/usr/local/xyx0.ms.vds -localhost#/usr/local/xyx1.ms,node1:/usr,/usr/local/xyx1.ms.vds -localhost#/usr/local/xyx2.ms,node1:/usr,/usr/local/xyx2.ms.vds -startdistproc -useenv curdir/trundist_tmp.env -mode 0 -nomasterhost -dsn 'curdir/trundist.in_vd' -hfn 'curdir/trundist_tmp.hfn' -cdn 'curdir/trundist.in_cd' -logfile '' -dry curdir/trundist_tmp.sh '' -arg a b c d -socketrun 1 curdir/trundist_tmp.hfn '' 0 1 0 ssdir/rundist-part curdir/trundist_tmp.env curdir/trundist_tmp.sh -arg a b c d -ssh -x -n localhost ssdir/rundist-part socket localhost 0 3 0 '/usr/local/xyx0.ms' 'node1:/usr' '/usr/local/xyx0.ms.vds' 'curdir/trundist_tmp.env' 'curdir/trundist_tmp.sh' '' '-arg' 'a b c d' & -ssh -x -n localhost ssdir/rundist-part socket localhost 0 3 1 '/usr/local/xyx1.ms' 'node1:/usr' '/usr/local/xyx1.ms.vds' 'curdir/trundist_tmp.env' 'curdir/trundist_tmp.sh' '' '-arg' 'a b c d' & -ssh -x -n localhost ssdir/rundist-part socket localhost 0 3 2 '/usr/local/xyx2.ms' 'node1:/usr' '/usr/local/xyx2.ms.vds' 'curdir/trundist_tmp.env' 'curdir/trundist_tmp.sh' '' '-arg' 'a b c d' & -status=0 -localhost#/usr/local/xyx0.ms,node1:/usr,/usr/local/xyx0.ms.vds -localhost#/usr/local/xyx1.ms,node1:/usr,/usr/local/xyx1.ms.vds -localhost#/usr/local/xyx2.ms,node1:/usr,/usr/local/xyx2.ms.vds -startdistproc -useenv curdir/trundist_tmp.env -mode 0 -nomasterhost -dsn 'curdir/trundist.in_vd' -hfn 'curdir/trundist_tmp.hfn' -cdn 'curdir/trundist.in_cd' -logfile 'trundist_tmp.logx' curdir/trundist_tmp.sh '' -arg a b c d -socketrun 0 curdir/trundist_tmp.hfn '' 0 1 0 trundist_tmp.logx ssdir/rundist-part curdir/trundist_tmp.env curdir/trundist_tmp.sh -arg a b c d -ssh -x -n localhost ssdir/rundist-part socket localhost 0 3 0 '/usr/local/xyx0.ms' 'node1:/usr' '/usr/local/xyx0.ms.vds' 'curdir/trundist_tmp.env' 'curdir/trundist_tmp.sh' '' '-arg' 'a b c d' & -ssh -x -n localhost ssdir/rundist-part socket localhost 0 3 1 '/usr/local/xyx1.ms' 'node1:/usr' '/usr/local/xyx1.ms.vds' 'curdir/trundist_tmp.env' 'curdir/trundist_tmp.sh' '' '-arg' 'a b c d' & -ssh -x -n localhost ssdir/rundist-part socket localhost 0 3 2 '/usr/local/xyx2.ms' 'node1:/usr' '/usr/local/xyx2.ms.vds' 'curdir/trundist_tmp.env' 'curdir/trundist_tmp.sh' '' '-arg' 'a b c d' & -Creating global VDS file trundist.img -argc=4 -argv=0 /usr/local/xyx0.ms -arg a b c d -argc=4 -argv=1 /usr/local/xyx1.ms -arg a b c d -argc=4 -argv=2 /usr/local/xyx2.ms -arg a b c d -Name = /usr/local/xyx.gds -FileSys = -StartTime = 0 -EndTime = 2 -StepTime = 0.5 -NChan = [64,128] -StartFreqs = [20,120] -EndFreqs = [100,300] -NParts = 3 - -Part0.Name = /usr/local/xyx0.ms.vds -Part0.FileName = /usr/local/xyx0.img -Part0.FileSys = node1:/usr -Part0.StartTime = 0 -Part0.EndTime = 2 -Part0.StepTime = 0.5 -Part0.NChan = [64,128] -Part0.StartFreqs = [20,120] -Part0.EndFreqs = [100,300] - -Part1.Name = /usr/local/xyx1.ms.vds -Part1.FileName = /usr/local/xyx1.img -Part1.FileSys = node1:/usr -Part1.StartTime = 0 -Part1.EndTime = 2 -Part1.StepTime = 0.5 -Part1.NChan = [64,128] -Part1.StartFreqs = [20,120] -Part1.EndFreqs = [100,300] - -Part2.Name = /usr/local/xyx2.ms.vds -Part2.FileName = /usr/local/xyx2.img -Part2.FileSys = node1:/usr -Part2.StartTime = 0 -Part2.EndTime = 2 -Part2.StepTime = 0.5 -Part2.NChan = [64,128] -Part2.StartFreqs = [20,120] -Part2.EndFreqs = [100,300] diff --git a/CEP/MWCommon/test/tstartdproc.cc b/CEP/MWCommon/test/tstartdproc.cc deleted file mode 100644 index ddd4eec408ee970afbab371c67cb1bd9fba8ad9b..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tstartdproc.cc +++ /dev/null @@ -1,45 +0,0 @@ -//# ttartdproc.cc: sleep for some seconds -//# -//# Copyright (C) 2009 -//# ASTRON (Netherlands Institute for Radio Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -//# -//# This file is part of the LOFAR software suite. -//# The LOFAR software suite is free software: you can redistribute it and/or -//# modify it under the terms of the GNU General Public License as published -//# by the Free Software Foundation, either version 3 of the License, or -//# (at your option) any later version. -//# -//# The LOFAR software suite is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License along -//# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -//# -//# @author Ger van Diepen <diepen AT astron nl> -//# -//# $Id$ - -#include <unistd.h> -#include <iostream> -#include <sstream> -using namespace std; - -int main(int argc, char* argv[]) -{ - int nsec=30; - if (argc > 1) { - istringstream iss(argv[1]); - iss >> nsec; - } - int status=0; - if (argc > 2) { - istringstream iss(argv[2]); - iss >> status; - } - cout << "sleep for " << nsec << " seconds" << endl; - sleep (nsec); - return status; -} diff --git a/CEP/MWCommon/test/tstartdproc.in_cd b/CEP/MWCommon/test/tstartdproc.in_cd deleted file mode 100644 index ddcf03f903fe98946b5fbc772c015adb2b582ae5..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tstartdproc.in_cd +++ /dev/null @@ -1,8 +0,0 @@ -ClusterName = cl -NNodes = 2 -Node0.NodeName = node1 -Node0.NodeFileSys = [node1:/usr] -Node0.NodeMountPoints = [/usr] -Node1.NodeName = node2 -Node1.NodeFileSys = [node1:/usr] -Node1.NodeMountPoints = [/usr] diff --git a/CEP/MWCommon/test/tstartdproc.in_cd1 b/CEP/MWCommon/test/tstartdproc.in_cd1 deleted file mode 100644 index a40dd724469b645d7d550014121bc340ee336878..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tstartdproc.in_cd1 +++ /dev/null @@ -1,5 +0,0 @@ -ClusterName = cl -NNodes = 1 -Node0.NodeName = localhost -Node0.NodeFileSys = [node1:/usr] -Node0.NodeMountPoints = [/usr] diff --git a/CEP/MWCommon/test/tstartdproc.in_run b/CEP/MWCommon/test/tstartdproc.in_run deleted file mode 100755 index 1d885ff5fd11405e849fd22281525d54263c7fd0..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tstartdproc.in_run +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh - -pgmpath=`dirname $0` - -# Get the envfile name and rank. -rank=$5 -envfile=$9 - -# Source the envfile. -. $envfile - -# Start the test program and log its pid. -# It will sleep for some seconds and return the given status. -# -# This is used to test the killonfail behaviour of startdistproc/socketrun . -# The process with rank 1 will sleep shorter than the others and exit with an -# error status. Thereafter socketrun should kill the other processes. -# -# Note that it is not possible to use a script and sleep in it, because in that -# way the logged (and killed) process pid is the script and not the sleep command -# which would become a zombie. -if test $rank = 1; then - runlogpid $envfile $rank tstartdproc 5 1 -else - runlogpid $envfile $rank tstartdproc 30 0 -fi diff --git a/CEP/MWCommon/test/tstartdproc.in_vd b/CEP/MWCommon/test/tstartdproc.in_vd deleted file mode 100644 index 9a768cad51a18248e12cdadbefda9918a11ef115..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tstartdproc.in_vd +++ /dev/null @@ -1,39 +0,0 @@ -Name = /usr/local/xyx -FileSys = -StartTime = 0 -EndTime = 2 -StepTime = 0.5 -NChan = [64,128] -StartFreqs = [20,120] -EndFreqs = [100,300] -NParts = 3 - -Part0.Name = /usr/local/xyx0.vds -Part0.FileName = /usr/local/xyx0 -Part0.FileSys = node1:/usr -Part0.StartTime = 0 -Part0.EndTime = 2 -Part0.StepTime = 0.5 -Part0.NChan = [64,128] -Part0.StartFreqs = [20,120] -Part0.EndFreqs = [100,300] - -Part1.Name = /usr/local/xyx1.vds -Part1.FileName = /usr/local/xyx1 -Part1.FileSys = node1:/usr -Part1.StartTime = 0 -Part1.EndTime = 2 -Part1.StepTime = 0.5 -Part1.NChan = [64,128] -Part1.StartFreqs = [20,120] -Part1.EndFreqs = [100,300] - -Part2.Name = /usr/local/xyx2.vds -Part2.FileName = /usr/local/xyx2 -Part2.FileSys = node1:/usr -Part2.StartTime = 0 -Part2.EndTime = 2 -Part2.StepTime = 0.5 -Part2.NChan = [64,128] -Part2.StartFreqs = [20,120] -Part2.EndFreqs = [100,300] diff --git a/CEP/MWCommon/test/tstartdproc.run b/CEP/MWCommon/test/tstartdproc.run deleted file mode 100755 index 47a4f09865b53e741e9412eb9795aeacec318c3a..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tstartdproc.run +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/sh - -# tstartdproc: Test script startdistproc in various ways -# -# Copyright (C) 2008 -# ASTRON (Netherlands Institute for Radio Astronomy) -# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands -# -# This file is part of the LOFAR software suite. -# The LOFAR software suite is free software: you can redistribute it and/or -# modify it under the terms of the GNU General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# The LOFAR software suite is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. -# -# @author Ger van Diepen <diepen AT astron nl> -# -# $Id$ - - -# Set srcdir if not set. -if test "$srcdir" = ""; then - srcdir=../../../test -fi -curdir=`pwd` -# Set the src and make it absolute. -ssdir=`cd $srcdir/../src > /dev/null 2>&1; pwd` -sedir=`cd ../src > /dev/null 2>&1; pwd` - -# Add srcdir to PATH, so runlogpid can be found. -# Add ../src to PATH, so finddproc can be found -# Add test to PATH, so tstartdproc can be found. -PATH=$ssdir:$sedir:$curdir:$PATH -export PATH - -startdistproc -dsn tstartdproc.in_vd -cdn tstartdproc.in_cd \ --mode single -dry -hfn tstartdproc_tmp.out0 -fdp ../src prog1 -arg "a b" -echo "status=$?" -cat tstartdproc_tmp.out0 - -echo '' -startdistproc -dsn tstartdproc.in_vd -cdn tstartdproc.in_cd \ --mode mpi -dry -hfn tstartdproc_tmp.out1 -fdp ../src prog1 -arg "a b" -echo "status=$?" -cat tstartdproc_tmp.out1 - -echo '' -startdistproc -useenv $curdir/tstartdproc_tmp.out2.envfile \ --dsn tstartdproc.in_vd -cdn tstartdproc.in_cd \ --mode 3851 -dry -hfn tstartdproc_tmp.out2 -fdp ../src prog1 -arg "a b" \ -> tstartdproc_tmp.log2 -echo "status=$?" -cat tstartdproc_tmp.out2 -# Remove absolute directory path from logfile. -sed -e "s%$curdir%%g" tstartdproc_tmp.log2 - -echo '' -startdistproc -killonfail -useenv $curdir/tstartdproc_tmp.out3.envfile \ --logfile $curdir/tstartdproc_tmp.log3b \ --dsn tstartdproc.in_vd -cdn tstartdproc.in_cd1 -nostartmaster \ --mode 3851 -hfn tstartdproc_tmp.out3 -fdp ../src `pwd`/tstartdproc.in_run \ -> tstartdproc_tmp.log3a -echo "status=$?" -cat tstartdproc_tmp.out3 -# Print log file without lines containing directory path and pids. -# Outcomment lines with kill which contain pids. -# Remove other lines containing Killed: some systems print them, some don't. -# Also remove lines containing "Debug: registered context" which are written -# when not using log4cplus/cxx. -sed -e "s%$curdir%%g" -e 's/pid=[0-9]*/pid=nn/' -e 's/kill -9 .*/kill -9 /' tstartdproc_tmp.log3a -for i in 0 1 2 -do - sed -e "s%$curdir%%g" tstartdproc_tmp.log3b-$i | grep -v "^Debug: registered context" - if [ -f tstartdproc_tmp.out3.envfile.pid-$i ]; then - sed -e 's/pid=[0-9]*/pid=nn/' tstartdproc_tmp.out3.envfile.pid-$i | grep -v " Killed " - fi -done diff --git a/CEP/MWCommon/test/tstartdproc.sh b/CEP/MWCommon/test/tstartdproc.sh deleted file mode 100755 index 98b8194b1cbcb72554e4e1a9bd9455498a629aea..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tstartdproc.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./runctest.sh tstartdproc > tstartdproc.log 2>&1 diff --git a/CEP/MWCommon/test/tstartdproc.stdout b/CEP/MWCommon/test/tstartdproc.stdout deleted file mode 100644 index 7a7644699a521b280b73fee0803df75aeb5524fc..0000000000000000000000000000000000000000 --- a/CEP/MWCommon/test/tstartdproc.stdout +++ /dev/null @@ -1,55 +0,0 @@ -prog1 -arg a b -status=0 -localhost -node1#/usr/local/xyx0,node1:/usr,/usr/local/xyx0.vds -node2#/usr/local/xyx1,node1:/usr,/usr/local/xyx1.vds -node1#/usr/local/xyx2,node1:/usr,/usr/local/xyx2.vds - -mpirun -np 4 -machinefile tstartdproc_tmp.out1 prog1 -arg a b -status=0 -localhost -node1 -node2 -node1 - -status=0 -localhost -node1#/usr/local/xyx0,node1:/usr,/usr/local/xyx0.vds -node2#/usr/local/xyx1,node1:/usr,/usr/local/xyx1.vds -node1#/usr/local/xyx2,node1:/usr,/usr/local/xyx2.vds -socketrun 1 tstartdproc_tmp.out2 'localhost' 3851 1 0 prog1 /tstartdproc_tmp.out2.envfile -arg a b -ssh -x -n localhost prog1 socket localhost 3851 4 0 '.' '.' '.' '/tstartdproc_tmp.out2.envfile' '-arg' 'a b' & -ssh -x -n node1 prog1 socket localhost 3851 4 1 '/usr/local/xyx0' 'node1:/usr' '/usr/local/xyx0.vds' '/tstartdproc_tmp.out2.envfile' '-arg' 'a b' & -ssh -x -n node2 prog1 socket localhost 3851 4 2 '/usr/local/xyx1' 'node1:/usr' '/usr/local/xyx1.vds' '/tstartdproc_tmp.out2.envfile' '-arg' 'a b' & -ssh -x -n node1 prog1 socket localhost 3851 4 3 '/usr/local/xyx2' 'node1:/usr' '/usr/local/xyx2.vds' '/tstartdproc_tmp.out2.envfile' '-arg' 'a b' & - -status=1 -localhost#/usr/local/xyx0,node1:/usr,/usr/local/xyx0.vds -localhost#/usr/local/xyx1,node1:/usr,/usr/local/xyx1.vds -localhost#/usr/local/xyx2,node1:/usr,/usr/local/xyx2.vds -socketrun 0 tstartdproc_tmp.out3 'localhost' 3851 1 1 /tstartdproc_tmp.log3b /tstartdproc.in_run /tstartdproc_tmp.out3.envfile -ssh -x -n localhost /tstartdproc.in_run socket localhost 3851 3 0 '/usr/local/xyx0' 'node1:/usr' '/usr/local/xyx0.vds' '/tstartdproc_tmp.out3.envfile' & -ssh -x -n localhost /tstartdproc.in_run socket localhost 3851 3 1 '/usr/local/xyx1' 'node1:/usr' '/usr/local/xyx1.vds' '/tstartdproc_tmp.out3.envfile' & -ssh -x -n localhost /tstartdproc.in_run socket localhost 3851 3 2 '/usr/local/xyx2' 'node1:/usr' '/usr/local/xyx2.vds' '/tstartdproc_tmp.out3.envfile' & -Remote process (pid=nn) with rank 1 ended with error status 1 -Killing the other remote processes ... -ssh -x localhost kill -9 >>> 20373 <<< -ssh -x localhost kill -9 >>> 20385 <<< -sleep for 30 seconds -tstartdproc 30 0 -pid=nn ->>> -/Users/diepen/sim/LOFAR/CEP/MWCommon/src/runlogpid: line 52: 20373 Killed $program "$@" -<<< -status=137 -sleep for 5 seconds -tstartdproc 5 1 -pid=nn -status=1 -sleep for 30 seconds -tstartdproc 30 0 -pid=nn ->>> -/Users/diepen/sim/LOFAR/CEP/MWCommon/src/runlogpid: line 52: 20385 Killed $program "$@" -<<< -status=137