List of usage examples for javax.ejb Timer getNextTimeout
public Date getNextTimeout() throws java.lang.IllegalStateException, javax.ejb.NoSuchObjectLocalException, javax.ejb.NoMoreTimeoutsException, javax.ejb.EJBException;
From source file:eu.agilejava.snoop.eureka.scan.EurekaClient.java
@Timeout public void health(Timer timer) { LOGGER.config(() -> "health update: " + Calendar.getInstance().getTime()); LOGGER.config(() -> "Next: " + timer.getNextTimeout()); EurekaConfig eurekaConfig = new EurekaConfig(); eurekaConfig.setStatus("UP"); Entity<InstanceConfig> entity = Entity.entity(new InstanceConfig(eurekaConfig), MediaType.APPLICATION_JSON); Response response = ClientBuilder.newClient() .target(serviceUrl + "apps/" + applicationName + "/" + applicationName).request().put(entity); LOGGER.config(() -> "PUT resulted in: " + response.getStatus() + ", " + response.getEntity()); }
From source file:eu.agilejava.snoop.scan.SnoopClient.java
@Timeout public void health(Timer timer) { LOGGER.config(() -> "health update: " + Calendar.getInstance().getTime()); LOGGER.config(() -> "Next: " + timer.getNextTimeout()); sendMessage(STATUS_ENDPOINT + applicationName, "UP"); }
From source file:eu.agilejava.snoop.scan.SnoopRegistrationClient.java
@Timeout public void health(Timer timer) { LOGGER.config(() -> "health update: " + Calendar.getInstance().getTime()); LOGGER.config(() -> "Next: " + timer.getNextTimeout()); sendMessage(STATUS_ENDPOINT + applicationConfig.getServiceName(), applicationConfig.toJSON()); }
From source file:be.fedict.trust.service.bean.SchedulingServiceBean.java
/** * {@inheritDoc}/*ww w .j av a 2s .c om*/ */ public void startTimerNow(TrustPointEntity trustPoint) { TimerConfig timerConfig = new TimerConfig(); timerConfig.setInfo(trustPoint.getName()); timerConfig.setPersistent(false); Timer timer = this.timerService.createSingleActionTimer(1000 * 10, timerConfig); LOG.debug("created single action timer for trustpoint " + trustPoint.getName() + " at " + timer.getNextTimeout().toString()); }
From source file:be.fedict.trust.service.bean.SchedulingServiceBean.java
/** * {@inheritDoc}//ww w.ja v a 2s . co m */ public void startTimer(ClockDriftConfigEntity clockDriftConfig) throws InvalidCronExpressionException { LOG.debug("start timer for clock drift detection"); if (null == clockDriftConfig.getCronSchedule() || clockDriftConfig.getCronSchedule().isEmpty()) { LOG.debug("no interval set for clock drift, ignoring..."); return; } // remove old timers cancelTimers(TrustServiceConstants.CLOCK_DRIFT_TIMER); TimerConfig timerConfig = new TimerConfig(); timerConfig.setInfo(TrustServiceConstants.CLOCK_DRIFT_TIMER); timerConfig.setPersistent(false); ScheduleExpression schedule = getScheduleExpression(clockDriftConfig.getCronSchedule()); Timer timer; try { timer = this.timerService.createCalendarTimer(schedule, timerConfig); } catch (Exception e) { LOG.error("Exception while creating timer for clock drift: " + e.getMessage(), e); throw new InvalidCronExpressionException(e); } LOG.debug("created timer for clock drift at " + timer.getNextTimeout().toString()); clockDriftConfig.setFireDate(timer.getNextTimeout()); }
From source file:be.fedict.eid.dss.model.bean.DocumentServiceBean.java
/** * {@inheritDoc}//from w ww . j av a 2s.c o m */ @Timeout public void timeOut(Timer timer) { String timerInfo = (String) timer.getInfo(); LOG.debug("timeout: " + timerInfo); if (null == timerInfo) { LOG.error("no timer info ?? cancel timer"); timer.cancel(); return; } if (timerInfo.equals(TIMER_ID)) { cleanup(); LOG.debug("Next cleanup: " + timer.getNextTimeout()); } }
From source file:be.fedict.trust.service.bean.SchedulingServiceBean.java
/** * {@inheritDoc}//from w ww . j a va 2 s . c o m */ public void startTimer(TrustPointEntity trustPoint) throws InvalidCronExpressionException { LOG.debug("start timer for " + trustPoint.getName()); if (null == trustPoint.getCrlRefreshCronSchedule() || trustPoint.getCrlRefreshCronSchedule().isEmpty()) { LOG.debug("no CRL refresh set for trust point " + trustPoint.getName() + " ignoring..."); return; } // remove old timers cancelTimers(trustPoint.getName()); TimerConfig timerConfig = new TimerConfig(); timerConfig.setInfo(trustPoint.getName()); timerConfig.setPersistent(false); ScheduleExpression schedule = getScheduleExpression(trustPoint.getCrlRefreshCronSchedule()); Timer timer; try { timer = this.timerService.createCalendarTimer(schedule, timerConfig); } catch (Exception e) { LOG.error("Exception while creating timer for clock drift: " + e.getMessage(), e); throw new InvalidCronExpressionException(e); } LOG.debug("created timer for trustpoint " + trustPoint.getName() + " at " + timer.getNextTimeout().toString()); trustPoint.setFireDate(timer.getNextTimeout()); }
From source file:be.fedict.eid.dss.model.bean.DocumentServiceBean.java
/** * {@inheritDoc}/*w w w. ja va 2 s.c o m*/ */ public void startTimer(String cronSchedule) throws InvalidCronExpressionException { LOG.debug("start document service's cleanup task timer"); if (null == cronSchedule || cronSchedule.isEmpty()) { // TODO: error message sufficient? or explode here?... LOG.error("No interval set for document service cleanup task!"); return; } // remove old timers cancelTimers(); TimerConfig timerConfig = new TimerConfig(); timerConfig.setInfo(TIMER_ID); timerConfig.setPersistent(true); ScheduleExpression schedule = getScheduleExpression(cronSchedule); Timer timer; try { timer = this.timerService.createCalendarTimer(schedule, timerConfig); } catch (Exception e) { LOG.error("Exception while creating timer for document service " + "cleanup task: " + e.getMessage(), e); throw new InvalidCronExpressionException(e); } LOG.debug("created timer for document service cleanup task: next=" + timer.getNextTimeout().toString()); }
From source file:edu.harvard.iq.dvn.core.index.IndexServiceBean.java
public void createIndexTimer() { for (Iterator it = timerService.getTimers().iterator(); it.hasNext();) { Timer timer = (Timer) it.next(); if (timer.getInfo().equals(INDEX_TIMER)) { logger.info("Cannot create IndexTimer, timer already exists."); logger.info("IndexTimer next timeout is " + timer.getNextTimeout()); return; }//from ww w . j a v a2 s . co m } Calendar cal = Calendar.getInstance(); cal.add(Calendar.DAY_OF_YEAR, 1); cal.set(Calendar.HOUR_OF_DAY, 1); logger.log(Level.INFO, "Indexer timer set for " + cal.getTime()); Date initialExpiration = cal.getTime(); // First timeout is 1:00 AM of next day long intervalDuration = 1000 * 60 * 60 * 24; // repeat every 24 hours timerService.createTimer(initialExpiration, intervalDuration, INDEX_TIMER); }
From source file:edu.harvard.iq.dvn.core.index.IndexServiceBean.java
public void createCollectionIndexTimer() { for (Iterator it = timerService.getTimers().iterator(); it.hasNext();) { Timer timer = (Timer) it.next(); if (timer.getInfo().equals(COLLECTION_INDEX_TIMER)) { logger.info("Cannot create COllectionIndexTimer, timer already exists."); logger.info("IndexTimer next timeout is " + timer.getNextTimeout()); return; }/*from ww w .ja v a2s .c o m*/ } Calendar cal = Calendar.getInstance(); cal.add(Calendar.MINUTE, 5); // First run 5 minutes from now Date initialRun = cal.getTime(); long intervalInMinutes = 60; // default value String intervalJVMOption = System.getProperty("dvn.index.collection.reindex.interval"); if (intervalJVMOption != null) { Long intervalValue = null; try { intervalValue = new Long(intervalJVMOption); } catch (Exception ex) { } if (intervalValue != null && (intervalValue.longValue() > 0L)) { intervalInMinutes = intervalValue.longValue(); } } long intervalDuration = 1000 * 60 * intervalInMinutes; timerService.createTimer(initialRun, intervalDuration, COLLECTION_INDEX_TIMER); logger.log(Level.INFO, "Collection index timer set for " + initialRun); }