Search in sources :

Example 31 with ServerInfo

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

the class CMDatabaseNavigatorMenu method getDatabaseLabel.

/**
	 * return a text of selected database on the query editor
	 *
	 * @param database
	 * @return
	 */
public String getDatabaseLabel(CubridDatabase cubridDatabase) {
    DatabaseInfo dbInfo = cubridDatabase.getDatabaseInfo();
    ServerInfo svrInfo = null;
    String text = "";
    if (dbInfo != null) {
        text = dbInfo.getDbName();
        svrInfo = dbInfo.getServerInfo();
    }
    String userName = cubridDatabase.getUserName();
    if (userName != null && userName.trim().length() > 0) {
        text = userName + "@" + text;
    }
    if (svrInfo != null) {
        String hostName = svrInfo.getServerName();
        text = text + ":" + hostName;
    }
    return text;
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo)

Example 32 with ServerInfo

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

the class ConnectionComposite method changeData.

public void changeData(CubridDatabase database) {
    charsetCombo.removeAll();
    if (database == null) {
        showDefaultForm();
        return;
    }
    dbInfo = database.getDatabaseInfo();
    if (dbInfo == null) {
        showDefaultForm();
        return;
    }
    ServerInfo serverInfo = dbInfo.getServerInfo();
    if (serverInfo == null) {
        showDefaultForm();
        return;
    }
    String databaseName = dbInfo.getDbName();
    String brokerIp = dbInfo.getBrokerIP();
    String brokerPort = dbInfo.getBrokerPort();
    String userName = dbInfo.getAuthLoginedDbUserInfo().getName();
    String userPassword = dbInfo.getAuthLoginedDbUserInfo().getNoEncryptPassword();
    String charset = dbInfo.getCharSet();
    String jdbcAttrs = dbInfo.getJdbcAttrs();
    String jdbcVersion = serverInfo.getJdbcDriverVersion();
    if (databaseText != null) {
        databaseText.setText(databaseName);
    }
    userNameText.setText(userName);
    btnAutoCommit.setSelection(QueryOptions.getAutoCommit(serverInfo));
    if (database.isAutoSavePassword()) {
        passwordText.setText(StringUtil.nvl(userPassword));
        if (isIncludingSavePwd) {
            btnSavePassword.setSelection(true);
        }
    } else {
        passwordText.setText("");
        if (isIncludingSavePwd) {
            btnSavePassword.setSelection(false);
        }
    }
    brokerIpText.setText(brokerIp);
    if (brokerPortText != null) {
        brokerPortText.setText(brokerPort);
    }
    charsetCombo.setItems(QueryOptions.getAllCharset(charset));
    if (charset == null) {
        charsetCombo.select(0);
    } else {
        charsetCombo.setText(charset);
    }
    jdbcCombo.setText(jdbcVersion);
    attrText.setText(StringUtil.nvl(jdbcAttrs));
    passwordText.selectAll();
    passwordText.setFocus();
    if (hasValidDatabaseInfo(database)) {
        boolean isShard = database.getDatabaseInfo().isShard();
        btnShard.setSelection(isShard);
        btnShardId.setEnabled(isShard);
    }
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo)

Example 33 with ServerInfo

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

the class JdbcManageComposite method isJdbcDriverUsing.

/**
	 * 
	 * Return whether the JDBC driver is using
	 * 
	 * @param jdbcVersion String
	 * @return boolean
	 */
private boolean isJdbcDriverUsing(String jdbcVersion) {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return false;
    }
    IWorkbenchPage page = window.getActivePage();
    if (page == null) {
        return false;
    }
    IViewReference[] viewReference = page.getViewReferences();
    for (int i = 0; viewReference != null && i < viewReference.length; i++) {
        IViewPart viewPart = viewReference[i].getView(false);
        if (!(viewPart instanceof CubridNavigatorView)) {
            continue;
        }
        CubridNavigatorView navigatorView = (CubridNavigatorView) viewPart;
        List<ICubridNode> list = getUsingJdbcNodeList(navigatorView);
        if (list == null) {
            continue;
        }
        for (ICubridNode node : list) {
            if (NodeType.SERVER.equals(node.getType())) {
                CubridServer server = (CubridServer) node;
                ServerInfo serverInfo = server.getServerInfo();
                if (serverInfo == null) {
                    continue;
                }
                if (serverInfo.isConnected() && serverInfo.getJdbcDriverVersion().equals(jdbcVersion)) {
                    CommonUITool.openErrorBox(Messages.bind(Messages.errDeleteJdbcServer, new Object[] { serverInfo.getServerName(), jdbcVersion }));
                    return true;
                }
            } else if (NodeType.DATABASE.equals(node.getType())) {
                CubridDatabase database = (CubridDatabase) node;
                if (database == null || database.getServer() == null || database.getServer().getServerInfo() == null) {
                    continue;
                }
                ServerInfo serverInfo = database.getServer().getServerInfo();
                if (serverInfo == null) {
                    LOGGER.error("The serverInfo is a null.");
                    return false;
                }
                boolean isSameVersion = StringUtil.isEqual(serverInfo.getJdbcDriverVersion(), jdbcVersion);
                if (isSameVersion && database.isLogined()) {
                    CommonUITool.openErrorBox(Messages.bind(Messages.errDeleteJdbcConn, new Object[] { database.getName(), jdbcVersion }));
                    return true;
                }
            }
        }
    }
    IEditorReference[] editorReference = page.getEditorReferences();
    for (int i = 0; editorReference != null && i < editorReference.length; i++) {
        IEditorPart editorPart = editorReference[i].getEditor(false);
        if (!(editorPart instanceof QueryEditorPart)) {
            continue;
        }
        QueryEditorPart queryEditorPart = (QueryEditorPart) editorPart;
        CubridServer server = queryEditorPart.getSelectedServer();
        ServerInfo serverInfo = server == null ? null : server.getServerInfo();
        String partName = queryEditorPart.getPartName();
        if (serverInfo != null && serverInfo.getJdbcDriverVersion().equals(jdbcVersion)) {
            CommonUITool.openErrorBox(Messages.bind(Messages.errDeleteJdbcQuery, new Object[] { partName, jdbcVersion }));
            return true;
        }
    }
    return false;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) IEditorPart(org.eclipse.ui.IEditorPart) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) QueryEditorPart(com.cubrid.common.ui.query.editor.QueryEditorPart) IEditorReference(org.eclipse.ui.IEditorReference) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 34 with ServerInfo

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

the class BackupDatabaseAction method run.

public void run() {
    Object[] obj = this.getSelectedObj();
    if (!isSupported(obj[0])) {
        setEnabled(false);
        return;
    }
    ISchemaNode node = (ISchemaNode) obj[0];
    final CubridDatabase database = node.getDatabase();
    final BackupDatabaseDialog dialog = new BackupDatabaseDialog(getShell());
    dialog.setDatabase(database);
    final Shell shell = getShell();
    TaskExecutor taskExcutor = new TaskExecutor() {

        public boolean exec(final IProgressMonitor monitor) {
            if (monitor.isCanceled()) {
                return false;
            }
            monitor.beginTask(Messages.loadDbBackupInfoTaskName, IProgressMonitor.UNKNOWN);
            for (ITask task : taskList) {
                task.execute();
                final String msg = task.getErrorMsg();
                if (openErrorBox(shell, msg, monitor)) {
                    return false;
                }
                if (monitor.isCanceled()) {
                    return false;
                }
                if (task instanceof GetDbBackupInfoTask) {
                    GetDbBackupInfoTask getDbBackupInfoTask = (GetDbBackupInfoTask) task;
                    dialog.setDbBackupInfo(getDbBackupInfoTask.getDbBackupInfo());
                } else if (task instanceof GetCubridConfParameterTask) {
                    GetCubridConfParameterTask getCubridConfParameterTask = (GetCubridConfParameterTask) task;
                    Map<String, Map<String, String>> confParas = getCubridConfParameterTask.getConfParameters();
                    Map<String, String> commonParas = confParas.get(ConfConstants.COMMON_SECTION_NAME);
                    Map<String, String> dbParas = confParas.get("[@" + database.getLabel() + "]");
                    String str = dbParas == null ? null : dbParas.get(ConfConstants.REPLICATION);
                    boolean isReplication = "yes".equals(str);
                    if (!isReplication) {
                        str = commonParas == null ? null : commonParas.get(ConfConstants.REPLICATION);
                        isReplication = "yes".equals(str);
                    }
                    dialog.setReplication(isReplication);
                }
            }
            return true;
        }
    };
    ServerInfo serverInfo = database.getServer().getServerInfo();
    GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(serverInfo);
    taskExcutor.addTask(getCubridConfParameterTask);
    GetDbBackupInfoTask getDbBackupInfoTask = new GetDbBackupInfoTask(serverInfo);
    getDbBackupInfoTask.setDbName(database.getLabel());
    taskExcutor.addTask(getDbBackupInfoTask);
    new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
    if (taskExcutor.isSuccess()) {
        dialog.open();
    }
}
Also used : ITask(com.cubrid.common.core.task.ITask) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) GetCubridConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask) GetDbBackupInfoTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDbBackupInfoTask) BackupDatabaseDialog(com.cubrid.cubridmanager.ui.cubrid.database.dialog.BackupDatabaseDialog) Shell(org.eclipse.swt.widgets.Shell) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) Map(java.util.Map)

Example 35 with ServerInfo

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

the class DatabaseDashboardEditor method createBrokerComposite.

/**
	 * craete broker composite
	 *
	 * @param bar
	 * @param bar index
	 *
	 */
public void createBrokerComposite(ExpandBar bar, int index) {
    ExpandItem brokerItem = new ExpandItem(bar, SWT.NONE, index);
    brokerItem.setText(Messages.exportDashboardBrokerTableTitle);
    Composite brokerComposite = new Composite(bar, SWT.None);
    brokerComposite.setLayout(new FillLayout());
    brokerInfoTableViewer = new TableViewer(brokerComposite, SWT.BORDER | SWT.FULL_SELECTION);
    brokerInfoTable = brokerInfoTableViewer.getTable();
    brokerInfoTable.setHeaderVisible(true);
    brokerInfoTable.setLinesVisible(true);
    final TableViewerColumn columnVolumn = new TableViewerColumn(brokerInfoTableViewer, SWT.CENTER);
    columnVolumn.getColumn().setWidth(100);
    columnVolumn.getColumn().setText("Broker");
    columnVolumn.getColumn().setToolTipText(com.cubrid.cubridmanager.ui.host.Messages.tipBrokerName);
    final TableViewerColumn columnType = new TableViewerColumn(brokerInfoTableViewer, SWT.CENTER);
    columnType.getColumn().setWidth(80);
    columnType.getColumn().setText("ID");
    columnType.getColumn().setToolTipText(Messages.brokerTableIDColumnTip);
    final TableViewerColumn columnSize = new TableViewerColumn(brokerInfoTableViewer, SWT.CENTER);
    columnSize.getColumn().setWidth(100);
    columnSize.getColumn().setText("PID");
    columnSize.getColumn().setToolTipText(Messages.brokerTablePIDColumnTip);
    final TableViewerColumn columnQPS = new TableViewerColumn(brokerInfoTableViewer, SWT.CENTER);
    columnQPS.getColumn().setWidth(100);
    columnQPS.getColumn().setText("QPS");
    columnQPS.getColumn().setToolTipText(com.cubrid.cubridmanager.ui.host.Messages.tipQps);
    final TableViewerColumn columnFreeSize = new TableViewerColumn(brokerInfoTableViewer, SWT.CENTER);
    columnFreeSize.getColumn().setWidth(100);
    columnFreeSize.getColumn().setText("LQS");
    columnFreeSize.getColumn().setToolTipText(Messages.brokerTableLQSColumnTip);
    final TableViewerColumn columnTotalSize = new TableViewerColumn(brokerInfoTableViewer, SWT.CENTER);
    columnTotalSize.getColumn().setWidth(80);
    columnTotalSize.getColumn().setText(Messages.multiDatabaseLoginDialogColumnStatus);
    columnTotalSize.getColumn().setToolTipText(Messages.multiDatabaseLoginDialogColumnStatus);
    final TableViewerColumn columnLocation = new TableViewerColumn(brokerInfoTableViewer, SWT.CENTER);
    columnLocation.getColumn().setWidth(140);
    columnLocation.getColumn().setText(Messages.brokerTableLastConnectTimeColumnLabel);
    columnLocation.getColumn().setToolTipText(Messages.brokerTableLastConnectTimeColumnLabel);
    brokerInfoTableViewer.setContentProvider(new TableContentProvider());
    brokerInfoTableViewer.setLabelProvider(new TableLabelProvider());
    brokerInfoTableViewer.setInput(brokerInfoListData);
    brokerItem.setControl(brokerComposite);
    brokerItem.setHeight(140);
    brokerItem.setExpanded(true);
    Menu menu = new Menu(this.getSite().getShell(), SWT.POP_UP);
    final MenuItem itemRestartCAS = new MenuItem(menu, SWT.PUSH);
    itemRestartCAS.setText(Messages.exportDashboardMenuRestartServer);
    itemRestartCAS.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            int i = brokerInfoTable.getSelectionIndex();
            if (i < 0) {
                return;
            }
            String brokerName = brokerInfoTable.getItem(i).getText(0);
            String serverId = brokerInfoTable.getItem(i).getText(1);
            if (!CommonUITool.openConfirmBox(Messages.bind(com.cubrid.cubridmanager.ui.broker.Messages.restartBrokerServerMsg, serverId))) {
                return;
            }
            ServerInfo serverInfo = database.getServer().getServerInfo();
            RestartBrokerTask restartTask = new RestartBrokerTask(serverInfo);
            restartTask.setBrokerName(brokerName);
            restartTask.setApplyServerNum(serverId);
            TaskExecutor taskExecutor = new CommonTaskExec(Messages.bind(com.cubrid.cubridmanager.ui.broker.Messages.restartBrokerServerTaskName, serverId));
            taskExecutor.addTask(restartTask);
            new ExecTaskWithProgress(taskExecutor).exec();
            if (taskExecutor.isSuccess()) {
                // refresh
                brokerInfoListData.clear();
                asinfoLst.clear();
                brokerInfoTable.remove(i);
                loadBrokerInfo();
                //recompute database's qps
                long qps = 0;
                for (HashMap<String, ApplyServerInfo> brokerValueMap : asinfoLst) {
                    for (Entry<String, ApplyServerInfo> entry : brokerValueMap.entrySet()) {
                        ApplyServerInfo applyServerInfo = entry.getValue();
                        qps += Long.valueOf(applyServerInfo.getAs_num_query());
                    }
                }
                Map<String, String> dbInfoMap = brokerInfoListData.get(0);
                dbInfoMap.put("2", Long.toString(qps));
                if (CompatibleUtil.isSupportGetCPUAndMemoryInfo(database.getDatabaseInfo())) {
                    dbInfoTableViewer.refresh();
                }
                brokerInfoTableViewer.refresh();
            }
        }
    });
    final MenuItem itemShowSqlLog = new MenuItem(menu, SWT.PUSH);
    itemShowSqlLog.setText(Messages.exportDashboardMenuShowSQLLog);
    itemShowSqlLog.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            showLogView("sql");
        }
    });
    final MenuItem itemShowSlowQueryLog = new MenuItem(menu, SWT.PUSH);
    itemShowSlowQueryLog.setText(Messages.exportDashboardMenuShowSlowQueryLog);
    itemShowSlowQueryLog.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            showLogView("slow");
        }
    });
    menu.addMenuListener(new MenuListener() {

        public void menuHidden(MenuEvent e) {
        }

        public void menuShown(MenuEvent e) {
            int i = brokerInfoTable.getSelectionIndex();
            if (i < 0) {
                Menu menu = (Menu) e.getSource();
                menu.setVisible(false);
            }
        }
    });
    brokerInfoTable.setMenu(menu);
    tableViewOnBarIndexMap.put(brokerInfoTableViewer, index);
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) Composite(org.eclipse.swt.widgets.Composite) HashMap(java.util.HashMap) ApplyServerInfo(com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) MenuListener(org.eclipse.swt.events.MenuListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MenuItem(org.eclipse.swt.widgets.MenuItem) FillLayout(org.eclipse.swt.layout.FillLayout) TableLabelProvider(com.cubrid.common.ui.spi.TableLabelProvider) ApplyServerInfo(com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) DbLotEntry(com.cubrid.cubridmanager.core.cubrid.database.model.lock.DbLotEntry) Entry(java.util.Map.Entry) ExpandItem(org.eclipse.swt.widgets.ExpandItem) TableContentProvider(com.cubrid.common.ui.spi.TableContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) RestartBrokerTask(com.cubrid.cubridmanager.core.broker.task.RestartBrokerTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) Menu(org.eclipse.swt.widgets.Menu) TableViewer(org.eclipse.jface.viewers.TableViewer) Map(java.util.Map) TreeMap(java.util.TreeMap) HashMap(java.util.HashMap) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) MenuEvent(org.eclipse.swt.events.MenuEvent)

Aggregations

ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)255 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)40 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)40 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)39 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)37 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)35 ArrayList (java.util.ArrayList)30 EnvInfo (com.cubrid.cubridmanager.core.common.model.EnvInfo)29 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)28 TreeViewer (org.eclipse.jface.viewers.TreeViewer)27 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)24 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)24 MonitoringTask (com.cubrid.cubridmanager.core.common.task.MonitoringTask)24 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)21 SelectionEvent (org.eclipse.swt.events.SelectionEvent)20 GridData (org.eclipse.swt.layout.GridData)17 GridLayout (org.eclipse.swt.layout.GridLayout)17 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)16 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)16 ITask (com.cubrid.common.core.task.ITask)15