Search in sources :

Example 1 with DbTransactionList

use of com.cubrid.cubridmanager.core.cubrid.database.model.transaction.DbTransactionList in project cubrid-manager by CUBRID.

the class DatabaseDashboardEditor method loadTransactionInfo.

/**
	 * load lock and transaction information
	 */
public void loadTransactionInfo() {
    //if database is stop, do not get data
    if (database.getRunningType() != DbRunningType.CS) {
        return;
    }
    final CommonQueryTask<DatabaseLockInfo> getLockInfotask = new CommonQueryTask<DatabaseLockInfo>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DatabaseLockInfo());
    getLockInfotask.setDbName(database.getName());
    final CommonQueryTask<DbTransactionList> getTransactionTask = new CommonQueryTask<DbTransactionList>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbTransactionList());
    getTransactionTask.setDbName(database.getName());
    new Thread(new Runnable() {

        public void run() {
            getLockInfotask.execute();
            if (!getLockInfotask.isSuccess()) {
                getLockInfotask.finish();
                return;
            }
            getTransactionTask.execute();
            if (!getTransactionTask.isSuccess()) {
                getTransactionTask.finish();
                return;
            }
            Display.getDefault().asyncExec(new Runnable() {

                public void run() {
                    process();
                }
            });
        }

        private void process() {
            lockAndTransactionListData.clear();
            databaseLockInfo = getLockInfotask.getResultModel();
            LockInfo lockInfo = databaseLockInfo.getLockInfo();
            if (lockInfo == null) {
                return;
            }
            DbLotInfo dbLotInfo = lockInfo.getDbLotInfo();
            if (dbLotInfo == null) {
                return;
            }
            if (dbLotInfo.getDbLotEntryList() != null) {
                //get Lock
                for (DbLotEntry dbLot : dbLotInfo.getDbLotEntryList()) {
                    Map<String, String> map = new HashMap<String, String>();
                    if (dbLot.getLockHoldersList() != null) {
                        lockAndTransactionListData.add(map);
                        map.put("4", dbLot.getOb_type());
                        //get lock holder
                        for (int i = 0; i < dbLot.getLockHoldersList().size(); i++) {
                            LockHolders lockHolders = dbLot.getLockHoldersList().get(i);
                            //add mode to the last mode
                            String previousMode = map.get("5");
                            if (i != 0 && previousMode != null) {
                                previousMode += ",";
                            }
                            if (previousMode != null) {
                                previousMode += lockHolders.getGranted_mode();
                            } else {
                                previousMode = lockHolders.getGranted_mode();
                            }
                            map.put("5", previousMode);
                            //get DatabaseTransaction which id is equlas lock holder tranid
                            for (DatabaseTransaction tran : lockInfo.getTransaction()) {
                                if (tran.getIndex() == lockHolders.getTran_index()) {
                                    map.put("0", Integer.toString(tran.getIndex()));
                                    map.put("1", tran.getUid());
                                    map.put("2", tran.getHost());
                                    map.put("3", tran.getPid());
                                }
                            }
                        }
                    }
                }
            }
            setTransactionInfoData();
            getLockInfotask.finish();
            getTransactionTask.finish();
        }
    }).start();
}
Also used : LockHolders(com.cubrid.cubridmanager.core.cubrid.database.model.lock.LockHolders) DatabaseLockInfo(com.cubrid.cubridmanager.core.cubrid.database.model.lock.DatabaseLockInfo) HashMap(java.util.HashMap) DbLotInfo(com.cubrid.cubridmanager.core.cubrid.database.model.lock.DbLotInfo) DatabaseTransaction(com.cubrid.cubridmanager.core.cubrid.database.model.lock.DatabaseTransaction) DbLotEntry(com.cubrid.cubridmanager.core.cubrid.database.model.lock.DbLotEntry) DbTransactionList(com.cubrid.cubridmanager.core.cubrid.database.model.transaction.DbTransactionList) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) DatabaseLockInfo(com.cubrid.cubridmanager.core.cubrid.database.model.lock.DatabaseLockInfo) LockInfo(com.cubrid.cubridmanager.core.cubrid.database.model.lock.LockInfo)

Example 2 with DbTransactionList

use of com.cubrid.cubridmanager.core.cubrid.database.model.transaction.DbTransactionList in project cubrid-manager by CUBRID.

the class TransactionInfoDialog method killTransaction.

/**
	 *
	 * Kill the transaction
	 *
	 * @param type the transaction type
	 * @param parameter the parameter
	 */
private void killTransaction(KillTranType type, String parameter) {
    CommonQueryTask<KillTransactionList> task = new CommonQueryTask<KillTransactionList>(database.getServer().getServerInfo(), CommonSendMsg.getKillTransactionMSGItems(), new KillTransactionList());
    task.setDbName(database.getName());
    task.setKillTranType(type);
    task.setKillTranParameter(parameter);
    execTask(-1, new SocketTask[] { task }, true, getShell());
    if (task.getErrorMsg() != null) {
        return;
    }
    CommonUITool.openInformationBox(parentComp.getShell(), Messages.titleSuccess, Messages.msgKillSuccess);
    KillTransactionList killTransactionList = task.getResultModel();
    DbTransactionList dbDbTransactionList = new DbTransactionList();
    dbDbTransactionList.setTransationInfo(killTransactionList.getTransationInfo());
    setDbTransactionList(dbDbTransactionList);
}
Also used : DbTransactionList(com.cubrid.cubridmanager.core.cubrid.database.model.transaction.DbTransactionList) KillTransactionList(com.cubrid.cubridmanager.core.cubrid.database.model.transaction.KillTransactionList) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask)

Example 3 with DbTransactionList

use of com.cubrid.cubridmanager.core.cubrid.database.model.transaction.DbTransactionList 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)3 DbTransactionList (com.cubrid.cubridmanager.core.cubrid.database.model.transaction.DbTransactionList)3 DatabaseLockInfo (com.cubrid.cubridmanager.core.cubrid.database.model.lock.DatabaseLockInfo)1 DatabaseTransaction (com.cubrid.cubridmanager.core.cubrid.database.model.lock.DatabaseTransaction)1 DbLotEntry (com.cubrid.cubridmanager.core.cubrid.database.model.lock.DbLotEntry)1 DbLotInfo (com.cubrid.cubridmanager.core.cubrid.database.model.lock.DbLotInfo)1 LockHolders (com.cubrid.cubridmanager.core.cubrid.database.model.lock.LockHolders)1 LockInfo (com.cubrid.cubridmanager.core.cubrid.database.model.lock.LockInfo)1 KillTransactionList (com.cubrid.cubridmanager.core.cubrid.database.model.transaction.KillTransactionList)1 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)1 HashMap (java.util.HashMap)1