0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ScannerMap.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 
26 
27 #ifndef Hypertable_RangeServer_ScannerMap_h
28 #define Hypertable_RangeServer_ScannerMap_h
29 
32 
34 
35 #include <atomic>
36 #include <mutex>
37 #include <unordered_map>
38 
39 namespace Hypertable {
40 
43 
45  class ScannerMap {
46 
47  public:
48 
59  int32_t put(MergeScannerRangePtr &scanner, RangePtr &range,
60  const TableIdentifier &table, ProfileDataScanner &profile_data);
61 
75  bool get(int32_t id, MergeScannerRangePtr &scanner, RangePtr &range,
76  TableIdentifierManaged &table, ProfileDataScanner *profile_data);
77 
85  bool remove(int32_t id);
86 
93  void purge_expired(int32_t max_idle_ms);
94 
105  void get_counts(int32_t *totalp, CstrToInt32Map &table_scanner_count_map);
106 
111  void update_profile_data(int32_t id, ProfileDataScanner &profile_data);
112 
113  private:
114 
118  int64_t get_timestamp_millis();
119 
121  static std::atomic<int> ms_next_id;
122 
125 
127  struct ScanInfo {
138  };
139 
141  std::unordered_map<int32_t, ScanInfo> m_scanner_map;
142 
143  };
144 
146 
147 }
148 
149 
150 #endif // Hypertable_RangeServer_ScannerMap_h
static std::mutex mutex
Definition: Logger.cc:43
void purge_expired(int32_t max_idle_ms)
This method iterates through the scanner map purging mappings that have not been referenced for max_i...
Definition: ScannerMap.cc:83
int64_t last_access_millis
Last access time in milliseconds since epoch.
Definition: ScannerMap.h:133
ProfileDataScanner profile_data
Accumulated profile data.
Definition: ScannerMap.h:137
Wrapper for TableIdentifier providing member storage.
Declarations for ProfileDataScanner.
MergeScannerRangePtr scanner
Scanner.
Definition: ScannerMap.h:129
std::shared_ptr< MergeScannerRange > MergeScannerRangePtr
Smart pointer to MergeScannerRange.
int32_t put(MergeScannerRangePtr &scanner, RangePtr &range, const TableIdentifier &table, ProfileDataScanner &profile_data)
This method computes a unique scanner ID and puts the given scanner and range pointers into a map usi...
Definition: ScannerMap.cc:40
Holds scanner information.
Definition: ScannerMap.h:127
static std::atomic< int > ms_next_id
Next available scanner ID.
Definition: ScannerMap.h:121
Declarations for Range.
Map to hold outstanding scanners.
Definition: ScannerMap.h:45
Hypertable definitions
std::shared_ptr< Range > RangePtr
Smart pointer to Range.
Definition: Range.h:404
std::mutex m_mutex
Mutex for serializing access to members
Definition: ScannerMap.h:124
void get_counts(int32_t *totalp, CstrToInt32Map &table_scanner_count_map)
This method retrieves outstanding scanner counts.
Definition: ScannerMap.cc:104
TableIdentifierManaged table
Table identifier.
Definition: ScannerMap.h:135
Declarations for MergeScannerRange.
std::unordered_map< int32_t, ScanInfo > m_scanner_map
Scanner map.
Definition: ScannerMap.h:141
void update_profile_data(int32_t id, ProfileDataScanner &profile_data)
Updates profile data of a scanner in the map.
Definition: ScannerMap.cc:117
int64_t get_timestamp_millis()
Returns the number of milliseconds since the epoch.
Definition: ScannerMap.cc:127
std::map< const char *, int32_t, LtCstr > CstrToInt32Map
STL map from c-style string to int32_t.
Definition: StringExt.h:55