0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
UpdatePipeline.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; either version 3
9  * of the 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_UpdatePipeline_h
28 #define Hypertable_RangeServer_UpdatePipeline_h
29 
34 
35 #include <Hypertable/Lib/KeySpec.h>
36 
37 #include <Common/ByteString.h>
38 #include <Common/DynamicBuffer.h>
39 #include <Common/Filesystem.h>
40 
41 #include <condition_variable>
42 #include <memory>
43 #include <mutex>
44 #include <thread>
45 
46 namespace Hypertable {
47 
50 
53  public:
54 
72  UpdatePipeline(ContextPtr &context, QueryCachePtr &query_cache,
73  TimerHandlerPtr &timer_handler, CommitLogPtr &log,
74  Filesystem::Flags flags);
75 
79  void add(UpdateContext *uc);
80 
84  void shutdown();
85 
86  private:
87 
98  void qualify_and_transform();
99 
111  void commit();
112 
119  void add_and_respond();
120 
121  void transform_key(ByteString &bskey, DynamicBuffer *dest_bufp,
122  int64_t revision, int64_t *revisionp,
123  bool timeorder_desc);
124 
126  std::shared_ptr<Context> m_context;
127 
130 
133 
136 
139 
141  std::condition_variable m_qualify_queue_cond;
142 
144  std::list<UpdateContext *> m_qualify_queue;
145 
148 
150  std::condition_variable m_commit_queue_cond;
151 
154 
156  std::list<UpdateContext *> m_commit_queue;
157 
160 
162  std::condition_variable m_response_queue_cond;
163 
165  std::list<UpdateContext *> m_response_queue;
166 
168  std::vector<std::thread> m_threads;
169 
172 
175 
178 
180  uint32_t m_update_delay {};
181 
183  int32_t m_max_clock_skew {};
184 
187 
189  bool m_shutdown {};
190  };
191 
193  typedef std::shared_ptr<UpdatePipeline> UpdatePipelinePtr;
194 
196 
197 }
198 
199 #endif // Hypertable_RangeServer_UpdatePipeline_h
std::list< UpdateContext * > m_commit_queue
Stage 2 input queue.
static std::mutex mutex
Definition: Logger.cc:43
std::mutex m_commit_queue_mutex
Mutex protecting stage 2 input queue
void shutdown()
Shuts down the pipeline Sets m_shutdown to true, signals the three pipeline condition variables...
std::shared_ptr< Context > m_context
Range server context
Abstract base class for a filesystem.
UpdatePipeline(ContextPtr &context, QueryCachePtr &query_cache, TimerHandlerPtr &timer_handler, CommitLogPtr &log, Filesystem::Flags flags)
Constructor.
std::shared_ptr< UpdatePipeline > UpdatePipelinePtr
Smart pointer to UpdatePipeline.
void commit()
Thread function for stage 2 of update pipeline.
Flags
Enumeration type for append flags.
Definition: Filesystem.h:76
int64_t m_last_revision
Last (largest) assigned revision number.
void transform_key(ByteString &bskey, DynamicBuffer *dest_bufp, int64_t revision, int64_t *revisionp, bool timeorder_desc)
Three-staged, multithreaded update pipeline.
Filesystem::Flags m_flags
Commit log flush flag (NONE, FLUSH, or SYNC)
Declarations for Context.
bool m_shutdown
Flag indicating if pipeline is being shut down.
int32_t m_maintenance_pause_interval
Millisecond pause time at the end of the pipeline (TESTING)
A dynamic, resizable and reference counted memory buffer.
Definition: DynamicBuffer.h:42
static const int64_t TIMESTAMP_MIN
Definition: KeySpec.h:34
std::mutex m_response_queue_mutex
Mutex protecting stage 3 input queue
std::vector< std::thread > m_threads
Update pipeline threads.
std::shared_ptr< Context > ContextPtr
Smart pointer to Context.
Definition: Context.h:265
A class managing one or more serializable ByteStrings.
Definition: ByteString.h:47
std::mutex m_qualify_queue_mutex
Mutex protecting stage 1 input queue
std::condition_variable m_response_queue_cond
Condition variable signaling addition to stage 3 input queue.
std::list< UpdateContext * > m_qualify_queue
Stage 1 input queue.
void add_and_respond()
Thread function for stage 3 of update pipeline.
A dynamic, resizable memory buffer.
uint64_t m_update_coalesce_limit
Commit log coalesce limit.
TimerHandlerPtr m_timer_handler
Pointer to timer handler.
std::list< UpdateContext * > m_response_queue
Stage 3 input queue.
int32_t m_commit_queue_count
Count of objects in stage 2 input queue.
std::shared_ptr< TimerHandler > TimerHandlerPtr
Smart pointer to TimerHandler.
Definition: TimerHandler.h:226
Declarations for TimerHandler.
std::shared_ptr< QueryCache > QueryCachePtr
Smart pointer to QueryCache.
Definition: QueryCache.h:252
int32_t m_max_clock_skew
Maximum allowable clock skew.
Context record for update request passed into UpdatePipeline.
Definition: UpdateContext.h:38
Hypertable definitions
std::condition_variable m_commit_queue_cond
Condition variable signaling addition to stage 2 input queue.
uint32_t m_update_delay
Update delay at start of pipeline (TESTING)
std::condition_variable m_qualify_queue_cond
Condition variable signaling addition to stage 1 input queue.
void qualify_and_transform()
Thread function for stage 1 of update pipeline.
std::shared_ptr< CommitLog > CommitLogPtr
Smart pointer to CommitLog.
Definition: CommitLog.h:223
A serializable ByteString.
void add(UpdateContext *uc)
Adds updates to pipeline Adds uc to m_qualify_queue and signals m_qualify_queue_cond.
CommitLogPtr m_log
Pointer to commit log.
QueryCachePtr m_query_cache
Pointer to query cache.