Search in sources :

Example 1 with BasicCounterFile

use of com.cubrid.cubridmanager.ui.monitoring.editor.count.BasicCounterFile in project cubrid-manager by CUBRID.

the class HistoryFileHelp method createOrOpenHistoryFile.

/**
	 * 
	 * Create or Open a history file when the history data should be restored.
	 * 
	 * @param typeNames the array of type names
	 * @return the instance of CounterFile
	 */
private CounterFile createOrOpenHistoryFile(String[] typeNames) {
    File counter = new File(historyPath);
    if (counter.exists() && counter.isFile()) {
        try {
            countFile = new BasicCounterFile(counter, null);
        } catch (IOException ex) {
            LOGGER.error(ex.getMessage());
        }
    } else {
        List<CounterType> counterLst = new ArrayList<CounterType>();
        for (String type : typeNames) {
            CounterType counterType = new CounterType(type, true, false, RangeType.INT);
            counterLst.add(counterType);
        }
        CounterType[] types = counterLst.toArray(new CounterType[counterLst.size()]);
        Properties props = new Properties();
        try {
            countFile = new BasicCounterFile(counter, types, maxCount, interval, 0, props);
        } catch (IOException ex) {
            LOGGER.error(ex.getMessage());
        }
    }
    return countFile;
}
Also used : CounterType(com.cubrid.cubridmanager.ui.monitoring.editor.count.CounterType) BasicCounterFile(com.cubrid.cubridmanager.ui.monitoring.editor.count.BasicCounterFile) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Properties(java.util.Properties) File(java.io.File) CounterFile(com.cubrid.cubridmanager.ui.monitoring.editor.count.CounterFile) BasicCounterFile(com.cubrid.cubridmanager.ui.monitoring.editor.count.BasicCounterFile)

Example 2 with BasicCounterFile

use of com.cubrid.cubridmanager.ui.monitoring.editor.count.BasicCounterFile in project cubrid-manager by CUBRID.

the class ChartCompositePart method createOrOpenHistoryFile.

/**
	 * Create or Open a history file when the history data should be restored.
	 *
	 *
	 * @param <T> the generic type which is the sub type of IDiagPara
	 * @param ts the instance of generic array
	 * @param dbName the database name
	 * @return the instance of CounterFile
	 */
private <T extends IDiagPara> CounterFile createOrOpenHistoryFile(T[] ts, String dbName) {
    File counter = new File(historyPath);
    if (counter.exists() && counter.isFile()) {
        try {
            countFile = new BasicCounterFile(counter, null);
        } catch (IOException ex) {
            LOGGER.error(ex.getMessage());
        }
    } else {
        List<CounterType> counterLst = new ArrayList<CounterType>();
        for (T diagName : ts) {
            String type = diagName.getName();
            if (dbName != null) {
                type = dbName + "_" + type;
            }
            CounterType counterType = new CounterType(type, true, false, RangeType.INT);
            counterLst.add(counterType);
        }
        CounterType[] types = counterLst.toArray(new CounterType[counterLst.size()]);
        Properties props = new Properties();
        try {
            countFile = new BasicCounterFile(counter, types, 36000, 3, 0, props);
        } catch (IOException ex) {
            LOGGER.error(ex.getMessage());
        }
    }
    return countFile;
}
Also used : CounterType(com.cubrid.cubridmanager.ui.monitoring.editor.count.CounterType) SWT(org.eclipse.swt.SWT) BasicCounterFile(com.cubrid.cubridmanager.ui.monitoring.editor.count.BasicCounterFile) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Properties(java.util.Properties) CounterFile(com.cubrid.cubridmanager.ui.monitoring.editor.count.CounterFile) File(java.io.File) BasicCounterFile(com.cubrid.cubridmanager.ui.monitoring.editor.count.BasicCounterFile)

Aggregations

BasicCounterFile (com.cubrid.cubridmanager.ui.monitoring.editor.count.BasicCounterFile)2 CounterFile (com.cubrid.cubridmanager.ui.monitoring.editor.count.CounterFile)2 CounterType (com.cubrid.cubridmanager.ui.monitoring.editor.count.CounterType)2 File (java.io.File)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Properties (java.util.Properties)2 SWT (org.eclipse.swt.SWT)1