use of com.cubrid.cubridmanager.core.broker.model.BrokerInfo 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.core.broker.model.BrokerInfo in project cubrid-manager by CUBRID.
the class CubridDatabasesFolderLoader method getDefaultPort.
/**
*
* Get default port
*
* @param serverInfo ServerInfo
* @return String
*/
private static String getDefaultPort(ServerInfo serverInfo) {
// FIXME extract
String defaultBrokerPort = "30000";
BrokerInfos brokerInfos = serverInfo.getBrokerInfos();
if (brokerInfos != null) {
BrokerInfoList brokerInfoList = brokerInfos.getBorkerInfoList();
if (brokerInfoList != null) {
List<BrokerInfo> list = brokerInfoList.getBrokerInfoList();
for (int i = 0; list != null && i < list.size(); i++) {
BrokerInfo brokerInfo = list.get(i);
if (i == 0) {
defaultBrokerPort = brokerInfo.getPort();
}
if (brokerInfo.getName().equals("query_editor")) {
defaultBrokerPort = brokerInfo.getPort();
break;
}
}
}
}
return defaultBrokerPort;
}
use of com.cubrid.cubridmanager.core.broker.model.BrokerInfo 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.cubridmanager.core.broker.model.BrokerInfo in project cubrid-manager by CUBRID.
the class DBSpaceLabelProvider method run.
/**
* Thread run method
*/
public void run() {
int sleepTime = smallSpaceTime;
long startTime = System.currentTimeMillis();
while (runFlag) {
// It should be stopped when it have exceed 5 minutes because of server load
if (System.currentTimeMillis() - startTime > timeout) {
break;
}
getUpdateValue(startRun);
if (startRun == 0) {
startRun++;
continue;
}
if (startRun < 15) {
startRun++;
} else {
sleepTime = bigSpaceTime;
}
HostStatus hostStatus = new HostStatus();
hostStatus.setCpu(StringUtil.doubleValue(hostStatDataProxy.getUserPercent(), 0));
hostStatus.setMemoryUsed(StringUtil.doubleValue(hostStatDataProxy.getMemPhyUsed(), 0));
hostStatus.setMemoryPhy(StringUtil.doubleValue(hostStatDataProxy.getMemPhyTotal(), 0));
task.execute();
BrokerInfos brokerInfos = task.getResultModel();
double qps = 0;
double tps = 0;
List<BrokerInfo> newBrokerInfoList = null;
if (null != brokerInfos) {
BrokerInfoList list = brokerInfos.getBorkerInfoList();
if (list != null && list.getBrokerInfoList() != null) {
newBrokerInfoList = list.getBrokerInfoList();
}
}
if (newBrokerInfoList != null) {
for (BrokerInfo brokerInfo : newBrokerInfoList) {
tps += StringUtil.doubleValue(brokerInfo.getTran(), 0);
qps += StringUtil.doubleValue(brokerInfo.getQuery(), 0);
}
}
hostStatus.setTps(tps);
hostStatus.setQps(qps);
hostDataManager.addData(hostStatus);
final List<HostStatus> serverDataList = new ArrayList<HostStatus>();
HostStatus hostStatusNow = new HostStatus();
hostStatusNow.setLabel(Messages.lblNow);
hostStatusNow.setMemoryUsed(1.0d * hostDataManager.getMemeryUsed());
hostStatusNow.setMemoryPhy(1.0d * hostDataManager.getMemoryPhy());
hostStatusNow.setCpu(hostDataManager.getCpu());
hostStatusNow.setQps(hostDataManager.getQps());
hostStatusNow.setTps(hostDataManager.getTps());
hostStatusNow.setFreespaceOnStorage(editorPart.getFreespaceOnStorage());
serverDataList.add(hostStatusNow);
HostStatus hostStatusAvg = new HostStatus();
hostStatusAvg.setLabel(Messages.lbl5MinAvg);
hostStatusAvg.setMemoryUsed(hostDataManager.getAvgMemeryUsed());
hostStatusAvg.setMemoryPhy(1.0d * hostDataManager.getMemoryPhy());
hostStatusAvg.setCpu(hostDataManager.getAvgCpu());
hostStatusAvg.setQps(hostDataManager.getAvgQps());
hostStatusAvg.setTps(hostDataManager.getAvgTps());
hostStatusAvg.setFreespaceOnStorage(-1);
serverDataList.add(hostStatusAvg);
Display.getDefault().syncExec(new Runnable() {
public void run() {
if (editorPart.getServerTableViewer() != null && !editorPart.getServerTableViewer().getTable().isDisposed()) {
editorPart.getServerTableViewer().setInput(serverDataList);
editorPart.getServerTableViewer().refresh();
}
}
});
try {
Thread.sleep(sleepTime);
} catch (Exception e) {
}
}
}
use of com.cubrid.cubridmanager.core.broker.model.BrokerInfo in project cubrid-manager by CUBRID.
the class CubridStatusLineContrItem method updateStatusLine.
/**
*
* Update the status line information
*
* @param statusLineManager StatusLineManager
* @param cubridNode The selected ICubridNode object
*/
protected void updateStatusLine(StatusLineManager statusLineManager, ICubridNode cubridNode) {
clearStatusLine();
updateStatusLineForRestoreQueryEditor();
if (cubridNode == null || cubridNode.getServer() == null || cubridNode.getServer().getServerInfo() == null) {
return;
}
String serverInfoStr = cubridNode.getServer().getLabel();
if (!DatabaseNavigatorMenu.SELF_DATABASE_ID.equals(cubridNode.getId())) {
ServerUserInfo userInfo = cubridNode.getServer().getServerInfo().getLoginedUserInfo();
if (userInfo != null && userInfo.getUserName() != null && userInfo.getUserName().trim().length() > 0) {
serverInfoStr = userInfo.getUserName() + "@" + serverInfoStr;
}
String monPort = cubridNode.getServer().getMonPort();
if (monPort != null && monPort.trim().length() > 0) {
serverInfoStr = serverInfoStr + ":" + monPort;
}
}
StringBuffer dbInfoStrBuffer = new StringBuffer();
if (cubridNode instanceof ISchemaNode) {
ISchemaNode schemaNode = (ISchemaNode) cubridNode;
CubridDatabase database = schemaNode.getDatabase();
dbInfoStrBuffer.append(database.getDatabaseInfo().getDbName());
DbUserInfo dbUserInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
if (database.isLogined() && dbUserInfo != null && dbUserInfo.getName() != null && dbUserInfo.getName().trim().length() > 0) {
dbInfoStrBuffer = new StringBuffer(dbUserInfo.getName() + "@" + dbInfoStrBuffer.toString());
}
String brokerPort = QueryOptions.getBrokerPort(database.getDatabaseInfo());
BrokerInfos brokerInfos = database.getServer().getServerInfo().getBrokerInfos();
List<BrokerInfo> brokerInfoList = brokerInfos == null || brokerInfos.getBorkerInfoList() == null ? null : brokerInfos.getBorkerInfoList().getBrokerInfoList();
boolean isExist = false;
for (int i = 0; brokerInfoList != null && i < brokerInfoList.size(); i++) {
BrokerInfo brokerInfo = brokerInfoList.get(i);
if (brokerPort == null || brokerInfo.getPort() == null || brokerInfo.getPort().trim().length() == 0 || !brokerPort.equals(brokerInfo.getPort())) {
continue;
}
if (brokerPort.equals(brokerInfo.getPort())) {
isExist = true;
String status = brokerInfo.getState() == null || brokerInfo.getState().trim().equalsIgnoreCase("OFF") ? "OFF" : "ON";
String text = brokerInfo.getName() + "[" + brokerInfo.getPort() + "/" + status + "]";
dbInfoStrBuffer.append(":").append(text);
break;
}
}
if (!isExist && brokerPort != null && brokerPort.trim().length() > 0) {
dbInfoStrBuffer.append(":").append(brokerPort);
}
String charset = database.getDatabaseInfo().getCharSet();
if (charset != null && charset.trim().length() > 0) {
dbInfoStrBuffer.append(":charset=").append(charset);
}
}
String numberStr = getChilderenNumStr(cubridNode);
if (numberStr != null && numberStr.length() > 0) {
StatusLineContributionItem item = new StatusLineContributionItem(OBJ_NUM_INFO_CONTR_ID, numberStr.length() + 4);
statusLineManager.add(item);
item.setText(numberStr);
}
int addedWidth = 3;
if (dbInfoStrBuffer == null || dbInfoStrBuffer.length() == 0) {
addedWidth = 30;
}
StatusLineContributionItem item = new StatusLineContributionItem(SERVER_INFO_CONTR_ID, serverInfoStr.length() + addedWidth);
statusLineManager.add(item);
item.setText(serverInfoStr);
if (dbInfoStrBuffer != null && dbInfoStrBuffer.length() > 0) {
item = new StatusLineContributionItem(DB_INFO_CONTR_ID, dbInfoStrBuffer.length() + 3);
statusLineManager.add(item);
item.setText(dbInfoStrBuffer.toString());
}
}
Aggregations