public static NotNullRestriction isNotNull(final String attribute) { return new NotNullRestriction(attribute); }
@Override public String toString() { return "NotNullRestriction [attribute=" + getAttribute() + "]"; }
public static NotNullRestriction isNotNull(final String attribute) { return new NotNullRestriction(attribute); }
@Override public String toString() { return "NotNullRestriction [attribute=" + getAttribute() + "]"; }
/** * <p>checkForDisconnectedMonitors</p> */ @Override public void checkForDisconnectedMonitors() { LOG.debug("Checking for disconnected monitors: disconnectedTimeout = {}", m_disconnectedTimeout); try { final Date now = m_timeKeeper.getCurrentDate(); final Date earliestAcceptable = new Date(now.getTime() - m_disconnectedTimeout); final Criteria criteria = new Criteria(OnmsLocationMonitor.class); criteria.addRestriction(new EqRestriction("status", MonitorStatus.STARTED)); criteria.addRestriction(new NotNullRestriction("lastUpdated")); criteria.addRestriction(new LtRestriction("lastUpdated", earliestAcceptable)); // Lock all of the records for update since we will be marking them as DISCONNECTED criteria.setLockType(LockType.PESSIMISTIC_READ); final Collection<OnmsLocationMonitor> monitors = m_locMonDao.findMatching(criteria); LOG.debug("Found {} monitor(s) that are transitioning to disconnected state", monitors.size()); for (final OnmsLocationMonitor monitor : monitors) { LOG.debug("Monitor {} has stopped responding", monitor.getName()); monitor.setStatus(MonitorStatus.DISCONNECTED); m_locMonDao.update(monitor); sendDisconnectedEvent(monitor); } } catch (final Throwable e) { LOG.warn("An error occurred checking for disconnected monitors.", e); } }
@Override public void visitNotNull(final NotNullRestriction restriction) { m_criterions.add(org.hibernate.criterion.Restrictions.isNotNull(restriction.getAttribute())); }
/** * <p>checkForDisconnectedMonitors</p> */ @Override public void checkForDisconnectedMonitors() { LOG.debug("Checking for disconnected monitors: disconnectedTimeout = {}", m_disconnectedTimeout); try { final Date now = m_timeKeeper.getCurrentDate(); final Date earliestAcceptable = new Date(now.getTime() - m_disconnectedTimeout); final Criteria criteria = new Criteria(OnmsLocationMonitor.class); criteria.addRestriction(new EqRestriction("status", MonitorStatus.STARTED)); criteria.addRestriction(new NotNullRestriction("lastUpdated")); criteria.addRestriction(new LtRestriction("lastUpdated", earliestAcceptable)); // Lock all of the records for update since we will be marking them as DISCONNECTED criteria.setLockType(LockType.PESSIMISTIC_READ); final Collection<OnmsLocationMonitor> monitors = m_locMonDao.findMatching(criteria); LOG.debug("Found {} monitor(s) that are transitioning to disconnected state", monitors.size()); for (final OnmsLocationMonitor monitor : monitors) { LOG.debug("Monitor {} has stopped responding", monitor.getName()); monitor.setStatus(MonitorStatus.DISCONNECTED); m_locMonDao.update(monitor); sendDisconnectedEvent(monitor); } } catch (final Throwable e) { LOG.warn("An error occurred checking for disconnected monitors.", e); } }