Search in sources :

Example 6 with ApplyServerInfo

use of com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo in project cubrid-manager by CUBRID.

the class BrokerDashboardViewPart method performUpdate.

/**
	 * Perform update UI when data change event happen
	 * 
	 * @param dataChangedEvent the instance of DataChangedEvent
	 */
public void performUpdate(DataChangedEvent dataChangedEvent) {
    if (composite == null || composite.isDisposed()) {
        return;
    }
    if (dataChangedEvent != null) {
        String brokerName = brokerNode.getBrokerName();
        BrokerInfos brokerInfos = dataChangedEvent.getBrokerInfosMap().get(brokerName);
        BrokerStatusInfos brokerStatusInfos = dataChangedEvent.getBrokerStatusInfosMap().get(brokerName);
        BrokerDiagData brokerDiagData = dataChangedEvent.getBrokerDiagDataMap().get(brokerName);
        List<String> basicTableLst = new ArrayList<String>();
        if (brokerInfos == null) {
            for (int i = 0; i < 10; i++) {
                basicTableLst.add("");
            }
        } else {
            BrokerInfoList brokerInfoList = brokerInfos.getBorkerInfoList();
            if (brokerInfoList.getBrokerInfoList().isEmpty()) {
                for (int i = 0; i < 10; i++) {
                    basicTableLst.add("");
                }
            }
            for (BrokerInfo bi : brokerInfoList.getBrokerInfoList()) {
                if (brokerName.equals(bi.getName())) {
                    basicTableLst.add(bi.getPid());
                    basicTableLst.add(bi.getPort());
                    basicTableLst.add(bi.getJq());
                    basicTableLst.add(bi.getAuto());
                    basicTableLst.add(bi.getSqll());
                    basicTableLst.add(bi.getLong_tran_time());
                    basicTableLst.add(bi.getLong_query_time());
                    basicTableLst.add(bi.getSes());
                    basicTableLst.add(bi.getKeep_conn());
                    basicTableLst.add(bi.getAccess_mode());
                }
            }
        }
        if (brokerDiagData == null) {
            for (int i = 0; i < 3; i++) {
                basicTableLst.add("");
            }
        } else {
            basicTableLst.add(brokerDiagData.getCas_mon_active());
            basicTableLst.add(brokerDiagData.getCas_mon_session());
            basicTableLst.add(brokerDiagData.getCas_mon_tran());
        }
        //test
        List<List<String>> basicColumnLst = new ArrayList<List<String>>();
        basicColumnLst.add(basicTableLst);
        basicTableViewer.setInput(basicColumnLst);
        basicTableViewer.refresh();
        List<ApplyServerInfo> asinfoLst = null;
        List<JobInfo> jobinfoLst = null;
        if (brokerStatusInfos == null) {
            asinfoLst = new ArrayList<ApplyServerInfo>();
            jobinfoLst = new ArrayList<JobInfo>();
        } else {
            asinfoLst = brokerStatusInfos.getAsinfo();
            jobinfoLst = brokerStatusInfos.getJobinfo();
            if (asinfoLst == null) {
                asinfoLst = new ArrayList<ApplyServerInfo>();
            }
            if (jobinfoLst == null) {
                jobinfoLst = new ArrayList<JobInfo>();
            }
        }
        asTableViewer.setInput(asinfoLst);
        asTableViewer.refresh();
        jqTableViewer.setInput(jobinfoLst);
        jqTableViewer.refresh();
    }
}
Also used : BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) ArrayList(java.util.ArrayList) BrokerDiagData(com.cubrid.cubridmanager.core.monitoring.model.BrokerDiagData) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) ApplyServerInfo(com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo) BrokerStatusInfos(com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo) JobInfo(com.cubrid.cubridmanager.core.broker.model.JobInfo) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 7 with ApplyServerInfo

use of com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo in project cubrid-manager by CUBRID.

the class BrokerStatusView method createAsTable.

/**
	 * Create app server table
	 * 
	 * @param comp the parent composite
	 * 
	 */
private void createAsTable(Composite comp) {
    Composite asComposite = new Composite(comp, SWT.NONE);
    GridData gdAs = new GridData(SWT.FILL, SWT.FILL, true, true);
    asComposite.setLayoutData(gdAs);
    asComposite.setLayout(new GridLayout());
    asTableViewer = new TableViewer(asComposite, SWT.FULL_SELECTION | SWT.NO_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    Table asTable = asTableViewer.getTable();
    asTable.setHeaderVisible(true);
    asTable.setLinesVisible(true);
    asTable.setLayoutData(gdAs);
    TableLayout asLayout = new TableLayout();
    setAsLayout(asLayout);
    asTable.setLayout(asLayout);
    TableColumn tblColumn = new TableColumn(asTable, SWT.CENTER);
    tblColumn.setText(Messages.tblAsId);
    tblColumn.setToolTipText(Messages.tblAsId);
    tblColumn = new TableColumn(asTable, SWT.CENTER);
    tblColumn.setText(Messages.tblAsProcess);
    tblColumn.setToolTipText(Messages.tblAsProcess);
    tblColumn = new TableColumn(asTable, SWT.CENTER);
    tblColumn.setText(Messages.tblAsQps);
    tblColumn.setToolTipText(Messages.tblAsQps);
    tblColumn = new TableColumn(asTable, SWT.CENTER);
    tblColumn.setText(Messages.tblAsLqs);
    tblColumn.setToolTipText(Messages.tblAsLqs);
    tblColumn = new TableColumn(asTable, SWT.CENTER);
    tblColumn.setText(Messages.tblAsPort);
    tblColumn.setToolTipText(Messages.tblAsPort);
    tblColumn = new TableColumn(asTable, SWT.CENTER);
    tblColumn.setText(Messages.tblAsSize);
    tblColumn.setToolTipText(Messages.tblAsSize);
    tblColumn = new TableColumn(asTable, SWT.CENTER);
    tblColumn.setText(Messages.tblAsStatus);
    tblColumn.setToolTipText(Messages.tblAsStatus);
    tblColumn = new TableColumn(asTable, SWT.CENTER);
    tblColumn.setText(Messages.tblAsDb);
    tblColumn.setToolTipText(Messages.tblAsDb);
    tblColumn = new TableColumn(asTable, SWT.CENTER);
    tblColumn.setText(Messages.tblAsHost);
    tblColumn.setToolTipText(Messages.tblAsHost);
    tblColumn = new TableColumn(asTable, SWT.CENTER);
    tblColumn.setText(Messages.tblAsLastAccess);
    tblColumn.setToolTipText(Messages.tblAsLastAccess);
    tblColumn = new TableColumn(asTable, SWT.CENTER);
    tblColumn.setText(Messages.tblAsLct);
    tblColumn.setToolTipText(Messages.tblAsLct);
    tblColumn = new TableColumn(asTable, SWT.CENTER);
    tblColumn.setText(Messages.tblAsClientIp);
    tblColumn.setToolTipText(Messages.tblAsClientIp);
    tblColumn = new TableColumn(asTable, SWT.CENTER);
    tblColumn.setText(Messages.tblAsCur);
    tblColumn.setToolTipText(Messages.tblAsCur);
    asTableViewer.setContentProvider(new ApplyServerContentProvider());
    asTableViewer.setLabelProvider(new ApplyServerLabelProvider());
    asTableViewer.setInput(asinfoLst);
    MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    menuManager.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            IStructuredSelection selection = (IStructuredSelection) asTableViewer.getSelection();
            ApplyServerInfo as = (ApplyServerInfo) (selection.toArray()[0]);
            RestartAction restartAcion = new RestartAction(as.getAs_id());
            manager.add(restartAcion);
        }
    });
    Menu contextMenu = menuManager.createContextMenu(asTableViewer.getControl());
    asTableViewer.getControl().setMenu(contextMenu);
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TableColumn(org.eclipse.swt.widgets.TableColumn) ApplyServerInfo(com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo) IMenuListener(org.eclipse.jface.action.IMenuListener) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) TableViewer(org.eclipse.jface.viewers.TableViewer) TableLayout(org.eclipse.jface.viewers.TableLayout)

Example 8 with ApplyServerInfo

use of com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo 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 9 with ApplyServerInfo

use of com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo 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 10 with ApplyServerInfo

use of com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo 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

ApplyServerInfo (com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo)13 BrokerStatusInfos (com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos)8 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 BrokerInfoList (com.cubrid.cubridmanager.core.broker.model.BrokerInfoList)3 Composite (org.eclipse.swt.widgets.Composite)3 Menu (org.eclipse.swt.widgets.Menu)3 BrokerInfo (com.cubrid.cubridmanager.core.broker.model.BrokerInfo)2 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)2 GetBrokerStatusInfosTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerStatusInfosTask)2 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)2 HashSet (java.util.HashSet)2 List (java.util.List)2 IMenuListener (org.eclipse.jface.action.IMenuListener)2 IMenuManager (org.eclipse.jface.action.IMenuManager)2 MenuManager (org.eclipse.jface.action.MenuManager)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 TableViewer (org.eclipse.jface.viewers.TableViewer)2 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)2 GridLayout (org.eclipse.swt.layout.GridLayout)2