0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
TableMutatorAsyncScatterBuffer.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_Lib_TableMutatorAsyncScatterBuffer_h
28 #define Hypertable_Lib_TableMutatorAsyncScatterBuffer_h
29 
30 #include <Hypertable/Lib/Cell.h>
31 #include <Hypertable/Lib/Cells.h>
32 #include <Hypertable/Lib/Key.h>
35 #include <Hypertable/Lib/Schema.h>
38 
39 #include <AsyncComm/CommAddress.h>
41 #include <AsyncComm/Event.h>
42 
43 #include <Common/ByteString.h>
44 #include <Common/FlyweightString.h>
45 #include <Common/StringExt.h>
46 #include <Common/Timer.h>
47 #include <Common/InetAddr.h>
48 
49 #include <condition_variable>
50 #include <memory>
51 #include <mutex>
52 #include <random>
53 #include <vector>
54 
55 namespace Hypertable {
56 
57  class TableMutatorAsync;
58 
60 
62  typedef std::shared_ptr<TableMutatorAsyncScatterBuffer> TableMutatorAsyncScatterBufferPtr;
63 
65 
66  public:
68  TableMutatorAsync *mutator,
69  const TableIdentifier *,
70  SchemaPtr &, RangeLocatorPtr &, bool auto_refresh,
71  uint32_t timeout_ms,
72  uint32_t id);
74  void set(const Key &, const ColumnFamilySpec *cf, const void *value,
75  uint32_t value_len, size_t incr_mem);
76  void set_delete(const Key &key, size_t incr_mem);
77  void set(SerializedKey key, ByteString value, size_t incr_mem);
78  bool full() { std::lock_guard<std::mutex> lock(m_mutex); return m_full; }
79  void send(uint32_t flags);
80  void wait_for_completion();
81  TableMutatorAsyncScatterBufferPtr create_redo_buffer(uint32_t id);
82  uint64_t get_resend_count() { return m_resends; }
83  void
85  failed_mutations = m_failed_mutations;
86  }
87  size_t get_failure_count() { return m_failed_mutations.size(); }
88  void refresh_schema(const TableIdentifier &table_id, SchemaPtr &schema) {
89  m_schema = schema;
90  m_table_identifier = table_id;
91  }
92 
93  uint32_t get_id() const { return m_id; }
94  uint32_t get_send_flags() const { return m_send_flags; }
101  size_t memory_used() const { return m_memory_used; }
102  void set_memory_used(size_t mem) { m_memory_used = mem; }
103  void finish();
104  void set_retries_to_fail(int error);
105 
106  private:
107  int set_failed_mutations();
109 
118  TableMutatorAsyncSendBufferMap m_buffer_map;
120  bool m_full {};
121  uint64_t m_resends {};
125  uint32_t m_timeout_ms;
129  uint32_t m_id;
131  size_t m_memory_used {};
133  std::condition_variable m_cond;
134  bool m_outstanding {};
135  uint32_t m_send_flags {};
136  uint32_t m_wait_time;
137  const static uint32_t ms_init_redo_wait_time=1000;
138  bool dead {};
139  };
140 
141 }
142 
143 #endif // Hypertable_Lib_TableMutatorAsyncScatterBuffer_h
static std::mutex mutex
Definition: Logger.cc:43
TableMutatorAsyncScatterBuffer(Comm *comm, ApplicationQueueInterfacePtr &app_queue, TableMutatorAsync *mutator, const TableIdentifier *, SchemaPtr &, RangeLocatorPtr &, bool auto_refresh, uint32_t timeout_ms, uint32_t id)
CommAddressMap< TableMutatorAsyncSendBufferPtr > TableMutatorAsyncSendBufferMap
void get_failed_mutations(FailedMutations &failed_mutations)
void set(const Key &, const ColumnFamilySpec *cf, const void *value, uint32_t value_len, size_t incr_mem)
std::shared_ptr< RangeLocator > RangeLocatorPtr
Smart pointer to RangeLocator.
Definition: RangeLocator.h:198
std::shared_ptr< TableMutatorAsyncScatterBuffer > TableMutatorAsyncScatterBufferPtr
Smart pointer to TableMutatorAsyncScatterBuffer.
Column family specification.
Declarations for CommAddress.
The Flyweight string set stores duplicate strings efficiently.
Declarations for RangeServerClient.
A dynamic, resizable and reference counted memory buffer.
Definition: DynamicBuffer.h:42
std::shared_ptr< LocationCache > LocationCachePtr
Smart pointer to LocationCache.
Declarations for Event.
Declarations for Schema.
size_t memory_used() const
Returns the amount of memory used by the collected mutations.
Tracks outstanding RangeServer update requests.
A class managing one or more serializable ByteStrings.
Definition: ByteString.h:47
Provides the ability to mutate a table in the form of adding and deleting rows and cells...
Wrapper for TableIdentifier providing member storage.
void refresh_schema(const TableIdentifier &table_id, SchemaPtr &schema)
Flyweight string set.
A timer class to keep timeout states across AsyncComm related calls.
std::shared_ptr< ApplicationQueueInterface > ApplicationQueueInterfacePtr
Smart pointer to ApplicationQueueInterface.
TableMutatorAsyncScatterBufferPtr create_redo_buffer(uint32_t id)
Hypertable definitions
std::set< CommAddress > CommAddressSet
Set of CommAddress objects.
Definition: CommAddress.h:212
Entry point to AsyncComm service.
Definition: Comm.h:61
TableMutatorAsyncCompletionCounter m_completion_counter
Provides access to internal components of opaque key.
Definition: Key.h:40
Client interface to RangeServer.
Definition: Client.h:63
Internet address wrapper classes and utility functions.
A timer class to keep timeout states across AsyncComm related calls.
Definition: Timer.h:44
A serializable ByteString.
std::shared_ptr< Schema > SchemaPtr
Smart pointer to Schema.
Definition: Schema.h:465
Declarations for ApplicationQueueInterface.
String extensions and helpers: sets, maps, append operators etc.
std::vector< FailedMutation > FailedMutations
Definition: Cells.h:39