ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aonis...@apache.org
Subject [2/2] ambari git commit: AMBARI-20024. Relax ranger config DB consistency check rules (aonishuk)
Date Fri, 17 Feb 2017 11:36:26 GMT
AMBARI-20024. Relax ranger config DB consistency check rules (aonishuk)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/f1fa4ec6
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f1fa4ec6
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f1fa4ec6

Branch: refs/heads/branch-2.5
Commit: f1fa4ec6abcf4746a9f3cd0aeabdae35a157c84b
Parents: 481cfe5
Author: Andrew Onishuk <aonishuk@hortonworks.com>
Authored: Fri Feb 17 13:36:15 2017 +0200
Committer: Andrew Onishuk <aonishuk@hortonworks.com>
Committed: Fri Feb 17 13:36:15 2017 +0200

----------------------------------------------------------------------
 .../checks/DatabaseConsistencyCheckHelper.java   | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f1fa4ec6/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
b/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
index b4630a6..4cdeecb 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
@@ -33,6 +33,8 @@ import java.util.Map;
 import java.util.Objects;
 import java.util.Scanner;
 import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import javax.annotation.Nullable;
 import javax.inject.Provider;
@@ -917,6 +919,12 @@ public class DatabaseConsistencyCheckHelper {
                 Collection<String> serviceConfigsFromDB = dbServiceConfigs.get(serviceName);
                 if (serviceConfigsFromDB != null && serviceConfigsFromStack != null)
{
                   serviceConfigsFromStack.removeAll(serviceConfigsFromDB);
+
+                  // skip ranger-{service_name}-* from being checked, unless ranger is installed
+                  if(!dbServiceConfigs.containsKey("RANGER")) {
+                    removeStringsByRegexp(serviceConfigsFromStack, "^ranger-"+ serviceName.toLowerCase()
+ "-" + "*");
+                  }
+
                   if (!serviceConfigsFromStack.isEmpty()) {
                     error("Required config(s): {} is(are) not available for service {} with
service config version {} in cluster {}",
                             StringUtils.join(serviceConfigsFromStack, ","), serviceName,
Integer.toString(serviceVersion), clusterName);
@@ -992,4 +1000,15 @@ public class DatabaseConsistencyCheckHelper {
     }
   }
 
+  private static void removeStringsByRegexp(Collection<String> stringItems, String
regexp) {
+      Pattern pattern = Pattern.compile(regexp);
+
+      for (Iterator<String> iterator = stringItems.iterator(); iterator.hasNext();)
{
+        String stringItem = iterator.next();
+        Matcher matcher = pattern.matcher(stringItem);
+        if (matcher.find()) {
+          iterator.remove();
+        }
+      }
+  }
 }


Mime
View raw message