use of com.cubrid.common.ui.spi.model.DefaultCubridNode in project cubrid-manager by CUBRID.
the class DatabaseDashboardEditor method showLogView.
/**
* show sql log view at broker table
*
* @param type sql type
*/
public void showLogView(String type) {
try {
int i = brokerInfoTable.getSelectionIndex();
if (i < 0) {
return;
}
final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
String brokerName = brokerInfoTable.getItem(i).getText(0);
String serverId = brokerInfoTable.getItem(i).getText(1);
//get all log infor
BrokerLogInfos brokerLogInfos = new BrokerLogInfos();
final CommonQueryTask<BrokerLogInfos> task = new CommonQueryTask<BrokerLogInfos>(database.getDatabaseInfo().getServerInfo(), CommonSendMsg.getGetBrokerLogFileInfoMSGItems(), brokerLogInfos);
task.setBroker(brokerName);
task.execute();
brokerLogInfos = task.getResultModel();
String logFileName = brokerName + "_" + serverId + "." + type + ".log";
sqlLogViewPartName = logFileName + "@" + database.getServer().getLabel() + ":" + database.getServer().getMonPort();
List<LogInfo> logInfoList = brokerLogInfos == null ? null : brokerLogInfos.getBrokerLogInfoList().getLogFileInfoList();
task.finish();
//get the current log
LogInfo logInfo = null;
if (logInfoList != null && !logInfoList.isEmpty()) {
for (LogInfo logInfoInlist : logInfoList) {
if (logFileName.equals(logInfoInlist.getName())) {
logInfo = logInfoInlist;
break;
}
}
}
if (logInfo == null) {
String msg = Messages.bind(com.cubrid.cubridmanager.ui.logs.Messages.errLogFileNoExist, logFileName);
LOGGER.error(msg);
//CommonUITool.openErrorBox(msg);
return;
}
final String filePath = logInfo.getPath();
TaskJobExecutor taskJobExecutor = new TaskJobExecutor() {
public IStatus exec(IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
for (ITask task : taskList) {
task.execute();
final String msg = task.getErrorMsg();
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
}
if (task instanceof CheckFileTask) {
CheckFileTask checkFileTask = (CheckFileTask) task;
final String[] files = checkFileTask.getExistFiles();
if (files == null || files.length == 0) {
return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, Messages.bind(com.cubrid.cubridmanager.ui.logs.Messages.errLogFileNoExist, filePath));
}
} else if (task instanceof GetLogListTask) {
GetLogListTask getLogListTask = (GetLogListTask) task;
final LogContentInfo logContentInfo = (LogContentInfo) getLogListTask.getLogContent();
Display.getDefault().syncExec(new Runnable() {
public void run() {
try {
ICubridNode logInfoNode = new DefaultCubridNode("", "", "");
IEditorPart editor = window.getActivePage().openEditor(logInfoNode, LogEditorPart.ID);
((LogEditorPart) editor).setTableInfo(logContentInfo, true);
((LogEditorPart) editor).setShowLogPartName(sqlLogViewPartName);
} catch (PartInitException e) {
LOGGER.error(e.getMessage(), e);
}
}
});
}
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
task.finish();
}
return Status.OK_STATUS;
}
};
CheckFileTask checkFileTask = new CheckFileTask(cubridNode.getServer().getServerInfo());
checkFileTask.setFile(new String[] { filePath });
taskJobExecutor.addTask(checkFileTask);
GetLogListTask getLogListTask = new GetLogListTask(cubridNode.getServer().getServerInfo());
getLogListTask.setPath(filePath);
getLogListTask.setStart("1");
getLogListTask.setEnd("100");
taskJobExecutor.addTask(getLogListTask);
String jobName = com.cubrid.cubridmanager.ui.logs.Messages.viewLogJobName + " - " + cubridNode.getName() + "@" + cubridNode.getServer().getName();
taskJobExecutor.schedule(jobName, null, false, Job.SHORT);
} catch (Exception e) {
LOGGER.error(Messages.exportDashboardOpenSQLLogErrMsg, e);
// CommonUITool.openErrorBox(Messages.exportDashboardOpenSQLLogErrMsg);
}
}
use of com.cubrid.common.ui.spi.model.DefaultCubridNode in project cubrid-manager by CUBRID.
the class AutoAddVolumeLogAction method run.
/**
*
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
Object[] obj = this.getSelectedObj();
DefaultCubridNode node = null;
CubridServer server = null;
if (obj.length > 0 && obj[0] instanceof DefaultCubridNode) {
node = (DefaultCubridNode) obj[0];
server = node.getServer();
}
AutoAddVolumeLogDialog dlg = new AutoAddVolumeLogDialog(getShell());
dlg.setServer(server);
if (dlg.loadData()) {
dlg.open();
}
}
use of com.cubrid.common.ui.spi.model.DefaultCubridNode in project cubrid-manager by CUBRID.
the class RestartBrokerAction method run.
public void run() {
final Object[] obj = this.getSelectedObj();
DefaultCubridNode selection = (DefaultCubridNode) obj[0];
if (selection == null || selection.getServer() == null) {
return;
}
ServerInfo serverInfo = selection.getServer().getServerInfo();
if (serverInfo == null) {
return;
}
//stop first
StopBrokerTask stopTask = new StopBrokerTask(serverInfo);
stopTask.setBrokerName(selection.getLabel());
//then start again
StartBrokerTask startTask = new StartBrokerTask(serverInfo);
startTask.setBrokerName(selection.getLabel());
final String taskName = Messages.bind(Messages.restartBrokerTaskName, selection.getLabel());
TaskExecutor taskExecutor = new CommonTaskExec(taskName);
taskExecutor.addTask(stopTask);
taskExecutor.addTask(startTask);
new ExecTaskWithProgress(taskExecutor).exec();
if (!taskExecutor.isSuccess()) {
return;
}
TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
CommonUITool.refreshNavigatorTree(treeViewer, selection.getParent());
ActionManager.getInstance().fireSelectionChanged(getSelection());
}
use of com.cubrid.common.ui.spi.model.DefaultCubridNode in project cubrid-manager by CUBRID.
the class StartBrokerAction method run.
/**
* Override the run method in order to complete starting broker environment
*
*/
public void run() {
final Object[] obj = this.getSelectedObj();
DefaultCubridNode selection = (DefaultCubridNode) obj[0];
ServerInfo site = selection.getServer().getServerInfo();
StartBrokerTask task = new StartBrokerTask(site);
task.setBrokerName(selection.getLabel());
final String taskName = Messages.bind(Messages.startBrokerTaskName, selection.getLabel());
TaskExecutor taskExecutor = new CommonTaskExec(taskName);
taskExecutor.addTask(task);
new ExecTaskWithProgress(taskExecutor).exec();
if (!taskExecutor.isSuccess()) {
return;
}
TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
CommonUITool.refreshNavigatorTree(treeViewer, selection.getParent());
ActionManager.getInstance().fireSelectionChanged(getSelection());
}
use of com.cubrid.common.ui.spi.model.DefaultCubridNode in project cubrid-manager by CUBRID.
the class AnalyzeSqlLogAction method run.
/**
* Open dialog
*/
public void run() {
Object[] obj = this.getSelectedObj();
DefaultCubridNode node = null;
LogInfo logInfo = null;
node = (DefaultCubridNode) obj[0];
logInfo = (LogInfo) node.getAdapter(LogInfo.class);
SqlLogFileListDialog cASLogTopConfigDialog = new SqlLogFileListDialog(getShell());
List<String> targetStringList = new ArrayList<String>();
if (logInfo == null) {
for (int j = 0, m = node.getChildren().size(); j < m; j++) {
targetStringList.add(((LogInfo) node.getChildren().get(j).getAdapter(LogInfo.class)).getPath());
}
} else {
targetStringList.add(logInfo.getPath());
}
cASLogTopConfigDialog.create();
cASLogTopConfigDialog.setInfo(targetStringList);
int returnCode = cASLogTopConfigDialog.open();
if (returnCode == SqlLogFileListDialog.OK) {
String optionT;
final GetAnalyzeCasLogTask task = new GetAnalyzeCasLogTask(node.getServer().getServerInfo());
if (cASLogTopConfigDialog.isOption()) {
optionT = "yes";
} else {
optionT = "no";
}
List<String> selectedStringList = cASLogTopConfigDialog.getSelectedStringList();
String[] path = new String[selectedStringList.size()];
selectedStringList.toArray(path);
task.setLogFiles(path);
task.setOptionT(optionT);
TaskExecutor taskExcutor = new CommonTaskExec(Messages.loadLogTaskName);
taskExcutor.addTask(task);
new ExecTaskWithProgress(taskExcutor).exec();
if (!taskExcutor.isSuccess()) {
return;
}
AnalyzeCasLogResultList analyzeCasLogResultList = (AnalyzeCasLogResultList) task.getAnalyzeCasLogResultList();
SqlLogAnalyzeResultDialog activityCASLogPathDialog = new SqlLogAnalyzeResultDialog(getShell());
activityCASLogPathDialog.setOption(cASLogTopConfigDialog.isOption());
activityCASLogPathDialog.setNode(node);
activityCASLogPathDialog.setResultFile(analyzeCasLogResultList.getResultfile());
activityCASLogPathDialog.setAnalyzeCasLogResultList(analyzeCasLogResultList);
activityCASLogPathDialog.create();
activityCASLogPathDialog.setLabel(selectedStringList);
activityCASLogPathDialog.insertArrayToTable(analyzeCasLogResultList);
activityCASLogPathDialog.open();
}
}
Aggregations