use of com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo in project cubrid-manager by CUBRID.
the class HostNode method setConnected.
/**
* Only fire the property changed events,does not change the server's real
* connection status, call this method after the server is connected or
* disconnected.
*
* @param connected connections status.
*/
public void setConnected(boolean connected) {
isConnected = connected && getServerInfo() != null;
if (!isConnected) {
HAHostStatusInfo statusInfo = new HAHostStatusInfo();
statusInfo.setIp(getIp());
setHostStatusInfo(statusInfo);
for (DatabaseNode dn : dbNodeList) {
dn.setConnected(isConnected);
}
for (BrokerNode brokerNode : brokerNodeList) {
brokerNode.setBrokerInfo(null);
brokerNode.setBrokerDiagData(null);
brokerNode.setBrokerStatusInfos(null);
}
}
this.firePropertyChange(PROP_HOST_CONNECTION_STATUS, null, isConnected);
}
use of com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo in project cubrid-manager by CUBRID.
the class HAUtil method getSyncModeType.
/**
*
* Get sync mode from standby database node
*
* @param standbyNode DatabaseNode
* @param activeNode DatabaseNode
* @return SyncModeType
*/
public static SyncModeType getSyncModeType(DatabaseNode standbyNode, DatabaseNode activeNode) {
HADatabaseStatusInfo dbStatusInfo = standbyNode.getHaDatabaseStatus();
if (dbStatusInfo == null) {
return null;
}
DBStatusType dbStatusType = dbStatusInfo.getStatusType();
if (dbStatusType != DBStatusType.STANDBY && dbStatusType != DBStatusType.MAINTENANCE) {
return null;
}
List<DbProcessStatusInfo> dbProcessList = dbStatusInfo.getCopyLogDbProcessStatusList();
if (dbProcessList == null || dbProcessList.isEmpty()) {
return null;
}
HAHostStatusInfo hostStatusInfo = dbStatusInfo.getHaHostStatusInfo();
if (hostStatusInfo.getStatusType() != HostStatusType.SLAVE && hostStatusInfo.getStatusType() != HostStatusType.REPLICA) {
return null;
}
HAHostStatusInfo masterHostStatusInfo = hostStatusInfo.getMasterHostStatusInfo();
if (masterHostStatusInfo == null) {
return null;
}
String masterHostName = masterHostStatusInfo.getHostName();
String masterIp = masterHostStatusInfo.getIp();
if (!StringUtil.isIpEqual(activeNode.getParent().getIp(), masterIp)) {
return null;
}
for (DbProcessStatusInfo dbProcessStatusInfo : dbProcessList) {
String hostName = dbProcessStatusInfo.getHostName();
String dbName = dbProcessStatusInfo.getDbName();
if (masterHostName.equals(hostName) && dbName.equals(activeNode.getDbName())) {
return dbProcessStatusInfo.getMode();
}
}
return null;
}
use of com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo in project cubrid-manager by CUBRID.
the class GetHeartbeatNodeInfoTask method buildHaNodeList.
/**
*
* Parse the node and build HAHostStatus object
*
* @param parent The TreeNode
* @param hostStatusList The List<HAHostStatus>
* @param currentHostName The String
* @return The HAHostStatus
*/
private HAHostStatusInfo buildHaNodeList(TreeNode parent, List<HAHostStatusInfo> hostStatusList, String currentHostName) {
HAHostStatusInfo reHaHostStatus = null;
List<HAHostStatusInfo> slaveHostStatusInfoList = new ArrayList<HAHostStatusInfo>();
HAHostStatusInfo masterHostStatusInfo = null;
for (int i = 0; i < parent.childrenSize(); i++) {
TreeNode node = parent.getChildren().get(i);
if (node.getValue("open") == null) {
continue;
}
if (node.getValue("open").trim().equals("node")) {
String hostName = node.getValue("hostname");
String ip = node.getValue("ip");
String priority = node.getValue("priority");
String state = node.getValue("state");
HAHostStatusInfo haHostStatus = new HAHostStatusInfo();
haHostStatus.setHostName(hostName);
haHostStatus.setIp(ip);
haHostStatus.setPriority(priority);
haHostStatus.setStatusType(HostStatusType.getType(state));
if (hostName.equals(currentHostName)) {
reHaHostStatus = haHostStatus;
}
if (haHostStatus.getStatusType() == HostStatusType.MASTER) {
masterHostStatusInfo = haHostStatus;
} else if (haHostStatus.getStatusType() == HostStatusType.SLAVE || haHostStatus.getStatusType() == HostStatusType.REPLICA) {
slaveHostStatusInfoList.add(haHostStatus);
}
hostStatusList.add(haHostStatus);
}
}
//set master and slave relation
for (int i = 0; i < slaveHostStatusInfoList.size(); i++) {
slaveHostStatusInfoList.get(i).setMasterHostStatusInfo(masterHostStatusInfo);
}
if (masterHostStatusInfo != null) {
masterHostStatusInfo.setSlaveHostStatusInfoList(slaveHostStatusInfoList);
}
return reHaHostStatus;
}
use of com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo in project cubrid-manager by CUBRID.
the class GetHeartbeatNodeInfoTask method getHAHostStatusList.
/**
*
* Get host status list
*
* @return The List<HAHostStatus>
*/
public List<HAHostStatusInfo> getHAHostStatusList() {
TreeNode response = getResponse();
if (response == null || (this.getErrorMsg() != null && getErrorMsg().trim().length() > 0)) {
return null;
}
String currentHostName = response.getValue("currentnode");
String currentHostStatus = response.getValue("currentnodestate");
HAHostStatusInfo currentHaHostStatus = null;
hostStatusList = new ArrayList<HAHostStatusInfo>();
for (int i = 0; i < response.childrenSize(); i++) {
TreeNode node = response.getChildren().get(i);
if (node.getValue("open") == null) {
continue;
}
if (node.getValue("open").trim().equals("hanodelist")) {
currentHaHostStatus = buildHaNodeList(node, hostStatusList, currentHostName);
} else if (node.getValue("open").trim().equals("hadbinfolist")) {
buildHaDbInfoList(node, currentHaHostStatus);
}
}
if (currentHaHostStatus != null) {
currentHaHostStatus.setStatusType(HostStatusType.getType(currentHostStatus));
}
return hostStatusList;
}
use of com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo 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);
}
Aggregations