class ServicePresenceCheck extends AbstractCheckDescriptor {

  @Override
  public void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request) throws AmbariException {
    final Cluster cluster = clustersProvider.get().getCluster(request.getClusterName());
    Set<String> installedServices = cluster.getServices().keySet();

    List<String> noUpgradeSupportServices = getNoUpgradeSupportServices(request);
    Map<String, String> replacedServices = getReplacedServices(request);
    List<String> removedServices = getRemovedServices(request);

    List<String> failReasons = new ArrayList<>();

    String reason = getFailReason(prerequisiteCheck, request);
    for(String service: noUpgradeSupportServices){
      if (installedServices.contains(service.toUpperCase())){
        prerequisiteCheck.getFailedOn().add(service);
        String msg = String.format(reason, service, service);
        failReasons.add(msg);
      }
    }

    reason = getFailReason(KEY_SERVICE_REPLACED, prerequisiteCheck, request);
    for (Map.Entry<String, String> entry : replacedServices.entrySet()) {
      String removedService = entry.getKey();
      if(installedServices.contains(removedService.toUpperCase())){
        prerequisiteCheck.getFailedOn().add(removedService);
        String newService = entry.getValue();
        String msg = String.format(reason, removedService, newService);
        failReasons.add(msg);
      }
    }

    reason = getFailReason(KEY_SERVICE_REMOVED, prerequisiteCheck, request);
    for(String service: removedServices){
      if (installedServices.contains(service.toUpperCase())){
        prerequisiteCheck.getFailedOn().add(service);
        String msg = String.format(reason, service, service);
        failReasons.add(msg);
      }
    }

    if(!failReasons.isEmpty()){
      prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL);
      prerequisiteCheck.setFailReason(StringUtils.join(failReasons, '\n'));
    }
  }

  public  ServicePresenceCheck();

}