use of java.util.LinkedHashSet in project opennms by OpenNMS.
the class DefaultCollectionAgentService method getSnmpInterfaceData.
/* (non-Javadoc)
* @see org.opennms.netmgt.collectd.CollectionAgent#getSnmpInterfaceInfo(org.opennms.netmgt.collectd.IfResourceType)
*/
/**
* <p>getSnmpInterfaceData</p>
*
* @return a {@link java.util.Set} object.
*/
@Override
public Set<SnmpIfData> getSnmpInterfaceData() {
Set<OnmsSnmpInterface> snmpIfs = getSnmpInterfaces();
Set<SnmpIfData> ifData = new LinkedHashSet<SnmpIfData>(snmpIfs.size());
for (OnmsSnmpInterface snmpIface : snmpIfs) {
logInitializeSnmpIf(snmpIface);
SnmpIfData snmpIfData = new SnmpIfData(snmpIface);
ifData.add(snmpIfData);
//ifInfos.add(new IfInfo(type, agent, snmpIfData));
}
return ifData;
}
use of java.util.LinkedHashSet in project OpenAM by OpenRock.
the class PropertyXMLBuilderBase method buildSchemaTypeXML.
protected void buildSchemaTypeXML(String schemaTypeName, Set attributeSchemas, StringBuffer xml, AMModel model, ResourceBundle serviceBundle, Set readonly, boolean section, boolean addSubSection) {
if (section) {
String label = "lbl" + schemaTypeName.replace('.', '_');
Object[] params = { label, schemaTypeName };
xml.append(MessageFormat.format(SECTION_START_TAG, params));
}
List sorted = new ArrayList(attributeSchemas);
if (!(attributeSchemas instanceof LinkedHashSet)) {
// Sort attribute schemas by property key if they are not sorted by section properties.
Collections.sort(sorted, new AttributeSchemaComparator(null));
}
for (Iterator iter = sorted.iterator(); iter.hasNext(); ) {
AttributeSchema as = (AttributeSchema) iter.next();
if (allAttributesReadonly || readonly.contains(as.getName())) {
buildReadonlyXML(as, xml, model, serviceBundle);
} else if (SCRIPTSELECT.equals(as.getUIType())) {
buildScriptSelectXML(as, xml, model, serviceBundle, false);
} else if (GLOBALSCRIPTSELECT.equals(as.getUIType())) {
buildScriptSelectXML(as, xml, model, serviceBundle, true);
} else {
buildAttributeSchemaTypeXML(as, xml, model, serviceBundle, addSubSection);
String tagClassName = getTagClassName(as);
if (tagClassName.equals(TAGNAME_PASSWORD)) {
buildConfirmPasswordXML(as, xml, model, serviceBundle);
}
if (AttributeSchema.Syntax.SCRIPT.equals(as.getSyntax())) {
buildFileUploadXML(as, xml, model);
}
}
}
xml.append((section ? SECTION_END_TAG : ""));
}
use of java.util.LinkedHashSet in project OpenAM by OpenRock.
the class PropertyXMLBuilderBase method getSortedChoiceValues.
private Set getSortedChoiceValues(AttributeSchema as, Map values, ResourceBundle serviceBundle) {
Set sorted = new TreeSet();
if (AttributeSchema.ListOrder.INSERTION.equals(as.getListOrder())) {
sorted = new LinkedHashSet();
}
Map tmp = new HashMap(2);
tmp.put(Constants.ORGANIZATION_NAME, getCurrentRealm());
String[] choices = as.getChoiceValues(tmp);
if ((choices != null) && (choices.length > 0)) {
for (int i = 0; i < choices.length; i++) {
String val = choices[i];
String i18nKey = as.getChoiceValueI18NKey(val);
String localizedName = null;
if ((i18nKey == null) || (i18nKey.trim().length() == 0)) {
localizedName = val;
} else {
localizedName = com.sun.identity.shared.locale.Locale.getString(serviceBundle, i18nKey, debug);
}
values.put(localizedName, val);
sorted.add(localizedName);
}
}
return sorted;
}
use of java.util.LinkedHashSet in project opennms by OpenNMS.
the class NrtController method getRequiredRrdGraphAttributes.
public Set<RrdGraphAttribute> getRequiredRrdGraphAttributes(OnmsResource reportResource, PrefabGraph prefabGraph) {
Map<String, RrdGraphAttribute> available = reportResource.getRrdGraphAttributes();
Set<RrdGraphAttribute> reqAttrs = new LinkedHashSet<RrdGraphAttribute>();
for (String attrName : prefabGraph.getColumns()) {
RrdGraphAttribute attr = available.get(attrName);
if (attr != null) {
reqAttrs.add(attr);
}
}
return reqAttrs;
}
use of java.util.LinkedHashSet in project opennms by OpenNMS.
the class DefaultThresholdsDao method fillThresholdStateMap.
private void fillThresholdStateMap(String groupName, String typeName, Map<String, Set<ThresholdEntity>> thresholdMap) {
boolean merge = !thresholdMap.isEmpty();
for (Basethresholddef thresh : getThresholdingConfigFactory().getThresholds(groupName)) {
// See if map entry already exists for this datasource; if not, create a new one.
if (thresh.getDsType().equals(typeName)) {
try {
BaseThresholdDefConfigWrapper wrapper = BaseThresholdDefConfigWrapper.getConfigWrapper(thresh);
Set<ThresholdEntity> thresholdEntitySet = thresholdMap.get(wrapper.getDatasourceExpression());
// Found set for this DS type?
if (thresholdEntitySet == null) {
// Nope, create a new set
thresholdEntitySet = new LinkedHashSet<ThresholdEntity>();
thresholdMap.put(wrapper.getDatasourceExpression(), thresholdEntitySet);
}
try {
ThresholdEntity thresholdEntity = new ThresholdEntity();
thresholdEntity.addThreshold(wrapper);
if (merge) {
boolean updated = false;
for (ThresholdEntity e : thresholdEntitySet) {
if (thresholdEntity.getThresholdConfig().equals(e.getThresholdConfig())) {
e.merge(thresholdEntity);
updated = true;
}
}
if (// Does not exist!
!updated)
thresholdEntitySet.add(thresholdEntity);
} else {
thresholdEntitySet.add(thresholdEntity);
}
} catch (IllegalStateException e) {
LOG.warn("fillThresholdStateMap: Encountered duplicate {} for datasource {}", thresh.getType(), wrapper.getDatasourceExpression(), e);
}
} catch (ThresholdExpressionException e) {
LOG.warn("fillThresholdStateMap: Could not parse threshold expression", e);
}
}
}
// Search for deleted configuration
if (merge) {
LOG.debug("fillThresholdStateMap(merge): checking if definitions that are no longer exist for group {} using type {}", groupName, typeName);
for (final Entry<String, Set<ThresholdEntity>> entry : thresholdMap.entrySet()) {
final Set<ThresholdEntity> value = entry.getValue();
for (final Iterator<ThresholdEntity> thresholdIterator = value.iterator(); thresholdIterator.hasNext(); ) {
final ThresholdEntity entity = thresholdIterator.next();
boolean found = false;
for (final Basethresholddef thresh : getThresholdingConfigFactory().getThresholds(groupName)) {
BaseThresholdDefConfigWrapper newConfig = null;
try {
newConfig = BaseThresholdDefConfigWrapper.getConfigWrapper(thresh);
} catch (ThresholdExpressionException e) {
LOG.warn("fillThresholdStateMap: Could not parse threshold expression", e);
}
if (newConfig != null && newConfig.equals(entity.getThresholdConfig())) {
found = true;
continue;
}
}
if (!found) {
LOG.info("fillThresholdStateMap(merge): deleting entity {}", entity);
entity.delete();
thresholdIterator.remove();
}
}
}
}
}
Aggregations