📄 timeout.java
字号:
sb.append( outputRow ); sb.append( newline ); } else { sb.append( "*** A latch/lock, " + currentLock + ", exist in the lockTable that cannot be printed ***" ); sb.append( newline ); } } for( i = 0; i < LENGTHOFTABLE; i++ ) sb.append( LINE ); sb.append( newline ); } return sb.toString(); } /** * The static entry way to get the LockTable in the system. * @param timeoutLock The Latch that the timeout happened on * @param table The lockTable * @param time The time when the lockTable was cloned * @return StandardException The exception with the lockTable snapshot in it */ static StandardException buildException( Latch timeoutLock, Enumeration table, long time ) { Timeout myTimeout = new Timeout( timeoutLock, table, time ); return myTimeout.createException(); } /* * A static entry way to get the LockTable in the system. * For track 3311 */ public static String buildString( Enumeration table, long time ) throws StandardException { Timeout myTimeout = new Timeout( null, table, time); return myTimeout.buildLockTableString(); } /** * dumpLock puts information about currentLock into currentRow for output later. * @throws StandardException */ private void dumpLock() throws StandardException { Hashtable attributes = new Hashtable(17); Object lock_type = currentLock.getQualifier(); // want containerId, segmentId, pageNum, recId from locktable Lockable lockable = currentLock.getLockable(); // See if the lockable object wants to participate if( !lockable.lockAttributes(ALL, attributes) ) { currentRow = null; return; } // if it does, the lockable object must have filled in the following // fields if( SanityManager.DEBUG ) { SanityManager.ASSERT(attributes.get(VirtualLockTable.LOCKNAME) != null, "lock table can only represent locks that have a LOCKNAME" ); SanityManager.ASSERT(attributes.get(VirtualLockTable.LOCKTYPE) != null, "lock table can only represent locks that have a LOCKTYPE" ); if( attributes.get(VirtualLockTable.CONTAINERID ) == null && attributes.get(VirtualLockTable.CONGLOMID ) == null ) SanityManager.THROWASSERT("lock table can only represent locks that are associated with a container or conglomerate"); } Long conglomId = (Long) attributes.get(VirtualLockTable.CONGLOMID); if( conglomId == null ) { if( attributes.get(VirtualLockTable.CONTAINERID) != null && tc != null ) { Long value = (Long)attributes.get(VirtualLockTable.CONTAINERID); conglomId = new Long( tc.findConglomid( value.longValue() ) ); attributes.put( VirtualLockTable.CONGLOMID, conglomId ); } } Long containerId = (Long) attributes.get(VirtualLockTable.CONTAINERID); if( containerId == null ) { if( conglomId != null && tc != null ) { try { containerId = new Long( tc.findContainerid( conglomId.longValue() ) ); attributes.put( VirtualLockTable.CONTAINERID, containerId ); } catch( Exception e ) { // just don't do anything } } } attributes.put( VirtualLockTable.LOCKOBJ, currentLock ); attributes.put( VirtualLockTable.XACTID, currentLock.getCompatabilitySpace().toString() ); attributes.put( VirtualLockTable.LOCKMODE, lock_type.toString() ); attributes.put( VirtualLockTable.LOCKCOUNT, Integer.toString( currentLock.getCount() ) ); attributes.put( VirtualLockTable.STATE, (currentLock.getCount() != 0 ) ? "GRANT" : "WAIT" ); if( tabInfo != null && conglomId != null ) { try{ String tableName = tabInfo.getTableName( conglomId ); attributes.put( VirtualLockTable.TABLENAME, tableName ); } catch( NullPointerException e ) { attributes.put( VirtualLockTable.TABLENAME, conglomId ); } try { String indexName = tabInfo.getIndexName( conglomId ); if( indexName != null ) attributes.put( VirtualLockTable.INDEXNAME, indexName ); else { if( attributes.get(VirtualLockTable.LOCKTYPE).equals("LATCH") ) { // because MODE field is way to short to display this, // just put it in the indexname field for LATCH only. attributes.put( VirtualLockTable.INDEXNAME, attributes.get(VirtualLockTable.LOCKMODE) ); } else attributes.put( VirtualLockTable.INDEXNAME, "NULL" ); } }catch( Exception e ) { // we are here because tabInfo.indexCache is null if( VirtualLockTable.CONTAINERID != null ) attributes.put( VirtualLockTable.INDEXNAME, VirtualLockTable.CONTAINERID ); else attributes.put( VirtualLockTable.INDEXNAME, "NULL" ); } String tableType = tabInfo.getTableType( conglomId ); attributes.put( VirtualLockTable.TABLETYPE, tableType ); } else { if( conglomId != null ) attributes.put( VirtualLockTable.TABLENAME, VirtualLockTable.CONGLOMID ); else attributes.put( VirtualLockTable.TABLENAME, "NULL" ); if( VirtualLockTable.CONTAINERID != null ) attributes.put( VirtualLockTable.INDEXNAME, VirtualLockTable.CONTAINERID ); else attributes.put( VirtualLockTable.INDEXNAME, "NULL" ); attributes.put( VirtualLockTable.TABLETYPE, currentLock.toString() ); } currentRow = attributes; } /** * cpArray helps built the output string (outputRow). * @param toCp the String to be copied into outputRow * @param start the start place * @param end the end place */ private void cpArray( String toCp, int start, int end ) { // build a field in the output string int i = 0; int totalAllowWrite = end - start; if( toCp != null ) { for( ; i < toCp.length() ; i++ ) { if( (totalAllowWrite-i) == 0 ) break; outputRow[ i + start ] = toCp.charAt(i); } } for( ; i + start != end; i++ ) outputRow[ i + start ] = ' '; outputRow[ end ] = SEPARATOR; } /** * Copies the needed information from currentRow into the StringBuffer for output * @return true if successful */ private boolean timeoutInfoHash( ) { if( currentRow == null ) return false; String[] myData = new String[9]; myData[0] = VirtualLockTable.XACTID; myData[1] = VirtualLockTable.LOCKTYPE; myData[2] = VirtualLockTable.LOCKMODE; myData[3] = VirtualLockTable.LOCKCOUNT; myData[4] = VirtualLockTable.LOCKNAME; myData[5] = VirtualLockTable.STATE; myData[6] = VirtualLockTable.TABLETYPE; myData[7] = VirtualLockTable.INDEXNAME; myData[8] = VirtualLockTable.TABLENAME; int currentLength = 0; for( int i = 0; i < myData.length; i++ ) { cpArray( currentRow.get( myData[i] ).toString(), currentLength , currentLength + column[i].length() ); // the next beginning position currentLength = currentLength + column[i].length() + 1; } return true; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -