HBASE-16419 check REPLICATION_SCOPE's value more stringently (Guangxu Cheng)
This commit is contained in:
parent
d5080e82fb
commit
233ca65b8f
|
@ -131,6 +131,7 @@ import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
|
||||||
import org.apache.hadoop.hbase.procedure2.store.wal.WALProcedureStore;
|
import org.apache.hadoop.hbase.procedure2.store.wal.WALProcedureStore;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.GetRegionInfoResponse.CompactionState;
|
import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.GetRegionInfoResponse.CompactionState;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo;
|
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionServerInfo;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.WALProtos;
|
||||||
import org.apache.hadoop.hbase.quotas.MasterQuotaManager;
|
import org.apache.hadoop.hbase.quotas.MasterQuotaManager;
|
||||||
import org.apache.hadoop.hbase.regionserver.DefaultStoreEngine;
|
import org.apache.hadoop.hbase.regionserver.DefaultStoreEngine;
|
||||||
import org.apache.hadoop.hbase.regionserver.HRegionServer;
|
import org.apache.hadoop.hbase.regionserver.HRegionServer;
|
||||||
|
@ -1581,11 +1582,7 @@ public class HMaster extends HRegionServer implements MasterServices {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check replication scope
|
// check replication scope
|
||||||
if (hcd.getScope() < 0) {
|
checkReplicationScope(hcd);
|
||||||
String message = "Replication scope for column family "
|
|
||||||
+ hcd.getNameAsString() + " must be positive.";
|
|
||||||
warnOrThrowExceptionForFailure(logWarn, CONF_KEY, message, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
// check data replication factor, it can be 0(default value) when user has not explicitly
|
// check data replication factor, it can be 0(default value) when user has not explicitly
|
||||||
// set the value, in this case we use default replication factor set in the file system.
|
// set the value, in this case we use default replication factor set in the file system.
|
||||||
|
@ -1599,6 +1596,18 @@ public class HMaster extends HRegionServer implements MasterServices {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkReplicationScope(HColumnDescriptor hcd) throws IOException{
|
||||||
|
// check replication scope
|
||||||
|
WALProtos.ScopeType scop = WALProtos.ScopeType.valueOf(hcd.getScope());
|
||||||
|
if (scop == null) {
|
||||||
|
String message = "Replication scope for column family "
|
||||||
|
+ hcd.getNameAsString() + " is " + hcd.getScope() + " which is invalid.";
|
||||||
|
|
||||||
|
LOG.error(message);
|
||||||
|
throw new DoNotRetryIOException(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void checkCompactionPolicy(Configuration conf, HTableDescriptor htd)
|
private void checkCompactionPolicy(Configuration conf, HTableDescriptor htd)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
// FIFO compaction has some requirements
|
// FIFO compaction has some requirements
|
||||||
|
@ -1833,6 +1842,7 @@ public class HMaster extends HRegionServer implements MasterServices {
|
||||||
checkInitialized();
|
checkInitialized();
|
||||||
checkCompression(columnDescriptor);
|
checkCompression(columnDescriptor);
|
||||||
checkEncryption(conf, columnDescriptor);
|
checkEncryption(conf, columnDescriptor);
|
||||||
|
checkReplicationScope(columnDescriptor);
|
||||||
if (cpHost != null) {
|
if (cpHost != null) {
|
||||||
if (cpHost.preAddColumn(tableName, columnDescriptor)) {
|
if (cpHost.preAddColumn(tableName, columnDescriptor)) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1860,6 +1870,7 @@ public class HMaster extends HRegionServer implements MasterServices {
|
||||||
checkInitialized();
|
checkInitialized();
|
||||||
checkCompression(descriptor);
|
checkCompression(descriptor);
|
||||||
checkEncryption(conf, descriptor);
|
checkEncryption(conf, descriptor);
|
||||||
|
checkReplicationScope(descriptor);
|
||||||
if (cpHost != null) {
|
if (cpHost != null) {
|
||||||
if (cpHost.preModifyColumn(tableName, descriptor)) {
|
if (cpHost.preModifyColumn(tableName, descriptor)) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in New Issue