0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
OperationRegisterServerBlocker.cc
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 
30 #include "Common/Compat.h"
31 #include "Common/Error.h"
32 
33 #include "OperationProcessor.h"
35 #include "OperationTimedBarrier.h"
36 
37 using namespace Hypertable;
38 
40  const String &location)
41  : OperationEphemeral(context, MetaLog::EntityType::OPERATION_REGISTER_SERVER_BLOCKER),
42  m_location(location) {
43  m_obstructions.insert(String("RegisterServerBlocker ") + m_location);
44 }
45 
47  int32_t state = get_state();
48 
49  HT_INFOF("Entering RegisterServerBlocker-%lld %s state=%s", (Lld)header.id,
50  m_location.c_str(), OperationState::get_text(state));
51 
52  switch (state) {
53 
56  block();
57  break;
58 
60  complete_ok();
61  break;
62 
63  default:
64  HT_FATALF("Unrecognized state %d", state);
65  }
66 
67  HT_INFOF("Leaving RegisterServerBlocker-%lld %s state=%s", (Lld)header.id,
69 }
70 
72  return "OperationRegisterServerBlocker";
73 }
74 
76  return "RegisterServerBlocker(" + m_location + ")";
77 }
78 
Abstract base class for ephemeral operations.
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
virtual const String name()
Returns name of operation ("OperationRegisterServerBlocker")
int64_t id
Unique ID of entity.
Declarations for OperationProcessor.
virtual void execute()
Carries out a range server recovery operation.
EntityHeader header
Entity header
const char * get_text(int32_t state)
Definition: Operation.cc:609
std::shared_ptr< Context > ContextPtr
Smart pointer to Context.
Definition: Context.h:265
void set_state(int32_t state)
Definition: Operation.h:473
Compatibility Macros for C/C++.
Declarations for OperationRegisterServerBlocker.
Hypertable definitions
#define HT_FATALF(msg,...)
Definition: Logger.h:343
long long int Lld
Shortcut for printf formats.
Definition: String.h:53
DependencySet m_obstructions
Set of obstructions.
Definition: Operation.h:598
#define HT_INFOF(msg,...)
Definition: Logger.h:272
void complete_ok(std::vector< MetaLog::EntityPtr > &additional)
Definition: Operation.cc:436
Error codes, Exception handling, error logging.
virtual const String label()
Returns descriptive label for operation.
OperationRegisterServerBlocker(ContextPtr &context, const String &location)
Constructor.