0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GroupCommit.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_RangeServer_GroupCommit_h
23 #define Hypertable_RangeServer_GroupCommit_h
24 
25 #include "GroupCommitInterface.h"
26 #include "RangeServer.h"
27 
28 #include <Common/FlyweightString.h>
29 
30 #include <map>
31 #include <mutex>
32 
33 namespace Hypertable {
34 
37 
39  typedef std::pair<uint64_t, TableIdentifier> ClusterTableIdPair;
40 
42  struct lt_ctip {
43  bool operator()(const ClusterTableIdPair &key1, const ClusterTableIdPair &key2) const {
44  if (key1.first != key2.first)
45  return false;
46  if (key1.second.id == 0 || key2.second.id == 0) {
47  if (key1.second.id == 0)
48  return true;
49  return false;
50  }
51  int cmpval = strcmp(key1.second.id, key2.second.id);
52  if (cmpval != 0)
53  return cmpval < 0;
54  return key1.second.generation < key2.second.generation;
55  }
56  };
57 
60 
61  public:
62 
67  GroupCommit(Apps::RangeServer *range_server);
68  virtual void add(EventPtr &event, uint64_t cluster_id, SchemaPtr &schema,
69  const TableIdentifier &table, uint32_t count,
70  StaticBuffer &buffer, uint32_t flags);
71  virtual void trigger();
72 
73  private:
80  uint32_t m_commit_interval {};
82  int m_counter {};
85 
86  std::map<ClusterTableIdPair, UpdateRecTable *, lt_ctip> m_table_map;
87  };
89 }
90 
91 #endif // Hypertable_RangeServer_GroupCommit_h
92 
uint32_t m_commit_interval
Cached copy of Hypertable.RangeServer.CommitInterval property.
Definition: GroupCommit.h:80
A memory buffer of static size.
Definition: StaticBuffer.h:45
static std::mutex mutex
Definition: Logger.cc:43
virtual void trigger()
Processes queued updates that are ready to be committed.
Definition: GroupCommit.cc:81
std::map< ClusterTableIdPair, UpdateRecTable *, lt_ctip > m_table_map
Definition: GroupCommit.h:86
std::shared_ptr< Event > EventPtr
Smart pointer to Event.
Definition: Event.h:228
The Flyweight string set stores duplicate strings efficiently.
Declarations for RangeServer.
Declarations for GroupCommitInterface.
FlyweightString m_flyweight_strings
String cache for holding table IDs
Definition: GroupCommit.h:84
Comparison functor for ClusterTableIdPair objects.
Definition: GroupCommit.h:42
Group commit manager.
Definition: GroupCommit.h:59
bool operator()(const ClusterTableIdPair &key1, const ClusterTableIdPair &key2) const
Definition: GroupCommit.h:43
Flyweight string set.
GroupCommit(Apps::RangeServer *range_server)
Constructor.
Definition: GroupCommit.cc:34
Apps::RangeServer * m_range_server
Pointer to RangeServer.
Definition: GroupCommit.h:77
virtual void add(EventPtr &event, uint64_t cluster_id, SchemaPtr &schema, const TableIdentifier &table, uint32_t count, StaticBuffer &buffer, uint32_t flags)
Adds a batch of updates to the group commit queue.
Definition: GroupCommit.cc:42
Hypertable definitions
std::pair< uint64_t, TableIdentifier > ClusterTableIdPair
Structure for holding cluster ID / table identifier pair.
Definition: GroupCommit.h:39
std::shared_ptr< Schema > SchemaPtr
Smart pointer to Schema.
Definition: Schema.h:465
Abstract base class for group commit implementation.
int m_counter
Trigger iteration counter.
Definition: GroupCommit.h:82
std::mutex m_mutex
Mutex to serialize concurrent access
Definition: GroupCommit.h:75