0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GroupCommitTimerHandler.cc
Go to the documentation of this file.
1 /*
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 #include <Common/Compat.h>
22 
25 
26 #include <Common/Config.h>
27 #include <Common/Error.h>
28 #include <Common/InetAddr.h>
29 #include <Common/StringExt.h>
30 #include <Common/System.h>
31 #include <Common/Time.h>
32 
33 using namespace Hypertable;
34 using namespace Hypertable::RangeServer;
35 using namespace Hypertable::Config;
36 using namespace std;
37 
39  ApplicationQueuePtr &app_queue)
40  : m_comm(comm), m_range_server(range_server), m_app_queue(app_queue) {
41  m_commit_interval = get_i32("Hypertable.RangeServer.CommitInterval");
42 }
43 
45  int error;
46  if ((error = m_comm->set_timer(m_commit_interval, shared_from_this())) != Error::OK)
47  HT_FATALF("Problem setting timer - %s", Error::get_text(error));
48 }
49 
50 
52  lock_guard<mutex> lock(m_mutex);
53  int error;
54 
55  if (m_shutdown)
56  return;
57 
59 
60  if ((error = m_comm->set_timer(m_commit_interval, shared_from_this())) != Error::OK)
61  HT_FATALF("Problem setting timer - %s", Error::get_text(error));
62 }
63 
64 
66  lock_guard<mutex> lock(m_mutex);
67  m_shutdown = true;
68  m_comm->cancel_timer(shared_from_this());
69 }
Retrieves system information (hardware, installation directory, etc)
GroupCommitTimerHandler(Comm *comm, Apps::RangeServer *range_server, ApplicationQueuePtr &app_queue)
std::shared_ptr< Event > EventPtr
Smart pointer to Event.
Definition: Event.h:228
STL namespace.
const char * get_text(int error)
Returns a descriptive error message.
Definition: Error.cc:330
Compatibility Macros for C/C++.
virtual void handle(Hypertable::EventPtr &event_ptr)
Callback method.
Time related declarations.
Hypertable definitions
#define HT_FATALF(msg,...)
Definition: Logger.h:343
Entry point to AsyncComm service.
Definition: Comm.h:61
Internet address wrapper classes and utility functions.
int set_timer(uint32_t duration_millis, const DispatchHandlerPtr &handler)
Sets a timer for duration_millis milliseconds in the future.
Definition: Comm.cc:465
void cancel_timer(const DispatchHandlerPtr &handler)
Cancels all scheduled timers registered with the dispatch handler handler.
Definition: Comm.cc:483
Configuration settings.
std::shared_ptr< ApplicationQueue > ApplicationQueuePtr
Shared smart pointer to ApplicationQueue object.
String extensions and helpers: sets, maps, append operators etc.
Error codes, Exception handling, error logging.