use of com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos 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.BrokerStatusInfos in project cubrid-manager by CUBRID.
the class BrokerNode method getAccessedHostDbMap.
/*public Set<String> getDbSet(){
Set<String> dbSet = new HashSet<String>();
for(BrokerStatusInfos bStatusInfos : brokerStatusMap.values()){
List<ApplyServerInfo> asInfoList = bStatusInfos.getAsinfo();
if(asInfoList == null){
continue;
}
for(ApplyServerInfo asInfo : asInfoList){
String dbHost = asInfo.getAs_dbhost();
String dbName = asInfo.getAs_dbname();
if(!StringUtil.isEmpty(dbName) && !isLocalHost(dbHost)){
dbSet.add(dbName);
}
}
}
return dbSet;
}*/
public Map<List<String>, Set<String>> getAccessedHostDbMap() {
List<DbLocationInfo> dbLocationInfoList = getDbLocationInfoList();
if (brokerStatusMap == null || brokerStatusMap.isEmpty() || dbLocationInfoList == null || dbLocationInfoList.isEmpty()) {
return null;
}
Map<List<String>, Set<String>> accessedHostDbMap = new HashMap<List<String>, Set<String>>();
for (BrokerStatusInfos bStatusInfos : brokerStatusMap.values()) {
List<ApplyServerInfo> asInfoList = bStatusInfos.getAsinfo();
if (asInfoList == null) {
continue;
}
for (ApplyServerInfo asInfo : asInfoList) {
String dbHost = asInfo.getAs_dbhost();
String dbName = asInfo.getAs_dbname();
if (StringUtil.isEmpty(dbName) || StringUtil.isEmpty(dbHost)) {
continue;
}
List<String> hostList = null;
if (CMServiceAnalysisUtil.isLocalHost(dbHost)) {
hostList = new ArrayList<String>();
hostList.add(BrokerNode.LOCALHOST);
} else {
for (DbLocationInfo dbLocalInfo : dbLocationInfoList) {
if (dbName.equals(dbLocalInfo.getDbName())) {
if (dbLocalInfo.findHost(dbHost)) {
hostList = dbLocalInfo.getDbHosts();
}
}
}
}
Set<String> dbSet = accessedHostDbMap.get(hostList);
if (dbSet != null) {
dbSet.add(dbName);
} else {
dbSet = new HashSet<String>();
dbSet.add(dbName);
accessedHostDbMap.put(hostList, dbSet);
}
}
}
return accessedHostDbMap;
}
use of com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos in project cubrid-manager by CUBRID.
the class BrokerNode method getAccessedHosts.
public Set<String> getAccessedHosts() {
if (brokerStatusMap == null || brokerStatusMap.isEmpty()) {
return null;
}
Set<String> accessedHosts = new HashSet<String>();
for (BrokerStatusInfos bStatusInfos : brokerStatusMap.values()) {
List<ApplyServerInfo> asInfoList = bStatusInfos.getAsinfo();
if (asInfoList == null) {
continue;
}
for (ApplyServerInfo asInfo : asInfoList) {
String dbHost = asInfo.getAs_dbhost();
if (StringUtil.isEmpty(dbHost) || CMServiceAnalysisUtil.isLocalHost(dbHost)) {
continue;
}
accessedHosts.add(dbHost);
}
}
return accessedHosts;
}
use of com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos in project cubrid-manager by CUBRID.
the class BrokerNodeTest method testBrokerNode.
public void testBrokerNode() {
BrokerNode brokerNode = new BrokerNode();
BrokerInfoList brokerInfoList = new BrokerInfoList();
brokerNode.setBrokerInfoList(brokerInfoList);
Map<String, BrokerStatusInfos> brokerStatusMap = new HashMap<String, BrokerStatusInfos>();
brokerNode.setBrokerStatusMap(brokerStatusMap);
assertEquals(brokerNode.getBrokerInfoList(), brokerInfoList);
assertEquals(brokerNode.getBrokerStatusMap(), brokerStatusMap);
brokerNode.setBrokerStatusMap(null);
assertNull(brokerNode.getBrokerStatusMap());
String port = "30000";
BrokerStatusInfos brokerStatusInfos = new BrokerStatusInfos();
brokerNode.addBrokerStatus(port, brokerStatusInfos);
assertNotNull(brokerNode.getBrokerStatusMap());
BrokerStatusInfos brokerStatusInfos2 = brokerNode.getBrokerStatusMap().get(port);
assertEquals(brokerStatusInfos, brokerStatusInfos2);
brokerNode.setRemoteBrokers(new HashSet<NodeInfo>());
brokerNode.AddRemoteBroker(new NodeInfo(NodeType.BROKER));
assertNull(brokerNode.getRemoteBrokers());
brokerNode.genBrokerInfo();
assertNotNull(brokerNode.getBrokerInfo());
assertNotNull(brokerNode.getStatus());
buildFakeData(brokerNode);
assertNotNull(brokerNode.getHostSet());
// assertNotNull(brokerNode.getDbSet());
assertNotNull(brokerNode.getAccessedHosts());
assertNotNull(brokerNode.getAccessedHostDbMap());
assertNotNull(brokerNode.getAccessedDbInfo());
}
use of com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos in project cubrid-manager by CUBRID.
the class DashboardConnectionManager method refreshBroker2DBConnections.
/**
* Refresh Broker to DB Connections
*
*/
public void refreshBroker2DBConnections() {
List<BrokerNode> allBrokerNode = dashboard.getAllBrokerNode();
for (BrokerNode broker : allBrokerNode) {
//create broker to db connections
BrokerStatusInfos brokerStatusInfos = broker.getBrokerStatusInfos();
List<DatabaseNode> dbList2Connect = new ArrayList<DatabaseNode>();
if (null != brokerStatusInfos && null != brokerStatusInfos.getAsinfo() && !brokerStatusInfos.getAsinfo().isEmpty()) {
List<ApplyServerInfo> asList = brokerStatusInfos.getAsinfo();
for (ApplyServerInfo asi : asList) {
if ("IDLE".equals(asi.getAs_status())) {
continue;
}
HostNode hostNode = dashboard.getHostNodeByName(asi.getAs_dbhost());
if (hostNode == null) {
continue;
}
String asDbname = asi.getAs_dbname();
if (StringUtil.isNotEmpty(asDbname)) {
asDbname = asDbname.replaceAll("@.*", "");
}
DatabaseNode dbNode = hostNode.getDBNodeByName(asDbname);
if (dbNode == null) {
continue;
}
dbList2Connect.add(dbNode);
}
}
//remove old connections
broker.removeConnectionsTargetNotInList(dbList2Connect, DatabaseNode.class);
//create new connections
for (DatabaseNode db2Conn : dbList2Connect) {
if (!broker.targetExists(db2Conn)) {
new BrokerConnection(broker, db2Conn);
}
}
}
List<DatabaseNode> allDatabaseNode = dashboard.getAllDatabaseNode();
for (DatabaseNode dbNode : allDatabaseNode) {
dbNode.removeConnectionsSourceNotInList(allBrokerNode, BrokerNode.class);
}
}
Aggregations