Package lcmc.crm.ui

Examples of lcmc.crm.ui.CrmGraph


                host.execCommand(new ExecCommandConfig().commandString("HostBrowser.getCrmConfigureShow")
                                                        .execCallback(execCallback)
                                                        .sshCommandTimeout(Ssh.DEFAULT_COMMAND_TIMEOUT));
            }
        });
        final CrmGraph crmg = getBrowser().getClusterBrowser().getCrmGraph();
        final Document taDocument = ta.getDocument();
        taDocument.addDocumentListener(new DocumentListener() {
            private void update() {
                if (!crmShowInProgress && !crmInfoShowing) {
                    crmConfigureCommitButton.setEnabled(true);
                }
            }

            @Override
            public void changedUpdate(final DocumentEvent e) {
                update();
            }

            @Override
            public void insertUpdate(final DocumentEvent e) {
                update();
            }

            @Override
            public void removeUpdate(final DocumentEvent e) {
                update();
            }
        });

        final ButtonCallback buttonCallback = new ButtonCallback() {
            private volatile boolean mouseStillOver = false;

            @Override
            public boolean isEnabled() {
                return !Tools.versionBeforePacemaker(host);
            }

            @Override
            public void mouseOut(final ComponentWithTest component) {
                if (!isEnabled()) {
                    return;
                }
                mouseStillOver = false;
                crmg.stopTestAnimation((JComponent) component);
                component.setToolTipText("");
            }

            @Override
            public void mouseOver(final ComponentWithTest component) {
                if (!isEnabled()) {
                    return;
                }
                mouseStillOver = true;
                component.setToolTipText(ClusterBrowser.STARTING_PTEST_TOOLTIP);
                component.setToolTipBackground(Tools.getDefaultColor("ClusterBrowser.Test.Tooltip.Background"));
                Tools.sleep(250);
                if (!mouseStillOver) {
                    return;
                }
                mouseStillOver = false;
                final CountDownLatch startTestLatch = new CountDownLatch(1);
                crmg.startTestAnimation((JComponent) component, startTestLatch);
                final Host dcHost = getBrowser().getClusterBrowser().getDCHost();
                getBrowser().getClusterBrowser().ptestLockAcquire();
                try {
                    final ClusterStatus clStatus = getBrowser().getClusterBrowser().getClusterStatus();
                    clStatus.setPtestResult(null);
View Full Code Here


    /** Sets clone info object. */
    private CloneInfo setCreateCloneInfo(final String cloneId,
                                         final ClusterStatus clStatus,
                                         final Application.RunMode runMode) {
        CloneInfo newCi = (CloneInfo) getBrowser().getServiceInfoFromCRMId(cloneId);
        final CrmGraph hg = getBrowser().getCrmGraph();
        if (newCi == null) {
            final Point2D p = null;
            newCi =
               (CloneInfo) addServicePanel(getBrowser().getCrmXml().getCloneResourceAgent(),
                                           p,
                                           false,
                                           cloneId,
                                           null,
                                           runMode);
            getBrowser().addToHeartbeatIdList(newCi);
            final Map<String, String> resourceNode = clStatus.getParamValuePairs(newCi.getHeartbeatId(runMode));
            newCi.setParameters(resourceNode);
        } else {
            final Map<String, String> resourceNode = clStatus.getParamValuePairs(newCi.getHeartbeatId(runMode));
            newCi.setParameters(resourceNode);
            if (Application.isLive(runMode)) {
                newCi.setUpdated(false);
                hg.repaint();
            }
        }
        newCi.getService().setNew(false);
        return newCi;
    }
View Full Code Here

    private GroupInfo setCreateGroupInfo(final String group,
                                         final CloneInfo newCi,
                                         final ClusterStatus clStatus,
                                         final Application.RunMode runMode) {
        GroupInfo newGi = (GroupInfo) getBrowser().getServiceInfoFromCRMId(group);
        final CrmGraph hg = getBrowser().getCrmGraph();
        if (newGi == null) {
            final Point2D p = null;
            newGi =
              (GroupInfo) addServicePanel(getBrowser().getCrmXml().getGroupResourceAgent(),
                                          p,
                                          false,
                                          group,
                                          newCi,
                                          runMode);
            final Map<String, String> resourceNode = clStatus.getParamValuePairs(newGi.getHeartbeatId(runMode));
            newGi.setParameters(resourceNode);
            if (newCi != null) {
                newCi.addCloneServicePanel(newGi);
            }
        } else {
            final Map<String, String> resourceNode = clStatus.getParamValuePairs(newGi.getHeartbeatId(runMode));
            newGi.setParameters(resourceNode);
            if (Application.isLive(runMode)) {
                newGi.setUpdated(false);
                hg.repaint();
            }
        }
        newGi.getService().setNew(false);
        return newGi;
    }
View Full Code Here

        if (newCi != null) {
            setParametersHash.put(newCi, clStatus.getParamValuePairs(grpOrCloneId));
        } else if (newGi != null) {
            setParametersHash.put(newGi, clStatus.getParamValuePairs(grpOrCloneId));
        }
        final CrmGraph hg = getBrowser().getCrmGraph();
        final List<String> gs = clStatus.getGroupResources(grpOrCloneId, runMode);
        if (gs == null) {
            return;
        }
        boolean newService = false;
        int pos = 0;
        for (final String hbId : gs) {
            if (clStatus.isOrphaned(hbId) && application.isHideLRM()) {
                continue;
            }
            ServiceInfo newServiceInfo;
            if (allGroupsAndClones.contains(hbId)) {
                if (newGi != null) {
                    LOG.appWarning("setGroupResources: group in group not implemented");
                    continue;
                }
                /* clone group */
                final GroupInfo gi = setCreateGroupInfo(hbId, newCi, clStatus, runMode);
                setGroupResources(allGroupsAndClones,
                                  hbId,
                                  gi,
                                  null,
                                  serviceIsPresent,
                                  groupServiceIsPresent,
                                  clStatus,
                                  runMode);
                newServiceInfo = gi;
            } else {
                final ResourceAgent newResourceAgent = clStatus.getResourceType(hbId);
                if (newResourceAgent == null) {
                    /* This is bad. There is a service but we do not have
                     * the heartbeat script of this service or the we look
                     * in the wrong places.
                     */
                    LOG.appWarning("setGroupResources: " + hbId + ": could not find resource agent");
                }
                /* continue of creating/updating of the
                 * service in the gui.
                 */
                newServiceInfo = getBrowser().getServiceInfoFromCRMId(hbId);
                final Map<String, String> resourceNode = clStatus.getParamValuePairs(hbId);
                if (newServiceInfo == null) {
                    newService = true;
                    newServiceInfo = crmServiceFactory.createServiceWithParameters(
                            hbId,
                            newResourceAgent,
                            resourceNode,
                            getBrowser());
                    newServiceInfo.getService().setCrmId(hbId);
                    getBrowser().addToHeartbeatIdList(newServiceInfo);
                    if (newGi != null) {
                        newGi.addGroupServicePanel(newServiceInfo, false);
                    } else if (newCi != null) {
                        newCi.addCloneServicePanel(newServiceInfo);
                    } else {
                        final Point2D p = null;
                        addServicePanel(newServiceInfo, p, false, false, runMode);
                    }
                } else {
                    getBrowser().addNameToServiceInfoHash(newServiceInfo);
                    setParametersHash.put(newServiceInfo, resourceNode);
                }
                newServiceInfo.getService().setNew(false);
                serviceIsPresent.add(newServiceInfo);
                if (newGi != null || newCi != null) {
                    groupServiceIsPresent.add(newServiceInfo);
                }
            }
            final DefaultMutableTreeNode node = newServiceInfo.getNode();
            if (node != null) {
                treeMenuController.moveNodeToPosition(node, pos);
                pos++;
            }
        }

        for (final Map.Entry<ServiceInfo, Map<String, String>> setEntry : setParametersHash.entrySet()) {
            setEntry.getKey().setParameters(setEntry.getValue());
            if (Application.isLive(runMode)) {
                setEntry.getKey().setUpdated(false);
            }
        }
        if (newService) {
            treeMenuController.reloadNode(getBrowser().getServicesNode(), false);
        }
        hg.repaint();
    }
View Full Code Here

    public void setAllResources(final ClusterStatus clStatus, final Application.RunMode runMode) {
        if (clStatus == null) {
            return;
        }
        final Set<String> allGroupsAndClones = clStatus.getAllGroups();
        final CrmGraph hg = getBrowser().getCrmGraph();
        final List<ServiceInfo> groupServiceIsPresent = new ArrayList<ServiceInfo>();
        final List<ServiceInfo> serviceIsPresent = new ArrayList<ServiceInfo>();
        for (final String groupOrClone : allGroupsAndClones) {
            CloneInfo newCi = null;
            GroupInfo newGi = null;
            if (clStatus.isClone(groupOrClone)) {
                /* clone */
                newCi = setCreateCloneInfo(groupOrClone, clStatus, runMode);
                serviceIsPresent.add(newCi);
            } else if (!"none".equals(groupOrClone)) {
                /* group */
                final GroupInfo gi = (GroupInfo) getBrowser().getServiceInfoFromCRMId(groupOrClone);
                if (gi != null && gi.getCloneInfo() != null) {
                    /* cloned group is already done */
                    groupServiceIsPresent.add(gi);
                    continue;
                }
                newGi = setCreateGroupInfo(groupOrClone, newCi, clStatus, runMode);
                serviceIsPresent.add(newGi);
            }
            setGroupResources(allGroupsAndClones,
                              groupOrClone,
                              newGi,
                              newCi,
                              serviceIsPresent,
                              groupServiceIsPresent,
                              clStatus,
                              runMode);
        }

        hg.clearKeepColocationList();
        hg.clearKeepOrderList();
        /* resource sets */
        final List<CrmXml.RscSetConnectionData> rscSetConnections = clStatus.getRscSetConnections();
        if (rscSetConnections != null) {
            final Map<CrmXml.RscSetConnectionData, ConstraintPHInfo> rdataToCphi =
                                                     new LinkedHashMap<CrmXml.RscSetConnectionData, ConstraintPHInfo>();
            getBrowser().lockNameToServiceInfo();
            final Map<String, ServiceInfo> idToInfoHash = getBrowser().getNameToServiceInfoHash(ConstraintPHInfo.NAME);
            final List<ConstraintPHInfo> preNewCphis = new ArrayList<ConstraintPHInfo>();
            if (idToInfoHash != null) {
                for (final Map.Entry<String, ServiceInfo> infoEntry : idToInfoHash.entrySet()) {
                    final ConstraintPHInfo cphi = (ConstraintPHInfo) infoEntry.getValue();
                    final CrmXml.RscSetConnectionData rdataOrd = cphi.getRscSetConnectionDataOrder();
                    final CrmXml.RscSetConnectionData rdataCol = cphi.getRscSetConnectionDataColocation();
                    if (cphi.getService().isNew()) {
                        preNewCphis.add(cphi);
                    }
                    if (rdataOrd != null && !rdataOrd.isEmpty()) {
                        rdataToCphi.put(rdataOrd, cphi);
                    }
                    if (rdataCol != null && !rdataCol.isEmpty()) {
                        rdataToCphi.put(rdataCol, cphi);
                    }
                }
            }
            getBrowser().unlockNameToServiceInfo();
            final Collection<ConstraintPHInfo> newCphis = new ArrayList<ConstraintPHInfo>();
            for (final CrmXml.RscSetConnectionData rdata : rscSetConnections) {
                ConstraintPHInfo constraintPHInfo = null;

                for (final Map.Entry<CrmXml.RscSetConnectionData, ConstraintPHInfo> phEntry : rdataToCphi.entrySet()) {
                    if (phEntry.getKey() == rdata) {
                        continue;
                    }
                    if (rdata.equals(phEntry.getKey()) || rdata.equalsAlthoughReversed(phEntry.getKey())) {
                        constraintPHInfo = phEntry.getValue();
                        constraintPHInfo.setRscSetConnectionData(rdata);
                        break;
                    }
                }
                PcmkRscSetsInfo rscSetsInfo = null;
                if (constraintPHInfo == null) {
                    for (final Map.Entry<CrmXml.RscSetConnectionData, ConstraintPHInfo> phEntry
                            : rdataToCphi.entrySet()) {
                        if (phEntry.getKey() == rdata) {
                            constraintPHInfo = phEntry.getValue();
                            break;
                        }
                        if (phEntry.getValue().sameConstraintId(rdata)) {
                            /* use the same rsc set info object */
                            rscSetsInfo = phEntry.getValue().getPcmkRscSetsInfo();
                        }
                        if (phEntry.getValue().getService().isNew()
                            || (rdata.canUseSamePlaceholder(phEntry.getKey())
                                && phEntry.getValue().sameConstraintId(rdata))) {
                            constraintPHInfo = phEntry.getValue();
                            constraintPHInfo.setRscSetConnectionData(rdata);
                            rscSetsInfo = constraintPHInfo.getPcmkRscSetsInfo();
                            if (rscSetsInfo != null) {
                                if (rdata.isColocation()) {
                                    rscSetsInfo.addColocation(rdata.getConstraintId(), constraintPHInfo);
                                } else {
                                    rscSetsInfo.addOrder(rdata.getConstraintId(), constraintPHInfo);
                                }
                            }
                            break;
                        }
                    }
                }
                if (constraintPHInfo == null && !preNewCphis.isEmpty()) {
                    /* placeholder */
                    constraintPHInfo = preNewCphis.remove(0);
                    rdataToCphi.put(rdata, constraintPHInfo);
                    constraintPHInfo.setRscSetConnectionData(rdata);
                }
                if (constraintPHInfo == null) {
                    constraintPHInfo = constraintPHInfoProvider.get();
                    constraintPHInfo.init(getBrowser(), rdata, ConstraintPHInfo.Preference.AND);
                    if (rscSetsInfo == null) {
                        rscSetsInfo = pcmkRscSetsInfoProvider.get();
                        rscSetsInfo.init(getBrowser());
                    }
                    if (rdata.isColocation()) {
                        rscSetsInfo.addColocation(rdata.getConstraintId(), constraintPHInfo);
                    } else {
                        rscSetsInfo.addOrder(rdata.getConstraintId(), constraintPHInfo);
                    }
                    constraintPHInfo.setPcmkRscSetsInfo(rscSetsInfo);
                    getBrowser().addNameToServiceInfoHash(constraintPHInfo);
                    newCphis.add(constraintPHInfo); /* have to add it later,
                                           so that ids are correct. */
                    rdataToCphi.put(rdata, constraintPHInfo);
                }
                serviceIsPresent.add(constraintPHInfo);

                final CrmXml.RscSet rscSet1 = rdata.getRscSet1();
                final CrmXml.RscSet rscSet2 = rdata.getRscSet2();
                if (rdata.isColocation()) {
                    /* colocation */
                    if (rscSet1 != null) {
                        for (final String rscId : rscSet1.getRscIds()) {
                            final ServiceInfo si =
                               getBrowser().getServiceInfoFromCRMId(rscId);
                            hg.addColocation(rdata.getConstraintId(), constraintPHInfo, si);
                        }
                    }
                    if (rscSet2 != null) {
                        for (final String rscId : rscSet2.getRscIds()) {
                            final ServiceInfo si = getBrowser().getServiceInfoFromCRMId( rscId);
                            hg.addColocation(rdata.getConstraintId(), si, constraintPHInfo);
                        }
                    }
                } else {
                    /* order */
                    if (rscSet1 != null) {
                        for (final String rscId : rscSet1.getRscIds()) {
                            final ServiceInfo si = getBrowser().getServiceInfoFromCRMId( rscId);
                            hg.addOrder(rdata.getConstraintId(), si, constraintPHInfo);
                        }
                    }
                    if (rscSet2 != null) {
                        for (final String rscId : rscSet2.getRscIds()) {
                            final ServiceInfo si = getBrowser().getServiceInfoFromCRMId(rscId);
                            hg.addOrder(rdata.getConstraintId(), constraintPHInfo, si);
                        }
                    }
                }
                if (Application.isLive(runMode)) {
                    constraintPHInfo.setUpdated(false);
                    constraintPHInfo.getService().setNew(false);
                }
            }

            for (final ConstraintPHInfo cphi : newCphis) {
                hg.addConstraintPlaceholder(cphi,
                                            null, /* pos */
                                            Application.RunMode.LIVE);
            }
        }

        /* colocations */
        final Map<String, List<CrmXml.ColocationData>> colocationMap = clStatus.getColocationRscMap();
        for (final Map.Entry<String, List<CrmXml.ColocationData>> colocationEntry : colocationMap.entrySet()) {
            final List<CrmXml.ColocationData> withs = colocationEntry.getValue();
            for (final CrmXml.ColocationData data : withs) {
                final String withRscId = data.getWithRsc();
                final ServiceInfo withSi = getBrowser().getServiceInfoFromCRMId(withRscId);
                final ServiceInfo siP = getBrowser().getServiceInfoFromCRMId(colocationEntry.getKey());
                hg.addColocation(data.getId(), siP, withSi);
            }
        }

        /* orders */
        final Map<String, List<CrmXml.OrderData>> orderMap = clStatus.getOrderRscMap();
        for (final Map.Entry<String, List<CrmXml.OrderData>> orderEntry : orderMap.entrySet()) {
            for (final CrmXml.OrderData data : orderEntry.getValue()) {
                final String rscThenId = data.getRscThen();
                final ServiceInfo si = getBrowser().getServiceInfoFromCRMId(rscThenId);
                if (si != null) { /* not yet complete */
                    final ServiceInfo siP = getBrowser().getServiceInfoFromCRMId(orderEntry.getKey());
                    if (siP != null && siP.getResourceAgent() != null) {
                        /* dangling orders and colocations */
                        if ((siP.getResourceAgent().isDrbddisk() || siP.getResourceAgent().isLinbitDrbd())
                            && "Filesystem".equals(si.getName())) {
                            final List<CrmXml.ColocationData> cds = clStatus.getColocationDatas(orderEntry.getKey());
                            if (cds != null) {
                                for (final CrmXml.ColocationData cd : cds) {
                                    if (cd.getWithRsc().equals(rscThenId)) {
                                        setFilesystemWithDrbd(siP, si);
                                    }
                                }
                            }
                        }
                        hg.addOrder(data.getId(), siP, si);
                    }
                }
            }
        }

        for (final Info info : treeMenuController.nodesToInfos(getNode().children())) {
            final ServiceInfo group = (ServiceInfo) info;
            if (group.getResourceAgent().isGroup() || group.getResourceAgent().isClone()) {
                for (final Info groupInfo : treeMenuController.nodesToInfos(group.getNode().children())) {
                    final ServiceInfo groupService = (ServiceInfo) groupInfo;
                    if (!groupServiceIsPresent.contains(groupService) && !groupService.getService().isNew()) {
                        /* remove the group service from the menu
                           that does not exist anymore. */
                        groupService.removeInfo();
                    }
                }
            }
        }
        hg.setServiceIsPresentList(serviceIsPresent);
        /** Set placeholders to "new", if they have no connections. */
        application.invokeInEdt(new Runnable() {
            @Override
            public void run() {
                hg.killRemovedEdges();
                final Map<String, ServiceInfo> idToInfoHash =
                                                   getBrowser().getNameToServiceInfoHash(ConstraintPHInfo.NAME);
                if (idToInfoHash != null) {
                    for (final Map.Entry<String, ServiceInfo> serviceEntry : idToInfoHash.entrySet()) {
                        final ConstraintPHInfo cphi = (ConstraintPHInfo) serviceEntry.getValue();
                        if (!cphi.getService().isNew() && cphi.isEmpty()) {
                            cphi.getService().setNew(true);
                        }
                    }
                }
                hg.killRemovedVertices();
                hg.scale();
            }
        });
    }
View Full Code Here

         * TODO: OR we need to get hb status only once
         */
        if (getBrowser().crmStatusFailed()) {
            return super.getInfoPanel();
        }
        final CrmGraph hg = getBrowser().getCrmGraph();
        if (infoPanel != null) {
            hg.pickBackground();
            return infoPanel;
        }
        final JPanel newPanel = new JPanel();
        newPanel.setBackground(ClusterBrowser.PANEL_BACKGROUND);
        newPanel.setLayout(new BoxLayout(newPanel, BoxLayout.PAGE_AXIS));
        if (getBrowser().getCrmXml() == null || getBrowser().getClusterStatus() == null) {
            return newPanel;
        }
        final ButtonCallback buttonCallback = new ButtonCallback() {
            private volatile boolean mouseStillOver = false;

            /**
             * Whether the whole thing should be enabled.
             */
            @Override
            public boolean isEnabled() {
                final Host dcHost = getBrowser().getDCHost();
                return dcHost != null && !Tools.versionBeforePacemaker(dcHost);
            }

            @Override
            public void mouseOut(final ComponentWithTest component) {
                if (!isEnabled()) {
                    return;
                }
                mouseStillOver = false;
                hg.stopTestAnimation((JComponent) component);
                component.setToolTipText("");
            }

            @Override
            public void mouseOver(final ComponentWithTest component) {
                if (!isEnabled()) {
                    return;
                }
                mouseStillOver = true;
                component.setToolTipText(ClusterBrowser.STARTING_PTEST_TOOLTIP);
                component.setToolTipBackground(Tools.getDefaultColor("ClusterBrowser.Test.Tooltip.Background"));
                Tools.sleep(250);
                if (!mouseStillOver) {
                    return;
                }
                mouseStillOver = false;
                final CountDownLatch startTestLatch = new CountDownLatch(1);
                hg.startTestAnimation((JComponent) component, startTestLatch);
                final Host dcHost = getBrowser().getDCHost();
                getBrowser().ptestLockAcquire();
                try {
                    final ClusterStatus clStatus = getBrowser().getClusterStatus();
                    clStatus.setPtestResult(null);
                    apply(dcHost, Application.RunMode.TEST);
                    final PtestData ptestData = new PtestData(CRM.getPtest(dcHost));
                    component.setToolTipText(ptestData.getToolTip());
                    clStatus.setPtestResult(ptestData);
                } finally {
                    getBrowser().ptestLockRelease();
                }
                startTestLatch.countDown();
            }
        };
        initCommitButton(buttonCallback);
        getBrowser().getRscDefaultsInfo().setApplyButton(getApplyButton());
        getBrowser().getRscDefaultsInfo().setRevertButton(getRevertButton());
        final JPanel mainPanel = new JPanel();
        mainPanel.setBackground(ClusterBrowser.PANEL_BACKGROUND);
        mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.PAGE_AXIS));
        final JPanel optionsPanel = new JPanel();
        optionsPanel.setBackground(ClusterBrowser.PANEL_BACKGROUND);
        optionsPanel.setLayout(new BoxLayout(optionsPanel, BoxLayout.PAGE_AXIS));
        optionsPanel.setAlignmentX(java.awt.Component.LEFT_ALIGNMENT);

        final JPanel buttonPanel = new JPanel(new BorderLayout());
        buttonPanel.setBackground(ClusterBrowser.BUTTON_PANEL_BACKGROUND);
        buttonPanel.setMinimumSize(new Dimension(0, 50));
        buttonPanel.setPreferredSize(new Dimension(0, 50));
        buttonPanel.setMaximumSize(new Dimension(Short.MAX_VALUE, 50));
        buttonPanel.add(getActionsButton(), BorderLayout.LINE_END);

        newPanel.add(buttonPanel);

        final String[] params = getParametersFromXML();
        addParams(optionsPanel,
                  params,
                  application.getDefaultSize("ClusterBrowser.DrbdResLabelWidth"),
                  application.getDefaultSize("ClusterBrowser.DrbdResFieldWidth"),
                  null);

        addRscDefaultsPanel(optionsPanel,
                            application.getDefaultSize("ClusterBrowser.DrbdResLabelWidth"),
                            application.getDefaultSize("ClusterBrowser.DrbdResFieldWidth"));
        getApplyButton().addActionListener(
            new ActionListener() {
                @Override
                public void actionPerformed(final ActionEvent e) {
                    LOG.debug1("actionPerformed: BUTTON: apply");
                    final Thread thread = new Thread(
                        new Runnable() {
                            @Override
                            public void run() {
                                getBrowser().clStatusLock();
                                apply(getBrowser().getDCHost(), Application.RunMode.LIVE);
                                getBrowser().clStatusUnlock();
                            }
                        }
                    );
                    thread.start();
                }
            }
        );
        getRevertButton().addActionListener(
            new ActionListener() {
                @Override
                public void actionPerformed(final ActionEvent e) {
                    LOG.debug1("actionPerformed: BUTTON: revert");
                    final Thread thread = new Thread(new Runnable() {
                        @Override
                        public void run() {
                            getBrowser().clStatusLock();
                            revert();
                            getBrowser().clStatusUnlock();
                        }
                    });
                    thread.start();
                }
            }
        );

        /* apply button */
        addApplyButton(buttonPanel);
        addRevertButton(buttonPanel);
        application.invokeLater(new Runnable() {
            @Override
            public void run() {
                setApplyButtons(null, params);
            }
        });

        mainPanel.add(optionsPanel);

        newPanel.add(getMoreOptionsPanel(application.getServiceLabelWidth() + application.getServiceFieldWidth() + 4));
        newPanel.add(new JScrollPane(mainPanel));

        hg.pickBackground();
        infoPanel = newPanel;
        infoPanelDone();
        return infoPanel;
    }
View Full Code Here

                         final Application.RunMode runMode) {
        application.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                newServiceInfo.getService().setResourceClass(newServiceInfo.getResourceAgent().getResourceClass());
                final CrmGraph hg = getBrowser().getCrmGraph();
                getBrowser().addNameToServiceInfoHash(newServiceInfo);
                if (!hg.addResource(newServiceInfo,
                                    null,
                                    pos,
                                    false, /* colocation only */
                                    false, /* order only */
                                    runMode)) {
                    final DefaultMutableTreeNode newServiceNode = treeMenuController.createMenuItem(
                            getBrowser().getServicesNode(),
                            newServiceInfo);
                    if (interactive) {
                        if (newServiceInfo.getResourceAgent().isProbablyMasterSlave()) {
                            /* only if it was added manually. */
                            newServiceInfo.changeType(ServiceInfo.MASTER_SLAVE_TYPE_STRING);
                        } else if (newServiceInfo.getResourceAgent().isProbablyClone()) {
                            newServiceInfo.changeType(ServiceInfo.CLONE_TYPE_STRING);
                        }
                    }
                    if (reloadNode) {
                        /* show it */
                        treeMenuController.reloadNode(getBrowser().getServicesNode(), false);
                        treeMenuController.reloadNode(newServiceNode, true);
                    }
                    getBrowser().reloadAllComboBoxes(newServiceInfo);
                    hg.scale();
                }
                hg.reloadServiceMenus();
            }
        });
    }
View Full Code Here

                        });
        addConstraintPlaceholderAnd.addAction(new MenuAction() {
            @Override
            public void run(final String text) {
                servicesInfo.hidePopup();
                final CrmGraph hg = servicesInfo.getBrowser().getCrmGraph();
                final ConstraintPHInfo constraintPHInfo = constraintPHInfoProvider.get();
                constraintPHInfo.init(servicesInfo.getBrowser(), null, ConstraintPHInfo.Preference.AND);
                constraintPHInfo.getService().setNew(true);
                servicesInfo.getBrowser().addNameToServiceInfoHash(constraintPHInfo);
                hg.addConstraintPlaceholder(constraintPHInfo, addConstraintPlaceholderAnd.getPos(), runMode);
                final PcmkRscSetsInfo rscSetsInfo = rscSetsInfoProvider.get();
                rscSetsInfo.init(servicesInfo.getBrowser(), constraintPHInfo);
                constraintPHInfo.setPcmkRscSetsInfo(rscSetsInfo);
                application.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        hg.scale();
                    }
                });
            }
        });
        items.add(addConstraintPlaceholderAnd);

        /* add constraint placeholder (or) */
        final MyMenuItem addConstraintPlaceholderOr =
                menuFactory.createMenuItem(Tools.getString("ServicesInfo.AddConstraintPlaceholderOr"),
                        null,
                        Tools.getString("ServicesInfo.AddConstraintPlaceholderOr.ToolTip"),
                        new AccessMode(AccessMode.ADMIN, AccessMode.NORMAL),
                        new AccessMode(AccessMode.OP, AccessMode.NORMAL))
                        .enablePredicate(new EnablePredicate() {
                            @Override
                            public String check() {
                                final String pmV = servicesInfo.getBrowser().getDCHost().getPacemakerVersion();
                                try {
                                    //TODO: get this from constraints-.rng files
                                    if (pmV == null || Tools.compareVersions(pmV, "1.1.7") <= 0) {
                                        return HbOrderInfo.NOT_AVAIL_FOR_PCMK_VERSION;
                                    }
                                } catch (final Exceptions.IllegalVersionException e) {
                                    LOG.appWarning("enablePredicate: unkonwn version: " + pmV);
                        /* enable it, if version check doesn't work */
                                }
                                if (servicesInfo.getBrowser().crmStatusFailed()) {
                                    return ClusterBrowser.UNKNOWN_CLUSTER_STATUS_STRING;
                                }
                                return null;
                            }
                        });
        addConstraintPlaceholderOr.addAction(new MenuAction() {
            @Override
            public void run(final String text) {
                servicesInfo.hidePopup();
                final CrmGraph hg = servicesInfo.getBrowser().getCrmGraph();
                final ConstraintPHInfo constraintPHInfo = constraintPHInfoProvider.get();
                constraintPHInfo.init(servicesInfo.getBrowser(), null, ConstraintPHInfo.Preference.OR);
                constraintPHInfo.getService().setNew(true);
                servicesInfo.getBrowser().addNameToServiceInfoHash(constraintPHInfo);
                hg.addConstraintPlaceholder(constraintPHInfo, addConstraintPlaceholderOr.getPos(), runMode);
                final PcmkRscSetsInfo rscSetsInfo = rscSetsInfoProvider.get();
                rscSetsInfo.init(servicesInfo.getBrowser(), constraintPHInfo);
                constraintPHInfo.setPcmkRscSetsInfo(rscSetsInfo);
                application.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        hg.scale();
                    }
                });
            }
        });
        items.add(addConstraintPlaceholderOr);
View Full Code Here

    void checkNumberOfVertices(final String name, final int should) {
        if (aborted) {
            return;
        }
        final CrmGraph graph = cluster.getBrowser().getCrmGraph();
        int i = 0;
        while (i < 10 && should != graph.getNumberOfVertices()) {
            LOG.info("checkNumberOfVertices: " + name
                     + " number of vertices: "
                     + should + " -> "
                     + graph.getNumberOfVertices());
            Tools.sleep(1000);
            i++;
        }
    }
View Full Code Here

    }

    /** Adds old style drbddisk service in the heartbeat and graph. */
    public void addDrbdDisk(final FilesystemRaInfo fi, final Host dcHost, final String drbdId, final Application.RunMode runMode) {
        final Point2D p = null;
        final CrmGraph crmg = getBrowser().getCrmGraph();
        final DrbddiskInfo di =
            (DrbddiskInfo) getBrowser().getServicesInfo().addServicePanel(getBrowser().getCrmXml().getDrbddiskResourceAgent(),
                                                                          p,
                                                                          true,
                                                                          drbdId,
                                                                          null,
                                                                          runMode);
        di.setGroupInfo(fi.getGroupInfo());
        getBrowser().addToHeartbeatIdList(di);
        fi.setDrbddiskInfo(di);
        final GroupInfo giFi = fi.getGroupInfo();
        if (giFi == null) {
            crmg.addColocation(null, fi, di);
            crmg.addOrder(null, di, fi);
        } else {
            crmg.addColocation(null, giFi, di);
            crmg.addOrder(null, di, giFi);
        }
        di.waitForInfoPanel();
        di.getWidget("1", null).setValueAndWait(new StringValue(getDrbdResourceInfo().getName()));
        di.apply(dcHost, runMode);
        di.getResource().setNew(false);
View Full Code Here

TOP

Related Classes of lcmc.crm.ui.CrmGraph

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.