0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MaintenanceTaskWorkQueue.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 
22 #include <Common/Compat.h>
23 
24 #include "Global.h"
26 
27 using namespace Hypertable;
28 using namespace std;
29 
31  std::vector<MetaLog::EntityTaskPtr> &work)
32  : MaintenanceTask(level, priority, String("WORK QUEUE")) {
33  m_work.swap(work);
34 }
35 
36 
38  if (!m_completed.empty())
39  Global::rsml_writer->record_removal(m_completed);
40 }
41 
42 
44  for (auto &entity_task : m_work) {
45  try {
46  if (!entity_task->execute()) {
47  lock_guard<mutex> lock(Global::mutex);
48  Global::work_queue.push_back(entity_task);
49  }
50  else
51  m_completed.push_back(entity_task);
52  }
53  catch (Hypertable::Exception &e) {
54  HT_ERROR_OUT << e << HT_END;
55  lock_guard<mutex> lock(Global::mutex);
56  Global::work_queue.push_back(entity_task);
57  }
58  catch (std::exception &e) {
59  HT_ERROR_OUT << "Problem executing " << entity_task->name() << " - " << e.what() << HT_END;
60  lock_guard<mutex> lock(Global::mutex);
61  Global::work_queue.push_back(entity_task);
62  }
63  }
64 }
std::vector< MetaLog::EntityTaskPtr > m_work
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
STL namespace.
static std::vector< MetaLog::EntityTaskPtr > work_queue
Definition: Global.h:114
static MetaLog::WriterPtr rsml_writer
Definition: Global.h:81
Compatibility Macros for C/C++.
#define HT_END
Definition: Logger.h:220
#define HT_ERROR_OUT
Definition: Logger.h:301
MaintenanceTaskWorkQueue(uint32_t level, int priority, std::vector< MetaLog::EntityTaskPtr > &work)
Hypertable definitions
std::vector< MetaLog::EntityPtr > m_completed
This is a generic exception class for Hypertable.
Definition: Error.h:314
static std::mutex mutex
Definition: Global.h:62