use of com.cubrid.cubridmanager.core.broker.model.BrokerInfos in project cubrid-manager by CUBRID.
the class ServiceDashboardEditor method loadServerBrokerInfo.
/**
* Load Server Broker Info
*/
private void loadServerBrokerInfo(final ServerInfo serverInfo, final String key) {
final CommonQueryTask<BrokerInfos> task = new CommonQueryTask<BrokerInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), new BrokerInfos());
TaskJobExecutor taskJobExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {
public void completeAll() {
Object input = serviceTreeViewer.getInput();
ServiceDashboardInfo sDashInfo = getSelectedDashInfo(input, serverInfo.getServerName(), key);
BrokerInfos brokerInfos = task.getResultModel();
setBrokerData(sDashInfo, brokerInfos);
serviceTreeViewer.refresh(input);
}
public IStatus postTaskFinished(ITask task) {
return Status.OK_STATUS;
}
});
taskJobExec.addTask(task);
executeTask(taskJobExec, serverInfo.getServerName(), Messages.taskGetServerBrokerInfo);
}
use of com.cubrid.cubridmanager.core.broker.model.BrokerInfos in project cubrid-manager by CUBRID.
the class BrokerStatusView method initValue.
/**
* Initializes the parameters of this view
*/
public void initValue() {
if (null == getCubridNode() || !CubridNodeType.BROKER.equals(getCubridNode().getType())) {
return;
}
brokerNode = (CubridBroker) getCubridNode();
nodeName = brokerNode.getLabel().trim();
serverName = brokerNode.getServer().getLabel();
port = brokerNode.getServer().getMonPort();
ServerInfo serverInfo = brokerNode.getServer().getServerInfo();
//get basic info
BrokerInfos brokerInfos = new BrokerInfos();
//brokerInfos.setBname(nodeName);
final GetBrokerStatusInfosTask<BrokerInfos> basicTask = new GetBrokerStatusInfosTask<BrokerInfos>(serverInfo, CommonSendMsg.getGetBrokerStatusItems(), brokerInfos);
basicTask.setBrokerName(nodeName);
//get status
BrokerStatusInfos brokerStatusInfos = new BrokerStatusInfos();
final GetBrokerStatusInfosTask<BrokerStatusInfos> statisTask = new GetBrokerStatusInfosTask<BrokerStatusInfos>(serverInfo, CommonSendMsg.getGetBrokerStatusItems(), brokerStatusInfos);
statisTask.setBrokerName(nodeName);
TaskExecutor taskExecutor = new CommonTaskExec(Messages.showBrokerStatusTaskName);
taskExecutor.addTask(basicTask);
taskExecutor.addTask(statisTask);
new ExecTaskWithProgress(taskExecutor).exec();
if (!taskExecutor.isSuccess()) {
return;
}
brokerInfos = basicTask.getResultModel();
if (null != brokerInfos) {
BrokerInfoList list = brokerInfos.getBorkerInfoList();
if (list != null && list.getBrokerInfoList() != null) {
basicInfoLst = list.getBrokerInfoList();
}
}
brokerStatusInfos = statisTask.getResultModel();
if (brokerStatusInfos != null) {
asinfoLst = brokerStatusInfos.getAsinfo();
jobinfoLst = brokerStatusInfos.getJobinfo();
}
}
use of com.cubrid.cubridmanager.core.broker.model.BrokerInfos in project cubrid-manager by CUBRID.
the class BrokerStatusView method refreshBasicTable.
/**
* refresh the basic info table viewer
*
* @param serverInfo the instance of ServerInfo
*/
private void refreshBasicTable(ServerInfo serverInfo) {
BrokerInfos brokerInfos = new BrokerInfos();
final GetBrokerStatusInfosTask<BrokerInfos> basicTask = new GetBrokerStatusInfosTask<BrokerInfos>(serverInfo, CommonSendMsg.getGetBrokerStatusItems(), brokerInfos);
basicTask.setBrokerName(nodeName);
basicTask.execute();
brokerInfos = basicTask.getResultModel();
if (null != brokerInfos) {
BrokerInfoList list = brokerInfos.getBorkerInfoList();
if (list != null && list.getBrokerInfoList() != null) {
basicInfoLst = list.getBrokerInfoList();
}
}
if (basicTableViewer != null) {
basicTableViewer.setInput(basicInfoLst);
basicTableViewer.refresh();
}
}
use of com.cubrid.cubridmanager.core.broker.model.BrokerInfos 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.BrokerInfos 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