use of com.cubrid.cubridmanager.core.broker.model.BrokerInfos in project cubrid-manager by CUBRID.
the class BrokerEnvStatusView method refresh.
/**
* Refreshes this view
*
* @param isUpdateTable whether update table
* @param isRefreshChanged whether refresh changed
*
*/
public void refresh(boolean isUpdateTable, boolean isRefreshChanged) {
ServerInfo site = cubridNode.getServer().getServerInfo();
BrokerInfos brokerInfos = new BrokerInfos();
final CommonQueryTask<BrokerInfos> task = new CommonQueryTask<BrokerInfos>(site, CommonSendMsg.getCommonSimpleSendMsg(), brokerInfos);
task.execute();
brokerInfos = task.getResultModel();
List<BrokerInfo> newBrokerInfoList = null;
if (null != brokerInfos) {
BrokerInfoList list = brokerInfos.getBorkerInfoList();
if (list != null && list.getBrokerInfoList() != null) {
newBrokerInfoList = list.getBrokerInfoList();
}
}
List<BrokerInfo> changedBrokerInfoList = new ArrayList<BrokerInfo>();
for (int i = 0; newBrokerInfoList != null && i < newBrokerInfoList.size(); i++) {
BrokerInfo newBrokerInfo = newBrokerInfoList.get(i);
BrokerInfo changedBrokerInfo = newBrokerInfo.clone();
for (int j = 0; oldBrokerInfoList != null && j < oldBrokerInfoList.size(); j++) {
BrokerInfo oldBrokerInfo = oldBrokerInfoList.get(j);
if (newBrokerInfo.getName().equalsIgnoreCase(oldBrokerInfo.getName())) {
// FIXME more simple
long newTran = StringUtil.intValue(newBrokerInfo.getTran());
long newQuery = StringUtil.intValue(newBrokerInfo.getQuery());
long newLongTran = StringUtil.longValue(newBrokerInfo.getLong_tran());
long newLongQuery = StringUtil.longValue(newBrokerInfo.getLong_query());
long newErrQuery = StringUtil.intValue(newBrokerInfo.getError_query());
long oldTran = StringUtil.intValue(oldBrokerInfo.getTran());
long oldQuery = StringUtil.intValue(oldBrokerInfo.getQuery());
long oldLongTran = StringUtil.longValue(oldBrokerInfo.getLong_tran());
long oldLongQuery = StringUtil.longValue(oldBrokerInfo.getLong_query());
long oldErrQuery = StringUtil.intValue(oldBrokerInfo.getError_query());
long changedTran = newTran - oldTran;
long changedQuery = newQuery - oldQuery;
long changedLongTran = newLongTran - oldLongTran;
long changedLongQuery = newLongQuery - oldLongQuery;
long changedErrQuery = newErrQuery - oldErrQuery;
changedBrokerInfo.setTran(String.valueOf(changedTran > 0 ? changedTran : 0));
changedBrokerInfo.setQuery(String.valueOf(changedQuery > 0 ? changedQuery : 0));
changedBrokerInfo.setLong_tran(String.valueOf(changedLongTran > 0 ? changedLongTran : 0));
changedBrokerInfo.setLong_query(String.valueOf(changedLongQuery > 0 ? changedLongQuery : 0));
changedBrokerInfo.setError_query(String.valueOf(changedErrQuery > 0 ? changedErrQuery : 0));
break;
}
}
changedBrokerInfoList.add(changedBrokerInfo);
}
oldBrokerInfoList = newBrokerInfoList;
if (isUpdateTable) {
if (isRefreshChanged) {
tableViewer.setInput(changedBrokerInfoList);
} else {
tableViewer.setInput(oldBrokerInfoList);
}
tableViewer.refresh();
}
}
use of com.cubrid.cubridmanager.core.broker.model.BrokerInfos in project cubrid-manager by CUBRID.
the class ExecuteSqlLogAction method run.
/**
* Open dialog
*/
public void run() {
Object[] obj = this.getSelectedObj();
DefaultCubridNode node = null;
LogInfo logInfo = null;
node = (DefaultCubridNode) obj[0];
String targetBroker = node.getParent().getParent().getLabel();
logInfo = (LogInfo) node.getAdapter(LogInfo.class);
List<String> allDatabaseList = node.getServer().getServerInfo().getAllDatabaseList();
BrokerInfos brokerInfos = node.getServer().getServerInfo().getBrokerInfos();
CasRunnerConfigDialog casRunnerConfigDialog = new CasRunnerConfigDialog(getShell());
casRunnerConfigDialog.setBrokerInfos(brokerInfos);
casRunnerConfigDialog.setAllDatabaseList(allDatabaseList);
casRunnerConfigDialog.setLogInfo(logInfo);
casRunnerConfigDialog.setTargetBroker(targetBroker);
casRunnerConfigDialog.setExecwithFile(true);
casRunnerConfigDialog.create();
if (casRunnerConfigDialog.open() == Dialog.OK) {
final GetExecuteCasRunnerResultTask task = new GetExecuteCasRunnerResultTask(((DefaultCubridNode) obj[0]).getServer().getServerInfo());
task.setBrokerName(CasRunnerConfigDialog.getBrokerName());
task.setUserName(CasRunnerConfigDialog.getUserName());
task.setPasswd(CasRunnerConfigDialog.getPassword());
task.setNumThread(CasRunnerConfigDialog.getNumThread());
task.setRepeatCount(casRunnerConfigDialog.getNumRepeatCount());
String isShowqueryresult = "";
if (casRunnerConfigDialog.isShowqueryresult()) {
isShowqueryresult = "yes";
} else {
isShowqueryresult = "no";
}
task.setShowQueryResult(isShowqueryresult);
String isShowqueryplan = "";
if (casRunnerConfigDialog.isShowqueryplan()) {
isShowqueryplan = "yes";
} else {
isShowqueryplan = "no";
}
task.setShowQueryResult(isShowqueryplan);
task.setDbName(CasRunnerConfigDialog.getDbname());
task.setExecuteLogFile("yes");
task.setLogFile(logInfo.getPath());
TaskExecutor taskExcutor = new CommonTaskExec(Messages.loadSqlLogExecResultTaskName);
taskExcutor.addTask(task);
new ExecTaskWithProgress(taskExcutor).exec();
if (!taskExcutor.isSuccess()) {
return;
}
GetExecuteCasRunnerResultInfo getExecuteCasRunnerResultInfo = (GetExecuteCasRunnerResultInfo) task.getContent();
StringBuffer result = new StringBuffer("");
if (getExecuteCasRunnerResultInfo.getResult() != null) {
for (int i = 0, n = getExecuteCasRunnerResultInfo.getResult().size(); i < n; i++) {
result.append(getExecuteCasRunnerResultInfo.getResult().get(i) + "\n");
}
}
CasRunnerResultDialog casRunnerResultDialog = new CasRunnerResultDialog(getShell());
casRunnerResultDialog.setResult(result);
casRunnerResultDialog.open();
}
}
use of com.cubrid.cubridmanager.core.broker.model.BrokerInfos in project cubrid-manager by CUBRID.
the class LoginQueryEditDialog method fillBrokerPortCombo.
/**
*
* Fill in the broker port combo
*
* @param serverName the server name
*/
private void fillBrokerPortCombo(String serverName) {
CubridServer cubridServer = serverMap.get(serverName);
BrokerInfos brokerInfos = cubridServer.getServerInfo().getBrokerInfos();
if (brokerInfos != null && brokerInfos.getBorkerInfoList() != null && brokerInfos.getBorkerInfoList().getBrokerInfoList() != null) {
List<BrokerInfo> brokerList = brokerInfos.getBorkerInfoList().getBrokerInfoList();
Combo brokerPortCombo = connectionComp.getBrokerPortCombo();
brokerPortCombo.removeAll();
for (int i = 0; i < brokerList.size(); i++) {
brokerPortCombo.add(brokerList.get(i).getPort());
}
if (!brokerList.isEmpty()) {
brokerPortCombo.select(0);
}
}
}
use of com.cubrid.cubridmanager.core.broker.model.BrokerInfos in project cubrid-manager by CUBRID.
the class UserAuthDbInfoPage method initialBrokerPorts.
/**
*
* Initial the broker ports
*
* @param brokerIp String
*
*/
private void initialBrokerPorts(String brokerIp) {
String ip = server.getHostAddress();
if (!ip.equals(brokerIp)) {
allBrokerPorts = null;
return;
}
BrokerInfos brokerInfos = server.getServerInfo().getBrokerInfos();
if (brokerInfos != null) {
String brokerStauts = brokerInfos.getBrokerstatus();
BrokerInfoList brokerInfo = brokerInfos.getBorkerInfoList();
if (brokerInfo != null) {
List<BrokerInfo> brokerInfoList = brokerInfo.getBrokerInfoList();
if (brokerInfoList != null) {
List<String> brokerPortList = new ArrayList<String>();
for (int i = 0; i < brokerInfoList.size(); i++) {
BrokerInfo info = brokerInfoList.get(i);
if (info.getPort() == null || info.getPort().trim().length() == 0) {
continue;
}
String port = info.getPort();
String status = "";
if (brokerStauts == null || !brokerStauts.equalsIgnoreCase("ON")) {
status = "OFF";
} else {
status = info.getState() == null || info.getState().trim().equalsIgnoreCase("OFF") ? "OFF" : "ON";
}
brokerPortList.add(info.getName() + "[" + port + "/" + status + "]");
}
if (!brokerPortList.isEmpty()) {
allBrokerPorts = new String[brokerPortList.size()];
brokerPortList.toArray(allBrokerPorts);
}
}
}
}
}
use of com.cubrid.cubridmanager.core.broker.model.BrokerInfos 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;
}
Aggregations