Skip to content
Snippets Groups Projects
  • William F Godoy's avatar
    77a5923b
    Tested refactored implementation · 77a5923b
    William F Godoy authored
    1 Now IO (replaced Method) and is the factory for Variables and Engines
    2 Reduced core components to user-public objects only
    3 Moved and reorganized all helper functions to helper directory
    4 Engines are now lightweight (except for ADIOS1Reader WIP) using MACRO
    5 HF5Common and ADIOS1Common (except for Readers WIP) are now part of the toolkit so they can be reused by Engines
    6 TransportMan is a new layer for transport management (file is default)
    7 DataMan will be implemented under toolkit/transportman/dataman
    8 Template separation (tcc and inl) applied all over the code
    9 Improved Doxygen documentation
    
    Runtime Issues:
    DataMan library compilation (cacheman)
    ADIOS1 Warning
    TestADIOSInterfaceWrite catches exceptions
    77a5923b
    History
    Tested refactored implementation
    William F Godoy authored
    1 Now IO (replaced Method) and is the factory for Variables and Engines
    2 Reduced core components to user-public objects only
    3 Moved and reorganized all helper functions to helper directory
    4 Engines are now lightweight (except for ADIOS1Reader WIP) using MACRO
    5 HF5Common and ADIOS1Common (except for Readers WIP) are now part of the toolkit so they can be reused by Engines
    6 TransportMan is a new layer for transport management (file is default)
    7 DataMan will be implemented under toolkit/transportman/dataman
    8 Template separation (tcc and inl) applied all over the code
    9 Improved Doxygen documentation
    
    Runtime Issues:
    DataMan library compilation (cacheman)
    ADIOS1 Warning
    TestADIOSInterfaceWrite catches exceptions
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
DataMan.cpp 3.17 KiB
/*
 * Distributed under the OSI-approved Apache License, Version 2.0.  See
 * accompanying file Copyright.txt for details.
 *
 * DataMan.cpp
 *
 *  Created on: Jun 1, 2017
 *      Author: Jason Wang wangr1@ornl.gov
 */

#include "DataMan.h"

namespace adios
{
namespace transportman
{

DataMan::DataMan(MPI_Comm mpiComm, const bool debugMode)
: TransportMan(mpiComm, debugMode)
{
}

void DataMan::OpenWANTransports(const std::string &name,
                                const OpenMode openMode,
                                const std::vector<Params> &parametersVector,
                                const bool profile)
{
    auto lf_GetParameter = [](const std::string key, const Params &params,
                              const bool isMandatory,
                              const bool debugMode) -> std::string {

        std::string value;
        auto itParameter = params.find(key);
        if (itParameter == params.end())
        {
            if (debugMode == true && isMandatory == true)
            {
                throw std::invalid_argument(
                    "ERROR: wan transport doesn't have mandatory parameter " +
                    key +
                    ", provide one in IO AddTransport, in call to Open\n");
            }
        }
        else
        {
            value = itParameter->second;
        }
        return value;
    };

    for (const auto &parameters : parametersVector)
    {
        std::shared_ptr<Transport> wanTransport;

        const std::string type(
            lf_GetParameter("transport", parameters, true, m_DebugMode));

        const std::string lib(
            lf_GetParameter("lib", parameters, true, m_DebugMode));

        const std::string ipAddress(
            lf_GetParameter("ipaddress", parameters, true, m_DebugMode));

        const std::string port(
            lf_GetParameter("port", parameters, false, m_DebugMode));

        if (port.empty())
        {
            port = m_DefaultPort;
        }

        const std::string messageName(
            lf_GetParameter("name", parameters, false, m_DebugMode));

        if (messageName.empty())
        {
            messageName = name;
        }

        if (type == "wan") // need to create directory
        {
            if (lib == "zmq")
            {
#ifdef ADIOS_HAVE_ZMQ
                wanTransport = std::make_shared<transport::WANZmq>(
                    ipAddress, port, m_MPIComm, m_DebugMode);
#else
                throw std::invalid_argument(
                    "ERROR: this version of ADIOS2 didn't compile with "
                    "ZMQ library, in call to Open\n");
#endif
            }
            else
            {
                if (m_DebugMode == true)
                {
                    throw std::invalid_argument("ERROR: wan library " + lib +
                                                " not supported or not "
                                                "provided in IO AddTransport, "
                                                "in call to Open\n");
                }
            }
        }
        wanTransport->Open(messageName, openMode);
        m_Transports.push_back(std::move(wanTransport));
    }
}

} // end namespace transportman
} // end namespace adios