Search in sources :

Example 51 with CommonQueryTask

use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.

the class LockDbTaskTest method testLockDbLocked.

public void testLockDbLocked() {
    if (StringUtil.isEqual(SystemParameter.getParameterValue("useMockTest"), "n"))
        return;
    System.out.println("<database.lockdb.002.req.txt>");
    CommonQueryTask<DatabaseLockInfo> task = new CommonQueryTask<DatabaseLockInfo>(ServerManager.getInstance().getServer(host, monport, userName), CommonSendMsg.getCommonDatabaseSendMsg(), new DatabaseLockInfo());
    task.setDbName("lockeddb");
    task.execute();
    assertTrue(task.isSuccess());
    assertNull(task.getErrorMsg());
    DatabaseLockInfo dli = task.getResultModel();
    assertNotNull(dli);
    assertEquals("lockdb", dli.getTaskName());
    LockInfo li = dli.getLockInfo();
    assertNotNull(li);
    assertEquals(1, li.getDinterval());
    assertEquals(100000, li.getEsc());
    List<DatabaseTransaction> dtList = li.getTransaction();
    assertNotNull(dtList);
    assertEquals(4, dtList.size());
    DatabaseTransaction dt = dtList.get(0);
    assertEquals(0, dt.getIndex());
    assertEquals("(unknown)", dt.getPname());
    assertEquals("(unknown)", dt.getUid());
    assertEquals("(unknown)", dt.getHost());
    assertEquals("-1", dt.getPid());
    assertEquals("REPEATABLE CLASSES AND READ UNCOMMITTED INSTANCES", dt.getIsolevel());
    assertEquals(-1, dt.getTimeout());
    dt = dtList.get(1);
    assertEquals(1, dt.getIndex());
    assertEquals("csql", dt.getPname());
    assertEquals("dba", dt.getUid());
    assertEquals("localhost.localdomain", dt.getHost());
    assertEquals("10731", dt.getPid());
    assertEquals("REPEATABLE CLASSES AND READ UNCOMMITTED INSTANCES", dt.getIsolevel());
    assertEquals(-1, dt.getTimeout());
    dt = dtList.get(2);
    assertEquals(2, dt.getIndex());
    assertEquals("csql", dt.getPname());
    assertEquals("dba", dt.getUid());
    assertEquals("localhost.localdomain", dt.getHost());
    assertEquals("10786", dt.getPid());
    assertEquals("REPEATABLE CLASSES AND READ UNCOMMITTED INSTANCES", dt.getIsolevel());
    assertEquals(-1, dt.getTimeout());
    dt = dtList.get(3);
    assertEquals(3, dt.getIndex());
    assertEquals("lockdb", dt.getPname());
    assertEquals("dba", dt.getUid());
    assertEquals("localhost.localdomain", dt.getHost());
    assertEquals("10987", dt.getPid());
    assertEquals("READ COMMITTED CLASSES AND READ UNCOMMITTED INSTANCES", dt.getIsolevel());
    assertEquals(-2, dt.getTimeout());
    DbLotInfo dbLotInfo = li.getDbLotInfo();
    assertNotNull(dbLotInfo);
    assertEquals(2, dbLotInfo.getNumlocked());
    assertEquals(10000, dbLotInfo.getMaxnumlock());
    assertNotNull(dbLotInfo.getDbLotEntryList());
    assertEquals(2, dbLotInfo.getDbLotEntryList().size());
    List<DbLotEntry> dbLotEntryList = dbLotInfo.getDbLotEntryList();
    assertNotNull(dbLotEntryList);
    assertEquals(2, dbLotEntryList.size());
    DbLotEntry dbLotEntry = dbLotEntryList.get(0);
    assertNotNull(dbLotEntry);
    assertEquals("0|354|2", dbLotEntry.getOid());
    assertEquals("Class = dual", dbLotEntry.getOb_type());
    assertEquals(1, dbLotEntry.getNum_holders());
    assertEquals(0, dbLotEntry.getNum_b_holders());
    assertEquals(0, dbLotEntry.getNum_waiters());
    List<LockHolders> lockHolderList = dbLotEntry.getLockHoldersList();
    assertNotNull(lockHolderList);
    assertEquals(1, lockHolderList.size());
    LockHolders lockHolders = lockHolderList.get(0);
    assertNotNull(lockHolders);
    assertEquals(2, lockHolders.getTran_index());
    assertEquals(2, lockHolders.getCount());
    assertEquals("IS_LOCK", lockHolders.getGranted_mode());
    assertEquals(0, lockHolders.getNsubgranules());
    assertNull(dbLotEntry.getBlockHoldersList());
    assertNull(dbLotEntry.getLockWaitersList());
    dbLotEntry = dbLotEntryList.get(1);
    assertNotNull(dbLotEntry);
    assertEquals("0|60|1", dbLotEntry.getOid());
    assertEquals("Root class", dbLotEntry.getOb_type());
    assertEquals(1, dbLotEntry.getNum_holders());
    assertEquals(0, dbLotEntry.getNum_b_holders());
    assertEquals(1, dbLotEntry.getNum_waiters());
    lockHolderList = dbLotEntry.getLockHoldersList();
    assertNotNull(lockHolderList);
    assertEquals(1, lockHolderList.size());
    lockHolders = lockHolderList.get(0);
    assertNotNull(lockHolders);
    assertEquals(2, lockHolders.getTran_index());
    assertEquals(1, lockHolders.getCount());
    assertEquals("IS_LOCK", lockHolders.getGranted_mode());
    assertEquals(1, lockHolders.getNsubgranules());
    assertNull(dbLotEntry.getBlockHoldersList());
    assertNotNull(dbLotEntry.getLockWaitersList());
    List<LockWaiters> lockWaitersList = dbLotEntry.getLockWaitersList();
    assertNotNull(lockWaitersList);
    assertEquals(1, lockWaitersList.size());
    LockWaiters lockWaiters = lockWaitersList.get(0);
    assertEquals("IX_LOCK", lockWaiters.getB_mode());
    assertEquals("Mon Jun 29 21:29:12 2009", lockWaiters.getStart_at());
    assertEquals("-1", lockWaiters.getWaitfornsec());
    assertEquals(1, lockWaiters.getTran_index());
//TODO: need a test for the b_holders attribute
}
Also used : LockHolders(com.cubrid.cubridmanager.core.cubrid.database.model.lock.LockHolders) DatabaseLockInfo(com.cubrid.cubridmanager.core.cubrid.database.model.lock.DatabaseLockInfo) DatabaseTransaction(com.cubrid.cubridmanager.core.cubrid.database.model.lock.DatabaseTransaction) DbLotInfo(com.cubrid.cubridmanager.core.cubrid.database.model.lock.DbLotInfo) DbLotEntry(com.cubrid.cubridmanager.core.cubrid.database.model.lock.DbLotEntry) LockWaiters(com.cubrid.cubridmanager.core.cubrid.database.model.lock.LockWaiters) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) LockInfo(com.cubrid.cubridmanager.core.cubrid.database.model.lock.LockInfo) DatabaseLockInfo(com.cubrid.cubridmanager.core.cubrid.database.model.lock.DatabaseLockInfo)

Example 52 with CommonQueryTask

use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.

the class LockDbTaskTest method testLockDbNoLock.

public void testLockDbNoLock() {
    if (StringUtil.isEqual(SystemParameter.getParameterValue("useMockTest"), "n"))
        return;
    System.out.println("<database.lockdb.001.req.txt>");
    CommonQueryTask<DatabaseLockInfo> task = new CommonQueryTask<DatabaseLockInfo>(ServerManager.getInstance().getServer(host, monport, userName), CommonSendMsg.getCommonDatabaseSendMsg(), new DatabaseLockInfo());
    task.setDbName("unlockeddb");
    task.execute();
    assertTrue(task.isSuccess());
    assertNull(task.getErrorMsg());
    DatabaseLockInfo dli = task.getResultModel();
    assertNotNull(dli);
    assertEquals("lockdb", dli.getTaskName());
    LockInfo li = dli.getLockInfo();
    assertNotNull(li);
    assertEquals(1, li.getDinterval());
    assertEquals(100000, li.getEsc());
    List<DatabaseTransaction> dtList = li.getTransaction();
    assertNotNull(dtList);
    assertEquals(2, dtList.size());
    DatabaseTransaction dt = dtList.get(0);
    assertEquals(0, dt.getIndex());
    assertEquals("(unknown)", dt.getPname());
    assertEquals("(unknown)", dt.getUid());
    assertEquals("(unknown)", dt.getHost());
    assertEquals("-1", dt.getPid());
    assertEquals("REPEATABLE CLASSES AND READ UNCOMMITTED INSTANCES", dt.getIsolevel());
    assertEquals(-1, dt.getTimeout());
    dt = dtList.get(1);
    assertEquals(1, dt.getIndex());
    assertEquals("lockdb", dt.getPname());
    assertEquals("dba", dt.getUid());
    assertEquals("localhost.localdomain", dt.getHost());
    assertEquals("5334", dt.getPid());
    assertEquals("READ COMMITTED CLASSES AND READ UNCOMMITTED INSTANCES", dt.getIsolevel());
    assertEquals(-2, dt.getTimeout());
    DbLotInfo dbLotInfo = li.getDbLotInfo();
    assertNotNull(dbLotInfo);
    assertEquals(0, dbLotInfo.getNumlocked());
    assertEquals(10000, dbLotInfo.getMaxnumlock());
    assertNotNull(dbLotInfo.getDbLotEntryList());
    assertEquals(0, dbLotInfo.getDbLotEntryList().size());
}
Also used : DatabaseLockInfo(com.cubrid.cubridmanager.core.cubrid.database.model.lock.DatabaseLockInfo) DatabaseTransaction(com.cubrid.cubridmanager.core.cubrid.database.model.lock.DatabaseTransaction) DbLotInfo(com.cubrid.cubridmanager.core.cubrid.database.model.lock.DbLotInfo) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) LockInfo(com.cubrid.cubridmanager.core.cubrid.database.model.lock.LockInfo) DatabaseLockInfo(com.cubrid.cubridmanager.core.cubrid.database.model.lock.DatabaseLockInfo)

Example 53 with CommonQueryTask

use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.

the class AddVolumeDbTaskTest method testExecute.

public void testExecute() {
    String dbName = testDbName;
    GetAddVolumeStatusInfo getAddVolumeStatusInfo = new GetAddVolumeStatusInfo();
    final CommonQueryTask<GetAddVolumeStatusInfo> statusTask = new CommonQueryTask<GetAddVolumeStatusInfo>(serverInfo, CommonSendMsg.getCommonDatabaseSendMsg(), getAddVolumeStatusInfo);
    statusTask.setDbName(dbName);
    statusTask.execute();
    getAddVolumeStatusInfo = statusTask.getResultModel();
    assertNotNull(getAddVolumeStatusInfo);
    String volpath = getAddVolumeStatusInfo.getVolpath();
    assertNotNull(volpath);
    AddVolumeDbInfo addVolumeDbInfo = new AddVolumeDbInfo();
    addVolumeDbInfo.setDbname(dbName);
    addVolumeDbInfo.setPurpose("generic");
    addVolumeDbInfo.setPath(volpath);
    addVolumeDbInfo.setSize_need_mb("40");
    addVolumeDbInfo.setNumberofpage("10000");
    AddVolumeDbTask addTask = new AddVolumeDbTask(serverInfo);
    addTask.setDbname(dbName);
    addTask.setVolname(addVolumeDbInfo.getVolname());
    addTask.setPurpose(addVolumeDbInfo.getPurpose());
    addTask.setPath(addVolumeDbInfo.getPath());
    addTask.setNumberofpages(addVolumeDbInfo.getNumberofpage());
    addTask.setSizeNeedMb(addVolumeDbInfo.getSize_need_mb());
    //addTask.execute();
    assertNull(addTask.getErrorMsg());
}
Also used : AddVolumeDbInfo(com.cubrid.cubridmanager.core.cubrid.dbspace.model.AddVolumeDbInfo) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) GetAddVolumeStatusInfo(com.cubrid.cubridmanager.core.cubrid.dbspace.model.GetAddVolumeStatusInfo)

Example 54 with CommonQueryTask

use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.

the class GetDbSpaceInfoTaskTest method testSendMessage.

public void testSendMessage() {
    if (StringUtil.isEqual(SystemParameter.getParameterValue("useMockTest"), "y"))
        return;
    CommonQueryTask<DbSpaceInfoList> task = new CommonQueryTask<DbSpaceInfoList>(serverInfo, CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoList());
    task.setDbName(testDbName);
    task.setUsingSpecialDelimiter(false);
    task.execute();
    DbSpaceInfoList bean = task.getResultModel();
    assertEquals(null, task.getErrorMsg());
    System.out.println(task.getErrorMsg());
    assertEquals(testDbName, bean.getDbname());
    // test children
    assertEquals(true, bean.getSpaceinfo().size() > 0);
    System.out.println("------------the result of task:dbspaceinfo in JSON-----------------");
    System.out.println(JsonObjectUtil.object2json(bean));
    System.out.println("-------------------------------------------------------------------");
}
Also used : DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask)

Example 55 with CommonQueryTask

use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.

the class TransactionInfoDialog method loadData.

/**
	 * load the init data from the server
	 *
	 * @param shell the shell
	 * @return <code>true</code> if it is valid;<code>false</code>otherwise
	 */
public boolean loadData(Shell shell) {
    CommonQueryTask<DbTransactionList> task = new CommonQueryTask<DbTransactionList>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbTransactionList());
    task.setDbName(database.getName());
    DbUserInfo userInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
    if (userInfo != null) {
        task.setDbUser(userInfo.getName() == null ? "" : userInfo.getName());
        task.setDbpasswd(userInfo.getNoEncryptPassword() == null ? "" : userInfo.getNoEncryptPassword());
    }
    execTask(-1, new SocketTask[] { task }, true, shell);
    if (task.getErrorMsg() != null) {
        return false;
    }
    setDbTransactionList(task.getResultModel());
    return true;
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) DbTransactionList(com.cubrid.cubridmanager.core.cubrid.database.model.transaction.DbTransactionList) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask)

Aggregations

CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)60 DbSpaceInfoList (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)19 ITask (com.cubrid.common.core.task.ITask)14 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)12 IStatus (org.eclipse.core.runtime.IStatus)12 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)11 TaskJobExecutor (com.cubrid.common.ui.spi.progress.TaskJobExecutor)11 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)11 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)8 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)7 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)7 CommonTaskJobExec (com.cubrid.common.ui.spi.progress.CommonTaskJobExec)7 ArrayList (java.util.ArrayList)7 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)6 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)6 ITaskExecutorInterceptor (com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor)6 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)6 LogInfo (com.cubrid.cubridmanager.core.logs.model.LogInfo)6 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)5 GetBrokerConfParameterTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask)5