use of com.cubrid.cubridmanager.core.cubrid.database.model.lock.LockHolders 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();
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.lock.LockHolders in project cubrid-manager by CUBRID.
the class LockInfoDetailDialog method initial.
/**
*
* Initial data
*
*/
private void initial() {
if (dbLotEntry == null) {
return;
}
if (dbLotEntry.getLockHoldersList() != null) {
for (LockHolders bean : dbLotEntry.getLockHoldersList()) {
Map<String, String> map = new HashMap<String, String>();
map.put("0", String.valueOf(bean.getTran_index()));
map.put("1", bean.getGranted_mode());
map.put("2", String.valueOf(bean.getCount()));
map.put("3", String.valueOf(bean.getNsubgranules()));
lockHolderListData.add(map);
}
lockHolderTableViewer.refresh();
for (int i = 0; i < lockHolderTable.getColumnCount(); i++) {
lockHolderTable.getColumn(i).pack();
}
}
if (dbLotEntry.getBlockHoldersList() != null) {
for (BlockedHolders bean : dbLotEntry.getBlockHoldersList()) {
Map<String, String> map = new HashMap<String, String>();
map.put("0", String.valueOf(bean.getTran_index()));
map.put("1", bean.getGranted_mode());
map.put("2", String.valueOf(bean.getCount()));
map.put("3", String.valueOf(bean.getBlocked_mode()));
map.put("4", String.valueOf(bean.getStart_at()));
map.put("5", String.valueOf(bean.getWait_for_sec()));
blockedHolderListData.add(map);
}
blockedHolderTableViewer.refresh();
for (int i = 0; i < blockedHolderTable.getColumnCount(); i++) {
blockedHolderTable.getColumn(i).pack();
}
}
if (dbLotEntry.getLockWaitersList() != null) {
for (LockWaiters bean : dbLotEntry.getLockWaitersList()) {
Map<String, String> map = new HashMap<String, String>();
map.put("0", String.valueOf(bean.getTran_index()));
map.put("1", bean.getB_mode());
map.put("2", String.valueOf(bean.getStart_at()));
map.put("3", String.valueOf(bean.getWaitfornsec()));
lockWaiterListData.add(map);
}
lockWaiterTableViewer.refresh();
for (int i = 0; i < lockWaiterTable.getColumnCount(); i++) {
lockWaiterTable.getColumn(i).pack();
}
}
objectIdLabel.setText(Messages.bind(Messages.lblObjectId, dbLotEntry.getOid()));
objectTypeLabel.setText(Messages.bind(Messages.lblObjectType, dbLotEntry.getOb_type()));
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.lock.LockHolders 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
}
Aggregations