HBASE-4373 HBaseAdmin.assign() does not use force flag (Ramkrishna)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1171697 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8948204c47
commit
db102ed307
|
@ -494,6 +494,7 @@ Release 0.91.0 - Unreleased
|
|||
HBASE-4287 If region opening fails, change region in transition into
|
||||
a FAILED_OPEN state so that it can be retried quickly. (todd)
|
||||
HBASE-4381 Refactor split decisions into a split policy class. (todd)
|
||||
HBASE-4373 HBaseAdmin.assign() does not use force flag (Ramkrishna)
|
||||
|
||||
TASKS
|
||||
HBASE-3559 Move report of split to master OFF the heartbeat channel
|
||||
|
|
|
@ -54,6 +54,7 @@ import org.apache.hadoop.hbase.ZooKeeperConnectionException;
|
|||
import org.apache.hadoop.hbase.catalog.CatalogTracker;
|
||||
import org.apache.hadoop.hbase.catalog.MetaReader;
|
||||
import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitor;
|
||||
import org.apache.hadoop.hbase.coprocessor.ObserverContext;
|
||||
import org.apache.hadoop.hbase.ipc.HMasterInterface;
|
||||
import org.apache.hadoop.hbase.ipc.HRegionInterface;
|
||||
import org.apache.hadoop.hbase.regionserver.wal.FailedLogCloseException;
|
||||
|
@ -1303,15 +1304,31 @@ public class HBaseAdmin implements Abortable, Closeable {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param regionName Region name to assign.
|
||||
* @param force True to force assign.
|
||||
* @param regionName
|
||||
* Region name to assign.
|
||||
* @param force
|
||||
* True to force assign.
|
||||
* @throws MasterNotRunningException
|
||||
* @throws ZooKeeperConnectionException
|
||||
* @throws IOException
|
||||
* @deprecated The <code>force</code> is unused.Use {@link #assign(byte[])}
|
||||
*/
|
||||
public void assign(final byte[] regionName, final boolean force)
|
||||
throws MasterNotRunningException, ZooKeeperConnectionException,
|
||||
IOException {
|
||||
getMaster().assign(regionName, force);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param regionName
|
||||
* Region name to assign.
|
||||
* @throws MasterNotRunningException
|
||||
* @throws ZooKeeperConnectionException
|
||||
* @throws IOException
|
||||
*/
|
||||
public void assign(final byte [] regionName, final boolean force)
|
||||
throws MasterNotRunningException, ZooKeeperConnectionException, IOException {
|
||||
getMaster().assign(regionName, force);
|
||||
public void assign(final byte[] regionName) throws MasterNotRunningException,
|
||||
ZooKeeperConnectionException, IOException {
|
||||
getMaster().assign(regionName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -112,12 +112,12 @@ public class BaseMasterObserver implements MasterObserver {
|
|||
|
||||
@Override
|
||||
public void preAssign(ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
HRegionInfo regionInfo, boolean force) throws IOException {
|
||||
HRegionInfo regionInfo) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postAssign(ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
HRegionInfo regionInfo, boolean force) throws IOException {
|
||||
HRegionInfo regionInfo) throws IOException {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -205,20 +205,17 @@ public interface MasterObserver extends Coprocessor {
|
|||
* Called prior to assigning a specific region.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param regionInfo the regionInfo of the region
|
||||
* @param force whether to force assignment or not
|
||||
*/
|
||||
void preAssign(final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
final HRegionInfo regionInfo, final boolean force)
|
||||
throws IOException;
|
||||
final HRegionInfo regionInfo) throws IOException;
|
||||
|
||||
/**
|
||||
* Called after the region assignment has been requested.
|
||||
* @param ctx the environment to interact with the framework and master
|
||||
* @param regionInfo the regionInfo of the region
|
||||
* @param force whether to force assignment or not
|
||||
*/
|
||||
void postAssign(final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||
final HRegionInfo regionInfo, final boolean force) throws IOException;
|
||||
final HRegionInfo regionInfo) throws IOException;
|
||||
|
||||
/**
|
||||
* Called prior to unassigning a given region.
|
||||
|
|
|
@ -24,11 +24,15 @@ import java.util.List;
|
|||
|
||||
import org.apache.hadoop.hbase.ClusterStatus;
|
||||
import org.apache.hadoop.hbase.HColumnDescriptor;
|
||||
import org.apache.hadoop.hbase.HRegionInfo;
|
||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||
import org.apache.hadoop.hbase.UnknownRegionException;
|
||||
import org.apache.hadoop.hbase.util.Pair;
|
||||
import org.apache.hadoop.hbase.coprocessor.ObserverContext;
|
||||
import org.apache.hadoop.hbase.ipc.VersionedProtocol;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Clients interact with the HMasterInterface to gain access to meta-level
|
||||
* HBase functionality, like finding an HRegionServer and creating/destroying
|
||||
|
@ -180,10 +184,20 @@ public interface HMasterInterface extends VersionedProtocol {
|
|||
* found.
|
||||
* @param force If true, will force the assignment.
|
||||
* @throws IOException
|
||||
* @deprecated The <code>force</code> is unused.Use {@link #assign(byte[])}
|
||||
*/
|
||||
public void assign(final byte [] regionName, final boolean force)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Assign a region to a server chosen at random.
|
||||
*
|
||||
* @param regionName
|
||||
* Region to assign. Will use existing RegionPlan if one found.
|
||||
* @throws IOException
|
||||
*/
|
||||
public void assign(final byte[] regionName) throws IOException;
|
||||
|
||||
/**
|
||||
* Unassign a region from current hosting regionserver. Region will then be
|
||||
* assigned to a regionserver chosen at random. Region could be reassigned
|
||||
|
|
|
@ -1332,22 +1332,30 @@ implements HMasterInterface, HMasterRegionInterface, MasterServices, Server {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void assign(final byte [] regionName, final boolean force)
|
||||
@Deprecated
|
||||
public void assign(final byte[] regionName, final boolean force)
|
||||
throws IOException {
|
||||
assign(regionName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assign(final byte [] regionName)throws IOException {
|
||||
Pair<HRegionInfo, ServerName> pair =
|
||||
MetaReader.getRegion(this.catalogTracker, regionName);
|
||||
if (pair == null) throw new UnknownRegionException(Bytes.toString(regionName));
|
||||
if (cpHost != null) {
|
||||
if (cpHost.preAssign(pair.getFirst(), force)) {
|
||||
if (cpHost.preAssign(pair.getFirst())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
assignRegion(pair.getFirst());
|
||||
if (cpHost != null) {
|
||||
cpHost.postAssign(pair.getFirst(), force);
|
||||
cpHost.postAssign(pair.getFirst());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void assignRegion(HRegionInfo hri) {
|
||||
assignmentManager.assign(hri, true);
|
||||
}
|
||||
|
|
|
@ -332,14 +332,13 @@ public class MasterCoprocessorHost
|
|||
}
|
||||
}
|
||||
|
||||
boolean preAssign(final HRegionInfo regionInfo, final boolean force)
|
||||
throws IOException {
|
||||
boolean preAssign(final HRegionInfo regionInfo) throws IOException {
|
||||
boolean bypass = false;
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env: coprocessors) {
|
||||
if (env.getInstance() instanceof MasterObserver) {
|
||||
ctx = ObserverContext.createAndPrepare(env, ctx);
|
||||
((MasterObserver)env.getInstance()).preAssign(ctx, regionInfo, force);
|
||||
((MasterObserver) env.getInstance()).preAssign(ctx, regionInfo);
|
||||
bypass |= ctx.shouldBypass();
|
||||
if (ctx.shouldComplete()) {
|
||||
break;
|
||||
|
@ -349,12 +348,12 @@ public class MasterCoprocessorHost
|
|||
return bypass;
|
||||
}
|
||||
|
||||
void postAssign(final HRegionInfo regionInfo, final boolean force) throws IOException {
|
||||
void postAssign(final HRegionInfo regionInfo) throws IOException {
|
||||
ObserverContext<MasterCoprocessorEnvironment> ctx = null;
|
||||
for (MasterEnvironment env: coprocessors) {
|
||||
if (env.getInstance() instanceof MasterObserver) {
|
||||
ctx = ObserverContext.createAndPrepare(env, ctx);
|
||||
((MasterObserver)env.getInstance()).postAssign(ctx, regionInfo, force);
|
||||
((MasterObserver) env.getInstance()).postAssign(ctx, regionInfo);
|
||||
if (ctx.shouldComplete()) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ public class HBaseFsckRepair {
|
|||
|
||||
private static void forceOfflineInZK(HBaseAdmin admin, final HRegionInfo region)
|
||||
throws ZooKeeperConnectionException, KeeperException, IOException {
|
||||
admin.assign(region.getRegionName(), true);
|
||||
admin.assign(region.getRegionName());
|
||||
}
|
||||
|
||||
private static void closeRegionSilentlyAndWait(Configuration conf,
|
||||
|
|
|
@ -230,8 +230,8 @@ module Hbase
|
|||
#----------------------------------------------------------------------------------------------
|
||||
#----------------------------------------------------------------------------------------------
|
||||
# Assign a region
|
||||
def assign(region_name, force)
|
||||
@admin.assign(region_name.to_java_bytes, java.lang.Boolean::valueOf(force))
|
||||
def assign(region_name)
|
||||
@admin.assign(region_name.to_java_bytes)
|
||||
end
|
||||
|
||||
#----------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -23,15 +23,15 @@ module Shell
|
|||
class Assign < Command
|
||||
def help
|
||||
return <<-EOF
|
||||
Assign a region. Add 'true' to force assign of a region. Use with caution.
|
||||
If region already assigned, this command will just go ahead and reassign
|
||||
Assign a region.Use with caution.If region already assigned,
|
||||
this command will just go ahead and reassign
|
||||
the region anyways. For experts only.
|
||||
EOF
|
||||
end
|
||||
|
||||
def command(region_name, force = 'false')
|
||||
def command(region_name)
|
||||
format_simple_command do
|
||||
admin.assign(region_name, force)
|
||||
admin.assign(region_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -336,7 +336,7 @@ public class TestMasterObserver {
|
|||
|
||||
@Override
|
||||
public void preAssign(ObserverContext<MasterCoprocessorEnvironment> env,
|
||||
final HRegionInfo regionInfo, final boolean force) throws IOException {
|
||||
final HRegionInfo regionInfo) throws IOException {
|
||||
if (bypass) {
|
||||
env.bypass();
|
||||
}
|
||||
|
@ -345,7 +345,7 @@ public class TestMasterObserver {
|
|||
|
||||
@Override
|
||||
public void postAssign(ObserverContext<MasterCoprocessorEnvironment> env,
|
||||
final HRegionInfo regionInfo, final boolean force) throws IOException {
|
||||
final HRegionInfo regionInfo) throws IOException {
|
||||
postAssignCalled = true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue