示例#1
0
 /**
  * Resolve common service
  *
  * @param allStacks all stack modules
  * @param commonServices common service modules
  * @throws AmbariException
  */
 public void resolveCommonService(
     Map<String, StackModule> allStacks, Map<String, ServiceModule> commonServices)
     throws AmbariException {
   if (!isCommonService) {
     throw new AmbariException("Not a common service");
   }
   moduleState = ModuleState.VISITED;
   String parentString = serviceInfo.getParent();
   if (parentString != null) {
     String[] parentToks = parentString.split(StackManager.PATH_DELIMITER);
     if (parentToks.length != 3) {
       throw new AmbariException(
           "The common service '"
               + serviceInfo.getName()
               + serviceInfo.getVersion()
               + "' extends an invalid parent: '"
               + parentString
               + "'");
     }
     if (parentToks[0].equalsIgnoreCase(StackManager.COMMON_SERVICES)) {
       String baseServiceKey = parentToks[1] + StackManager.PATH_DELIMITER + parentToks[2];
       ServiceModule baseService = commonServices.get(baseServiceKey);
       ModuleState baseModuleState = baseService.getModuleState();
       if (baseModuleState == ModuleState.INIT) {
         baseService.resolveCommonService(allStacks, commonServices);
       } else if (baseModuleState == ModuleState.VISITED) {
         // todo: provide more information to user about cycle
         throw new AmbariException("Cycle detected while parsing common service");
       }
       resolve(baseService, allStacks, commonServices);
     } else {
       throw new AmbariException("Common service cannot inherit from a non common service");
     }
   }
   moduleState = ModuleState.RESOLVED;
 }
示例#2
0
  @Override
  public void resolve(
      ServiceModule parentModule,
      Map<String, StackModule> allStacks,
      Map<String, ServiceModule> commonServices)
      throws AmbariException {

    if (!serviceInfo.isValid() || !parentModule.isValid()) return;

    ServiceInfo parent = parentModule.getModuleInfo();

    if (serviceInfo.getComment() == null) {
      serviceInfo.setComment(parent.getComment());
    }
    if (serviceInfo.getDisplayName() == null) {
      serviceInfo.setDisplayName(parent.getDisplayName());
    }
    if (serviceInfo.getVersion() == null) {
      serviceInfo.setVersion(parent.getVersion());
    }

    if (serviceInfo.getRequiredServices() == null
        || serviceInfo.getRequiredServices().size() == 0) {
      serviceInfo.setRequiredServices(
          parent.getRequiredServices() != null
              ? parent.getRequiredServices()
              : Collections.<String>emptyList());
    }

    if (serviceInfo.isRestartRequiredAfterChange() == null) {
      serviceInfo.setRestartRequiredAfterChange(parent.isRestartRequiredAfterChange());
    }
    if (serviceInfo.isRestartRequiredAfterRackChange() == null) {
      serviceInfo.setRestartRequiredAfterRackChange(parent.isRestartRequiredAfterRackChange());
    }
    if (serviceInfo.isMonitoringService() == null) {
      serviceInfo.setMonitoringService(parent.isMonitoringService());
    }
    if (serviceInfo.getOsSpecifics().isEmpty()) {
      serviceInfo.setOsSpecifics(parent.getOsSpecifics());
    }
    if (serviceInfo.getCommandScript() == null) {
      serviceInfo.setCommandScript(parent.getCommandScript());
    }
    if (serviceInfo.getServicePackageFolder() == null) {
      serviceInfo.setServicePackageFolder(parent.getServicePackageFolder());
    }
    if (serviceInfo.getMetricsFile() == null) {
      serviceInfo.setMetricsFile(parent.getMetricsFile());
    }
    if (serviceInfo.getAlertsFile() == null) {
      serviceInfo.setAlertsFile(parent.getAlertsFile());
    }
    if (serviceInfo.getKerberosDescriptorFile() == null) {
      serviceInfo.setKerberosDescriptorFile(parent.getKerberosDescriptorFile());
    }
    if (serviceInfo.getThemesMap().isEmpty()) {
      serviceInfo.setThemesMap(parent.getThemesMap());
    }
    if (serviceInfo.getWidgetsDescriptorFile() == null) {
      serviceInfo.setWidgetsDescriptorFile(parent.getWidgetsDescriptorFile());
    }

    mergeCustomCommands(parent.getCustomCommands(), serviceInfo.getCustomCommands());
    mergeConfigDependencies(parent);
    mergeComponents(parentModule, allStacks, commonServices);
    mergeConfigurations(parentModule, allStacks, commonServices);
    mergeThemes(parentModule, allStacks, commonServices);
    mergeExcludedConfigTypes(parent);

    mergeServiceProperties(parent.getServicePropertyList());
  }