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);
}
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;
}
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();
// }
}
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());
}
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();
}
}
Aggregations