use of com.cubrid.cubridmanager.ui.spi.model.CubridShardFolder in project cubrid-manager by CUBRID.
the class NavigatorTreeLabelProvider method getImage.
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
*/
public Image getImage(Object element) {
String iconPath = "";
if (element instanceof CubridServer) {
CubridServer server = (CubridServer) element;
if (server.isConnected()) {
iconPath = server.getConnectedIconPath();
} else {
iconPath = server.getDisConnectedIconPath();
}
Image serverImage = CubridManagerUIPlugin.getImage(iconPath);
return decorateServerImgae(serverImage, server);
} else if (element instanceof CubridDatabase) {
CubridDatabase database = (CubridDatabase) element;
if (database.getRunningType() == DbRunningType.STANDALONE && database.isLogined()) {
iconPath = database.getStopAndLoginIconPath();
} else if (database.getRunningType() == DbRunningType.STANDALONE && !database.isLogined()) {
iconPath = database.getStopAndLogoutIconPath();
} else if (database.getRunningType() == DbRunningType.CS && database.isLogined()) {
iconPath = database.getStartAndLoginIconPath();
} else if (database.getRunningType() == DbRunningType.CS && !database.isLogined()) {
iconPath = database.getStartAndLogoutIconPath();
}
Image databaseImage = CubridManagerUIPlugin.getImage(iconPath);
return decorateDatabaseImgae(databaseImage, database);
} else if (element instanceof CubridBrokerFolder) {
CubridBrokerFolder brokerFolder = (CubridBrokerFolder) element;
if (brokerFolder.isRunning()) {
iconPath = brokerFolder.getStartedIconPath();
} else {
iconPath = brokerFolder.getStopedIconPath();
}
} else if (element instanceof CubridBroker) {
CubridBroker broker = (CubridBroker) element;
if (broker.isRunning()) {
iconPath = broker.getStartedIconPath();
} else {
iconPath = broker.getStopedIconPath();
}
} else if (element instanceof CubridShardFolder) {
// TODO shard
CubridShardFolder shardFolder = (CubridShardFolder) element;
// if (shardFolder.isEnable()) {
if (shardFolder.isRunning()) {
iconPath = shardFolder.getStartedIconPath();
} else {
iconPath = shardFolder.getStopedIconPath();
}
// } else {
// iconPath = shardFolder.getDisableIconPath();
// }
} else if (element instanceof CubridShard) {
CubridShard shard = (CubridShard) element;
if (shard.isRunning()) {
iconPath = shard.getStartedIconPath();
} else {
iconPath = shard.getStopedIconPath();
}
} else if (element instanceof ICubridNode) {
ICubridNode node = (ICubridNode) element;
iconPath = node.getIconPath();
}
if (iconPath != null && iconPath.length() > 0) {
return CubridManagerUIPlugin.getImage(iconPath.trim());
}
return super.getImage(element);
}
use of com.cubrid.cubridmanager.ui.spi.model.CubridShardFolder in project cubrid-manager by CUBRID.
the class StartShardEnvAction method run.
/**
* Override the run method in order to complete starting broker environment
*
*/
public void run() {
final Object[] obj = this.getSelectedObj();
CubridShardFolder selection = (CubridShardFolder) obj[0];
if (null == selection) {
return;
}
ServerInfo serverInfo = selection.getServer().getServerInfo();
StartShardTask task = new StartShardTask(serverInfo, null);
IMessageHandler messageHandler = new IMessageHandler() {
public String translate(String message) {
if (message == null) {
return "";
}
if (message.indexOf("failed to metadata validate check") != -1) {
return Messages.errStartShardNotConfigOrFailed + StringUtil.NEWLINE + StringUtil.NEWLINE + Messages.msgShardGuide;
}
return "";
}
};
TaskExecutor taskExecutor = new CommonTaskExec(Messages.startShardEnvActionName, messageHandler);
taskExecutor.addTask(task);
new ExecTaskWithProgress(taskExecutor).exec();
if (!taskExecutor.isSuccess()) {
return;
}
if (!task.isSuccess()) {
String msg = Messages.bind(Messages.errCanNotStartShardBroker, Messages.msgShardGuide);
CommonUITool.openErrorBox(msg);
return;
}
selection.setRunning(true);
TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
CommonUITool.refreshNavigatorTree(treeViewer, selection);
ActionManager.getInstance().fireSelectionChanged(getSelection());
}
use of com.cubrid.cubridmanager.ui.spi.model.CubridShardFolder in project cubrid-manager by CUBRID.
the class StartShardEnvAction method isSupportedNode.
/**
* Return whether this action support this object,if not support,this action
* will be disabled
*
* @param obj
* the object
* @return <code>true</code> if supported;<code>false</code>
*/
public static boolean isSupportedNode(Object obj) {
if (obj instanceof CubridShardFolder) {
CubridShardFolder selection = ((CubridShardFolder) obj);
if (!selection.isEnable()) {
return false;
}
ServerUserInfo userInfo = selection.getServer().getServerInfo().getLoginedUserInfo();
if (userInfo == null || CasAuthType.AUTH_ADMIN != userInfo.getCasAuth()) {
return false;
}
return !selection.isRunning();
}
return false;
}
use of com.cubrid.cubridmanager.ui.spi.model.CubridShardFolder in project cubrid-manager by CUBRID.
the class ShardEnvStatusView method nodeChanged.
/**
* Response to cubrid node changes
*
* @param event
* the event
*/
public void nodeChanged(CubridNodeChangedEvent event) {
ICubridNode eventNode = event.getCubridNode();
if (eventNode == null || this.cubridNode == null) {
return;
}
// if it is not in the same host,return
if (!eventNode.getServer().getId().equals(this.cubridNode.getServer().getId())) {
return;
}
// if changed node is not broker folder or server,return
String type = eventNode.getType();
if (!CubridNodeType.SHARD_FOLDER.equals(type) && !CubridNodeType.SERVER.equals(type)) {
return;
}
synchronized (this) {
if (StringUtil.isEqual(type, NodeType.SERVER)) {
String id = eventNode.getId();
CubridShardFolder currentNode = (CubridShardFolder) eventNode.getChild(id);
this.cubridNode = currentNode;
} else {
this.cubridNode = eventNode;
}
if (this.cubridNode == null || !((CubridShardFolder) eventNode).isRunning()) {
setRunflag(false);
this.setTitleImage(CubridManagerUIPlugin.getImage("icons/navigator/broker_group.png"));
return;
} else {
setRunflag(true);
this.setTitleImage(CubridManagerUIPlugin.getImage("icons/navigator/broker_service_started.png"));
}
refresh();
}
}
use of com.cubrid.cubridmanager.ui.spi.model.CubridShardFolder 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));
}
}
Aggregations