implements and fixes #997
- ServerPaths object can be populated by passing base path to OSRM - reduces code/functionality duplication in node-OSRM
This commit is contained in:
parent
5bb7e62a7c
commit
b9e1d3116c
@ -46,6 +46,7 @@ namespace boost { namespace interprocess { class named_mutex; } }
|
||||
#include "../Server/DataStructures/SharedBarriers.h"
|
||||
#include "../Server/DataStructures/SharedDataFacade.h"
|
||||
#include "../Util/make_unique.hpp"
|
||||
#include "../Util/ProgramOptions.h"
|
||||
#include "../Util/SimpleLogger.h"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
@ -57,8 +58,8 @@ namespace boost { namespace interprocess { class named_mutex; } }
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
OSRM_impl::OSRM_impl(const ServerPaths &server_paths, const bool use_shared_memory)
|
||||
: use_shared_memory(use_shared_memory)
|
||||
OSRM_impl::OSRM_impl(const ServerPaths &paths, const bool use_shared_memory)
|
||||
: server_paths(paths)
|
||||
{
|
||||
if (use_shared_memory)
|
||||
{
|
||||
@ -67,6 +68,8 @@ OSRM_impl::OSRM_impl(const ServerPaths &server_paths, const bool use_shared_memo
|
||||
}
|
||||
else
|
||||
{
|
||||
// populate base path
|
||||
populate_base_path(server_paths);
|
||||
query_data_facade = new InternalDataFacade<QueryEdge::EdgeData>(server_paths);
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,7 @@ class OSRM_impl
|
||||
private:
|
||||
void RegisterPlugin(BasePlugin *plugin);
|
||||
PluginMap plugin_map;
|
||||
ServerPaths server_paths;
|
||||
bool use_shared_memory;
|
||||
SharedBarriers *barrier;
|
||||
// base class pointer to the objects
|
||||
|
@ -45,6 +45,109 @@ const static unsigned INIT_OK_START_ENGINE = 0;
|
||||
const static unsigned INIT_OK_DO_NOT_START_ENGINE = 1;
|
||||
const static unsigned INIT_FAILED = -1;
|
||||
|
||||
inline void populate_base_path(ServerPaths & server_paths)
|
||||
{
|
||||
// populate the server_path object
|
||||
auto path_iterator = server_paths.find("base");
|
||||
BOOST_ASSERT(server_paths.end() != path_iterator);
|
||||
std::string base_string = path_iterator->second.string();
|
||||
SimpleLogger().Write() << "populating base path: " << base_string;
|
||||
|
||||
path_iterator = server_paths.find("hsgrdata");
|
||||
if (path_iterator != server_paths.end() &&
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
path_iterator->second = base_string + ".hsgr";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw OSRMException(base_string + ".hsgr not found");
|
||||
}
|
||||
|
||||
path_iterator = server_paths.find("nodesdata");
|
||||
if (path_iterator != server_paths.end() &&
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
path_iterator->second = base_string + ".nodes";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw OSRMException(base_string + ".nodes not found");
|
||||
}
|
||||
|
||||
path_iterator = server_paths.find("edgesdata");
|
||||
if (path_iterator != server_paths.end() &&
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
path_iterator->second = base_string + ".edges";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw OSRMException(base_string + ".edges not found");
|
||||
}
|
||||
|
||||
path_iterator = server_paths.find("geometries");
|
||||
if (path_iterator != server_paths.end() &&
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
path_iterator->second = base_string + ".geometry";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw OSRMException(base_string + ".geometry not found");
|
||||
}
|
||||
|
||||
path_iterator = server_paths.find("ramindex");
|
||||
if (path_iterator != server_paths.end() &&
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
path_iterator->second = base_string + ".ramIndex";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw OSRMException(base_string + ".ramIndex not found");
|
||||
}
|
||||
|
||||
path_iterator = server_paths.find("fileindex");
|
||||
if (path_iterator != server_paths.end() &&
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
path_iterator->second = base_string + ".fileIndex";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw OSRMException(base_string + ".fileIndex not found");
|
||||
}
|
||||
|
||||
path_iterator = server_paths.find("namesdata");
|
||||
if (path_iterator != server_paths.end() &&
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
path_iterator->second = base_string + ".names";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw OSRMException(base_string + ".namesIndex not found");
|
||||
}
|
||||
|
||||
path_iterator = server_paths.find("timestamp");
|
||||
if (path_iterator != server_paths.end() &&
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
path_iterator->second = base_string + ".timestamp";
|
||||
}
|
||||
|
||||
SimpleLogger().Write() << "HSGR file:\t" << server_paths["hsgrdata"];
|
||||
SimpleLogger().Write(logDEBUG) << "Nodes file:\t" << server_paths["nodesdata"];
|
||||
SimpleLogger().Write(logDEBUG) << "Edges file:\t" << server_paths["edgesdata"];
|
||||
SimpleLogger().Write(logDEBUG) << "Geometry file:\t" << server_paths["geometries"];
|
||||
SimpleLogger().Write(logDEBUG) << "RAM file:\t" << server_paths["ramindex"];
|
||||
SimpleLogger().Write(logDEBUG) << "Index file:\t" << server_paths["fileindex"];
|
||||
SimpleLogger().Write(logDEBUG) << "Names file:\t" << server_paths["namesdata"];
|
||||
SimpleLogger().Write(logDEBUG) << "Timestamp file:\t" << server_paths["timestamp"];
|
||||
}
|
||||
|
||||
|
||||
// generate boost::program_options object for the routing part
|
||||
inline unsigned GenerateServerProgramOptions(const int argc,
|
||||
const char *argv[],
|
||||
@ -169,94 +272,6 @@ inline unsigned GenerateServerProgramOptions(const int argc,
|
||||
|
||||
if (!use_shared_memory && option_variables.count("base"))
|
||||
{
|
||||
path_iterator = paths.find("base");
|
||||
BOOST_ASSERT(paths.end() != path_iterator);
|
||||
std::string base_string = path_iterator->second.string();
|
||||
|
||||
path_iterator = paths.find("hsgrdata");
|
||||
if (path_iterator != paths.end() &&
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
path_iterator->second = base_string + ".hsgr";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw OSRMException(base_string + ".hsgr not found");
|
||||
}
|
||||
|
||||
path_iterator = paths.find("nodesdata");
|
||||
if (path_iterator != paths.end() &&
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
path_iterator->second = base_string + ".nodes";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw OSRMException(base_string + ".nodes not found");
|
||||
}
|
||||
|
||||
path_iterator = paths.find("edgesdata");
|
||||
if (path_iterator != paths.end() &&
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
path_iterator->second = base_string + ".edges";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw OSRMException(base_string + ".edges not found");
|
||||
}
|
||||
|
||||
path_iterator = paths.find("geometries");
|
||||
if (path_iterator != paths.end() &&
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
path_iterator->second = base_string + ".geometry";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw OSRMException(base_string + ".geometry not found");
|
||||
}
|
||||
|
||||
path_iterator = paths.find("ramindex");
|
||||
if (path_iterator != paths.end() &&
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
path_iterator->second = base_string + ".ramIndex";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw OSRMException(base_string + ".ramIndex not found");
|
||||
}
|
||||
|
||||
path_iterator = paths.find("fileindex");
|
||||
if (path_iterator != paths.end() &&
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
path_iterator->second = base_string + ".fileIndex";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw OSRMException(base_string + ".fileIndex not found");
|
||||
}
|
||||
|
||||
path_iterator = paths.find("namesdata");
|
||||
if (path_iterator != paths.end() &&
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
path_iterator->second = base_string + ".names";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw OSRMException(base_string + ".namesIndex not found");
|
||||
}
|
||||
|
||||
path_iterator = paths.find("timestamp");
|
||||
if (path_iterator != paths.end() &&
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
path_iterator->second = base_string + ".timestamp";
|
||||
}
|
||||
|
||||
return INIT_OK_START_ENGINE;
|
||||
}
|
||||
if (use_shared_memory && !option_variables.count("base"))
|
||||
|
18
routed.cpp
18
routed.cpp
@ -108,20 +108,10 @@ int main(int argc, const char *argv[])
|
||||
{
|
||||
SimpleLogger().Write(logDEBUG) << "Loading from shared memory";
|
||||
}
|
||||
else
|
||||
{
|
||||
SimpleLogger().Write() << "HSGR file:\t" << server_paths["hsgrdata"];
|
||||
SimpleLogger().Write(logDEBUG) << "Nodes file:\t" << server_paths["nodesdata"];
|
||||
SimpleLogger().Write(logDEBUG) << "Edges file:\t" << server_paths["edgesdata"];
|
||||
SimpleLogger().Write(logDEBUG) << "Geometry file:\t" << server_paths["geometries"];
|
||||
SimpleLogger().Write(logDEBUG) << "RAM file:\t" << server_paths["ramindex"];
|
||||
SimpleLogger().Write(logDEBUG) << "Index file:\t" << server_paths["fileindex"];
|
||||
SimpleLogger().Write(logDEBUG) << "Names file:\t" << server_paths["namesdata"];
|
||||
SimpleLogger().Write(logDEBUG) << "Timestamp file:\t" << server_paths["timestamp"];
|
||||
SimpleLogger().Write(logDEBUG) << "Threads:\t" << requested_thread_num;
|
||||
SimpleLogger().Write(logDEBUG) << "IP address:\t" << ip_address;
|
||||
SimpleLogger().Write(logDEBUG) << "IP port:\t" << ip_port;
|
||||
}
|
||||
|
||||
SimpleLogger().Write(logDEBUG) << "Threads:\t" << requested_thread_num;
|
||||
SimpleLogger().Write(logDEBUG) << "IP address:\t" << ip_address;
|
||||
SimpleLogger().Write(logDEBUG) << "IP port:\t" << ip_port;
|
||||
#ifndef _WIN32
|
||||
int sig = 0;
|
||||
sigset_t new_mask;
|
||||
|
Loading…
Reference in New Issue
Block a user