HBASE-25617 Revisit the span names (#2998)
[hbase.git] / hbase-client / src / main / java / org / apache / hadoop / hbase / client / Hbck.java
blobc518a87d61c018babb32bb7e3abdb8fdc5f0e76c
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 package org.apache.hadoop.hbase.client;
20 import java.io.Closeable;
21 import java.io.IOException;
22 import java.util.List;
23 import java.util.Map;
24 import java.util.stream.Collectors;
25 import org.apache.hadoop.hbase.Abortable;
26 import org.apache.hadoop.hbase.HBaseInterfaceAudience;
27 import org.apache.hadoop.hbase.ServerName;
28 import org.apache.hadoop.hbase.master.RegionState;
29 import org.apache.yetus.audience.InterfaceAudience;
31 import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
32 import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos;
34 /**
35 * Hbck fixup tool APIs. Obtain an instance from {@link Connection#getHbck()} and call
36 * {@link #close()} when done.
37 * <p>WARNING: the below methods can damage the cluster. It may leave the cluster in an
38 * indeterminate state, e.g. region not assigned, or some hdfs files left behind. After running
39 * any of the below, operators may have to do some clean up on hdfs or schedule some assign
40 * procedures to get regions back online. DO AT YOUR OWN RISK. For experienced users only.
42 * @see ConnectionFactory
43 * @since 2.0.2, 2.1.1
45 @InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.HBCK)
46 public interface Hbck extends Abortable, Closeable {
47 /**
48 * Update table state in Meta only. No procedures are submitted to open/assign or
49 * close/unassign regions of the table.
50 * @param state table state
51 * @return previous state of the table in Meta
53 TableState setTableStateInMeta(TableState state) throws IOException;
55 /**
56 * Update region state in Meta only. No procedures are submitted to manipulate the given region or
57 * any other region from same table.
58 * @param nameOrEncodedName2State list of all region states to be updated in meta
59 * @return previous state of the region in Meta
61 Map<String, RegionState.State>
62 setRegionStateInMeta(Map<String, RegionState.State> nameOrEncodedName2State) throws IOException;
64 /**
65 * Like {@link Admin#assign(byte[])} but 'raw' in that it can do more than one Region at a time
66 * -- good if many Regions to online -- and it will schedule the assigns even in the case where
67 * Master is initializing (as long as the ProcedureExecutor is up). Does NOT call Coprocessor
68 * hooks.
69 * @param override You need to add the override for case where a region has previously been
70 * bypassed. When a Procedure has been bypassed, a Procedure will have completed
71 * but no other Procedure will be able to make progress on the target entity
72 * (intentionally). This override flag will override this fencing mechanism.
73 * @param encodedRegionNames Region encoded names; e.g. 1588230740 is the hard-coded encoding
74 * for hbase:meta region and de00010733901a05f5a2a3a382e27dd4 is an
75 * example of what a random user-space encoded Region name looks like.
77 List<Long> assigns(List<String> encodedRegionNames, boolean override) throws IOException;
79 default List<Long> assigns(List<String> encodedRegionNames) throws IOException {
80 return assigns(encodedRegionNames, false);
83 /**
84 * Like {@link Admin#unassign(byte[], boolean)} but 'raw' in that it can do more than one Region
85 * at a time -- good if many Regions to offline -- and it will schedule the assigns even in the
86 * case where Master is initializing (as long as the ProcedureExecutor is up). Does NOT call
87 * Coprocessor hooks.
88 * @param override You need to add the override for case where a region has previously been
89 * bypassed. When a Procedure has been bypassed, a Procedure will have completed
90 * but no other Procedure will be able to make progress on the target entity
91 * (intentionally). This override flag will override this fencing mechanism.
92 * @param encodedRegionNames Region encoded names; e.g. 1588230740 is the hard-coded encoding
93 * for hbase:meta region and de00010733901a05f5a2a3a382e27dd4 is an
94 * example of what a random user-space encoded Region name looks like.
96 List<Long> unassigns(List<String> encodedRegionNames, boolean override) throws IOException;
98 default List<Long> unassigns(List<String> encodedRegionNames) throws IOException {
99 return unassigns(encodedRegionNames, false);
103 * Bypass specified procedure and move it to completion. Procedure is marked completed but
104 * no actual work is done from the current state/step onwards. Parents of the procedure are
105 * also marked for bypass.
107 * @param pids of procedures to complete.
108 * @param waitTime wait time in ms for acquiring lock for a procedure
109 * @param override if override set to true, we will bypass the procedure even if it is executing.
110 * This is for procedures which can't break out during execution (bugs?).
111 * @param recursive If set, if a parent procedure, we will find and bypass children and then
112 * the parent procedure (Dangerous but useful in case where child procedure has been 'lost').
113 * Does not always work. Experimental.
114 * @return true if procedure is marked for bypass successfully, false otherwise
116 List<Boolean> bypassProcedure(List<Long> pids, long waitTime, boolean override, boolean recursive)
117 throws IOException;
120 * Use {@link #scheduleServerCrashProcedures(List)} instead.
121 * @deprecated since 2.2.1. Will removed in 3.0.0.
123 @Deprecated
124 default List<Long> scheduleServerCrashProcedure(List<HBaseProtos.ServerName> serverNames)
125 throws IOException {
126 return scheduleServerCrashProcedures(
127 serverNames.stream().map(ProtobufUtil::toServerName).collect(Collectors.toList()));
130 List<Long> scheduleServerCrashProcedures(List<ServerName> serverNames) throws IOException;
132 List<Long> scheduleSCPsForUnknownServers() throws IOException;
135 * Request HBCK chore to run at master side.
137 * @return <code>true</code> if HBCK chore ran, <code>false</code> if HBCK chore already running
138 * @throws IOException if a remote or network exception occurs
140 boolean runHbckChore() throws IOException;
143 * Fix Meta.
145 void fixMeta() throws IOException;