|
mod_tile 0.9.1
Renders map tiles with Mapnik and serves them using Apache HTTP Server
|
#include <glib.h>#include <stdio.h>#include "config.h"#include "g_logger.h"#include "store.h"#include "store_rados.h"#include <errno.h>#include <limits.h>#include <pthread.h>#include <rados/librados.h>#include <stdlib.h>#include <string.h>#include <time.h>#include "metatile.h"#include "protocol.h"#include "render_config.h"Classes | |
| struct | metadata_cache |
| Single-entry cache holding the combined stat_info + meta_layout header of the most recently accessed metatile in a RADOS context. More... | |
| struct | rados_ctx |
| Per-backend Ceph RADOS cluster handle, pool I/O context, and metadata cache. More... | |
Functions | |
| static char * | rados_xyzo_to_storagekey (const char *xmlconfig, const char *options, int x, int y, int z, char *key) |
| Format the RADOS object key for a metatile given (xmlconfig, options, x, y, z). | |
| static char * | read_meta_data (struct storage_backend *store, const char *xmlconfig, const char *options, int x, int y, int z) |
| Fetch (or return cached) stat_info + meta_layout header bytes for a metatile. | |
| static int | rados_tile_read (struct storage_backend *store, const char *xmlconfig, const char *options, int x, int y, int z, char *buf, size_t sz, int *compressed, char *log_msg) |
| Read a single sub-tile payload from a metatile object stored in Ceph RADOS. | |
| static struct stat_info | rados_tile_stat (struct storage_backend *store, const char *xmlconfig, const char *options, int x, int y, int z) |
| Retrieve stored metadata, timestamps, and expiry status for a tile in Ceph RADOS. | |
| static char * | rados_tile_storage_id (struct storage_backend *store, const char *xmlconfig, const char *options, int x, int y, int z, char *string) |
| Format a human-readable rados://<pool>/<key> storage URI identifying (x, y, z). | |
| static int | rados_metatile_write (struct storage_backend *store, const char *xmlconfig, const char *options, int x, int y, int z, const char *buf, int sz) |
| Atomically write a full serialized metatile object to Ceph RADOS prefixed with stat_info. | |
| static int | rados_metatile_delete (struct storage_backend *store, const char *xmlconfig, int x, int y, int z) |
| Remove the metatile object containing (x, y, z) from the Ceph RADOS pool. | |
| static int | rados_metatile_expire (struct storage_backend *store, const char *xmlconfig, int x, int y, int z) |
| Mark a RADOS metatile object as expired by updating its leading struct stat_info. | |
| static int | rados_close_storage (struct storage_backend *store) |
| Tear down the Ceph RADOS I/O context, cluster connection, and metadata cache. | |
| struct storage_backend * | init_storage_rados (const char *connection_string) |
| Allocate and initialize a Ceph RADOS metatile storage_backend. | |
Variables | |
| static pthread_mutex_t | rados_mutex |
| Mutex serializing rados_connect() calls across worker threads during startup. | |
| struct storage_backend * init_storage_rados | ( | const char * | connection_string | ) |
Allocate and initialize a Ceph RADOS metatile storage_backend.
Parses connection_string of the form "rados://<pool>/<path/to/ceph.conf>", creates a rados_t cluster handle, loads the Ceph configuration file, connects to the cluster (serialized via rados_mutex), opens an I/O context to <pool>, allocates the single-entry metadata_cache buffer, and wires all backend operation function pointers. Returns NULL if compiled without HAVE_LIBRADOS or if any initialization step fails.
| connection_string | Backend URI of the form "rados://<pool>/<ceph_conf_path>". |
|
static |
Tear down the Ceph RADOS I/O context, cluster connection, and metadata cache.
| store | Storage backend instance to close. |
|
static |
Remove the metatile object containing (x, y, z) from the Ceph RADOS pool.
| store | Initialized RADOS storage_backend. |
| xmlconfig | Logical map style name. |
| x | Global tile X coordinate. |
| y | Global tile Y coordinate. |
| z | Tile zoom level. |
|
static |
Mark a RADOS metatile object as expired by updating its leading struct stat_info.
Reads the first sizeof(struct stat_info) bytes of the RADOS object, sets expired = 1, and writes those bytes back in place at offset 0 via rados_write() without rewriting the metatile image payloads.
| store | Initialized RADOS storage_backend. |
| xmlconfig | Logical map style name. |
| x | Global tile X coordinate. |
| y | Global tile Y coordinate. |
| z | Tile zoom level. |
|
static |
Atomically write a full serialized metatile object to Ceph RADOS prefixed with stat_info.
Prepends a freshly initialized struct stat_info (expired = 0, current timestamps) ahead of buf and overwrites the entire RADOS object in a single rados_write_full() operation.
| store | Initialized RADOS storage_backend. |
| xmlconfig | Logical map style name. |
| options | Style parameterization options string. |
| x | Top-left tile X coordinate of the metatile. |
| y | Top-left tile Y coordinate of the metatile. |
| z | Tile zoom level. |
| buf | Serialized metatile buffer (meta_layout + index table + tile payloads). |
| sz | Total byte length of buf. |
|
static |
Read a single sub-tile payload from a metatile object stored in Ceph RADOS.
Retrieves the metatile header via read_meta_data(), validates the magic signature and sub-tile count, and performs a ranged rados_read() at file_offset (adjusted for the leading struct stat_info) for tile_size bytes into buf.
| store | Initialized RADOS storage_backend. |
| xmlconfig | Logical map style name. |
| options | Style parameterization options string. |
| x | Global tile X coordinate. |
| y | Global tile Y coordinate. |
| z | Tile zoom level. |
| buf | Caller-supplied output buffer receiving the sub-tile image bytes. |
| sz | Maximum capacity of buf in bytes. |
| compressed | Output flag set to 1 if META_MAGIC_COMPRESSED is present, 0 otherwise. |
| log_msg | Caller-supplied buffer receiving an error message on failure. |
|
static |
Retrieve stored metadata, timestamps, and expiry status for a tile in Ceph RADOS.
Reads (or hits cache for) the metatile's leading struct stat_info and index table via read_meta_data(), setting tile_stat.size to the individual sub-tile's byte size (or -1 if the RADOS object is missing).
| store | Initialized RADOS storage_backend. |
| xmlconfig | Logical map style name. |
| options | Style parameterization options string. |
| x | Global tile X coordinate. |
| y | Global tile Y coordinate. |
| z | Tile zoom level. |
|
static |
Format a human-readable rados://<pool>/<key> storage URI identifying (x, y, z).
| store | Initialized RADOS storage_backend. |
| xmlconfig | Logical map style name. |
| options | Style parameterization options string. |
| x | Global tile X coordinate. |
| y | Global tile Y coordinate. |
| z | Tile zoom level. |
| string | Caller-supplied output buffer (PATH_MAX bytes) receiving the formatted URI. |
|
static |
Format the RADOS object key for a metatile given (xmlconfig, options, x, y, z).
Masks x and y down to the top-left (0, 0) corner of their METATILE x METATILE block and formats key as "<xmlconfig>/<z>/<x>/<y>[.<options>].meta".
| xmlconfig | Logical map style name. |
| options | Style parameterization options string (omitted from key if empty). |
| x | Global tile X coordinate. |
| y | Global tile Y coordinate. |
| z | Tile zoom level. |
| key | Caller-supplied output buffer (PATH_MAX bytes) receiving the formatted object key. |
|
static |
Fetch (or return cached) stat_info + meta_layout header bytes for a metatile.
Aligns (x, y) to the metatile origin and checks ctx->metadata_cache. On a cache hit, returns ctx->metadata_cache.data immediately. On a cache miss, reads header_len bytes from offset 0 of the RADOS object into ctx->metadata_cache.data, updates the cache key, and returns the buffer (or invalidates the cache and returns NULL on error).
| store | Initialized RADOS storage_backend (storage_ctx holds struct rados_ctx *). |
| xmlconfig | Logical map style name. |
| options | Style parameterization options string. |
| x | Global tile X coordinate. |
| y | Global tile Y coordinate. |
| z | Tile zoom level. |
|
static |
Mutex serializing rados_connect() calls across worker threads during startup.