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 2016/09/09 21:22:56 UTC
[08/10] ambari git commit: AMBARI-18126 - Refactor Configuration To
Allow For Generation Of Documentation (jonathanhurley)
http://git-wip-us.apache.org/repos/asf/ambari/blob/5630b5e7/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
index a6d8d6a..46f6ce5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
@@ -19,16 +19,20 @@
package org.apache.ambari.server.controller;
-import com.google.common.util.concurrent.ServiceManager;
-import com.google.gson.Gson;
-import com.google.inject.Guice;
-import com.google.inject.Inject;
-import com.google.inject.Injector;
-import com.google.inject.Scopes;
-import com.google.inject.Singleton;
-import com.google.inject.name.Named;
-import com.google.inject.persist.Transactional;
-import com.sun.jersey.spi.container.servlet.ServletContainer;
+import java.io.File;
+import java.io.IOException;
+import java.net.Authenticator;
+import java.net.BindException;
+import java.net.PasswordAuthentication;
+import java.net.URL;
+import java.util.EnumSet;
+import java.util.Enumeration;
+import java.util.Map;
+import java.util.logging.LogManager;
+
+import javax.crypto.BadPaddingException;
+import javax.servlet.DispatcherType;
+
import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.StateRecoveryManager;
import org.apache.ambari.server.StaticallyInject;
@@ -143,19 +147,16 @@ import org.springframework.web.context.request.RequestContextListener;
import org.springframework.web.context.support.GenericWebApplicationContext;
import org.springframework.web.filter.DelegatingFilterProxy;
-import javax.crypto.BadPaddingException;
-import javax.servlet.DispatcherType;
-import java.io.File;
-import java.io.IOException;
-import java.net.Authenticator;
-import java.net.BindException;
-import java.net.PasswordAuthentication;
-import java.net.URL;
-import java.util.EnumSet;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.logging.LogManager;
+import com.google.common.util.concurrent.ServiceManager;
+import com.google.gson.Gson;
+import com.google.inject.Guice;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import com.google.inject.Scopes;
+import com.google.inject.Singleton;
+import com.google.inject.name.Named;
+import com.google.inject.persist.Transactional;
+import com.sun.jersey.spi.container.servlet.ServletContainer;
@Singleton
public class AmbariServer {
@@ -414,21 +415,21 @@ public class AmbariServer {
SslSelectChannelConnector sslConnectorTwoWay = new SslSelectChannelConnector(contextFactoryTwoWay);
sslConnectorTwoWay.setPort(configs.getTwoWayAuthPort());
- String keystore = configsMap.get(Configuration.SRVR_KSTR_DIR_KEY) + File.separator
- + configsMap.get(Configuration.KSTR_NAME_KEY);
+ String keystore = configsMap.get(Configuration.SRVR_KSTR_DIR.getKey()) + File.separator
+ + configsMap.get(Configuration.KSTR_NAME.getKey());
- String truststore = configsMap.get(Configuration.SRVR_KSTR_DIR_KEY) + File.separator
- + configsMap.get(Configuration.TSTR_NAME_KEY);
+ String truststore = configsMap.get(Configuration.SRVR_KSTR_DIR.getKey()) + File.separator
+ + configsMap.get(Configuration.TSTR_NAME.getKey());
- String srvrCrtPass = configsMap.get(Configuration.SRVR_CRT_PASS_KEY);
+ String srvrCrtPass = configsMap.get(Configuration.SRVR_CRT_PASS.getKey());
sslConnectorTwoWay.setKeystore(keystore);
sslConnectorTwoWay.setTruststore(truststore);
sslConnectorTwoWay.setPassword(srvrCrtPass);
sslConnectorTwoWay.setKeyPassword(srvrCrtPass);
sslConnectorTwoWay.setTrustPassword(srvrCrtPass);
- sslConnectorTwoWay.setKeystoreType(configsMap.get(Configuration.KSTR_TYPE_KEY));
- sslConnectorTwoWay.setTruststoreType(configsMap.get(Configuration.TSTR_TYPE_KEY));
+ sslConnectorTwoWay.setKeystoreType(configsMap.get(Configuration.KSTR_TYPE.getKey()));
+ sslConnectorTwoWay.setTruststoreType(configsMap.get(Configuration.TSTR_TYPE.getKey()));
sslConnectorTwoWay.setNeedClientAuth(configs.getTwoWaySsl());
sslConnectorTwoWay.setRequestHeaderSize(configs.getHttpRequestHeaderSize());
sslConnectorTwoWay.setResponseHeaderSize(configs.getHttpResponseHeaderSize());
@@ -440,8 +441,8 @@ public class AmbariServer {
contextFactoryOneWay.setKeyStorePassword(srvrCrtPass);
contextFactoryOneWay.setKeyManagerPassword(srvrCrtPass);
contextFactoryOneWay.setTrustStorePassword(srvrCrtPass);
- contextFactoryOneWay.setKeyStoreType(configsMap.get(Configuration.KSTR_TYPE_KEY));
- contextFactoryOneWay.setTrustStoreType(configsMap.get(Configuration.TSTR_TYPE_KEY));
+ contextFactoryOneWay.setKeyStoreType(configsMap.get(Configuration.KSTR_TYPE.getKey()));
+ contextFactoryOneWay.setTrustStoreType(configsMap.get(Configuration.TSTR_TYPE.getKey()));
contextFactoryOneWay.setNeedClientAuth(false);
disableInsecureProtocols(contextFactoryOneWay);
@@ -536,13 +537,13 @@ public class AmbariServer {
SelectChannelConnector apiConnector;
if (configs.getApiSSLAuthentication()) {
- String httpsKeystore = configsMap.get(Configuration.CLIENT_API_SSL_KSTR_DIR_NAME_KEY) +
- File.separator + configsMap.get(Configuration.CLIENT_API_SSL_KSTR_NAME_KEY);
- String httpsTruststore = configsMap.get(Configuration.CLIENT_API_SSL_KSTR_DIR_NAME_KEY) +
- File.separator + configsMap.get(Configuration.CLIENT_API_SSL_TSTR_NAME_KEY);
+ String httpsKeystore = configsMap.get(Configuration.CLIENT_API_SSL_KSTR_DIR_NAME.getKey()) +
+ File.separator + configsMap.get(Configuration.CLIENT_API_SSL_KSTR_NAME.getKey());
+ String httpsTruststore = configsMap.get(Configuration.CLIENT_API_SSL_KSTR_DIR_NAME.getKey()) +
+ File.separator + configsMap.get(Configuration.CLIENT_API_SSL_TSTR_NAME.getKey());
LOG.info("API SSL Authentication is turned on. Keystore - " + httpsKeystore);
- String httpsCrtPass = configsMap.get(Configuration.CLIENT_API_SSL_CRT_PASS_KEY);
+ String httpsCrtPass = configsMap.get(Configuration.CLIENT_API_SSL_CRT_PASS.getKey());
SslContextFactory contextFactoryApi = new SslContextFactory();
disableInsecureProtocols(contextFactoryApi);
@@ -553,8 +554,8 @@ public class AmbariServer {
sapiConnector.setPassword(httpsCrtPass);
sapiConnector.setKeyPassword(httpsCrtPass);
sapiConnector.setTrustPassword(httpsCrtPass);
- sapiConnector.setKeystoreType(configsMap.get(Configuration.CLIENT_API_SSL_KSTR_TYPE_KEY));
- sapiConnector.setTruststoreType(configsMap.get(Configuration.CLIENT_API_SSL_KSTR_TYPE_KEY));
+ sapiConnector.setKeystoreType(configsMap.get(Configuration.CLIENT_API_SSL_KSTR_TYPE.getKey()));
+ sapiConnector.setTruststoreType(configsMap.get(Configuration.CLIENT_API_SSL_KSTR_TYPE.getKey()));
sapiConnector.setMaxIdleTime(configs.getConnectionMaxIdleTime());
apiConnector = sapiConnector;
} else {
@@ -576,7 +577,7 @@ public class AmbariServer {
String osType = getServerOsType();
if (osType == null || osType.isEmpty()) {
- throw new RuntimeException(Configuration.OS_VERSION_KEY + " is not "
+ throw new RuntimeException(Configuration.OS_VERSION.getKey() + " is not "
+ " set in the ambari.properties file");
}
@@ -799,7 +800,7 @@ public class AmbariServer {
users.createUser("user", "user");
MetainfoEntity schemaVersion = new MetainfoEntity();
- schemaVersion.setMetainfoName(Configuration.SERVER_VERSION_KEY);
+ schemaVersion.setMetainfoName(Configuration.SERVER_VERSION.getKey());
schemaVersion.setMetainfoValue(VersionUtils.getVersionSubstring(ambariMetaInfo.getServerVersion()));
metainfoDAO.create(schemaVersion);
http://git-wip-us.apache.org/repos/asf/ambari/blob/5630b5e7/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
index 2bd7eff..256f0d1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
@@ -18,6 +18,21 @@
package org.apache.ambari.server.controller;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.CREATE_JDBC_DDL_FILE;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.CREATE_ONLY;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.CREATE_OR_EXTEND;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.DDL_BOTH_GENERATION;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.DDL_GENERATION;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.DDL_GENERATION_MODE;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.DROP_AND_CREATE;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.DROP_JDBC_DDL_FILE;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_DRIVER;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_PASSWORD;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_URL;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_USER;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.NON_JTA_DATASOURCE;
+import static org.eclipse.persistence.config.PersistenceUnitProperties.THROW_EXCEPTIONS;
+
import java.beans.PropertyVetoException;
import java.lang.annotation.Annotation;
import java.security.SecureRandom;
@@ -142,21 +157,6 @@ import com.google.inject.persist.PersistModule;
import com.google.inject.persist.jpa.AmbariJpaPersistModule;
import com.mchange.v2.c3p0.ComboPooledDataSource;
-import static org.eclipse.persistence.config.PersistenceUnitProperties.CREATE_JDBC_DDL_FILE;
-import static org.eclipse.persistence.config.PersistenceUnitProperties.CREATE_ONLY;
-import static org.eclipse.persistence.config.PersistenceUnitProperties.CREATE_OR_EXTEND;
-import static org.eclipse.persistence.config.PersistenceUnitProperties.DDL_BOTH_GENERATION;
-import static org.eclipse.persistence.config.PersistenceUnitProperties.DDL_GENERATION;
-import static org.eclipse.persistence.config.PersistenceUnitProperties.DDL_GENERATION_MODE;
-import static org.eclipse.persistence.config.PersistenceUnitProperties.DROP_AND_CREATE;
-import static org.eclipse.persistence.config.PersistenceUnitProperties.DROP_JDBC_DDL_FILE;
-import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_DRIVER;
-import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_PASSWORD;
-import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_URL;
-import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_USER;
-import static org.eclipse.persistence.config.PersistenceUnitProperties.NON_JTA_DATASOURCE;
-import static org.eclipse.persistence.config.PersistenceUnitProperties.THROW_EXCEPTIONS;
-
/**
* Used for injection purposes.
*/
@@ -211,7 +211,7 @@ public class ControllerModule extends AbstractModule {
switch (configuration.getPersistenceType()) {
case IN_MEMORY:
properties.setProperty(JDBC_URL, Configuration.JDBC_IN_MEMORY_URL);
- properties.setProperty(JDBC_DRIVER, Configuration.JDBC_IN_MEMROY_DRIVER);
+ properties.setProperty(JDBC_DRIVER, Configuration.JDBC_IN_MEMORY_DRIVER);
properties.setProperty(DDL_GENERATION, DROP_AND_CREATE);
properties.setProperty(THROW_EXCEPTIONS, "true");
case REMOTE:
@@ -220,7 +220,7 @@ public class ControllerModule extends AbstractModule {
break;
case LOCAL:
properties.setProperty(JDBC_URL, configuration.getLocalDatabaseUrl());
- properties.setProperty(JDBC_DRIVER, Configuration.JDBC_LOCAL_DRIVER);
+ properties.setProperty(JDBC_DRIVER, Configuration.SERVER_JDBC_DRIVER.getDefaultValue());
break;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/5630b5e7/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java
index 70b991a..f5d646a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java
@@ -1999,7 +1999,7 @@ public class KerberosHelperImpl implements KerberosHelper {
* @throws AmbariException if a new temporary directory cannot be created
*/
private File createTemporaryDirectory() throws AmbariException {
- String tempDirectoryPath = configuration.getProperty(Configuration.SERVER_TMP_DIR_KEY);
+ String tempDirectoryPath = configuration.getProperty(Configuration.SERVER_TMP_DIR.getKey());
if ((tempDirectoryPath == null) || tempDirectoryPath.isEmpty()) {
tempDirectoryPath = System.getProperty("java.io.tmpdir");
http://git-wip-us.apache.org/repos/asf/ambari/blob/5630b5e7/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProvider.java
index c390c86..020a454 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProvider.java
@@ -175,8 +175,8 @@ public class ClientConfigResourceProvider extends AbstractControllerResourceProv
Configuration configs = new Configuration();
Map<String, String> configMap = configs.getConfigsMap();
- String TMP_PATH = configMap.get(Configuration.SERVER_TMP_DIR_KEY);
- String pythonCmd = configMap.get(Configuration.AMBARI_PYTHON_WRAP_KEY);
+ String TMP_PATH = configMap.get(Configuration.SERVER_TMP_DIR.getKey());
+ String pythonCmd = configMap.get(Configuration.AMBARI_PYTHON_WRAP.getKey());
AmbariManagementController managementController = getManagementController();
ConfigHelper configHelper = managementController.getConfigHelper();
Cluster cluster = null;
@@ -341,7 +341,7 @@ public class ClientConfigResourceProvider extends AbstractControllerResourceProv
String userList = gson.toJson(userSet);
hostLevelParams.put(USER_LIST, userList);
- Set<String> groupSet = configHelper.getPropertyValuesWithPropertyType(stackId, PropertyType.GROUP, cluster, desiredClusterConfigs);
+ Set<String> groupSet = configHelper.getPropertyValuesWithPropertyType(stackId, PropertyType.GROUP, cluster, desiredClusterConfigs);
String groupList = gson.toJson(groupSet);
hostLevelParams.put(GROUP_LIST, groupList);
http://git-wip-us.apache.org/repos/asf/ambari/blob/5630b5e7/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/DatabaseChecker.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/DatabaseChecker.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/DatabaseChecker.java
index d35fc1a..722e6f1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/DatabaseChecker.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/DatabaseChecker.java
@@ -269,7 +269,7 @@ public class DatabaseChecker {
metainfoDAO = injector.getInstance(MetainfoDAO.class);
}
- MetainfoEntity schemaVersionEntity = metainfoDAO.findByKey(Configuration.SERVER_VERSION_KEY);
+ MetainfoEntity schemaVersionEntity = metainfoDAO.findByKey(Configuration.SERVER_VERSION.getKey());
String schemaVersion = null;
if (schemaVersionEntity != null) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/5630b5e7/ambari-server/src/main/java/org/apache/ambari/server/resources/ResourceManager.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/resources/ResourceManager.java b/ambari-server/src/main/java/org/apache/ambari/server/resources/ResourceManager.java
index 9f4e708..950d1e1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/resources/ResourceManager.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/resources/ResourceManager.java
@@ -32,7 +32,7 @@ import com.google.inject.Singleton;
@Singleton
public class ResourceManager {
private static Log LOG = LogFactory.getLog(ResourceManager.class);
-
+
@Inject Configuration configs;
/**
* Returns resource file.
@@ -40,7 +40,7 @@ public class ResourceManager {
* @return resource file
*/
public File getResource(String resourcePath) {
- String resDir = configs.getConfigsMap().get(Configuration.RESOURCES_DIR_KEY);
+ String resDir = configs.getConfigsMap().get(Configuration.RESOURCES_DIR.getKey());
String resourcePathIndep = resourcePath.replace("/", File.separator);
File resourceFile = new File(resDir + File.separator + resourcePathIndep);
if (LOG.isDebugEnabled()) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/5630b5e7/ambari-server/src/main/java/org/apache/ambari/server/security/AbstractSecurityHeaderFilter.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/security/AbstractSecurityHeaderFilter.java b/ambari-server/src/main/java/org/apache/ambari/server/security/AbstractSecurityHeaderFilter.java
index 10aa6ea..05c9ecb 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/security/AbstractSecurityHeaderFilter.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/security/AbstractSecurityHeaderFilter.java
@@ -78,15 +78,15 @@ public abstract class AbstractSecurityHeaderFilter implements Filter {
/**
* The value for the Strict-Transport-Security HTTP response header.
*/
- private String strictTransportSecurity = Configuration.HTTP_STRICT_TRANSPORT_HEADER_VALUE_DEFAULT;
+ private String strictTransportSecurity = Configuration.HTTP_STRICT_TRANSPORT_HEADER_VALUE.getDefaultValue();
/**
* The value for the X-Frame-Options HTTP response header.
*/
- private String xFrameOptionsHeader = Configuration.HTTP_X_FRAME_OPTIONS_HEADER_VALUE_DEFAULT;
+ private String xFrameOptionsHeader = Configuration.HTTP_X_FRAME_OPTIONS_HEADER_VALUE.getDefaultValue();
/**
* The value for the X-XSS-Protection HTTP response header.
*/
- private String xXSSProtectionHeader = Configuration.HTTP_X_XSS_PROTECTION_HEADER_VALUE_DEFAULT;
+ private String xXSSProtectionHeader = Configuration.HTTP_X_XSS_PROTECTION_HEADER_VALUE.getDefaultValue();
@Override
public void init(FilterConfig filterConfig) throws ServletException {
http://git-wip-us.apache.org/repos/asf/ambari/blob/5630b5e7/ambari-server/src/main/java/org/apache/ambari/server/security/CertificateManager.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/security/CertificateManager.java b/ambari-server/src/main/java/org/apache/ambari/server/security/CertificateManager.java
index 9f70dc0..8d54acb 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/security/CertificateManager.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/security/CertificateManager.java
@@ -17,8 +17,14 @@
*/
package org.apache.ambari.server.security;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.nio.charset.Charset;
+import java.text.MessageFormat;
+import java.util.Map;
+
import org.apache.ambari.server.configuration.Configuration;
import org.apache.ambari.server.utils.HostUtils;
import org.apache.ambari.server.utils.ShellCommandUtil;
@@ -27,13 +33,8 @@ import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.nio.charset.Charset;
-import java.text.MessageFormat;
-import java.util.Map;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
/**
* Ambari security.
@@ -82,8 +83,8 @@ public class CertificateManager {
private boolean isCertExists() {
Map<String, String> configsMap = configs.getConfigsMap();
- String srvrKstrDir = configsMap.get(Configuration.SRVR_KSTR_DIR_KEY);
- String srvrCrtName = configsMap.get(Configuration.SRVR_CRT_NAME_KEY);
+ String srvrKstrDir = configsMap.get(Configuration.SRVR_KSTR_DIR.getKey());
+ String srvrCrtName = configsMap.get(Configuration.SRVR_CRT_NAME.getKey());
File certFile = new File(srvrKstrDir + File.separator + srvrCrtName);
LOG.debug("srvrKstrDir = " + srvrKstrDir);
LOG.debug("srvrCrtName = " + srvrCrtName);
@@ -138,12 +139,12 @@ public class CertificateManager {
LOG.info("Generation of server certificate");
Map<String, String> configsMap = configs.getConfigsMap();
- String srvrKstrDir = configsMap.get(Configuration.SRVR_KSTR_DIR_KEY);
- String srvrCrtName = configsMap.get(Configuration.SRVR_CRT_NAME_KEY);
- String srvrCsrName = configsMap.get(Configuration.SRVR_CSR_NAME_KEY);;
- String srvrKeyName = configsMap.get(Configuration.SRVR_KEY_NAME_KEY);
- String kstrName = configsMap.get(Configuration.KSTR_NAME_KEY);
- String srvrCrtPass = configsMap.get(Configuration.SRVR_CRT_PASS_KEY);
+ String srvrKstrDir = configsMap.get(Configuration.SRVR_KSTR_DIR.getKey());
+ String srvrCrtName = configsMap.get(Configuration.SRVR_CRT_NAME.getKey());
+ String srvrCsrName = configsMap.get(Configuration.SRVR_CSR_NAME.getKey());;
+ String srvrKeyName = configsMap.get(Configuration.SRVR_KEY_NAME.getKey());
+ String kstrName = configsMap.get(Configuration.KSTR_NAME.getKey());
+ String srvrCrtPass = configsMap.get(Configuration.SRVR_CRT_PASS.getKey());
Object[] scriptArgs = {srvrCrtPass, srvrKstrDir, srvrKeyName,
srvrCrtName, kstrName, srvrCsrName};
@@ -168,8 +169,8 @@ public class CertificateManager {
*/
public String getServerCert() {
Map<String, String> configsMap = configs.getConfigsMap();
- File certFile = new File(configsMap.get(Configuration.SRVR_KSTR_DIR_KEY) +
- File.separator + configsMap.get(Configuration.SRVR_CRT_NAME_KEY));
+ File certFile = new File(configsMap.get(Configuration.SRVR_KSTR_DIR.getKey()) +
+ File.separator + configsMap.get(Configuration.SRVR_CRT_NAME.getKey()));
String srvrCrtContent = null;
try {
srvrCrtContent = FileUtils.readFileToString(certFile);
@@ -221,7 +222,7 @@ public class CertificateManager {
LOG.info("Verifying passphrase");
String passphraseSrvr = configs.getConfigsMap().get(Configuration.
- PASSPHRASE_KEY).trim();
+ PASSPHRASE.getKey()).trim();
if (!passphraseSrvr.equals(passphraseAgent.trim())) {
LOG.warn("Incorrect passphrase from the agent");
@@ -231,10 +232,10 @@ public class CertificateManager {
}
Map<String, String> configsMap = configs.getConfigsMap();
- String srvrKstrDir = configsMap.get(Configuration.SRVR_KSTR_DIR_KEY);
- String srvrCrtPass = configsMap.get(Configuration.SRVR_CRT_PASS_KEY);
- String srvrCrtName = configsMap.get(Configuration.SRVR_CRT_NAME_KEY);
- String srvrKeyName = configsMap.get(Configuration.SRVR_KEY_NAME_KEY);
+ String srvrKstrDir = configsMap.get(Configuration.SRVR_KSTR_DIR.getKey());
+ String srvrCrtPass = configsMap.get(Configuration.SRVR_CRT_PASS.getKey());
+ String srvrCrtName = configsMap.get(Configuration.SRVR_CRT_NAME.getKey());
+ String srvrKeyName = configsMap.get(Configuration.SRVR_KEY_NAME.getKey());
String agentCrtReqName = agentHostname + ".csr";
String agentCrtName = agentHostname + ".crt";
http://git-wip-us.apache.org/repos/asf/ambari/blob/5630b5e7/ambari-server/src/main/java/org/apache/ambari/server/security/encryption/MasterKeyServiceImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/security/encryption/MasterKeyServiceImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/security/encryption/MasterKeyServiceImpl.java
index 6c52cf4..1dd0f85 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/security/encryption/MasterKeyServiceImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/security/encryption/MasterKeyServiceImpl.java
@@ -18,15 +18,6 @@
package org.apache.ambari.server.security.encryption;
-import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.configuration.Configuration;
-import org.apache.ambari.server.utils.AmbariPath;
-import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.net.ntp.TimeStamp;
-
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
@@ -38,6 +29,15 @@ import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.configuration.Configuration;
+import org.apache.ambari.server.utils.AmbariPath;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.net.ntp.TimeStamp;
+
public class MasterKeyServiceImpl implements MasterKeyService {
private static final Log LOG = LogFactory.getLog(MasterKeyServiceImpl.class);
private static final String MASTER_PASSPHRASE = "masterpassphrase";
@@ -78,7 +78,7 @@ public class MasterKeyServiceImpl implements MasterKeyService {
*/
public MasterKeyServiceImpl(String masterKey) {
if (masterKey != null) {
- this.master = masterKey.toCharArray();
+ master = masterKey.toCharArray();
} else {
throw new IllegalArgumentException("Master key cannot be null");
}
@@ -90,17 +90,18 @@ public class MasterKeyServiceImpl implements MasterKeyService {
public MasterKeyServiceImpl() {
String key = readMasterKey();
if (key != null) {
- this.master = key.toCharArray();
+ master = key.toCharArray();
}
}
+ @Override
public boolean isMasterKeyInitialized() {
- return this.master != null;
+ return master != null;
}
@Override
public char[] getMasterSecret() {
- return this.master;
+ return master;
}
public static void main(String args[]) {
@@ -275,14 +276,14 @@ public class MasterKeyServiceImpl implements MasterKeyService {
if (envVariables != null && !envVariables.isEmpty()) {
key = envVariables.get(Configuration.MASTER_KEY_ENV_PROP);
if (key == null || key.isEmpty()) {
- String keyPath = envVariables.get(Configuration.MASTER_KEY_LOCATION);
+ String keyPath = envVariables.get(Configuration.MASTER_KEY_LOCATION.getKey());
if (keyPath != null && !keyPath.isEmpty()) {
File keyFile = new File(keyPath);
if (keyFile.exists()) {
try {
initializeFromFile(keyFile);
- if (this.master != null) {
- key = new String(this.master);
+ if (master != null) {
+ key = new String(master);
}
FileUtils.deleteQuietly(keyFile);
} catch (IOException e) {
@@ -306,7 +307,7 @@ public class MasterKeyServiceImpl implements MasterKeyService {
LOG.info("Loading from persistent master: " + tag);
String line = new String(Base64.decodeBase64(lines.get(1)));
String[] parts = line.split("::");
- this.master = new String(aes.decrypt(Base64.decodeBase64(parts[0]),
+ master = new String(aes.decrypt(Base64.decodeBase64(parts[0]),
Base64.decodeBase64(parts[1]), Base64.decodeBase64(parts[2])),
"UTF8").toCharArray();
} catch (IOException e) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/5630b5e7/ambari-server/src/main/java/org/apache/ambari/server/security/unsecured/rest/ConnectionInfo.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/security/unsecured/rest/ConnectionInfo.java b/ambari-server/src/main/java/org/apache/ambari/server/security/unsecured/rest/ConnectionInfo.java
index 6e8b2aa..a1b5a6e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/security/unsecured/rest/ConnectionInfo.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/security/unsecured/rest/ConnectionInfo.java
@@ -17,21 +17,20 @@
*/
package org.apache.ambari.server.security.unsecured.rest;
+import java.util.HashMap;
+import java.util.Map;
+
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.apache.ambari.server.configuration.Configuration;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.google.inject.Inject;
-import java.util.HashMap;
-import java.util.Map;
-
@Path("/connection_info")
public class ConnectionInfo {
@@ -43,7 +42,7 @@ public class ConnectionInfo {
@Inject
public static void init(Configuration instance){
conf = instance;
- response.put(Configuration.SRVR_TWO_WAY_SSL_KEY,String.valueOf(conf.getTwoWaySsl()));
+ response.put(Configuration.SRVR_TWO_WAY_SSL.getKey(),String.valueOf(conf.getTwoWaySsl()));
}
@GET
http://git-wip-us.apache.org/repos/asf/ambari/blob/5630b5e7/ambari-server/src/main/java/org/apache/ambari/server/state/services/RetryUpgradeActionService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/services/RetryUpgradeActionService.java b/ambari-server/src/main/java/org/apache/ambari/server/state/services/RetryUpgradeActionService.java
index 7d81cc4..72b8ab7 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/services/RetryUpgradeActionService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/services/RetryUpgradeActionService.java
@@ -17,11 +17,15 @@
*/
package org.apache.ambari.server.state.services;
-import com.google.common.util.concurrent.AbstractScheduledService;
-import com.google.inject.Inject;
-import com.google.inject.Injector;
-import com.google.inject.Provider;
-import com.google.inject.persist.Transactional;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+import java.util.concurrent.TimeUnit;
+
import org.apache.ambari.server.AmbariService;
import org.apache.ambari.server.actionmanager.HostRoleStatus;
import org.apache.ambari.server.configuration.Configuration;
@@ -34,14 +38,11 @@ import org.apache.ambari.server.state.Clusters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.TimeZone;
-import java.util.concurrent.TimeUnit;
+import com.google.common.util.concurrent.AbstractScheduledService;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import com.google.inject.Provider;
+import com.google.inject.persist.Transactional;
/**
* Monitors commands during Stack Upgrade that are in a HOLDING_* failed because they failed in order to retry them
@@ -90,10 +91,10 @@ public class RetryUpgradeActionService extends AbstractScheduledService {
public RetryUpgradeActionService() {
- this.m_fullDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ m_fullDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
TimeZone tz = TimeZone.getTimeZone("UTC");
- this.m_deltaDateFormat = new SimpleDateFormat("HH:mm:ss");
- this.m_deltaDateFormat.setTimeZone(tz);
+ m_deltaDateFormat = new SimpleDateFormat("HH:mm:ss");
+ m_deltaDateFormat.setTimeZone(tz);
}
/**
@@ -113,26 +114,26 @@ public class RetryUpgradeActionService extends AbstractScheduledService {
*/
@Override
protected void startUp() throws Exception {
- this.MAX_TIMEOUT_MINS = m_configuration.getStackUpgradeAutoRetryTimeoutMins();
- this.MAX_TIMEOUT_MS = MAX_TIMEOUT_MINS * 60000L;
+ MAX_TIMEOUT_MINS = m_configuration.getStackUpgradeAutoRetryTimeoutMins();
+ MAX_TIMEOUT_MS = MAX_TIMEOUT_MINS * 60000L;
- if (this.MAX_TIMEOUT_MINS < 1) {
+ if (MAX_TIMEOUT_MINS < 1) {
LOG.info("Will not start service {} used to auto-retry failed actions during " +
"Stack Upgrade since since the property {} is either invalid/missing or set to {}",
- this.getClass().getSimpleName(), Configuration.STACK_UPGRADE_AUTO_RETRY_TIMEOUT_MINS_KEY, MAX_TIMEOUT_MINS);
+ this.getClass().getSimpleName(), Configuration.STACK_UPGRADE_AUTO_RETRY_TIMEOUT_MINS.getKey(), MAX_TIMEOUT_MINS);
stopAsync();
}
// During Stack Upgrade, some tasks don't make since to auto-retry since they are either
// running on the server, should only be ran multiple times with human intervention,
// or are not going to succeed on repeat attempts because they involve DB queries and not necessarily down hosts.
- this.CUSTOM_COMMAND_NAMES_TO_IGNORE = m_configuration.getStackUpgradeAutoRetryCustomCommandNamesToIgnore();
- this.COMMAND_DETAILS_TO_IGNORE = m_configuration.getStackUpgradeAutoRetryCommandDetailsToIgnore();
+ CUSTOM_COMMAND_NAMES_TO_IGNORE = m_configuration.getStackUpgradeAutoRetryCustomCommandNamesToIgnore();
+ COMMAND_DETAILS_TO_IGNORE = m_configuration.getStackUpgradeAutoRetryCommandDetailsToIgnore();
}
public void setMaxTimeout(int mins) {
- this.MAX_TIMEOUT_MINS = mins;
- this.MAX_TIMEOUT_MS = MAX_TIMEOUT_MINS * 60000L;
+ MAX_TIMEOUT_MINS = mins;
+ MAX_TIMEOUT_MS = MAX_TIMEOUT_MINS * 60000L;
}
/**
@@ -212,8 +213,8 @@ public class RetryUpgradeActionService extends AbstractScheduledService {
Long deltaMS = retryTimeWindow - now;
if (deltaMS > 0) {
- String originalStartTimeString = this.m_fullDateFormat.format(new Date(hrc.getOriginalStartTime()));
- String deltaString = this.m_deltaDateFormat.format(new Date(deltaMS));
+ String originalStartTimeString = m_fullDateFormat.format(new Date(hrc.getOriginalStartTime()));
+ String deltaString = m_deltaDateFormat.format(new Date(deltaMS));
LOG.info("Retrying task with id: {}, attempts: {}, original start time: {}, time til timeout: {}",
hrc.getTaskId(), hrc.getAttemptCount(), originalStartTimeString, deltaString);
retryHostRoleCommand(hrc);
@@ -233,14 +234,14 @@ public class RetryUpgradeActionService extends AbstractScheduledService {
// Important not to retry some steps during RU/EU like "Finalize Upgrade Pre-Check", "Execute HDFS Finalize", and "Save Cluster State".
// These elements are expected to be in lowercase already
if (null != hrc.getCustomCommandName()) {
- for (String s : this.CUSTOM_COMMAND_NAMES_TO_IGNORE) {
+ for (String s : CUSTOM_COMMAND_NAMES_TO_IGNORE) {
if (hrc.getCustomCommandName().toLowerCase().contains(s)){
return false;
}
}
}
if (null != hrc.getCommandDetail()) {
- for (String s : this.COMMAND_DETAILS_TO_IGNORE) {
+ for (String s : COMMAND_DETAILS_TO_IGNORE) {
if (hrc.getCommandDetail().toLowerCase().contains(s)) {
return false;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/5630b5e7/ambari-server/src/main/java/org/apache/ambari/server/state/stack/OsFamily.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/OsFamily.java b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/OsFamily.java
index 599696a..1300172 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/OsFamily.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/OsFamily.java
@@ -71,7 +71,7 @@ public class OsFamily {
* @param properties list of properties
*/
public OsFamily(Properties properties){
- init(properties.getProperty(Configuration.SHARED_RESOURCES_DIR_KEY));
+ init(properties.getProperty(Configuration.SHARED_RESOURCES_DIR.getKey()));
}
private void init(String SharedResourcesPath){
@@ -127,7 +127,9 @@ public class OsFamily {
JsonOsFamilyEntry fam = osMap.get(family);
if (fam.getDistro().contains(pos.get(OS_DISTRO)) && fam.getVersions().contains(pos.get(OS_VERSION))){
Set<String> data=new HashSet<String>();
- for (String item: fam.getDistro()) data.add(item + pos.get(OS_VERSION));
+ for (String item: fam.getDistro()) {
+ data.add(item + pos.get(OS_VERSION));
+ }
return Collections.unmodifiableSet(data);
}
}
@@ -176,7 +178,9 @@ public class OsFamily {
JsonOsFamilyEntry fam = osMap.get(family);
for (String version: fam.getVersions()){
Set<String> data=new HashSet<String>();
- for (String item: fam.getDistro()) data.add(item + version);
+ for (String item: fam.getDistro()) {
+ data.add(item + version);
+ }
r.addAll(data);
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/5630b5e7/ambari-server/src/main/java/org/apache/ambari/server/view/ViewURLStreamProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/view/ViewURLStreamProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/view/ViewURLStreamProvider.java
index 0e50f04..24d3527 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/view/ViewURLStreamProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/view/ViewURLStreamProvider.java
@@ -18,17 +18,6 @@
package org.apache.ambari.server.view;
-import org.apache.ambari.server.configuration.Configuration;
-import org.apache.ambari.server.controller.internal.URLStreamProvider;
-import org.apache.ambari.server.proxy.ProxyService;
-import org.apache.ambari.view.URLConnectionProvider;
-import org.apache.ambari.view.ViewContext;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.client.utils.URIBuilder;
-
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
@@ -41,6 +30,17 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import org.apache.ambari.server.configuration.Configuration;
+import org.apache.ambari.server.controller.internal.URLStreamProvider;
+import org.apache.ambari.server.proxy.ProxyService;
+import org.apache.ambari.view.URLConnectionProvider;
+import org.apache.ambari.view.ViewContext;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.client.utils.URIBuilder;
+
/**
* Wrapper around an internal URL stream provider.
*/
@@ -87,12 +87,12 @@ public class ViewURLStreamProvider implements org.apache.ambari.view.URLStreamPr
* @return
*/
private HostPortRestrictionHandler getHostPortRestrictionHandler() {
- if (this.hostPortRestrictionHandler == null) {
+ if (hostPortRestrictionHandler == null) {
HostPortRestrictionHandler hostPortRestrictionHandlerTmp =
- new HostPortRestrictionHandler(this.viewContext.getAmbariProperty(Configuration.PROXY_ALLOWED_HOST_PORTS));
- this.hostPortRestrictionHandler = hostPortRestrictionHandlerTmp;
+ new HostPortRestrictionHandler(viewContext.getAmbariProperty(Configuration.PROXY_ALLOWED_HOST_PORTS.getKey()));
+ hostPortRestrictionHandler = hostPortRestrictionHandlerTmp;
}
- return this.hostPortRestrictionHandler;
+ return hostPortRestrictionHandler;
}
// ----- URLStreamProvider -----------------------------------------------
@@ -245,10 +245,10 @@ public class ViewURLStreamProvider implements org.apache.ambari.view.URLStreamPr
* @return
*/
protected boolean isProxyCallAllowed(String spec) {
- if (StringUtils.isNotBlank(spec) && this.getHostPortRestrictionHandler().proxyCallRestricted()) {
+ if (StringUtils.isNotBlank(spec) && getHostPortRestrictionHandler().proxyCallRestricted()) {
try {
URL url = new URL(spec);
- return this.getHostPortRestrictionHandler().allowProxy(url.getHost(),
+ return getHostPortRestrictionHandler().allowProxy(url.getHost(),
Integer.toString(url.getPort() == -1
? url.getDefaultPort()
: url.getPort()));
@@ -284,20 +284,20 @@ public class ViewURLStreamProvider implements org.apache.ambari.view.URLStreamPr
LOG.debug("Checking host " + host + " port " + port + " against allowed list.");
if (StringUtils.isNotBlank(host)) {
String hostToCompare = host.trim().toLowerCase();
- if (this.allowedHostPorts == null) {
+ if (allowedHostPorts == null) {
initializeAllowedHostPorts();
}
- if (this.isProxyCallRestricted) {
- if (this.allowedHostPorts.containsKey(hostToCompare)) {
- if (this.allowedHostPorts.get(hostToCompare).contains("*")) {
+ if (isProxyCallRestricted) {
+ if (allowedHostPorts.containsKey(hostToCompare)) {
+ if (allowedHostPorts.get(hostToCompare).contains("*")) {
return true;
}
String portToCompare = "";
if (StringUtils.isNotBlank(port)) {
portToCompare = port.trim();
}
- if (this.allowedHostPorts.get(hostToCompare).contains(portToCompare)) {
+ if (allowedHostPorts.get(hostToCompare).contains(portToCompare)) {
return true; // requested host port allowed
}
return false;
@@ -316,7 +316,7 @@ public class ViewURLStreamProvider implements org.apache.ambari.view.URLStreamPr
Map<String, HashSet<String>> allowed = new HashMap<String, HashSet<String>>();
if (StringUtils.isNotBlank(allowedHostPortsValue)) {
String allowedStr = allowedHostPortsValue.toLowerCase();
- if (!allowedStr.equals(Configuration.PROXY_ALLOWED_HOST_PORTS_DEFAULT)) {
+ if (!allowedStr.equals(Configuration.PROXY_ALLOWED_HOST_PORTS.getDefaultValue())) {
proxyCallRestricted = true;
String[] hostPorts = allowedStr.trim().split(",");
for (String hostPortStr : hostPorts) {
@@ -337,8 +337,8 @@ public class ViewURLStreamProvider implements org.apache.ambari.view.URLStreamPr
}
}
}
- this.allowedHostPorts = allowed;
- this.isProxyCallRestricted = proxyCallRestricted;
+ allowedHostPorts = allowed;
+ isProxyCallRestricted = proxyCallRestricted;
}
/**
@@ -346,10 +346,10 @@ public class ViewURLStreamProvider implements org.apache.ambari.view.URLStreamPr
* @return
*/
public Boolean proxyCallRestricted() {
- if (this.allowedHostPorts == null) {
+ if (allowedHostPorts == null) {
initializeAllowedHostPorts();
}
- return this.isProxyCallRestricted;
+ return isProxyCallRestricted;
}
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/5630b5e7/ambari-server/src/test/java/org/apache/ambari/annotations/TransactionalLockTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/annotations/TransactionalLockTest.java b/ambari-server/src/test/java/org/apache/ambari/annotations/TransactionalLockTest.java
index 2c4b445..d1f4fba 100644
--- a/ambari-server/src/test/java/org/apache/ambari/annotations/TransactionalLockTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/annotations/TransactionalLockTest.java
@@ -39,7 +39,7 @@ public class TransactionalLockTest {
@Test
public void testLockAreaEnabled() throws Exception {
final Properties ambariProperties = new Properties();
- ambariProperties.put(Configuration.SERVER_HRC_STATUS_SUMMARY_CACHE_ENABLED, "true");
+ ambariProperties.put(Configuration.SERVER_HRC_STATUS_SUMMARY_CACHE_ENABLED.getKey(), "true");
Configuration configuration = new Configuration(ambariProperties);
LockArea lockArea = LockArea.HRC_STATUS_CACHE;
@@ -54,7 +54,7 @@ public class TransactionalLockTest {
@Test
public void testLockAreaEnabledDisabled() throws Exception {
final Properties ambariProperties = new Properties();
- ambariProperties.put(Configuration.SERVER_HRC_STATUS_SUMMARY_CACHE_ENABLED, "false");
+ ambariProperties.put(Configuration.SERVER_HRC_STATUS_SUMMARY_CACHE_ENABLED.getKey(), "false");
Configuration configuration = new Configuration(ambariProperties);
LockArea lockArea = LockArea.HRC_STATUS_CACHE;
http://git-wip-us.apache.org/repos/asf/ambari/blob/5630b5e7/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
index 9f12a94..2c39bda 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
@@ -727,7 +727,7 @@ public class TestActionScheduler {
when(db.getStagesInProgress()).thenReturn(stages);
Properties properties = new Properties();
- properties.put(Configuration.PARALLEL_STAGE_EXECUTION_KEY, "true");
+ properties.put(Configuration.PARALLEL_STAGE_EXECUTION.getKey(), "true");
Configuration conf = new Configuration(properties);
ActionScheduler scheduler = new ActionScheduler(100, 50, db, aq, fsm, 3,
new HostsMap((String) null),
@@ -1221,7 +1221,7 @@ public class TestActionScheduler {
when(db.getStagesInProgress()).thenReturn(stages);
Properties properties = new Properties();
- properties.put(Configuration.PARALLEL_STAGE_EXECUTION_KEY, "false");
+ properties.put(Configuration.PARALLEL_STAGE_EXECUTION.getKey(), "false");
Configuration conf = new Configuration(properties);
ActionScheduler scheduler = spy(new ActionScheduler(100, 50, db, aq, fsm, 3,
new HostsMap((String) null),
@@ -1296,7 +1296,7 @@ public class TestActionScheduler {
when(db.getStagesInProgress()).thenReturn(stages);
Properties properties = new Properties();
- properties.put(Configuration.PARALLEL_STAGE_EXECUTION_KEY, "true");
+ properties.put(Configuration.PARALLEL_STAGE_EXECUTION.getKey(), "true");
Configuration conf = new Configuration(properties);
ActionScheduler scheduler = spy(new ActionScheduler(100, 50, db, aq, fsm, 3,
new HostsMap((String) null),
http://git-wip-us.apache.org/repos/asf/ambari/blob/5630b5e7/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java b/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
index 525595a..aa7ef20 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
@@ -519,11 +519,11 @@ public class TestHeartbeatHandler {
RegistrationResponse rr = handler.handleRegistration(reg);
Map<String, String> config = rr.getAgentConfig();
assertFalse(config.isEmpty());
- assertTrue(config.containsKey(Configuration.CHECK_REMOTE_MOUNTS_KEY));
- assertTrue("false".equals(config.get(Configuration.CHECK_REMOTE_MOUNTS_KEY)));
- assertTrue(config.containsKey(Configuration.CHECK_MOUNTS_TIMEOUT_KEY));
- assertTrue("0".equals(config.get(Configuration.CHECK_MOUNTS_TIMEOUT_KEY)));
- assertTrue("true".equals(config.get(Configuration.ENABLE_AUTO_AGENT_CACHE_UPDATE_KEY)));
+ assertTrue(config.containsKey(Configuration.CHECK_REMOTE_MOUNTS.getKey()));
+ assertTrue("false".equals(config.get(Configuration.CHECK_REMOTE_MOUNTS.getKey())));
+ assertTrue(config.containsKey(Configuration.CHECK_MOUNTS_TIMEOUT.getKey()));
+ assertTrue("0".equals(config.get(Configuration.CHECK_MOUNTS_TIMEOUT.getKey())));
+ assertTrue("true".equals(config.get(Configuration.ENABLE_AUTO_AGENT_CACHE_UPDATE.getKey())));
}
@Test
http://git-wip-us.apache.org/repos/asf/ambari/blob/5630b5e7/ambari-server/src/test/java/org/apache/ambari/server/api/rest/KdcServerConnectionVerificationTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/rest/KdcServerConnectionVerificationTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/rest/KdcServerConnectionVerificationTest.java
index 18a4c0a..551209c 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/rest/KdcServerConnectionVerificationTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/rest/KdcServerConnectionVerificationTest.java
@@ -56,7 +56,7 @@ public class KdcServerConnectionVerificationTest {
@Before
public void before() throws Exception {
Properties configProps = new Properties();
- configProps.setProperty(Configuration.KDC_PORT_KEY, Integer.toString(KDC_TEST_PORT));
+ configProps.setProperty(Configuration.KDC_PORT.getKey(), Integer.toString(KDC_TEST_PORT));
configuration = new Configuration(configProps);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/5630b5e7/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
index 538fa48..0f8ed9c 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
@@ -18,8 +18,6 @@
package org.apache.ambari.server.api.services;
-import javax.persistence.EntityManager;
-import junit.framework.Assert;
import static org.easymock.EasyMock.createNiceMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
@@ -45,6 +43,8 @@ import java.util.Properties;
import java.util.Set;
import java.util.UUID;
+import javax.persistence.EntityManager;
+
import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.StackAccessException;
import org.apache.ambari.server.configuration.Configuration;
@@ -104,6 +104,8 @@ import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.util.Modules;
+import junit.framework.Assert;
+
public class AmbariMetaInfoTest {
private static final String STACK_NAME_HDP = "HDP";
@@ -927,9 +929,9 @@ public class AmbariMetaInfoTest {
}
Properties properties = new Properties();
- properties.setProperty(Configuration.METADATA_DIR_PATH, stacks.getPath());
- properties.setProperty(Configuration.COMMON_SERVICES_DIR_PATH, commonServicesRoot.getPath());
- properties.setProperty(Configuration.SERVER_VERSION_FILE, version.getPath());
+ properties.setProperty(Configuration.METADATA_DIR_PATH.getKey(), stacks.getPath());
+ properties.setProperty(Configuration.COMMON_SERVICES_DIR_PATH.getKey(), commonServicesRoot.getPath());
+ properties.setProperty(Configuration.SERVER_VERSION_FILE.getKey(), version.getPath());
Configuration configuration = new Configuration(properties);
TestAmbariMetaInfo ambariMetaInfo = new TestAmbariMetaInfo(configuration);
@@ -2004,8 +2006,8 @@ public class AmbariMetaInfoTest {
File versionFile) throws Exception {
Properties properties = new Properties();
- properties.setProperty(Configuration.METADATA_DIR_PATH, stackRoot.getPath());
- properties.setProperty(Configuration.SERVER_VERSION_FILE, versionFile.getPath());
+ properties.setProperty(Configuration.METADATA_DIR_PATH.getKey(), stackRoot.getPath());
+ properties.setProperty(Configuration.SERVER_VERSION_FILE.getKey(), versionFile.getPath());
Configuration configuration = new Configuration(properties);
TestAmbariMetaInfo metaInfo = new TestAmbariMetaInfo(configuration);
http://git-wip-us.apache.org/repos/asf/ambari/blob/5630b5e7/ambari-server/src/test/java/org/apache/ambari/server/api/services/KerberosServiceMetaInfoTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/KerberosServiceMetaInfoTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/KerberosServiceMetaInfoTest.java
index befd594..4137ffb 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/KerberosServiceMetaInfoTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/KerberosServiceMetaInfoTest.java
@@ -32,8 +32,6 @@ import java.util.Properties;
import javax.persistence.EntityManager;
-import junit.framework.Assert;
-
import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.configuration.Configuration;
import org.apache.ambari.server.events.publishers.AmbariEventPublisher;
@@ -60,6 +58,8 @@ import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.util.Modules;
+import junit.framework.Assert;
+
public class KerberosServiceMetaInfoTest {
private final static Logger LOG = LoggerFactory.getLogger(KerberosServiceMetaInfoTest.class);
private ServiceInfo serviceInfo = null;
@@ -198,9 +198,9 @@ public class KerberosServiceMetaInfoTest {
private TestAmbariMetaInfo createAmbariMetaInfo(File stackRoot, File commonServicesRoot, File versionFile, boolean replayMocks) throws Exception {
Properties properties = new Properties();
- properties.setProperty(Configuration.METADATA_DIR_PATH, stackRoot.getPath());
- properties.setProperty(Configuration.COMMON_SERVICES_DIR_PATH, commonServicesRoot.getPath());
- properties.setProperty(Configuration.SERVER_VERSION_FILE, versionFile.getPath());
+ properties.setProperty(Configuration.METADATA_DIR_PATH.getKey(), stackRoot.getPath());
+ properties.setProperty(Configuration.COMMON_SERVICES_DIR_PATH.getKey(), commonServicesRoot.getPath());
+ properties.setProperty(Configuration.SERVER_VERSION_FILE.getKey(), versionFile.getPath());
Configuration configuration = new Configuration(properties);
TestAmbariMetaInfo metaInfo = new TestAmbariMetaInfo(configuration);
http://git-wip-us.apache.org/repos/asf/ambari/blob/5630b5e7/ambari-server/src/test/java/org/apache/ambari/server/bootstrap/BootStrapTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/bootstrap/BootStrapTest.java b/ambari-server/src/test/java/org/apache/ambari/server/bootstrap/BootStrapTest.java
index e4a385f..3299b63 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/bootstrap/BootStrapTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/bootstrap/BootStrapTest.java
@@ -18,8 +18,12 @@
package org.apache.ambari.server.bootstrap;
-import junit.framework.Assert;
-import junit.framework.TestCase;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
import org.apache.ambari.server.api.services.AmbariMetaInfo;
import org.apache.ambari.server.bootstrap.BootStrapStatus.BSStat;
import org.apache.ambari.server.configuration.Configuration;
@@ -31,11 +35,8 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
+import junit.framework.Assert;
+import junit.framework.TestCase;
/**
* Test BootStrap Implementation.
@@ -44,11 +45,13 @@ public class BootStrapTest extends TestCase {
private static Log LOG = LogFactory.getLog(BootStrapTest.class);
public TemporaryFolder temp = new TemporaryFolder();
+ @Override
@Before
public void setUp() throws IOException {
temp.create();
}
+ @Override
@After
public void tearDown() throws IOException {
temp.delete();
@@ -69,12 +72,12 @@ public class BootStrapTest extends TestCase {
sharedResourcesDir = ClassLoader.getSystemClassLoader().getResource("").getPath();
}
- properties.setProperty(Configuration.BOOTSTRAP_DIR, bootdir);
- properties.setProperty(Configuration.BOOTSTRAP_SCRIPT, prepareEchoCommand(bootdir));
- properties.setProperty(Configuration.SRVR_KSTR_DIR_KEY, "target" + File.separator + "classes");
- properties.setProperty(Configuration.METADATA_DIR_PATH, metadetadir);
- properties.setProperty(Configuration.SERVER_VERSION_FILE, serverVersionFilePath);
- properties.setProperty(Configuration.SHARED_RESOURCES_DIR_KEY, sharedResourcesDir);
+ properties.setProperty(Configuration.BOOTSTRAP_DIRECTORY.getKey(), bootdir);
+ properties.setProperty(Configuration.BOOTSTRAP_SCRIPT.getKey(), prepareEchoCommand(bootdir));
+ properties.setProperty(Configuration.SRVR_KSTR_DIR.getKey(), "target" + File.separator + "classes");
+ properties.setProperty(Configuration.METADATA_DIR_PATH.getKey(), metadetadir);
+ properties.setProperty(Configuration.SERVER_VERSION_FILE.getKey(), serverVersionFilePath);
+ properties.setProperty(Configuration.SHARED_RESOURCES_DIR.getKey(), sharedResourcesDir);
Configuration conf = new Configuration(properties);
AmbariMetaInfo ambariMetaInfo = new AmbariMetaInfo(conf);
@@ -146,12 +149,12 @@ public class BootStrapTest extends TestCase {
serverKSTRDir = new File(new File(ClassLoader.getSystemClassLoader().getResource("").getPath()).getParent(), "classes").getPath();
}
- properties.setProperty(Configuration.BOOTSTRAP_DIR, bootdir);
- properties.setProperty(Configuration.BOOTSTRAP_SCRIPT, prepareEchoCommand(bootdir));
- properties.setProperty(Configuration.SRVR_KSTR_DIR_KEY, serverKSTRDir);
- properties.setProperty(Configuration.METADATA_DIR_PATH, metadetadir);
- properties.setProperty(Configuration.SERVER_VERSION_FILE, serverVersionFilePath);
- properties.setProperty(Configuration.SHARED_RESOURCES_DIR_KEY, sharedResourcesDir);
+ properties.setProperty(Configuration.BOOTSTRAP_DIRECTORY.getKey(), bootdir);
+ properties.setProperty(Configuration.BOOTSTRAP_SCRIPT.getKey(), prepareEchoCommand(bootdir));
+ properties.setProperty(Configuration.SRVR_KSTR_DIR.getKey(), serverKSTRDir);
+ properties.setProperty(Configuration.METADATA_DIR_PATH.getKey(), metadetadir);
+ properties.setProperty(Configuration.SERVER_VERSION_FILE.getKey(), serverVersionFilePath);
+ properties.setProperty(Configuration.SHARED_RESOURCES_DIR.getKey(), sharedResourcesDir);
Configuration conf = new Configuration(properties);
AmbariMetaInfo ambariMetaInfo = new AmbariMetaInfo(conf);
BootStrapImpl impl = new BootStrapImpl(conf, ambariMetaInfo);
http://git-wip-us.apache.org/repos/asf/ambari/blob/5630b5e7/ambari-server/src/test/java/org/apache/ambari/server/checks/UpgradeCheckOrderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/checks/UpgradeCheckOrderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/checks/UpgradeCheckOrderTest.java
index 687d263..cb03613 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/checks/UpgradeCheckOrderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/checks/UpgradeCheckOrderTest.java
@@ -50,9 +50,9 @@ public class UpgradeCheckOrderTest {
String sourceResourceDirectory = "src" + File.separator + "test" + File.separator + "resources";
Properties properties = new Properties();
- properties.setProperty(Configuration.SERVER_PERSISTENCE_TYPE_KEY, "in-memory");
- properties.setProperty(Configuration.OS_VERSION_KEY, "centos6");
- properties.setProperty(Configuration.SHARED_RESOURCES_DIR_KEY, sourceResourceDirectory);
+ properties.setProperty(Configuration.SERVER_PERSISTENCE_TYPE.getKey(), "in-memory");
+ properties.setProperty(Configuration.OS_VERSION.getKey(), "centos6");
+ properties.setProperty(Configuration.SHARED_RESOURCES_DIR.getKey(), sourceResourceDirectory);
Injector injector = Guice.createInjector(new ControllerModule(properties), new AuditLoggerModule());
UpgradeCheckRegistry registry = injector.getInstance(UpgradeCheckRegistry.class);
http://git-wip-us.apache.org/repos/asf/ambari/blob/5630b5e7/ambari-server/src/test/java/org/apache/ambari/server/cleanup/CleanupServiceFunctionalTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/cleanup/CleanupServiceFunctionalTest.java b/ambari-server/src/test/java/org/apache/ambari/server/cleanup/CleanupServiceFunctionalTest.java
index 33018bc..e04871d 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/cleanup/CleanupServiceFunctionalTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/cleanup/CleanupServiceFunctionalTest.java
@@ -109,7 +109,7 @@ public class CleanupServiceFunctionalTest {
properties.put("server.jdbc.user.name", "ambari");
//properties.put("server.jdbc.user.passwd", "bigdata");
properties.put("server.jdbc.url", "jdbc:postgresql://192.168.59.103:5432/ambari");
- properties.put(Configuration.SHARED_RESOURCES_DIR_KEY, "/Users/lpuskas/prj/ambari/ambari-server/src/test/resources");
+ properties.put(Configuration.SHARED_RESOURCES_DIR.getKey(), "/Users/lpuskas/prj/ambari/ambari-server/src/test/resources");
return properties;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/5630b5e7/ambari-server/src/test/java/org/apache/ambari/server/configuration/ComponentSSLConfigurationTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/configuration/ComponentSSLConfigurationTest.java b/ambari-server/src/test/java/org/apache/ambari/server/configuration/ComponentSSLConfigurationTest.java
index 92a7ef5..ba08b70 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/configuration/ComponentSSLConfigurationTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/configuration/ComponentSSLConfigurationTest.java
@@ -31,10 +31,11 @@ public class ComponentSSLConfigurationTest {
public static ComponentSSLConfiguration getConfiguration(String path,
String pass, String type, boolean isSslEnabled) {
Properties ambariProperties = new Properties();
- ambariProperties.setProperty(Configuration.SSL_TRUSTSTORE_PATH_KEY, path);
- ambariProperties.setProperty(Configuration.SSL_TRUSTSTORE_PASSWORD_KEY, pass);
- ambariProperties.setProperty(Configuration.SSL_TRUSTSTORE_TYPE_KEY, type);
- ambariProperties.setProperty(Configuration.AMRABI_METRICS_HTTPS_ENABLED_KEY, Boolean.toString(isSslEnabled));
+ ambariProperties.setProperty(Configuration.SSL_TRUSTSTORE_PATH.getKey(), path);
+ ambariProperties.setProperty(Configuration.SSL_TRUSTSTORE_PASSWORD.getKey(), pass);
+ ambariProperties.setProperty(Configuration.SSL_TRUSTSTORE_TYPE.getKey(), type);
+ ambariProperties.setProperty(Configuration.AMBARI_METRICS_HTTPS_ENABLED.getKey(),
+ Boolean.toString(isSslEnabled));
Configuration configuration = new TestConfiguration(ambariProperties);