bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
HDF5RequestHandler.h
Go to the documentation of this file.
1// -*- mode: c++; c-basic-offset:4 -*-
2
3// This file is part of hdf5_handler, a data handler for the OPeNDAP data
4// server.
5
6// Copyright (c) 2002,2003 OPeNDAP, Inc.
7// Author: James Gallagher <jgallagher@opendap.org>
8//
9// This is free software; you can redistribute it and/or modify it under the
10// terms of the GNU Lesser General Public License as published by the Free
11// Software Foundation; either version 2.1 of the License, or (at your
12// option) any later version.
13//
14// This software is distributed in the hope that it will be useful, but
15// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17// License for more details.
18//
19// You should have received a copy of the GNU Lesser General Public
20// License along with this library; if not, write to the Free Software
21// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22//
23// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
24
25// HDF5RequestHandler.h
26
27#ifndef I_HDF5RequestHandler_H
28#define I_HDF5RequestHandler_H
29
30#include <string>
31#include <map>
32#include <vector>
33#include "BESRequestHandler.h"
34#include "HDF5_DataMemCache.h"
35#include <BESDDSResponse.h>
36#include <BESDataDDSResponse.h>
37#include <BESDMRResponse.h>
38#include <hdf5.h>
39
40class ObjMemCache; // in bes/dap
41
42namespace libdap {
43
44 class DAS;
45 class DDS;
46 class DMR;
47 class DataDDS;
48
49}
50
56class HDF5RequestHandler:public BESRequestHandler {
57 public:
58 explicit HDF5RequestHandler(const std::string & name);
59 ~HDF5RequestHandler(void) override;
60
61 static bool hdf5_build_das(BESDataHandlerInterface & dhi);
62 static bool hdf5_build_dds(BESDataHandlerInterface & dhi);
63 static bool hdf5_build_data(BESDataHandlerInterface & dhi);
64 static bool hdf5_build_dmr(BESDataHandlerInterface & dhi);
65 static bool hdf5_build_help(BESDataHandlerInterface & dhi);
66 static bool hdf5_build_version(BESDataHandlerInterface & dhi);
67
68 static bool get_usecf() { return _usecf;}
69 static bool get_pass_fileid() { return _pass_fileid;}
70 static bool get_disable_structmeta() { return _disable_structmeta;}
71 static bool get_disable_ecsmeta() { return _disable_ecsmeta;}
72 static bool get_keep_var_leading_underscore() { return _keep_var_leading_underscore;}
73 static bool get_check_name_clashing() { return _check_name_clashing;}
74 static bool get_add_path_attrs() { return _add_path_attrs;}
75 static bool get_drop_long_string() { return _drop_long_string;}
76 static bool get_fillvalue_check() { return _fillvalue_check;}
77 static bool get_check_ignore_obj() { return _check_ignore_obj;}
78 static bool get_force_flatten_coor_attr() { return _flatten_coor_attr;}
79 static bool get_eos5_rm_convention_attr_path() { return _eos5_rm_convention_attr_path;}
80 static bool get_dmr_long_int() { return _dmr_long_int;}
81 static bool get_no_zero_size_fullnameattr() { return _no_zero_size_fullnameattr;}
82 static bool get_enable_coord_attr_add_path() { return _enable_coord_attr_add_path;}
83
84 static bool get_usecfdmr() { return _usecfdmr;}
85 static bool get_add_dap4_coverage() { return _add_dap4_coverage;}
86
87 // Default Handle dimension key, only valid when the default option is on.
88 static bool get_default_handle_dimension() { return _default_handle_dimension;}
89
90 static void set_dmr_64bit_int(libdap::DMR *dmr) { dmr_int64 = dmr;}
91 static libdap::DMR* get_dmr_64bit_int() {return dmr_int64;}
92
93 // Handling Memory Cache
94 static string get_stp_east_filename() {return _stp_east_filename;}
95 static string get_stp_north_filename() {return _stp_north_filename;}
96
97 // Handling Cache
98 static unsigned int get_mdcache_entries() { return _mdcache_entries;}
99 static unsigned int get_lrdcache_entries() { return _lrdcache_entries;}
100 static unsigned int get_srdcache_entries() { return _srdcache_entries;}
101 static float get_cache_purge_level() { return _cache_purge_level;}
102
103
104 static ObjMemCache* get_lrdata_mem_cache() {return lrdata_mem_cache;}
105 void set_lrdata_mem_cache(ObjMemCache* my_lrdata_mem_cache) const
106 {lrdata_mem_cache=my_lrdata_mem_cache;}
107
108 static ObjMemCache* get_srdata_mem_cache() {return srdata_mem_cache;}
109 void set_srdata_mem_cache(ObjMemCache* my_srdata_mem_cache) const
110 {srdata_mem_cache=my_srdata_mem_cache;}
111
112 static bool get_common_cache_dirs() { return _common_cache_dirs;}
113 static void get_lrd_cache_dir_list(std::vector<string>& cur_lrd_cache_dir_list)
114 { cur_lrd_cache_dir_list = lrd_cache_dir_list;}
115
116 static void get_lrd_non_cache_dir_list(std::vector<string>& cur_lrd_non_cache_dir_list)
117 { cur_lrd_non_cache_dir_list = lrd_non_cache_dir_list;}
118
119 static void get_lrd_var_cache_file_list(std::vector<string>& cur_lrd_var_cache_file_list)
120 { cur_lrd_var_cache_file_list = lrd_var_cache_file_list;}
121
122 // Handling Disk Cache
123 static bool get_use_disk_cache() {return _use_disk_cache;}
124 static string get_disk_cache_dir() { return _disk_cache_dir;}
125 static string get_disk_cachefile_prefix() { return _disk_cachefile_prefix;}
126 static unsigned long long get_disk_cache_size() {return _disk_cache_size;}
127 static bool get_disk_cache_comp_data() { return _disk_cache_comp_data;}
128 static bool get_disk_cache_float_only_comp(){return _disk_cache_float_only_comp_data;}
129 static float get_disk_comp_threshold() {return _disk_cache_comp_threshold;}
130 static unsigned long get_disk_var_size() {return _disk_cache_var_size; }
131
132 static bool get_use_eosgeo_cachefile() {return _use_latlon_disk_cache; }
133 static string get_latlon_disk_cache_dir() { return _latlon_disk_cache_dir;}
134 static string get_latlon_disk_cachefile_prefix() { return _latlon_disk_cachefile_prefix;}
135 static long get_latlon_disk_cache_size() {return _latlon_disk_cache_size;}
136
137 // jhrg 3/9/22
138 static bool get_escape_utf8_attr() {return _escape_utf8_attr;}
139
140 // This handler supports the "not including attributes" in
141 // the data access feature. Attributes are generated only
142 // if necessary. KY 10/30/19
143 void add_attributes(BESDataHandlerInterface &dhi) override;
144
145 private:
146 // Loads configuration state from TheBESKeys
147 void static load_config();
148 void static load_config_disk_cache();
149 void static load_config_cf_cache();
150
151 //cache variables.
152
153 static unsigned int _mdcache_entries;
154 static unsigned int _lrdcache_entries;
155 static unsigned int _srdcache_entries;
156 static float _cache_purge_level;
157
158 static ObjMemCache *das_cache;
159 static ObjMemCache *dds_cache;
160 static ObjMemCache *datadds_cache;
161 static ObjMemCache *dmr_cache;
162 static ObjMemCache *lrdata_mem_cache;
163 static ObjMemCache *srdata_mem_cache;
164
165 // BES keys
166 static bool _usecf;
167 static bool _pass_fileid;
168 static bool _disable_structmeta;
169 static bool _disable_ecsmeta;
170 static bool _keep_var_leading_underscore;
171 static bool _check_name_clashing;
172 static bool _add_path_attrs;
173 static bool _drop_long_string;
174 static bool _fillvalue_check;
175 static bool _check_ignore_obj;
176 static bool _flatten_coor_attr;
177 static bool _eos5_rm_convention_attr_path;
178 static bool _dmr_long_int;
179 static bool _no_zero_size_fullnameattr;
180 static bool _enable_coord_attr_add_path;
181
182 static bool _usecfdmr;
183 static bool _add_dap4_coverage;
184
185 // For the default option
186 static bool _default_handle_dimension;
187 static std::string _stp_east_filename;
188 static std::string _stp_north_filename;
189
190 static libdap::DMR *dmr_int64;
191 static bool _use_disk_cache;
192 static std::string _disk_cache_dir;
193 static std::string _disk_cachefile_prefix;
194 static unsigned long long _disk_cache_size;
195 static bool _disk_cache_comp_data;
196 static bool _disk_cache_float_only_comp_data;
197 static float _disk_cache_comp_threshold;
198 static unsigned long _disk_cache_var_size;
199
200
201 static bool _use_disk_meta_cache;
202 static bool _use_disk_dds_cache;
203 static std::string _disk_meta_cache_path;
204
205 static bool _use_latlon_disk_cache;
206 static long _latlon_disk_cache_size;
207 static std::string _latlon_disk_cache_dir;
208 static std::string _latlon_disk_cachefile_prefix;
209
210 static bool _common_cache_dirs;
211
212 static bool _escape_utf8_attr; // jhrg 3/9/22
213
214 static std::vector<std::string> lrd_cache_dir_list;
215 static std::vector<string> lrd_non_cache_dir_list;
216 static std::vector<string> lrd_var_cache_file_list;
217 static bool obtain_lrd_common_cache_dirs();
218 static void obtain_lrd_common_cache_dirs_data_vars(std::vector<std::string> &temp_name_list,
219 const std::string &subline, char sep);
220
221 static bool hdf5_build_data_with_IDs(BESDataHandlerInterface &dhi);
222 static bool hdf5_build_dmr_with_IDs(BESDataHandlerInterface &dhi);
223
224 static bool hdf5_build_dmr_from_file(BESDataHandlerInterface & dhi, BESDMRResponse &bes_dmr_response,
225 libdap::DMR *dmr,const std::string &filename, hid_t &cf_fileid, hid_t &fileid);
226
227 static void hdf5_build_das_internal_no_mem_cache(const std::string& filename, libdap::DAS *das, hid_t &cf_fileid);
228
229 static void get_dds_with_attributes(BESDDSResponse*bdds,BESDataDDSResponse*data_bdds,
230 const std::string &container_name,const std::string &filename,
231 const std::string &dds_cache_fname, const std::string &das_cache_fname,
232 bool dds_from_dc,bool das_from_dc, bool build_data);
233
234 static void get_dds_without_attributes_datadds(BESDataDDSResponse*data_bdds, const std::string &filename);
235 static void read_datadds_from_file(libdap::DDS *dds, const std::string &filename, hid_t &cf_fileid, hid_t &fileid);
236
237 static void read_dds_from_disk_cache(BESDDSResponse* bdds, BESDataDDSResponse* data_bdds,bool build_data,
238 const std::string & container_name,const std::string & h5_fname,
239 const std::string & dds_cache_fname,const std::string &das_cache_fname,
240 hid_t h5_fd, bool das_from_dc);
241
242 static void read_dds_from_file(libdap::DDS *dds, const std::string &filename, hid_t &cf_fileid, hid_t &fileid,
243 const std::string &dds_cache_fname, bool dds_from_dc);
244
245 static void add_das_to_dds(libdap::DDS *dds,const std::string &container_name, const std::string &filename,
246 const std::string &das_cache_fname,hid_t h5_fd, bool das_from_dc);
247 static void add_das_to_dds_wrapper(libdap::DDS *dds, const std::string &filename, hid_t cf_fileid, hid_t fileid,
248 const std::string &container_name, const std::string &das_cache_fname,
249 bool das_from_dc);
250
251 static bool write_dds_to_disk_cache(const std::string& dds_cache_fname,libdap::DDS *dds_ptr);
252
253 static bool write_das_to_disk_cache(const std::string & das_cache_fname, libdap::DAS *das_ptr);
254
255 static bool read_das_from_disk_cache(const std::string & cache_filename,libdap::DAS *das_ptr);
256
257 static void read_das_from_file(libdap::DAS *das, const std::string &filename, const std::string &das_cache_fname,
258 hid_t h5_fd, bool das_from_dc);
259
260 static void close_h5_files(hid_t cf_fileid, hid_t file_id);
261};
262
263#endif
Holds a DDS object within the BES.
Represents an OPeNDAP DMR DAP4 data object within the BES.
Represents an OPeNDAP DataDDS DAP2 data object within the BES.
Structure storing information used by the BES to handle the request.
An in-memory cache for DapObj (DAS, DDS, ...) objects.
Definition ObjMemCache.h:83