Add support for naming the dataset
This commit is contained in:
committed by
Patrick Niklaus
parent
666ce46d36
commit
2c80f76004
@@ -36,17 +36,18 @@ class DataWatchdogImpl<AlgorithmT, datafacade::ContiguousInternalMemoryDataFacad
|
||||
using Facade = datafacade::ContiguousInternalMemoryDataFacade<AlgorithmT>;
|
||||
|
||||
public:
|
||||
DataWatchdogImpl() : active(true)
|
||||
DataWatchdogImpl(const std::string &dataset_name) : dataset_name(dataset_name), active(true)
|
||||
{
|
||||
// create the initial facade before launching the watchdog thread
|
||||
{
|
||||
boost::interprocess::scoped_lock<mutex_type> current_region_lock(barrier.get_mutex());
|
||||
|
||||
auto& shared_register = barrier.data();
|
||||
auto region_id = shared_register.Find("data");
|
||||
auto &shared_register = barrier.data();
|
||||
auto region_id = shared_register.Find(dataset_name + "/data");
|
||||
if (region_id == storage::SharedRegionRegister::INVALID_REGION_ID)
|
||||
{
|
||||
throw util::exception("Could not find shared memory region. Did you run osrm-datastore?");
|
||||
throw util::exception(
|
||||
"Could not find shared memory region. Did you run osrm-datastore?");
|
||||
}
|
||||
shared_region = &shared_register.GetRegion(region_id);
|
||||
region = *shared_region;
|
||||
@@ -101,6 +102,7 @@ class DataWatchdogImpl<AlgorithmT, datafacade::ContiguousInternalMemoryDataFacad
|
||||
util::Log() << "DataWatchdog thread stopped";
|
||||
}
|
||||
|
||||
const std::string dataset_name;
|
||||
storage::SharedMonitor<storage::SharedRegionRegister> barrier;
|
||||
std::thread watcher;
|
||||
bool active;
|
||||
|
||||
@@ -83,6 +83,8 @@ class WatchingProvider : public DataFacadeProvider<AlgorithmT, FacadeT>
|
||||
public:
|
||||
using Facade = typename DataFacadeProvider<AlgorithmT, FacadeT>::Facade;
|
||||
|
||||
WatchingProvider(const std::string &dataset_name) : watchdog(dataset_name) {}
|
||||
|
||||
std::shared_ptr<const Facade> Get(const api::TileParameters ¶ms) const override final
|
||||
{
|
||||
return watchdog.Get(params);
|
||||
|
||||
@@ -61,7 +61,7 @@ template <typename Algorithm> class Engine final : public EngineInterface
|
||||
{
|
||||
util::Log(logDEBUG) << "Using shared memory with algorithm "
|
||||
<< routing_algorithms::name<Algorithm>();
|
||||
facade_provider = std::make_unique<WatchingProvider<Algorithm>>();
|
||||
facade_provider = std::make_unique<WatchingProvider<Algorithm>>(config.dataset_name);
|
||||
}
|
||||
else if (!config.memory_file.empty())
|
||||
{
|
||||
|
||||
@@ -91,6 +91,7 @@ struct EngineConfig final
|
||||
boost::filesystem::path memory_file;
|
||||
Algorithm algorithm = Algorithm::CH;
|
||||
std::string verbosity;
|
||||
std::string dataset_name;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user