use of com.cubrid.cubridmanager.core.mondashboard.model.DBStatusType in project cubrid-manager by CUBRID.
the class AddHADatabaseDialog method initial.
/**
*
* Initial the value of dialog field
*
*/
private void initial() {
DBStatusType type = haDbStatusInfo.getStatusType();
String ip = haDbStatusInfo.getHaHostStatusInfo().getIp();
String dbName = haDbStatusInfo.getDbName();
if (type == DBStatusType.ACTIVE || type == DBStatusType.TO_BE_ACTIVE) {
setMessage(Messages.bind(Messages.msgAddStadnbyDbDialog, dbName));
} else if (type == DBStatusType.STANDBY || type == DBStatusType.TO_BE_STANDBY || type == DBStatusType.MAINTENANCE) {
setMessage(Messages.bind(Messages.msgAddActiveDbDialog, dbName));
}
for (int i = 0; haHostStatusInfoList != null && i < haHostStatusInfoList.size(); i++) {
String address = haHostStatusInfoList.get(i).getIp();
if (!address.equals(ip)) {
ipCombo.add(address);
}
}
if (ipCombo.getItemCount() > 0) {
ipCombo.select(0);
}
dbNameText.setText(dbName);
ipCombo.addModifyListener(this);
portText.addModifyListener(this);
passwordText.addModifyListener(this);
portText.selectAll();
portText.setFocus();
}
use of com.cubrid.cubridmanager.core.mondashboard.model.DBStatusType in project cubrid-manager by CUBRID.
the class DashboardPreferencePage method performApply.
/**
* Perform Apply,save colors to local.
*/
protected void performApply() {
for (DBStatusType dbt : DBStatusType.values()) {
PREFER.setColor(getDBStatusText(dbt), colorSettings.get(getDBStatusText(dbt)).getBackground());
}
PREFER.setHAHeartBeatTimeout(haHeartBeatTimeout);
PREFER.save();
}
use of com.cubrid.cubridmanager.core.mondashboard.model.DBStatusType 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.DBStatusType in project cubrid-manager by CUBRID.
the class SelectDbPage method getHADatabaseList.
/**
*
* Get databases in HA mode
*
* @param haDbStatusInfo The HADatabaseStatusInfo
* @param haHostStatusInfoList The List<HAHostStatusInfo>
* @param isShowMsg boolean
* @return List<DatabaseNode>
*/
private List<DatabaseNode> getHADatabaseList(HADatabaseStatusInfo haDbStatusInfo, List<HAHostStatusInfo> haHostStatusInfoList, boolean isShowMsg) {
boolean isConfirm = false;
if (haDbStatusInfo != null) {
DBStatusType type = haDbStatusInfo.getStatusType();
String msg = null;
if (type == DBStatusType.ACTIVE || type == DBStatusType.TO_BE_ACTIVE) {
msg = Messages.bind(Messages.confirmMsgAddStandby, type.getText());
isConfirm = true;
} else if (type == DBStatusType.STANDBY || type == DBStatusType.TO_BE_STANDBY || type == DBStatusType.MAINTENANCE) {
msg = Messages.bind(Messages.confirmMsgAddActive, type.getText());
isConfirm = true;
}
if (isShowMsg) {
isConfirm = CommonUITool.openConfirmBox(msg);
}
}
if (isConfirm) {
AddHADatabaseDialog dialog = new AddHADatabaseDialog(getShell(), haDbStatusInfo, haHostStatusInfoList);
int ret = dialog.open();
if (ret == IDialogConstants.OK_ID) {
return dialog.getDbNodeList();
}
}
return null;
}
use of com.cubrid.cubridmanager.core.mondashboard.model.DBStatusType 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