-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-23647: Make MasterRegistry the default impl. #1039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -250,7 +250,7 @@ public static Configuration createClusterConf(Configuration baseConf, String clu | |
| * @return the merged configuration with override properties and cluster key applied | ||
| */ | ||
| public static Configuration createClusterConf(Configuration baseConf, String clusterKey, | ||
| String overridePrefix) throws IOException { | ||
| String overridePrefix) throws IOException { | ||
| Configuration clusterConf = HBaseConfiguration.create(baseConf); | ||
| if (clusterKey != null && !clusterKey.isEmpty()) { | ||
| applyClusterKeyToConf(clusterConf, clusterKey); | ||
|
|
@@ -268,14 +268,21 @@ public static Configuration createClusterConf(Configuration baseConf, String clu | |
| * used to communicate with distant clusters | ||
| * @param conf configuration object to configure | ||
| * @param key string that contains the 3 required configuratins | ||
| * @throws IOException | ||
| */ | ||
| private static void applyClusterKeyToConf(Configuration conf, String key) | ||
| throws IOException{ | ||
| throws IOException { | ||
| ZKConfig.ZKClusterKey zkClusterKey = ZKConfig.transformClusterKey(key); | ||
| conf.set(HConstants.ZOOKEEPER_QUORUM, zkClusterKey.getQuorumString()); | ||
| conf.setInt(HConstants.ZOOKEEPER_CLIENT_PORT, zkClusterKey.getClientPort()); | ||
| conf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, zkClusterKey.getZnodeParent()); | ||
| // Without the right registry, the above configs are useless. Also, we don't use setClass() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a check-then-fail that can be done to assert that the method invocation has significance? Maybe log a warning saying zk configs are being applied to a master registry?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added the logging. Don't think it should be warn though. |
||
| // here because the ConnectionRegistry* classes are not resolvable from this module. | ||
| // This will be broken if ZkConnectionRegistry class gets renamed or moved. Is there a better | ||
| // way? | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could use findClass and if there's an exception fall through to alternate or recovery code. Anyway, agreed, a reference to a class constant is not called for here.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There is no alternate or recovery from that point, no? The same error is propagated while creating the registry instance, so I guess we don't need to do it again here I think.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code is going waste away. If user chooses zk registry, this code applies?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree. It is ok to leave as-is since it is a no-op?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm finding this method used by
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm. Good point. TableMapReduceUtil: This happens only in initCredentialsForCluster() or if hbase.mapred.output.quorum is specified. Basically it only happens for a "peer" cluster. (same for TableOutputFormat, unless QUORUM_ADDRESS for a target is specified this doesn't happen). Overall, I think all MR jobs running on a single cluster will use master registry. I think that answers the MR/Spark/Flink usecases. Now coming to MR jobs spanning multiple clusters (source and target) Ex: VerifyReplication / ExportSnapshot/SyncTable/TableOutputFormat etc I think these need to be rewritten with new config params like hbase.[source|target].master.addrs for clients to pass the addresses so that they can use master registry. What do you think? Should we rewrite them with new configs or maintain compatibility and keep using zkregistry?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sounds good.
I think it's best to reduce the ZK-exposed surface area as much as possible. This seems a reasonable solution to me. |
||
| LOG.info("Overriding client registry implementation to {}", | ||
| HConstants.ZK_CONNECTION_REGISTRY_CLASS); | ||
| conf.set(HConstants.CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY, | ||
| HConstants.ZK_CONNECTION_REGISTRY_CLASS); | ||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,7 +91,7 @@ public LocalHBaseCluster(final Configuration conf) | |
| */ | ||
| public LocalHBaseCluster(final Configuration conf, final int noRegionServers) | ||
| throws IOException { | ||
| this(conf, 1, noRegionServers, getMasterImplementation(conf), | ||
| this(conf, 1, 0, noRegionServers, getMasterImplementation(conf), | ||
| getRegionServerImplementation(conf)); | ||
| } | ||
|
|
||
|
|
@@ -106,7 +106,7 @@ public LocalHBaseCluster(final Configuration conf, final int noRegionServers) | |
| public LocalHBaseCluster(final Configuration conf, final int noMasters, | ||
| final int noRegionServers) | ||
| throws IOException { | ||
| this(conf, noMasters, noRegionServers, getMasterImplementation(conf), | ||
| this(conf, noMasters, 0, noRegionServers, getMasterImplementation(conf), | ||
| getRegionServerImplementation(conf)); | ||
| } | ||
|
|
||
|
|
@@ -122,6 +122,12 @@ private static Class<? extends HMaster> getMasterImplementation(final Configurat | |
| HMaster.class); | ||
| } | ||
|
|
||
| public LocalHBaseCluster(final Configuration conf, final int noMasters, final int noRegionServers, | ||
| final Class<? extends HMaster> masterClass, | ||
| final Class<? extends HRegionServer> regionServerClass) throws IOException { | ||
| this(conf, noMasters, 0, noRegionServers, masterClass, regionServerClass); | ||
| } | ||
|
|
||
| /** | ||
| * Constructor. | ||
| * @param conf Configuration to use. Post construction has the master's | ||
|
|
@@ -134,9 +140,9 @@ private static Class<? extends HMaster> getMasterImplementation(final Configurat | |
| */ | ||
| @SuppressWarnings("unchecked") | ||
| public LocalHBaseCluster(final Configuration conf, final int noMasters, | ||
| final int noRegionServers, final Class<? extends HMaster> masterClass, | ||
| final Class<? extends HRegionServer> regionServerClass) | ||
| throws IOException { | ||
| final int noAlwaysStandByMasters, final int noRegionServers, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ugh. The final constructor args are
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ya, too long and confusing now. |
||
| final Class<? extends HMaster> masterClass, | ||
| final Class<? extends HRegionServer> regionServerClass) throws IOException { | ||
| this.conf = conf; | ||
|
|
||
| // When active, if a port selection is default then we switch to random | ||
|
|
@@ -170,24 +176,22 @@ public LocalHBaseCluster(final Configuration conf, final int noMasters, | |
| this.masterClass = (Class<? extends HMaster>) | ||
| conf.getClass(HConstants.MASTER_IMPL, masterClass); | ||
| // Start the HMasters. | ||
| for (int i = 0; i < noMasters; i++) { | ||
| int i; | ||
| for (i = 0; i < noMasters; i++) { | ||
| addMaster(new Configuration(conf), i); | ||
| } | ||
|
|
||
| // Populate the master address host ports in the config. This is needed if a master based | ||
| // registry is configured for client metadata services (HBASE-18095) | ||
| List<String> masterHostPorts = new ArrayList<>(); | ||
| getMasters().forEach(masterThread -> | ||
| masterHostPorts.add(masterThread.getMaster().getServerName().getAddress().toString())); | ||
| conf.set(HConstants.MASTER_ADDRS_KEY, String.join(",", masterHostPorts)); | ||
|
|
||
| for (int j = 0; j < noAlwaysStandByMasters; j++) { | ||
| Configuration c = new Configuration(conf); | ||
| c.set(HConstants.MASTER_IMPL, "org.apache.hadoop.hbase.master.AlwaysStandByHMaster"); | ||
bharathv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| addMaster(c, i + j); | ||
| } | ||
| // Start the HRegionServers. | ||
| this.regionServerClass = | ||
| (Class<? extends HRegionServer>)conf.getClass(HConstants.REGION_SERVER_IMPL, | ||
| regionServerClass); | ||
|
|
||
| for (int i = 0; i < noRegionServers; i++) { | ||
| addRegionServer(new Configuration(conf), i); | ||
| for (int j = 0; j < noRegionServers; j++) { | ||
| addRegionServer(new Configuration(conf), j); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -233,8 +237,13 @@ public JVMClusterUtil.MasterThread addMaster(Configuration c, final int index) | |
| // its Connection instance rather than share (see HBASE_INSTANCES down in | ||
| // the guts of ConnectionManager. | ||
| JVMClusterUtil.MasterThread mt = JVMClusterUtil.createMasterThread(c, | ||
| (Class<? extends HMaster>) conf.getClass(HConstants.MASTER_IMPL, this.masterClass), index); | ||
| (Class<? extends HMaster>) c.getClass(HConstants.MASTER_IMPL, this.masterClass), index); | ||
| this.masterThreads.add(mt); | ||
| // Refresh the master address config. | ||
| List<String> masterHostPorts = new ArrayList<>(); | ||
| getMasters().forEach(masterThread -> | ||
| masterHostPorts.add(masterThread.getMaster().getServerName().getAddress().toString())); | ||
| conf.set(HConstants.MASTER_ADDRS_KEY, String.join(",", masterHostPorts)); | ||
| return mt; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.