use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode in project cubrid-manager by CUBRID.
the class HAUtil method mergeCopyedHostChildNode.
/**
*
* Merge the database node
*
* @param hostNode The HostNode
* @param addedHostNode The HostNode
*/
private static void mergeCopyedHostChildNode(HostNode hostNode, HostNode addedHostNode) {
List<HANode> haNodeList = hostNode.getCopyedHaNodeList();
//merge database node
List<DatabaseNode> addedDbNodeList = addedHostNode.getCopyedDbNodeList();
for (int i = 0; i < addedDbNodeList.size(); i++) {
DatabaseNode addDbNode = addedDbNodeList.get(i);
addDbNode.setParent(hostNode);
if (haNodeList.contains(addDbNode)) {
haNodeList.remove(addDbNode);
haNodeList.add(addDbNode);
} else {
haNodeList.add(addDbNode);
}
}
//merge broker node
List<BrokerNode> addedBrokerNodeList = addedHostNode.getCopyedBrokerNodeList();
for (int i = 0; i < addedBrokerNodeList.size(); i++) {
BrokerNode addBrokerNode = addedBrokerNodeList.get(i);
addBrokerNode.setParent(hostNode);
if (haNodeList.contains(addBrokerNode)) {
haNodeList.remove(addBrokerNode);
haNodeList.add(addBrokerNode);
} else {
haNodeList.add(addBrokerNode);
}
}
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode in project cubrid-manager by CUBRID.
the class AddHostAndDbWizard method performFinish.
/**
* Called when user clicks Finish
*
* @return boolean
*/
public boolean performFinish() {
List<Map<String, Object>> dbNodeList = selectDbPage == null ? null : selectDbPage.getDbNodeList();
List<Map<String, Object>> brokerNodeNodeList = selectBrokerPage == null ? null : selectBrokerPage.getBrokerNodeList();
HostNode hostNode = mergeHostNode(setHostInfoPage == null ? null : setHostInfoPage.getHostNode());
for (int i = 0; dbNodeList != null && i < dbNodeList.size(); i++) {
Map<String, Object> map = dbNodeList.get(i);
hostNode = mergeHostNode((HostNode) map.get("6"));
DatabaseNode dbNode = (DatabaseNode) map.get("7");
if (hostNode != null) {
dbNode.setParent(hostNode);
hostNode.getCopyedHaNodeList().remove(dbNode);
hostNode.getCopyedHaNodeList().add(dbNode);
}
}
for (int i = 0; brokerNodeNodeList != null && i < brokerNodeNodeList.size(); i++) {
Map<String, Object> map = brokerNodeNodeList.get(i);
hostNode = mergeHostNode((HostNode) map.get("8"));
BrokerNode brokerNode = (BrokerNode) map.get("9");
if (hostNode != null) {
brokerNode.setParent(hostNode);
hostNode.getCopyedHaNodeList().remove(brokerNode);
hostNode.getCopyedHaNodeList().add(brokerNode);
}
}
return true;
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode in project cubrid-manager by CUBRID.
the class SelectDbPage method addDbNodeToTable.
/**
*
* Add DatabaseNode to table
*
* @param haDbNodeList The List<DatabaseNode>
* @param haHostStatusInfoList The List<HAHostStatusInfo>
*/
private void addDbNodeToTable(List<DatabaseNode> haDbNodeList, List<HAHostStatusInfo> haHostStatusInfoList) {
for (int i = 0; haDbNodeList != null && i < haDbNodeList.size(); i++) {
DatabaseNode dbNode = haDbNodeList.get(i);
if (isDbNodeExist(dbNode)) {
continue;
}
Map<String, Object> map = new HashMap<String, Object>();
map.put("0", dbNode.getName());
map.put("1", dbNode.getDbName());
map.put("2", DBStatusType.getShowText(dbNode.getDbStatusType()));
map.put("3", dbNode.getParent().getIp());
map.put("4", dbNode.getParent().getPort());
map.put("5", HostStatusType.getShowText(dbNode.getParent().getHostStatusInfo().getStatusType()));
map.put("6", dbNode.getParent());
map.put("7", dbNode);
map.put("8", haHostStatusInfoList);
dbNodeList.add(map);
}
dbTableViewer.refresh();
for (int i = 0; i < dbTable.getColumnCount(); i++) {
dbTable.getColumn(i).pack();
}
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode in project cubrid-manager by CUBRID.
the class SelectDbPage method createTable.
/**
*
* Create table area
*
* @param parent the parent composite
*/
private void createTable(Composite parent) {
Label tipLabel = new Label(parent, SWT.LEFT | SWT.WRAP);
tipLabel.setText(Messages.lblDbListInfo);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
tipLabel.setLayoutData(gridData);
final String[] columnNameArr = new String[] { Messages.colNickName, Messages.colDbName, Messages.colDbStatus, Messages.colIP, Messages.colPort, Messages.colServerStatus };
dbTableViewer = CommonUITool.createCommonTableViewer(parent, null, columnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, 500));
dbTable = dbTableViewer.getTable();
for (int i = 0; i < dbTable.getColumnCount(); i++) {
dbTable.getColumn(i).pack();
}
dbTable.addSelectionListener(new SelectionAdapter() {
@SuppressWarnings("unchecked")
public void widgetSelected(SelectionEvent event) {
deleteDbButton.setEnabled(dbTable.getSelectionCount() > 0);
addHANodeButton.setEnabled(false);
StructuredSelection selection = (StructuredSelection) dbTableViewer.getSelection();
if (selection == null || selection.isEmpty() || selection.size() > 1) {
return;
}
Map<String, Object> map = (Map<String, Object>) selection.getFirstElement();
DatabaseNode dbNode = (DatabaseNode) map.get("7");
DBStatusType type = dbNode.getHaDatabaseStatus().getStatusType();
if (type == DBStatusType.ACTIVE || type == DBStatusType.TO_BE_ACTIVE || type == DBStatusType.MAINTENANCE || type == DBStatusType.STANDBY || type == DBStatusType.TO_BE_STANDBY) {
addHANodeButton.setEnabled(true);
}
}
});
dbTableViewer.setInput(dbNodeList);
Composite composite = new Composite(parent, SWT.NONE);
RowLayout rowLayout = new RowLayout();
rowLayout.spacing = 5;
composite.setLayout(rowLayout);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalAlignment = GridData.END;
composite.setLayoutData(gridData);
addHANodeButton = new Button(composite, SWT.NONE);
addHANodeButton.setText(Messages.btnAddHADb);
addHANodeButton.setToolTipText(Messages.tipBtnAddHaDb);
addHANodeButton.addSelectionListener(new SelectionAdapter() {
@SuppressWarnings("unchecked")
public void widgetSelected(SelectionEvent event) {
StructuredSelection selection = (StructuredSelection) dbTableViewer.getSelection();
if (selection == null || selection.isEmpty() || selection.size() > 1) {
return;
}
Map<String, Object> map = (Map<String, Object>) selection.getFirstElement();
DatabaseNode dbNode = (DatabaseNode) map.get("7");
List<HAHostStatusInfo> haHostStatusInfoList = (List<HAHostStatusInfo>) map.get("8");
List<DatabaseNode> haDbNodeList = getHADatabaseList(dbNode.getHaDatabaseStatus(), haHostStatusInfoList, false);
if (haDbNodeList == null) {
haDbNodeList = new ArrayList<DatabaseNode>();
}
if (dbNode.getDbStatusType() == DBStatusType.ACTIVE || dbNode.getDbStatusType() == DBStatusType.TO_BE_ACTIVE) {
haDbNodeList.add(0, dbNode);
} else {
haDbNodeList.add(dbNode);
}
addDbNodeToTable(haDbNodeList, haHostStatusInfoList);
addHANodeButton.setEnabled(dbTable.getSelectionCount() > 0);
}
});
addHANodeButton.setEnabled(false);
deleteDbButton = new Button(composite, SWT.NONE);
deleteDbButton.setText(Messages.btnDelete);
deleteDbButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
StructuredSelection selection = (StructuredSelection) dbTableViewer.getSelection();
if (selection != null && !selection.isEmpty()) {
dbNodeList.removeAll(selection.toList());
}
dbTableViewer.refresh();
deleteDbButton.setEnabled(dbTable.getSelectionCount() > 0);
}
});
deleteDbButton.setEnabled(false);
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode in project cubrid-manager by CUBRID.
the class ConnectionManager method connectHost.
/**
*
* Connect Host
*
* @param hostNode The HostNode
* @param isConnectChild The boolean
* @param isPing The boolean
*/
public static void connectHost(HostNode hostNode, boolean isConnectChild, boolean isPing) {
if (hostNode.isConnected() || hostNode.isConnecting()) {
return;
}
ServerInfo serverInfo = hostNode.getServerInfo();
if (serverInfo == null) {
serverInfo = new ServerInfo();
serverInfo.setServerName(hostNode.getIp());
serverInfo.setHostAddress(hostNode.getIp());
serverInfo.setHostMonPort(Integer.parseInt(hostNode.getPort()));
serverInfo.setHostJSPort(Integer.parseInt(hostNode.getPort()) + 1);
serverInfo.setUserName(hostNode.getUserName());
serverInfo.setUserPassword(hostNode.getPassword());
serverInfo.setJdbcDriverVersion(ServerJdbcVersionMapping.JDBC_SELF_ADAPTING_VERSION);
}
hostNode.setConnecting(true);
ConnectHostJobExecutor executor = new ConnectHostJobExecutor(hostNode, serverInfo, isPing);
IStatus status = executor.exec(new NullProgressMonitor());
executor.finish(status);
if (isConnectChild && hostNode.isConnected()) {
List<DatabaseNode> dbNodeList = hostNode.getDbNodeList();
for (DatabaseNode dbNode : dbNodeList) {
if (dbNode.isConnecting() || dbNode.isConnected()) {
continue;
}
dbNode.setConnecting(true);
ConnectDatabaseNodeJobExecutor dbJobExecutor = new ConnectDatabaseNodeJobExecutor(dbNode, serverInfo);
status = dbJobExecutor.exec(new NullProgressMonitor());
dbJobExecutor.finish(status);
}
}
}
Aggregations