use of com.cubrid.cubridmanager.core.broker.task.RestartBrokerTask 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