/** {@inheritDoc} */ @Override public ThresholdGroup get(String name) { return get(name, null); }
/** * <p>initThresholdsDao</p> * @throws ThresholdInitializationException */ protected final void initThresholdsDao() throws ThresholdInitializationException { if (!m_initialized) { LOG.debug("initThresholdsDao: Initializing Factories and DAOs"); final DefaultThresholdsDao defaultThresholdsDao = new DefaultThresholdsDao(); try { ThresholdingConfigFactory.init(); defaultThresholdsDao.setThresholdingConfigFactory(ThresholdingConfigFactory.getInstance()); defaultThresholdsDao.afterPropertiesSet(); } catch (final Throwable t) { final ThresholdInitializationException tie = new ThresholdInitializationException("Could not initialize DefaultThresholdsDao.", t); LOG.error("initThresholdsDao: " + tie.getLocalizedMessage(), t); throw tie; } try { ThreshdConfigFactory.init(); } catch (final Throwable t) { final ThresholdInitializationException tie = new ThresholdInitializationException("Could not initialize ThreshdConfigFactory.", t); LOG.error("initThresholdsDao: " + tie.getLocalizedMessage(), t); throw tie; } m_thresholdsDao = defaultThresholdsDao; m_initialized = true; } }
private ThresholdGroup get(String name, ThresholdGroup group) { boolean merge = group != null; ThresholdGroup newGroup = new ThresholdGroup(name); File rrdRepository = new File(getThresholdingConfigFactory().getRrdRepository(name)); newGroup.setRrdRepository(rrdRepository); ThresholdResourceType nodeType = getThresholdResourceType(name, "node", merge ? group.getNodeResourceType() : null); newGroup.setNodeResourceType(nodeType); ThresholdResourceType ifType = getThresholdResourceType(name, "if", merge ? group.getIfResourceType() : null); newGroup.setIfResourceType(ifType); for (Basethresholddef thresh : getThresholdingConfigFactory().getThresholds(name)) { final String id = thresh.getDsType(); if (!(id.equals("if") || id.equals("node") || newGroup.getGenericResourceTypeMap().containsKey(id))) { ThresholdResourceType genericType = getThresholdResourceType(name, id, merge ? group.getGenericResourceTypeMap().get(id) : null); if (genericType.getThresholdMap().size() > 0) { LOG.info("Adding {}::{} with {} elements", name, id, genericType.getThresholdMap().size()); newGroup.getGenericResourceTypeMap().put(id, genericType); } } } return newGroup; }
private ThresholdResourceType getThresholdResourceType(String groupName, String typeName, ThresholdResourceType type) { ThresholdResourceType resourceType = new ThresholdResourceType(typeName); Map<String, Set<ThresholdEntity>> thresholdMap = null; if (type == null) { thresholdMap = new HashMap<String, Set<ThresholdEntity>>(); fillThresholdStateMap(groupName, typeName, thresholdMap); } else { thresholdMap = type.getThresholdMap(); fillThresholdStateMap(groupName, type.getDsType(), thresholdMap); } resourceType.setThresholdMap(thresholdMap); return resourceType; }
private void fillThresholdStateMap(String groupName, String typeName, Map<String, Set<ThresholdEntity>> thresholdMap) { boolean merge = !thresholdMap.isEmpty(); for (Basethresholddef thresh : getThresholdingConfigFactory().getThresholds(groupName)) { final ThresholdEntity entity = thresholdIterator.next(); boolean found = false; for (final Basethresholddef thresh : getThresholdingConfigFactory().getThresholds(groupName)) { BaseThresholdDefConfigWrapper newConfig = null; try {
/** {@inheritDoc} */ @Override public ThresholdGroup merge(ThresholdGroup group) { return get(group.getName(), group); }