pvary commented on a change in pull request #698: HIVE-21912: Implement
DisablingDaemonStatisticsHandler
URL: https://github.com/apache/hive/pull/698#discussion_r300313040
##########
File path:
llap-client/src/java/org/apache/hadoop/hive/llap/registry/impl/LlapZookeeperRegistryImpl.java
##########
@@ -416,4 +423,65 @@ protected String getZkPathUser(Configuration conf) {
// rather than relying on RegistryUtils.currentUser().
return HiveConf.getVar(conf, ConfVars.LLAP_ZK_REGISTRY_USER,
RegistryUtils.currentUser());
}
+
+ /**
+ * Locks the Llap Cluster for configuration change by setting the next
possible configuration
+ * change time. Until this time is reached the configuration should not be
changed.
+ * @param nextMinConfigChangeTime The next time when the cluster can be
reconfigured
+ * @return The result of the change (success if the lock is succeeded, and
the next possible
+ * configuration change time
+ */
+ public ConfigChangeLockResult lockForConfigChange(long
nextMinConfigChangeTime) {
+ try {
+ if (nextChangeTime == null) {
+ // Create the node with the
/llap-sasl/hiveuser/hostname/config-change/next-change path without retry
+ nextChangeTime = new DistributedAtomicLong(zooKeeperClient,
+ String.join("/", workersPath.substring(0,
workersPath.lastIndexOf('/')), CONFIG_CHANGE_PATH,
+ CONFIG_CHANGE_NODE), (i, j, sleeper) -> false);
+ nextChangeTime.initialize(0L);
+ }
+ AtomicValue<Long> current = nextChangeTime.get();
+ if (!current.succeeded()) {
+ LOG.debug("Can not get the current configuration lock time");
+ return new ConfigChangeLockResult(false, -1L);
+ }
+ if (current.postValue() >= nextMinConfigChangeTime) {
+ LOG.debug("Can not set {}. Current value is {}.",
nextMinConfigChangeTime, current.postValue());
+ return new ConfigChangeLockResult(false, current.postValue());
+ }
+ current = nextChangeTime.compareAndSet(current.postValue(),
nextMinConfigChangeTime);
+ if (!current.succeeded()) {
+ LOG.debug("Can not set {}. Current value is changed to {}.",
nextMinConfigChangeTime, current.postValue());
+ return new ConfigChangeLockResult(false, current.postValue());
+ }
+ return new ConfigChangeLockResult(true, current.postValue());
+ } catch (Throwable t) {
+ LOG.info("Can not reserve configuration change lock", t);
+ return new ConfigChangeLockResult(false, -1L);
+ }
+ }
+
+ public static class ConfigChangeLockResult {
+ boolean success;
Review comment:
Yeah. Forget to finish my refactor.
Thanks!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]