private boolean configIntervalExceedsMinimalInterval(final Date currentConfigurationVersion) { return m_minimumConfigurationReloadInterval > 0 && (m_timeKeeper.getCurrentTime() - currentConfigurationVersion.getTime()) > m_minimumConfigurationReloadInterval; }
/** * <p>configurationUpdated</p> */ @Override public void configurationUpdated() { m_configurationTimestamp.set(m_timeKeeper.getCurrentDate()); m_configCache.set(new ConcurrentHashMap<String, SimplePollerConfiguration>()); }
protected TimeZone getTimeZone() { return myTimeKeeper().getTimeZone(); }
private boolean configIntervalExceedsMinimalInterval(final Date currentConfigurationVersion) { return m_minimumConfigurationReloadInterval > 0 && (m_timeKeeper.getCurrentTime() - currentConfigurationVersion.getTime()) > m_minimumConfigurationReloadInterval; }
/** * <p>configurationUpdated</p> */ @Override public void configurationUpdated() { m_configurationTimestamp.set(m_timeKeeper.getCurrentDate()); m_configCache.set(new ConcurrentHashMap<String, SimplePollerConfiguration>()); }
/** * <p>getCurrentTime</p> * * @return a long. */ protected long getCurrentTime() { return myTimeKeeper().getCurrentTime(); }
/** {@inheritDoc} */ @Override public void pollerStopping(final String locationMonitorId) { final OnmsLocationMonitor mon = m_locMonDao.get(locationMonitorId); if (mon == null) { LOG.info("pollerStopping was called for location monitor ID {} which does not exist", locationMonitorId); return; } if (mon.getStatus() != MonitorStatus.PAUSED) { mon.setStatus(MonitorStatus.STOPPED); } mon.setLastUpdated(m_timeKeeper.getCurrentDate()); m_locMonDao.update(mon); sendMonitorStoppedEvent(mon); }
/** * Commit. * * @throws PersistException the persist exception */ @Override public void commit() throws PersistException { if (m_dbl_declarations.size() == 0 && m_str_declarations.size() == 0) { return; } try { final String ownerName = m_resource.getOwnerName(); final String absolutePath = getResourceDir(m_resource).getAbsolutePath(); String rrdFile = absolutePath + File.separator + m_rrdName + fileExt; long timestamp = m_timeKeeper.getCurrentTime(); long time = (timestamp + 500L) / 1000L; m_tcpStrategy.updateData(rrdFile, ownerName, new Long(time), getDblValues(), getStrValues()); } catch (FileNotFoundException e) { LoggerFactory.getLogger(getClass()).warn("Could not get resource directory: " + e.getMessage(), e); return; } catch (Exception e) { throw new PersistException(e); } }
/** {@inheritDoc} */ @Override public void pollerStopping(final String locationMonitorId) { final OnmsLocationMonitor mon = m_locMonDao.get(locationMonitorId); if (mon == null) { LOG.info("pollerStopping was called for location monitor ID {} which does not exist", locationMonitorId); return; } if (mon.getStatus() != MonitorStatus.PAUSED) { mon.setStatus(MonitorStatus.STOPPED); } mon.setLastUpdated(m_timeKeeper.getCurrentDate()); m_locMonDao.update(mon); sendMonitorStoppedEvent(mon); }
/** * <p>commit</p> * * @throws org.opennms.netmgt.collection.api.PersistException if any. */ public void commit() throws PersistException { if (m_declarations.size() == 0) { // Nothing to do. In fact, we'll get an error if we try to create an RRD file with no data sources return; } try { final String ownerName = m_resource.getOwnerName(); final String absolutePath = getResourceDir(m_resource); RrdMetaDataUtils.createMetaDataFile(absolutePath, m_rrdName, m_metaData); List<RrdDataSource> dataSources = getDataSources(); if (dataSources != null && dataSources.size() > 0) { createRRD(m_rrdStrategy, ownerName, absolutePath, m_rrdName, getRepository().getStep(), dataSources, getRepository().getRraList()); updateRRD(m_rrdStrategy, ownerName, absolutePath, m_rrdName, m_timeKeeper.getCurrentTime(), getValues()); } } catch (FileNotFoundException e) { LoggerFactory.getLogger(getClass()).warn("Could not get resource directory: " + e.getMessage(), e); return; } catch (RrdException e) { throw new PersistException(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); } }
Timestamp timestamp = Timestamp.fromEpochMillis(m_timeKeeper.getCurrentTime()); for (Entry<CollectionAttributeType, Number> entry : m_declarations.entrySet()) { CollectionAttributeType attrType = entry.getKey();
/** * <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); } }
Timestamp timestamp = Timestamp.fromEpochMillis(m_timeKeeper.getCurrentTime()); for (Entry<CollectionAttributeType, Number> entry : m_declarations.entrySet()) { CollectionAttributeType attrType = entry.getKey();
/** {@inheritDoc} */ @Override public boolean pollerStarting(final String locationMonitorId, final Map<String, String> pollerDetails) { final OnmsLocationMonitor mon = m_locMonDao.get(locationMonitorId); if (mon == null) { return false; } mon.setStatus(MonitorStatus.STARTED); mon.setLastUpdated(m_timeKeeper.getCurrentDate()); updateConnectionHostDetails(mon, pollerDetails); m_locMonDao.update(mon); sendMonitorStartedEvent(mon); return true; }
/** * <p>commit</p> * * @throws org.opennms.netmgt.collection.api.PersistException if any. */ public void commit() throws PersistException { if (m_declarations.size() == 0) { // Nothing to do. In fact, we'll get an error if we try to create an RRD file with no data sources return; } try { final String ownerName = m_resource.getOwnerName(); final String absolutePath = getResourceDir(m_resource); RrdMetaDataUtils.createMetaDataFile(absolutePath, m_rrdName, m_metaData); List<RrdDataSource> dataSources = getDataSources(); if (dataSources != null && dataSources.size() > 0) { createRRD(m_rrdStrategy, ownerName, absolutePath, m_rrdName, getRepository().getStep(), dataSources, getRepository().getRraList()); updateRRD(m_rrdStrategy, ownerName, absolutePath, m_rrdName, m_timeKeeper.getCurrentTime(), getValues()); } } catch (FileNotFoundException e) { LoggerFactory.getLogger(getClass()).warn("Could not get resource directory: " + e.getMessage(), e); return; } catch (RrdException e) { throw new PersistException(e); } }
/** {@inheritDoc} */ @Override public boolean pollerStarting(final String locationMonitorId, final Map<String, String> pollerDetails) { final OnmsLocationMonitor mon = m_locMonDao.get(locationMonitorId); if (mon == null) { return false; } mon.setStatus(MonitorStatus.STARTED); mon.setLastUpdated(m_timeKeeper.getCurrentDate()); updateConnectionHostDetails(mon, pollerDetails); m_locMonDao.update(mon); sendMonitorStartedEvent(mon); return true; }
private MonitorStatus updateMonitorState(final OnmsLocationMonitor mon, final Date currentConfigurationVersion) { try { switch(mon.getStatus()) { case DISCONNECTED: sendReconnectedEvent(mon); mon.setStatus(MonitorStatus.STARTED); return checkForGlobalConfigChange(currentConfigurationVersion); case STARTED: mon.setStatus(MonitorStatus.STARTED); return checkForGlobalConfigChange(currentConfigurationVersion); case PAUSED: mon.setStatus(MonitorStatus.PAUSED); return MonitorStatus.PAUSED; case CONFIG_CHANGED: mon.setStatus(MonitorStatus.STARTED); return MonitorStatus.CONFIG_CHANGED; default: LOG.error("Unexpected monitor state for monitor: {}", mon); throw new IllegalStateException("Unexpected monitor state for monitor: "+mon); } } finally { mon.setLastUpdated(m_timeKeeper.getCurrentDate()); updateConnectionHostDetails(mon, mon.getProperties()); m_locMonDao.update(mon); } }
private MonitorStatus updateMonitorState(final OnmsLocationMonitor mon, final Date currentConfigurationVersion) { try { switch(mon.getStatus()) { case DISCONNECTED: sendReconnectedEvent(mon); mon.setStatus(MonitorStatus.STARTED); return checkForGlobalConfigChange(currentConfigurationVersion); case STARTED: mon.setStatus(MonitorStatus.STARTED); return checkForGlobalConfigChange(currentConfigurationVersion); case PAUSED: mon.setStatus(MonitorStatus.PAUSED); return MonitorStatus.PAUSED; case CONFIG_CHANGED: mon.setStatus(MonitorStatus.STARTED); return MonitorStatus.CONFIG_CHANGED; default: LOG.error("Unexpected monitor state for monitor: {}", mon); throw new IllegalStateException("Unexpected monitor state for monitor: "+mon); } } finally { mon.setLastUpdated(m_timeKeeper.getCurrentDate()); updateConnectionHostDetails(mon, mon.getProperties()); m_locMonDao.update(mon); } }