52 : m_comm(comm), m_range_server(range_server) {
53 int32_t maintenance_interval;
57 maintenance_interval = get_i32(
"Hypertable.RangeServer.Maintenance.Interval");
63 HT_INFOF(
"Reducing timer interval to %d to support maintenance interval %d",
86 lock_guard<mutex> lock(
m_mutex);
89 auto now = std::chrono::steady_clock::now();
90 uint64_t elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(now -
m_last_schedule).count();
92 uint32_t millis = (elapsed < 1000) ? 1000 - elapsed : 0;
93 HT_INFOF(
"Scheduling immediate maintenance for %u millis in the future", millis);
103 lock_guard<mutex> lock(
m_mutex);
128 lock_guard<mutex> lock(
m_mutex);
135 lock_guard<mutex> lock(
m_mutex);
142 auto now = std::chrono::steady_clock::now();
145 unsigned int elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(now -
m_pause_time).count();
146 HT_DEBUGF(
"App queue paused (pause_time=%u, lmm=%s, restart_gen=%lld, "
147 "queue_gen=%lld)", (
unsigned)elapsed,
152 m_restart_generation <= Global::maintenance_queue->generation())
174 HT_DEBUGF(
"aq_paused=%s, lowmm=%s, ci=%d, ims=%s, so=%s, dm=%s",
180 do_maintenance ?
"true" :
"false");
186 if (do_maintenance) {
196 HT_ERRORF(
"Unexpected event - %s", event->to_str().c_str());
209 HT_INFOF(
"Application queue PAUSED due to %s",
217 auto now = std::chrono::steady_clock::now();
218 int64_t pause_millis = std::chrono::duration_cast<std::chrono::milliseconds>(now -
m_pause_time).count();
219 HT_INFOF(
"Restarting application queue (pause time = %lld millis)",
226 std::stringstream ss;
227 auto seconds = std::chrono::duration_cast<std::chrono::seconds>(now.time_since_epoch()).count();
228 ss << seconds <<
"\tapp-queue-pause\t" << pause_millis;
234 bool low_physical_memory =
false;
247 if (low_physical_memory)
249 Global::memory_limit_ensure_unused_current / (
double)Property::MiB);
Retrieves system information (hardware, installation directory, etc)
void handle(Hypertable::EventPtr &event)
Timer event handler callback method.
int64_t m_userlog_size_threshold
Pause app queue if USER log exceeds this size.
static int64_t memory_limit_ensure_unused_current
static int64_t memory_limit
void shutdown()
Start shutdown sequence.
std::shared_ptr< Event > EventPtr
Smart pointer to Event.
bool m_shutdown
Indicates that a shutdown is in progress.
Declarations for RangeServer.
void schedule_immediate_maintenance()
Force maintenance to be scheduled immediately.
int32_t m_current_interval
Current timer interval (set to 500 when app queue is paused)
static int64_t memory_limit_ensure_unused
static int64_t log_prune_threshold_max
bool m_low_memory_mode
Low memory mode.
static Hypertable::MemoryTracker * memory_tracker
bool m_schedule_outstanding
A maintenance scheduling operation is outstanding.
void restart_app_queue()
Restarts the application queue.
void write_profile_data(const String &line)
Apps::RangeServer * m_range_server
RangeServer.
const char * get_text(int error)
Returns a descriptive error message.
Compatibility Macros for C/C++.
std::mutex m_mutex
Mutex for serializing access
TimerHandler(Comm *comm, Apps::RangeServer *range_server)
Constructor.
ApplicationQueuePtr get_application_queue()
Declarations for TimerHandler.
Time related declarations.
bool low_memory()
Checks for low memory.
int32_t m_timer_interval
Timer interval.
#define HT_FATALF(msg,...)
#define HT_DEBUGF(msg,...)
static Hypertable::MaintenanceQueuePtr maintenance_queue
long long int Lld
Shortcut for printf formats.
bool m_immediate_maintenance_scheduled
An immediate maintenance timer has been scheduled.
bool m_app_queue_paused
Application queue is paused.
Entry point to AsyncComm service.
void pause_app_queue()
Pauses the application queue.
int64_t m_restart_generation
Generation of maintenance queue signalling application queue restart.
int32_t m_max_app_queue_pause
Maximum time to keep application queue paused each time it is paused.
int64_t m_query_cache_memory
Query cache max size (Hypertable.RangeServer.QueryCache.MaxMemory)
#define HT_INFOF(msg,...)
Internet address wrapper classes and utility functions.
This is a generic exception class for Hypertable.
std::chrono::steady_clock::time_point m_pause_time
Last time application queue was paused.
static CommitLogPtr user_log
std::chrono::steady_clock::time_point m_last_schedule
Last time maintenance was scheduled.
ApplicationQueuePtr m_app_queue
Application queue.
#define HT_ERRORF(msg,...)
void maintenance_scheduled_notify()
Signal maintenance scheduling complete.
int set_timer(uint32_t duration_millis, const DispatchHandlerPtr &handler)
Sets a timer for duration_millis milliseconds in the future.
void cancel_timer(const DispatchHandlerPtr &handler)
Cancels all scheduled timers registered with the dispatch handler handler.
Comm * m_comm
Comm object.
String extensions and helpers: sets, maps, append operators etc.
static const MemStat & mem_stat()
Retrieves updated Memory statistics (see SystemInfo.h)
Error codes, Exception handling, error logging.
int64_t balance()
Return total range server memory used.