001/** 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase.executor; 019 020import org.apache.yetus.audience.InterfaceAudience; 021 022/** 023 * List of all HBase event handler types. Event types are named by a 024 * convention: event type names specify the component from which the event 025 * originated and then where its destined -- e.g. RS2ZK_ prefix means the 026 * event came from a regionserver destined for zookeeper -- and then what 027 * the even is; e.g. REGION_OPENING. 028 * 029 * <p>We give the enums indices so we can add types later and keep them 030 * grouped together rather than have to add them always to the end as we 031 * would have to if we used raw enum ordinals. 032 */ 033@InterfaceAudience.Private 034public enum EventType { 035 // Messages originating from RS (NOTE: there is NO direct communication from 036 // RS to Master). These are a result of RS updates into ZK. 037 // RS_ZK_REGION_CLOSING (1), // It is replaced by M_ZK_REGION_CLOSING(HBASE-4739) 038 039 /** 040 * RS_ZK_REGION_CLOSED<br> 041 * 042 * RS has finished closing a region. 043 */ 044 RS_ZK_REGION_CLOSED (2, ExecutorType.MASTER_CLOSE_REGION), 045 /** 046 * RS_ZK_REGION_OPENING<br> 047 * 048 * RS is in process of opening a region. 049 */ 050 RS_ZK_REGION_OPENING (3, null), 051 /** 052 * RS_ZK_REGION_OPENED<br> 053 * 054 * RS has finished opening a region. 055 */ 056 RS_ZK_REGION_OPENED (4, ExecutorType.MASTER_OPEN_REGION), 057 /** 058 * RS_ZK_REGION_SPLITTING<br> 059 * 060 * RS has started a region split after master says it's ok to move on. 061 */ 062 RS_ZK_REGION_SPLITTING (5, null), 063 /** 064 * RS_ZK_REGION_SPLIT<br> 065 * 066 * RS split has completed and is notifying the master. 067 */ 068 RS_ZK_REGION_SPLIT (6, ExecutorType.MASTER_SERVER_OPERATIONS), 069 /** 070 * RS_ZK_REGION_FAILED_OPEN<br> 071 * 072 * RS failed to open a region. 073 */ 074 RS_ZK_REGION_FAILED_OPEN (7, ExecutorType.MASTER_CLOSE_REGION), 075 /** 076 * RS_ZK_REGION_MERGING<br> 077 * 078 * RS has started merging regions after master says it's ok to move on. 079 */ 080 RS_ZK_REGION_MERGING (8, null), 081 /** 082 * RS_ZK_REGION_MERGE<br> 083 * 084 * RS region merge has completed and is notifying the master. 085 */ 086 RS_ZK_REGION_MERGED (9, ExecutorType.MASTER_SERVER_OPERATIONS), 087 /** 088 * RS_ZK_REQUEST_REGION_SPLIT<br> 089 * 090 * RS has requested to split a region. This is to notify master 091 * and check with master if the region is in a state good to split. 092 */ 093 RS_ZK_REQUEST_REGION_SPLIT (10, null), 094 /** 095 * RS_ZK_REQUEST_REGION_MERGE<br> 096 * 097 * RS has requested to merge two regions. This is to notify master 098 * and check with master if two regions is in states good to merge. 099 */ 100 RS_ZK_REQUEST_REGION_MERGE (11, null), 101 102 /** 103 * Messages originating from Master to RS.<br> 104 * M_RS_OPEN_REGION<br> 105 * Master asking RS to open a region. 106 */ 107 M_RS_OPEN_REGION (20, ExecutorType.RS_OPEN_REGION), 108 /** 109 * Messages originating from Master to RS.<br> 110 * M_RS_OPEN_ROOT<br> 111 * Master asking RS to open root. 112 */ 113 M_RS_OPEN_ROOT (21, ExecutorType.RS_OPEN_ROOT), 114 /** 115 * Messages originating from Master to RS.<br> 116 * M_RS_OPEN_META<br> 117 * Master asking RS to open meta. 118 */ 119 M_RS_OPEN_META (22, ExecutorType.RS_OPEN_META), 120 /** 121 * Messages originating from Master to RS.<br> 122 * M_RS_CLOSE_REGION<br> 123 * Master asking RS to close a region. 124 */ 125 M_RS_CLOSE_REGION (23, ExecutorType.RS_CLOSE_REGION), 126 /** 127 * Messages originating from Master to RS.<br> 128 * M_RS_CLOSE_ROOT<br> 129 * Master asking RS to close root. 130 */ 131 M_RS_CLOSE_ROOT (24, ExecutorType.RS_CLOSE_ROOT), 132 /** 133 * Messages originating from Master to RS.<br> 134 * M_RS_CLOSE_META<br> 135 * Master asking RS to close meta. 136 */ 137 M_RS_CLOSE_META (25, ExecutorType.RS_CLOSE_META), 138 /** 139 * Messages originating from Master to RS.<br> 140 * M_RS_OPEN_PRIORITY_REGION<br> 141 * Master asking RS to open a priority region. 142 */ 143 M_RS_OPEN_PRIORITY_REGION (26, ExecutorType.RS_OPEN_PRIORITY_REGION), 144 145 /** 146 * Messages originating from Client to Master.<br> 147 * C_M_MERGE_REGION<br> 148 * Client asking Master to merge regions. 149 */ 150 C_M_MERGE_REGION (30, ExecutorType.MASTER_TABLE_OPERATIONS), 151 /** 152 * Messages originating from Client to Master.<br> 153 * C_M_DELETE_TABLE<br> 154 * Client asking Master to delete a table. 155 */ 156 C_M_DELETE_TABLE (40, ExecutorType.MASTER_TABLE_OPERATIONS), 157 /** 158 * Messages originating from Client to Master.<br> 159 * C_M_DISABLE_TABLE<br> 160 * Client asking Master to disable a table. 161 */ 162 C_M_DISABLE_TABLE (41, ExecutorType.MASTER_TABLE_OPERATIONS), 163 /** 164 * Messages originating from Client to Master.<br> 165 * C_M_ENABLE_TABLE<br> 166 * Client asking Master to enable a table. 167 */ 168 C_M_ENABLE_TABLE (42, ExecutorType.MASTER_TABLE_OPERATIONS), 169 /** 170 * Messages originating from Client to Master.<br> 171 * C_M_MODIFY_TABLE<br> 172 * Client asking Master to modify a table. 173 */ 174 C_M_MODIFY_TABLE (43, ExecutorType.MASTER_TABLE_OPERATIONS), 175 /** 176 * Messages originating from Client to Master.<br> 177 * C_M_ADD_FAMILY<br> 178 * Client asking Master to add family to table. 179 */ 180 C_M_ADD_FAMILY (44, null), 181 /** 182 * Messages originating from Client to Master.<br> 183 * C_M_DELETE_FAMILY<br> 184 * Client asking Master to delete family of table. 185 */ 186 C_M_DELETE_FAMILY (45, null), 187 /** 188 * Messages originating from Client to Master.<br> 189 * C_M_MODIFY_FAMILY<br> 190 * Client asking Master to modify family of table. 191 */ 192 C_M_MODIFY_FAMILY (46, null), 193 /** 194 * Messages originating from Client to Master.<br> 195 * C_M_CREATE_TABLE<br> 196 * Client asking Master to create a table. 197 */ 198 C_M_CREATE_TABLE (47, ExecutorType.MASTER_TABLE_OPERATIONS), 199 /** 200 * Messages originating from Client to Master.<br> 201 * C_M_SNAPSHOT_TABLE<br> 202 * Client asking Master to snapshot an offline table. 203 */ 204 C_M_SNAPSHOT_TABLE (48, ExecutorType.MASTER_TABLE_OPERATIONS), 205 /** 206 * Messages originating from Client to Master.<br> 207 * C_M_RESTORE_SNAPSHOT<br> 208 * Client asking Master to restore a snapshot. 209 */ 210 C_M_RESTORE_SNAPSHOT (49, ExecutorType.MASTER_TABLE_OPERATIONS), 211 212 // Updates from master to ZK. This is done by the master and there is 213 // nothing to process by either Master or RS 214 /** 215 * M_ZK_REGION_OFFLINE 216 * Master adds this region as offline in ZK 217 */ 218 M_ZK_REGION_OFFLINE (50, null), 219 /** 220 * M_ZK_REGION_CLOSING 221 * Master adds this region as closing in ZK 222 */ 223 M_ZK_REGION_CLOSING (51, null), 224 225 /** 226 * Master controlled events to be executed on the master 227 * M_SERVER_SHUTDOWN 228 * Master is processing shutdown of a RS 229 */ 230 M_SERVER_SHUTDOWN (70, ExecutorType.MASTER_SERVER_OPERATIONS), 231 /** 232 * Master controlled events to be executed on the master.<br> 233 * M_META_SERVER_SHUTDOWN <br> 234 * Master is processing shutdown of RS hosting a meta region (-ROOT- or hbase:meta). 235 */ 236 M_META_SERVER_SHUTDOWN (72, ExecutorType.MASTER_META_SERVER_OPERATIONS), 237 /** 238 * Master controlled events to be executed on the master.<br> 239 * 240 * M_MASTER_RECOVERY<br> 241 * Master is processing recovery of regions found in ZK RIT 242 */ 243 M_MASTER_RECOVERY (73, ExecutorType.MASTER_SERVER_OPERATIONS), 244 /** 245 * Master controlled events to be executed on the master.<br> 246 * 247 * M_LOG_REPLAY<br> 248 * Master is processing log replay of failed region server 249 */ 250 M_LOG_REPLAY (74, ExecutorType.M_LOG_REPLAY_OPS), 251 252 /** 253 * RS controlled events to be executed on the RS.<br> 254 * 255 * RS_PARALLEL_SEEK 256 */ 257 RS_PARALLEL_SEEK (80, ExecutorType.RS_PARALLEL_SEEK), 258 259 /** 260 * RS wal recovery work items (splitting wals) to be executed on the RS.<br> 261 * 262 * RS_LOG_REPLAY 263 */ 264 RS_LOG_REPLAY (81, ExecutorType.RS_LOG_REPLAY_OPS), 265 266 /** 267 * RS flush triggering from secondary region replicas to primary region replica. <br> 268 * 269 * RS_REGION_REPLICA_FLUSH 270 */ 271 RS_REGION_REPLICA_FLUSH (82, ExecutorType.RS_REGION_REPLICA_FLUSH_OPS), 272 273 /** 274 * RS compacted files discharger <br> 275 * 276 * RS_COMPACTED_FILES_DISCHARGER 277 */ 278 RS_COMPACTED_FILES_DISCHARGER (83, ExecutorType.RS_COMPACTED_FILES_DISCHARGER); 279 280 private final int code; 281 private final ExecutorType executor; 282 283 /** 284 * Constructor 285 */ 286 EventType(final int code, final ExecutorType executor) { 287 this.code = code; 288 this.executor = executor; 289 } 290 291 public int getCode() { 292 return this.code; 293 } 294 295 public static EventType get(final int code) { 296 // Is this going to be slow? Its used rare but still... 297 for (EventType et : EventType.values()) { 298 if (et.getCode() == code) { 299 return et; 300 } 301 } 302 throw new IllegalArgumentException("Unknown code " + code); 303 } 304 305 public boolean isOnlineSchemaChangeSupported() { 306 return this.equals(EventType.C_M_ADD_FAMILY) || this.equals(EventType.C_M_DELETE_FAMILY) || 307 this.equals(EventType.C_M_MODIFY_FAMILY) || this.equals(EventType.C_M_MODIFY_TABLE); 308 } 309 310 ExecutorType getExecutorServiceType() { 311 return this.executor; 312 } 313}