0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MetaLogDefinitionMaster.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 
25 
26 #include "OperationAlterTable.h"
27 #include "OperationBalance.h"
28 #include "OperationCompact.h"
30 #include "OperationCreateTable.h"
31 #include "OperationDropTable.h"
32 #include "OperationDropNamespace.h"
33 #include "OperationInitialize.h"
34 #include "OperationMoveRange.h"
35 #include "OperationRenameTable.h"
36 #include "OperationRecover.h"
37 #include "OperationRecoverRanges.h"
40 #include "OperationSetState.h"
42 #include "RangeServerConnection.h"
43 #include "BalancePlanAuthority.h"
44 #include "RecoveredServers.h"
45 #include "SystemState.h"
46 
47 #include <memory>
48 
49 using namespace Hypertable;
50 using namespace Hypertable::MetaLog;
51 using namespace std;
52 
54  return 4;
55 }
56 
57 const char *DefinitionMaster::name() {
58  return "mml";
59 }
60 
62  OperationPtr operation;
63 
65  return make_shared<RangeServerConnection>(header);
66 
67  if ((header.type & 0xF0000L) == 0x20000L) {
68 
69  /*
70  * If old operation, then record the original type and convert
71  */
72 
75  operation = make_shared<OperationInitialize>(m_context, header);
76  operation->set_original_type(EntityType::OLD_OPERATION_INITIALIZE);
77  }
78  else if (header.type == EntityType::OLD_OPERATION_ALTER_TABLE) {
80  operation = make_shared<OperationAlterTable>(m_context, header);
81  operation->set_original_type(EntityType::OLD_OPERATION_ALTER_TABLE);
82  }
85  operation = make_shared<OperationCreateNamespace>(m_context, header);
86  operation->set_original_type(EntityType::OLD_OPERATION_CREATE_NAMESPACE);
87  }
90  operation = make_shared<OperationDropNamespace>(m_context, header);
91  operation->set_original_type(EntityType::OLD_OPERATION_DROP_NAMESPACE);
92  }
93  else if (header.type == EntityType::OLD_OPERATION_CREATE_TABLE) {
95  operation = make_shared<OperationCreateTable>(m_context, header);
96  operation->set_original_type(EntityType::OLD_OPERATION_CREATE_TABLE);
97  }
98  else if (header.type == EntityType::OLD_OPERATION_DROP_TABLE) {
100  operation = make_shared<OperationDropTable>(m_context, header);
101  operation->set_original_type(EntityType::OLD_OPERATION_DROP_TABLE);
102  }
103  else if (header.type == EntityType::OLD_OPERATION_RENAME_TABLE) {
105  operation = make_shared<OperationRenameTable>(m_context, header);
106  operation->set_original_type(EntityType::OLD_OPERATION_RENAME_TABLE);
107  }
108  else if (header.type == EntityType::OLD_OPERATION_MOVE_RANGE) {
109  ((EntityHeader *)&header)->type = EntityType::OPERATION_MOVE_RANGE;
110  operation = make_shared<OperationMoveRange>(m_context, header);
111  operation->set_original_type(EntityType::OLD_OPERATION_MOVE_RANGE);
112  }
113  else if (header.type == EntityType::OLD_OPERATION_BALANCE) {
114  return 0;
115  }
116  }
117  else if (header.type == EntityType::BALANCE_PLAN_AUTHORITY) {
118  MetaLog::WriterPtr mml_writer = m_context ? m_context->mml_writer : 0;
119  return make_shared<BalancePlanAuthority>(m_context, mml_writer, header);
120  }
121  else {
123  operation = make_shared<OperationInitialize>(m_context, header);
124  else if (header.type == EntityType::OPERATION_ALTER_TABLE)
125  operation = make_shared<OperationAlterTable>(m_context, header);
126  else if (header.type == EntityType::OPERATION_CREATE_NAMESPACE)
127  operation = make_shared<OperationCreateNamespace>(m_context, header);
128  else if (header.type == EntityType::OPERATION_DROP_NAMESPACE)
129  operation = make_shared<OperationDropNamespace>(m_context, header);
130  else if (header.type == EntityType::OPERATION_CREATE_TABLE)
131  operation = make_shared<OperationCreateTable>(m_context, header);
132  else if (header.type == EntityType::OPERATION_DROP_TABLE)
133  operation = make_shared<OperationDropTable>(m_context, header);
134  else if (header.type == EntityType::OPERATION_RENAME_TABLE)
135  operation = make_shared<OperationRenameTable>(m_context, header);
136  else if (header.type == EntityType::OPERATION_MOVE_RANGE)
137  operation = make_shared<OperationMoveRange>(m_context, header);
138  else if (header.type == EntityType::OPERATION_BALANCE_RETIRED)
139  return 0;
140  else if (header.type == EntityType::OPERATION_RECOVER_SERVER)
141  operation = make_shared<OperationRecover>(m_context, header);
143  operation = make_shared<OperationRecoverRanges>(m_context, header);
144  else if (header.type == EntityType::OPERATION_BALANCE)
145  operation = make_shared<OperationBalance>(m_context, header);
146  else if (header.type == EntityType::OPERATION_COMPACT)
147  operation = make_shared<OperationCompact>(m_context, header);
148  else if (header.type == EntityType::OPERATION_SET)
149  operation = make_shared<OperationSetState>(m_context, header);
151  operation = make_shared<OperationToggleTableMaintenance>(m_context, header);
153  operation = make_shared<OperationRecreateIndexTables>(m_context, header);
154  else if (header.type == EntityType::SYSTEM_STATE)
155  return make_shared<SystemState>(header);
156  else if (header.type == EntityType::RECOVERED_SERVERS)
157  return make_shared<RecoveredServers>(header);
158  }
159 
160  if (operation)
161  return operation;
162 
164  "Unrecognized type (%d) encountered in mml",
165  (int)header.type);
166 }
167 
Declarations for OperationToggleTableMaintenance.
Declarations for OperationDropTable.
std::shared_ptr< Entity > EntityPtr
Smart pointer to Entity.
Declarations for OperationCreateTable.
Declarations for RecoveredServers.
STL namespace.
Declarations for OperationRecreateIndexTables.
Declarations for OperationCompact.
Declarations for SystemState.
EntityPtr create(const EntityHeader &header) override
Constructs a MetaLog entity from an entity header.
int32_t type
Entity type defined within the context of a Definition
Compatibility Macros for C/C++.
Hypertable definitions
const char * name() override
Returns MetaLog definition name.
std::shared_ptr< Writer > WriterPtr
Smart pointer to Writer.
Declarations for OperationSetState.
#define HT_THROWF(_code_, _fmt_,...)
Definition: Error.h:490
uint16_t version() override
Returns version number of definition.
Declarations for OperationAlterTable.
Declarations for BalancePlanAuthority.
std::shared_ptr< Operation > OperationPtr
Smart pointer to Operation.
Definition: Operation.h:609
MetaLog framework.
Definition: MetaLog.h:44