You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jo...@apache.org on 2018/07/26 18:51:01 UTC
[ambari] branch branch-feature-AMBARI-14714 updated: [AMBARI-24363]
- Allow Ambari to Bypass Hashing of Stack Resources (#1898)
This is an automated email from the ASF dual-hosted git repository.
jonathanhurley pushed a commit to branch branch-feature-AMBARI-14714
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/branch-feature-AMBARI-14714 by this push:
new 0a6c9db [AMBARI-24363] - Allow Ambari to Bypass Hashing of Stack Resources (#1898)
0a6c9db is described below
commit 0a6c9dbef118b272831474c33b4bdb7bc8340cd1
Author: Jonathan Hurley <jo...@apache.org>
AuthorDate: Thu Jul 26 14:50:58 2018 -0400
[AMBARI-24363] - Allow Ambari to Bypass Hashing of Stack Resources (#1898)
---
.../ambari/server/api/services/AmbariMetaInfo.java | 3 +-
.../ambari/server/configuration/Configuration.java | 23 ++++++++++-
.../apache/ambari/server/stack/StackManager.java | 46 +++++++++++-----------
3 files changed, 47 insertions(+), 25 deletions(-)
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
index b984bee..f55d7ff 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
@@ -302,7 +302,8 @@ public class AmbariMetaInfo {
readServerVersion();
stackManager = stackManagerFactory.create(resourcesRoot, stackRoot, commonServicesRoot, extensionsRoot,
- osFamily, false /* validate = false */, true /* refreshArchives = true */);
+ osFamily, false /* validate = false */,
+ conf.isStackResourceHashAndArchiveGenerationEnabled());
mpackManager = mpackManagerFactory.create(mpacksV2Staging, stackRoot);
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
index d74477d..583c17e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
@@ -2601,6 +2601,16 @@ public class Configuration {
public static final ConfigurationProperty<Integer> DEFAULT_MAX_DEGREE_OF_PARALLELISM_FOR_UPGRADES = new ConfigurationProperty<>(
"stack.upgrade.default.parallelism", 100);
+ /**
+ * If enabled, Ambari will generate hash files for stack resource directories
+ * and generate compressed archives of those directories to send to agents.
+ * This should normally always be {@code true} except in a development
+ * environment.
+ */
+ @Markdown(description = "Enables whether Ambari should generate .hash files for stack resource directories. This should always be enabled unless working in a development environment.")
+ public static final ConfigurationProperty<Boolean> STACK_RESOURCE_HASH_ENABLED = new ConfigurationProperty<>(
+ "server.stack.resources.hash.enabled", true);
+
private static final Logger LOG = LoggerFactory.getLogger(
Configuration.class);
@@ -3015,7 +3025,7 @@ public class Configuration {
writeConfigFile(existingProperties, false);
// reloading properties
- this.properties = readConfigFile();
+ properties = readConfigFile();
}
/**
@@ -6031,4 +6041,15 @@ public class Configuration {
public int getAlertServiceCorePoolSize() {
return Integer.parseInt(getProperty(SERVER_SIDE_ALERTS_CORE_POOL_SIZE));
}
+
+ /**
+ * Gets whether Ambari should generate {@code .hash} and {@code archive.zip}
+ * files for stack resources.
+ *
+ * @return {@code true} to generate the files, {@code false} otherwise.
+ */
+ public boolean isStackResourceHashAndArchiveGenerationEnabled() {
+ return Boolean.parseBoolean(getProperty(STACK_RESOURCE_HASH_ENABLED));
+ }
+
}
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/stack/StackManager.java b/ambari-server/src/main/java/org/apache/ambari/server/stack/StackManager.java
index ec3c0bc..62409d5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/stack/StackManager.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/stack/StackManager.java
@@ -119,6 +119,8 @@ public class StackManager {
private AmbariManagementHelper helper;
+ private final boolean refreshArchives;
+
/**
* Constructor. Initialize stack manager.
*
@@ -165,6 +167,8 @@ public class StackManager {
LOG.info("Initializing the stack manager...");
+ this.refreshArchives = refreshArchives;
+
if (validate) {
validateStackDirectory(stackRoot);
validateCommonServicesDirectory(commonServicesRoot);
@@ -200,39 +204,35 @@ public class StackManager {
fullyResolveExtensions(stackModules, commonServiceModules, extensionModules);
fullyResolveStacks(stackModules, commonServiceModules, extensionModules);
- if(refreshArchives) {
- updateArchives(resourcesRoot, stackRoot, stackModules, commonServiceModules, extensionModules);
- }
+ updateArchives(resourcesRoot, stackRoot, stackModules, commonServiceModules, extensionModules);
populateDB(stackDao, extensionDao);
}
- /***
- * Constructor. Initialize StackManager for merging service definitions and creating management packs
+ /**
+ * Generates {@code .hash} and {@code archive.zip} files by invoking the
+ * {@link ResourceFilesKeeperHelper}. If
+ * {@link Configuration#isStackResourceHashAndArchiveGenerationEnabled()} is
+ * disabled, then this method will do no work.
+ *
+ * @param resourcesRoot
* @param stackRoot
- * @param commonServicesRoot
+ * @param stackModules
+ * @param commonServiceModules
+ * @param extensionModules
+ * @throws AmbariException
+ *
+ * @see {@link Configuration#isStackResourceHashAndArchiveGenerationEnabled()}
*/
- public StackManager(File stackRoot, File commonServicesRoot, boolean validate) throws AmbariException{
- LOG.info("Initializing the stack manager...");
-
- if (validate) {
- validateStackDirectory(stackRoot);
- validateCommonServicesDirectory(commonServicesRoot);
- }
-
- stackMap = new TreeMap<>();
-
- parseDirectories(stackRoot, commonServicesRoot, null);
-
- fullyResolveCommonServices(stackModules, commonServiceModules, extensionModules);
- fullyResolveExtensions(stackModules, commonServiceModules, extensionModules);
- fullyResolveStacks(stackModules, commonServiceModules, extensionModules);
- }
-
protected void updateArchives(
File resourcesRoot, File stackRoot, Map<String, StackModule> stackModules, Map<String, ServiceModule> commonServiceModules,
Map<String, ExtensionModule> extensionModules ) throws AmbariException {
+ if (!refreshArchives) {
+ LOG.info("Refreshing archives is disabled, no hash or archive generation will be done.");
+ return;
+ }
+
LOG.info("Refreshing archives ...");
LOG.debug("Refreshing archives for stacks");