@Override public String toString() { return "LtRestriction [attribute=" + getAttribute() + ", value=" + getValue() + "]"; } }
public static LtRestriction lt(final String attribute, final Object comparator) { return new LtRestriction(attribute, comparator); }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public void visitLt(final LtRestriction restriction) { final Object o = getProperty(restriction); if (o instanceof java.lang.Number && restriction.getValue() instanceof java.lang.Number) { final BigDecimal left = new BigDecimal(((Number)o).doubleValue()); final BigDecimal right = new BigDecimal(((Number)restriction.getValue()).doubleValue()); if (left.compareTo(right) == -1) return; } else if (o instanceof Comparable) { try { final Comparable oC = (Comparable)o; final Comparable oV = (Comparable)restriction.getValue(); if (oC.compareTo(oV) < 0) { return; } } catch (final ClassCastException e) {} } fail(restriction); } @Override public void visitLtComplete(final LtRestriction restriction) {}
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public void visitLt(final LtRestriction restriction) { final Object o = getProperty(restriction); if (o instanceof java.lang.Number && restriction.getValue() instanceof java.lang.Number) { final BigDecimal left = new BigDecimal(((Number)o).doubleValue()); final BigDecimal right = new BigDecimal(((Number)restriction.getValue()).doubleValue()); if (left.compareTo(right) == -1) return; } else if (o instanceof Comparable) { try { final Comparable oC = (Comparable)o; final Comparable oV = (Comparable)restriction.getValue(); if (oC.compareTo(oV) < 0) { return; } } catch (final ClassCastException e) {} } fail(restriction); } @Override public void visitLtComplete(final LtRestriction restriction) {}
@Override public String toString() { return "LtRestriction [attribute=" + getAttribute() + ", value=" + getValue() + "]"; } }
public static LtRestriction lt(final String attribute, final Object comparator) { return new LtRestriction(attribute, comparator); }
@Override public void visitLt(final LtRestriction restriction) { m_criterions.add(org.hibernate.criterion.Restrictions.lt(restriction.getAttribute(), restriction.getValue())); }
/** * <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); } }
/** * <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); } }