Search in sources :

Example 16 with EnvInfo

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

the class ConnectHostJobExecutor method exec.

/**
	 * Execute to connect host
	 * 
	 * @param monitor the IProgressMonitor
	 * @return <code>true</code> if successful;<code>false</code>otherwise;
	 */
@SuppressWarnings("unchecked")
public IStatus exec(final IProgressMonitor monitor) {
    monitor.subTask(Messages.bind(com.cubrid.cubridmanager.ui.mondashboard.Messages.jobConnectHost, serverInfo.getHostAddress()));
    isContinue = true;
    boolean isRunUpdateCmUserTask = false;
    BrokerInfos brokerInfos = null;
    errorMsg = null;
    for (ITask task : taskList) {
        if (task instanceof MonitoringTask) {
            IStatus status = connectHost((MonitoringTask) task);
            if (Status.OK_STATUS != status) {
                return status;
            }
        } else if ((task instanceof UpdateCMUserTask)) {
            updateCMUserAuthInfo(task, isRunUpdateCmUserTask);
        } else if ((task instanceof GetHeartbeatNodeInfoTask) && !CompatibleUtil.isSupportHA(serverInfo)) {
            continue;
        } else {
            task.execute();
        }
        final String msg = task.getErrorMsg();
        if (monitor.isCanceled()) {
            disConnect();
            return Status.CANCEL_STATUS;
        }
        if (!hostNode.isConnecting()) {
            return Status.CANCEL_STATUS;
        }
        if (msg != null && msg.length() > 0) {
            disConnect();
            if (isPing) {
                errorMsg = msg;
                return Status.CANCEL_STATUS;
            }
            return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
        }
        if (task instanceof GetEnvInfoTask) {
            GetEnvInfoTask getEnvInfoTask = (GetEnvInfoTask) task;
            EnvInfo envInfo = getEnvInfoTask.loadEnvInfo();
            serverInfo.setEnvInfo(envInfo);
            String clientVersion = Version.buildVersionId.substring(0, Version.buildVersionId.lastIndexOf("."));
            if (!CompatibleUtil.isSupportCMServer(serverInfo, clientVersion)) {
                disConnect();
                errorMsg = Messages.bind(Messages.errNoSupportServerVersion, clientVersion);
                if (isPing) {
                    return Status.CANCEL_STATUS;
                }
                return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, errorMsg);
            }
            if (!serverInfo.validateJdbcVersion(serverInfo.getJdbcDriverVersion())) {
                disConnect();
                if (ServerJdbcVersionMapping.JDBC_SELF_ADAPTING_VERSION.equals(serverInfo.getJdbcDriverVersion())) {
                    errorMsg = Messages.errNoSupportDriver;
                } else {
                    errorMsg = Messages.errSelectSupportDriver;
                }
                if (isPing) {
                    return Status.CANCEL_STATUS;
                }
                return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, errorMsg);
            }
        } 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;
                    }
                }
            }
            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 GetHeartbeatNodeInfoTask) {
            GetHeartbeatNodeInfoTask getHeartbeatNodeInfoTask = (GetHeartbeatNodeInfoTask) task;
            haHostStatusInfo = getHeartbeatNodeInfoTask.getHostStatusInfo(serverInfo.getHostAddress());
        }
        if (monitor.isCanceled() || !isContinue) {
            disConnect();
            return Status.CANCEL_STATUS;
        }
    }
    return Status.OK_STATUS;
}
Also used : ServerType(com.cubrid.cubridmanager.core.common.model.ServerType) ITask(com.cubrid.common.core.task.ITask) IStatus(org.eclipse.core.runtime.IStatus) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) GetHeartbeatNodeInfoTask(com.cubrid.cubridmanager.core.mondashboard.task.GetHeartbeatNodeInfoTask) 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) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) 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 17 with EnvInfo

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

the class VolumeSizeValidator method initial.

private void initial() {
    volumeTypeCombo.setItems(VOLUME_TYPES);
    volumeTypeCombo.select(0);
    EnvInfo envInfo = server.getServerInfo().getEnvInfo();
    if (envInfo != null) {
        databasePath = envInfo.getDatabaseDir();
        ServerInfo serverInfo = server.getServerInfo();
        if (serverInfo != null) {
            databasePath = FileUtil.changeSeparatorByOS(databasePath, serverInfo.getServerOsInfo());
        }
    }
    volumeNameText.addModifyListener(this);
    volumePathText.addModifyListener(this);
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) EnvInfo(com.cubrid.cubridmanager.core.common.model.EnvInfo)

Example 18 with EnvInfo

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

the class RenameDatabaseDialog method initial.

/**
	 * 
	 * Initial data
	 * 
	 */
private void initial() {
    EnvInfo envInfo = database.getServer().getServerInfo().getEnvInfo();
    if (envInfo != null) {
        extVolumePath = envInfo.getDatabaseDir();
        extVolumePath = FileUtil.changeSeparatorByOS(extVolumePath, database.getServer().getServerInfo().getServerOsInfo());
        exVolumePathText.setText(extVolumePath);
    }
    String dir = CubridManagerUIPlugin.getPluginDialogSettings().get(KEY_EXTENDED_VOLUME_PATH + database.getId());
    if (dir != null && dir.trim().length() > 0) {
        extVolumePath = dir;
        exVolumePathText.setText(extVolumePath);
    }
    if (spaceInfoList == null) {
        spaceInfoList = new ArrayList<Map<String, String>>();
        if (this.dbSpaceInfoList != null) {
            List<DbSpaceInfo> list = this.dbSpaceInfoList.getSpaceinfo();
            for (int i = 0; list != null && i < list.size(); i++) {
                Map<String, String> map = new HashMap<String, String>();
                DbSpaceInfo spaceInfo = list.get(i);
                String type = spaceInfo.getType();
                if (!VolumeType.GENERIC.getText().equals(type) && !VolumeType.DATA.getText().equals(type) && !VolumeType.INDEX.getText().equals(type) && !VolumeType.TEMP.getText().equals(type)) {
                    continue;
                }
                map.put("0", spaceInfo.getSpacename());
                map.put("1", spaceInfo.getSpacename());
                String location = spaceInfo.getLocation();
                location = FileUtil.changeSeparatorByOS(location, database.getServer().getServerInfo().getServerOsInfo());
                map.put("2", location);
                map.put("3", location);
                spaceInfoList.add(map);
            }
        }
    }
    volumeTableViewer.setInput(spaceInfoList);
    for (int i = 0; i < volumeTable.getColumnCount(); i++) {
        volumeTable.getColumn(i).pack();
    }
    databaseNameText.addModifyListener(this);
    exVolumePathText.addModifyListener(this);
}
Also used : HashMap(java.util.HashMap) DbSpaceInfo(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfo) Map(java.util.Map) HashMap(java.util.HashMap) EnvInfo(com.cubrid.cubridmanager.core.common.model.EnvInfo)

Example 19 with EnvInfo

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

the class GetHeartbeatNodeInfoTaskTest method testSend.

public void testSend() throws Exception {
    if (StringUtil.isEqual(SystemParameter.getParameterValue("useMockTest"), "y"))
        return;
    String filepath = this.getFilePathInPlugin("/com/cubrid/cubridmanager/core/mondashboard/task/test.message/GetHeartbeatNodeInfoTask_send");
    String msg = Tool.getFileContent(filepath);
    //replace "token" field with the latest value
    msg = msg.replaceFirst("token:.*\n", "token:" + token + "\n");
    //composite message
    GetHeartbeatNodeInfoTask task = new GetHeartbeatNodeInfoTask(serverInfo);
    task.setAllDb(false);
    List<String> dbList = new ArrayList<String>();
    dbList.add("demodb");
    dbList.add("tb1");
    task.setDbList(dbList);
    //compare 
    assertEquals(msg, task.getRequest());
    //test special case1
    ServerInfo server = new ServerInfo();
    server.setConnected(true);
    EnvInfo envInfo = new EnvInfo();
    envInfo.setServerVersion("CUBRID 2008 R2.0(8.2.0.1150)");
    envInfo.setOsInfo("NT");
    server.setEnvInfo(envInfo);
    task = new GetHeartbeatNodeInfoTask(server);
    task.execute();
    //test special case2
    envInfo.setServerVersion("CUBRID 2008 R2.0(8.3.1.1150)");
    task.execute();
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ArrayList(java.util.ArrayList) EnvInfo(com.cubrid.cubridmanager.core.common.model.EnvInfo)

Example 20 with EnvInfo

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

the class GeneralInfoPage method initial.

private void initial() {
    String[] pageSizeItem = CompatibleUtil.getSupportedPageSize(server.getServerInfo());
    pageSizeCombo.setItems(pageSizeItem);
    pageSizeCombo.setText(CompatibleUtil.getDefaultPageSize(server.getServerInfo()));
    if (logPageSizeCombo != null) {
        logPageSizeCombo.setItems(pageSizeItem);
        logPageSizeCombo.setText(CompatibleUtil.getDefaultPageSize(server.getServerInfo()));
    }
    /*if (charsetCombo != null) {
			charsetCombo.setItems(charsetItem);
			charsetCombo.setText(DEFAULT);
		}*/
    EnvInfo envInfo = server.getServerInfo().getEnvInfo();
    if (envInfo != null) {
        databasePath = envInfo.getDatabaseDir();
        ServerInfo serverInfo = server.getServerInfo();
        if (serverInfo != null) {
            databasePath = FileUtil.changeSeparatorByOS(databasePath, serverInfo.getServerOsInfo());
        }
        genericVolumePathText.setText(databasePath);
        logVolumePathText.setText(databasePath);
    }
    genericVolumeSizeText.setText(ConfConstants.DEFAULT_DATA_VOLUME_SIZE);
    defaultDatVolumeSize = ConfConstants.DEFAULT_DATA_VOLUME_SIZE;
    /*If Configed Generic Volume Size is not null*/
    String genericVolumeSize = CompatibleUtil.getConfigGenericVolumeSize(server.getServerInfo(), null);
    if (!StringUtil.isEmpty(genericVolumeSize)) {
        Long bytes = StringUtil.getByteNumber(genericVolumeSize);
        if (bytes > -1) {
            double value = StringUtil.convertToM(bytes);
            String strValue = getIntSizeString(value, 20);
            genericVolumeSizeText.setText(strValue);
            defaultDatVolumeSize = strValue;
        }
    }
    logVolumeSizeText.setText(ConfConstants.DEFAULT_DATA_VOLUME_SIZE);
    /*If Config Log Volume Size is not null*/
    String logValueSize = CompatibleUtil.getConfigLogVolumeSize(server.getServerInfo(), null);
    if (!StringUtil.isEmpty(logValueSize)) {
        Long bytes = StringUtil.getByteNumber(logValueSize);
        if (bytes > -1) {
            double value = StringUtil.convertToM(bytes);
            logVolumeSizeText.setText(getIntSizeString(value, 20));
        }
    }
    databaseNameText.addModifyListener(this);
    genericVolumePathText.addModifyListener(this);
    logVolumePathText.addModifyListener(this);
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) EnvInfo(com.cubrid.cubridmanager.core.common.model.EnvInfo)

Aggregations

EnvInfo (com.cubrid.cubridmanager.core.common.model.EnvInfo)37 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)29 ITask (com.cubrid.common.core.task.ITask)5 GetEnvInfoTask (com.cubrid.cubridmanager.core.common.task.GetEnvInfoTask)5 ArrayList (java.util.ArrayList)5 Map (java.util.Map)4 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)3 GetBrokerConfParameterTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask)3 ServerType (com.cubrid.cubridmanager.core.common.model.ServerType)3 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)3 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)3 GetCMConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask)3 GetCMUserListTask (com.cubrid.cubridmanager.core.common.task.GetCMUserListTask)3 GetCubridConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask)3 MonitoringTask (com.cubrid.cubridmanager.core.common.task.MonitoringTask)3 UpdateCMUserTask (com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask)3 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)3 GetDatabaseListTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask)3 List (java.util.List)3 IStatus (org.eclipse.core.runtime.IStatus)3