/** * <p>reload</p> * * @throws java.io.IOException if any. * @throws java.io.FileNotFoundException if any. */ public synchronized void reload() throws IOException, FileNotFoundException { m_instance = null; init(); }
/** {@inheritDoc} */ @Override public RrdRepository getRrdRepository(final String collectionName) { return WmiDataCollectionConfigFactory.getInstance().getRrdRepository(collectionName); }
/** * <p>Constructor for WmiDataCollectionConfigFactory.</p> * * @param is a {@link java.io.InputStream} object. */ public WmiDataCollectionConfigFactory(InputStream is) throws IOException { initialize(is); }
@Override public Map<String, Object> getRuntimeAttributes(CollectionAgent agent, Map<String, Object> parameters) { final Map<String, Object> runtimeAttributes = new HashMap<>(); final String collectionName = ParameterMap.getKeyedString(parameters, "collection", ParameterMap.getKeyedString(parameters, "wmi-collection", null)); final WmiCollection collection = WmiDataCollectionConfigFactory.getInstance().getWmiCollection(collectionName); runtimeAttributes.put(WMI_COLLECTION_KEY, collection); final WmiAgentConfig agentConfig = WmiPeerFactory.getInstance().getAgentConfig(agent.getAddress()); runtimeAttributes.put(WMI_AGENT_CONFIG_KEY, agentConfig); return runtimeAttributes; }
/** * <p>getRrdRepository</p> * * @param collectionName a {@link java.lang.String} object. * @return a {@link org.opennms.netmgt.rrd.RrdRepository} object. */ public RrdRepository getRrdRepository(String collectionName) { RrdRepository repo = new RrdRepository(); repo.setRrdBaseDir(new File(getRrdPath())); repo.setRraList(getRRAList(collectionName)); repo.setStep(getStep(collectionName)); repo.setHeartBeat((2 * getStep(collectionName))); return repo; }
/** * <p>getRRAList</p> * * @param cName a {@link java.lang.String} object. * @return a {@link java.util.List} object. */ public List<String> getRRAList(String cName) { WmiCollection collection = getWmiCollection(cName); if (collection != null) return collection.getRrd().getRra(); else return null; }
/** * Be sure to call this method before calling getInstance(). * * @throws java.io.IOException if any. * @throws java.io.FileNotFoundException if any. */ public static synchronized void init() throws IOException, FileNotFoundException { if (m_instance == null) { File cfgFile = ConfigFileConstants.getFile(ConfigFileConstants.WMI_COLLECTION_CONFIG_FILE_NAME); m_instance = new WmiDataCollectionConfigFactory(cfgFile.getPath()); m_lastModified = cfgFile.lastModified(); m_loadedFromFile = true; } }
/** * Reload the wmi-datacollection-config.xml file if it has been changed since we last * read it. * * @throws java.io.IOException if any. */ protected void updateFromFile() throws IOException { if (m_loadedFromFile) { File surveillanceViewsFile = ConfigFileConstants.getFile(ConfigFileConstants.WMI_COLLECTION_CONFIG_FILE_NAME); if (m_lastModified != surveillanceViewsFile.lastModified()) { this.reload(); } } }
@Override public Map<String, Object> getRuntimeAttributes(CollectionAgent agent, Map<String, Object> parameters) { final Map<String, Object> runtimeAttributes = new HashMap<>(); final String collectionName = ParameterMap.getKeyedString(parameters, "collection", ParameterMap.getKeyedString(parameters, "wmi-collection", null)); final WmiCollection collection = WmiDataCollectionConfigFactory.getInstance().getWmiCollection(collectionName); runtimeAttributes.put(WMI_COLLECTION_KEY, collection); final WmiAgentConfig agentConfig = WmiPeerFactory.getInstance().getAgentConfig(agent.getAddress()); runtimeAttributes.put(WMI_AGENT_CONFIG_KEY, agentConfig); return runtimeAttributes; }
/** * <p>getStep</p> * * @param cName a {@link java.lang.String} object. * @return a int. */ public int getStep(String cName) { WmiCollection collection = getWmiCollection(cName); if (collection != null) return collection.getRrd().getStep(); else return -1; }
private void initWMICollectionConfig() { LOG.debug("initialize: Initializing collector: {}", getClass()); try { WmiDataCollectionConfigFactory.init(); } catch (FileNotFoundException e) { LOG.error("initialize: Error locating configuration.", e); throw new UndeclaredThrowableException(e); } catch (IOException e) { LOG.error("initialize: Error reading configuration.", e); throw new UndeclaredThrowableException(e); } }
/** {@inheritDoc} */ @Override public RrdRepository getRrdRepository(final String collectionName) { return WmiDataCollectionConfigFactory.getInstance().getRrdRepository(collectionName); }
/** * <p>Constructor for WmiDataCollectionConfigFactory.</p> * * @param configFile a {@link java.lang.String} object. * @throws java.io.IOException if any. */ public WmiDataCollectionConfigFactory(String configFile) throws IOException { InputStream is = null; try { is = new FileInputStream(configFile); initialize(is); } finally { if (is != null) { IOUtils.closeQuietly(is); } } }
private void initWMICollectionConfig() { LOG.debug("initialize: Initializing collector: {}", getClass()); try { WmiDataCollectionConfigFactory.init(); } catch (FileNotFoundException e) { LOG.error("initialize: Error locating configuration.", e); throw new UndeclaredThrowableException(e); } catch (IOException e) { LOG.error("initialize: Error reading configuration.", e); throw new UndeclaredThrowableException(e); } }