0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
TableCache.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 
22 #ifndef Hypertable_Lib_TableCache_h
23 #define Hypertable_Lib_TableCache_h
24 
26 #include <Hypertable/Lib/Schema.h>
27 #include <Hypertable/Lib/Table.h>
28 
30 
31 #include <Common/String.h>
32 
33 #include <memory>
34 #include <mutex>
35 #include <unordered_map>
36 
37 namespace Hypertable {
38 
40  public:
41 
44  NameIdMapperPtr &namemap, uint32_t default_timeout_ms);
45 
46  virtual ~TableCache();
47 
51  TablePtr get(const std::string &table_name, int32_t flags);
52 
53  TablePtr get_unlocked(const std::string &table_name, int32_t flags);
54 
61  bool get_schema_str(const std::string &table_name, std::string &output_schema, bool with_ids=false);
62 
69  bool get_schema(const std::string &table_name, SchemaPtr &output_schema);
70 
75  bool remove(const std::string &table_name);
76 
77  void lock() { m_mutex.lock(); }
78  void unlock() { m_mutex.unlock(); }
79 
80  private:
81 
82  virtual void safe() { }
83  virtual void expired() { }
84  virtual void jeopardy() { }
85  virtual void disconnected() { }
86  virtual void reconnected();
87 
88  typedef std::unordered_map<String, TablePtr> TableMap;
89 
98  uint32_t m_timeout_ms;
99  TableMap m_table_map;
100  };
101 
103  typedef std::shared_ptr<TableCache> TableCachePtr;
104 
105 }
106 
107 #endif // Hypertable_Lib_TableCache_h
virtual void jeopardy()
Definition: TableCache.h:84
static std::mutex mutex
Definition: Logger.cc:43
A callback object derived from this class gets passed into the constructor of Hyperspace.
Definition: Session.h:94
std::shared_ptr< RangeLocator > RangeLocatorPtr
Smart pointer to RangeLocator.
Definition: RangeLocator.h:198
bool get_schema_str(const std::string &table_name, std::string &output_schema, bool with_ids=false)
Definition: TableCache.cc:71
PropertiesPtr m_props
Definition: TableCache.h:91
RangeLocatorPtr m_range_locator
Definition: TableCache.h:92
ApplicationQueueInterfacePtr m_app_queue
Definition: TableCache.h:96
Declarations for Schema.
bool get_schema(const std::string &table_name, SchemaPtr &output_schema)
Definition: TableCache.cc:82
std::unordered_map< String, TablePtr > TableMap
Definition: TableCache.h:88
virtual void safe()
Definition: TableCache.h:82
std::shared_ptr< Session > SessionPtr
Definition: Session.h:734
NameIdMapperPtr m_namemap
Definition: TableCache.h:97
std::shared_ptr< Properties > PropertiesPtr
Definition: Properties.h:447
std::shared_ptr< ApplicationQueueInterface > ApplicationQueueInterfacePtr
Smart pointer to ApplicationQueueInterface.
virtual void expired()
Definition: TableCache.h:83
TableCache(PropertiesPtr &, RangeLocatorPtr &, ConnectionManagerPtr &, Hyperspace::SessionPtr &, ApplicationQueueInterfacePtr &, NameIdMapperPtr &namemap, uint32_t default_timeout_ms)
Definition: TableCache.cc:29
ConnectionManagerPtr m_conn_manager
Definition: TableCache.h:94
Hypertable definitions
std::shared_ptr< TableCache > TableCachePtr
Smart pointer to TableCache.
Definition: TableCache.h:103
Entry point to AsyncComm service.
Definition: Comm.h:61
TablePtr get_unlocked(const std::string &table_name, int32_t flags)
Definition: TableCache.cc:51
virtual void disconnected()
Definition: TableCache.h:85
A String class based on std::string.
std::shared_ptr< Schema > SchemaPtr
Smart pointer to Schema.
Definition: Schema.h:465
virtual void reconnected()
Definition: TableCache.cc:104
Declarations for ApplicationQueueInterface.
Hyperspace::SessionPtr m_hyperspace
Definition: TableCache.h:95
std::shared_ptr< ConnectionManager > ConnectionManagerPtr
Smart pointer to ConnectionManager.
std::shared_ptr< NameIdMapper > NameIdMapperPtr
Smart pointer to NameIdMapper.
Definition: NameIdMapper.h:121
std::shared_ptr< Table > TablePtr
Definition: Table.h:53