use of com.cubrid.cubridmanager.ui.spi.model.CubridBroker in project cubrid-manager by CUBRID.
the class CubridBrokerFolderLoader method checkBrokerExist.
/**
*
* Check broker whether exist
*
* @param parent the parent node
* @param monitor the IProgressMonitor
* @return <code>0</code> exist;<code>1</code> has error;<code>2</code>
* canceled;<code>3</code> no exist;
*/
private int checkBrokerExist(final ICubridNode parent, final IProgressMonitor monitor) {
ServerInfo serverInfo = parent.getServer().getServerInfo();
BrokerInfos brokerInfos = new BrokerInfos();
final CommonQueryTask<BrokerInfos> getBrokersTask = new CommonQueryTask<BrokerInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), brokerInfos);
monitorCancel(monitor, new ITask[] { getBrokersTask });
getBrokersTask.execute();
final String msg = getBrokersTask.getErrorMsg();
if (!monitor.isCanceled() && msg != null && msg.trim().length() > 0) {
parent.removeAllChild();
openErrorBox(msg);
setLoaded(true);
return 1;
}
if (monitor.isCanceled()) {
setLoaded(true);
return 2;
}
CubridBroker broker = (CubridBroker) parent;
String brokerName = broker.getLabel();
brokerInfos = getBrokersTask.getResultModel();
boolean isExist = false;
List<BrokerInfo> brokerInfoList = (brokerInfos == null || brokerInfos.getBorkerInfoList() == null) ? null : brokerInfos.getBorkerInfoList().getBrokerInfoList();
for (int i = 0; brokerInfoList != null && i < brokerInfoList.size(); i++) {
BrokerInfo brokerInfo = brokerInfoList.get(i);
if (brokerInfo.getName().equalsIgnoreCase(brokerName)) {
broker.setRunning(brokerInfo.getState() == null ? false : brokerInfo.getState().equalsIgnoreCase("ON"));
isExist = true;
}
}
return isExist ? 0 : 3;
}
use of com.cubrid.cubridmanager.ui.spi.model.CubridBroker in project cubrid-manager by CUBRID.
the class CubridBrokersFolderLoader method load.
/**
*
* Load children object for parent
*
* @param parent the parent node
* @param monitor the IProgressMonitor object
*/
public void load(ICubridNode parent, final IProgressMonitor monitor) {
synchronized (this) {
if (isLoaded()) {
return;
}
ServerInfo serverInfo = parent.getServer().getServerInfo();
ServerUserInfo userInfo = serverInfo.getLoginedUserInfo();
if (userInfo == null || CasAuthType.AUTH_NONE == userInfo.getCasAuth()) {
parent.removeAllChild();
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
return;
}
BrokerInfos brokerInfos = new BrokerInfos();
final CommonQueryTask<BrokerInfos> task = new CommonQueryTask<BrokerInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), brokerInfos);
monitorCancel(monitor, new ITask[] { task });
task.execute();
final String errorMsg = task.getErrorMsg();
if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
parent.removeAllChild();
Display display = Display.getDefault();
display.syncExec(new Runnable() {
public void run() {
CommonUITool.openErrorBox(errorMsg);
}
});
setLoaded(true);
return;
}
if (monitor.isCanceled()) {
setLoaded(true);
return;
}
brokerInfos = task.getResultModel();
List<ICubridNode> oldNodeList = parent.getChildren();
parent.removeAllChild();
List<BrokerInfo> brokerInfoList = (brokerInfos == null || brokerInfos.getBorkerInfoList() == null) ? null : brokerInfos.getBorkerInfoList().getBrokerInfoList();
for (int i = 0; brokerInfoList != null && i < brokerInfoList.size(); i++) {
BrokerInfo brokerInfo = brokerInfoList.get(i);
String id = parent.getId() + NODE_SEPARATOR + brokerInfo.getName();
ICubridNode brokerInfoNode = isContained(oldNodeList, id);
if (brokerInfoNode == null) {
brokerInfoNode = new CubridBroker(id, brokerInfo.getName(), "icons/navigator/broker.png");
((CubridBroker) brokerInfoNode).setStartedIconPath("icons/navigator/broker_started.png");
brokerInfoNode.setType(CubridNodeType.BROKER);
brokerInfoNode.setContainer(true);
brokerInfoNode.setModelObj(brokerInfo);
brokerInfoNode.setViewId(BrokerStatusView.ID);
brokerInfoNode.setLoader(new CubridBrokerFolderLoader());
} else {
brokerInfoNode.setModelObj(brokerInfo);
if (brokerInfoNode.getLoader() != null && brokerInfoNode.getLoader().isLoaded()) {
brokerInfoNode.getLoader().setLoaded(false);
brokerInfoNode.getChildren(monitor);
}
}
parent.addChild(brokerInfoNode);
}
serverInfo.setBrokerInfos(brokerInfos);
// For the Shard Broker Folder
if (CompatibleUtil.isSupportShard(serverInfo)) {
Shards shards = new Shards();
GetShardConfTask<Shards> getShardConfTask = new GetShardConfTask<Shards>(serverInfo, shards);
getShardConfTask.execute();
// !"File(?) open error".equals(errorMsg.trim())) {
if (getShardConfTask.isSuccess()) {
GetShardStatusTask getShardStatusTask = new GetShardStatusTask(serverInfo, null);
getShardStatusTask.execute();
boolean runningShard = getShardStatusTask.isSuccess();
serverInfo.setShards(shards);
shards.setRunning(runningShard);
String shardFolderId = parent.getId() + NODE_SEPARATOR + SHARD_FOLDER_ID;
ICubridNode shardFolder = parent.getChild(shardFolderId);
if (shardFolder == null) {
shardFolder = new CubridShardFolder(shardFolderId, SHARD_FOLDER_NAME);
ICubridNodeLoader loader = new CubridShardsFolderLoader((CubridShardFolder) shardFolder);
loader.setLevel(getLevel());
shardFolder.setLoader(loader);
parent.addChild(shardFolder);
// shardFolder.getChildren(monitor);
} else {
if (shardFolder.getLoader() != null && shardFolder.getLoader().isLoaded()) {
shardFolder.getLoader().setLoaded(false);
shardFolder.getChildren(monitor);
}
}
}
}
Collections.sort(parent.getChildren());
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of com.cubrid.cubridmanager.ui.spi.model.CubridBroker in project cubrid-manager by CUBRID.
the class NavigatorTreeLabelProvider method getText.
public String getText(Object element) {
if (element instanceof ICubridNode) {
if (element instanceof CubridDatabase) {
CubridDatabase database = (CubridDatabase) element;
StringBuffer sbLabel = new StringBuffer();
sbLabel.append(((ICubridNode) element).getLabel());
DatabaseEditorConfig editorConfig = QueryOptions.getEditorConfig(database, true);
if (editorConfig != null && editorConfig.getDatabaseComment() != null && editorConfig.getDatabaseComment().length() > 0) {
sbLabel.append("(").append(editorConfig.getDatabaseComment()).append(")");
return sbLabel.toString();
}
} else if (element instanceof CubridBroker) {
CubridBroker broker = (CubridBroker) element;
BrokerInfo brokerInfo = broker.getBrokerInfo();
if (brokerInfo == null || brokerInfo.getAccess_mode() == null) {
return broker.getName();
}
return broker.getName() + " (" + brokerInfo.getPort() + "," + brokerInfo.getAccess_mode() + ")";
} else if (element instanceof CubridServer) {
CubridServer server = (CubridServer) element;
return decorateServerText(server.getLabel(), server);
}
return ((ICubridNode) element).getLabel();
} else if (element instanceof PendingUpdateAdapter) {
return com.cubrid.common.ui.common.Messages.msgLoading;
}
return element == null ? "" : element.toString();
}
use of com.cubrid.cubridmanager.ui.spi.model.CubridBroker in project cubrid-manager by CUBRID.
the class CubridHostNavigatorView method getToolTip.
/**
* Get tooltip string
*
* @param cubridNode ICubridNode
* @return String
*/
protected String getToolTip(ICubridNode cubridNode) {
StringBuffer toolTipText = new StringBuffer();
if (cubridNode instanceof CubridServer) {
CubridServer server = (CubridServer) cubridNode;
String ip = server.getHostAddress();
toolTipText.append(Messages.bind(Messages.tipIP, ip == null ? "" : ip)).append("\r\n");
String port = server.getMonPort();
toolTipText.append(Messages.bind(Messages.tipPort, port == null ? "" : port)).append("\r\n");
String userName = server.getUserName();
toolTipText.append(Messages.bind(Messages.tipUser, userName == null ? "" : userName)).append("\r\n");
String jdbcVersion = server.getJdbcDriverVersion();
toolTipText.append(Messages.bind(Messages.tipJDBC, jdbcVersion == null ? "" : jdbcVersion));
} else if (cubridNode instanceof CubridBroker) {
CubridBroker broker = (CubridBroker) cubridNode;
BrokerInfo brokerInfo = broker.getBrokerInfo();
String brokerMode = brokerInfo.getAccess_mode() == null ? Messages.tipBrokerAccessModeNotWorking : brokerInfo.getAccess_mode();
toolTipText.append(Messages.bind(Messages.tipBrokerPort, brokerInfo.getPort())).append("\r\n");
toolTipText.append(Messages.bind(Messages.tipBrokerAccessMode, brokerMode)).append("\r\n");
if (OnOffType.ON.getText().equalsIgnoreCase(brokerInfo.getState())) {
toolTipText.append(Messages.tipBrokerStatusON);
} else {
toolTipText.append(Messages.tipBrokerStatusOFF);
}
}
return toolTipText.toString();
}
use of com.cubrid.cubridmanager.ui.spi.model.CubridBroker in project cubrid-manager by CUBRID.
the class ShowBrokerStatusAction method isSupported.
/**
* Return whether this action support this object,if not support,this action
* will be disabled
*
* @see com.cubrid.common.ui.spi.action.ISelectionAction#isSupported(java
* .lang.Object)
* @param obj the object
* @return <code>true</code> if supported;<code>false</code>
*/
public boolean isSupported(Object obj) {
if (obj instanceof CubridBroker) {
CubridBroker selection = ((CubridBroker) obj);
ServerUserInfo userInfo = selection.getServer().getServerInfo().getLoginedUserInfo();
if (userInfo == null || (CasAuthType.AUTH_ADMIN != userInfo.getCasAuth() && CasAuthType.AUTH_MONITOR != userInfo.getCasAuth())) {
return false;
}
return true;
}
return false;
}
Aggregations