use of com.cubrid.cubridmanager.core.common.task.CommonUpdateTask in project cubrid-manager by CUBRID.
the class OptimizeTaskTest method testNotExistDatabase.
public void testNotExistDatabase() {
if (StringUtil.isEqual(SystemParameter.getParameterValue("useMockTest"), "n"))
return;
System.out.println("<database.optimizedb.003.req.txt>");
CommonUpdateTask task = new CommonUpdateTask(CommonTaskName.OPTIMIZE_DATABASE_TASK_NAME, serverInfo, CommonSendMsg.getOptimizeDbSendMsg());
task.setDbName("notexistdb");
task.execute();
assertTrue(task.isSuccess());
assertNull(task.getErrorMsg());
// this result does not understanding... I expacted a failure result -.-;
// perhaps, cubrid will be done a database authentication before executing a shell command(cubrid optimizedb ...).
// must be examine in the future...
}
use of com.cubrid.cubridmanager.core.common.task.CommonUpdateTask in project cubrid-manager by CUBRID.
the class StopDbTaskTest method testStopDbNotActive.
public void testStopDbNotActive() {
if (StringUtil.isEqual(SystemParameter.getParameterValue("useMockTest"), "n"))
return;
System.out.println("<database.stopdb.003.req.txt>");
CommonUpdateTask task = new CommonUpdateTask(CommonTaskName.STOP_DB_TASK_NAME, ServerManager.getInstance().getServer(host, monport, userName), CommonSendMsg.getCommonDatabaseSendMsg());
task.setDbName("notactivedb");
task.execute();
assertTrue(task.isSuccess());
assertNull(task.getErrorMsg());
}
use of com.cubrid.cubridmanager.core.common.task.CommonUpdateTask in project cubrid-manager by CUBRID.
the class StartDbTaskTest method testStartDbEmpty.
public void testStartDbEmpty() {
if (StringUtil.isEqual(SystemParameter.getParameterValue("useMockTest"), "n"))
return;
System.out.println("<database.startdb.003.req.txt>");
CommonUpdateTask task = new CommonUpdateTask(CommonTaskName.START_DB_TASK_NAME, ServerManager.getInstance().getServer(host, monport, userName), CommonSendMsg.getCommonDatabaseSendMsg());
task.setDbName(null);
task.execute();
assertFalse(task.isSuccess());
assertNotNull(task.getErrorMsg());
}
use of com.cubrid.cubridmanager.core.common.task.CommonUpdateTask in project cubrid-manager by CUBRID.
the class StartDatabaseAction method doRun.
public void doRun(ISchemaNode[] schemaArray) {
if (schemaArray == null || schemaArray.length == 0) {
return;
}
List<ISchemaNode> startList = new ArrayList<ISchemaNode>();
/*Judge start job is running*/
for (ISchemaNode node : schemaArray) {
if (!isSupported(node)) {
setEnabled(false);
return;
}
CubridDatabase database = node.getDatabase();
final JobFamily jobFamily = new JobFamily();
String serverName = database.getServer().getName();
String dbName = database.getName();
jobFamily.setServerName(serverName);
jobFamily.setDbName(dbName);
Job[] jobs = Job.getJobManager().find(jobFamily);
if (jobs.length > 0) {
CommonUITool.openWarningBox(Messages.bind(Messages.msgStartDbWithJob, dbName));
continue;
}
startList.add(database);
}
CubridNavigatorView navigationView = CubridNavigatorView.findNavigationView();
if (navigationView != null && startList.size() > 0) {
final TreeViewer treeViewer = navigationView.getViewer();
TaskExecutor taskExcutor = new TaskExecutor() {
public boolean exec(final IProgressMonitor monitor) {
Display display = Display.getDefault();
if (monitor.isCanceled()) {
return false;
}
for (int i = 0; i < taskList.size(); i++) {
ITask task = taskList.get(i);
final CubridDatabase database = (CubridDatabase) task.getData("dbName");
if (!isSupported(database)) {
continue;
}
monitor.subTask(Messages.bind(Messages.startDbTaskName, database.getName()));
task.execute();
if (openErrorBox(shell, task.getErrorMsg(), monitor) || monitor.isCanceled()) {
return false;
}
openWarningBox(shell, task.getWarningMsg(), monitor);
if (monitor.isCanceled()) {
return false;
}
database.removeAllChild();
if (database.getLoader() != null) {
database.getLoader().setLoaded(false);
}
database.setRunningType(DbRunningType.CS);
display.syncExec(new Runnable() {
public void run() {
treeViewer.refresh(database, true);
}
});
if (monitor.isCanceled()) {
return false;
}
}
return true;
}
};
for (ISchemaNode schemaNode : startList) {
CubridDatabase database = schemaNode.getDatabase();
if (!isSupported(database)) {
setEnabled(false);
return;
}
ServerInfo serverInfo = database.getServer().getServerInfo();
CommonUpdateTask task = new CommonUpdateTask(CommonTaskName.START_DB_TASK_NAME, serverInfo, CommonSendMsg.getCommonDatabaseSendMsg());
task.setDbName(database.getLabel());
task.putData("dbName", database);
taskExcutor.addTask(task);
}
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
ActionManager.getInstance().fireSelectionChanged(getSelection());
}
}
use of com.cubrid.cubridmanager.core.common.task.CommonUpdateTask in project cubrid-manager by CUBRID.
the class StopSlaveDbAction method run.
/**
* Stop database and refresh navigator
*/
public void run() {
Object[] obj = this.getSelectedObj();
if (!isSupported(obj[0])) {
setEnabled(false);
return;
}
final ISchemaNode schemaNode = (ISchemaNode) obj[0];
ReplicationInfo replInfo = (ReplicationInfo) schemaNode.getAdapter(ReplicationInfo.class);
Set<CubridDatabase> databaseSet = new HashSet<CubridDatabase>();
for (int j = 0; j < replInfo.getSlaveList().size(); j++) {
CubridDatabase database = StartSlaveDbAction.getDatabaseByName(schemaNode.getParent(), replInfo.getSlaveList().get(j).getSlaveDbName());
databaseSet.add(database);
}
StringBuffer dbNamesBuffer = new StringBuffer("");
Iterator<SlaveInfo> it = replInfo.getSlaveList().iterator();
while (it.hasNext()) {
dbNamesBuffer.append(it.next().getSlaveDbName()).append(",");
}
String dbNames = dbNamesBuffer.toString().substring(0, dbNamesBuffer.toString().length() - 1);
boolean isStop = CommonUITool.openConfirmBox(getShell(), Messages.bind(Messages.msgConfirmStopDatabase, dbNames));
if (!isStop) {
return;
}
final Object[] dbObjectArr = new Object[databaseSet.size()];
databaseSet.toArray(dbObjectArr);
ISelectionProvider provider = getSelectionProvider();
final Shell shell = getShell();
if (provider instanceof TreeViewer && dbObjectArr.length > 0) {
final TreeViewer viewer = (TreeViewer) provider;
TaskExecutor taskExcutor = new TaskExecutor() {
public boolean exec(final IProgressMonitor monitor) {
Display display = Display.getDefault();
if (monitor.isCanceled()) {
return false;
}
for (int i = 0; i < taskList.size(); i++) {
ISchemaNode node = (ISchemaNode) dbObjectArr[i];
final CubridDatabase database = node.getDatabase();
ITask task = taskList.get(i);
task.execute();
final String msg = task.getErrorMsg();
if (openErrorBox(shell, msg, monitor)) {
return false;
}
if (monitor.isCanceled()) {
return false;
}
database.removeAllChild();
if (database.getLoader() != null) {
database.getLoader().setLoaded(false);
}
database.setRunningType(DbRunningType.STANDALONE);
display.syncExec(new Runnable() {
public void run() {
viewer.refresh(database, true);
}
});
if (monitor.isCanceled()) {
return false;
}
}
return true;
}
};
for (int i = 0; i < dbObjectArr.length; i++) {
ISchemaNode node = (ISchemaNode) dbObjectArr[i];
CubridDatabase database = node.getDatabase();
CommonUpdateTask task = new CommonUpdateTask(CommonTaskName.STOP_DB_TASK_NAME, database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg());
task.setDbName(database.getLabel());
taskExcutor.addTask(task);
}
new ExecTaskWithProgress(taskExcutor).exec();
if (taskExcutor.isSuccess()) {
for (int i = 0; i < dbObjectArr.length; i++) {
CubridDatabase database = (CubridDatabase) dbObjectArr[i];
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_STOP));
}
ActionManager.getInstance().fireSelectionChanged(getSelection());
}
}
}
Aggregations