Ejemplo n.º 1
0
  private boolean restoreMonitor(Long manifestId, Long ciId, CmsCI monitor, boolean writeMode) {

    if (!"true".equals(monitor.getAttributes().get(IS_ENABLED).getDjValue())) {
      return false;
    }

    boolean isHeartBeat = "true".equals(monitor.getAttributes().get(HEARTBEAT).getDjValue());
    String hbDuration = monitor.getAttributes().get(DURATION).getDjValue();
    String source = monitor.getCiName();

    long checksum = getChecksum(monitor);

    String thresholdsJson = monitor.getAttributes().get(THRESHOLDS).getDjValue();

    Threshold threshold = tsDao.getThreshold(manifestId, source);
    if (threshold == null) {
      logger.info(
          "RestoreMonitor###: threshold for manifestId:"
              + manifestId
              + " and source:"
              + source
              + " not found. Will add");

      if (thresholdsJson == null || thresholdsJson.length() <= THRESHOLDS_JSON_SIZE_FLOOR) {
        thresholdsJson = "n";
      }
      if (writeMode) {
        tsDao.addCiThresholds(
            ciId, manifestId, source, checksum, thresholdsJson, isHeartBeat, hbDuration);
      }
      return true;
    }
    return false;
  }
Ejemplo n.º 2
0
 private void restoreManifestMapping(Long manifestId, Long ciId, boolean writeMode) {
   if (tsDao.getManifestId(ciId) == null) {
     // add manifest mapping regardless of the monitors
     logger.info(
         "RestoreMonitor###: bom -> manifest mapping is missing for ciId: "
             + ciId
             + " for manifestId: "
             + manifestId);
     if (writeMode) {
       tsDao.addManifestMap(ciId, manifestId);
     }
   }
 }
Ejemplo n.º 3
0
 private void restoreRealizedAsMapping(Long manifestId, Set<Long> cmsBomCiIds, boolean writeMode) {
   Set<Long> opsdbBomCiId =
       tsDao.getManifestCiIds(manifestId).stream().collect(Collectors.toSet());
   for (Long bomCiId : cmsBomCiIds) {
     // add manifest mapping regardless of the monitors
     if (!opsdbBomCiId.contains(bomCiId)) {
       logger.info(
           "RestoreMonitor###: manifest -> bom mapping is missing for manifestId: "
               + manifestId
               + " for ciId: "
               + bomCiId);
       if (writeMode) {
         tsDao.addManifestMap(bomCiId, manifestId);
       }
     }
   }
 }