Procházet zdrojové kódy

AMBARI-9579. After upgrading Ambari 1.6.1 to 1.7, the directory of zookeeper server get changed to /hadoop/zookeeper (dlysnichenko)

Lisnichenko Dmitro před 10 roky
rodič
revize
fad54e324d

+ 11 - 3
ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java

@@ -1178,6 +1178,7 @@ public class UpgradeCatalog170 extends AbstractUpgradeCatalog {
         for (Map.Entry<String, String> property : globalProperites.entrySet()) {
           String propertyName = property.getKey();
           String propertyValue = property.getValue();
+          String newPropertyName = getNewPropertyName().get(propertyName);
 
           Set<String> newConfigTypes = configHelper.findConfigTypesByPropertyName(cluster.getCurrentStackVersion(),
                   propertyName, cluster.getClusterName());
@@ -1188,7 +1189,7 @@ public class UpgradeCatalog170 extends AbstractUpgradeCatalog {
           if(newConfigTypes.size() > 0) {
             newConfigType = newConfigTypes.iterator().next();
           } else {
-            newConfigType = getAdditionalMappingGlobalToEnv().get(propertyName);
+            newConfigType = getAdditionalMappingGlobalToEnv().get(((newPropertyName == null)? propertyName : newPropertyName));
           }
 
           if(newConfigType==null) {
@@ -1199,13 +1200,13 @@ public class UpgradeCatalog170 extends AbstractUpgradeCatalog {
           }
 
           LOG.info("Mapping config " + propertyName + " from " + Configuration.GLOBAL_CONFIG_TAG +
-              " to " + newConfigType +
+              " to " + ((newPropertyName == null)? propertyName : newPropertyName) + " property in " + newConfigType +
               " (value="+propertyValue+")");
 
           if(!newProperties.containsKey(newConfigType)) {
             newProperties.put(newConfigType, new HashMap<String, String>());
           }
-          newProperties.get(newConfigType).put(propertyName, propertyValue);
+          newProperties.get(newConfigType).put(((newPropertyName == null)? propertyName : newPropertyName), propertyValue);
         }
 
         for (Entry<String, Map<String, String>> newProperty : newProperties.entrySet()) {
@@ -1243,10 +1244,17 @@ public class UpgradeCatalog170 extends AbstractUpgradeCatalog {
     result.put("storm_keytab","storm-env");
     result.put("hive_hostname","hive-env");
     result.put("oozie_hostname","oozie-env");
+    result.put("dataDir","zoo.cfg");
 
     return result;
   }
 
+  public Map<String, String> getNewPropertyName() {
+    Map<String, String> result = new HashMap<String, String>();
+    result.put("zk_data_dir","dataDir");
+    return result;
+  }
+  
   private void upgradePermissionModel() throws SQLException {
     final UserDAO userDAO = injector.getInstance(UserDAO.class);
     final PrincipalDAO principalDAO = injector.getInstance(PrincipalDAO.class);

+ 5 - 2
ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java

@@ -162,7 +162,7 @@ public class UpgradeCatalog170Test {
   }
 
   @Test
-  public void testExecuteDDLUpdates() throws Exception {
+  public void testExecuteDDLUpdates_DBAccessor() throws Exception {
     final DBAccessor dbAccessor = createNiceMock(DBAccessor.class);
     Connection connection = createNiceMock(Connection.class);
     PreparedStatement stmt = createNiceMock(PreparedStatement.class);
@@ -334,9 +334,11 @@ public class UpgradeCatalog170Test {
     Method n = AbstractUpgradeCatalog.class.getDeclaredMethod("getEntityManagerProvider");
     Method l = AbstractUpgradeCatalog.class.getDeclaredMethod
         ("addNewConfigurationsFromXml");
+    Method newPropMap = UpgradeCatalog170.class.getDeclaredMethod("getNewPropertyName");
 
     UpgradeCatalog170 upgradeCatalog = createMockBuilder(UpgradeCatalog170.class)
-      .addMockedMethod(m).addMockedMethod(n).addMockedMethod(l).createMock();
+      .addMockedMethod(m).addMockedMethod(n).addMockedMethod(l).addMockedMethod(newPropMap)
+            .createMock();
 
     List<ConfigGroupConfigMappingEntity> configGroupConfigMappingEntities =
             new ArrayList<ConfigGroupConfigMappingEntity>();
@@ -379,6 +381,7 @@ public class UpgradeCatalog170Test {
     expect(entityManager.createQuery(cq)).andReturn(q).anyTimes();
     expect(trans.isActive()).andReturn(true).anyTimes();
     expect(upgradeCatalog.getEntityManagerProvider()).andReturn(entityManagerProvider).anyTimes();
+    expect(upgradeCatalog.getNewPropertyName()).andReturn(new HashMap<String, String>()).anyTimes();
     expect(cb.createQuery(HostRoleCommandEntity.class)).andReturn(cq).anyTimes();
     expect(cb.desc(taskId)).andReturn(o).anyTimes();
     expect(cq.from(HostRoleCommandEntity.class)).andReturn(hrc).anyTimes();