From 1dd47842ca8813449f3e8e01bb2f2f5949e6e545 Mon Sep 17 00:00:00 2001 From: zhangduo Date: Thu, 14 Dec 2017 17:34:27 +0800 Subject: [PATCH] HBASE-19512 Move EventType and ExecutorType from hbase-client to hbase-server --- .../apache/hadoop/hbase/executor/EventType.java | 317 --------------------- .../apache/hadoop/hbase/executor/ExecutorType.java | 62 ---- .../apache/hadoop/hbase/executor/EventType.java | 313 ++++++++++++++++++++ .../apache/hadoop/hbase/executor/ExecutorType.java | 60 ++++ 4 files changed, 373 insertions(+), 379 deletions(-) delete mode 100644 hbase-client/src/main/java/org/apache/hadoop/hbase/executor/EventType.java delete mode 100644 hbase-client/src/main/java/org/apache/hadoop/hbase/executor/ExecutorType.java create mode 100644 hbase-server/src/main/java/org/apache/hadoop/hbase/executor/EventType.java create mode 100644 hbase-server/src/main/java/org/apache/hadoop/hbase/executor/ExecutorType.java diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/executor/EventType.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/executor/EventType.java deleted file mode 100644 index 03eb55a..0000000 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/executor/EventType.java +++ /dev/null @@ -1,317 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.hbase.executor; - -import org.apache.yetus.audience.InterfaceAudience; - -/** - * List of all HBase event handler types. Event types are named by a - * convention: event type names specify the component from which the event - * originated and then where its destined -- e.g. RS2ZK_ prefix means the - * event came from a regionserver destined for zookeeper -- and then what - * the even is; e.g. REGION_OPENING. - * - *

We give the enums indices so we can add types later and keep them - * grouped together rather than have to add them always to the end as we - * would have to if we used raw enum ordinals. - */ -@InterfaceAudience.Private -public enum EventType { - // Messages originating from RS (NOTE: there is NO direct communication from - // RS to Master). These are a result of RS updates into ZK. - // RS_ZK_REGION_CLOSING (1), // It is replaced by M_ZK_REGION_CLOSING(HBASE-4739) - - /** - * RS_ZK_REGION_CLOSED
- * - * RS has finished closing a region. - */ - RS_ZK_REGION_CLOSED (2, ExecutorType.MASTER_CLOSE_REGION), - /** - * RS_ZK_REGION_OPENING
- * - * RS is in process of opening a region. - */ - RS_ZK_REGION_OPENING (3, null), - /** - * RS_ZK_REGION_OPENED
- * - * RS has finished opening a region. - */ - RS_ZK_REGION_OPENED (4, ExecutorType.MASTER_OPEN_REGION), - /** - * RS_ZK_REGION_SPLITTING
- * - * RS has started a region split after master says it's ok to move on. - */ - RS_ZK_REGION_SPLITTING (5, null), - /** - * RS_ZK_REGION_SPLIT
- * - * RS split has completed and is notifying the master. - */ - RS_ZK_REGION_SPLIT (6, ExecutorType.MASTER_SERVER_OPERATIONS), - /** - * RS_ZK_REGION_FAILED_OPEN
- * - * RS failed to open a region. - */ - RS_ZK_REGION_FAILED_OPEN (7, ExecutorType.MASTER_CLOSE_REGION), - /** - * RS_ZK_REGION_MERGING
- * - * RS has started merging regions after master says it's ok to move on. - */ - RS_ZK_REGION_MERGING (8, null), - /** - * RS_ZK_REGION_MERGE
- * - * RS region merge has completed and is notifying the master. - */ - RS_ZK_REGION_MERGED (9, ExecutorType.MASTER_SERVER_OPERATIONS), - /** - * RS_ZK_REQUEST_REGION_SPLIT
- * - * RS has requested to split a region. This is to notify master - * and check with master if the region is in a state good to split. - */ - RS_ZK_REQUEST_REGION_SPLIT (10, null), - /** - * RS_ZK_REQUEST_REGION_MERGE
- * - * RS has requested to merge two regions. This is to notify master - * and check with master if two regions is in states good to merge. - */ - RS_ZK_REQUEST_REGION_MERGE (11, null), - - /** - * Messages originating from Master to RS.
- * M_RS_OPEN_REGION
- * Master asking RS to open a region. - */ - M_RS_OPEN_REGION (20, ExecutorType.RS_OPEN_REGION), - /** - * Messages originating from Master to RS.
- * M_RS_OPEN_ROOT
- * Master asking RS to open root. - */ - M_RS_OPEN_ROOT (21, ExecutorType.RS_OPEN_ROOT), - /** - * Messages originating from Master to RS.
- * M_RS_OPEN_META
- * Master asking RS to open meta. - */ - M_RS_OPEN_META (22, ExecutorType.RS_OPEN_META), - /** - * Messages originating from Master to RS.
- * M_RS_CLOSE_REGION
- * Master asking RS to close a region. - */ - M_RS_CLOSE_REGION (23, ExecutorType.RS_CLOSE_REGION), - /** - * Messages originating from Master to RS.
- * M_RS_CLOSE_ROOT
- * Master asking RS to close root. - */ - M_RS_CLOSE_ROOT (24, ExecutorType.RS_CLOSE_ROOT), - /** - * Messages originating from Master to RS.
- * M_RS_CLOSE_META
- * Master asking RS to close meta. - */ - M_RS_CLOSE_META (25, ExecutorType.RS_CLOSE_META), - /** - * Messages originating from Master to RS.
- * M_RS_OPEN_PRIORITY_REGION
- * Master asking RS to open a priority region. - */ - M_RS_OPEN_PRIORITY_REGION (26, ExecutorType.RS_OPEN_PRIORITY_REGION), - - /** - * Messages originating from Client to Master.
- * C_M_MERGE_REGION
- * Client asking Master to merge regions. - */ - C_M_MERGE_REGION (30, ExecutorType.MASTER_TABLE_OPERATIONS), - /** - * Messages originating from Client to Master.
- * C_M_DELETE_TABLE
- * Client asking Master to delete a table. - */ - C_M_DELETE_TABLE (40, ExecutorType.MASTER_TABLE_OPERATIONS), - /** - * Messages originating from Client to Master.
- * C_M_DISABLE_TABLE
- * Client asking Master to disable a table. - */ - C_M_DISABLE_TABLE (41, ExecutorType.MASTER_TABLE_OPERATIONS), - /** - * Messages originating from Client to Master.
- * C_M_ENABLE_TABLE
- * Client asking Master to enable a table. - */ - C_M_ENABLE_TABLE (42, ExecutorType.MASTER_TABLE_OPERATIONS), - /** - * Messages originating from Client to Master.
- * C_M_MODIFY_TABLE
- * Client asking Master to modify a table. - */ - C_M_MODIFY_TABLE (43, ExecutorType.MASTER_TABLE_OPERATIONS), - /** - * Messages originating from Client to Master.
- * C_M_ADD_FAMILY
- * Client asking Master to add family to table. - */ - C_M_ADD_FAMILY (44, null), - /** - * Messages originating from Client to Master.
- * C_M_DELETE_FAMILY
- * Client asking Master to delete family of table. - */ - C_M_DELETE_FAMILY (45, null), - /** - * Messages originating from Client to Master.
- * C_M_MODIFY_FAMILY
- * Client asking Master to modify family of table. - */ - C_M_MODIFY_FAMILY (46, null), - /** - * Messages originating from Client to Master.
- * C_M_CREATE_TABLE
- * Client asking Master to create a table. - */ - C_M_CREATE_TABLE (47, ExecutorType.MASTER_TABLE_OPERATIONS), - /** - * Messages originating from Client to Master.
- * C_M_SNAPSHOT_TABLE
- * Client asking Master to snapshot an offline table. - */ - C_M_SNAPSHOT_TABLE (48, ExecutorType.MASTER_TABLE_OPERATIONS), - /** - * Messages originating from Client to Master.
- * C_M_RESTORE_SNAPSHOT
- * Client asking Master to restore a snapshot. - */ - C_M_RESTORE_SNAPSHOT (49, ExecutorType.MASTER_TABLE_OPERATIONS), - - // Updates from master to ZK. This is done by the master and there is - // nothing to process by either Master or RS - /** - * M_ZK_REGION_OFFLINE - * Master adds this region as offline in ZK - */ - M_ZK_REGION_OFFLINE (50, null), - /** - * M_ZK_REGION_CLOSING - * Master adds this region as closing in ZK - */ - M_ZK_REGION_CLOSING (51, null), - - /** - * Master controlled events to be executed on the master - * M_SERVER_SHUTDOWN - * Master is processing shutdown of a RS - */ - M_SERVER_SHUTDOWN (70, ExecutorType.MASTER_SERVER_OPERATIONS), - /** - * Master controlled events to be executed on the master.
- * M_META_SERVER_SHUTDOWN
- * Master is processing shutdown of RS hosting a meta region (-ROOT- or hbase:meta). - */ - M_META_SERVER_SHUTDOWN (72, ExecutorType.MASTER_META_SERVER_OPERATIONS), - /** - * Master controlled events to be executed on the master.
- * - * M_MASTER_RECOVERY
- * Master is processing recovery of regions found in ZK RIT - */ - M_MASTER_RECOVERY (73, ExecutorType.MASTER_SERVER_OPERATIONS), - /** - * Master controlled events to be executed on the master.
- * - * M_LOG_REPLAY
- * Master is processing log replay of failed region server - */ - M_LOG_REPLAY (74, ExecutorType.M_LOG_REPLAY_OPS), - - /** - * RS controlled events to be executed on the RS.
- * - * RS_PARALLEL_SEEK - */ - RS_PARALLEL_SEEK (80, ExecutorType.RS_PARALLEL_SEEK), - - /** - * RS wal recovery work items (splitting wals) to be executed on the RS.
- * - * RS_LOG_REPLAY - */ - RS_LOG_REPLAY (81, ExecutorType.RS_LOG_REPLAY_OPS), - - /** - * RS flush triggering from secondary region replicas to primary region replica.
- * - * RS_REGION_REPLICA_FLUSH - */ - RS_REGION_REPLICA_FLUSH (82, ExecutorType.RS_REGION_REPLICA_FLUSH_OPS), - - /** - * RS compacted files discharger
- * - * RS_COMPACTED_FILES_DISCHARGER - */ - RS_COMPACTED_FILES_DISCHARGER (83, ExecutorType.RS_COMPACTED_FILES_DISCHARGER); - - private final int code; - private final ExecutorType executor; - - /** - * Constructor - */ - EventType(final int code, final ExecutorType executor) { - this.code = code; - this.executor = executor; - } - - public int getCode() { - return this.code; - } - - public static EventType get(final int code) { - // Is this going to be slow? Its used rare but still... - for (EventType et: EventType.values()) { - if (et.getCode() == code) return et; - } - throw new IllegalArgumentException("Unknown code " + code); - } - - public boolean isOnlineSchemaChangeSupported() { - return ( - this.equals(EventType.C_M_ADD_FAMILY) || - this.equals(EventType.C_M_DELETE_FAMILY) || - this.equals(EventType.C_M_MODIFY_FAMILY) || - this.equals(EventType.C_M_MODIFY_TABLE) - ); - } - - ExecutorType getExecutorServiceType() { - return this.executor; - } -} diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/executor/ExecutorType.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/executor/ExecutorType.java deleted file mode 100644 index 548c7a4..0000000 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/executor/ExecutorType.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.hbase.executor; - -import org.apache.yetus.audience.InterfaceAudience; - -/** - * The following is a list of all executor types, both those that run in the - * master and those that run in the regionserver. - */ -@InterfaceAudience.Private -public enum ExecutorType { - - // Master executor services - MASTER_CLOSE_REGION (1), - MASTER_OPEN_REGION (2), - MASTER_SERVER_OPERATIONS (3), - MASTER_TABLE_OPERATIONS (4), - MASTER_RS_SHUTDOWN (5), - MASTER_META_SERVER_OPERATIONS (6), - M_LOG_REPLAY_OPS (7), - - // RegionServer executor services - RS_OPEN_REGION (20), - RS_OPEN_ROOT (21), - RS_OPEN_META (22), - RS_CLOSE_REGION (23), - RS_CLOSE_ROOT (24), - RS_CLOSE_META (25), - RS_PARALLEL_SEEK (26), - RS_LOG_REPLAY_OPS (27), - RS_REGION_REPLICA_FLUSH_OPS (28), - RS_COMPACTED_FILES_DISCHARGER (29), - RS_OPEN_PRIORITY_REGION (30); - - ExecutorType(int value) {} - - /** - * @param serverName - * @return Conflation of the executor type and the passed servername. - */ - String getExecutorName(String serverName) { - return this.toString() + "-" + serverName.replace("%", "%%"); - } -} diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/executor/EventType.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/executor/EventType.java new file mode 100644 index 0000000..26fb63a --- /dev/null +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/executor/EventType.java @@ -0,0 +1,313 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.executor; + +import org.apache.yetus.audience.InterfaceAudience; + +/** + * List of all HBase event handler types. Event types are named by a + * convention: event type names specify the component from which the event + * originated and then where its destined -- e.g. RS2ZK_ prefix means the + * event came from a regionserver destined for zookeeper -- and then what + * the even is; e.g. REGION_OPENING. + * + *

We give the enums indices so we can add types later and keep them + * grouped together rather than have to add them always to the end as we + * would have to if we used raw enum ordinals. + */ +@InterfaceAudience.Private +public enum EventType { + // Messages originating from RS (NOTE: there is NO direct communication from + // RS to Master). These are a result of RS updates into ZK. + // RS_ZK_REGION_CLOSING (1), // It is replaced by M_ZK_REGION_CLOSING(HBASE-4739) + + /** + * RS_ZK_REGION_CLOSED
+ * + * RS has finished closing a region. + */ + RS_ZK_REGION_CLOSED (2, ExecutorType.MASTER_CLOSE_REGION), + /** + * RS_ZK_REGION_OPENING
+ * + * RS is in process of opening a region. + */ + RS_ZK_REGION_OPENING (3, null), + /** + * RS_ZK_REGION_OPENED
+ * + * RS has finished opening a region. + */ + RS_ZK_REGION_OPENED (4, ExecutorType.MASTER_OPEN_REGION), + /** + * RS_ZK_REGION_SPLITTING
+ * + * RS has started a region split after master says it's ok to move on. + */ + RS_ZK_REGION_SPLITTING (5, null), + /** + * RS_ZK_REGION_SPLIT
+ * + * RS split has completed and is notifying the master. + */ + RS_ZK_REGION_SPLIT (6, ExecutorType.MASTER_SERVER_OPERATIONS), + /** + * RS_ZK_REGION_FAILED_OPEN
+ * + * RS failed to open a region. + */ + RS_ZK_REGION_FAILED_OPEN (7, ExecutorType.MASTER_CLOSE_REGION), + /** + * RS_ZK_REGION_MERGING
+ * + * RS has started merging regions after master says it's ok to move on. + */ + RS_ZK_REGION_MERGING (8, null), + /** + * RS_ZK_REGION_MERGE
+ * + * RS region merge has completed and is notifying the master. + */ + RS_ZK_REGION_MERGED (9, ExecutorType.MASTER_SERVER_OPERATIONS), + /** + * RS_ZK_REQUEST_REGION_SPLIT
+ * + * RS has requested to split a region. This is to notify master + * and check with master if the region is in a state good to split. + */ + RS_ZK_REQUEST_REGION_SPLIT (10, null), + /** + * RS_ZK_REQUEST_REGION_MERGE
+ * + * RS has requested to merge two regions. This is to notify master + * and check with master if two regions is in states good to merge. + */ + RS_ZK_REQUEST_REGION_MERGE (11, null), + + /** + * Messages originating from Master to RS.
+ * M_RS_OPEN_REGION
+ * Master asking RS to open a region. + */ + M_RS_OPEN_REGION (20, ExecutorType.RS_OPEN_REGION), + /** + * Messages originating from Master to RS.
+ * M_RS_OPEN_ROOT
+ * Master asking RS to open root. + */ + M_RS_OPEN_ROOT (21, ExecutorType.RS_OPEN_ROOT), + /** + * Messages originating from Master to RS.
+ * M_RS_OPEN_META
+ * Master asking RS to open meta. + */ + M_RS_OPEN_META (22, ExecutorType.RS_OPEN_META), + /** + * Messages originating from Master to RS.
+ * M_RS_CLOSE_REGION
+ * Master asking RS to close a region. + */ + M_RS_CLOSE_REGION (23, ExecutorType.RS_CLOSE_REGION), + /** + * Messages originating from Master to RS.
+ * M_RS_CLOSE_ROOT
+ * Master asking RS to close root. + */ + M_RS_CLOSE_ROOT (24, ExecutorType.RS_CLOSE_ROOT), + /** + * Messages originating from Master to RS.
+ * M_RS_CLOSE_META
+ * Master asking RS to close meta. + */ + M_RS_CLOSE_META (25, ExecutorType.RS_CLOSE_META), + /** + * Messages originating from Master to RS.
+ * M_RS_OPEN_PRIORITY_REGION
+ * Master asking RS to open a priority region. + */ + M_RS_OPEN_PRIORITY_REGION (26, ExecutorType.RS_OPEN_PRIORITY_REGION), + + /** + * Messages originating from Client to Master.
+ * C_M_MERGE_REGION
+ * Client asking Master to merge regions. + */ + C_M_MERGE_REGION (30, ExecutorType.MASTER_TABLE_OPERATIONS), + /** + * Messages originating from Client to Master.
+ * C_M_DELETE_TABLE
+ * Client asking Master to delete a table. + */ + C_M_DELETE_TABLE (40, ExecutorType.MASTER_TABLE_OPERATIONS), + /** + * Messages originating from Client to Master.
+ * C_M_DISABLE_TABLE
+ * Client asking Master to disable a table. + */ + C_M_DISABLE_TABLE (41, ExecutorType.MASTER_TABLE_OPERATIONS), + /** + * Messages originating from Client to Master.
+ * C_M_ENABLE_TABLE
+ * Client asking Master to enable a table. + */ + C_M_ENABLE_TABLE (42, ExecutorType.MASTER_TABLE_OPERATIONS), + /** + * Messages originating from Client to Master.
+ * C_M_MODIFY_TABLE
+ * Client asking Master to modify a table. + */ + C_M_MODIFY_TABLE (43, ExecutorType.MASTER_TABLE_OPERATIONS), + /** + * Messages originating from Client to Master.
+ * C_M_ADD_FAMILY
+ * Client asking Master to add family to table. + */ + C_M_ADD_FAMILY (44, null), + /** + * Messages originating from Client to Master.
+ * C_M_DELETE_FAMILY
+ * Client asking Master to delete family of table. + */ + C_M_DELETE_FAMILY (45, null), + /** + * Messages originating from Client to Master.
+ * C_M_MODIFY_FAMILY
+ * Client asking Master to modify family of table. + */ + C_M_MODIFY_FAMILY (46, null), + /** + * Messages originating from Client to Master.
+ * C_M_CREATE_TABLE
+ * Client asking Master to create a table. + */ + C_M_CREATE_TABLE (47, ExecutorType.MASTER_TABLE_OPERATIONS), + /** + * Messages originating from Client to Master.
+ * C_M_SNAPSHOT_TABLE
+ * Client asking Master to snapshot an offline table. + */ + C_M_SNAPSHOT_TABLE (48, ExecutorType.MASTER_TABLE_OPERATIONS), + /** + * Messages originating from Client to Master.
+ * C_M_RESTORE_SNAPSHOT
+ * Client asking Master to restore a snapshot. + */ + C_M_RESTORE_SNAPSHOT (49, ExecutorType.MASTER_TABLE_OPERATIONS), + + // Updates from master to ZK. This is done by the master and there is + // nothing to process by either Master or RS + /** + * M_ZK_REGION_OFFLINE + * Master adds this region as offline in ZK + */ + M_ZK_REGION_OFFLINE (50, null), + /** + * M_ZK_REGION_CLOSING + * Master adds this region as closing in ZK + */ + M_ZK_REGION_CLOSING (51, null), + + /** + * Master controlled events to be executed on the master + * M_SERVER_SHUTDOWN + * Master is processing shutdown of a RS + */ + M_SERVER_SHUTDOWN (70, ExecutorType.MASTER_SERVER_OPERATIONS), + /** + * Master controlled events to be executed on the master.
+ * M_META_SERVER_SHUTDOWN
+ * Master is processing shutdown of RS hosting a meta region (-ROOT- or hbase:meta). + */ + M_META_SERVER_SHUTDOWN (72, ExecutorType.MASTER_META_SERVER_OPERATIONS), + /** + * Master controlled events to be executed on the master.
+ * + * M_MASTER_RECOVERY
+ * Master is processing recovery of regions found in ZK RIT + */ + M_MASTER_RECOVERY (73, ExecutorType.MASTER_SERVER_OPERATIONS), + /** + * Master controlled events to be executed on the master.
+ * + * M_LOG_REPLAY
+ * Master is processing log replay of failed region server + */ + M_LOG_REPLAY (74, ExecutorType.M_LOG_REPLAY_OPS), + + /** + * RS controlled events to be executed on the RS.
+ * + * RS_PARALLEL_SEEK + */ + RS_PARALLEL_SEEK (80, ExecutorType.RS_PARALLEL_SEEK), + + /** + * RS wal recovery work items (splitting wals) to be executed on the RS.
+ * + * RS_LOG_REPLAY + */ + RS_LOG_REPLAY (81, ExecutorType.RS_LOG_REPLAY_OPS), + + /** + * RS flush triggering from secondary region replicas to primary region replica.
+ * + * RS_REGION_REPLICA_FLUSH + */ + RS_REGION_REPLICA_FLUSH (82, ExecutorType.RS_REGION_REPLICA_FLUSH_OPS), + + /** + * RS compacted files discharger
+ * + * RS_COMPACTED_FILES_DISCHARGER + */ + RS_COMPACTED_FILES_DISCHARGER (83, ExecutorType.RS_COMPACTED_FILES_DISCHARGER); + + private final int code; + private final ExecutorType executor; + + /** + * Constructor + */ + EventType(final int code, final ExecutorType executor) { + this.code = code; + this.executor = executor; + } + + public int getCode() { + return this.code; + } + + public static EventType get(final int code) { + // Is this going to be slow? Its used rare but still... + for (EventType et : EventType.values()) { + if (et.getCode() == code) { + return et; + } + } + throw new IllegalArgumentException("Unknown code " + code); + } + + public boolean isOnlineSchemaChangeSupported() { + return this.equals(EventType.C_M_ADD_FAMILY) || this.equals(EventType.C_M_DELETE_FAMILY) || + this.equals(EventType.C_M_MODIFY_FAMILY) || this.equals(EventType.C_M_MODIFY_TABLE); + } + + ExecutorType getExecutorServiceType() { + return this.executor; + } +} diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/executor/ExecutorType.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/executor/ExecutorType.java new file mode 100644 index 0000000..c75a0a9 --- /dev/null +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/executor/ExecutorType.java @@ -0,0 +1,60 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.executor; + +import org.apache.yetus.audience.InterfaceAudience; + +/** + * The following is a list of all executor types, both those that run in the + * master and those that run in the regionserver. + */ +@InterfaceAudience.Private +public enum ExecutorType { + + // Master executor services + MASTER_CLOSE_REGION (1), + MASTER_OPEN_REGION (2), + MASTER_SERVER_OPERATIONS (3), + MASTER_TABLE_OPERATIONS (4), + MASTER_RS_SHUTDOWN (5), + MASTER_META_SERVER_OPERATIONS (6), + M_LOG_REPLAY_OPS (7), + + // RegionServer executor services + RS_OPEN_REGION (20), + RS_OPEN_ROOT (21), + RS_OPEN_META (22), + RS_CLOSE_REGION (23), + RS_CLOSE_ROOT (24), + RS_CLOSE_META (25), + RS_PARALLEL_SEEK (26), + RS_LOG_REPLAY_OPS (27), + RS_REGION_REPLICA_FLUSH_OPS (28), + RS_COMPACTED_FILES_DISCHARGER (29), + RS_OPEN_PRIORITY_REGION (30); + + ExecutorType(int value) { + } + + /** + * @return Conflation of the executor type and the passed {@code serverName}. + */ + String getExecutorName(String serverName) { + return this.toString() + "-" + serverName.replace("%", "%%"); + } +} -- 2.7.4