Search in sources :

Example 16 with ServerType

use of com.cubrid.cubridmanager.core.common.model.ServerType in project cubrid-manager by CUBRID.

the class DataProvider method setDefaultValue.

/**
	 * 
	 * Set the default value
	 * 
	 */
private void setDefaultValue() {
    boolean isOldExecuteHostStatTask = isExecuteHostStatTask;
    isExecuteHostStatTask = false;
    isExecuteHeartbeatTask = false;
    isExecuteBrokerStatTask = false;
    isExecuteDbModeTask = false;
    errorMsg = "";
    getHeartbeatNodeInfoTask = null;
    hostNodeList.clear();
    connectedHostNode = null;
    uniqueDbNodeList.clear();
    uniqueBrokerNodeList.clear();
    List<DataUpdateListener> listenerList = generator.getListeners();
    for (DataUpdateListener listener : listenerList) {
        addHaNode(listener.getModel());
    }
    if (connectedHostNode == null && !hostNodeList.isEmpty()) {
        connectedHostNode = hostNodeList.get(0);
    }
    if (connectedHostNode == null) {
        return;
    }
    filterDatabaseDataProvider();
    if (!uniqueBrokerNodeList.isEmpty()) {
        brokerDataProvider.setDataGenerator(generator);
        brokerDataProvider.setBrokerNodeList(uniqueBrokerNodeList);
    }
    //Connect host and set time out
    if (!connectedHostNode.isConnected() && !connectedHostNode.isConnecting()) {
        for (final HostNode hostNode : hostNodeList) {
            Display.getDefault().syncExec(new Runnable() {

                public void run() {
                    hostNode.setConnected(false);
                }
            });
        }
        ConnectionManager.connectHost(connectedHostNode, true, !isFirstConnected);
    }
    final boolean isCanConnected = connectedHostNode.isConnected();
    for (final HostNode hostNode : hostNodeList) {
        if (hostNode != connectedHostNode) {
            Display.getDefault().syncExec(new Runnable() {

                public void run() {
                    hostNode.setConnected(isCanConnected);
                    hostNode.setErrorMsg(connectedHostNode.getLastErrorMsg());
                }
            });
        }
    }
    if (isCanConnected) {
        isFirstConnected = true;
        serverInfo = connectedHostNode.getServerInfo();
        if (serverInfo != null) {
            MonitoringTask monitoringTask = serverInfo.getMonitoringTask();
            monitoringTask.setTimeout(DataProvider.TIME_OUT_MILL);
        }
    } else {
        isFirstConnected = false;
    }
    for (DataUpdateListener listener : listenerList) {
        if (listener instanceof HostMonitorPartHelper) {
            isExecuteHostStatTask = isCanConnected;
            isExecuteHeartbeatTask = isCanConnected;
        } else if (listener instanceof DatabaseMonitorPartHelper) {
            isExecuteHostStatTask = isCanConnected;
            isExecuteHeartbeatTask = isCanConnected;
            isExecuteDbModeTask = isCanConnected;
        } else if (listener instanceof HostDashboardViewPart) {
            isExecuteHostStatTask = isCanConnected;
            isExecuteBrokerStatTask = isCanConnected;
        } else if (listener instanceof DatabaseDashboardViewPart) {
            isExecuteHostStatTask = isCanConnected;
            isExecuteHeartbeatTask = isCanConnected;
            isExecuteDbModeTask = isCanConnected;
        }
    }
    ServerType serverType = serverInfo == null ? null : serverInfo.getServerType();
    isExecuteBrokerStatTask = isExecuteBrokerStatTask && (serverType == ServerType.BOTH || serverType == ServerType.BROKER);
    if (isOldExecuteHostStatTask != isExecuteHostStatTask) {
        hostStatRequestCount = 0;
    }
}
Also used : HostMonitorPartHelper(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.helper.HostMonitorPartHelper) ServerType(com.cubrid.cubridmanager.core.common.model.ServerType) DatabaseMonitorPartHelper(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.helper.DatabaseMonitorPartHelper) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) HostDashboardViewPart(com.cubrid.cubridmanager.ui.mondashboard.editor.HostDashboardViewPart) DatabaseDashboardViewPart(com.cubrid.cubridmanager.ui.mondashboard.editor.DatabaseDashboardViewPart)

Example 17 with ServerType

use of com.cubrid.cubridmanager.core.common.model.ServerType in project cubrid-manager by CUBRID.

the class UserManagementTableViewerSorter method createDialogArea.

/**
	 * Create dialog area content
	 * 
	 * @param parent the parent composite
	 * @return the control
	 */
protected Control createDialogArea(Composite parent) {
    Composite parentComp = (Composite) super.createDialogArea(parent);
    Composite composite = new Composite(parentComp, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    composite.setLayout(layout);
    Label tipLabel = new Label(composite, SWT.LEFT | SWT.WRAP);
    tipLabel.setText(Messages.msgUserManagementList);
    tipLabel.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    // create CUBRID Manager user information table
    String[] columnNameArr = new String[] { Messages.tblColumnUserId, Messages.tblColumnDbAuth, Messages.tblColumnBrokerAuth, Messages.tblColumnMonitorAuth };
    final ServerType serverType = server.getServerInfo().getServerType();
    if (serverType == ServerType.DATABASE) {
        columnNameArr = new String[] { Messages.tblColumnUserId, Messages.tblColumnDbAuth, Messages.tblColumnMonitorAuth };
    } else if (serverType == ServerType.BROKER) {
        columnNameArr = new String[] { Messages.tblColumnUserId, Messages.tblColumnBrokerAuth, Messages.tblColumnMonitorAuth };
    }
    tableViewer = CommonUITool.createCommonTableViewer(composite, new UserManagementTableViewerSorter(), columnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, 200));
    userManageTable = tableViewer.getTable();
    initialTableModel();
    tableViewer.setInput(serverUserInfoTableList);
    for (int i = 0; i < userManageTable.getColumnCount(); i++) {
        userManageTable.getColumn(i).pack();
    }
    userManageTable.addSelectionListener(new SelectionAdapter() {

        @SuppressWarnings("rawtypes")
        public void widgetSelected(SelectionEvent event) {
            if (userManageTable.getSelectionCount() > 0) {
                StructuredSelection selection = (StructuredSelection) tableViewer.getSelection();
                boolean isHasAdmin = false;
                if (selection != null && !selection.isEmpty()) {
                    Iterator it = selection.iterator();
                    while (it.hasNext()) {
                        Map map = (Map) it.next();
                        if (map.get("0").equals("admin")) {
                            isHasAdmin = true;
                            break;
                        }
                    }
                }
                deleteButton.setEnabled(!isHasAdmin);
            } else {
                deleteButton.setEnabled(false);
            }
            if (userManageTable.getSelectionCount() == 1) {
                editButton.setEnabled(true);
            } else {
                editButton.setEnabled(false);
            }
        }
    });
    // create button
    Composite buttonComp = new Composite(composite, SWT.NONE);
    RowLayout rowLayout = new RowLayout();
    rowLayout.spacing = 5;
    buttonComp.setLayout(rowLayout);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalAlignment = GridData.END;
    buttonComp.setLayoutData(gridData);
    Button addButton = new Button(buttonComp, SWT.PUSH);
    addButton.setText(Messages.btnAdd);
    addButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            UserManagementWizard userManagementWizard = new UserManagementWizard(server, null, serverUserInfoList);
            CMWizardDialog dialog = new CMWizardDialog(getShell(), userManagementWizard);
            int returnCode = dialog.open();
            if (returnCode == IDialogConstants.OK_ID) {
                ServerUserInfo userInfo = userManagementWizard.getServerUserInfo();
                Map<String, Object> map = new HashMap<String, Object>();
                map.put("0", userInfo.getUserName());
                if (serverType == ServerType.BOTH) {
                    map.put("1", userInfo.getDbCreateAuthType().getText());
                    map.put("2", userInfo.getCasAuth().getText());
                    map.put("3", userInfo.getStatusMonitorAuth().getText());
                    map.put("4", userInfo);
                }
                if (serverType == ServerType.DATABASE) {
                    map.put("1", userInfo.getDbCreateAuthType().getText());
                    map.put("2", userInfo.getStatusMonitorAuth().getText());
                    map.put("3", userInfo);
                } else if (serverType == ServerType.BROKER) {
                    map.put("1", userInfo.getCasAuth().getText());
                    map.put("2", userInfo.getStatusMonitorAuth().getText());
                    map.put("3", userInfo);
                }
                serverUserInfoTableList.add(map);
                serverUserInfoList.add(userInfo);
                tableViewer.refresh();
                for (int i = 0; i < userManageTable.getColumnCount(); i++) {
                    userManageTable.getColumn(i).pack();
                }
            }
        }
    });
    editButton = new Button(buttonComp, SWT.PUSH);
    editButton.setText(Messages.btnEdit);
    editButton.addSelectionListener(new SelectionAdapter() {

        @SuppressWarnings({ "rawtypes", "unchecked" })
        public void widgetSelected(SelectionEvent event) {
            StructuredSelection selection = (StructuredSelection) tableViewer.getSelection();
            ServerUserInfo serverUserInfo = null;
            if (selection != null && !selection.isEmpty()) {
                Map map = (Map) selection.getFirstElement();
                if (serverType == ServerType.BOTH) {
                    serverUserInfo = (ServerUserInfo) map.get("4");
                } else {
                    serverUserInfo = (ServerUserInfo) map.get("3");
                }
                UserManagementWizard userManagementWizard = new UserManagementWizard(server, serverUserInfo, serverUserInfoList);
                CMWizardDialog dialog = new CMWizardDialog(getShell(), userManagementWizard);
                int returnCode = dialog.open();
                if (returnCode == IDialogConstants.OK_ID) {
                    ServerUserInfo userInfo = userManagementWizard.getServerUserInfo();
                    map.put("0", userInfo.getUserName());
                    if (serverType == ServerType.BOTH) {
                        map.put("1", userInfo.getDbCreateAuthType().getText());
                        map.put("2", userInfo.getCasAuth().getText());
                        map.put("3", userInfo.getStatusMonitorAuth().getText());
                        map.put("4", userInfo);
                    }
                    if (serverType == ServerType.DATABASE) {
                        map.put("1", userInfo.getDbCreateAuthType().getText());
                        map.put("2", userInfo.getStatusMonitorAuth().getText());
                        map.put("3", userInfo);
                    } else if (serverType == ServerType.BROKER) {
                        map.put("1", userInfo.getCasAuth().getText());
                        map.put("2", userInfo.getStatusMonitorAuth().getText());
                        map.put("3", userInfo);
                    }
                    tableViewer.refresh();
                    for (int i = 0; i < userManageTable.getColumnCount(); i++) {
                        userManageTable.getColumn(i).pack();
                    }
                }
            }
        }
    });
    editButton.setEnabled(userManageTable.getSelectionCount() == 1);
    deleteButton = new Button(buttonComp, SWT.PUSH);
    deleteButton.setText(Messages.btnDelete);
    deleteButton.addSelectionListener(new SelectionAdapter() {

        @SuppressWarnings("rawtypes")
        public void widgetSelected(SelectionEvent event) {
            boolean isDelete = CommonUITool.openConfirmBox(getShell(), Messages.msgDeleteUserConfirm);
            if (!isDelete) {
                return;
            }
            StructuredSelection selection = (StructuredSelection) tableViewer.getSelection();
            if (selection != null && !selection.isEmpty()) {
                Map[] userInfoMapArr = new Map[selection.size()];
                Iterator it = selection.iterator();
                int i = 0;
                while (it.hasNext()) {
                    Map map = (Map) it.next();
                    userInfoMapArr[i] = map;
                    i++;
                }
                deleteUser(userInfoMapArr);
            }
            tableViewer.refresh();
        }
    });
    deleteButton.setEnabled(userManageTable.getSelectionCount() == 1);
    setTitle(Messages.titleUserManagementDialog);
    setMessage(Messages.msgUserManagementDialog);
    return parentComp;
}
Also used : ServerType(com.cubrid.cubridmanager.core.common.model.ServerType) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) UserManagementWizard(com.cubrid.cubridmanager.ui.common.control.UserManagementWizard) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Iterator(java.util.Iterator) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) HashMap(java.util.HashMap) Map(java.util.Map) CMWizardDialog(com.cubrid.common.ui.spi.dialog.CMWizardDialog)

Example 18 with ServerType

use of com.cubrid.cubridmanager.core.common.model.ServerType in project cubrid-manager by CUBRID.

the class FinishTask method call.

public Integer call() {
    ProgressBar bar = (ProgressBar) item.getData(MultiHostConnectionDialog.KEY_BAR);
    MonitorDashboardPreference monPref = new MonitorDashboardPreference();
    boolean isRunUpdateCmUserTask = false;
    BrokerInfos brokerInfos = null;
    int size = tasks.size();
    int taskIdx = 1;
    for (ITask task : tasks) {
        if (task instanceof MonitoringTask) {
            if (!serverInfo.isConnected()) {
                CMHostNodePersistManager.getInstance().addServer(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getUserName(), serverInfo);
                MonitoringTask monitoringTask = (MonitoringTask) task;
                serverInfo = monitoringTask.connectServer(Version.releaseVersion, monPref.getHAHeartBeatTimeout());
                if (serverInfo.isConnected()) {
                    CMHostNodePersistManager.getInstance().addServer(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getUserName(), serverInfo);
                } else {
                    CMHostNodePersistManager.getInstance().removeServer(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getUserName());
                }
            }
        } else if ((task instanceof UpdateCMUserTask)) {
            updateCMUserAuthInfo(task, isRunUpdateCmUserTask);
        } else {
            task.execute();
        }
        final String msg = task.getErrorMsg();
        if (msg != null && msg.length() > 0) {
            item.setText(3, msg);
            disConnect();
            isFinished = true;
            updateIcon();
            return 1;
        }
        if (task instanceof GetEnvInfoTask) {
            GetEnvInfoTask getEnvInfoTask = (GetEnvInfoTask) task;
            EnvInfo envInfo = getEnvInfoTask.loadEnvInfo();
            serverInfo.setEnvInfo(envInfo);
            String clientVersion = getClientVerion();
            if (!isClientSupport(clientVersion)) {
                item.setText(3, Messages.bind(Messages.errNoSupportServerVersion, clientVersion));
                disConnect();
                isFinished = true;
                updateIcon();
                return 2;
            }
            String jdbcVersion = serverInfo.getJdbcDriverVersion();
            if (serverInfo.validateJdbcVersion(jdbcVersion)) {
                if (ServerJdbcVersionMapping.JDBC_SELF_ADAPTING_VERSION.equals(jdbcVersion)) {
                    serverInfo.setJdbcDriverVersion(ServerInfo.getAutoDetectJdbcVersion(serverInfo.getFullServerVersionKey()));
                }
            } else {
                if (ServerJdbcVersionMapping.JDBC_SELF_ADAPTING_VERSION.equals(jdbcVersion)) {
                    item.setText(3, Messages.errNoSupportDriver);
                } else {
                    item.setText(3, Messages.errSelectSupportDriver);
                }
                disConnect();
                isFinished = true;
                updateIcon();
                return 3;
            }
        } else if (task instanceof GetDatabaseListTask) {
            GetDatabaseListTask getDatabaseListTask = (GetDatabaseListTask) task;
            List<DatabaseInfo> databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
            if (databaseInfoList != null) {
                allDatabaseInfoList.addAll(databaseInfoList);
            }
        } else if (task instanceof GetCMConfParameterTask) {
            GetCMConfParameterTask getCMConfParameterTask = (GetCMConfParameterTask) task;
            Map<String, String> confParameters = getCMConfParameterTask.getConfParameters();
            ServerType serverType = ServerType.BOTH;
            if (confParameters != null) {
                String target = confParameters.get(CubridManagerConfParaConstants.CM_TARGET);
                if (target != null) {
                    if (target.indexOf("broker") >= 0 && target.indexOf("server") >= 0) {
                        serverType = ServerType.BOTH;
                    } else if (target.indexOf("broker") >= 0) {
                        serverType = ServerType.BROKER;
                    } else if (target.indexOf("server") >= 0) {
                        serverType = ServerType.DATABASE;
                    }
                }
            }
            if (serverInfo != null) {
                serverInfo.setServerType(serverType);
            }
        } else if (task instanceof CommonQueryTask) {
            CommonQueryTask<BrokerInfos> getBrokerTask = (CommonQueryTask<BrokerInfos>) task;
            brokerInfos = getBrokerTask.getResultModel();
            if (serverInfo != null) {
                serverInfo.setBrokerInfos(brokerInfos);
            }
        } else if (task instanceof GetCMUserListTask) {
            if (serverInfo != null && serverInfo.isConnected()) {
                GetCMUserListTask getUserInfoTask = (GetCMUserListTask) task;
                List<ServerUserInfo> serverUserInfoList = getUserInfoTask.getServerUserInfoList();
                for (int i = 0; serverUserInfoList != null && i < serverUserInfoList.size(); i++) {
                    ServerUserInfo userInfo = serverUserInfoList.get(i);
                    if (userInfo != null && userInfo.getUserName().equals(serverInfo.getUserName())) {
                        serverInfo.setLoginedUserInfo(userInfo);
                        break;
                    }
                }
                List<DatabaseInfo> databaseInfoList = serverInfo.getLoginedUserInfo().getDatabaseInfoList();
                if (databaseInfoList != null) {
                    authDatabaseList.addAll(databaseInfoList);
                }
                isRunUpdateCmUserTask = CubridDatabasesFolderLoader.filterDatabaseList(serverInfo, allDatabaseInfoList, authDatabaseList);
                if (isRunUpdateCmUserTask) {
                    serverInfo.getLoginedUserInfo().setDatabaseInfoList(authDatabaseList);
                }
            }
        } else if (task instanceof GetCubridConfParameterTask) {
            GetCubridConfParameterTask getCubridConfParameterTask = (GetCubridConfParameterTask) task;
            Map<String, Map<String, String>> confParas = getCubridConfParameterTask.getConfParameters();
            if (serverInfo != null) {
                serverInfo.setCubridConfParaMap(confParas);
            }
        } else if (task instanceof GetBrokerConfParameterTask) {
            GetBrokerConfParameterTask getBrokerConfParameterTask = (GetBrokerConfParameterTask) task;
            Map<String, Map<String, String>> confParas = getBrokerConfParameterTask.getConfParameters();
            if (serverInfo != null) {
                serverInfo.setBrokerConfParaMap(confParas);
            }
        } else if (task instanceof FinishTask) {
            isSuccess = true;
            server.getLoader().setLoaded(false);
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(server, CubridNodeChangedEventType.SERVER_CONNECTED));
        }
        bar.setSelection(taskIdx++ / size * 100);
        if (isCanceled()) {
            isFinished = true;
            updateIcon();
            return 4;
        }
    }
    bar.setSelection(100);
    item.setText(3, Messages.msgConneted);
    isFinished = true;
    return 0;
}
Also used : ServerType(com.cubrid.cubridmanager.core.common.model.ServerType) MonitorDashboardPreference(com.cubrid.cubridmanager.ui.mondashboard.preference.MonitorDashboardPreference) ITask(com.cubrid.common.core.task.ITask) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) GetCMConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask) UpdateCMUserTask(com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) ArrayList(java.util.ArrayList) List(java.util.List) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) ProgressBar(org.eclipse.swt.widgets.ProgressBar) GetCMUserListTask(com.cubrid.cubridmanager.core.common.task.GetCMUserListTask) GetCubridConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask) GetEnvInfoTask(com.cubrid.cubridmanager.core.common.task.GetEnvInfoTask) GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) GetBrokerConfParameterTask(com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask) Map(java.util.Map) EnvInfo(com.cubrid.cubridmanager.core.common.model.EnvInfo)

Example 19 with ServerType

use of com.cubrid.cubridmanager.core.common.model.ServerType in project cubrid-manager by CUBRID.

the class ConnectHostExecutor method runLoop.

private boolean runLoop(final IProgressMonitor monitor) {
    MonitorDashboardPreference monPref = new MonitorDashboardPreference();
    isContinue = true;
    boolean isRunUpdateCmUserTask = false;
    BrokerInfos brokerInfos = null;
    /*To avoid invalid thread access exception*/
    beginTask(monitor);
    for (ITask task : taskList) {
        if (task instanceof MonitoringTask) {
            if (!serverInfo.isConnected()) {
                addServerInHashMap(serverInfo);
                MonitoringTask monitoringTask = (MonitoringTask) task;
                serverInfo = monitoringTask.connectServer(Version.releaseVersion, monPref.getHAHeartBeatTimeout());
                if (serverInfo.isConnected()) {
                    addServerInHashMap(serverInfo);
                } else {
                    removeServerFromHashMap(serverInfo);
                }
            }
            changePassword();
        } else if ((task instanceof UpdateCMUserTask)) {
            updateCMUserAuthInfo(task, isRunUpdateCmUserTask);
        } else {
            task.execute();
        }
        final String msg = task.getErrorMsg();
        if (monitor.isCanceled()) {
            disConnect();
            return false;
        }
        if (msg != null) {
            boolean emptyMsg = StringUtil.isEmpty(msg);
            // for TOOLS-2142 logging
            try {
                if (task instanceof MonitoringTask) {
                    String request = ((MonitoringTask) task).getRequest();
                    char[] requestCharArray = request.toCharArray();
                    int sp = request.indexOf("id:");
                    if (sp != -1) {
                        sp += "id:".length();
                        for (int i = sp; i < requestCharArray.length; i++) {
                            if (requestCharArray[i] == '\n') {
                                break;
                            }
                            requestCharArray[i] = '*';
                        }
                    }
                    sp = request.indexOf("password:");
                    if (sp != -1) {
                        sp += "password:".length();
                        for (int i = sp; i < requestCharArray.length; i++) {
                            if (requestCharArray[i] == '\n') {
                                break;
                            }
                            requestCharArray[i] = '*';
                        }
                    }
                    LOGGER.debug("CMS request : \n" + new String(requestCharArray));
                    LOGGER.debug("CMS error : \n" + task.getErrorMsg());
                    LOGGER.debug("CMS warn : \n" + task.getWarningMsg());
                }
            } catch (Exception e) {
                LOGGER.error("", e);
            }
            String lowerMsg = msg.toLowerCase();
            // Connection refused: connect
            if (lowerMsg.indexOf("connection refused: connect") != -1) {
                String localizedMsg = Messages.errConnectionRefused;
                if (!prepareMessage(monitor, localizedMsg)) {
                    return false;
                }
            } else //the socket "Connection reset" occasional error is unnecessary to display, and it will affect user experience.
            if (lowerMsg.indexOf("connection reset") != -1) {
                String localizedMsg = Messages.errConnectionReset;
                if (!prepareMessage(monitor, localizedMsg)) {
                    return false;
                }
            } else // connect timed out
            if (lowerMsg.indexOf("connect timed out") != -1) {
                String localizedMsg = Messages.errConnectTimedOut;
                if (!prepareMessage(monitor, localizedMsg)) {
                    return false;
                }
            } else // user not found
            if (lowerMsg.indexOf("user not found") != -1) {
                String localizedMsg = Messages.errUserNotFound;
                if (!prepareMessage(monitor, localizedMsg)) {
                    return false;
                }
            } else // Incorrect password
            if (lowerMsg.indexOf("incorrect password") != -1) {
                String localizedMsg = Messages.errUserPasswordConnect;
                if (!prepareMessage(monitor, localizedMsg)) {
                    return false;
                }
            } else // No route to host connect
            if (lowerMsg.indexOf("no route to host connect") != -1) {
                String localizedMsg = Messages.errConnectAddress;
                if (!prepareMessage(monitor, localizedMsg)) {
                    return false;
                }
            } else // There is no error message but there have some error about brokers.
            if (emptyMsg && StringUtil.isEqual(task.getTaskname(), BrokerInfos.TASK_NAME)) {
                String localizedMsg = Messages.errConnectionByBrokerConfig;
                if (!prepareMessage(monitor, localizedMsg)) {
                    return false;
                }
            } else {
                String localizedMsg = Messages.bind(Messages.errConnectionFailed, msg);
                if (!prepareMessage(monitor, localizedMsg)) {
                    return false;
                }
            }
        }
        if (task instanceof GetEnvInfoTask) {
            GetEnvInfoTask getEnvInfoTask = (GetEnvInfoTask) task;
            EnvInfo envInfo = getEnvInfoTask.loadEnvInfo();
            serverInfo.setEnvInfo(envInfo);
            String clientVersion = getClientVerion();
            if (!isClientSupport(clientVersion)) {
                openErrorBox(shell, Messages.bind(Messages.errNoSupportServerVersion, clientVersion), monitor);
            }
            //for multi host monitor statistic and monitor dashboard
            if (isCheckJdbc) {
                String jdbcVersion = serverInfo.getJdbcDriverVersion();
                if (serverInfo.validateJdbcVersion(jdbcVersion)) {
                    if (ServerJdbcVersionMapping.JDBC_SELF_ADAPTING_VERSION.equals(jdbcVersion)) {
                        serverInfo.setJdbcDriverVersion(ServerInfo.getAutoDetectJdbcVersion(serverInfo.getFullServerVersionKey()));
                    }
                } else {
                    if (ServerJdbcVersionMapping.JDBC_SELF_ADAPTING_VERSION.equals(jdbcVersion)) {
                        openErrorBox(shell, Messages.errNoSupportDriver, monitor);
                    } else {
                        openErrorBox(shell, Messages.errSelectSupportDriver, monitor);
                    }
                    disConnect();
                    return false;
                }
            }
        } else if (task instanceof GetDatabaseListTask) {
            GetDatabaseListTask getDatabaseListTask = (GetDatabaseListTask) task;
            List<DatabaseInfo> databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
            if (databaseInfoList != null) {
                allDatabaseInfoList.addAll(databaseInfoList);
            }
        } else if (task instanceof GetCMConfParameterTask) {
            GetCMConfParameterTask getCMConfParameterTask = (GetCMConfParameterTask) task;
            Map<String, String> confParameters = getCMConfParameterTask.getConfParameters();
            ServerType serverType = ServerType.BOTH;
            if (confParameters != null) {
                String target = confParameters.get(ConfConstants.CM_TARGET);
                if (target != null) {
                    if (target.indexOf("broker") >= 0 && target.indexOf("server") >= 0) {
                        serverType = ServerType.BOTH;
                    } else if (target.indexOf("broker") >= 0) {
                        serverType = ServerType.BROKER;
                    } else if (target.indexOf("server") >= 0) {
                        serverType = ServerType.DATABASE;
                    }
                }
                String supportMonStatistic = confParameters.get(ConfConstants.SUPPORT_MON_STATISTIC);
                if ("yes".equalsIgnoreCase(supportMonStatistic)) {
                    serverInfo.setSupportMonitorStatistic(true);
                } else {
                    serverInfo.setSupportMonitorStatistic(false);
                }
            }
            if (serverInfo != null) {
                serverInfo.setServerType(serverType);
            }
        } else if (task instanceof CommonQueryTask) {
            @SuppressWarnings("unchecked") CommonQueryTask<BrokerInfos> getBrokerTask = (CommonQueryTask<BrokerInfos>) task;
            brokerInfos = getBrokerTask.getResultModel();
            if (serverInfo != null) {
                serverInfo.setBrokerInfos(brokerInfos);
            }
        } else if (task instanceof GetCMUserListTask) {
            if (serverInfo != null && serverInfo.isConnected()) {
                GetCMUserListTask getUserInfoTask = (GetCMUserListTask) task;
                List<ServerUserInfo> serverUserInfoList = getUserInfoTask.getServerUserInfoList();
                for (int i = 0; serverUserInfoList != null && i < serverUserInfoList.size(); i++) {
                    ServerUserInfo userInfo = serverUserInfoList.get(i);
                    if (userInfo != null && userInfo.getUserName().equals(serverInfo.getUserName())) {
                        serverInfo.setLoginedUserInfo(userInfo);
                        break;
                    }
                }
                List<DatabaseInfo> databaseInfoList = serverInfo.getLoginedUserInfo().getDatabaseInfoList();
                if (databaseInfoList != null) {
                    authDatabaseList.addAll(databaseInfoList);
                }
                isRunUpdateCmUserTask = CubridDatabasesFolderLoader.filterDatabaseList(serverInfo, allDatabaseInfoList, authDatabaseList);
                if (isRunUpdateCmUserTask) {
                    serverInfo.getLoginedUserInfo().setDatabaseInfoList(authDatabaseList);
                }
            }
        } else if (task instanceof GetCubridConfParameterTask) {
            GetCubridConfParameterTask getCubridConfParameterTask = (GetCubridConfParameterTask) task;
            Map<String, Map<String, String>> confParas = getCubridConfParameterTask.getConfParameters();
            if (serverInfo != null) {
                serverInfo.setCubridConfParaMap(confParas);
            }
        } else if (task instanceof GetBrokerConfParameterTask) {
            GetBrokerConfParameterTask getBrokerConfParameterTask = (GetBrokerConfParameterTask) task;
            Map<String, Map<String, String>> confParas = getBrokerConfParameterTask.getConfParameters();
            if (serverInfo != null) {
                serverInfo.setBrokerConfParaMap(confParas);
            }
        }
        if (monitor.isCanceled() || !isContinue) {
            disConnect();
            return false;
        }
    }
    return true;
}
Also used : ServerType(com.cubrid.cubridmanager.core.common.model.ServerType) MonitorDashboardPreference(com.cubrid.cubridmanager.ui.mondashboard.preference.MonitorDashboardPreference) ITask(com.cubrid.common.core.task.ITask) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) GetCMConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask) UpdateCMUserTask(com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) ArrayList(java.util.ArrayList) List(java.util.List) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) GetCMUserListTask(com.cubrid.cubridmanager.core.common.task.GetCMUserListTask) GetCubridConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask) GetEnvInfoTask(com.cubrid.cubridmanager.core.common.task.GetEnvInfoTask) GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) GetBrokerConfParameterTask(com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask) Map(java.util.Map) EnvInfo(com.cubrid.cubridmanager.core.common.model.EnvInfo)

Example 20 with ServerType

use of com.cubrid.cubridmanager.core.common.model.ServerType in project cubrid-manager by CUBRID.

the class StopServiceAction method isSupported.

/**
	 * 
	 * Return whether this action support this object,if not support,this action
	 * will be disabled
	 * 
	 * @param obj the Object
	 * @return <code>true</code> if support this obj;<code>false</code>
	 *         otherwise
	 */
public boolean isSupported(Object obj) {
    if (obj instanceof ICubridNode) {
        ICubridNode node = (ICubridNode) obj;
        CubridServer server = node.getServer();
        if (server == null) {
            return false;
        }
        ServerInfo serverInfo = server.getServerInfo();
        ServerType serverType = serverInfo == null ? null : serverInfo.getServerType();
        if (serverType == null || serverType == ServerType.BROKER) {
            return false;
        }
        if (server != null && server.isConnected() && serverInfo != null && serverInfo.getLoginedUserInfo() != null && serverInfo.getLoginedUserInfo().isAdmin()) {
            return true;
        }
    }
    return false;
}
Also used : ServerType(com.cubrid.cubridmanager.core.common.model.ServerType) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridServer(com.cubrid.common.ui.spi.model.CubridServer)

Aggregations

ServerType (com.cubrid.cubridmanager.core.common.model.ServerType)26 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)10 Map (java.util.Map)9 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)7 MonitoringTask (com.cubrid.cubridmanager.core.common.task.MonitoringTask)7 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)7 GetBrokerConfParameterTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask)6 GetCMConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask)6 GetCMUserListTask (com.cubrid.cubridmanager.core.common.task.GetCMUserListTask)6 GetCubridConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask)6 GetEnvInfoTask (com.cubrid.cubridmanager.core.common.task.GetEnvInfoTask)6 GetDatabaseListTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask)6 HashMap (java.util.HashMap)6 ITask (com.cubrid.common.core.task.ITask)5 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)5 ArrayList (java.util.ArrayList)5 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)4 UpdateCMUserTask (com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask)4 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)3 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)3