Package lcmc.crm.domain

Examples of lcmc.crm.domain.ClusterStatus


            return;
        }
        /* Attributes */
        final String[] params = getEnabledSectionParams(crmXML.getOcfMetaDataParameters(resourceAgent,
                getService().isMaster()));
        final ClusterStatus cs = getBrowser().getClusterStatus();
        if (params != null) {
            final String newMetaAttrsId = cs.getMetaAttrsId(getService().getCrmId());
            if ((savedMetaAttrsId == null && newMetaAttrsId != null)
                || (savedMetaAttrsId != null && !savedMetaAttrsId.equals(newMetaAttrsId))) {
                /* newly generated operations id, reload all other combo
                   boxes. */
                getBrowser().reloadAllComboBoxes(this);
            }
            savedMetaAttrsId = newMetaAttrsId;
            String refCRMId = cs.getMetaAttrsRef(getService().getCrmId());
            final ServiceInfo metaAttrInfoRef = getBrowser().getServiceInfoFromCRMId(refCRMId);
            if (refCRMId == null) {
                refCRMId = getService().getCrmId();
            }
            resourceNode.put(PCMK_ID, getService().getCrmId());
            resourceNode.put(GUI_ID, getService().getId());
            boolean allMetaAttrsAreDefaultValues = true;
            boolean allSavedMetaAttrsAreDefaultValues = true;
            for (final String param : params) {
                Value value;
                if (isMetaAttr(param) && refCRMId != null) {
                    value = new StringValue(cs.getParameter(refCRMId, param, Application.RunMode.LIVE));
                } else {
                    value = new StringValue(resourceNode.get(param));
                }
                final Value defaultValue = getParamDefault(param);
                if (value.isNothingSelected()) {
                    value = defaultValue;
                }
                final Value oldValue = getResource().getValue(param);
                if (isMetaAttr(param)) {
                    if (!Tools.areEqual(defaultValue, value)) {
                        allMetaAttrsAreDefaultValues = false;
                    }
                    if (!Tools.areEqual(defaultValue, oldValue)) {
                        allSavedMetaAttrsAreDefaultValues = false;
                    }
                }
                if (infoPanelOk) {
                    final Widget wi = getWidget(param, null);
                    final boolean haveChanged = !Tools.areEqual(value, oldValue)
                                                || !Tools.areEqual(defaultValue,
                                                                   getResource().getDefaultValue(param));
                    if (haveChanged || (metaAttrInfoRef != null && isMetaAttr(param))) {
                        getResource().setValue(param, value);
                        /* set default value, because it can change in
                         * rsc_defaults. */
                        getResource().setDefaultValue(param, defaultValue);
                        if (wi != null && metaAttrInfoRef == null) {
                            wi.setValue(value);
                        }
                    }
                }
            }
            if (!Tools.areEqual(metaAttrInfoRef, savedMetaAttrInfoRef)) {
                savedMetaAttrInfoRef = metaAttrInfoRef;
                if (sameAsMetaAttrsWi != null) {
                    if (metaAttrInfoRef == null) {
                        if (allMetaAttrsAreDefaultValues) {
                            if (!allSavedMetaAttrsAreDefaultValues) {
                                sameAsMetaAttrsWi.setValue(META_ATTRS_DEFAULT_VALUES);
                            }
                        } else {
                            if (metaAttrInfoRef != null) {
                                sameAsMetaAttrsWi.setValue(null);
                            }
                        }
                    } else {
                        sameAsMetaAttrsWi.setValue(metaAttrInfoRef);
                    }
                }
            }
        }

        /* set scores */
        for (final Host host : getBrowser().getClusterHosts()) {
            final HostInfo hi = host.getBrowser().getHostInfo();
            final HostLocation hostLocation = cs.getScore(getService().getCrmId(),
                                                          hi.getName(),
                                                          Application.RunMode.LIVE);
            final HostLocation savedLocation = savedHostLocations.get(hi);
            if (Tools.areEqual(hostLocation, savedLocation)) {
                if (hostLocation == null) {
                    savedHostLocations.remove(hi);
                } else {
                    savedHostLocations.put(hi, hostLocation);
                }
                if (infoPanelOk) {
                    final Widget wi = scoreComboBoxHash.get(hi);
                    if (wi != null) {
                        String score = null;
                        String op = null;
                        if (hostLocation != null) {
                            score = hostLocation.getScore();
                            op = hostLocation.getOperation();
                        }
                        wi.setValue(new StringValue(score));
                        final JLabel label = wi.getLabel();
                        final String text = getHostLocationLabel(hi.getName(), op);
                        label.setText(text);
                    }
                }
            }
        }

        /* set ping constraint */
        final HostLocation hostLocation = cs.getPingScore(getService().getCrmId(), Application.RunMode.LIVE);
        Value pingOperation = null;
        if (hostLocation != null) {
            final String op = hostLocation.getOperation();
            final String value = hostLocation.getValue();
            if ("eq".equals(op) && "0".equals(value)) {
                pingOperation = new StringValue("eq0");
            } else {
                pingOperation = new StringValue(hostLocation.getOperation());
            }
        }
        if (!Tools.areEqual(pingOperation, savedPingOperation)) {
            savedPingOperation = pingOperation;
        }
        if (infoPanelOk) {
            final Widget wi = pingComboBox;
            if (wi != null) {
                if (pingOperation == null) {
                    wi.setValue(null);
                } else {
                    wi.setValue(PING_ATTRIBUTES.get(pingOperation.getValueForConfig()));
                }
            }
        }

        /* Operations */
        final String newOperationsId = cs.getOperationsId(getService().getCrmId());
        if ((savedOperationsId == null && newOperationsId != null)
            || (savedOperationsId != null && !savedOperationsId.equals(newOperationsId))) {
            /* newly generated operations id, reload all other combo
               boxes. */
            getBrowser().reloadAllComboBoxes(this);
        }

        savedOperationsId = newOperationsId;
        String refCRMId = cs.getOperationsRef(getService().getCrmId());
        final ServiceInfo operationIdRef = getBrowser().getServiceInfoFromCRMId(refCRMId);
        if (refCRMId == null) {
            refCRMId = getService().getCrmId();
        }
        mSavedOperationsLock.lock();
        boolean allAreDefaultValues = true;
        boolean allSavedAreDefaultValues = true;
        for (final String op : getResourceAgent().getOperationNames()) {
            for (final String param : getBrowser().getCrmOperationParams(op)) {
                Value defaultValue = resourceAgent.getOperationDefault(op, param);
                if (defaultValue == null || defaultValue.isNothingSelected()) {
                    continue;
                }
                if (ClusterBrowser.CRM_OPERATIONS_WITH_IGNORED_DEFAULT.contains(op)) {
                    defaultValue = NOTHING_SELECTED_VALUE;
                }
                Value value = cs.getOperation(refCRMId, op, param);
                if (value == null || value.isNothingSelected()) {
                    value = getOpDefaultsDefault(param);
                }
                if (!Tools.areEqual(defaultValue, value)) {
                    allAreDefaultValues = false;
                }
                if (!Tools.areEqual(defaultValue, savedOperation.get(op, param))) {
                    allSavedAreDefaultValues = false;
                }
            }
        }
        boolean sameAs = false;
        if (!Tools.areEqual(operationIdRef, savedOperationIdRef)) {
            savedOperationIdRef = operationIdRef;
            if (sameAsOperationsWi != null) {
                if (operationIdRef == null) {
                    if (allAreDefaultValues) { // TODO: don't have it yet.
                        if (!allSavedAreDefaultValues) {
                            sameAsOperationsWi.setValue(OPERATIONS_DEFAULT_VALUES);
                        }
                    } else {
                        if (savedOperationIdRef != null) {
                            sameAsOperationsWi.setValue(null);
                        }
                    }
                } else {
                    sameAs = false;
                    sameAsOperationsWi.setValue(operationIdRef);
                }
            }
        }
        if (!sameAs) {
            for (final String op : getResourceAgent().getOperationNames()) {
                for (final String param : getBrowser().getCrmOperationParams(op)) {
                    final Value defaultValue = resourceAgent.getOperationDefault(op, param);
                    if (defaultValue == null || defaultValue.isNothingSelected()) {
                        continue;
                    }
                    Value value = cs.getOperation(refCRMId, op, param);
                    if (value == null || value.isNothingSelected()) {
                        value = getOpDefaultsDefault(param);
                    }
                    if (!Tools.areEqual(value, savedOperation.get(op, param))) {
                        savedOperation.put(op, param, value);
                        if (infoPanelOk) {
                            mOperationsComboBoxHashReadLock.lock();
                            final Widget wi;
                            try {
                                wi = operationsComboBoxHash.get(op, param);
                            } finally {
                                mOperationsComboBoxHashReadLock.unlock();
                            }
                            application.invokeLater(new Runnable() {
                                @Override
                                public void run() {
                                    wi.setEnabled(operationIdRef == null);
                                }
                            });
                            if (value != null) {
                                wi.setValue(value);
                            }
                        }
                    }
                }
            }
        }
        mSavedOperationsLock.unlock();
        getService().setAvailable();
        if (cs.isOrphaned(getHeartbeatId(Application.RunMode.LIVE))) {
            getService().setOrphaned(true);
            getService().setNew(false);
            final CloneInfo ci = getCloneInfo();
            if (ci != null) {
                ci.getService().setNew(false);
View Full Code Here

TOP

Related Classes of lcmc.crm.domain.ClusterStatus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.