YARN-8810. Fixed a YARN service bug in comparing ConfigFile object.
Contributed by Chandni Singh
This commit is contained in:
parent
3e1894c376
commit
7c40f9b37c
|
@ -88,7 +88,7 @@ public interface UpgradeComponentsFinder {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Objects.equals(currentDef.getConfiguration(),
|
if (!Objects.equals(currentDef.getConfiguration(),
|
||||||
currentDef.getConfiguration())) {
|
targetDef.getConfiguration())) {
|
||||||
return targetDef.getComponents();
|
return targetDef.getComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -200,7 +200,8 @@ public class ConfigFile implements Serializable {
|
||||||
ConfigFile configFile = (ConfigFile) o;
|
ConfigFile configFile = (ConfigFile) o;
|
||||||
return Objects.equals(this.type, configFile.type)
|
return Objects.equals(this.type, configFile.type)
|
||||||
&& Objects.equals(this.destFile, configFile.destFile)
|
&& Objects.equals(this.destFile, configFile.destFile)
|
||||||
&& Objects.equals(this.srcFile, configFile.srcFile);
|
&& Objects.equals(this.srcFile, configFile.srcFile)
|
||||||
|
&& Objects.equals(this.properties, configFile.properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -17,14 +17,15 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.yarn.service;
|
package org.apache.hadoop.yarn.service;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import org.apache.hadoop.yarn.service.api.records.Component;
|
import org.apache.hadoop.yarn.service.api.records.Component;
|
||||||
|
import org.apache.hadoop.yarn.service.api.records.ConfigFile;
|
||||||
|
import org.apache.hadoop.yarn.service.api.records.Configuration;
|
||||||
import org.apache.hadoop.yarn.service.api.records.Service;
|
import org.apache.hadoop.yarn.service.api.records.Service;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
@ -86,4 +87,37 @@ public class TestDefaultUpgradeComponentsFinder {
|
||||||
expected, finder.findTargetComponentSpecs(currentDef,
|
expected, finder.findTargetComponentSpecs(currentDef,
|
||||||
targetDef));
|
targetDef));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testChangeInConfigFileProperty() {
|
||||||
|
ConfigFile file = new ConfigFile().srcFile("src").destFile("dest")
|
||||||
|
.type(ConfigFile.TypeEnum.HADOOP_XML);
|
||||||
|
|
||||||
|
Map<String, String> props = new HashMap<>();
|
||||||
|
props.put("k1", "v1");
|
||||||
|
file.setProperties(props);
|
||||||
|
|
||||||
|
Configuration conf = new Configuration().files(Lists.newArrayList(file));
|
||||||
|
|
||||||
|
Service currentDef = TestServiceManager.createBaseDef("test");
|
||||||
|
currentDef.setConfiguration(conf);
|
||||||
|
|
||||||
|
// new spec has changes in config file property
|
||||||
|
file = new ConfigFile().srcFile("src").destFile("dest")
|
||||||
|
.type(ConfigFile.TypeEnum.HADOOP_XML);
|
||||||
|
Map<String, String> changedProps = new HashMap<>();
|
||||||
|
changedProps.put("k1", "v2");
|
||||||
|
file.setProperties(changedProps);
|
||||||
|
|
||||||
|
conf = new Configuration().files(Lists.newArrayList(file));
|
||||||
|
|
||||||
|
Service targetDef = TestServiceManager.createBaseDef("test");
|
||||||
|
targetDef.setConfiguration(conf);
|
||||||
|
|
||||||
|
List<Component> expected = new ArrayList<>();
|
||||||
|
expected.addAll(targetDef.getComponents());
|
||||||
|
|
||||||
|
assertEquals("all components needs upgrade",
|
||||||
|
expected, finder.findTargetComponentSpecs(currentDef, targetDef));
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue