Example #1
0
 @Override
 public void run() {
   reportStatus.setCurrentProcess(ReportStatusInfo.ReportEngineProcess.DredgeTask);
   try {
     updateCacheFromLdap();
   } catch (Exception e) {
     if (e instanceof PwmException) {
       if (((PwmException) e).getErrorInformation().getError()
           == PwmError.ERROR_DIRECTORY_UNAVAILABLE) {
         if (executorService != null) {
           LOGGER.error(
               PwmConstants.REPORTING_SESSION_LABEL,
               "directory unavailable error during background DredgeTask, will retry; error: "
                   + e.getMessage());
           executorService.schedule(new DredgeTask(), 10, TimeUnit.MINUTES);
         }
       } else {
         LOGGER.error(
             PwmConstants.REPORTING_SESSION_LABEL,
             "error during background DredgeTask: " + e.getMessage());
       }
     }
   } finally {
     reportStatus.setCurrentProcess(ReportStatusInfo.ReportEngineProcess.None);
   }
 }
 protected Audit waitForAuditToComplete(Audit audit) {
   LOGGER.debug(
       "WAIT FOR AUDIT TO COMPLETE:"
           + audit
           + ","
           + (long) (audit.getDateOfCreation().getTime() / 1000));
   Long token = new Date().getTime();
   this.getAuditExecutionList().put(audit, token);
   // while the audit is not seen as completed or crashed
   while (!this.getAuditCompletedList().containsKey(token)
       && !this.getAuditCrashedList().containsKey(token)) {
     try {
       Thread.sleep(500);
     } catch (InterruptedException ex) {
       LOGGER.error("", ex);
     }
   }
   if ((audit = this.getAuditCompletedList().get(token)) != null) {
     this.getAuditCompletedList().remove(token);
     return audit;
   }
   if ((audit = this.getAuditCrashedList().get(token).getKey()) != null) {
     this.getAuditCrashedList().remove(token);
     return audit;
   }
   return null;
 }
 @Override
 public void auditCrashed(Audit audit, Exception exception) {
   String url = "";
   if (audit.getSubject() != null) {
     url = audit.getSubject().getURL();
   }
   LOGGER.error(
       "AUDIT CRASHED:"
           + audit
           + ","
           + url
           + ","
           + (long) (audit.getDateOfCreation().getTime() / 1000),
       exception);
   Audit auditCrashed = null;
   for (Audit auditRunning : this.auditExecutionList.keySet()) {
     if (auditRunning.getId().equals(audit.getId())
         && (long) (auditRunning.getDateOfCreation().getTime() / 1000)
             == (long) (audit.getDateOfCreation().getTime() / 1000)) {
       auditCrashed = auditRunning;
       break;
     }
   }
   if (auditCrashed != null) {
     Long token = this.auditExecutionList.get(auditCrashed);
     this.auditExecutionList.remove(auditCrashed);
     this.auditCrashedList.put(token, new AbstractMap.SimpleImmutableEntry<>(audit, exception));
     this.exception = exception;
   }
 }
Example #4
0
 @Override
 public void run() {
   try {
     initTempData();
   } catch (LocalDBException | PwmUnrecoverableException e) {
     LOGGER.error(
         PwmConstants.REPORTING_SESSION_LABEL, "error during initialization: " + e.getMessage());
     status = STATUS.CLOSED;
     return;
   }
   final long secondsUntilNextDredge =
       settings.getJobOffsetSeconds()
           + TimeDuration.fromCurrent(Helper.nextZuluZeroTime()).getTotalSeconds();
   executorService.scheduleAtFixedRate(
       new DredgeTask(),
       secondsUntilNextDredge,
       TimeDuration.DAY.getTotalSeconds(),
       TimeUnit.SECONDS);
   executorService.scheduleAtFixedRate(
       new RolloverTask(),
       secondsUntilNextDredge + 1,
       TimeDuration.DAY.getTotalSeconds(),
       TimeUnit.SECONDS);
   executorService.submit(new RolloverTask());
 }
Example #5
0
 public void run() {
   try {
     publishStatisticsToCloud();
   } catch (Exception e) {
     LOGGER.error("error publishing statistics to cloud: " + e.getMessage());
   }
 }
 public void run() {
   try {
     reduceWordDB();
   } catch (LocalDBException e) {
     LOGGER.error("error during old record purge: " + e.getMessage());
   }
 }
Example #7
0
 public void close() {
   if (resultSet != null) {
     try {
       resultSet.close();
     } catch (SQLException e) {
       LOGGER.error("error closing inner resultset in iterator: " + e.getMessage());
     }
   }
   finished = true;
 }
 @Override
 public void onMessage(String key, String msg) {
   if (LOGGER.isInfoEnabled()) {
     LOGGER.info("redis event: " + key + " = " + msg);
   }
   if (msg.equals(Constants.REGISTER) || msg.equals(Constants.UNREGISTER)) {
     try {
       Jedis jedis = jedisPool.getResource();
       try {
         doNotify(jedis, key);
       } finally {
         jedis.close();
       }
     } catch (Throwable t) {
       LOGGER.error(t.getMessage(), t);
     }
   }
 }
 @Override
 public String getSwaggerType(Property p) {
   String swaggerType = super.getSwaggerType(p);
   String type;
   if (typeMapping.containsKey(swaggerType)) {
     type = typeMapping.get(swaggerType);
     if (languageSpecificPrimitives.contains(type)
         || type.indexOf(".") >= 0
         || type.equals("Map")
         || type.equals("List")
         || type.equals("File")
         || type.equals("Date")) {
       return type;
     }
   } else {
     type = swaggerType;
   }
   if (null == type) {
     LOGGER.error("No Type defined for Property " + p);
   }
   return toModelName(type);
 }
 @Override
 public void run() {
   try {
     while (running) {
       int retryTimes = 0;
       for (Map.Entry<String, JedisPool> entry : jedisPools.entrySet()) {
         try {
           JedisPool jedisPool = entry.getValue();
           jedis = jedisPool.getResource();
           if (listenNodePath.equals(monitorId) && !redisAvailable) {
             redisAvailable = true;
             appContext.getRegistryStatMonitor().setAvailable(redisAvailable);
           }
           try {
             retryTimes = 0;
             jedis.subscribe(new NotifySub(jedisPool), listenNodePath); // 阻塞
             break;
           } finally {
             jedis.close();
           }
         } catch (Throwable t) { // 重试另一台
           LOGGER.warn(
               "Failed to subscribe node from redis registry. registry: " + entry.getKey(), t);
           if (++retryTimes % jedisPools.size() == 0) {
             // 如果在所有redis都不可用,需要休息一会,避免空转占用过多cpu资源
             sleep(reconnectPeriod);
             if (listenNodePath.equals(monitorId) && redisAvailable) {
               redisAvailable = false;
               appContext.getRegistryStatMonitor().setAvailable(redisAvailable);
             }
           }
         }
       }
     }
   } catch (Throwable t) {
     LOGGER.error(t.getMessage(), t);
   }
 }
 private BoundingBox getBoundingBox(Envelope env, CoordinateReferenceSystem crs) {
   BoundingBox bBox = new BoundingBox();
   if (crs != null) {
     Integer code = null;
     try {
       code = Integer.valueOf(crs.getAuthorityKey());
     } catch (NumberFormatException ex) {
       LOGGER.error("Cannot find a unique authority key from the crs " + crs.getName(), ex);
     }
     if (code != null) {
       bBox.setCRS("EPSG:" + code);
     } else {
       return null;
     }
   } else {
     return null;
   }
   bBox.setMaxx(env.getMaxX());
   bBox.setMinx(env.getMinX());
   bBox.setMiny(env.getMinY());
   bBox.setMaxy(env.getMaxY());
   return bBox;
 }