List of usage examples for org.apache.commons.collections15.map MultiKeyMap MultiKeyMap
public MultiKeyMap()
HashedMap
. From source file:lcmc.common.ui.EditableInfo.java
/** Adds parameters to the panel. */ private void addParams(final JPanel optionsPanel, final String prefix, final String[] params, final MyButton thisApplyButton, final int leftWidth, final int rightWidth, final Map<String, Widget> sameAsFields) { swingUtils.isSwingThread();/*from w ww. j a va 2s . co m*/ if (params == null) { return; } final MultiKeyMap<String, JPanel> panelPartsMap = new MultiKeyMap<String, JPanel>(); final Collection<PanelPart> panelPartsList = new ArrayList<PanelPart>(); final MultiKeyMap<String, Integer> panelPartRowsMap = new MultiKeyMap<String, Integer>(); for (final String param : params) { final Widget paramWi = createWidget(param, prefix, rightWidth); /* sub panel */ final String section = getSection(param); final JPanel panel; final AccessMode.Type accessType = getAccessType(param); final String accessTypeString = accessType.toString(); final Boolean advanced = isAdvanced(param); final String advancedString = advanced.toString(); if (panelPartsMap.containsKey(section, accessTypeString, advancedString)) { panel = panelPartsMap.get(section, accessTypeString, advancedString); panelPartRowsMap.put(section, accessTypeString, advancedString, panelPartRowsMap.get(section, accessTypeString, advancedString) + 1); } else { panel = new JPanel(new SpringLayout()); panel.setBackground(getSectionColor(section)); if (advanced) { advancedPanelList.add(panel); panel.setVisible(access.isAdvancedMode()); } panelPartsMap.put(section, accessTypeString, advancedString, panel); panelPartsList.add(new PanelPart(section, accessType, advanced)); panelPartRowsMap.put(section, accessTypeString, advancedString, 1); } /* label */ final JLabel label = new JLabel(getParamShortDesc(param)); final String longDesc = getParamLongDesc(param); paramWi.setLabel(label, longDesc); /* tool tip */ paramWi.setToolTipText(getToolTipText(param, paramWi)); label.setToolTipText(longDesc + additionalToolTip(param)); int height = 0; if (paramWi instanceof Label) { height = application.getDefaultSize("Browser.LabelFieldHeight"); } addField(panel, label, paramWi.getComponent(), leftWidth, rightWidth, height); } final boolean wizard = Widget.WIZARD_PREFIX.equals(prefix); for (final String param : params) { final Widget paramWi = getWidget(param, prefix); if (wizard) { final Widget rpwi = getWidget(param, null); if (rpwi == null) { LOG.error("addParams: unknown param: " + param); continue; } if (paramWi.getValue() == null || paramWi.getValue().isNothingSelected()) { rpwi.setValueAndWait(null); } else { final Value value = paramWi.getValue(); rpwi.setValueAndWait(value); } } } for (final String param : params) { final Widget paramWi = getWidget(param, prefix); Widget rpwi = null; if (wizard) { rpwi = getWidget(param, null); } final Widget realParamWi = rpwi; paramWi.addListeners(new WidgetListener() { @Override public void check(final Value value) { checkParameterFields(paramWi, realParamWi, param, getParametersFromXML(), thisApplyButton); } }); } /* add sub panels to the option panel */ final Map<String, JPanel> sectionMap = new HashMap<String, JPanel>(); final Collection<JPanel> notAdvancedSections = new HashSet<JPanel>(); final Collection<JPanel> advancedSections = new HashSet<JPanel>(); for (final PanelPart panelPart : panelPartsList) { final String section = panelPart.getSection(); final AccessMode.Type accessType = panelPart.getType(); final String accessTypeString = accessType.toString(); final Boolean advanced = panelPart.isAdvanced(); final String advancedString = advanced.toString(); final JPanel panel = panelPartsMap.get(section, accessTypeString, advancedString); final int rows = panelPartRowsMap.get(section, accessTypeString, advancedString); final int columns = 2; SpringUtilities.makeCompactGrid(panel, rows, columns, 1, 1, // initX, initY 1, 1); // xPad, yPad final JPanel sectionPanel; if (sectionMap.containsKey(section)) { sectionPanel = sectionMap.get(section); } else { sectionPanel = getParamPanel(getSectionDisplayName(section), getSectionColor(section)); sectionMap.put(section, sectionPanel); addSectionPanel(section, wizard, sectionPanel); optionsPanel.add(sectionPanel); if (sameAsFields != null) { final Widget sameAsCombo = sameAsFields.get(section); if (sameAsCombo != null) { final JPanel saPanel = new JPanel(new SpringLayout()); saPanel.setBackground(Browser.BUTTON_PANEL_BACKGROUND); final JLabel label = new JLabel(Tools.getString("ClusterBrowser.SameAs")); sameAsCombo.setLabel(label, ""); addField(saPanel, label, sameAsCombo.getComponent(), leftWidth, rightWidth, 0); SpringUtilities.makeCompactGrid(saPanel, 1, 2, 1, 1, // initX, initY 1, 1); // xPad, yPad sectionPanel.add(saPanel); } } } sectionPanel.setVisible(isSectionEnabled(section)); sectionPanel.add(panel); if (advanced) { advancedSections.add(sectionPanel); } else { notAdvancedSections.add(sectionPanel); } } boolean advanced = false; for (final Map.Entry<String, JPanel> sectionEntry : sectionMap.entrySet()) { final JPanel sectionPanel = sectionEntry.getValue(); if (advancedSections.contains(sectionPanel)) { advanced = true; } if (!notAdvancedSections.contains(sectionPanel)) { advancedOnlySectionList.add(sectionEntry.getKey()); sectionPanel.setVisible(access.isAdvancedMode() && isSectionEnabled(sectionEntry.getKey())); } } moreOptionsPanel.setVisible(advanced && !access.isAdvancedMode()); }
From source file:lcmc.gui.resources.EditableInfo.java
/** Adds parameters to the panel. */ private void addParams(final JPanel optionsPanel, final String prefix, final String[] params, final MyButton thisApplyButton, final int leftWidth, final int rightWidth, final Map<String, Widget> sameAsFields) { if (params == null) { return;//from ww w .j av a 2 s . co m } final MultiKeyMap<String, JPanel> panelPartsMap = new MultiKeyMap<String, JPanel>(); final List<PanelPart> panelPartsList = new ArrayList<PanelPart>(); final MultiKeyMap<String, Integer> panelPartRowsMap = new MultiKeyMap<String, Integer>(); for (final String param : params) { final Widget paramWi = createWidget(param, prefix, rightWidth); /* sub panel */ final String section = getSection(param); JPanel panel; final ConfigData.AccessType accessType = getAccessType(param); final String accessTypeString = accessType.toString(); final Boolean advanced = isAdvanced(param); final String advancedString = advanced.toString(); if (panelPartsMap.containsKey(section, accessTypeString, advancedString)) { panel = panelPartsMap.get(section, accessTypeString, advancedString); panelPartRowsMap.put(section, accessTypeString, advancedString, panelPartRowsMap.get(section, accessTypeString, advancedString) + 1); } else { panel = new JPanel(new SpringLayout()); panel.setBackground(Browser.PANEL_BACKGROUND); if (advanced) { advancedPanelList.add(panel); final JPanel p = panel; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { p.setVisible(Tools.getConfigData().isAdvancedMode()); } }); } panelPartsMap.put(section, accessTypeString, advancedString, panel); panelPartsList.add(new PanelPart(section, accessType, advanced)); panelPartRowsMap.put(section, accessTypeString, advancedString, 1); } /* label */ final JLabel label = new JLabel(getParamShortDesc(param)); final String longDesc = getParamLongDesc(param); paramWi.setLabel(label, longDesc); /* tool tip */ SwingUtilities.invokeLater(new Runnable() { @Override public void run() { paramWi.setToolTipText(getToolTipText(param)); label.setToolTipText(longDesc); } }); int height = 0; if (paramWi.getType() == Widget.Type.LABELFIELD) { height = Tools.getDefaultSize("Browser.LabelFieldHeight"); } addField(panel, label, paramWi, leftWidth, rightWidth, height); } for (final String param : params) { final Widget paramWi = getWidget(param, prefix); Widget rpwi = null; if ("wizard".equals(prefix)) { rpwi = getWidget(param, null); if (rpwi == null) { Tools.appError("unkown param: " + param + ". Man pages not installed?"); continue; } int height = 0; if (rpwi.getType() == Widget.Type.LABELFIELD) { height = Tools.getDefaultSize("Browser.LabelFieldHeight"); } final Widget rpwi0 = rpwi; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { if (paramWi.getValue() == null || paramWi.getValue() == Widget.NOTHING_SELECTED) { rpwi0.setValueAndWait(null); } else { final Object value = paramWi.getStringValue(); rpwi0.setValueAndWait(value); } } }); } } for (final String param : params) { final Widget paramWi = getWidget(param, prefix); Widget rpwi = null; if ("wizard".equals(prefix)) { rpwi = getWidget(param, null); } final Widget realParamWi = rpwi; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { paramWi.addListeners(new WidgetListener() { @Override public void check(final Object value) { checkParameterFields(paramWi, realParamWi, param, params, thisApplyButton); } }); } }); } /* add sub panels to the option panel */ final Map<String, JPanel> sectionMap = new HashMap<String, JPanel>(); final Set<JPanel> notAdvancedSections = new HashSet<JPanel>(); final Set<JPanel> advancedSections = new HashSet<JPanel>(); for (final PanelPart panelPart : panelPartsList) { final String section = panelPart.getSection(); final ConfigData.AccessType accessType = panelPart.getAccessType(); final String accessTypeString = accessType.toString(); final Boolean advanced = panelPart.isAdvanced(); final String advancedString = advanced.toString(); final JPanel panel = panelPartsMap.get(section, accessTypeString, advancedString); final int rows = panelPartRowsMap.get(section, accessTypeString, advancedString); final int columns = 2; SpringUtilities.makeCompactGrid(panel, rows, columns, 1, 1, // initX, initY 1, 1); // xPad, yPad JPanel sectionPanel; if (sectionMap.containsKey(section)) { sectionPanel = sectionMap.get(section); } else { sectionPanel = getParamPanel(section); sectionMap.put(section, sectionPanel); optionsPanel.add(sectionPanel); if (sameAsFields != null) { final Widget sameAsCombo = sameAsFields.get(section); if (sameAsCombo != null) { final JPanel saPanel = new JPanel(new SpringLayout()); saPanel.setBackground(Browser.BUTTON_PANEL_BACKGROUND); final JLabel label = new JLabel("Same As"); sameAsCombo.setLabel(label, ""); addField(saPanel, label, sameAsCombo, leftWidth, rightWidth, 0); SpringUtilities.makeCompactGrid(saPanel, 1, 2, 1, 1, // initX, initY 1, 1); // xPad, yPad sectionPanel.add(saPanel); } } } sectionPanel.add(panel); if (advanced) { advancedSections.add(sectionPanel); } else { notAdvancedSections.add(sectionPanel); } } boolean advanced = false; for (final JPanel sectionPanel : sectionMap.values()) { if (advancedSections.contains(sectionPanel)) { advanced = true; } if (!notAdvancedSections.contains(sectionPanel)) { advancedOnlySectionList.add(sectionPanel); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { sectionPanel.setVisible(Tools.getConfigData().isAdvancedMode()); } }); } } final boolean a = advanced; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { moreOptionsPanel.setVisible(a && !Tools.getConfigData().isAdvancedMode()); } }); }
From source file:lcmc.data.CRMXML.java
/** Returns CibQuery object with information from the cib node. */ CibQuery parseCibQuery(final String query) { final Document document = getXMLDocument(query); final CibQuery cibQueryData = new CibQuery(); if (document == null) { Tools.appWarning("cib error: " + query); return cibQueryData; }//from w w w .j a va2 s.c o m /* get root <pacemaker> */ final Node pcmkNode = getChildNode(document, "pcmk"); if (pcmkNode == null) { Tools.appWarning("there is no pcmk node"); return cibQueryData; } /* get fenced nodes */ final Set<String> fencedNodes = new HashSet<String>(); final Node fencedNode = getChildNode(pcmkNode, "fenced"); if (fencedNode != null) { final NodeList nodes = fencedNode.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { final Node hostNode = nodes.item(i); if (hostNode.getNodeName().equals("node")) { final String host = getText(hostNode); if (host != null) { fencedNodes.add(host.toLowerCase(Locale.US)); } } } } /* get <cib> */ final Node cibNode = getChildNode(pcmkNode, "cib"); if (cibNode == null) { Tools.appWarning("there is no cib node"); return cibQueryData; } /* Designated Co-ordinator */ final String dcUuid = getAttribute(cibNode, "dc-uuid"); //TODO: more attributes are here /* <configuration> */ final Node confNode = getChildNode(cibNode, "configuration"); if (confNode == null) { Tools.appWarning("there is no configuration node"); return cibQueryData; } /* <rsc_defaults> */ final Node rscDefaultsNode = getChildNode(confNode, "rsc_defaults"); String rscDefaultsId = null; final Map<String, String> rscDefaultsParams = new HashMap<String, String>(); final Map<String, String> rscDefaultsParamsNvpairIds = new HashMap<String, String>(); if (rscDefaultsNode != null) { rscDefaultsId = parseRscDefaults(rscDefaultsNode, rscDefaultsParams, rscDefaultsParamsNvpairIds); } /* <op_defaults> */ final Node opDefaultsNode = getChildNode(confNode, "op_defaults"); final Map<String, String> opDefaultsParams = new HashMap<String, String>(); if (opDefaultsNode != null) { parseOpDefaults(opDefaultsNode, opDefaultsParams); } /* <crm_config> */ final Node crmConfNode = getChildNode(confNode, "crm_config"); if (crmConfNode == null) { Tools.appWarning("there is no crm_config node"); return cibQueryData; } /* <cluster_property_set> */ final Node cpsNode = getChildNode(crmConfNode, "cluster_property_set"); if (cpsNode == null) { Tools.appWarning("there is no cluster_property_set node"); } else { NodeList nvpairs; if (Tools.versionBeforePacemaker(host)) { /* <attributtes> only til 2.1.4 */ final Node attrNode = getChildNode(cpsNode, "attributes"); nvpairs = attrNode.getChildNodes(); } else { nvpairs = cpsNode.getChildNodes(); } final Map<String, String> crmConfMap = new HashMap<String, String>(); /* <nvpair...> */ for (int i = 0; i < nvpairs.getLength(); i++) { final Node optionNode = nvpairs.item(i); if (optionNode.getNodeName().equals("nvpair")) { final String name = getAttribute(optionNode, "name"); final String value = getAttribute(optionNode, "value"); crmConfMap.put(name, value); } } cibQueryData.setCrmConfig(crmConfMap); } /* <nodes> */ /* xml node with cluster node make stupid variable names, but let's * keep the convention. */ String dc = null; final MultiKeyMap<String, String> nodeParametersMap = new MultiKeyMap<String, String>(); final Node nodesNode = getChildNode(confNode, "nodes"); final Map<String, String> nodeOnline = new HashMap<String, String>(); final Map<String, String> nodeID = new HashMap<String, String>(); if (nodesNode != null) { final NodeList nodes = nodesNode.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { final Node nodeNode = nodes.item(i); if (nodeNode.getNodeName().equals("node")) { /* TODO: doing nothing with the info, just getting the dc, * for now. */ final String id = getAttribute(nodeNode, "id"); final String uname = getAttribute(nodeNode, "uname"); if (!nodeID.containsKey(uname)) { nodeID.put(uname, id); } if (dcUuid != null && dcUuid.equals(id)) { dc = uname; } parseNode(uname, nodeNode, nodeParametersMap); if (!nodeOnline.containsKey(uname.toLowerCase(Locale.US))) { nodeOnline.put(uname.toLowerCase(Locale.US), "no"); } } } } /* <resources> */ final Node resourcesNode = getChildNode(confNode, "resources"); if (resourcesNode == null) { Tools.appWarning("there is no resources node"); return cibQueryData; } /* <primitive> */ final Map<String, Map<String, String>> parametersMap = new HashMap<String, Map<String, String>>(); final Map<String, Map<String, String>> parametersNvpairsIdsMap = new HashMap<String, Map<String, String>>(); final Map<String, ResourceAgent> resourceTypeMap = new HashMap<String, ResourceAgent>(); final Set<String> orphanedList = new HashSet<String>(); /* host -> inLRMList list */ final Map<String, Set<String>> inLRMList = new HashMap<String, Set<String>>(); final Map<String, String> resourceInstanceAttrIdMap = new HashMap<String, String>(); final MultiKeyMap<String, String> operationsMap = new MultiKeyMap<String, String>(); final Map<String, String> metaAttrsIdMap = new HashMap<String, String>(); final Map<String, String> operationsIdMap = new HashMap<String, String>(); final Map<String, Map<String, String>> resOpIdsMap = new HashMap<String, Map<String, String>>(); /* must be linked, so that clone from group is before the group itself. */ final Map<String, List<String>> groupsToResourcesMap = new LinkedHashMap<String, List<String>>(); final Map<String, String> cloneToResourceMap = new HashMap<String, String>(); final List<String> masterList = new ArrayList<String>(); final MultiKeyMap<String, String> failedMap = new MultiKeyMap<String, String>(); final MultiKeyMap<String, Set<String>> failedClonesMap = new MultiKeyMap<String, Set<String>>(); final Map<String, String> pingCountMap = new HashMap<String, String>(); groupsToResourcesMap.put("none", new ArrayList<String>()); final NodeList primitivesGroups = resourcesNode.getChildNodes(); final Map<String, String> operationsIdRefs = new HashMap<String, String>(); final Map<String, String> operationsIdtoCRMId = new HashMap<String, String>(); final Map<String, String> metaAttrsIdRefs = new HashMap<String, String>(); final Map<String, String> metaAttrsIdToCRMId = new HashMap<String, String>(); for (int i = 0; i < primitivesGroups.getLength(); i++) { final Node primitiveGroupNode = primitivesGroups.item(i); final String nodeName = primitiveGroupNode.getNodeName(); if ("primitive".equals(nodeName)) { final List<String> resList = groupsToResourcesMap.get("none"); parsePrimitive(primitiveGroupNode, resList, resourceTypeMap, parametersMap, parametersNvpairsIdsMap, resourceInstanceAttrIdMap, operationsMap, metaAttrsIdMap, operationsIdMap, resOpIdsMap, operationsIdRefs, operationsIdtoCRMId, metaAttrsIdRefs, metaAttrsIdToCRMId); } else if ("group".equals(nodeName)) { parseGroup(primitiveGroupNode, null, groupsToResourcesMap, parametersMap, resourceTypeMap, parametersNvpairsIdsMap, resourceInstanceAttrIdMap, operationsMap, metaAttrsIdMap, operationsIdMap, resOpIdsMap, operationsIdRefs, operationsIdtoCRMId, metaAttrsIdRefs, metaAttrsIdToCRMId); } else if ("master".equals(nodeName) || "master_slave".equals(nodeName) || "clone".equals(nodeName)) { final NodeList primitives = primitiveGroupNode.getChildNodes(); final String cloneId = getAttribute(primitiveGroupNode, "id"); List<String> resList = groupsToResourcesMap.get(cloneId); if (resList == null) { resList = new ArrayList<String>(); groupsToResourcesMap.put(cloneId, resList); } parseAttributes(primitiveGroupNode, cloneId, parametersMap, parametersNvpairsIdsMap, resourceInstanceAttrIdMap, operationsMap, metaAttrsIdMap, operationsIdMap, resOpIdsMap, operationsIdRefs, operationsIdtoCRMId, metaAttrsIdRefs, metaAttrsIdToCRMId, false); for (int j = 0; j < primitives.getLength(); j++) { final Node primitiveNode = primitives.item(j); if (primitiveNode.getNodeName().equals("primitive")) { parsePrimitive(primitiveNode, resList, resourceTypeMap, parametersMap, parametersNvpairsIdsMap, resourceInstanceAttrIdMap, operationsMap, metaAttrsIdMap, operationsIdMap, resOpIdsMap, operationsIdRefs, operationsIdtoCRMId, metaAttrsIdRefs, metaAttrsIdToCRMId); } else if (primitiveNode.getNodeName().equals("group")) { parseGroup(primitiveNode, resList, groupsToResourcesMap, parametersMap, resourceTypeMap, parametersNvpairsIdsMap, resourceInstanceAttrIdMap, operationsMap, metaAttrsIdMap, operationsIdMap, resOpIdsMap, operationsIdRefs, operationsIdtoCRMId, metaAttrsIdRefs, metaAttrsIdToCRMId); } } if (!resList.isEmpty()) { cloneToResourceMap.put(cloneId, resList.get(0)); if ("master".equals(nodeName) || "master_slave".equals(nodeName)) { masterList.add(cloneId); } } } } /* operationsRefs crm id -> crm id */ final Map<String, String> operationsRefs = new HashMap<String, String>(); for (final String crmId : operationsIdRefs.keySet()) { final String idRef = operationsIdRefs.get(crmId); operationsRefs.put(crmId, operationsIdtoCRMId.get(idRef)); } /* mettaAttrsRefs crm id -> crm id */ final Map<String, String> metaAttrsRefs = new HashMap<String, String>(); for (final String crmId : metaAttrsIdRefs.keySet()) { final String idRef = metaAttrsIdRefs.get(crmId); metaAttrsRefs.put(crmId, metaAttrsIdToCRMId.get(idRef)); } /* <constraints> */ final Map<String, ColocationData> colocationIdMap = new LinkedHashMap<String, ColocationData>(); final Map<String, List<ColocationData>> colocationRscMap = new HashMap<String, List<ColocationData>>(); final Map<String, OrderData> orderIdMap = new LinkedHashMap<String, OrderData>(); final Map<String, List<RscSet>> orderIdRscSetsMap = new HashMap<String, List<RscSet>>(); final Map<String, List<RscSet>> colocationIdRscSetsMap = new HashMap<String, List<RscSet>>(); final List<RscSetConnectionData> rscSetConnections = new ArrayList<RscSetConnectionData>(); final Map<String, List<OrderData>> orderRscMap = new HashMap<String, List<OrderData>>(); final Map<String, Map<String, HostLocation>> locationMap = new HashMap<String, Map<String, HostLocation>>(); final Map<String, HostLocation> pingLocationMap = new HashMap<String, HostLocation>(); final Map<String, List<String>> locationsIdMap = new HashMap<String, List<String>>(); final MultiKeyMap<String, String> resHostToLocIdMap = new MultiKeyMap<String, String>(); final Map<String, String> resPingToLocIdMap = new HashMap<String, String>(); final Node constraintsNode = getChildNode(confNode, "constraints"); if (constraintsNode != null) { final NodeList constraints = constraintsNode.getChildNodes(); String rscString = "rsc"; String rscRoleString = "rsc-role"; String withRscString = "with-rsc"; String withRscRoleString = "with-rsc-role"; String firstString = "first"; String thenString = "then"; String firstActionString = "first-action"; String thenActionString = "then-action"; if (Tools.versionBeforePacemaker(host)) { rscString = "from"; rscRoleString = "from_role"; withRscString = "to"; withRscRoleString = "to_role"; firstString = "to"; thenString = "from"; firstActionString = "to_action"; thenActionString = "action"; } for (int i = 0; i < constraints.getLength(); i++) { final Node constraintNode = constraints.item(i); if (constraintNode.getNodeName().equals("rsc_colocation")) { final String colId = getAttribute(constraintNode, "id"); final String rsc = getAttribute(constraintNode, rscString); final String withRsc = getAttribute(constraintNode, withRscString); if (rsc == null || withRsc == null) { final List<RscSet> rscSets = new ArrayList<RscSet>(); parseRscSets(constraintNode, colId, null, rscSets, rscSetConnections); colocationIdRscSetsMap.put(colId, rscSets); } final String rscRole = getAttribute(constraintNode, rscRoleString); final String withRscRole = getAttribute(constraintNode, withRscRoleString); final String score = getAttribute(constraintNode, SCORE_STRING); final ColocationData colocationData = new ColocationData(colId, rsc, withRsc, rscRole, withRscRole, score); colocationIdMap.put(colId, colocationData); List<ColocationData> withs = colocationRscMap.get(rsc); if (withs == null) { withs = new ArrayList<ColocationData>(); } withs.add(colocationData); colocationRscMap.put(rsc, withs); } else if (constraintNode.getNodeName().equals("rsc_order")) { String rscFirst = getAttribute(constraintNode, firstString); String rscThen = getAttribute(constraintNode, thenString); final String ordId = getAttribute(constraintNode, "id"); if (rscFirst == null || rscThen == null) { final List<RscSet> rscSets = new ArrayList<RscSet>(); parseRscSets(constraintNode, null, ordId, rscSets, rscSetConnections); orderIdRscSetsMap.put(ordId, rscSets); } final String score = getAttribute(constraintNode, SCORE_STRING); final String symmetrical = getAttribute(constraintNode, "symmetrical"); String firstAction = getAttribute(constraintNode, firstActionString); String thenAction = getAttribute(constraintNode, thenActionString); final String type = getAttribute(constraintNode, "type"); if (type != null && "before".equals(type)) { /* exchange resoruces */ final String rsc = rscFirst; rscFirst = rscThen; rscThen = rsc; final String act = firstAction; firstAction = thenAction; thenAction = act; } final OrderData orderData = new OrderData(ordId, rscFirst, rscThen, score, symmetrical, firstAction, thenAction); orderIdMap.put(ordId, orderData); List<OrderData> thens = orderRscMap.get(rscFirst); if (thens == null) { thens = new ArrayList<OrderData>(); } thens.add(orderData); orderRscMap.put(rscFirst, thens); } else if ("rsc_location".equals(constraintNode.getNodeName())) { final String locId = getAttribute(constraintNode, "id"); final String node = getAttribute(constraintNode, "node"); final String rsc = getAttribute(constraintNode, "rsc"); final String score = getAttribute(constraintNode, SCORE_STRING); final String role = null; // TODO List<String> locs = locationsIdMap.get(rsc); if (locs == null) { locs = new ArrayList<String>(); locationsIdMap.put(rsc, locs); } Map<String, HostLocation> hostScoreMap = locationMap.get(rsc); if (hostScoreMap == null) { hostScoreMap = new HashMap<String, HostLocation>(); locationMap.put(rsc, hostScoreMap); } if (node != null) { resHostToLocIdMap.put(rsc, node.toLowerCase(Locale.US), locId); } if (score != null) { hostScoreMap.put(node.toLowerCase(Locale.US), new HostLocation(score, "eq", null, role)); } locs.add(locId); final Node ruleNode = getChildNode(constraintNode, "rule"); if (ruleNode != null) { final String score2 = getAttribute(ruleNode, SCORE_STRING); final String booleanOp = getAttribute(ruleNode, "boolean-op"); // TODO: I know only "and", ignoring everything we // don't know. final Node expNode = getChildNode(ruleNode, "expression"); if (expNode != null && "expression".equals(expNode.getNodeName())) { final String attr = getAttribute(expNode, "attribute"); final String op = getAttribute(expNode, "operation"); final String type = getAttribute(expNode, "type"); final String value = getAttribute(expNode, "value"); if ((booleanOp == null || "and".equals(booleanOp)) && "#uname".equals(attr)) { hostScoreMap.put(value.toLowerCase(Locale.US), new HostLocation(score2, op, null, role)); resHostToLocIdMap.put(rsc, value.toLowerCase(Locale.US), locId); } else if ((booleanOp == null || "and".equals(booleanOp)) && "pingd".equals(attr)) { pingLocationMap.put(rsc, new HostLocation(score2, op, value, null)); resPingToLocIdMap.put(rsc, locId); } else { Tools.appWarning("could not parse rsc_location: " + locId); } } } } } } /* <status> */ final Node statusNode = getChildNode(cibNode, "status"); final Set<String> nodePending = new HashSet<String>(); if (statusNode != null) { final String hbV = host.getHeartbeatVersion(); /* <node_state ...> */ final NodeList nodes = statusNode.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { final Node nodeStateNode = nodes.item(i); if ("node_state".equals(nodeStateNode.getNodeName())) { final String uname = getAttribute(nodeStateNode, "uname"); final String id = getAttribute(nodeStateNode, "id"); if (!id.equals(nodeID.get(uname))) { Tools.appWarning("skipping " + uname + " " + id); } final String ha = getAttribute(nodeStateNode, "ha"); final String join = getAttribute(nodeStateNode, "join"); final String inCCM = getAttribute(nodeStateNode, "in_ccm"); final String crmd = getAttribute(nodeStateNode, "crmd"); if ("member".equals(join) && "true".equals(inCCM) && !"offline".equals(crmd)) { nodeOnline.put(uname.toLowerCase(Locale.US), "yes"); } else { nodeOnline.put(uname.toLowerCase(Locale.US), "no"); } if ("pending".equals(join)) { nodePending.add(uname.toLowerCase(Locale.US)); } final NodeList nodeStates = nodeStateNode.getChildNodes(); /* transient attributes. */ for (int j = 0; j < nodeStates.getLength(); j++) { final Node nodeStateChild = nodeStates.item(j); if ("transient_attributes".equals(nodeStateChild.getNodeName())) { parseTransientAttributes(uname, nodeStateChild, failedMap, failedClonesMap, pingCountMap); } } final List<String> resList = groupsToResourcesMap.get("none"); for (int j = 0; j < nodeStates.getLength(); j++) { final Node nodeStateChild = nodeStates.item(j); if ("lrm".equals(nodeStateChild.getNodeName())) { parseLRM(uname.toLowerCase(Locale.US), nodeStateChild, resList, resourceTypeMap, parametersMap, inLRMList, orphanedList, failedClonesMap); } } } } } cibQueryData.setDC(dc); cibQueryData.setNodeParameters(nodeParametersMap); cibQueryData.setParameters(parametersMap); cibQueryData.setParametersNvpairsIds(parametersNvpairsIdsMap); cibQueryData.setResourceType(resourceTypeMap); cibQueryData.setInLRM(inLRMList); cibQueryData.setOrphaned(orphanedList); cibQueryData.setResourceInstanceAttrId(resourceInstanceAttrIdMap); cibQueryData.setColocationRsc(colocationRscMap); cibQueryData.setColocationId(colocationIdMap); cibQueryData.setOrderId(orderIdMap); cibQueryData.setOrderIdRscSets(orderIdRscSetsMap); cibQueryData.setColocationIdRscSets(colocationIdRscSetsMap); cibQueryData.setRscSetConnections(rscSetConnections); cibQueryData.setOrderRsc(orderRscMap); cibQueryData.setLocation(locationMap); cibQueryData.setPingLocation(pingLocationMap); cibQueryData.setLocationsId(locationsIdMap); cibQueryData.setResHostToLocId(resHostToLocIdMap); cibQueryData.setResPingToLocId(resPingToLocIdMap); cibQueryData.setOperations(operationsMap); cibQueryData.setOperationsId(operationsIdMap); cibQueryData.setOperationsRefs(operationsRefs); cibQueryData.setMetaAttrsId(metaAttrsIdMap); cibQueryData.setMetaAttrsRefs(metaAttrsRefs); cibQueryData.setResOpIds(resOpIdsMap); cibQueryData.setNodeOnline(nodeOnline); cibQueryData.setNodePending(nodePending); cibQueryData.setGroupsToResources(groupsToResourcesMap); cibQueryData.setCloneToResource(cloneToResourceMap); cibQueryData.setMasterList(masterList); cibQueryData.setFailed(failedMap); cibQueryData.setFailedClones(failedClonesMap); cibQueryData.setPingCount(pingCountMap); cibQueryData.setRscDefaultsId(rscDefaultsId); cibQueryData.setRscDefaultsParams(rscDefaultsParams); cibQueryData.setRscDefaultsParamsNvpairIds(rscDefaultsParamsNvpairIds); cibQueryData.setOpDefaultsParams(opDefaultsParams); cibQueryData.setFencedNodes(fencedNodes); return cibQueryData; }
From source file:lcmc.crm.domain.CrmXml.java
/** Returns CibQuery object with information from the cib node. */ CibQuery parseCibQuery(final String query) { final Document document = XMLTools.getXMLDocument(query); final CibQuery cibQueryData = new CibQuery(); if (document == null) { LOG.appWarning("parseCibQuery: cib error: " + query); return cibQueryData; }/* w w w. ja va 2s.c o m*/ /* get root <pacemaker> */ final Node pcmkNode = XMLTools.getChildNode(document, "pcmk"); if (pcmkNode == null) { LOG.appWarning("parseCibQuery: there is no pcmk node"); return cibQueryData; } /* get fenced nodes */ final Set<String> fencedNodes = new HashSet<String>(); final Node fencedNode = XMLTools.getChildNode(pcmkNode, "fenced"); if (fencedNode != null) { final NodeList nodes = fencedNode.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { final Node hostNode = nodes.item(i); if (hostNode.getNodeName().equals("node")) { final String h = XMLTools.getText(hostNode); if (h != null) { fencedNodes.add(h.toLowerCase(Locale.US)); } } } } /* get <cib> */ final Node cibNode = XMLTools.getChildNode(pcmkNode, "cib"); if (cibNode == null) { LOG.appWarning("parseCibQuery: there is no cib node"); return cibQueryData; } /* Designated Co-ordinator */ final String dcUuid = XMLTools.getAttribute(cibNode, "dc-uuid"); //TODO: more attributes are here /* <configuration> */ final Node confNode = XMLTools.getChildNode(cibNode, "configuration"); if (confNode == null) { LOG.appWarning("parseCibQuery: there is no configuration node"); return cibQueryData; } /* <rsc_defaults> */ final Node rscDefaultsNode = XMLTools.getChildNode(confNode, "rsc_defaults"); String rscDefaultsId = null; final Map<String, String> rscDefaultsParams = new HashMap<String, String>(); final Map<String, String> rscDefaultsParamsNvpairIds = new HashMap<String, String>(); if (rscDefaultsNode != null) { rscDefaultsId = parseResourceDefaults(rscDefaultsNode, rscDefaultsParams, rscDefaultsParamsNvpairIds); } /* <op_defaults> */ final Node opDefaultsNode = XMLTools.getChildNode(confNode, "op_defaults"); final Map<String, Value> opDefaultsParams = new HashMap<String, Value>(); if (opDefaultsNode != null) { parseOpDefaults(opDefaultsNode, opDefaultsParams); } /* <crm_config> */ final Node crmConfNode = XMLTools.getChildNode(confNode, "crm_config"); if (crmConfNode == null) { LOG.appWarning("parseCibQuery: there is no crm_config node"); return cibQueryData; } /* <cluster_property_set> */ final Node cpsNode = XMLTools.getChildNode(crmConfNode, "cluster_property_set"); if (cpsNode == null) { LOG.appWarning("parseCibQuery: there is no cluster_property_set node"); } else { final NodeList nvpairs; if (Tools.versionBeforePacemaker(host)) { /* <attributtes> only til 2.1.4 */ final Node attrNode = XMLTools.getChildNode(cpsNode, "attributes"); nvpairs = attrNode.getChildNodes(); } else { nvpairs = cpsNode.getChildNodes(); } final Map<String, String> crmConfMap = new HashMap<String, String>(); /* <nvpair...> */ for (int i = 0; i < nvpairs.getLength(); i++) { final Node optionNode = nvpairs.item(i); if (optionNode.getNodeName().equals("nvpair")) { final String name = XMLTools.getAttribute(optionNode, "name"); final String value = XMLTools.getAttribute(optionNode, "value"); crmConfMap.put(name, value); } } cibQueryData.setCrmConfig(crmConfMap); } /* <nodes> */ /* xml node with cluster node make stupid variable names, but let's * keep the convention. */ String dc = null; final Table<String, String, String> nodeParametersMap = HashBasedTable.create(); final Node nodesNode = XMLTools.getChildNode(confNode, "nodes"); final Map<String, String> nodeOnline = new HashMap<String, String>(); final Map<String, String> nodeID = new HashMap<String, String>(); if (nodesNode != null) { final NodeList nodes = nodesNode.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { final Node nodeNode = nodes.item(i); if (nodeNode.getNodeName().equals("node")) { /* TODO: doing nothing with the info, just getting the dc, * for now. */ final String id = XMLTools.getAttribute(nodeNode, "id"); final String uname = XMLTools.getAttribute(nodeNode, "uname"); if (!nodeID.containsKey(uname)) { nodeID.put(uname, id); } if (dcUuid != null && dcUuid.equals(id)) { dc = uname; } parseNode(uname, nodeNode, nodeParametersMap); if (!nodeOnline.containsKey(uname.toLowerCase(Locale.US))) { nodeOnline.put(uname.toLowerCase(Locale.US), "no"); } } } } /* <resources> */ final Node resourcesNode = XMLTools.getChildNode(confNode, "resources"); if (resourcesNode == null) { LOG.appWarning("parseCibQuery: there is no resources node"); return cibQueryData; } /* <primitive> */ final Map<String, Map<String, String>> parametersMap = new HashMap<String, Map<String, String>>(); final Map<String, Map<String, String>> parametersNvpairsIdsMap = new HashMap<String, Map<String, String>>(); final Map<String, ResourceAgent> resourceTypeMap = new HashMap<String, ResourceAgent>(); final Set<String> orphanedList = new HashSet<String>(); /* host -> inLRMList list */ final Map<String, Set<String>> inLRMList = new HashMap<String, Set<String>>(); final Map<String, String> resourceInstanceAttrIdMap = new HashMap<String, String>(); final MultiKeyMap<String, Value> operationsMap = new MultiKeyMap<String, Value>(); final Map<String, String> metaAttrsIdMap = new HashMap<String, String>(); final Map<String, String> operationsIdMap = new HashMap<String, String>(); final Map<String, Map<String, String>> resOpIdsMap = new HashMap<String, Map<String, String>>(); /* must be linked, so that clone from group is before the group itself. */ final Map<String, List<String>> groupsToResourcesMap = new LinkedHashMap<String, List<String>>(); final Map<String, String> cloneToResourceMap = new HashMap<String, String>(); final List<String> masterList = new ArrayList<String>(); final Table<String, String, String> failedMap = HashBasedTable.create(); final Table<String, String, Set<String>> failedClonesMap = HashBasedTable.create(); final Map<String, String> pingCountMap = new HashMap<String, String>(); groupsToResourcesMap.put("none", new ArrayList<String>()); final NodeList primitivesGroups = resourcesNode.getChildNodes(); final Map<String, String> operationsIdRefs = new HashMap<String, String>(); final Map<String, String> operationsIdtoCRMId = new HashMap<String, String>(); final Map<String, String> metaAttrsIdRefs = new HashMap<String, String>(); final Map<String, String> metaAttrsIdToCRMId = new HashMap<String, String>(); for (int i = 0; i < primitivesGroups.getLength(); i++) { final Node primitiveGroupNode = primitivesGroups.item(i); final String nodeName = primitiveGroupNode.getNodeName(); if ("primitive".equals(nodeName)) { final List<String> resList = groupsToResourcesMap.get("none"); parsePrimitiveNode(primitiveGroupNode, resList, resourceTypeMap, parametersMap, parametersNvpairsIdsMap, resourceInstanceAttrIdMap, operationsMap, metaAttrsIdMap, operationsIdMap, resOpIdsMap, operationsIdRefs, operationsIdtoCRMId, metaAttrsIdRefs, metaAttrsIdToCRMId); } else if ("group".equals(nodeName)) { parseGroupNode(primitiveGroupNode, null, groupsToResourcesMap, parametersMap, resourceTypeMap, parametersNvpairsIdsMap, resourceInstanceAttrIdMap, operationsMap, metaAttrsIdMap, operationsIdMap, resOpIdsMap, operationsIdRefs, operationsIdtoCRMId, metaAttrsIdRefs, metaAttrsIdToCRMId); } else if ("master".equals(nodeName) || "master_slave".equals(nodeName) || "clone".equals(nodeName)) { final NodeList primitives = primitiveGroupNode.getChildNodes(); final String cloneId = XMLTools.getAttribute(primitiveGroupNode, "id"); List<String> resList = groupsToResourcesMap.get(cloneId); if (resList == null) { resList = new ArrayList<String>(); groupsToResourcesMap.put(cloneId, resList); } parseAttributes(primitiveGroupNode, cloneId, parametersMap, parametersNvpairsIdsMap, resourceInstanceAttrIdMap, operationsMap, metaAttrsIdMap, operationsIdMap, resOpIdsMap, operationsIdRefs, operationsIdtoCRMId, metaAttrsIdRefs, metaAttrsIdToCRMId, false); for (int j = 0; j < primitives.getLength(); j++) { final Node primitiveNode = primitives.item(j); if (primitiveNode.getNodeName().equals("primitive")) { parsePrimitiveNode(primitiveNode, resList, resourceTypeMap, parametersMap, parametersNvpairsIdsMap, resourceInstanceAttrIdMap, operationsMap, metaAttrsIdMap, operationsIdMap, resOpIdsMap, operationsIdRefs, operationsIdtoCRMId, metaAttrsIdRefs, metaAttrsIdToCRMId); } else if (primitiveNode.getNodeName().equals("group")) { parseGroupNode(primitiveNode, resList, groupsToResourcesMap, parametersMap, resourceTypeMap, parametersNvpairsIdsMap, resourceInstanceAttrIdMap, operationsMap, metaAttrsIdMap, operationsIdMap, resOpIdsMap, operationsIdRefs, operationsIdtoCRMId, metaAttrsIdRefs, metaAttrsIdToCRMId); } } if (!resList.isEmpty()) { cloneToResourceMap.put(cloneId, resList.get(0)); if ("master".equals(nodeName) || "master_slave".equals(nodeName)) { masterList.add(cloneId); } } } } /* operationsRefs crm id -> crm id */ final Map<String, String> operationsRefs = new HashMap<String, String>(); for (final String crmId : operationsIdRefs.keySet()) { final String idRef = operationsIdRefs.get(crmId); operationsRefs.put(crmId, operationsIdtoCRMId.get(idRef)); } /* mettaAttrsRefs crm id -> crm id */ final Map<String, String> metaAttrsRefs = new HashMap<String, String>(); for (final String crmId : metaAttrsIdRefs.keySet()) { final String idRef = metaAttrsIdRefs.get(crmId); metaAttrsRefs.put(crmId, metaAttrsIdToCRMId.get(idRef)); } /* <constraints> */ final Map<String, ColocationData> colocationIdMap = new LinkedHashMap<String, ColocationData>(); final Map<String, List<ColocationData>> colocationRscMap = new HashMap<String, List<ColocationData>>(); final Map<String, OrderData> orderIdMap = new LinkedHashMap<String, OrderData>(); final Map<String, List<RscSet>> orderIdRscSetsMap = new HashMap<String, List<RscSet>>(); final Map<String, List<RscSet>> colocationIdRscSetsMap = new HashMap<String, List<RscSet>>(); final List<RscSetConnectionData> rscSetConnections = new ArrayList<RscSetConnectionData>(); final Map<String, List<OrderData>> orderRscMap = new HashMap<String, List<OrderData>>(); final Map<String, Map<String, HostLocation>> locationMap = new HashMap<String, Map<String, HostLocation>>(); final Map<String, HostLocation> pingLocationMap = new HashMap<String, HostLocation>(); final Map<String, List<String>> locationsIdMap = new HashMap<String, List<String>>(); final Table<String, String, String> resHostToLocIdMap = HashBasedTable.create(); final Map<String, String> resPingToLocIdMap = new HashMap<String, String>(); final Node constraintsNode = XMLTools.getChildNode(confNode, "constraints"); if (constraintsNode != null) { final NodeList constraints = constraintsNode.getChildNodes(); String rscString = "rsc"; String rscRoleString = "rsc-role"; String withRscString = "with-rsc"; String withRscRoleString = "with-rsc-role"; String firstString = "first"; String thenString = "then"; String firstActionString = "first-action"; String thenActionString = "then-action"; if (Tools.versionBeforePacemaker(host)) { rscString = "from"; rscRoleString = "from_role"; withRscString = "to"; withRscRoleString = "to_role"; firstString = "to"; thenString = "from"; firstActionString = "to_action"; thenActionString = "action"; } for (int i = 0; i < constraints.getLength(); i++) { final Node constraintNode = constraints.item(i); if (constraintNode.getNodeName().equals("rsc_colocation")) { final String colId = XMLTools.getAttribute(constraintNode, "id"); final String rsc = XMLTools.getAttribute(constraintNode, rscString); final String withRsc = XMLTools.getAttribute(constraintNode, withRscString); if (rsc == null || withRsc == null) { final List<RscSet> rscSets = new ArrayList<RscSet>(); parseResourceSets(constraintNode, colId, null, rscSets, rscSetConnections); colocationIdRscSetsMap.put(colId, rscSets); } final String rscRole = XMLTools.getAttribute(constraintNode, rscRoleString); final String withRscRole = XMLTools.getAttribute(constraintNode, withRscRoleString); final String score = XMLTools.getAttribute(constraintNode, SCORE_CONSTRAINT_PARAM); final ColocationData colocationData = new ColocationData(colId, rsc, withRsc, rscRole, withRscRole, score); colocationIdMap.put(colId, colocationData); List<ColocationData> withs = colocationRscMap.get(rsc); if (withs == null) { withs = new ArrayList<ColocationData>(); } withs.add(colocationData); colocationRscMap.put(rsc, withs); } else if (constraintNode.getNodeName().equals("rsc_order")) { String rscFirst = XMLTools.getAttribute(constraintNode, firstString); String rscThen = XMLTools.getAttribute(constraintNode, thenString); final String ordId = XMLTools.getAttribute(constraintNode, "id"); if (rscFirst == null || rscThen == null) { final List<RscSet> rscSets = new ArrayList<RscSet>(); parseResourceSets(constraintNode, null, ordId, rscSets, rscSetConnections); orderIdRscSetsMap.put(ordId, rscSets); } final String score = XMLTools.getAttribute(constraintNode, SCORE_CONSTRAINT_PARAM); final String symmetrical = XMLTools.getAttribute(constraintNode, "symmetrical"); String firstAction = XMLTools.getAttribute(constraintNode, firstActionString); String thenAction = XMLTools.getAttribute(constraintNode, thenActionString); final String type = XMLTools.getAttribute(constraintNode, "type"); if (type != null && "before".equals(type)) { /* exchange resoruces */ final String rsc = rscFirst; rscFirst = rscThen; rscThen = rsc; final String act = firstAction; firstAction = thenAction; thenAction = act; } final OrderData orderData = new OrderData(ordId, rscFirst, rscThen, score, symmetrical, firstAction, thenAction); orderIdMap.put(ordId, orderData); List<OrderData> thens = orderRscMap.get(rscFirst); if (thens == null) { thens = new ArrayList<OrderData>(); } thens.add(orderData); orderRscMap.put(rscFirst, thens); } else if ("rsc_location".equals(constraintNode.getNodeName())) { final String locId = XMLTools.getAttribute(constraintNode, "id"); final String node = XMLTools.getAttribute(constraintNode, "node"); final String rsc = XMLTools.getAttribute(constraintNode, "rsc"); final String score = XMLTools.getAttribute(constraintNode, SCORE_CONSTRAINT_PARAM); List<String> locs = locationsIdMap.get(rsc); if (locs == null) { locs = new ArrayList<String>(); locationsIdMap.put(rsc, locs); } Map<String, HostLocation> hostScoreMap = locationMap.get(rsc); if (hostScoreMap == null) { hostScoreMap = new HashMap<String, HostLocation>(); locationMap.put(rsc, hostScoreMap); } final String role = null; // TODO if (node != null) { resHostToLocIdMap.put(rsc, node.toLowerCase(Locale.US), locId); if (score != null) { hostScoreMap.put(node.toLowerCase(Locale.US), new HostLocation(score, "eq", null, role)); } } locs.add(locId); final Node ruleNode = XMLTools.getChildNode(constraintNode, "rule"); if (ruleNode != null) { final String score2 = XMLTools.getAttribute(ruleNode, SCORE_CONSTRAINT_PARAM); final String booleanOp = XMLTools.getAttribute(ruleNode, "boolean-op"); // TODO: I know only "and", ignoring everything we // don't know. final Node expNode = XMLTools.getChildNode(ruleNode, "expression"); if (expNode != null && "expression".equals(expNode.getNodeName())) { final String attr = XMLTools.getAttribute(expNode, "attribute"); final String op = XMLTools.getAttribute(expNode, "operation"); final String value = XMLTools.getAttribute(expNode, "value"); if ((booleanOp == null || "and".equals(booleanOp)) && "#uname".equals(attr) && value != null) { hostScoreMap.put(value.toLowerCase(Locale.US), new HostLocation(score2, op, null, role)); resHostToLocIdMap.put(rsc, value.toLowerCase(Locale.US), locId); } else if ((booleanOp == null || "and".equals(booleanOp)) && "pingd".equals(attr)) { pingLocationMap.put(rsc, new HostLocation(score2, op, value, null)); resPingToLocIdMap.put(rsc, locId); } else { LOG.appWarning("parseCibQuery: could not parse rsc_location: " + locId); } } } } } } /* <status> */ final Node statusNode = XMLTools.getChildNode(cibNode, "status"); final Set<String> nodePending = new HashSet<String>(); if (statusNode != null) { /* <node_state ...> */ final NodeList nodes = statusNode.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { final Node nodeStateNode = nodes.item(i); if ("node_state".equals(nodeStateNode.getNodeName())) { final String uname = XMLTools.getAttribute(nodeStateNode, "uname"); final String id = XMLTools.getAttribute(nodeStateNode, "id"); if (uname == null || !id.equals(nodeID.get(uname))) { LOG.appWarning("parseCibQuery: skipping " + uname + ' ' + id); continue; } final String join = XMLTools.getAttribute(nodeStateNode, "join"); final String inCCM = XMLTools.getAttribute(nodeStateNode, "in_ccm"); final String crmd = XMLTools.getAttribute(nodeStateNode, "crmd"); if ("member".equals(join) && "true".equals(inCCM) && !"offline".equals(crmd)) { nodeOnline.put(uname.toLowerCase(Locale.US), "yes"); } else { nodeOnline.put(uname.toLowerCase(Locale.US), "no"); } if ("pending".equals(join)) { nodePending.add(uname.toLowerCase(Locale.US)); } final NodeList nodeStates = nodeStateNode.getChildNodes(); /* transient attributes. */ for (int j = 0; j < nodeStates.getLength(); j++) { final Node nodeStateChild = nodeStates.item(j); if ("transient_attributes".equals(nodeStateChild.getNodeName())) { parseTransientAttributes(uname, nodeStateChild, failedMap, failedClonesMap, pingCountMap); } } final List<String> resList = groupsToResourcesMap.get("none"); for (int j = 0; j < nodeStates.getLength(); j++) { final Node nodeStateChild = nodeStates.item(j); if ("lrm".equals(nodeStateChild.getNodeName())) { parseLrmResources(uname.toLowerCase(Locale.US), nodeStateChild, resList, resourceTypeMap, parametersMap, inLRMList, orphanedList, failedClonesMap); } } } } } cibQueryData.setDC(dc); cibQueryData.setNodeParameters(nodeParametersMap); cibQueryData.setResourceParameters(parametersMap); cibQueryData.setResourceParametersNvpairsIds(parametersNvpairsIdsMap); cibQueryData.setResourceType(resourceTypeMap); cibQueryData.setInLRM(inLRMList); cibQueryData.setOrphaned(orphanedList); cibQueryData.setResourceInstanceAttrId(resourceInstanceAttrIdMap); cibQueryData.setColocationRsc(colocationRscMap); cibQueryData.setColocationId(colocationIdMap); cibQueryData.setOrderId(orderIdMap); cibQueryData.setOrderIdRscSets(orderIdRscSetsMap); cibQueryData.setColocationIdRscSets(colocationIdRscSetsMap); cibQueryData.setRscSetConnections(rscSetConnections); cibQueryData.setOrderRsc(orderRscMap); cibQueryData.setLocations(locationMap); cibQueryData.setPingLocations(pingLocationMap); cibQueryData.setLocationsId(locationsIdMap); cibQueryData.setResHostToLocId(resHostToLocIdMap); cibQueryData.setResPingToLocId(resPingToLocIdMap); cibQueryData.setOperations(operationsMap); cibQueryData.setOperationsId(operationsIdMap); cibQueryData.setOperationsRefs(operationsRefs); cibQueryData.setMetaAttrsId(metaAttrsIdMap); cibQueryData.setMetaAttrsRefs(metaAttrsRefs); cibQueryData.setResOpIds(resOpIdsMap); cibQueryData.setNodeOnline(nodeOnline); cibQueryData.setNodePending(nodePending); cibQueryData.setGroupsToResources(groupsToResourcesMap); cibQueryData.setCloneToResource(cloneToResourceMap); cibQueryData.setMasterList(masterList); cibQueryData.setNodeFailedCount(failedMap); cibQueryData.setResourceFailedCloneIds(failedClonesMap); cibQueryData.setNodePingCount(pingCountMap); cibQueryData.setRscDefaultsId(rscDefaultsId); cibQueryData.setRscDefaultsParams(rscDefaultsParams); cibQueryData.setRscDefaultsParamsNvpairIds(rscDefaultsParamsNvpairIds); cibQueryData.setOpDefaultsParams(opDefaultsParams); cibQueryData.setFencedNodes(fencedNodes); return cibQueryData; }