/** Parse and populate child configuration modules. */ private void populateConfigurationModules() { ConfigurationDirectory configDirectory = serviceDirectory.getConfigurationDirectory(serviceInfo.getConfigDir()); if (configDirectory != null) { for (ConfigurationModule config : configDirectory.getConfigurationModules()) { ConfigurationInfo info = config.getModuleInfo(); if (isValid()) { setValid(config.isValid() && info.isValid()); if (!isValid()) { setErrors(config.getErrors()); setErrors(info.getErrors()); } } serviceInfo.getProperties().addAll(info.getProperties()); serviceInfo.setTypeAttributes(config.getConfigType(), info.getAttributes()); configurationModules.put(config.getConfigType(), config); } for (String excludedType : serviceInfo.getExcludedConfigTypes()) { if (!configurationModules.containsKey(excludedType)) { ConfigurationInfo configInfo = new ConfigurationInfo( Collections.<PropertyInfo>emptyList(), Collections.<String, String>emptyMap()); ConfigurationModule config = new ConfigurationModule(excludedType, configInfo); config.setDeleted(true); configurationModules.put(excludedType, config); } } } }
/** * Constructor. * * @param stackContext stack context which provides module access to external functionality * @param serviceInfo associated service info * @param serviceDirectory used for all IO interaction with service directory in stack definition * @param isCommonService flag to mark a service as a common service */ public ServiceModule( StackContext stackContext, ServiceInfo serviceInfo, ServiceDirectory serviceDirectory, boolean isCommonService) { this.serviceInfo = serviceInfo; this.stackContext = stackContext; this.serviceDirectory = serviceDirectory; this.isCommonService = isCommonService; serviceInfo.setMetricsFile(serviceDirectory.getMetricsFile(serviceInfo.getName())); serviceInfo.setAlertsFile(serviceDirectory.getAlertsFile()); serviceInfo.setKerberosDescriptorFile(serviceDirectory.getKerberosDescriptorFile()); serviceInfo.setWidgetsDescriptorFile( serviceDirectory.getWidgetsDescriptorFile(serviceInfo.getName())); serviceInfo.setSchemaVersion(AmbariMetaInfo.SCHEMA_VERSION_2); serviceInfo.setServicePackageFolder(serviceDirectory.getPackageDir()); populateComponentModules(); populateConfigurationModules(); populateThemeModules(); validateServiceInfo(); }
private void populateThemeModules() { if (serviceInfo.getThemesDir() == null) { serviceInfo.setThemesDir(AmbariMetaInfo.SERVICE_THEMES_FOLDER_NAME); } String themesDir = serviceDirectory.getAbsolutePath() + File.separator + serviceInfo.getThemesDir(); if (serviceInfo.getThemes() != null) { for (ThemeInfo themeInfo : serviceInfo.getThemes()) { File themeFile = new File(themesDir + File.separator + themeInfo.getFileName()); ThemeModule module = new ThemeModule(themeFile, themeInfo); themeModules.put(module.getId(), module); } } // lets not fail if theme contain errors }
private ServiceDirectory createServiceDirectory(String dir, ConfigurationDirectory configDir) { ServiceDirectory serviceDirectory = createNiceMock(ServiceDirectory.class); expect(serviceDirectory.getConfigurationDirectory(dir)).andReturn(configDir).anyTimes(); expect(serviceDirectory.getMetricsFile()).andReturn(new File("testMetricsFile")).anyTimes(); expect(serviceDirectory.getAlertsFile()).andReturn(new File("testAlertsFile")).anyTimes(); expect(serviceDirectory.getKerberosDescriptorFile()) .andReturn(new File("testKerberosDescriptorFile")) .anyTimes(); expect(serviceDirectory.getPackageDir()).andReturn("packageDir").anyTimes(); replay(serviceDirectory); return serviceDirectory; }