HBASE-26474 Implement connection-level attributes (addendum)
[hbase.git] / hbase-client / src / main / java / org / apache / hadoop / hbase / client / Hbck.java
blob7e9a519b95f1cb2f6d656b5b72890db0f3206fdb
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 org.apache.hadoop.hbase.Abortable;
25 import org.apache.hadoop.hbase.HBaseInterfaceAudience;
26 import org.apache.hadoop.hbase.ServerName;
27 import org.apache.hadoop.hbase.master.RegionState;
28 import org.apache.yetus.audience.InterfaceAudience;
30 /**
31 * Hbck fixup tool APIs. Obtain an instance from {@link Connection#getHbck()} and call
32 * {@link #close()} when done.
33 * <p>WARNING: the below methods can damage the cluster. It may leave the cluster in an
34 * indeterminate state, e.g. region not assigned, or some hdfs files left behind. After running
35 * any of the below, operators may have to do some clean up on hdfs or schedule some assign
36 * procedures to get regions back online. DO AT YOUR OWN RISK. For experienced users only.
38 * @see ConnectionFactory
39 * @since 2.0.2, 2.1.1
41 @InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.HBCK)
42 public interface Hbck extends Abortable, Closeable {
43 /**
44 * Update table state in Meta only. No procedures are submitted to open/assign or
45 * close/unassign regions of the table.
46 * @param state table state
47 * @return previous state of the table in Meta
49 TableState setTableStateInMeta(TableState state) throws IOException;
51 /**
52 * Update region state in Meta only. No procedures are submitted to manipulate the given region or
53 * any other region from same table.
54 * @param nameOrEncodedName2State list of all region states to be updated in meta
55 * @return previous state of the region in Meta
57 Map<String, RegionState.State>
58 setRegionStateInMeta(Map<String, RegionState.State> nameOrEncodedName2State) throws IOException;
60 /**
61 * Like {@link Admin#assign(byte[])} but 'raw' in that it can do more than one Region at a time
62 * -- good if many Regions to online -- and it will schedule the assigns even in the case where
63 * Master is initializing (as long as the ProcedureExecutor is up). Does NOT call Coprocessor
64 * hooks.
65 * @param override You need to add the override for case where a region has previously been
66 * bypassed. When a Procedure has been bypassed, a Procedure will have completed
67 * but no other Procedure will be able to make progress on the target entity
68 * (intentionally). This override flag will override this fencing mechanism.
69 * @param encodedRegionNames Region encoded names; e.g. 1588230740 is the hard-coded encoding
70 * for hbase:meta region and de00010733901a05f5a2a3a382e27dd4 is an
71 * example of what a random user-space encoded Region name looks like.
73 List<Long> assigns(List<String> encodedRegionNames, boolean override) throws IOException;
75 default List<Long> assigns(List<String> encodedRegionNames) throws IOException {
76 return assigns(encodedRegionNames, false);
79 /**
80 * Like {@link Admin#unassign(byte[], boolean)} but 'raw' in that it can do more than one Region
81 * at a time -- good if many Regions to offline -- and it will schedule the assigns even in the
82 * case where Master is initializing (as long as the ProcedureExecutor is up). Does NOT call
83 * Coprocessor hooks.
84 * @param override You need to add the override for case where a region has previously been
85 * bypassed. When a Procedure has been bypassed, a Procedure will have completed
86 * but no other Procedure will be able to make progress on the target entity
87 * (intentionally). This override flag will override this fencing mechanism.
88 * @param encodedRegionNames Region encoded names; e.g. 1588230740 is the hard-coded encoding
89 * for hbase:meta region and de00010733901a05f5a2a3a382e27dd4 is an
90 * example of what a random user-space encoded Region name looks like.
92 List<Long> unassigns(List<String> encodedRegionNames, boolean override) throws IOException;
94 default List<Long> unassigns(List<String> encodedRegionNames) throws IOException {
95 return unassigns(encodedRegionNames, false);
98 /**
99 * Bypass specified procedure and move it to completion. Procedure is marked completed but
100 * no actual work is done from the current state/step onwards. Parents of the procedure are
101 * also marked for bypass.
103 * @param pids of procedures to complete.
104 * @param waitTime wait time in ms for acquiring lock for a procedure
105 * @param override if override set to true, we will bypass the procedure even if it is executing.
106 * This is for procedures which can't break out during execution (bugs?).
107 * @param recursive If set, if a parent procedure, we will find and bypass children and then
108 * the parent procedure (Dangerous but useful in case where child procedure has been 'lost').
109 * Does not always work. Experimental.
110 * @return true if procedure is marked for bypass successfully, false otherwise
112 List<Boolean> bypassProcedure(List<Long> pids, long waitTime, boolean override, boolean recursive)
113 throws IOException;
115 List<Long> scheduleServerCrashProcedures(List<ServerName> serverNames) throws IOException;
117 List<Long> scheduleSCPsForUnknownServers() throws IOException;
120 * Request HBCK chore to run at master side.
122 * @return <code>true</code> if HBCK chore ran, <code>false</code> if HBCK chore already running
123 * @throws IOException if a remote or network exception occurs
125 boolean runHbckChore() throws IOException;
128 * Fix Meta.
130 void fixMeta() throws IOException;