HBASE-21001 ReplicationObserver fails to load in HBase 2.0.0
This commit is contained in:
parent
5324911cd8
commit
12ffa086c7
|
@ -120,6 +120,7 @@ import org.apache.hadoop.hbase.client.TableDescriptor;
|
||||||
import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
|
import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
|
||||||
import org.apache.hadoop.hbase.conf.ConfigurationManager;
|
import org.apache.hadoop.hbase.conf.ConfigurationManager;
|
||||||
import org.apache.hadoop.hbase.conf.PropagatingConfigurationObserver;
|
import org.apache.hadoop.hbase.conf.PropagatingConfigurationObserver;
|
||||||
|
import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
|
||||||
import org.apache.hadoop.hbase.coprocessor.RegionObserver.MutationType;
|
import org.apache.hadoop.hbase.coprocessor.RegionObserver.MutationType;
|
||||||
import org.apache.hadoop.hbase.errorhandling.ForeignExceptionSnare;
|
import org.apache.hadoop.hbase.errorhandling.ForeignExceptionSnare;
|
||||||
import org.apache.hadoop.hbase.exceptions.FailedSanityCheckException;
|
import org.apache.hadoop.hbase.exceptions.FailedSanityCheckException;
|
||||||
|
@ -148,6 +149,8 @@ import org.apache.hadoop.hbase.regionserver.throttle.NoLimitThroughputController
|
||||||
import org.apache.hadoop.hbase.regionserver.throttle.StoreHotnessProtector;
|
import org.apache.hadoop.hbase.regionserver.throttle.StoreHotnessProtector;
|
||||||
import org.apache.hadoop.hbase.regionserver.throttle.ThroughputController;
|
import org.apache.hadoop.hbase.regionserver.throttle.ThroughputController;
|
||||||
import org.apache.hadoop.hbase.regionserver.wal.WALUtil;
|
import org.apache.hadoop.hbase.regionserver.wal.WALUtil;
|
||||||
|
import org.apache.hadoop.hbase.replication.ReplicationUtils;
|
||||||
|
import org.apache.hadoop.hbase.replication.regionserver.ReplicationObserver;
|
||||||
import org.apache.hadoop.hbase.security.User;
|
import org.apache.hadoop.hbase.security.User;
|
||||||
import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils;
|
import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils;
|
||||||
import org.apache.hadoop.hbase.snapshot.SnapshotManifest;
|
import org.apache.hadoop.hbase.snapshot.SnapshotManifest;
|
||||||
|
@ -810,6 +813,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
|
||||||
this.htableDescriptor.getDurability() == Durability.USE_DEFAULT ? defaultDurability :
|
this.htableDescriptor.getDurability() == Durability.USE_DEFAULT ? defaultDurability :
|
||||||
this.htableDescriptor.getDurability();
|
this.htableDescriptor.getDurability();
|
||||||
|
|
||||||
|
decorateRegionConfiguration(conf);
|
||||||
if (rsServices != null) {
|
if (rsServices != null) {
|
||||||
this.rsAccounting = this.rsServices.getRegionServerAccounting();
|
this.rsAccounting = this.rsServices.getRegionServerAccounting();
|
||||||
// don't initialize coprocessors if not running within a regionserver
|
// don't initialize coprocessors if not running within a regionserver
|
||||||
|
@ -8625,4 +8629,19 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
|
||||||
requestFlush0(tracker);
|
requestFlush0(tracker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method modifies the region's configuration in order to inject replication-related
|
||||||
|
* features
|
||||||
|
* @param conf region configurations
|
||||||
|
*/
|
||||||
|
static void decorateRegionConfiguration(Configuration conf) {
|
||||||
|
if (ReplicationUtils.isReplicationForBulkLoadDataEnabled(conf)) {
|
||||||
|
String plugins = conf.get(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,"");
|
||||||
|
String replicationCoprocessorClass = ReplicationObserver.class.getCanonicalName();
|
||||||
|
if (!plugins.contains(replicationCoprocessorClass)) {
|
||||||
|
conf.set(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
|
||||||
|
(plugins.equals("") ? "" : (plugins + ",")) + replicationCoprocessorClass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,9 +129,7 @@ import org.apache.hadoop.hbase.regionserver.handler.RSProcedureHandler;
|
||||||
import org.apache.hadoop.hbase.regionserver.handler.RegionReplicaFlushHandler;
|
import org.apache.hadoop.hbase.regionserver.handler.RegionReplicaFlushHandler;
|
||||||
import org.apache.hadoop.hbase.regionserver.throttle.FlushThroughputControllerFactory;
|
import org.apache.hadoop.hbase.regionserver.throttle.FlushThroughputControllerFactory;
|
||||||
import org.apache.hadoop.hbase.regionserver.throttle.ThroughputController;
|
import org.apache.hadoop.hbase.regionserver.throttle.ThroughputController;
|
||||||
import org.apache.hadoop.hbase.replication.ReplicationUtils;
|
|
||||||
import org.apache.hadoop.hbase.replication.regionserver.ReplicationLoad;
|
import org.apache.hadoop.hbase.replication.regionserver.ReplicationLoad;
|
||||||
import org.apache.hadoop.hbase.replication.regionserver.ReplicationObserver;
|
|
||||||
import org.apache.hadoop.hbase.replication.regionserver.ReplicationSourceInterface;
|
import org.apache.hadoop.hbase.replication.regionserver.ReplicationSourceInterface;
|
||||||
import org.apache.hadoop.hbase.replication.regionserver.ReplicationStatus;
|
import org.apache.hadoop.hbase.replication.regionserver.ReplicationStatus;
|
||||||
import org.apache.hadoop.hbase.security.Superusers;
|
import org.apache.hadoop.hbase.security.Superusers;
|
||||||
|
@ -542,7 +540,6 @@ public class HRegionServer extends HasThread implements
|
||||||
checkCodecs(this.conf);
|
checkCodecs(this.conf);
|
||||||
this.userProvider = UserProvider.instantiate(conf);
|
this.userProvider = UserProvider.instantiate(conf);
|
||||||
FSUtils.setupShortCircuitRead(this.conf);
|
FSUtils.setupShortCircuitRead(this.conf);
|
||||||
decorateRegionServerConfiguration(this.conf);
|
|
||||||
|
|
||||||
// Disable usage of meta replicas in the regionserver
|
// Disable usage of meta replicas in the regionserver
|
||||||
this.conf.setBoolean(HConstants.USE_META_REPLICAS, false);
|
this.conf.setBoolean(HConstants.USE_META_REPLICAS, false);
|
||||||
|
@ -3725,22 +3722,6 @@ public class HRegionServer extends HasThread implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method modifies the region server's configuration in order to inject replication-related
|
|
||||||
* features
|
|
||||||
* @param conf region server configurations
|
|
||||||
*/
|
|
||||||
static void decorateRegionServerConfiguration(Configuration conf) {
|
|
||||||
if (ReplicationUtils.isReplicationForBulkLoadDataEnabled(conf)) {
|
|
||||||
String plugins = conf.get(CoprocessorHost.REGIONSERVER_COPROCESSOR_CONF_KEY, "");
|
|
||||||
String rsCoprocessorClass = ReplicationObserver.class.getCanonicalName();
|
|
||||||
if (!plugins.contains(rsCoprocessorClass)) {
|
|
||||||
conf.set(CoprocessorHost.REGIONSERVER_COPROCESSOR_CONF_KEY,
|
|
||||||
plugins + "," + rsCoprocessorClass);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isShutDown() {
|
public boolean isShutDown() {
|
||||||
return shutDown;
|
return shutDown;
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,6 +113,7 @@ import org.apache.hadoop.hbase.client.RowMutations;
|
||||||
import org.apache.hadoop.hbase.client.Scan;
|
import org.apache.hadoop.hbase.client.Scan;
|
||||||
import org.apache.hadoop.hbase.client.Table;
|
import org.apache.hadoop.hbase.client.Table;
|
||||||
import org.apache.hadoop.hbase.client.TableDescriptor;
|
import org.apache.hadoop.hbase.client.TableDescriptor;
|
||||||
|
import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
|
||||||
import org.apache.hadoop.hbase.exceptions.FailedSanityCheckException;
|
import org.apache.hadoop.hbase.exceptions.FailedSanityCheckException;
|
||||||
import org.apache.hadoop.hbase.filter.BigDecimalComparator;
|
import org.apache.hadoop.hbase.filter.BigDecimalComparator;
|
||||||
import org.apache.hadoop.hbase.filter.BinaryComparator;
|
import org.apache.hadoop.hbase.filter.BinaryComparator;
|
||||||
|
@ -139,6 +140,7 @@ import org.apache.hadoop.hbase.regionserver.compactions.CompactionRequestImpl;
|
||||||
import org.apache.hadoop.hbase.regionserver.wal.FSHLog;
|
import org.apache.hadoop.hbase.regionserver.wal.FSHLog;
|
||||||
import org.apache.hadoop.hbase.regionserver.wal.MetricsWALSource;
|
import org.apache.hadoop.hbase.regionserver.wal.MetricsWALSource;
|
||||||
import org.apache.hadoop.hbase.regionserver.wal.WALUtil;
|
import org.apache.hadoop.hbase.regionserver.wal.WALUtil;
|
||||||
|
import org.apache.hadoop.hbase.replication.regionserver.ReplicationObserver;
|
||||||
import org.apache.hadoop.hbase.security.User;
|
import org.apache.hadoop.hbase.security.User;
|
||||||
import org.apache.hadoop.hbase.test.MetricsAssertHelper;
|
import org.apache.hadoop.hbase.test.MetricsAssertHelper;
|
||||||
import org.apache.hadoop.hbase.testclassification.LargeTests;
|
import org.apache.hadoop.hbase.testclassification.LargeTests;
|
||||||
|
@ -6524,6 +6526,29 @@ public class TestHRegion {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBulkLoadReplicationEnabled() throws IOException {
|
||||||
|
TEST_UTIL.getConfiguration().setBoolean(HConstants.REPLICATION_BULKLOAD_ENABLE_KEY, true);
|
||||||
|
final ServerName serverName = ServerName.valueOf(name.getMethodName(), 100, 42);
|
||||||
|
final RegionServerServices rss = spy(TEST_UTIL.createMockRegionServerService(serverName));
|
||||||
|
|
||||||
|
HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(name.getMethodName()));
|
||||||
|
htd.addFamily(new HColumnDescriptor(fam1));
|
||||||
|
HRegionInfo hri = new HRegionInfo(htd.getTableName(),
|
||||||
|
HConstants.EMPTY_BYTE_ARRAY, HConstants.EMPTY_BYTE_ARRAY);
|
||||||
|
region = HRegion.openHRegion(hri, htd, rss.getWAL(hri), TEST_UTIL.getConfiguration(),
|
||||||
|
rss, null);
|
||||||
|
|
||||||
|
assertTrue(region.conf.getBoolean(HConstants.REPLICATION_BULKLOAD_ENABLE_KEY, false));
|
||||||
|
String plugins = region.conf.get(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY, "");
|
||||||
|
String replicationCoprocessorClass = ReplicationObserver.class.getCanonicalName();
|
||||||
|
assertTrue(plugins.contains(replicationCoprocessorClass));
|
||||||
|
assertTrue(region.getCoprocessorHost().
|
||||||
|
getCoprocessors().contains(ReplicationObserver.class.getSimpleName()));
|
||||||
|
|
||||||
|
region.close();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The same as HRegion class, the only difference is that instantiateHStore will
|
* The same as HRegion class, the only difference is that instantiateHStore will
|
||||||
* create a different HStore - HStoreForTesting. [HBASE-8518]
|
* create a different HStore - HStoreForTesting. [HBASE-8518]
|
||||||
|
|
Loading…
Reference in New Issue