Explorar o código

AMBARI-2384. Ambari Server on dev VM with default ambari config fails to start. (swagle)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/trunk@1492926 13f79535-47bb-0310-9956-ffa450edef68
Siddharth Wagle %!s(int64=12) %!d(string=hai) anos
pai
achega
1d2b11f037

+ 10 - 2
ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java

@@ -310,8 +310,16 @@ public class Configuration {
 
   private void loadCredentialProvider() {
     if (credentialProvider == null) {
-      this.credentialProvider = new CredentialProvider(null,
-        getMasterKeyLocation(), isMasterKeyPersisted());
+      try {
+        this.credentialProvider = new CredentialProvider(null,
+          getMasterKeyLocation(), isMasterKeyPersisted());
+      } catch (Exception e) {
+        LOG.info("Credential provider creation failed.\n" + e.getMessage());
+        if (LOG.isDebugEnabled()) {
+          e.printStackTrace();
+        }
+        this.credentialProvider = null;
+      }
     }
   }
 

+ 4 - 1
ambari-server/src/main/java/org/apache/ambari/server/security/encryption/CredentialProvider.java

@@ -43,7 +43,7 @@ public class CredentialProvider {
   static final Logger LOG = LoggerFactory.getLogger(CredentialProvider.class);
 
   public CredentialProvider(String masterKey, String masterKeyLocation,
-                            boolean isMasterKeyPersisted) {
+              boolean isMasterKeyPersisted) throws AmbariException {
     if (masterKeyLocation == null)
       throw new IllegalArgumentException("Master key location needed for " +
         "Credential Provider initialization.");
@@ -55,6 +55,9 @@ public class CredentialProvider {
       masterKeyService = new MasterKeyServiceImpl(masterKeyLocation,
         isMasterKeyPersisted);
     }
+    if (!masterKeyService.isMasterKeyInitialized()) {
+      throw new AmbariException("Master key initialization failed.");
+    }
     String storeDir = masterKeyLocation.substring(0,
       masterKeyLocation.indexOf(Configuration.MASTER_KEY_FILENAME_DEFAULT));
     this.keystoreService = new CredentialStoreServiceImpl(storeDir);