Search in sources :

Example 51 with ServerInfo

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

the class ConnectHostNodeDialog method modifyText.

/**
	 * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
	 * @param event ModifyEvent
	 */
public void modifyText(ModifyEvent event) {
    getButton(IDialogConstants.OK_ID).setEnabled(false);
    String ip = ipText.getText();
    boolean isValidIP = ip.trim().length() > 0;
    if (!isValidIP) {
        setErrorMessage(Messages.errIPAddress);
        return;
    }
    String port = portText.getText();
    boolean isValidPort = ValidateUtil.isNumber(port);
    if (isValidPort) {
        int portVal = Integer.parseInt(port);
        if (portVal < 1024 || portVal > 65535) {
            isValidPort = false;
        }
    }
    if (!isValidPort) {
        setErrorMessage(Messages.errPort);
        return;
    }
    String password = passwordText.getText();
    boolean isValidPassword = password.trim().length() >= 4 && password.indexOf(" ") < 0;
    ServerInfo serverInfo = ServerManager.getInstance().getServer(ipText.getText(), Integer.parseInt(port), userNameText.getText());
    if (isValidPassword && serverInfo != null && serverInfo.getLoginedUserInfo() != null && serverInfo.getLoginedUserInfo().isAdmin()) {
        isValidPassword = password.equals(serverInfo.getLoginedUserInfo().getPassword());
    }
    if (!isValidPassword) {
        setErrorMessage(Messages.errPassword);
        return;
    }
    getButton(IDialogConstants.OK_ID).setEnabled(true);
    setErrorMessage(null);
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo)

Example 52 with ServerInfo

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

the class StartServiceAction 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 object;<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)

Example 53 with ServerInfo

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

the class StopServiceAction method doRun.

/**
	 * Perform do run
	 * 
	 * @param servers
	 */
public void doRun(CubridServer[] servers) {
    CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
    final TreeViewer viewer = view.getViewer();
    if (servers.length > 0) {
        CubridServer server = servers[0];
        if (isSupported(server)) {
            final JobFamily jobFamily = new JobFamily();
            final String serverName = server.getName();
            String dbName = JobFamily.ALL_DB;
            jobFamily.setServerName(serverName);
            jobFamily.setDbName(dbName);
            Job[] jobs = Job.getJobManager().find(jobFamily);
            if (jobs.length > 0) {
                CommonUITool.openWarningBox(Messages.bind(Messages.msgStopServiceWithJob, serverName));
                return;
            }
            TaskExecutor taskExcutor = new StopServiceExecutor(server, getShell(), viewer);
            ServerInfo serverInfo = server.getServerInfo();
            GetCubridConfParameterTask task = new GetCubridConfParameterTask(serverInfo);
            taskExcutor.addTask(task);
            new ExecTaskWithProgress(taskExcutor).exec();
        }
    }
//		for(CubridServer server : servers) {
//			final JobFamily jobFamily = new JobFamily();
//			final String serverName = server.getName();
//			String dbName = JobFamily.ALL_DB;
//			jobFamily.setServerName(serverName);
//			jobFamily.setDbName(dbName);
//			Job[] jobs = Job.getJobManager().find(jobFamily);
//			if (jobs.length > 0) {
//				CommonUITool.openWarningBox(Messages.bind(
//						Messages.msgStopServiceWithJob, serverName));
//				return;
//			}
//
//			TaskExecutor taskExcutor = new StopServiceExecutor(server, getShell(),
//					viewer);
//			ServerInfo serverInfo = server.getServerInfo();
//			GetCubridConfParameterTask task = new GetCubridConfParameterTask(
//					serverInfo);
//			taskExcutor.addTask(task);
//			new ExecTaskWithProgress(taskExcutor).exec();
//		}
}
Also used : CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) GetCubridConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) Job(org.eclipse.core.runtime.jobs.Job)

Example 54 with ServerInfo

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

the class RestartBrokerAction method run.

public void run() {
    final Object[] obj = this.getSelectedObj();
    DefaultCubridNode selection = (DefaultCubridNode) obj[0];
    if (selection == null || selection.getServer() == null) {
        return;
    }
    ServerInfo serverInfo = selection.getServer().getServerInfo();
    if (serverInfo == null) {
        return;
    }
    //stop first
    StopBrokerTask stopTask = new StopBrokerTask(serverInfo);
    stopTask.setBrokerName(selection.getLabel());
    //then start again
    StartBrokerTask startTask = new StartBrokerTask(serverInfo);
    startTask.setBrokerName(selection.getLabel());
    final String taskName = Messages.bind(Messages.restartBrokerTaskName, selection.getLabel());
    TaskExecutor taskExecutor = new CommonTaskExec(taskName);
    taskExecutor.addTask(stopTask);
    taskExecutor.addTask(startTask);
    new ExecTaskWithProgress(taskExecutor).exec();
    if (!taskExecutor.isSuccess()) {
        return;
    }
    TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
    CommonUITool.refreshNavigatorTree(treeViewer, selection.getParent());
    ActionManager.getInstance().fireSelectionChanged(getSelection());
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) StartBrokerTask(com.cubrid.cubridmanager.core.broker.task.StartBrokerTask) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) StopBrokerTask(com.cubrid.cubridmanager.core.broker.task.StopBrokerTask)

Example 55 with ServerInfo

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

the class BrokerEnvStatusView method refresh.

/**
	 * Refreshes this view
	 *
	 * @param isUpdateTable whether update table
	 * @param isRefreshChanged whether refresh changed
	 *
	 */
public void refresh(boolean isUpdateTable, boolean isRefreshChanged) {
    ServerInfo site = cubridNode.getServer().getServerInfo();
    BrokerInfos brokerInfos = new BrokerInfos();
    final CommonQueryTask<BrokerInfos> task = new CommonQueryTask<BrokerInfos>(site, CommonSendMsg.getCommonSimpleSendMsg(), brokerInfos);
    task.execute();
    brokerInfos = task.getResultModel();
    List<BrokerInfo> newBrokerInfoList = null;
    if (null != brokerInfos) {
        BrokerInfoList list = brokerInfos.getBorkerInfoList();
        if (list != null && list.getBrokerInfoList() != null) {
            newBrokerInfoList = list.getBrokerInfoList();
        }
    }
    List<BrokerInfo> changedBrokerInfoList = new ArrayList<BrokerInfo>();
    for (int i = 0; newBrokerInfoList != null && i < newBrokerInfoList.size(); i++) {
        BrokerInfo newBrokerInfo = newBrokerInfoList.get(i);
        BrokerInfo changedBrokerInfo = newBrokerInfo.clone();
        for (int j = 0; oldBrokerInfoList != null && j < oldBrokerInfoList.size(); j++) {
            BrokerInfo oldBrokerInfo = oldBrokerInfoList.get(j);
            if (newBrokerInfo.getName().equalsIgnoreCase(oldBrokerInfo.getName())) {
                // FIXME more simple
                long newTran = StringUtil.intValue(newBrokerInfo.getTran());
                long newQuery = StringUtil.intValue(newBrokerInfo.getQuery());
                long newLongTran = StringUtil.longValue(newBrokerInfo.getLong_tran());
                long newLongQuery = StringUtil.longValue(newBrokerInfo.getLong_query());
                long newErrQuery = StringUtil.intValue(newBrokerInfo.getError_query());
                long oldTran = StringUtil.intValue(oldBrokerInfo.getTran());
                long oldQuery = StringUtil.intValue(oldBrokerInfo.getQuery());
                long oldLongTran = StringUtil.longValue(oldBrokerInfo.getLong_tran());
                long oldLongQuery = StringUtil.longValue(oldBrokerInfo.getLong_query());
                long oldErrQuery = StringUtil.intValue(oldBrokerInfo.getError_query());
                long changedTran = newTran - oldTran;
                long changedQuery = newQuery - oldQuery;
                long changedLongTran = newLongTran - oldLongTran;
                long changedLongQuery = newLongQuery - oldLongQuery;
                long changedErrQuery = newErrQuery - oldErrQuery;
                changedBrokerInfo.setTran(String.valueOf(changedTran > 0 ? changedTran : 0));
                changedBrokerInfo.setQuery(String.valueOf(changedQuery > 0 ? changedQuery : 0));
                changedBrokerInfo.setLong_tran(String.valueOf(changedLongTran > 0 ? changedLongTran : 0));
                changedBrokerInfo.setLong_query(String.valueOf(changedLongQuery > 0 ? changedLongQuery : 0));
                changedBrokerInfo.setError_query(String.valueOf(changedErrQuery > 0 ? changedErrQuery : 0));
                break;
            }
        }
        changedBrokerInfoList.add(changedBrokerInfo);
    }
    oldBrokerInfoList = newBrokerInfoList;
    if (isUpdateTable) {
        if (isRefreshChanged) {
            tableViewer.setInput(changedBrokerInfoList);
        } else {
            tableViewer.setInput(oldBrokerInfoList);
        }
        tableViewer.refresh();
    }
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) ArrayList(java.util.ArrayList) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo)

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