Search in sources :

Example 11 with BrokerStatusInfos

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();
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ApplyServerInfo(com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) GetBrokerStatusInfosTask(com.cubrid.cubridmanager.core.broker.task.GetBrokerStatusInfosTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) BrokerStatusInfos(com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos)

Example 12 with BrokerStatusInfos

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;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) ApplyServerInfo(com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo) BrokerStatusInfos(com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos) ArrayList(java.util.ArrayList) List(java.util.List) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList)

Example 13 with BrokerStatusInfos

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;
}
Also used : ApplyServerInfo(com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo) HashSet(java.util.HashSet) BrokerStatusInfos(com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos)

Example 14 with BrokerStatusInfos

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());
}
Also used : HashMap(java.util.HashMap) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) BrokerStatusInfos(com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos)

Example 15 with BrokerStatusInfos

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);
    }
}
Also used : ArrayList(java.util.ArrayList) ApplyServerInfo(com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo) BrokerStatusInfos(com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos)

Aggregations

BrokerStatusInfos (com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos)16 ApplyServerInfo (com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo)10 BrokerInfoList (com.cubrid.cubridmanager.core.broker.model.BrokerInfoList)6 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)5 GetBrokerStatusInfosTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerStatusInfosTask)5 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)4 BrokerInfo (com.cubrid.cubridmanager.core.broker.model.BrokerInfo)3 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)3 HashSet (java.util.HashSet)2 List (java.util.List)2 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)1 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)1 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)1 JobInfo (com.cubrid.cubridmanager.core.broker.model.JobInfo)1 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)1 BrokerNode (com.cubrid.cubridmanager.core.cubrid.service.model.BrokerNode)1 BrokerDiagData (com.cubrid.cubridmanager.core.monitoring.model.BrokerDiagData)1 BrokerNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode)1 Set (java.util.Set)1