use of com.cubrid.cubridmanager.core.monstatistic.model.StatisticChartHost in project cubrid-manager by CUBRID.
the class EditMultiHostStatisticItemDialog method okPressed.
public void okPressed() {
int series = 0;
if (!isNew) {
series = statisticChartItem.getSeries();
}
statisticChartItem = new MultiHostChartItem(editor.getNodeId(), type, timeType.getType());
Iterator<StatisticChartHost> it = hostList.iterator();
while (it.hasNext()) {
((MultiHostChartItem) statisticChartItem).addStatisticChartHost(it.next());
}
if (!isNew) {
statisticChartItem.setSeries(series);
}
LoadMonitorStatisticDataProgress.tearDownDisconnectedServer();
super.okPressed();
}
use of com.cubrid.cubridmanager.core.monstatistic.model.StatisticChartHost in project cubrid-manager by CUBRID.
the class EditMultiHostStatisticItemDialog method openAddStatisticHostDialog.
private void openAddStatisticHostDialog(StatisticChartHost hostItem, boolean isFirstHost, boolean isNewHost) {
EditStatisticHostDialog dialog = new EditStatisticHostDialog(this.getShell(), this, isNewHost);
if (!isNewHost) {
//initial data when edit host info
dialog.init(type, timeType, hostItem);
}
dialog.setFirstHost(isFirstHost);
if (!isFirstHost) {
StatisticChartHost firstItem = hostList.get(0);
dialog.setFirstMetric(firstItem.getMetric());
dialog.setFirstTime(timeType);
}
ServerInfo serverInfo = null;
if (hostItem != null) {
//edit
serverInfo = LoadMonitorStatisticDataProgress.buildServerInfo(hostItem);
boolean isUnavailable = false;
boolean isSupported = false;
if (serverInfo == null) {
isUnavailable = true;
} else if (serverInfo.isConnected()) {
isSupported = serverInfo.isSupportMonitorStatistic();
} else {
LoadMonitorStatisticDataProgress.addDisconnectedServer(serverInfo);
TaskExecutor taskExcutor = new ConnectHostExecutor(getShell(), serverInfo, true);
((ConnectHostExecutor) taskExcutor).setCheckJdbc(false);
new ExecTaskWithProgress(taskExcutor).exec(true, true);
if (taskExcutor.isSuccess()) {
isSupported = serverInfo.isSupportMonitorStatistic();
} else {
isUnavailable = true;
}
}
dialog.setServerInfo(serverInfo);
if (isUnavailable) {
dialog.setHostStatusValue(dialog.HOST_STATUS_UNAVAILABLE);
} else if (isSupported) {
dialog.setHostStatusValue(dialog.HOST_STATUS_OK);
} else {
dialog.setHostStatusValue(dialog.HOST_STATUS_UNSUPPORTED);
}
}
if (dialog.open() == Dialog.OK) {
if (hostItem != null) {
int oldIndex = hostList.indexOf(hostItem);
hostList.set(oldIndex, dialog.getHostItem());
} else {
hostList.add(dialog.getHostItem());
}
refreshHostTable();
}
enableOk();
}
use of com.cubrid.cubridmanager.core.monstatistic.model.StatisticChartHost in project cubrid-manager by CUBRID.
the class EditMultiHostStatisticItemDialog method createDialogArea.
/**
* Creates and returns the contents of the upper part of this dialog (above
* the button bar).
*
* @param parent The parent composite to contain the dialog area
* @return the dialog area control
*/
protected Control createDialogArea(Composite parent) {
final Composite parentComp = (Composite) super.createDialogArea(parent);
final int DEFAULT_WIDTH = 80;
Composite compHost = new Composite(parentComp, SWT.RESIZE);
compHost.setLayout(new FillLayout());
compHost.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
hostTableViewer = new TableViewer(compHost, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
hostTableViewer.getTable().setHeaderVisible(true);
hostTableViewer.getTable().setLinesVisible(true);
hostTableViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
TableItem[] tableItems = hostTableViewer.getTable().getSelection();
StatisticChartHost hostItem = (StatisticChartHost) tableItems[0].getData();
openAddStatisticHostDialog(hostItem, hostList.size() == 1, false);
}
});
//Host Name
final TableViewerColumn nameColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
nameColumn.getColumn().setWidth(DEFAULT_WIDTH);
nameColumn.getColumn().setText(Messages.lblHostName);
//IP
final TableViewerColumn ipColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
ipColumn.getColumn().setWidth(DEFAULT_WIDTH);
ipColumn.getColumn().setText(Messages.lblIp);
//Port
final TableViewerColumn portColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
portColumn.getColumn().setWidth(50);
portColumn.getColumn().setText(Messages.lblPort);
//Data Type
final TableViewerColumn dataTypeColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
dataTypeColumn.getColumn().setWidth(DEFAULT_WIDTH);
dataTypeColumn.getColumn().setText(Messages.lblDataType);
//Time Type
final TableViewerColumn timeTypeColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
timeTypeColumn.getColumn().setWidth(DEFAULT_WIDTH);
timeTypeColumn.getColumn().setText(Messages.lblTimeType);
//Database Name
final TableViewerColumn dbNameColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
dbNameColumn.getColumn().setWidth(DEFAULT_WIDTH);
dbNameColumn.getColumn().setText(Messages.lblDbName);
//Database Volume Name
final TableViewerColumn volNameColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
volNameColumn.getColumn().setWidth(DEFAULT_WIDTH);
volNameColumn.getColumn().setText(Messages.lblVolName);
//Broker Name
final TableViewerColumn brokerColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
brokerColumn.getColumn().setWidth(DEFAULT_WIDTH);
brokerColumn.getColumn().setText(Messages.lblBrokerName);
//Metric
final TableViewerColumn metricColumn = new TableViewerColumn(hostTableViewer, SWT.LEFT);
metricColumn.getColumn().setWidth(DEFAULT_WIDTH);
metricColumn.getColumn().setText(Messages.lblMetric);
hostTableViewer.setContentProvider(new HostTableViewerContentProvider());
hostTableViewer.setLabelProvider(new HostTableViewerLabelProvider());
hostTableViewer.getTable().addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent event) {
ActionManager.getInstance().changeFocusProvider(hostTableViewer.getTable());
}
});
hostTableViewer.getTable().addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TableItem[] items = hostTableViewer.getTable().getSelection();
btnEditHost.setEnabled(items.length > 0);
btnDeleteHost.setEnabled(items.length > 0);
}
});
Composite compBtn = new Composite(parentComp, SWT.RESIZE);
GridLayout layoutCompBtn = new GridLayout(6, false);
layoutCompBtn.marginRight = 0;
// layoutCompBtn.numColumns = 6;
layoutCompBtn.marginWidth = 0;
compBtn.setLayout(layoutCompBtn);
compBtn.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
btnAddHost = new Button(compBtn, SWT.NONE);
btnAddHost.setText(Messages.btnAddHost);
btnAddHost.addSelectionListener(new ButtonAddHostAdapter());
btnEditHost = new Button(compBtn, SWT.NONE);
btnEditHost.setText(Messages.btnEditHost);
btnEditHost.addSelectionListener(new ButtonEditHostAdapter());
btnEditHost.setEnabled(false);
btnDeleteHost = new Button(compBtn, SWT.NONE);
btnDeleteHost.setText(Messages.btnDelHost);
btnDeleteHost.addSelectionListener(new ButtonDeleteHostAdapter());
btnDeleteHost.setEnabled(false);
if (!isNew && statisticChartItem != null) {
MultiHostChartItem multiHostChartItem = (MultiHostChartItem) statisticChartItem;
type = multiHostChartItem.getType();
timeType = TimeType.getEnumByType(multiHostChartItem.getDType());
hostList = multiHostChartItem.getHostList();
hostTableViewer.setInput(hostList);
} else {
hostList = new ArrayList<StatisticChartHost>();
}
return parentComp;
}
use of com.cubrid.cubridmanager.core.monstatistic.model.StatisticChartHost in project cubrid-manager by CUBRID.
the class EditStatisticHostDialog method okPressed.
/**
* When press "ok" button, call it.
*/
public void okPressed() {
StatisticType type = StatisticType.getEnumByMessage(comboDataType.getText());
if (isFirstHost) {
((EditMultiHostStatisticItemDialog) parentDialog).setType(type);
((EditMultiHostStatisticItemDialog) parentDialog).setTimeType(getTimeType());
}
String cubridServerId = comboHost.getText();
hostItem = new StatisticChartHost(cubridServerId);
ServerInfo serverInfo = hostNodePersistManager.getServer(cubridServerId).getServerInfo();
hostItem.setServerInfo(serverInfo);
hostItem.setIp(serverInfo.getHostAddress());
hostItem.setPort(serverInfo.getHostMonPort());
hostItem.setUser(serverInfo.getUserName());
hostItem.setPassword(serverInfo.getUserPassword());
switch(type) {
case DB:
hostItem.setDbName(comboDbName.getText());
break;
case DB_VOL:
hostItem.setDbName(comboDbName.getText());
hostItem.setVolName(comboVolName.getText());
break;
case BROKER:
hostItem.setBrokerName(comboBrokerName.getText());
break;
case OS:
break;
default:
}
hostItem.setMetric(MetricType.getEnumByMessage(comboMetric.getText()).getMetric());
boolean isDuplicated = ((EditMultiHostStatisticItemDialog) parentDialog).isDuplicatedHostInfo(hostItem, oldHostItem);
if (isDuplicated) {
CommonUITool.openWarningBox(Messages.errDuplicateHost);
return;
}
super.okPressed();
}
use of com.cubrid.cubridmanager.core.monstatistic.model.StatisticChartHost in project cubrid-manager by CUBRID.
the class LoadMonitorStatisticDataProgress method run.
/* (non-Javadoc)
* @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
*/
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
if (statisticItemList == null) {
success = false;
return;
}
if (isMultiHost) {
for (StatisticChartItem chartItem : statisticItemList) {
if (!(chartItem instanceof MultiHostChartItem)) {
statisticDataMap.put(chartItem, EMPTY_STATISTIC_DATA_LIST);
continue;
}
MultiHostChartItem item = (MultiHostChartItem) chartItem;
if (item.getHostList() == null || item.getHostList().size() == 0) {
statisticDataMap.put(chartItem, EMPTY_STATISTIC_DATA_LIST);
continue;
}
List<StatisticData> dataList = new ArrayList<StatisticData>();
for (StatisticChartHost host : item.getHostList()) {
//build ServerInfo
ServerInfo serverInfo = buildServerInfo(host);
StatisticData statisticData = new StatisticData();
statisticData.setServerInfo(serverInfo);
GetMonitorStatisticDataTask<StatisticData> getStatisticDatatask = new GetMonitorStatisticDataTask<StatisticData>(serverInfo, StatisticParamUtil.getSendMsgItems(item.getType()), statisticData);
getStatisticDatatask.setMetric(host.getMetric());
getStatisticDatatask.setDateType(item.getDType());
/*[TOOLS-3742] Initial StatisticData for GetMonitorStatisticDataTask failure*/
statisticData.setMetric(host.getMetric());
statisticData.setDtype(item.getDType());
switch(item.getType()) {
case DB:
getStatisticDatatask.setDbName(host.getDbName());
statisticData.setDbName(host.getDbName());
break;
case DB_VOL:
getStatisticDatatask.setDbName(host.getDbName());
getStatisticDatatask.setVolName(host.getVolName());
statisticData.setDbName(host.getDbName());
statisticData.setVolName(host.getVolName());
break;
case BROKER:
getStatisticDatatask.setBrokerName(host.getBrokerName());
statisticData.setbName(host.getBrokerName());
break;
case OS:
break;
default:
break;
}
if (!serverInfo.isConnected()) {
disconnectedServerSet.add(serverInfo);
MonitoringTask monitoringTask = serverInfo.getMonitoringTask();
serverInfo = monitoringTask.connectServer(Version.releaseVersion, 1000);
}
if (serverInfo.isConnected()) {
addServer(serverInfo);
getStatisticDatatask.execute();
if (getStatisticDatatask.isSuccess()) {
statisticData = getStatisticDatatask.getResultModel();
dataList.add(statisticData);
} else {
dataList.add(statisticData);
}
} else {
removeServer(serverInfo);
dataList.add(statisticData);
}
}
statisticDataMap.put(chartItem, dataList);
}
tearDownDisconnectedServer();
} else {
//for single host
for (StatisticChartItem chartItem : statisticItemList) {
if (!(chartItem instanceof SingleHostChartItem)) {
statisticDataMap.put(chartItem, EMPTY_STATISTIC_DATA_LIST);
continue;
}
SingleHostChartItem item = (SingleHostChartItem) chartItem;
if (item.getMetricList() == null || item.getMetricList().size() == 0) {
statisticDataMap.put(chartItem, EMPTY_STATISTIC_DATA_LIST);
continue;
}
List<StatisticData> dataList = new ArrayList<StatisticData>();
for (int i = 0; i < item.getMetricList().size(); i++) {
String metric = item.getMetricList().get(i);
StatisticData statisticData = new StatisticData();
statisticData.setServerInfo(serverInfo);
GetMonitorStatisticDataTask<StatisticData> task = new GetMonitorStatisticDataTask<StatisticData>(serverInfo, StatisticParamUtil.getSendMsgItems(item.getType()), statisticData);
task.setMetric(metric);
task.setDateType(item.getDType());
statisticData.setMetric(metric);
statisticData.setDtype(item.getDType());
switch(item.getType()) {
case DB:
task.setDbName(item.getDbName());
statisticData.setDbName(item.getDbName());
break;
case DB_VOL:
task.setDbName(item.getDbName());
task.setVolName(item.getVolName());
statisticData.setDbName(item.getDbName());
statisticData.setVolName(item.getVolName());
break;
case BROKER:
task.setBrokerName(item.getBrokerName());
statisticData.setbName(item.getBrokerName());
break;
case OS:
break;
default:
break;
}
task.execute();
if (task.isSuccess()) {
statisticData = task.getResultModel();
dataList.add(statisticData);
} else if (task.getErrorMsg() != null && (task.getErrorMsg().indexOf("invalid token") != -1 || !serverInfo.isConnected())) {
/*[TOOLS-3742] when invalid token or connect server failure, give out error message*/
errorMsg = task.getErrorMsg();
//build StatisticData with no data
for (; i < item.getMetricList().size(); i++) {
String metric2 = item.getMetricList().get(i);
StatisticData data = (StatisticData) statisticData.clone();
data.setMetric(metric2);
dataList.add(data);
}
break;
}
}
statisticDataMap.put(chartItem, dataList);
}
}
success = true;
}
Aggregations