Search in sources :

Example 86 with ServerInfo

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

the class JDBCConnectionManager method getConnection.

/**
	 * Get new JDBC connection
	 * 
	 * @param dbInfo DatabaseInfo The given info of DatabaseInfo
	 * @param autoCommit boolean Whether is autoCommit
	 * @throws SQLException A SQLException will be throws when exception occur
	 * @return Connection
	 */
public static Connection getConnection(DatabaseInfo dbInfo, boolean autoCommit) throws SQLException {
    if (dbInfo == null || dbInfo.getServerInfo() == null) {
        throw new IllegalArgumentException();
    }
    String dbName = dbInfo.getDbName();
    ServerInfo serverInfo = dbInfo.getServerInfo();
    String brokerIP = dbInfo.getBrokerIP();
    String brokerPort = dbInfo.getBrokerPort();
    DbUserInfo userInfo = dbInfo.getAuthLoginedDbUserInfo();
    String userName = userInfo.getName();
    String password = userInfo.getNoEncryptPassword();
    String charset = dbInfo.getCharSet();
    String driverVersion = serverInfo.getJdbcDriverVersion();
    // advanced jdbc settings
    String jdbcAttrs = dbInfo.getJdbcAttrs();
    boolean isShard = dbInfo.isShard();
    return getConnection(brokerIP, brokerPort, dbName, userName, password, charset, jdbcAttrs, driverVersion, autoCommit, isShard);
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo)

Example 87 with ServerInfo

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

the class ServerManager method disConnectAllServer.

public void disConnectAllServer() {
    synchronized (this) {
        if (serverInfos != null) {
            List<ServerInfo> serverInfoList = new ArrayList<ServerInfo>();
            serverInfoList.addAll(serverInfos.values());
            Iterator<ServerInfo> it = serverInfoList.iterator();
            while (it.hasNext()) {
                ServerInfo serverInfo = it.next();
                if (serverInfo.isConnected()) {
                    setConnected(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getLoginedUserInfo().getUserName(), false);
                }
            }
        }
    }
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ArrayList(java.util.ArrayList)

Example 88 with ServerInfo

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

the class LoginQueryEditDialog method buttonPressed.

/**
	 * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
	 * @param buttonId the id of the button that was pressed (see
	 *        <code>IDialogConstants.*_ID</code> constants)
	 */
protected void buttonPressed(int buttonId) {
    if (buttonId == IDialogConstants.OK_ID || buttonId == TEST_CONNECT_ID) {
        String brokerIp = connectionComp.getBrokerIpText().getText();
        CubridServer cubridServer = DatabaseNavigatorMenu.SELF_DATABASE.getServer();
        ServerInfo serverInfo = new ServerInfo();
        serverInfo.setServerName(DatabaseNavigatorMenu.SELF_DATABASE_ID);
        serverInfo.setHostAddress(brokerIp);
        cubridServer.setServerInfo(serverInfo);
        String databaseName = connectionComp.getDatabaseCombo().getText();
        DatabaseInfo dbInfo = new DatabaseInfo(databaseName, cubridServer.getServerInfo());
        dbInfo.setBrokerIP(brokerIp);
        dbInfo.setBrokerPort(connectionComp.getBrokerPortCombo().getText());
        dbInfo.getServerInfo().setJdbcDriverVersion(connectionComp.getJdbcCombo().getText());
        String userName = connectionComp.getUserNameText().getText();
        String password = connectionComp.getPasswordText().getText();
        DbUserInfo userInfo = new DbUserInfo();
        userInfo.setDbName(databaseName);
        userInfo.setName(userName);
        userInfo.setNoEncryptPassword(password);
        dbInfo.setAuthLoginedDbUserInfo(userInfo);
        int currentShardId = connectionComp.getCurShardId();
        dbInfo.setCurrentShardId(currentShardId);
        String charset = connectionComp.getCharsetCombo().getText();
        dbInfo.setCharSet(charset);
        boolean isShard = connectionComp.getBtnShard().getSelection();
        dbInfo.setShard(isShard);
        boolean sureCharset = CommonUITool.openConfirmBox(Messages.bind(com.cubrid.cubridmanager.ui.host.Messages.msgConfirmCharset, charset));
        if (!sureCharset) {
            connectionComp.getCharsetCombo().setFocus();
            return;
        }
        TaskExecutor taskExcutor = new ConnectDatabaseExecutor(dbInfo);
        new ExecTaskWithProgress(taskExcutor).exec();
        if (!taskExcutor.isSuccess()) {
            return;
        }
        if (buttonId == TEST_CONNECT_ID) {
            CommonUITool.openInformationBox(com.cubrid.cubridmanager.ui.common.Messages.titleSuccess, com.cubrid.cubridmanager.ui.host.Messages.msgTestConnSuccess);
            return;
        }
        dbInfo.setLogined(true);
        dbInfo.setRunningType(DbRunningType.CS);
        DatabaseNavigatorMenu.SELF_DATABASE.setDatabaseInfo(dbInfo);
    }
    super.buttonPressed(buttonId);
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) ConnectDatabaseExecutor(com.cubrid.common.ui.spi.util.ConnectDatabaseExecutor)

Example 89 with ServerInfo

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

the class StartDatabaseAction method doRun.

public void doRun(ISchemaNode[] schemaArray) {
    if (schemaArray == null || schemaArray.length == 0) {
        return;
    }
    List<ISchemaNode> startList = new ArrayList<ISchemaNode>();
    /*Judge start job is running*/
    for (ISchemaNode node : schemaArray) {
        if (!isSupported(node)) {
            setEnabled(false);
            return;
        }
        CubridDatabase database = node.getDatabase();
        final JobFamily jobFamily = new JobFamily();
        String serverName = database.getServer().getName();
        String dbName = database.getName();
        jobFamily.setServerName(serverName);
        jobFamily.setDbName(dbName);
        Job[] jobs = Job.getJobManager().find(jobFamily);
        if (jobs.length > 0) {
            CommonUITool.openWarningBox(Messages.bind(Messages.msgStartDbWithJob, dbName));
            continue;
        }
        startList.add(database);
    }
    CubridNavigatorView navigationView = CubridNavigatorView.findNavigationView();
    if (navigationView != null && startList.size() > 0) {
        final TreeViewer treeViewer = navigationView.getViewer();
        TaskExecutor taskExcutor = new TaskExecutor() {

            public boolean exec(final IProgressMonitor monitor) {
                Display display = Display.getDefault();
                if (monitor.isCanceled()) {
                    return false;
                }
                for (int i = 0; i < taskList.size(); i++) {
                    ITask task = taskList.get(i);
                    final CubridDatabase database = (CubridDatabase) task.getData("dbName");
                    if (!isSupported(database)) {
                        continue;
                    }
                    monitor.subTask(Messages.bind(Messages.startDbTaskName, database.getName()));
                    task.execute();
                    if (openErrorBox(shell, task.getErrorMsg(), monitor) || monitor.isCanceled()) {
                        return false;
                    }
                    openWarningBox(shell, task.getWarningMsg(), monitor);
                    if (monitor.isCanceled()) {
                        return false;
                    }
                    database.removeAllChild();
                    if (database.getLoader() != null) {
                        database.getLoader().setLoaded(false);
                    }
                    database.setRunningType(DbRunningType.CS);
                    display.syncExec(new Runnable() {

                        public void run() {
                            treeViewer.refresh(database, true);
                        }
                    });
                    if (monitor.isCanceled()) {
                        return false;
                    }
                }
                return true;
            }
        };
        for (ISchemaNode schemaNode : startList) {
            CubridDatabase database = schemaNode.getDatabase();
            if (!isSupported(database)) {
                setEnabled(false);
                return;
            }
            ServerInfo serverInfo = database.getServer().getServerInfo();
            CommonUpdateTask task = new CommonUpdateTask(CommonTaskName.START_DB_TASK_NAME, serverInfo, CommonSendMsg.getCommonDatabaseSendMsg());
            task.setDbName(database.getLabel());
            task.putData("dbName", database);
            taskExcutor.addTask(task);
        }
        new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
        ActionManager.getInstance().fireSelectionChanged(getSelection());
    }
}
Also used : ITask(com.cubrid.common.core.task.ITask) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ArrayList(java.util.ArrayList) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CommonUpdateTask(com.cubrid.cubridmanager.core.common.task.CommonUpdateTask) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) Job(org.eclipse.core.runtime.jobs.Job) Display(org.eclipse.swt.widgets.Display)

Example 90 with ServerInfo

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

the class UnloadDatabaseAction 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 UnloadDatabaseDialog dialog = new UnloadDatabaseDialog(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.loadAllClassTaskName, 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 GetClassListTask) {
                    GetClassListTask getClassListTask = (GetClassListTask) task;
                    List<String> allUserClassList = new ArrayList<String>();
                    DBClasses dbClasses = getClassListTask.getDbClassInfo();
                    List<ClassItem> userClassList = dbClasses == null ? null : dbClasses.getUserClassList().getClassList();
                    if (userClassList != null && !userClassList.isEmpty()) {
                        for (ClassItem userClass : userClassList) {
                            allUserClassList.add(userClass.getClassname());
                        }
                    }
                    Collections.sort(allUserClassList);
                    dialog.setUserClassList(allUserClassList);
                }
            }
            return true;
        }
    };
    ServerInfo serverInfo = database.getServer().getServerInfo();
    GetClassListTask task = new GetClassListTask(serverInfo, database.getDatabaseInfo().getCharSet());
    task.setDbName(database.getLabel());
    task.setDbStatus(OnOffType.OFF);
    taskExcutor.addTask(task);
    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) ArrayList(java.util.ArrayList) Shell(org.eclipse.swt.widgets.Shell) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ClassItem(com.cubrid.cubridmanager.core.cubrid.table.model.ClassItem) GetClassListTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetClassListTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) UnloadDatabaseDialog(com.cubrid.cubridmanager.ui.cubrid.database.dialog.UnloadDatabaseDialog) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) DBClasses(com.cubrid.cubridmanager.core.cubrid.table.model.DBClasses)

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