use of com.cubrid.cubridmanager.core.monitoring.model.DbStatDumpEnum in project cubrid-manager by CUBRID.
the class DbStatusHistoryViewPart method createPartControl.
/**
* Creates the SWT controls for this workbench part.
*
* @param parent the parent control
* @see IWorkbenchPart
*/
public void createPartControl(Composite parent) {
final Composite composite = new Composite(parent, SWT.RESIZE);
composite.setLayout(new GridLayout());
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
final HistoryComposite historyComposite = new HistoryComposite();
historyComposite.loadTimeSelection(composite);
serverInfo = cubridNode.getServer().getServerInfo();
Label sepWithResult = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.SHADOW_OUT);
sepWithResult.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
DbStatDumpData dbStatDumpData = new DbStatDumpData();
TreeMap<String, String> map = new TreeMap<String, String>();
for (Map.Entry<IDiagPara, String> entry : dbStatDumpData.getDiagStatusResultMap().entrySet()) {
map.put(entry.getKey().getName(), entry.getValue());
}
chartPart = new ChartCompositePart(composite, map);
dbCombo = new DbComboContribution("database");
List<String> databaseLst = new ArrayList<String>();
List<DatabaseInfo> databaseInfoLst = serverInfo.getLoginedUserInfo().getDatabaseInfoList();
if (null != databaseInfoLst && !databaseInfoLst.isEmpty()) {
for (DatabaseInfo databaseInfo : databaseInfoLst) {
databaseLst.add(databaseInfo.getDbName());
}
dbCombo.setDatabaseLst(databaseLst);
if (!databaseLst.isEmpty()) {
dbCombo.setSelectedDb(databaseLst.get(0));
}
}
for (Map.Entry<String, String> entry : map.entrySet()) {
String key = entry.getKey();
ShowSetting showSetting = chartPart.getSettingMap().get(key);
ShowSettingMatching.match(key, showSetting, MonitorType.DATABASE);
}
chartPart.setChartTitle(Messages.databaseHistoryChartTtl);
String dbName = dbCombo.getSelectedDb();
String hostAddress = serverInfo.getHostAddress();
int monPort = serverInfo.getHostMonPort();
String historyFileName = HistoryComposite.DB_HISTORY_FILE_PREFIX + dbName + "@" + hostAddress + "_" + monPort + HistoryComposite.HISTORY_SUFFIX;
chartPart.setHistoryFileName(historyFileName);
IPath historyPath = CubridManagerCorePlugin.getDefault().getStateLocation();
String sHistoryPath = historyPath.toOSString() + File.separator + historyFileName;
chartPart.setHistoryPath(sHistoryPath);
chartPart.loadContent();
chartPart.addChartMouseListener();
makeActions();
historyComposite.getQueryBtn().addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent ex) {
String date = historyComposite.getDate();
String fromTime = historyComposite.getFromTime();
String toTime = historyComposite.getToTime();
// check date/fromTime/toTime
boolean timeOrder = historyComposite.checkTime(date, fromTime, toTime);
if (!timeOrder) {
CommonUITool.openErrorBox(Messages.errDbHistorySettingTime);
return;
}
String[] ymd = date.split("-");
int year = Integer.valueOf(ymd[0]);
int month = Integer.valueOf(ymd[1]);
int day = Integer.valueOf(ymd[2]);
String[] fromHms = fromTime.split(":");
int fromHour = Integer.valueOf(fromHms[0]);
int fromMinute = Integer.valueOf(fromHms[1]);
int fromSecond = Integer.valueOf(fromHms[2]);
Calendar calFrom = Calendar.getInstance();
calFrom.set(year, month, day, fromHour, fromMinute, fromSecond);
long millisFrom = calFrom.getTimeInMillis();
String[] toHms = toTime.split(":");
int toHour = Integer.valueOf(toHms[0]);
int toMinute = Integer.valueOf(toHms[1]);
int toSecond = Integer.valueOf(toHms[2]);
Calendar calTo = Calendar.getInstance();
calTo.set(year, month, day, toHour, toMinute, toSecond);
long millisTo = calTo.getTimeInMillis();
XYPlot plot = (XYPlot) chartPart.getChart().getPlot();
plot.getDomainAxis().setRange(millisFrom, millisTo);
CounterFile countFile = chartPart.openHistoryFile();
if (countFile == null) {
return;
}
List<String> types = new ArrayList<String>();
for (DbStatDumpEnum diagName : DbStatDumpEnum.values()) {
String type = diagName.getName();
types.add(type);
}
chartPart.executeQueryWithBusyCursor(countFile, types, millisFrom, millisTo);
try {
countFile.close();
} catch (IOException e1) {
LOGGER.error(e1.getMessage());
}
}
public void widgetSelected(SelectionEvent ex) {
widgetDefaultSelected(ex);
}
});
}
use of com.cubrid.cubridmanager.core.monitoring.model.DbStatDumpEnum in project cubrid-manager by CUBRID.
the class DatabaseDashboardViewPart method init.
/**
* Initializes
*
* @param dbNode The DatabaseNode
*/
public void init(DatabaseNode dbNode) {
this.dbNode = dbNode;
HostNode hostNode = dbNode.getParent();
String partName = getPartName();
String suffix = " - " + dbNode.getDbName() + "@" + hostNode.getIp() + ":" + hostNode.getPort();
if (!partName.endsWith(suffix)) {
setPartName(partName + suffix);
}
ServerInfo serverInfo = hostNode.getServerInfo();
if (serverInfo != null) {
String hostAddress = serverInfo.getHostAddress();
int monPort = serverInfo.getHostMonPort();
historyFileName = HistoryComposite.DBDASHBOARD_HISTORY_FILE_PREFIX + dbNode.getDbName() + "@" + hostAddress + "_" + monPort + HistoryComposite.HISTORY_SUFFIX;
IPath histPath = CubridManagerCorePlugin.getDefault().getStateLocation();
historyPath = histPath.toOSString() + File.separator + historyFileName;
historyFileHelp = new HistoryFileHelp();
historyFileHelp.setHistoryPath(historyPath);
}
List<String> typeLst = new ArrayList<String>();
for (DbProcStatEnum dbProcEnum : DbProcStatEnum.values()) {
typeLst.add(dbProcEnum.getName());
}
for (StandbyServerStatEnum standbyEnum : StandbyServerStatEnum.values()) {
typeLst.add(standbyEnum.getName());
}
for (DbStatDumpEnum dbDumpEnum : DbStatDumpEnum.values()) {
typeLst.add(dbDumpEnum.getName());
}
typeNames = typeLst.toArray(new String[typeLst.size()]);
DataGeneratorPool pool = DataGeneratorPool.getInstance();
String generatorName = hostNode.getUserName() + "@" + hostNode.getIp() + ":" + hostNode.getPort();
generator = pool.getDataGenerator(generatorName, new DataProvider());
generator.addDataUpdateListener(this);
}
Aggregations