Overpass API regression suite coverage (Nova Scotia) / template_db/dispatcher_client.h
template_db/dispatcher_client.h
0 of 3 instrumented lines run by the suite (0.0%) at 8edf11b0419c (this file on GitHub).
runnever runcolumns: line, executions, queries (click for the queries that run the line)
1/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al.2 *3 * This file is part of Overpass_API.4 *5 * Overpass_API is free software: you can redistribute it and/or modify6 * it under the terms of the GNU Affero General Public License as7 * published by the Free Software Foundation, either version 3 of the8 * License, or (at your option) any later version.9 *10 * Overpass_API is distributed in the hope that it will be useful,11 * but WITHOUT ANY WARRANTY; without even the implied warranty of12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * GNU General Public License for more details.14 *15 * You should have received a copy of the GNU Affero General Public License16 * along with Overpass_API. If not, see <http://www.gnu.org/licenses/>.17 */19#ifndef DE__OSM3S___TEMPLATE_DB__DISPATCHER_CLIENT_H20#define DE__OSM3S___TEMPLATE_DB__DISPATCHER_CLIENT_H22#include "types.h"24#include <vector>27struct Running_Query28{29 uint32 status;30 uint32 pid;31 uint32 max_time;32 uint64 max_space;33 time_t start_time;34};36struct Client_Status37{38 uint32 rate_limit;39 std::vector< Running_Query > queries;40 std::vector< time_t > slot_starts;41};44class Dispatcher_Client45{46 public:47 /** Opens a shared memory for dispatcher communication.*/48 Dispatcher_Client(const std::string& dispatcher_share_name);50 /** Write operations: -------------------------------------------------- */52 /** Allocates a write lock. Waits if necessary. */53 void write_start();54 void migrate_start();56 /** Aborts an active writing operation. Results are undefined if it is57 called outside a writing operation. */58 void write_rollback();59 void migrate_rollback();61 /** Commits an active writing operation. Results are undefined if it is62 called outside a writing operation. */63 void write_commit();64 void migrate_commit();66 /** Read operations: --------------------------------------------------- */68 /** Request the index for a read operation and registers the reading process.69 Reading the index files should be taking a quick copy, because if any process70 is in this state, write_commits are blocked. */71 void request_read_and_idx(72 uint32 max_allowed_time, uint64 max_allowed_space, uint32 client_token, uint64 request_full_hash);74 /** Changes the registered state from reading the index to reading the75 database. Can be safely called multiple times for the same process. */76 void read_idx_finished();78 /** Unregisteres a reading process. */79 void read_finished();81 /** Other operations: -------------------------------------------------- */83 /** Terminate another instance running in the standby_loop. */84 void terminate();86 /** Let another instance running in the standby_loop output its status. */87 void output_status();89 /** Purge another instance. */90 void purge(uint32 pid);92 /** Query the pid of the instance with the given token. */93 pid_t query_by_token(uint32 token);95 Client_Status query_my_status(uint32 token);97 void set_global_limits(98 uint64 max_allowed_space, uint64 max_allowed_time_units, int32_t rate_limit, int32_t bit_limits);100 /** Called regularly to tell the dispatcher that this process is still alive */101 void ping();106 private:107 std::string dispatcher_share_name;108 std::string db_dir, shadow_name;109 Unix_Socket socket;111 uint32 ack_arrived();113 template< class TObject >114 void send_message(TObject message, const std::string& source_pos);115};118bool file_present(const std::string& full_path);121struct Context_Error122{125 std::string message;126};129#endif