use of com.cubrid.cubridmanager.ui.replication.editor.model.LeafNode in project cubrid-manager by CUBRID.
the class LeafNodePart method refreshVisuals.
/**
* @see com.cubrid.cubridmanager.ui.replication.editor.parts.NodePart#refreshVisuals()
*/
protected void refreshVisuals() {
super.refreshVisuals();
LeafNode node = (LeafNode) getModel();
LeafNodeFigure figure = (LeafNodeFigure) getFigure();
figure.setText(node.getName());
if (getModel() instanceof MasterNode) {
figure.setIcon(CubridManagerUIPlugin.getImage("icons/replication/master.png"));
}
if (getModel() instanceof DistributorNode) {
figure.setIcon(CubridManagerUIPlugin.getImage("icons/replication/distributor.gif"));
}
if (getModel() instanceof SlaveNode) {
figure.setIcon(CubridManagerUIPlugin.getImage("icons/replication/slave.png"));
}
}
use of com.cubrid.cubridmanager.ui.replication.editor.model.LeafNode in project cubrid-manager by CUBRID.
the class ReplicationEditor method doSave.
/**
* @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
* @param monitor IProgressMonitor
*/
public void doSave(IProgressMonitor monitor) {
List<ContainerNode> hostNodeList = diagram.getChildNodeList();
int hostSize = 0;
if (hostNodeList != null) {
hostSize = hostNodeList.size();
}
//check the host number,2 at less
if (hostSize <= 1) {
CommonUITool.openErrorBox(this.getSite().getShell(), Messages.errInvalidReplDesign);
monitor.setCanceled(true);
return;
}
//check the host and replication component information integrity
for (int i = 0; i < hostSize; i++) {
HostNode host = (HostNode) hostNodeList.get(i);
if (!host.isValid()) {
CommonUITool.openErrorBox(this.getSite().getShell(), Messages.bind(Messages.errInvalidHost, host.getName()));
monitor.setCanceled(true);
return;
}
List<LeafNode> leafNodeList = host.getChildNodeList();
for (int j = 0; j < leafNodeList.size(); j++) {
LeafNode node = leafNodeList.get(j);
if (!node.isValid()) {
CommonUITool.openErrorBox(this.getSite().getShell(), Messages.bind(Messages.errInvalidReplComponent, node.getName()));
monitor.setCanceled(true);
return;
}
}
}
//check the replication component connection validity
List<List<Node>> replicationsList = new ArrayList<List<Node>>();
for (int i = 0; i < hostSize; i++) {
HostNode host = (HostNode) hostNodeList.get(i);
List<LeafNode> leafNodeList = host.getChildNodeList();
for (int j = 0; j < leafNodeList.size(); j++) {
LeafNode node = leafNodeList.get(j);
if (node instanceof MasterNode) {
List<ArrowConnection> connList = node.getOutgoingConnections();
if (connList == null || connList.isEmpty()) {
CommonUITool.openErrorBox(this.getSite().getShell(), Messages.bind(Messages.errInvalidMasterConn1, node.getName()));
monitor.setCanceled(true);
return;
} else {
for (int k = 0; k < connList.size(); k++) {
LOGGER.debug("Replication chain" + k);
LOGGER.debug(node.getName());
List<Node> replicationList = new ArrayList<Node>();
replicationList.add(node);
HostNode masterHost = (HostNode) node.getParent();
ArrowConnection conn = connList.get(k);
HostNode distHost = (HostNode) conn.getTarget().getParent();
if (masterHost.getName().equals(distHost.getName())) {
CommonUITool.openErrorBox(this.getSite().getShell(), Messages.bind(Messages.errInvalidMasterConn2, new String[] { node.getName(), conn.getTarget().getName() }));
monitor.setCanceled(true);
return;
}
createReplChain(replicationList, conn);
replicationsList.add(replicationList);
}
}
} else if (node instanceof DistributorNode) {
if (node.getIncomingConnections() == null || node.getIncomingConnections().size() == 0) {
CommonUITool.openErrorBox(this.getSite().getShell(), Messages.bind(Messages.errInvalidDistConn1, node.getName()));
monitor.setCanceled(true);
return;
}
if (node.getOutgoingConnections() == null || node.getOutgoingConnections().size() == 0) {
CommonUITool.openErrorBox(this.getSite().getShell(), Messages.bind(Messages.errInvalidDistConn2, node.getName()));
monitor.setCanceled(true);
return;
}
} else if (node instanceof SlaveNode && (node.getIncomingConnections() == null || node.getIncomingConnections().isEmpty())) {
CommonUITool.openErrorBox(this.getSite().getShell(), Messages.bind(Messages.errInvalidSlaveConn, node.getName()));
monitor.setCanceled(true);
return;
}
}
}
int count = replicationsList.size();
if (count <= 0) {
CommonUITool.openErrorBox(this.getSite().getShell(), Messages.errInvalidReplDesign);
monitor.setCanceled(true);
return;
}
for (int i = 0; i < count; i++) {
List<Node> replcationlist = replicationsList.get(i);
int size = replcationlist.size();
if (size < 3) {
CommonUITool.openErrorBox(this.getSite().getShell(), Messages.errInvalidReplDesign);
monitor.setCanceled(true);
return;
}
if (!(replcationlist.get(size - 1) instanceof SlaveNode)) {
CommonUITool.openErrorBox(this.getSite().getShell(), Messages.errInvalidReplDesign);
monitor.setCanceled(true);
return;
}
//check the connection validity,
for (int j = 1; j + 1 < size; j++) {
Node node1 = (Node) replcationlist.get(j).getParent();
Node node2 = (Node) replcationlist.get(j + 1).getParent();
//from the slave to the distributor can not in the same host
if (j % 2 == 0) {
if (node1.getName().equals(node2.getName())) {
CommonUITool.openErrorBox(this.getSite().getShell(), Messages.bind(Messages.errInvalidConn1, new String[] { node1.getName(), node2.getName() }));
monitor.setCanceled(true);
return;
}
} else {
//from the distributor to the slave must be in the same host
if (!node1.getName().equals(node2.getName())) {
CommonUITool.openErrorBox(this.getSite().getShell(), Messages.bind(Messages.errInvalidConn2, new String[] { node1.getName(), node2.getName() }));
monitor.setCanceled(true);
return;
}
}
}
}
if (!CommonUITool.openConfirmBox(Messages.msgConfirmCreateRepl)) {
return;
}
isEditable = false;
getCommandStack().flush();
setDirty(false);
createReplication(replicationsList);
}
use of com.cubrid.cubridmanager.ui.replication.editor.model.LeafNode in project cubrid-manager by CUBRID.
the class SetSlaveDbInfoDialog method valid.
/**
* validate the input data
*
* @return boolean
*/
public boolean valid() {
String dbName = slaveDbNameText.getText();
String dbPath = dbPathText.getText();
String dbUser = dbUserText.getText();
String dbaPassword = dbPasswordText.getText();
String confirmDbaPassword = confirmDbPasswordText.getText();
boolean isValidHost = hostNode != null && hostNode.isValid();
if (!isValidHost) {
setErrorMessage(Messages.errInvalidHostInfo);
return false;
}
boolean isValidDbName = ValidateUtil.isValidDBName(dbName);
if (!isValidDbName) {
setErrorMessage(Messages.errDatabaseName);
return false;
}
boolean isDatabaseExist = false;
if (isValidDbName && isValidHost) {
List<DatabaseInfo> databaseInfoList = hostNode.getDatabaseInfoList();
for (int i = 0; databaseInfoList != null && i < databaseInfoList.size(); i++) {
DatabaseInfo databaseInfo = databaseInfoList.get(i);
if (dbName.equalsIgnoreCase(databaseInfo.getDbName())) {
isDatabaseExist = true;
break;
}
}
if (!isDatabaseExist) {
List<LeafNode> childNodeList = hostNode.getChildNodeList();
for (int i = 0; childNodeList != null && i < childNodeList.size(); i++) {
LeafNode node = childNodeList.get(i);
if (dbName.equalsIgnoreCase(node.getName()) && !dbName.equals(slaveNode.getDbName())) {
isDatabaseExist = true;
break;
}
}
}
}
if (isDatabaseExist) {
setErrorMessage(Messages.errDbExist);
return false;
}
boolean isValidDbPathName = ValidateUtil.isValidPathName(dbPath);
if (!isValidDbPathName) {
setErrorMessage(Messages.errDbPath);
return false;
}
boolean isValidDbUser = dbUser.trim().length() > 0 && dbUser.indexOf(" ") < 0 && !dbUser.equalsIgnoreCase("dba") && dbUser.trim().length() < ValidateUtil.MAX_NAME_LENGTH;
if (!isValidDbUser) {
setErrorMessage(Messages.errDbUser);
return false;
}
boolean isValidDbPassword = dbaPassword.trim().length() >= 4 && dbaPassword.indexOf(" ") < 0;
if (!isValidDbPassword) {
setErrorMessage(Messages.errDbPassword);
return false;
}
boolean isValidConfirmDbPassword = confirmDbaPassword.length() >= 4 && confirmDbaPassword.indexOf(" ") < 0;
if (!isValidConfirmDbPassword) {
setErrorMessage(Messages.errConfirmedDbPassword);
return false;
}
boolean isEqualPassword = dbaPassword.equals(confirmDbaPassword);
if (!isEqualPassword) {
setErrorMessage(Messages.errPasswordNotEqual);
return false;
}
setErrorMessage(null);
return true;
}
use of com.cubrid.cubridmanager.ui.replication.editor.model.LeafNode in project cubrid-manager by CUBRID.
the class ContainerNodePart method getModelTargetConnections.
/**
* @see com.cubrid.cubridmanager.ui.replication.editor.parts.NodePart#getModelTargetConnections()
* @return list
*/
protected List<ArrowConnection> getModelTargetConnections() {
List<ArrowConnection> list = new ArrayList<ArrowConnection>();
list.addAll(getContainerNode().getIncomingConnections());
for (Iterator<LeafNode> iter = getContainerNode().getChildNodeList().iterator(); iter.hasNext(); ) {
LeafNode node = (LeafNode) iter.next();
list.addAll(node.getIncomingConnections());
}
return list;
}
use of com.cubrid.cubridmanager.ui.replication.editor.model.LeafNode in project cubrid-manager by CUBRID.
the class CreateLeafNodeCommand method getSize.
/**
* get the size
*
* @param name String
* @return size
*/
public int getSize(String name) {
int count = containerNode.getChildNodeList().size();
int size = 0;
for (int i = 0; i < count; i++) {
LeafNode node = (LeafNode) containerNode.getChildNodeList().get(i);
if (node.getClass().getName().equals(name)) {
size++;
}
}
return size;
}
Aggregations