0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
AccessGroupGarbageTracker.h
Go to the documentation of this file.
1 /* -*- c++ -*-
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; version 3 of the
9  * License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
27 
28 #ifndef Hypertable_RangeServer_AccessGroupGarbageTracker_h
29 #define Hypertable_RangeServer_AccessGroupGarbageTracker_h
30 
34 
35 #include <Hypertable/Lib/Schema.h>
36 
37 #include <Common/Properties.h>
38 
39 #include <ctime>
40 #include <fstream>
41 #include <mutex>
42 #include <vector>
43 
44 namespace Hypertable {
45 
48 
110  public:
111 
123  CellCacheManagerPtr &cell_cache_manager,
124  AccessGroupSpec *ag_spec);
125 
134  void update_schema(AccessGroupSpec *ag_spec);
135 
145  bool check_needed(time_t now);
146 
156  bool collection_needed(double total, double garbage) {
157  return (garbage / total) >= m_garbage_threshold;
158  }
159 
205  void adjust_targets(time_t now, double total, double garbage);
206 
216  void adjust_targets(time_t now, MergeScannerAccessGroup *mscanner);
217 
233  void update_cellstore_info(std::vector<CellStoreInfo> &stores, time_t t=0,
234  bool collection_performed=true);
235 
245  void output_state(std::ofstream &out, const std::string &label);
246 
247  private:
248 
258 
267 
273  int64_t compute_delete_count();
274 
286  bool check_needed_deletes();
287 
300  bool check_needed_ttl(time_t now);
301 
304 
307 
310 
313  time_t m_elapsed_target {};
314 
317 
320 
322  uint32_t m_stored_deletes {};
323 
325  int64_t m_stored_expirable {};
326 
329 
332 
336 
339 
341  time_t m_min_ttl {};
342 
345 
347  bool m_in_memory {};
348  };
349 
351 
352 } // namespace Hypertable
353 
354 #endif // Hypertable_RangeServer_AccessGroupGarbageTracker_h
int64_t m_accum_data_target
Amount of data to accummulate before signaling GC likely needed (adaptive)
void update_cellstore_info(std::vector< CellStoreInfo > &stores, time_t t=0, bool collection_performed=true)
Updates stored data statistics from current set of CellStores.
int64_t m_current_disk_usage
Current disk usage, updated by update_cellstore_info()
static std::mutex mutex
Definition: Logger.cc:43
int64_t m_accum_data_target_minimum
Minimum amount of data to accummulate before signaling GC likely needed.
time_t m_min_ttl
Minimum TTL found in access group schema.
Declarations for MergeScannerAccessGroup.
int64_t m_stored_expirable
Amount of data accumulated in cell stores that could expire due to TTL.
Tracks access group garbage and signals when collection is needed.
bool m_have_max_versions
true if any column families have non-zero MAX_VERSIONS
bool check_needed_deletes()
Signals if GC is likely needed due to MAX_VERSIONS or deletes.
Program options handling.
bool m_in_memory
true if access group is in memory
Declarations for Schema.
int64_t memory_accumulated_since_collection()
Computes the amount of in-memory data accumulated since last collection.
int64_t total_accumulated_since_collection()
Computes the total amount of data accumulated since last collection.
time_t m_last_collection_time
Time of last garbage collection
std::shared_ptr< Properties > PropertiesPtr
Definition: Properties.h:447
bool check_needed(time_t now)
Signals if garbage collection is likely needed.
void update_schema(AccessGroupSpec *ag_spec)
Updates control variables from access group schema definition.
AccessGroupGarbageTracker(PropertiesPtr &props, CellCacheManagerPtr &cell_cache_manager, AccessGroupSpec *ag_spec)
Constructor.
CellCacheManagerPtr m_cell_cache_manager
Cell cache manager
int64_t compute_delete_count()
Computes number of delete records in access group.
Access group specification.
Hypertable definitions
double m_garbage_threshold
Fraction of accumulated garbage that triggers collection.
int64_t m_last_collection_disk_usage
Disk usage at the time the last garbage collection was performed.
Declarations for CellCacheManager.
uint32_t m_stored_deletes
Number of delete records accumulated in cell stores.
std::mutex m_mutex
Mutex to serialize access to data members
void output_state(std::ofstream &out, const std::string &label)
Prints a human-readable representation of internal state to an output stream.
bool check_needed_ttl(time_t now)
Signals if GC is likeley needed due to TTL.
time_t m_elapsed_target_minimum
Minimum elapsed seconds required before signaling TTL GC likely needed.
time_t m_elapsed_target
Elapsed seconds required before signaling TTL GC likely needed (adaptive)
std::shared_ptr< CellCacheManager > CellCacheManagerPtr
Smart pointer to CellCacheManager.
void adjust_targets(time_t now, double total, double garbage)
Adjusts targets based on measured garbage.
bool collection_needed(double total, double garbage)
Determines if garbage collection is actually needed.
Merge scanner for access groups.