0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
TableMutatorAsyncSendBuffer.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_TableMutatorAsyncSendBuffer_h
23 #define Hypertable_Lib_TableMutatorAsyncSendBuffer_h
24 
26 
27 #include <memory>
28 
29 namespace Hypertable {
30 
32  int error;
33  uint8_t *base;
34  uint32_t len;
35  };
36 
41  public:
44  : counterp(counterp_),
46  m_range_locator(rl) { }
47 
48  void add_retries(uint32_t count, uint32_t offset, uint32_t len) {
49  accum.add(pending_updates.base+offset, len);
51  retry_count += count;
52  // invalidate row key
55  }
56 
57  void add_retries_all(bool with_error=false, uint32_t error=0) {
61  // invalidate row key
64  if (with_error) {
65  FailedRegionAsync failed;
66  failed.error=(int) error;
67  failed.base = pending_updates.base;
68  failed.len = pending_updates.size;
69  failed_regions.push_back(failed);
71  }
72  }
73 
74  void add_errors(int error, uint32_t count, uint32_t offset, uint32_t len) {
75  FailedRegionAsync failed;
76  (void)count;
77  failed.error = error;
78  failed.base = pending_updates.base + offset;
79  failed.len = len;
80  failed_regions.push_back(failed);
82  }
83  void add_errors_all(uint32_t error) {
84  FailedRegionAsync failed;
85  failed.error = (int)error;
86  failed.base = pending_updates.base;
87  failed.len = pending_updates.size;
88  failed_regions.push_back(failed);
90  }
91  void clear() {
92  key_offsets.clear();
93  accum.clear();
95  failed_regions.clear();
96  send_count = 0;
97  retry_count = 0;
98  }
99  void reset() {
100  clear();
101  dispatch_handler = 0;
102  }
103  void get_failed_regions(std::vector<FailedRegionAsync> &errors) {
104  errors.insert(errors.end(), failed_regions.begin(), failed_regions.end());
105  }
106 
107  bool resend() { return retry_count > 0; }
108 
109  std::vector<uint64_t> key_offsets;
115  std::vector<FailedRegionAsync> failed_regions;
116  uint32_t send_count;
117  uint32_t retry_count;
118 
119  private:
122  };
123 
125  typedef std::shared_ptr<TableMutatorAsyncSendBuffer> TableMutatorAsyncSendBufferPtr;
126 
127 }
128 
129 #endif // Hypertable_Lib_TableMutatorAsyncSendBuffer_h
A memory buffer of static size.
Definition: StaticBuffer.h:45
void add_retries_all(bool with_error=false, uint32_t error=0)
const char * row() const
Definition: SerializedKey.h:53
std::vector< String > errors
void add_retries(uint32_t count, uint32_t offset, uint32_t len)
void get_failed_regions(std::vector< FailedRegionAsync > &errors)
bool invalidate(const TableIdentifier *table, const char *row_key)
Invalidates the cached entry for the given row key.
Definition: RangeLocator.h:116
A dynamic, resizable and reference counted memory buffer.
Definition: DynamicBuffer.h:42
Tracks outstanding RangeServer update requests.
std::shared_ptr< TableMutatorAsyncSendBuffer > TableMutatorAsyncSendBufferPtr
Smart pointer to TableMutatorAsyncSendBuffer.
TableMutatorAsyncCompletionCounter * counterp
uint8_t * add(const void *data, size_t len)
Adds more data WITH boundary checks; if required the buffer is resized and existing data is preserved...
void free()
Clears the data; if this object is owner of the data then the allocated buffer is delete[]d...
Definition: StaticBuffer.h:185
Hypertable definitions
TableMutatorAsyncSendBuffer(const TableIdentifier *tid, TableMutatorAsyncCompletionCounter *counterp_, RangeLocator *rl)
void clear()
Clears the buffer.
Locates containing range given a key.
Definition: RangeLocator.h:67
std::shared_ptr< DispatchHandler > DispatchHandlerPtr
Smart pointer to DispatchHandler.
std::vector< FailedRegionAsync > failed_regions
void add_errors(int error, uint32_t count, uint32_t offset, uint32_t len)
Address abstraction to hold either proxy name or IPv4:port address.
Definition: CommAddress.h:52