use of com.cubrid.common.ui.spi.model.DefaultCubridNode in project cubrid-manager by CUBRID.
the class CubridBrokerLogFolderLoader 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;
}
// add access and error and admin log folder to broker logs folder
String[] brokerLogIdArr = { ACCESS_LOG_FOLDER_ID, ERROR_LOG_FOLDER_ID, ADMIN_LOG_FOLDER_ID };
String[] brokerLogNameArr = { ACCESS_LOG_FOLDER_NAME, ERROR_LOG_FOLDER_NAME, ADMIN_LOG_FOLDER_NAME };
String[] brokerLogTypeArr = { CubridNodeType.LOGS_BROKER_ACCESS_LOG_FOLDER, CubridNodeType.LOGS_BROKER_ERROR_LOG_FOLDER, CubridNodeType.LOGS_BROKER_ADMIN_LOG_FOLDER };
String[] iconArr = { "icons/navigator/folder.png", "icons/navigator/folder.png", "icons/navigator/folder.png" };
ICubridNode[] logFoldrNodeArr = new ICubridNode[3];
for (int i = 0; i < brokerLogNameArr.length; i++) {
String id = parent.getId() + NODE_SEPARATOR + brokerLogIdArr[i];
logFoldrNodeArr[i] = parent.getChild(id);
if (logFoldrNodeArr[i] == null) {
logFoldrNodeArr[i] = new DefaultCubridNode(id, brokerLogNameArr[i], iconArr[i]);
logFoldrNodeArr[i].setType(brokerLogTypeArr[i]);
logFoldrNodeArr[i].setContainer(true);
parent.addChild(logFoldrNodeArr[i]);
if (i == 2) {
ICubridNodeLoader loader = new CubridAdminLogFolderLoader();
loader.setLevel(getLevel());
logFoldrNodeArr[i].setLoader(loader);
if (getLevel() == DEFINITE_LEVEL) {
logFoldrNodeArr[i].getChildren(monitor);
}
}
} else {
if (logFoldrNodeArr[i].getLoader() != null) {
logFoldrNodeArr[i].getLoader().setLoaded(false);
logFoldrNodeArr[i].getChildren(monitor);
}
}
}
ServerInfo serverInfo = parent.getServer().getServerInfo();
BrokerInfos brokerInfos = serverInfo.getBrokerInfos();
Shards shards = serverInfo.getShards();
monitorCancel(monitor, new ITask[] { loadBrokersTask, loadBrokrLogInfoTask });
if (brokerInfos == null && !monitor.isCanceled()) {
// load all borkers
brokerInfos = new BrokerInfos();
loadBrokersTask = new CommonQueryTask<BrokerInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), brokerInfos);
loadBrokersTask.execute();
final String errorMsg = loadBrokersTask.getErrorMsg();
if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
logFoldrNodeArr[0].removeAllChild();
logFoldrNodeArr[1].removeAllChild();
openErrorBox(errorMsg);
setLoaded(true);
return;
}
brokerInfos = loadBrokersTask.getResultModel();
serverInfo.setBrokerInfos(brokerInfos);
}
if (monitor.isCanceled()) {
setLoaded(true);
return;
}
// load broker log file information
List<BrokerLogInfos> brokerLogInfosList = new ArrayList<BrokerLogInfos>();
if (brokerInfos != null) {
BrokerInfoList list = brokerInfos.getBorkerInfoList();
if (list != null && list.getBrokerInfoList() != null) {
List<BrokerInfo> brokerInfoList = list.getBrokerInfoList();
for (int i = 0; !monitor.isCanceled() && brokerInfoList != null && i < brokerInfoList.size(); i++) {
BrokerInfo brokerInfo = brokerInfoList.get(i);
BrokerLogInfos brokerLogInfos = new BrokerLogInfos();
loadBrokrLogInfoTask = new CommonQueryTask<BrokerLogInfos>(serverInfo, CommonSendMsg.getGetBrokerLogFileInfoMSGItems(), brokerLogInfos);
loadBrokrLogInfoTask.setBroker(brokerInfo.getName());
loadBrokrLogInfoTask.execute();
final String errorMsg = loadBrokrLogInfoTask.getErrorMsg();
if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
logFoldrNodeArr[0].removeAllChild();
logFoldrNodeArr[1].removeAllChild();
openErrorBox(errorMsg);
setLoaded(true);
return;
}
brokerLogInfos = loadBrokrLogInfoTask.getResultModel();
brokerLogInfosList.add(brokerLogInfos);
}
}
}
// load shard broker log file information
if (shards != null) {
List<Shard> shardList = shards.getShardList();
if (shardList != null) {
for (int i = 0; i < shardList.size(); i++) {
Shard shard = shardList.get(i);
BrokerLogInfos brokerLogInfos = new BrokerLogInfos();
loadBrokrLogInfoTask = new CommonQueryTask<BrokerLogInfos>(serverInfo, CommonSendMsg.getGetBrokerLogFileInfoMSGItems(), brokerLogInfos);
loadBrokrLogInfoTask.setBroker(shard.getName());
loadBrokrLogInfoTask.execute();
final String errorMsg = loadBrokrLogInfoTask.getErrorMsg();
if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
logFoldrNodeArr[0].removeAllChild();
logFoldrNodeArr[1].removeAllChild();
openErrorBox(errorMsg);
setLoaded(true);
return;
}
brokerLogInfos = loadBrokrLogInfoTask.getResultModel();
brokerLogInfosList.add(brokerLogInfos);
}
}
}
if (monitor.isCanceled()) {
setLoaded(true);
return;
}
logFoldrNodeArr[0].removeAllChild();
logFoldrNodeArr[1].removeAllChild();
for (BrokerLogInfos brokerLogInfos : brokerLogInfosList) {
List<LogInfo> logInfoList = brokerLogInfos.getBrokerLogInfoList().getLogFileInfoList();
if (logInfoList != null && !logInfoList.isEmpty()) {
for (LogInfo logInfo : logInfoList) {
ICubridNode logInfoNode = new DefaultCubridNode("", logInfo.getName(), "");
logInfoNode.setContainer(false);
logInfoNode.setModelObj(logInfo);
logInfoNode.setEditorId(LogEditorPart.ID);
if (LogType.ACCESS.getText().toLowerCase().equals(logInfo.getType())) {
String id = logFoldrNodeArr[0].getId() + NODE_SEPARATOR + logInfo.getName();
logInfoNode.setId(id);
logInfoNode.setType(CubridNodeType.LOGS_BROKER_ACCESS_LOG);
logInfoNode.setIconPath("icons/navigator/log_item.png");
logFoldrNodeArr[0].addChild(logInfoNode);
} else if (LogType.ERROR.getText().toLowerCase().equals(logInfo.getType())) {
String id = logFoldrNodeArr[1].getId() + NODE_SEPARATOR + logInfo.getName();
logInfoNode.setId(id);
logInfoNode.setType(CubridNodeType.LOGS_BROKER_ERROR_LOG);
logInfoNode.setIconPath("icons/navigator/log_item.png");
logFoldrNodeArr[1].addChild(logInfoNode);
}
}
}
}
Collections.sort(logFoldrNodeArr[0].getChildren());
Collections.sort(logFoldrNodeArr[1].getChildren());
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(logFoldrNodeArr[0], CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(logFoldrNodeArr[1], CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of com.cubrid.common.ui.spi.model.DefaultCubridNode in project cubrid-manager by CUBRID.
the class CubridDatabaseLogFolderLoader 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();
List<DatabaseInfo> databaseInfoList = userInfo.getDatabaseInfoList();
if (databaseInfoList == null || databaseInfoList.size() <= 0) {
setLoaded(true);
return;
}
if (monitor.isCanceled()) {
setLoaded(true);
return;
}
List<ICubridNode> oldNodeList = new ArrayList<ICubridNode>();
oldNodeList.addAll(parent.getChildren());
parent.removeAllChild();
for (int i = 0; i < databaseInfoList.size() && !monitor.isCanceled(); i++) {
DatabaseInfo databaseInfo = databaseInfoList.get(i);
String id = parent.getId() + NODE_SEPARATOR + databaseInfo.getDbName();
ICubridNode logDatabaseNode = isContained(oldNodeList, id);
if (logDatabaseNode == null) {
logDatabaseNode = new DefaultCubridNode(id, databaseInfo.getDbName(), "icons/navigator/folder.png");
logDatabaseNode.setType(CubridNodeType.LOGS_SERVER_DATABASE_FOLDER);
logDatabaseNode.setModelObj(databaseInfo);
logDatabaseNode.setContainer(true);
ICubridNodeLoader loader = new CubridDatabaseLogLoader();
loader.setLevel(getLevel());
logDatabaseNode.setLoader(loader);
parent.addChild(logDatabaseNode);
if (getLevel() == DEFINITE_LEVEL) {
logDatabaseNode.getChildren(monitor);
}
} else {
parent.addChild(logDatabaseNode);
if (logDatabaseNode.getLoader() != null && logDatabaseNode.getLoader().isLoaded()) {
logDatabaseNode.getLoader().setLoaded(false);
logDatabaseNode.getChildren(monitor);
}
}
}
Collections.sort(parent.getChildren());
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of com.cubrid.common.ui.spi.model.DefaultCubridNode in project cubrid-manager by CUBRID.
the class CubridBrokerFolderLoader method load.
/**
*
* Load children object for parent
*
* @param parent the parent node
* @param monitor the IProgressMonitor object
*/
public void load(final ICubridNode parent, final IProgressMonitor monitor) {
synchronized (this) {
if (isLoaded()) {
return;
}
//when refresh broker,firstly check whether this broker exist
int ret = checkBrokerExist(parent, monitor);
if (ret == 1 || ret == 2) {
setLoaded(true);
return;
}
if (ret != 0) {
Display display = Display.getDefault();
display.syncExec(new Runnable() {
public void run() {
CommonUITool.openErrorBox(Messages.errBrokerNoExist);
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
TreeViewer treeViewer = navigatorView == null ? null : navigatorView.getViewer();
if (treeViewer != null) {
CommonUITool.refreshNavigatorTree(treeViewer, parent.getParent());
}
}
});
setLoaded(true);
return;
}
// add sql log folder
String sqlLogFolderId = parent.getId() + NODE_SEPARATOR + SQL_LOG_FOLDER_ID;
ICubridNode sqlLogFolder = parent.getChild(sqlLogFolderId);
if (sqlLogFolder == null) {
sqlLogFolder = new DefaultCubridNode(sqlLogFolderId, SQL_LOG_FOLDER_NAME, "icons/navigator/folder.png");
sqlLogFolder.setType(CubridNodeType.BROKER_SQL_LOG_FOLDER);
sqlLogFolder.setContainer(true);
parent.addChild(sqlLogFolder);
}
//add the children of sql log folder
ServerInfo serverInfo = parent.getServer().getServerInfo();
BrokerLogInfos brokerLogInfos = new BrokerLogInfos();
final CommonQueryTask<BrokerLogInfos> task = new CommonQueryTask<BrokerLogInfos>(serverInfo, CommonSendMsg.getGetBrokerLogFileInfoMSGItems(), brokerLogInfos);
task.setBroker(parent.getLabel());
monitorCancel(monitor, new ITask[] { task });
task.execute();
final String errorMsg = task.getErrorMsg();
if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
sqlLogFolder.removeAllChild();
openErrorBox(errorMsg);
setLoaded(true);
return;
}
if (monitor.isCanceled()) {
setLoaded(true);
return;
}
sqlLogFolder.removeAllChild();
brokerLogInfos = task.getResultModel();
List<LogInfo> logInfoList = brokerLogInfos == null ? null : brokerLogInfos.getBrokerLogInfoList().getLogFileInfoList();
if (logInfoList != null && !logInfoList.isEmpty()) {
for (LogInfo logInfo : logInfoList) {
String id = sqlLogFolder.getId() + NODE_SEPARATOR + logInfo.getName();
ICubridNode logInfoNode = new DefaultCubridNode(id, logInfo.getName(), "icons/navigator/sqllog_item.png");
logInfoNode.setContainer(false);
logInfoNode.setEditorId(LogEditorPart.ID);
logInfoNode.setModelObj(logInfo);
if (LogType.SCRIPT.getText().toLowerCase().equals(logInfo.getType())) {
logInfoNode.setType(CubridNodeType.BROKER_SQL_LOG);
sqlLogFolder.addChild(logInfoNode);
}
}
}
Collections.sort(sqlLogFolder.getChildren());
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of com.cubrid.common.ui.spi.model.DefaultCubridNode in project cubrid-manager by CUBRID.
the class CubridSystemMonitorFolderLoader 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 || StatusMonitorAuthType.AUTH_NONE == userInfo.getStatusMonitorAuth()) {
parent.removeAllChild();
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
return;
}
String hostSystemId = parent.getId() + NODE_SEPARATOR + HOST_SYSTEM_ID;
ICubridNode hostSystemNode = new DefaultCubridNode(hostSystemId, Messages.msgHostSystemMonitorName, "icons/navigator/status_item.png");
hostSystemNode.setType(CubridNodeType.SYSTEM_MONITOR_TEMPLATE);
hostSystemNode.setViewId(HostSystemMonitorViewPart.ID);
hostSystemNode.setContainer(false);
parent.addChild(hostSystemNode);
if (CompatibleUtil.isSupportDBSystemMonitor(serverInfo)) {
String dbSystemId = parent.getId() + NODE_SEPARATOR + DB_SYSTEM_ID;
ICubridNode dbSystemNode = new DefaultCubridNode(dbSystemId, Messages.msgDbSystemMonitorName, "icons/navigator/status_item.png");
dbSystemNode.setType(CubridNodeType.SYSTEM_MONITOR_TEMPLATE);
dbSystemNode.setViewId(DbSystemMonitorViewPart.ID);
dbSystemNode.setContainer(false);
parent.addChild(dbSystemNode);
}
}
Collections.sort(parent.getChildren());
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
use of com.cubrid.common.ui.spi.model.DefaultCubridNode in project cubrid-manager by CUBRID.
the class CubridMonitorFolderLoader 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 || StatusMonitorAuthType.AUTH_NONE == userInfo.getStatusMonitorAuth()) {
parent.removeAllChild();
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
return;
}
//add status node
if (CompatibleUtil.isSupportBrokerOrDBStatusMonitor(serverInfo)) {
String brokerStatusId = parent.getId() + NODE_SEPARATOR + BROKER_STATUS_ID;
ICubridNode brokerStatusNode = new DefaultCubridNode(brokerStatusId, Messages.msgBrokerStatusMonitorName, "icons/navigator/status_item.png");
brokerStatusNode.setType(CubridNodeType.STATUS_MONITOR_TEMPLATE);
brokerStatusNode.setViewId(BrokerStatusMonitorViewPart.ID);
brokerStatusNode.setContainer(false);
parent.addChild(brokerStatusNode);
String dbStatusId = parent.getId() + NODE_SEPARATOR + DB_STATUS_ID;
ICubridNode dbStautsNode = new DefaultCubridNode(dbStatusId, Messages.msgDbStatusMonitorName, "icons/navigator/status_item.png");
dbStautsNode.setType(CubridNodeType.STATUS_MONITOR_TEMPLATE);
dbStautsNode.setViewId(DbStatusDumpMonitorViewPart.ID);
dbStautsNode.setContainer(false);
parent.addChild(dbStautsNode);
createTempStatusNode(parent);
} else {
if (!loadStatusTempInfoTask(parent, monitor, serverInfo)) {
return;
}
}
//add system node
if (CompatibleUtil.isSupportSystemMonitor(serverInfo)) {
String hostSystemId = parent.getId() + NODE_SEPARATOR + HOST_SYSTEM_ID;
ICubridNode hostSystemNode = new DefaultCubridNode(hostSystemId, Messages.msgHostSystemMonitorName, "icons/navigator/status_item.png");
hostSystemNode.setType(CubridNodeType.SYSTEM_MONITOR_TEMPLATE);
hostSystemNode.setViewId(HostSystemMonitorViewPart.ID);
hostSystemNode.setContainer(false);
parent.addChild(hostSystemNode);
if (CompatibleUtil.isSupportDBSystemMonitor(serverInfo)) {
String dbSystemId = parent.getId() + NODE_SEPARATOR + DB_SYSTEM_ID;
ICubridNode dbSystemNode = new DefaultCubridNode(dbSystemId, Messages.msgDbSystemMonitorName, "icons/navigator/status_item.png");
dbSystemNode.setType(CubridNodeType.SYSTEM_MONITOR_TEMPLATE);
dbSystemNode.setViewId(DbSystemMonitorViewPart.ID);
dbSystemNode.setContainer(false);
parent.addChild(dbSystemNode);
}
}
//add monitor statistic node
if (CompatibleUtil.isSupportMonitorStatistic(serverInfo)) {
List<MonitorStatistic> childList = MonitorStatisticPersistManager.getInstance().getMonitorStatisticListByHostId(serverInfo.getServerName());
for (MonitorStatistic node : childList) {
if (node == null) {
continue;
}
parent.addChild(node);
}
}
Collections.sort(parent.getChildren());
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
Aggregations