@Test(expected = InvalidTopologyException.class) public void testShouldValidationFailWhenInvalidConfigGroupsSpecifiedInCCTemplate() throws Exception { clusterRequestConfigTypes = new HashSet<String>(Arrays.asList("oozie-site")); EasyMock.expect(clusterConfigurationMock.getAllConfigTypes()).andReturn(clusterRequestConfigTypes).anyTimes(); EasyMock.expect(blueprintMock.getServices()).andReturn(new HashSet<String>(Arrays.asList("YARN", "HDFS"))); EasyMock.expect(stackMock.getConfigurationTypes("HDFS")).andReturn(Arrays.asList("core-site")); EasyMock.expect(stackMock.getConfigurationTypes("YARN")).andReturn(Arrays.asList("yarn-site")); replayAll(); clusterConfigTypeValidator.validate(clusterTopologyMock); }
@Override public void validate(ClusterTopology topology) throws InvalidTopologyException { Set<String> topologyClusterConfigTypes = new HashSet(topology.getConfiguration().getAllConfigTypes()); LOGGER.debug("Cluster config types: {}", topologyClusterConfigTypes); if (topologyClusterConfigTypes.isEmpty()) { LOGGER.debug("No config types to be checked."); return; } Set<String> stackServiceConfigTypes = new HashSet<>(); for (String serviceName : topology.getBlueprint().getServices()) { stackServiceConfigTypes.addAll(topology.getBlueprint().getStack().getConfigurationTypes(serviceName)); } Set<String> configTypeIntersection = new HashSet<String>(topologyClusterConfigTypes); if (configTypeIntersection.retainAll(stackServiceConfigTypes)) { Set<String> invalidConfigTypes = new HashSet<>(topologyClusterConfigTypes); invalidConfigTypes.removeAll(configTypeIntersection); LOGGER.error("The following config typess are wrong: {}", invalidConfigTypes); throw new InvalidTopologyException("The following configuration types are invalid: " + invalidConfigTypes.toString()); } }
ClusterConfigTypeValidator implements TopologyValidator { @Override public void validate(ClusterTopology topology) throws InvalidTopologyException { Set<String> topologyClusterConfigTypes = new HashSet(topology.getConfiguration().getAllConfigTypes()); LOGGER.debug("Cluster config types: {}", topologyClusterConfigTypes); if (topologyClusterConfigTypes.isEmpty()) { LOGGER.debug("No config types to be checked."); return; } Set<String> stackServiceConfigTypes = new HashSet<>(); for (String serviceName : topology.getBlueprint().getServices()) { stackServiceConfigTypes.addAll(topology.getBlueprint().getStack().getConfigurationTypes(serviceName)); } Set<String> configTypeIntersection = new HashSet<String>(topologyClusterConfigTypes); if (configTypeIntersection.retainAll(stackServiceConfigTypes)) { Set<String> invalidConfigTypes = new HashSet<>(topologyClusterConfigTypes); invalidConfigTypes.removeAll(configTypeIntersection); LOGGER.error("The following config typess are wrong: {}", invalidConfigTypes); throw new InvalidTopologyException("The following configuration types are invalid: " + invalidConfigTypes.toString()); } } }
ClusterConfigTypeValidator implements TopologyValidator { @Override public void validate(ClusterTopology topology) throws InvalidTopologyException { Set<String> topologyClusterConfigTypes = new HashSet(topology.getConfiguration().getAllConfigTypes()); LOGGER.debug("Cluster config types: {}", topologyClusterConfigTypes); if (topologyClusterConfigTypes.isEmpty()) { LOGGER.debug("No config types to be checked."); return; } Set<String> stackServiceConfigTypes = new HashSet<>(); for (String serviceName : topology.getBlueprint().getServices()) { stackServiceConfigTypes.addAll(topology.getBlueprint().getStack().getConfigurationTypes(serviceName)); } Set<String> configTypeIntersection = new HashSet<String>(topologyClusterConfigTypes); if (configTypeIntersection.retainAll(stackServiceConfigTypes)) { Set<String> invalidConfigTypes = new HashSet<>(topologyClusterConfigTypes); invalidConfigTypes.removeAll(configTypeIntersection); LOGGER.error("The following config typess are wrong: {}", invalidConfigTypes); throw new InvalidTopologyException("The following configuration types are invalid: " + invalidConfigTypes.toString()); } }  }
ClusterConfigTypeValidator implements TopologyValidator { @Override public void validate(ClusterTopology topology) throws InvalidTopologyException { Set<String> topologyClusterConfigTypes = new HashSet(topology.getConfiguration().getAllConfigTypes()); LOGGER.debug("Cluster config types: {}", topologyClusterConfigTypes); if (topologyClusterConfigTypes.isEmpty()) { LOGGER.debug("No config types to be checked."); return; } Set<String> stackServiceConfigTypes = new HashSet<>(); for (String serviceName : topology.getBlueprint().getServices()) { stackServiceConfigTypes.addAll(topology.getBlueprint().getStack().getConfigurationTypes(serviceName)); } Set<String> configTypeIntersection = new HashSet<String>(topologyClusterConfigTypes); if (configTypeIntersection.retainAll(stackServiceConfigTypes)) { Set<String> invalidConfigTypes = new HashSet<>(topologyClusterConfigTypes); invalidConfigTypes.removeAll(configTypeIntersection); LOGGER.error("The following config typess are wrong: {}", invalidConfigTypes); throw new InvalidTopologyException("The following configuration types are invalid: " + invalidConfigTypes.toString()); } }  @Override void validate(ClusterTopology topology); }
ClusterConfigTypeValidator implements TopologyValidator { @Override public void validate(ClusterTopology topology) throws InvalidTopologyException { Set<String> topologyClusterConfigTypes = new HashSet(topology.getConfiguration().getAllConfigTypes()); LOGGER.debug("Cluster config types: {}", topologyClusterConfigTypes); if (topologyClusterConfigTypes.isEmpty()) { LOGGER.debug("No config types to be checked."); return; } Set<String> stackServiceConfigTypes = new HashSet<>(); for (String serviceName : topology.getBlueprint().getServices()) { stackServiceConfigTypes.addAll(topology.getBlueprint().getStack().getConfigurationTypes(serviceName)); } Set<String> configTypeIntersection = new HashSet<String>(topologyClusterConfigTypes); if (configTypeIntersection.retainAll(stackServiceConfigTypes)) { Set<String> invalidConfigTypes = new HashSet<>(topologyClusterConfigTypes); invalidConfigTypes.removeAll(configTypeIntersection); LOGGER.error("The following config typess are wrong: {}", invalidConfigTypes); throw new InvalidTopologyException("The following configuration types are invalid: " + invalidConfigTypes.toString()); } }  @Override void validate(ClusterTopology topology);  }