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