Search in sources :

Example 11 with ApplyServerInfo

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

the class BrokerDBListNode method propertyChange.

/**
	 * Litsen the broker's status changing.
	 *
	 * @param evt PropertyChangeEvent
	 */
public void propertyChange(PropertyChangeEvent evt) {
    if (BrokerNode.PROP_BROKER_STATUS.equals(evt.getPropertyName())) {
        BrokerStatusInfos bsi = brokerNode.getBrokerStatusInfos();
        dbList.clear();
        if (bsi == null || bsi.getAsinfo() == null || bsi.getAsinfo().isEmpty()) {
            fireStructureChange(PROP_DB_LIST, dbList);
            return;
        }
        for (ApplyServerInfo asi : bsi.getAsinfo()) {
            if ("IDLE".equals(asi.getAs_status()) || StringUtil.isEmpty(asi.getAs_dbname()) || dbList.contains(asi.getAs_dbname())) {
                continue;
            }
            dbList.add(asi.getAs_dbname());
        }
        fireStructureChange(PROP_DB_LIST, dbList);
    }
}
Also used : ApplyServerInfo(com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo) BrokerStatusInfos(com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos)

Example 12 with ApplyServerInfo

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

the class DatabaseDashboardEditor method updateDabaseTableDataInfo.

/**
	 * update database table data
	 *
	 * @param cpuAndMemoryMap the given instance of TreeMap<String,String>
	 * @param statisticsMap the given instance of TreeMap<String,String>
	 */
public void updateDabaseTableDataInfo(TreeMap<String, String> cpuAndMemoryMap, TreeMap<String, String> statisticsMap) {
    if (!CompatibleUtil.isSupportGetCPUAndMemoryInfo(database.getDatabaseInfo())) {
        return;
    }
    String deltaCpuUser = cpuAndMemoryMap.get(DbProcStatEnum.DELTA_USER.name());
    String deltaCpuKernel = cpuAndMemoryMap.get(DbProcStatEnum.DELTA_KERNEL.name());
    String hostCpuTotal = cpuAndMemoryMap.get(HostStatEnum.CPU_TOTAL.name());
    String hostMemTotal = cpuAndMemoryMap.get(HostStatEnum.MEMPHY_TOTAL.name());
    String memPhyUsed = cpuAndMemoryMap.get(DbProcStatEnum.MEM_PHYSICAL.name());
    NumberFormat numberFormat = NumberFormat.getInstance();
    numberFormat.setMaximumFractionDigits(0);
    numberFormat.setGroupingUsed(true);
    if (hostCpuTotal == null || hostMemTotal == null) {
        return;
    }
    double hostCpuTotalDouble = Double.parseDouble(hostCpuTotal);
    Long deltaCpuUserLong = Long.parseLong(deltaCpuUser == null ? "0" : deltaCpuUser);
    Long dletaCpuKernelLong = Long.parseLong(deltaCpuKernel == null ? "0" : deltaCpuKernel);
    int userPercent = 0;
    int kernelPercent = 0;
    String totalPercentString = "0%";
    if (!"0".equals(hostCpuTotal)) {
        userPercent = (int) (deltaCpuUserLong / hostCpuTotalDouble * 100 + 0.5);
        kernelPercent = (int) (dletaCpuKernelLong / hostCpuTotalDouble * 100 + 0.5);
        totalPercentString = Integer.toString(userPercent + kernelPercent) + "%";
        cpuAndMemoryMap.put(DbProcStatEnum.USER_PERCENT.name(), Integer.toString(userPercent));
        cpuAndMemoryMap.put(DbProcStatEnum.KERNEL_PERCENT.name(), Integer.toString(kernelPercent));
        Map<String, String> databaseInfo = dbInfoListData.get(0);
        if (databaseInfo != null) {
            databaseInfo.put("0", totalPercentString);
        }
    }
    memPhyUsed = memPhyUsed == null ? "0" : memPhyUsed;
    if (hostMemTotal != null) {
        //physichal memory
        double memPhyMb = Long.parseLong(memPhyUsed) / 1024.0;
        //total memory
        double hostMemTotalDoubleMb = Long.parseLong(hostMemTotal) / 1024.0;
        memPhyUsed = numberFormat.format(memPhyMb) + "MB";
        hostMemTotal = numberFormat.format(hostMemTotalDoubleMb) + "MB";
        Map<String, String> databaseInfo = dbInfoListData.get(0);
        if (databaseInfo != null) {
            databaseInfo.put("1", memPhyUsed + " / " + hostMemTotal);
        }
    }
    Map<String, String> databaseInfo = dbInfoListData.get(0);
    if (databaseInfo != null) {
        //compute Qps
        long qps = 0;
        for (HashMap<String, ApplyServerInfo> brokerValueMap : asinfoLst) {
            for (Entry<String, ApplyServerInfo> entry : brokerValueMap.entrySet()) {
                ApplyServerInfo applyServerInfo = entry.getValue();
                qps += Long.valueOf(applyServerInfo.getAs_num_query());
            }
        }
        databaseInfo.put("2", Long.toString(qps));
        String hitRatio = statisticsMap.get("data_page_buffer_hit_ratio");
        if (hitRatio == null) {
            hitRatio = "";
        }
        databaseInfo.put("3", hitRatio);
        //num_data_page_fetches
        String numDataPageFetches = statisticsMap.get("num_data_page_fetches");
        if (numDataPageFetches == null) {
            numDataPageFetches = "";
        }
        databaseInfo.put("4", numDataPageFetches);
        //num_data_page_dirties
        String numDataPageDirties = statisticsMap.get("num_data_page_dirties");
        if (numDataPageDirties == null) {
            numDataPageDirties = "";
        }
        databaseInfo.put("5", numDataPageDirties);
        //num_data_page_ioreads
        String numDataPageIoreads = statisticsMap.get("num_data_page_ioreads");
        if (numDataPageIoreads == null) {
            numDataPageIoreads = "";
        }
        databaseInfo.put("6", numDataPageIoreads);
        //num_data_page_iowrites
        String numDataPageIowrites = statisticsMap.get("num_data_page_iowrites");
        if (numDataPageIowrites == null) {
            numDataPageIowrites = "";
        }
        databaseInfo.put("7", numDataPageIowrites);
    }
    if (dbInfoTableViewer != null && !dbInfoTableViewer.getTable().isDisposed()) {
        dbInfoTableViewer.refresh();
    }
}
Also used : ApplyServerInfo(com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo) NumberFormat(java.text.NumberFormat)

Example 13 with ApplyServerInfo

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

the class DatabaseDashboardEditor method loadDatabaseInfo.

/**
	 * load databse information
	 */
public void loadDatabaseInfo() {
    if (!CompatibleUtil.isSupportGetCPUAndMemoryInfo(database.getDatabaseInfo())) {
        return;
    }
    dbInfoListData.clear();
    Map<String, String> dbMap = new HashMap<String, String>();
    //first time display value of 0
    dbMap.put("0", "0%");
    dbMap.put("1", "0M /0M");
    //compute Qps
    long qps = 0;
    for (HashMap<String, ApplyServerInfo> brokerValueMap : asinfoLst) {
        for (Entry<String, ApplyServerInfo> entry : brokerValueMap.entrySet()) {
            ApplyServerInfo applyServerInfo = entry.getValue();
            qps += Long.valueOf(applyServerInfo.getAs_num_query());
        }
    }
    dbMap.put("2", Long.toString(qps));
    dbMap.put("3", "0");
    dbInfoListData.add(dbMap);
    //start thread to compute cpu/memory information at first time or thread is stop
    new DatabaseDataGenerator().start();
}
Also used : HashMap(java.util.HashMap) ApplyServerInfo(com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo)

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