use of com.cubrid.cubridmanager.core.common.model.ServerInfo in project cubrid-manager by CUBRID.
the class AddStatusMonitorTemplateAction method run.
/**
* Override the run method in order to open an instance of status monitor
* dialog
*
*/
public void run() {
Object[] obj = this.getSelectedObj();
ICubridNode selection = (ICubridNode) obj[0];
ServerInfo site = selection.getServer().getServerInfo();
boolean execDiagChecked = false;
final GetCMConfParameterTask task = new GetCMConfParameterTask(site);
TaskExecutor taskExec = new CommonTaskExec(null);
taskExec.addTask(task);
new ExecTaskWithProgress(taskExec).exec();
if (!taskExec.isSuccess()) {
return;
}
Map<String, String> confParas = task.getConfParameters();
if (confParas == null) {
execDiagChecked = false;
} else {
if (confParas.get(ConfConstants.EXECUTE_DIAG) == null) {
execDiagChecked = false;
} else {
execDiagChecked = confParas.get(ConfConstants.EXECUTE_DIAG).equals(OnOffType.ON.getText()) ? true : false;
}
}
DiagStatusMonitorTemplateDialog dialog = new DiagStatusMonitorTemplateDialog(getShell());
dialog.setOperation(AddEditType.ADD);
dialog.setSelection(selection);
dialog.setExecDiagChecked(execDiagChecked);
if (dialog.open() == Dialog.OK) {
StatusTemplateInfo statusTemplateInfo = dialog.getStatusTemplateInfo();
AddStatusTemplateTask addTask = new AddStatusTemplateTask(site);
addTask.setStatusTemplateInfo(statusTemplateInfo);
addTask.buildMsg();
String taskName = Messages.bind(Messages.addTemplateTaskName, statusTemplateInfo.getName());
TaskExecutor taskExecutor = new CommonTaskExec(taskName);
taskExecutor.addTask(addTask);
new ExecTaskWithProgress(taskExecutor).exec();
if (taskExecutor.isSuccess()) {
TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
CommonUITool.refreshNavigatorTree(treeViewer, selection);
}
}
}
use of com.cubrid.cubridmanager.core.common.model.ServerInfo in project cubrid-manager by CUBRID.
the class OpenApplyLogDBLogAction method run.
/**
* open apply database log
*
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
Object[] objArr = this.getSelectedObj();
if (objArr == null || objArr.length <= 0 || !isSupported(objArr[0])) {
setEnabled(false);
return;
}
DatabaseMonitorPart dbMonPart = (DatabaseMonitorPart) objArr[0];
DatabaseNode dbNode = (DatabaseNode) dbMonPart.getModel();
HostNode hostNode = dbNode.getParent();
ServerInfo serverInfo = hostNode.getServerInfo();
CubridServer server = new CubridServer(serverInfo.getHostAddress(), serverInfo.getHostAddress(), null, null);
server.setServerInfo(serverInfo);
LogInfo logInfo = new LogInfo();
String logPath = serverInfo.getEnvInfo().getRootDir() + serverInfo.getPathSeparator() + "log" + serverInfo.getPathSeparator();
String fileName = dbNode.getDbName() + "@localhost_applylogdb_" + dbNode.getDbName() + "_" + hostNode.getHostStatusInfo().getMasterHostStatusInfo().getHostName() + ".err";
logInfo.setPath(logPath + fileName);
DefaultCubridNode dbLogInfoNode = new DefaultCubridNode(dbNode.getDbName() + ICubridNodeLoader.NODE_SEPARATOR + "apply_database_log", logInfo.getName(), "icons/navigator/log_item.png");
dbLogInfoNode.setType(CubridNodeType.LOGS_APPLY_DATABASE_LOG);
dbLogInfoNode.setModelObj(logInfo);
dbLogInfoNode.setEditorId(LogEditorPart.ID);
dbLogInfoNode.setContainer(false);
dbLogInfoNode.setServer(server);
LogViewAction action = (LogViewAction) ActionManager.getInstance().getAction(LogViewAction.ID);
action.setCubridNode(dbLogInfoNode);
action.run();
}
use of com.cubrid.cubridmanager.core.common.model.ServerInfo in project cubrid-manager by CUBRID.
the class BrokerStatusHistoryViewPart 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);
Label sepWithResult = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.SHADOW_OUT);
sepWithResult.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
BrokerDiagData brokerDiagData = new BrokerDiagData();
ICubridNode selection = getCubridNode();
ServerInfo serverInfo = selection.getServer().getServerInfo();
isNewBrokerDiag = CompatibleUtil.isNewBrokerDiag(serverInfo);
TreeMap<String, String> map = convertMapKey(brokerDiagData.getDiagStatusResultMap());
chartPart = new ChartCompositePart(composite, map);
for (Map.Entry<String, String> entry : map.entrySet()) {
String key = entry.getKey();
ShowSetting showSetting = chartPart.getSettingMap().get(key);
ShowSettingMatching.match(key, showSetting, MonitorType.BROKER, isNewBrokerDiag);
}
chartPart.setChartTitle(Messages.brokerHistoryChartTtl);
String hostAddress = serverInfo.getHostAddress();
int monPort = serverInfo.getHostMonPort();
String historyFileName = HistoryComposite.BROKER_HISTORY_FILE_PREFIX + 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.errBrokerHistorySettingTime);
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);
final 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);
final long millisTo = calTo.getTimeInMillis();
XYPlot plot = (XYPlot) chartPart.getChart().getPlot();
plot.getDomainAxis().setRange(millisFrom, millisTo);
final CounterFile countFile = chartPart.openHistoryFile();
if (countFile == null) {
return;
}
final List<String> types = new ArrayList<String>();
for (BrokerDiagEnum enumeration : BrokerDiagEnum.values()) {
String type = enumeration.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.common.model.ServerInfo in project cubrid-manager by CUBRID.
the class BrokerStatusMonitorViewPart method createPartControl.
/**
* Creates the SWT controls for this workbench part.
*
* @param parent the parent control
*/
public void createPartControl(Composite parent) {
composite = new Composite(parent, SWT.RESIZE);
composite.setLayout(new FillLayout());
ICubridNode selection = getCubridNode();
ServerInfo serverInfo = selection.getServer().getServerInfo();
isNewBrokerDiag = CompatibleUtil.isNewBrokerDiag(serverInfo);
BrokerDiagData brokerDiagData = new BrokerDiagData();
TreeMap<String, String> map = convertMapKey(brokerDiagData.getDiagStatusResultMap());
chartPart = new ChartCompositePart(composite, map);
String hostAddress = serverInfo.getHostAddress();
int monPort = serverInfo.getHostMonPort();
String historyFileName = HistoryComposite.BROKER_HISTORY_FILE_PREFIX + hostAddress + "_" + monPort + HistoryComposite.HISTORY_SUFFIX;
chartPart.setHistoryFileName(historyFileName);
if (null == monInstaceData) {
for (Map.Entry<String, String> entry : map.entrySet()) {
String key = entry.getKey();
ShowSetting showSetting = chartPart.getSettingMap().get(key);
ShowSettingMatching.match(key, showSetting, MonitorType.BROKER, isNewBrokerDiag);
}
chartPart.setChartTitle(Messages.brokerMonitorChartTtl);
IPath historyPath = CubridManagerCorePlugin.getDefault().getStateLocation();
String sHistoryPath = historyPath.toOSString() + File.separator + historyFileName;
chartPart.setHistoryPath(sHistoryPath);
} else {
String titleName = monInstaceData.getTitleName();
chartPart.setChartTitle(titleName);
chartPart.setSettingData(monInstaceData);
}
chartPart.loadContent();
makeActions();
new DataGenerator().start();
}
use of com.cubrid.cubridmanager.core.common.model.ServerInfo in project cubrid-manager by CUBRID.
the class BrokerStatusMonitorViewPart method getUpdateValue.
/**
* Get update value
*
* @param startRun int
* @return Map<String, String>
*/
private TreeMap<String, String> getUpdateValue(int startRun) {
ServerInfo site = cubridNode.getServer().getServerInfo();
final CommonQueryTask<BrokerDiagData> task = new CommonQueryTask<BrokerDiagData>(site, CommonSendMsg.getGetBrokerStatusItems(), diagStatusResult);
task.execute();
TreeMap<String, String> resultMap = null;
float inter = 0.0f;
if (startRun == 0) {
diagStatusResult = task.getResultModel();
if (!diagStatusResult.getStatus()) {
if (interruptReq) {
return convertMapKey(diagStatusResult.getDiagStatusResultMap());
} else {
showErrorMsg(diagStatusResult);
}
}
return convertMapKey(diagStatusResult.getDiagStatusResultMap());
} else if (startRun == 1) {
lastSec = Calendar.getInstance();
diagOldOneStatusResult.copyFrom(diagStatusResult);
BrokerDiagData brokerDiagDataDelta = new BrokerDiagData();
diagStatusResult = task.getResultModel();
if (!diagStatusResult.getStatus()) {
if (interruptReq) {
return convertMapKey(diagStatusResult.getDiagStatusResultMap());
} else {
showErrorMsg(diagStatusResult);
}
}
brokerDiagDataDelta.getDelta(diagStatusResult, diagOldOneStatusResult);
return convertMapKey(brokerDiagDataDelta.getDiagStatusResultMap());
} else {
nowSec = Calendar.getInstance();
double interval = (double) (nowSec.getTimeInMillis() - lastSec.getTimeInMillis()) / 1000;
NumberFormat nf = NumberFormat.getInstance();
nf.setMaximumFractionDigits(3);
inter = Float.parseFloat(nf.format(interval));
lastSec = nowSec;
diagOldTwoStatusResult.copyFrom(diagOldOneStatusResult);
diagOldOneStatusResult.copyFrom(diagStatusResult);
diagStatusResult = task.getResultModel();
if (!diagStatusResult.getStatus()) {
if (interruptReq) {
return convertMapKey(diagStatusResult.getDiagStatusResultMap());
} else {
showErrorMsg(diagStatusResult);
}
}
BrokerDiagData diagStatusResultDelta = new BrokerDiagData();
diagStatusResultDelta.getDelta(diagStatusResult, diagOldOneStatusResult, diagOldTwoStatusResult, inter);
resultMap = convertMapKey(diagStatusResultDelta.getDiagStatusResultMap());
}
return resultMap;
}
Aggregations