idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
159,700
private void rightSearch ( SearchComparator comp , GBSNode p , GBSNode l , Object searchKey , SearchNode point ) { int xcc = comp . compare ( searchKey , p . rightMostKey ( ) ) ; if ( xcc == 0 ) /* Target is right-most key in current */ point . setFound ( p , 0 ) ; else if ( xcc < 0 ) /* Target (if it exists) is in right */ { /* half of current node */ int idx = p . searchRight ( comp , searchKey ) ; if ( ! ( idx < 0 ) ) point . setFound ( p , idx ) ; } else /* Target (if it exists) is in left */ { /* half of successor (if it exists) */ if ( l != null ) { int idx = l . searchLeft ( comp , searchKey ) ; if ( ! ( idx < 0 ) ) point . setFound ( l , idx ) ; } } }
Search after falling off a right edge .
208
8
159,701
private InsertStack getInsertStack ( ) { Object x = _insertStack . get ( ) ; InsertStack g = null ; if ( x != null ) { g = ( InsertStack ) x ; g . reset ( ) ; } else { g = new InsertStack ( this ) ; x = ( Object ) g ; _insertStack . set ( x ) ; } return g ; }
Find an InsertStack for use by the current thread .
80
11
159,702
public boolean insert ( Object new1 ) { boolean result ; InsertStack stack = getInsertStack ( ) ; if ( root ( ) == null ) pessimisticInsert ( stack , new1 ) ; else { boolean didit = optimisticInsert ( stack , new1 ) ; if ( didit == pessimisticNeeded ) pessimisticInsert ( stack , new1 ) ; } if ( stack . isDuplicate ( ) ) result = false ; else result = true ; return result ; }
Insert into a GBS Tree .
97
7
159,703
private boolean optimisticInsert ( InsertStack stack , Object new1 ) { InsertNodes point = stack . insertNodes ( ) ; int v1 = _vno ; if ( root ( ) == null ) return pessimisticNeeded ; if ( ( v1 & 1 ) != 0 ) return pessimisticNeeded ; synchronized ( stack ) { } try { findInsert ( point , stack , new1 ) ; } catch ( NullPointerException npe ) { //No FFDC Code Needed. _nullPointerExceptions ++ ; return checkForPossibleIndexChange ( v1 , _vno , npe , "optimisticInsert" ) ; } catch ( OptimisticDepthException ode ) { //No FFDC Code Needed. _optimisticDepthExceptions ++ ; return checkForPossibleIndexChange ( v1 , _vno , ode , "optimisticInsert" ) ; } synchronized ( this ) { if ( v1 != _vno ) { _optimisticInsertSurprises ++ ; return pessimisticNeeded ; } _optimisticInserts ++ ; if ( point . isDuplicate ( ) ) stack . markDuplicate ( ) ; else { _vno ++ ; if ( ( _vno & 1 ) == 1 ) { finishInsert ( point , stack , new1 ) ; _population ++ ; } synchronized ( stack ) { } _vno ++ ; } } // synchronized(this) return optimisticWorked ; }
Optimistic insert into a GBS Tree .
304
10
159,704
private synchronized boolean pessimisticInsert ( InsertStack stack , Object new1 ) { _vno ++ ; if ( ( _vno & 1 ) == 1 ) { if ( root ( ) == null ) { addFirstNode ( new1 ) ; _population ++ ; } else { InsertNodes point = stack . insertNodes ( ) ; findInsert ( point , stack , new1 ) ; if ( point . isDuplicate ( ) ) stack . markDuplicate ( ) ; else { finishInsert ( point , stack , new1 ) ; _population ++ ; } } } synchronized ( stack ) { } _vno ++ ; _pessimisticInserts ++ ; return optimisticWorked ; }
Pessimistic insert into a GBS Tree .
146
10
159,705
private void findInsert ( InsertNodes point , InsertStack stack , Object new1 ) { java . util . Comparator comp = insertComparator ( ) ; NodeInsertPoint ip = stack . nodeInsertPoint ( ) ; GBSNode p ; /* P is used to march down the tree */ int xcc ; /* Compare result */ GBSNode l_last = null ; /* Node from which we last departed by */ /* turning left (logical successor) */ GBSNode r_last = null ; /* Node from which we last departed by */ /* turning right (logical predecessor) */ p = root ( ) ; /* Root of tree */ /* Remember father of root */ stack . start ( dummyTopNode ( ) , "GBSTree.findInsert" ) ; for ( ; ; ) /* Through the whole tree */ { xcc = comp . compare ( new1 , p . middleKey ( ) ) ; if ( ! ( xcc > 0 ) ) /* New key <= node key */ { GBSNode leftChild = p . leftChild ( ) ; if ( leftChild != null ) /* Have a left child */ { l_last = p ; /* Remember node from which we */ /* last moved left (successor) */ stack . balancedPush ( NodeStack . PROCESS_CURRENT , p ) ; p = leftChild ; /* Move left */ } else /* Have no left child */ { leftAdd ( /* Add a left child */ p , /* Current node */ r_last , /* Node from which we last turned right */ new1 , /* Key to add */ ip , /* NodeInsertPoint */ point ) ; /* Returned InsertNodes */ break ; } } else /* New key > node key */ { GBSNode rightChild = p . rightChild ( ) ; if ( rightChild != null ) /* There is a right child */ { r_last = p ; /* Remember node from which we */ /* last moved right (predecessor) */ stack . balancedPush ( NodeStack . DONE_VISITS , p ) ; p = rightChild ; /* Move right */ } else /* There is no right child */ { rightAdd ( /* Add a right child */ p , /* Current node */ l_last , /* Node from which we last turned left */ new1 , /* Key to add */ ip , /* NodeInsertPoint */ point ) ; /* Returned InsertNodes */ break ; } } } // for }
Find the insert point within the tree .
506
8
159,706
private void leftAdd ( GBSNode p , GBSNode r , Object new1 , NodeInsertPoint ip , InsertNodes point ) { if ( r == null ) /* There is no upper predecessor */ leftAddNoPredecessor ( p , new1 , ip , point ) ; else /* There is an upper predecessor */ leftAddWithPredecessor ( p , r , new1 , ip , point ) ; }
Add to predecssor or current .
88
8
159,707
private void leftAddNoPredecessor ( GBSNode p , Object new1 , NodeInsertPoint ip , InsertNodes point ) { p . findInsertPointInLeft ( new1 , ip ) ; point . setInsert ( p , ip ) ; }
Add to left side with no predecessor present .
54
9
159,708
private void leftAddWithPredecessor ( GBSNode p , GBSNode r , Object new1 , NodeInsertPoint ip , InsertNodes point ) { java . util . Comparator comp = r . insertComparator ( ) ; int xcc = comp . compare ( new1 , r . rightMostKey ( ) ) ; if ( xcc > 0 ) /* If key exists it is in left part */ { /* of current node */ p . findInsertPointInLeft ( new1 , ip ) ; point . setInsert ( p , ip ) ; } else /* If key exists it is in right part */ { /* of predecessor node */ r . findInsertPointInRight ( new1 , ip ) ; if ( ip . isDuplicate ( ) ) /* Key is a duplicate */ point . setInsert ( r , ip ) ; else /* Key is not a duplicate */ { point . setInsertAndPosition ( p , - 1 , r , ip . insertPoint ( ) ) ; point . setRight ( ) ; } } }
Add to left side with an upper predecessor present .
217
10
159,709
private void rightAdd ( GBSNode p , GBSNode l , Object new1 , NodeInsertPoint ip , InsertNodes point ) { if ( l == null ) /* There is no upper successor */ rightAddNoSuccessor ( p , new1 , ip , point ) ; else /* There is an upper successor */ rightAddWithSuccessor ( p , l , new1 , ip , point ) ; }
Add to current or successor .
86
6
159,710
private void rightAddNoSuccessor ( GBSNode p , Object new1 , NodeInsertPoint ip , InsertNodes point ) { if ( p . lessThanHalfFull ( ) ) /* Node not even half full so the insert */ /* point now is high key of current */ point . setInsert ( p , p . rightMostIndex ( ) ) ; else /* Keys exist beyond the median */ { /* Must look for insert point */ p . findInsertPointInRight ( new1 , ip ) ; point . setInsert ( p , ip ) ; } }
Add to right side with no upper successor present .
117
10
159,711
private void rightAddWithSuccessor ( GBSNode p , GBSNode l , Object new1 , NodeInsertPoint ip , InsertNodes point ) { java . util . Comparator comp = l . insertComparator ( ) ; int xcc = comp . compare ( new1 , l . leftMostKey ( ) ) ; if ( xcc < 0 ) /* If key exists it is in right part */ { /* of current node */ if ( p . lessThanHalfFull ( ) ) /* Node not even half full so the insert */ /* point now is high key of current */ point . setInsert ( p , p . rightMostIndex ( ) ) ; else /* Keys exist beyond the median */ { /* Must look for insert point */ p . findInsertPointInRight ( new1 , ip ) ; point . setInsert ( p , ip ) ; } } else /* If key exists it is in left part */ { /* of upper successor */ l . findInsertPointInLeft ( new1 , ip ) ; if ( ip . isDuplicate ( ) ) /* Key is a duplicate */ point . setInsert ( l , ip ) ; else /* Key is not a duplicate */ { point . setInsertAndPosition ( p , p . rightMostIndex ( ) , l , ip . insertPoint ( ) ) ; point . setLeft ( ) ; } } }
Add to right side with an upper successor present .
285
10
159,712
private void finishInsert ( InsertNodes point , InsertStack stack , Object new1 ) { Object insertKey = new1 ; if ( point . positionNode ( ) != null ) { GBSNode p = point . positionNode ( ) ; int ix = point . positionIndex ( ) ; if ( point . rightSide ( ) ) insertKey = p . insertByRightShift ( ix , insertKey ) ; else insertKey = p . insertByLeftShift ( ix , insertKey ) ; } /* If the insert point is at the right-most slot in a full node */ /* then we migrate the new key into the fringe. */ Object migrateKey = null ; if ( point . insertIndex ( ) == point . insertNode ( ) . topMostIndex ( ) ) migrateKey = insertKey ; else /* Insert within existing node */ migrateKey = /* Which may migrate a key out of it */ point . insertNode ( ) . insertByRightShift ( point . insertIndex ( ) , insertKey ) ; insertFringeMigrate ( stack , point . insertNode ( ) , migrateKey ) ; }
Do the write phase of the insert .
232
8
159,713
private void insertFringeMigrate ( InsertStack stack , GBSNode p , Object mkey ) { GBSNode endp = p ; int endIndex = stack . index ( ) ; /* Maximum number of right child nodes */ /* before the fringe must be rebalanced */ int maxBal = maximumFringeImbalance ( ) ; stack . setMigratingKey ( mkey ) ; if ( mkey != null ) /* Have a key to migrate */ { stack . processSubFringe ( p ) ; /* See InsertStack.processNode */ endp = stack . lastNode ( ) ; endIndex = stack . lastIndex ( ) ; } if ( stack . migrating ( ) ) /* Need a right child for migrating key */ { _xno ++ ; endp . addRightLeaf ( stack . migratingKey ( ) ) ; } insertCheckFringeBalance ( stack , endp , endIndex , maxBal ) ; }
Migrate a key from a partial leaf through to the proper place in its fringe adding a node to the right side of the fringe if necessary .
197
29
159,714
private void insertCheckFringeBalance ( InsertStack stack , GBSNode endp , int endIndex , int maxBal ) { GBSNode fpoint = null ; /* This points to the first half leaf we */ /* find that has a right child but no */ /* left child. If any rebalancing is */ /* to be done to a fringe, this will be */ /* the fringe balance point. */ int fDepth = 0 ; /* Fringe balance depth */ int fpidx = 0 ; /* Index into NodeStack where fpoint was */ /* last saved */ /* Check to see if we have filled out a final node, which may have */ /* filled out a fringe to the re-balance point. The absence of a */ /* left child means it is part of a fringe. If this is the case we */ /* walk backward through the tree looking for the top of the fringe. */ if ( ( endp . isFull ( ) ) && ( endp . leftChild ( ) == null ) ) { fDepth = 1 ; /* Last node counts as one */ for ( int j = endIndex ; j > 0 ; j -- ) { GBSNode q = stack . node ( j ) ; if ( q . leftChild ( ) != null ) /* Found the top of the fringe */ break ; else /* Not yet the top of the fringe */ { fDepth ++ ; /* Bump fringe depth */ fpoint = q ; /* Remember possible fringe balance point*/ fpidx = j ; /* and its index in the stack */ } } if ( fDepth >= maxBal ) { _xno ++ ; GBSInsertFringe . singleInstance ( ) . balance ( kFactor ( ) , stack , fpoint , fpidx , maxBal ) ; } } }
Check to see if fringe balancing is necessary and do it if needed .
368
14
159,715
private DeleteStack getDeleteStack ( ) { Object x = _deleteStack . get ( ) ; DeleteStack g = null ; if ( x != null ) { g = ( DeleteStack ) x ; g . reset ( ) ; } else { g = new DeleteStack ( this ) ; x = ( Object ) g ; _deleteStack . set ( x ) ; } return g ; }
Find a DeleteStack for use by the current thread .
80
11
159,716
private boolean optimisticDelete ( DeleteStack stack , Object deleteKey ) { DeleteNode point = stack . deleteNode ( ) ; int v1 = _vno ; if ( ( v1 & 1 ) != 0 ) return pessimisticNeeded ; synchronized ( stack ) { } try { findDelete ( point , stack , deleteKey ) ; } catch ( NullPointerException npe ) { //No FFDC Code Needed. _nullPointerExceptions ++ ; return checkForPossibleIndexChange ( v1 , _vno , npe , "optimisticDelete" ) ; } catch ( OptimisticDepthException ode ) { //No FFDC Code Needed. _optimisticDepthExceptions ++ ; return checkForPossibleIndexChange ( v1 , _vno , ode , "optimisticDelete" ) ; } synchronized ( this ) { if ( v1 != _vno ) { _optimisticDeleteSurprises ++ ; return pessimisticNeeded ; } _optimisticDeletes ++ ; if ( point . wasFound ( ) ) { _vno ++ ; if ( ( _vno & 1 ) == 1 ) { finishDelete ( point , stack , deleteKey ) ; if ( _population <= 0 ) throw new GBSTreeException ( "_population = " + _population ) ; _population -- ; } synchronized ( stack ) { } _vno ++ ; } } return optimisticWorked ; }
Optimistic delete from a GBS Tree .
295
10
159,717
void iteratorSpecialDelete ( Iterator iter , GBSNode node , int index ) { _vno ++ ; if ( ( _vno & 1 ) == 1 ) { node . deleteByLeftShift ( index ) ; node . adjustMedian ( ) ; _population -- ; } synchronized ( iter ) { } _vno ++ ; }
Allow an Iterator to delete an item by direct removal from a single node .
71
16
159,718
private void finishDelete ( DeleteNode point , DeleteStack stack , Object deleteKey ) { adjustTarget ( point ) ; point . deleteNode ( ) . deleteByLeftShift ( point . deleteIndex ( ) ) ; deleteFringeMigrate ( stack , point . deleteNode ( ) ) ; }
Do the write phase of the delete .
61
8
159,719
private void findDelete ( DeleteNode point , DeleteStack stack , Object deleteKey ) { java . util . Comparator comp = deleteComparator ( ) ; GBSNode p ; /* P is used to march down the tree */ int xcc ; /* Compare result */ GBSNode l_last = null ; /* Node from which we last departed by */ /* turning left (logical successor) */ GBSNode r_last = null ; /* Node from which we last departed by */ /* turning right (logical predecessor) */ p = root ( ) ; /* Root of tree */ /* Remember father of root */ stack . start ( dummyTopNode ( ) , "GBSTree.findDelete" ) ; while ( p != null ) { xcc = comp . compare ( deleteKey , p . middleKey ( ) ) ; if ( xcc == 0 ) /* Delete key = median key */ { midDelete ( stack , p , point ) ; p = null ; } else if ( xcc < 0 ) /* Delete key < median key */ { if ( p . leftChild ( ) != null ) { l_last = p ; /* Remember node from which we */ /* last moved left (successor) */ stack . push ( NodeStack . PROCESS_CURRENT , p , "GBSTree.findDelete(1)" ) ; p = p . leftChild ( ) ; } else /* There is no left child */ { /* Delete on left side */ leftDelete ( p , r_last , deleteKey , point ) ; p = null ; } } else /* Delete key > median key */ { if ( p . rightChild ( ) != null ) { r_last = p ; /* Remember node from which we */ /* last moved right (predecessor) */ stack . push ( NodeStack . DONE_VISITS , p , "GBSTree.findDelete(2)" ) ; p = p . rightChild ( ) ; } else /* There is no right child */ { rightDelete ( p , l_last , deleteKey , point ) ; p = null ; } } } }
Find the delete point within the tree .
437
8
159,720
private void midDelete ( DeleteStack stack , GBSNode p , DeleteNode point ) { /* Assume no lower predecessor/successor */ point . setDelete ( p , p . middleIndex ( ) ) ; GBSNode q = p . lowerPredecessor ( stack ) ; if ( q != null ) /* Have a lower predecessor */ { /* Elevate right-most of lower pred. */ point . setDelete ( q , q . rightMostIndex ( ) ) ; point . setTarget ( p , p . middleIndex ( ) , DeleteNode . ADD_LEFT ) ; } else /* There is no lower predecessor */ { /* Check for lower successor */ q = p . lowerSuccessor ( stack ) ; if ( q != null ) /* Have a lower successor */ { /* Elevate left-most of lower successor */ point . setDelete ( q , 0 ) ; point . setTarget ( p , p . middleIndex ( ) , DeleteNode . ADD_RIGHT ) ; } } }
Delete a key with an equal match .
208
8
159,721
private void leftDelete ( GBSNode p , GBSNode r , Object deleteKey , DeleteNode point ) { if ( r == null ) /* There is no upper predecessor */ leftDeleteNoPredecessor ( p , deleteKey , point ) ; else /* There is an upper predecessor */ leftDeleteWithPredecessor ( p , r , deleteKey , point ) ; }
Delete from current or predecessor .
78
6
159,722
private void leftDeleteNoPredecessor ( GBSNode p , Object deleteKey , DeleteNode point ) { int idx = p . findDeleteInLeft ( deleteKey ) ; if ( idx >= 0 ) point . setDelete ( p , idx ) ; }
Delete from left side with no upper predecessor .
57
9
159,723
private void leftDeleteWithPredecessor ( GBSNode p , GBSNode r , Object deleteKey , DeleteNode point ) { java . util . Comparator comp = p . deleteComparator ( ) ; int xcc = comp . compare ( deleteKey , r . rightMostKey ( ) ) ; if ( xcc == 0 ) /* Target key IS predecessor high key */ { /* Migrate up low key of current (delete key) into high key of predecessor (target key) */ point . setDelete ( p , 0 ) ; point . setTarget ( r , r . rightMostIndex ( ) , DeleteNode . OVERLAY_RIGHT ) ; } else if ( xcc > 0 ) /* Target key > predecessor high key */ { /* Target is in left part of current */ int ix = p . findDeleteInLeft ( deleteKey ) ; if ( ! ( ix < 0 ) ) point . setDelete ( p , ix ) ; } else /* Target key < predecessor high */ { /* It is in right half of predecessor */ int ix = r . findDeleteInRight ( deleteKey ) ; if ( ! ( ix < 0 ) ) { point . setTarget ( r , ix , DeleteNode . ADD_RIGHT ) ; point . setDelete ( p , 0 ) ; } } }
Delete from left side with an upper predecessor present .
278
10
159,724
private void rightDelete ( GBSNode p , GBSNode l , Object deleteKey , DeleteNode point ) { if ( l == null ) /* There is no upper successor */ rightDeleteNoSuccessor ( p , deleteKey , point ) ; else /* There is an upper successor */ rightDeleteWithSuccessor ( p , l , deleteKey , point ) ; }
Delete from current or successor .
76
6
159,725
private void rightDeleteNoSuccessor ( GBSNode p , Object deleteKey , DeleteNode point ) { int idx = p . findDeleteInRight ( deleteKey ) ; if ( idx >= 0 ) point . setDelete ( p , idx ) ; }
Delete from right side with no successor .
56
8
159,726
private void rightDeleteWithSuccessor ( GBSNode p , GBSNode l , Object deleteKey , DeleteNode point ) { java . util . Comparator comp = p . deleteComparator ( ) ; int xcc = comp . compare ( deleteKey , l . leftMostKey ( ) ) ; if ( xcc == 0 ) /* Target key IS low key of successor */ { /* Migrate up high key of current (delete key) into low key of successor (target key) */ point . setDelete ( p , p . rightMostIndex ( ) ) ; point . setTarget ( l , 0 , DeleteNode . OVERLAY_LEFT ) ; } else if ( xcc < 0 ) /* Less than left most key of successor */ { /* Target is in right of current */ int ix = p . findDeleteInRight ( deleteKey ) ; if ( ix >= 0 ) point . setDelete ( p , ix ) ; } else /* Greater than left most of successor */ { /* Target is in left of successor */ int ix = l . findDeleteInLeft ( deleteKey ) ; if ( ix >= 0 ) { /* Migrate up high key of current (delete key) into low key of successor (hole left after keys moved) */ point . setDelete ( p , p . rightMostIndex ( ) ) ; point . setTarget ( l , ix , DeleteNode . ADD_LEFT ) ; } } }
Delete from right side with successor node present .
303
9
159,727
private void deleteFringeMigrate ( DeleteStack stack , GBSNode p ) { GBSNode endp = p ; /* Last node processed */ int endIndex = stack . index ( ) ; /* Index to last parent */ stack . add ( 0 , p ) ; /* Put last node in stack for possible */ /* use by rebalance */ /* Maximum number of right child nodes */ /* before the fringe must be rebalanced */ int maxBal = maximumFringeImbalance ( ) ; stack . processSubFringe ( p ) ; /* See DeleteStack.processNode */ endp = stack . lastNode ( ) ; endIndex = stack . lastIndex ( ) ; deleteCheckFringeBalance ( stack , endp , endIndex , maxBal ) ; }
Migrate a hole from a partial leaf through to the proper place in its fringe deleting a node from the right side of the fringe if necessary .
161
29
159,728
private void deleteCheckFringeBalance ( DeleteStack stack , GBSNode endp , int endIndex , int maxBal ) { int fDepth = 0 ; /* Fringe balance depth */ fDepth = 0 ; if ( endp . leftChild ( ) == null ) { fDepth = 1 ; /* Last node counts as one */ for ( int j = endIndex ; j > 0 ; j -- ) { GBSNode q = stack . node ( j ) ; if ( q . leftChild ( ) == null ) /* Have not found end yet */ fDepth ++ ; else /* Found the top of the fringe */ break ; } } int t0_depth = tZeroDepth ( ) ; int t = t0_depth ; if ( t < 1 ) t = 1 ; if ( ( stack . maxDepth ( ) >= t ) && /* Deep enough for a t0 and */ ( endp . population ( ) == ( endp . width ( ) - 1 ) ) ) /* Last node was full */ { /* Check for a possible t0 tree */ int j = 1 ; if ( ( kFactor ( ) % 3 ) == 0 ) j = 2 ; if ( fDepth == j ) { _xno ++ ; GBSDeleteFringe . singleInstance ( ) . balance ( tZeroDepth ( ) , stack ) ; } } else /* Not a t0 fringe */ { /* Check for empty node */ if ( endp . population ( ) != 0 ) endp . adjustMedian ( ) ; else { _xno ++ ; GBSNode p = stack . node ( endIndex ) ; if ( p . leftChild ( ) == endp ) p . setLeftChild ( null ) ; else p . setRightChild ( null ) ; } } }
Check to see if fringe balancing is required following a delete and do the fringe rebalancing if needed .
368
21
159,729
public static ThreadContextDescriptor deserialize ( byte [ ] bytes , Map < String , String > execProps ) throws ClassNotFoundException , IOException { return new ThreadContextDescriptorImpl ( execProps , bytes ) ; }
Deserializes a thread context descriptor .
52
8
159,730
public static File [ ] listFiles ( final File target , final List < Pattern > patterns , final boolean include ) { if ( patterns == null || patterns . isEmpty ( ) ) return target . listFiles ( ) ; return target . listFiles ( new FilenameFilter ( ) { @ Override public boolean accept ( File dir , String name ) { for ( Pattern pattern : patterns ) { Matcher matcher = pattern . matcher ( name ) ; if ( matcher . matches ( ) ) return include ; } return ! include ; } } ) ; }
List files according to the patterns and the pattern type
115
10
159,731
public static void copyFile ( File dest , File source ) throws IOException { InputStream input = null ; try { input = new FileInputStream ( source ) ; createFile ( dest , input ) ; } finally { Utils . tryToClose ( input ) ; } }
Copy from one file to the other
57
7
159,732
public static void createFile ( final File dest , final InputStream sourceInput ) throws IOException { if ( sourceInput == null || dest == null ) return ; FileOutputStream fos = null ; try { if ( ! dest . getParentFile ( ) . exists ( ) ) { if ( ! dest . getParentFile ( ) . mkdirs ( ) ) { throw new FileNotFoundException ( ) ; } } fos = TextFileOutputStreamFactory . createOutputStream ( dest ) ; byte [ ] buffer = new byte [ DEFAULT_BUFFER_SIZE ] ; int count = - 1 ; while ( ( count = sourceInput . read ( buffer ) ) > 0 ) { fos . write ( buffer , 0 , count ) ; } fos . flush ( ) ; } finally { Utils . tryToClose ( fos ) ; Utils . tryToClose ( sourceInput ) ; } }
Read the content from an inputStream and write out to the other file
191
14
159,733
public static void copyDir ( File from , File to ) throws FileNotFoundException , IOException { File [ ] files = from . listFiles ( ) ; if ( files != null ) { for ( File ff : files ) { File tf = new File ( to , ff . getName ( ) ) ; if ( ff . isDirectory ( ) ) { if ( tf . mkdir ( ) ) { copyDir ( ff , tf ) ; } } else if ( ff . isFile ( ) ) { copyFile ( tf , ff ) ; } } } }
Recursively copy the files from one dir to the other .
117
13
159,734
public static boolean isUnderDirectory ( File child , File parent ) { if ( child == null || parent == null ) return false ; URI childUri = child . toURI ( ) ; URI relativeUri = parent . toURI ( ) . relativize ( childUri ) ; return relativeUri . equals ( childUri ) ? false : true ; }
If child is under parent will return true otherwise return false .
77
12
159,735
public static String normalizeEntryPath ( String entryPath ) { if ( entryPath == null || entryPath . isEmpty ( ) ) return "" ; entryPath = entryPath . replace ( "\\" , "/" ) ; if ( entryPath . startsWith ( "/" ) ) { if ( entryPath . length ( ) == 1 ) { entryPath = "" ; } else { entryPath = entryPath . substring ( 1 , entryPath . length ( ) ) ; } } return entryPath ; }
Normalize a relative entry path so that it can be used in an archive .
106
16
159,736
public static String normalizeDirPath ( String dirPath ) { if ( dirPath == null || dirPath . isEmpty ( ) ) return "" ; dirPath = dirPath . replace ( "\\" , "/" ) ; if ( ! dirPath . endsWith ( "/" ) ) { dirPath = dirPath + "/" ; } return dirPath ; }
Normalize a path that represents a directory
76
8
159,737
private static final boolean contains ( Collection < String > list , String value ) { for ( String item : list ) if ( item . contains ( value ) ) return true ; return false ; }
Utility method that determines if some text is found as a substring within the contents of a list .
39
21
159,738
static String getConnectionPoolDataSourceClassName ( String vendorPropertiesPID ) { String [ ] classNames = classNamesByPID . get ( vendorPropertiesPID ) ; return classNames == null ? null : classNames [ 1 ] ; }
Infer the vendor implementation class name for javax . sql . ConnectionPoolDataSource based on the PID of the vendor properties . A best effort is made for the known vendors .
54
37
159,739
static String getDataSourceClassName ( Collection < String > fileNames ) { for ( Map . Entry < String , String [ ] > entry : classNamesByKey . entrySet ( ) ) if ( contains ( fileNames , entry . getKey ( ) ) ) { String [ ] classNames = entry . getValue ( ) ; return classNames == null ? null : classNames [ 0 ] ; } return null ; }
Infer the vendor implementation class name for javax . sql . DataSource based on the JAR or ZIP names . A best effort is made for the known vendors .
88
35
159,740
static String getDataSourceClassName ( String vendorPropertiesPID ) { String [ ] classNames = classNamesByPID . get ( vendorPropertiesPID ) ; return classNames == null ? null : classNames [ 0 ] ; }
Infer the vendor implementation class name for javax . sql . DataSource based on the PID of the vendor properties . A best effort is made for the known vendors .
52
35
159,741
static String getXADataSourceClassName ( String vendorPropertiesPID ) { String [ ] classNames = classNamesByPID . get ( vendorPropertiesPID ) ; return classNames == null ? null : classNames [ 2 ] ; }
Infer the vendor implementation class name for javax . sql . XADataSource based on the PID of the vendor properties . A best effort is made for the known vendors .
54
37
159,742
private static String tryToLoad ( Class < ? > type , ClassLoader loader , String ... classNames ) { final boolean trace = TraceComponent . isAnyTracingEnabled ( ) ; for ( String className : classNames ) try { Class < ? > c = loader . loadClass ( className ) ; boolean isInstance = type . isAssignableFrom ( c ) ; if ( trace && tc . isDebugEnabled ( ) ) Tr . debug ( tc , className + " is " + ( isInstance ? "" : "not " ) + "an instance of " + type . getName ( ) ) ; if ( type . isAssignableFrom ( c ) ) return className ; } catch ( ClassNotFoundException x ) { if ( trace && tc . isDebugEnabled ( ) ) Tr . debug ( tc , className + " not found on " + loader ) ; } return null ; }
Attempt to load the specified class names returning the first that successfully loads and is an instance of the specified type .
191
22
159,743
protected final String [ ] getAttributes ( String key ) { ArrayList < String > array = this . _attributes . get ( key ) ; if ( array != null && array . size ( ) > 0 ) { String [ ] type = new String [ array . size ( ) ] ; return array . toArray ( type ) ; } return null ; }
Get the attribute value based on the named value . A string array is returned containing all values of the attribute previously set .
74
24
159,744
public Object handleOperation ( String operation , Object [ ] params ) throws IOException { if ( OPERATION_DOWNLOAD . equals ( operation ) ) { if ( params . length == 2 ) { downloadFile ( ( String ) params [ 0 ] , ( String ) params [ 1 ] ) ; } else { //partial download return downloadFile ( ( String ) params [ 0 ] , ( String ) params [ 1 ] , ( Long ) params [ 2 ] , ( Long ) params [ 3 ] ) ; } } else if ( OPERATION_UPLOAD . equals ( operation ) ) { uploadFile ( ( String ) params [ 0 ] , ( String ) params [ 1 ] , ( Boolean ) params [ 2 ] ) ; } else if ( OPERATION_DELETE . equals ( operation ) ) { deleteFile ( ( String ) params [ 0 ] ) ; } else if ( OPERATION_DELETE_ALL . equals ( operation ) ) { deleteAll ( ( List < String > ) params [ 0 ] ) ; } else { throw logUnsupportedOperationError ( "handleOperation" , operation ) ; } //currently all operations are void, so return null. return null ; }
Handle MBean invocation requests
246
6
159,745
@ Override public long read ( long numBytes , int timeout ) throws IOException { long readCount = 0 ; H2StreamProcessor p = muxLink . getStreamProcessor ( streamID ) ; try { p . getReadLatch ( ) . await ( timeout , TimeUnit . MILLISECONDS ) ; readCount = p . readCount ( numBytes , this . getBuffers ( ) ) ; } catch ( InterruptedException e ) { throw new IOException ( "read was stopped by an InterruptedException: " + e ) ; } return readCount ; }
Get bytes from the stream processor associated with this read context
124
11
159,746
@ FFDCIgnore ( PrivilegedActionException . class ) private String getConfigNameForRef ( final String ref ) { String name = null ; if ( ref != null ) { final ConfigurationAdmin configAdmin = configAdminRef . getService ( ) ; Configuration config ; try { config = AccessController . doPrivileged ( new PrivilegedExceptionAction < Configuration > ( ) { @ Override public Configuration run ( ) throws IOException { return configAdmin . getConfiguration ( ref , configAdminRef . getReference ( ) . getBundle ( ) . getLocation ( ) ) ; } } ) ; } catch ( PrivilegedActionException paex ) { return null ; } Dictionary < String , Object > props = config . getProperties ( ) ; name = ( String ) props . get ( KEY_NAME ) ; } return name ; }
Use the config admin service to get the name for a given service reference
174
14
159,747
public static synchronized void addConfig ( String id , String uri , Map < String , String > params ) { uriMap . put ( id , uri ) ; configInfo . put ( uri , params ) ; resolvedConfigInfo . clear ( ) ; if ( uri . endsWith ( "*" ) ) { wildcardsPresentInConfigInfo = true ; } }
add a configuration for a URL We d like a set of hashmaps keyed by URL however when osgi calls deactivate we have no arguments so we have to associate a url with the object id of the service . That allows us to remove the right one .
79
53
159,748
public String generateSessionId ( ) { byte random [ ] = new byte [ 16 ] ; // Render the result as a String of hexadecimal digits StringBuilder buffer = new StringBuilder ( ) ; int resultLenBytes = 0 ; while ( resultLenBytes < sessionIdLength ) { getRandomBytes ( random ) ; for ( int j = 0 ; j < random . length && resultLenBytes < sessionIdLength ; j ++ ) { byte b1 = ( byte ) ( ( random [ j ] & 0xf0 ) >> 4 ) ; byte b2 = ( byte ) ( random [ j ] & 0x0f ) ; if ( b1 < 10 ) { buffer . append ( ( char ) ( ' ' + b1 ) ) ; } else { buffer . append ( ( char ) ( ' ' + ( b1 - 10 ) ) ) ; } if ( b2 < 10 ) { buffer . append ( ( char ) ( ' ' + b2 ) ) ; } else { buffer . append ( ( char ) ( ' ' + ( b2 - 10 ) ) ) ; } resultLenBytes ++ ; } } if ( jvmRoute != null && jvmRoute . length ( ) > 0 ) { buffer . append ( ' ' ) . append ( jvmRoute ) ; } return buffer . toString ( ) ; }
Generate and return a new session identifier .
280
9
159,749
public boolean containsKey ( Object key ) { FastHashtableEntry tab [ ] = table ; int hash = key . hashCode ( ) ; int index = ( hash & 0x7FFFFFFF ) % tab . length ; for ( FastHashtableEntry e = tab [ index ] ; e != null ; e = e . next ) { if ( ( e . hash == hash ) && e . key . equals ( key ) ) { return true ; } } return false ; }
Tests if the specified object is a key in this hashtable .
100
14
159,750
private boolean ableToFilter ( ) { if ( filter == null ) return false ; for ( int i = table . length ; i -- > 0 ; ) { FastHashtableEntry newContents = null , next = null ; for ( FastHashtableEntry e = table [ i ] ; e != null ; e = next ) { next = e . next ; if ( filter . shouldRetain ( e . key , e . value ) ) { e . next = newContents ; newContents = e ; } else count -- ; } table [ i ] = newContents ; } return count < threshold ; }
Avoids the need to rehash when some entries can be filtered out of the Hashtable by an upcall to a separate decision routine .
125
28
159,751
private void readObject ( java . io . ObjectInputStream s ) throws IOException , ClassNotFoundException { // Read in the length, threshold, and loadfactor s . defaultReadObject ( ) ; // Read the original length of the array and number of elements int origlength = s . readInt ( ) ; int elements = s . readInt ( ) ; // Compute new size with a bit of room 5% to grow but // No larger than the original size. Make the length // odd if it's large enough, this helps distribute the entries. // Guard against the length ending up zero, that's not valid. int length = ( int ) ( elements * loadFactor ) + ( elements / 20 ) + 3 ; if ( length > elements && ( length & 1 ) == 0 ) length -- ; if ( origlength > 0 && length > origlength ) length = origlength ; table = new FastHashtableEntry [ length ] ; count = 0 ; // Read the number of elements and then all the key/value objects for ( ; elements > 0 ; elements -- ) { Object key = s . readObject ( ) ; Object value = s . readObject ( ) ; put ( key , value ) ; } }
readObject is called to restore the state of the hashtable from a stream . Only the keys and values are serialized since the hash values may be different when the contents are restored . Read count elements and insert into the hashtable .
253
47
159,752
public boolean getBooleanProperty ( String propertyName ) { boolean booleanValue = false ; // Pull the key from the property map Object objectValue = this . properties . get ( propertyName ) ; if ( objectValue != null ) { if ( objectValue instanceof Boolean ) { booleanValue = ( ( Boolean ) objectValue ) . booleanValue ( ) ; } else if ( objectValue instanceof String ) { booleanValue = Boolean . parseBoolean ( ( String ) objectValue ) ; } } return booleanValue ; }
Query the boolean property value of the input name .
107
10
159,753
public String getStringProperty ( String propertyName ) { Object value = this . properties . get ( propertyName ) ; if ( null != value && value instanceof String ) { return ( String ) value ; } return null ; }
Query the properties for the input name the value will be null if not found or was not a String object .
47
22
159,754
private boolean getBooleanProperty ( String key , String defaultValue , StringBuilder errors ) { boolean booleanValue = false ; String stringValue = null ; boolean valueCorrect = false ; // Pull the key from the property map Object objectValue = this . properties . get ( key ) ; if ( objectValue != null ) { if ( objectValue instanceof Boolean ) { booleanValue = ( ( Boolean ) objectValue ) . booleanValue ( ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Property " + key + " set to " + booleanValue ) ; } return booleanValue ; } else if ( objectValue instanceof String ) { stringValue = ( String ) objectValue ; } } else { // Key is not in map. if ( defaultValue != null ) { stringValue = defaultValue ; } else { // No default provided. Error. errors . append ( key ) ; errors . append ( ' ' ) ; errors . append ( stringValue ) ; errors . append ( ' ' ) ; return false ; } } // If we get this far, we have a non null string value to work with. May be the default. // Verify the value. if ( stringValue != null ) { if ( stringValue . equals ( "true" ) ) { booleanValue = true ; valueCorrect = true ; } else if ( stringValue . equals ( "false" ) ) { booleanValue = false ; valueCorrect = true ; } } if ( valueCorrect ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Property " + key + " set to " + booleanValue ) ; } } else { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Property " + key + " has invalid value " + stringValue ) ; } errors . append ( key ) ; errors . append ( ' ' ) ; errors . append ( stringValue ) ; errors . append ( ' ' ) ; } return booleanValue ; }
Extract String value from property list and convert to boolean .
451
12
159,755
private int getIntProperty ( String key , boolean defaultProvided , int defaultValue , StringBuilder errors ) { String value = getStringProperty ( key ) ; if ( null != value ) { try { int realValue = Integer . parseInt ( value ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Property " + key + " set to " + realValue ) ; } return realValue ; } catch ( NumberFormatException nfe ) { // no FFDC required; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Property " + key + ", format error in [" + value + "]" ) ; } } } if ( ! defaultProvided ) { // No default available. This is an error. if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Property " + key + " not found. Error being tallied." ) ; } errors . append ( key ) ; errors . append ( ":null \n" ) ; return - 1 ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Property " + key + " using default " + defaultValue ) ; } return defaultValue ; }
Extract an integer property from the stored values . This might use a default value if provided and the property was not found .
303
25
159,756
public synchronized void lockExclusive ( ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( this , tc , "lockExclusive" , this ) ; boolean interrupted = false ; // If another thread is attempting to lock exclusive, // wait for it to finish first. while ( ! tryLockExclusive ( ) ) { try { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "Waiting to get exclusive lock" ) ; wait ( 1000 ) ; } catch ( InterruptedException e ) { // No FFDC code needed interrupted = true ; } } // Wait for existing locks to be released while ( iLockCount > 0 ) { try { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "Waiting for lock count to reach 0 " + iLockCount ) ; wait ( 1000 ) ; } catch ( InterruptedException e ) { // No FFDC code needed interrupted = true ; } } if ( interrupted ) { Thread . currentThread ( ) . interrupt ( ) ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( this , tc , "lockExclusive" ) ; }
This method locks the mutex so no other lockers can get the lock .
300
16
159,757
public int getLocalBusinessInterfaceIndex ( String interfaceName ) { if ( ivBusinessLocalInterfaceClasses != null ) { for ( int i = 0 ; i < ivBusinessLocalInterfaceClasses . length ; i ++ ) { String bInterfaceName = ivBusinessLocalInterfaceClasses [ i ] . getName ( ) ; if ( bInterfaceName . equals ( interfaceName ) ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) Tr . debug ( tc , "getLocalBusinessInterfaceIndex : " + bInterfaceName + " at index " + i ) ; return i ; } } } return - 1 ; }
Gets the index of the local business interface .
139
10
159,758
public int getRequiredLocalBusinessInterfaceIndex ( String interfaceName ) throws IllegalStateException { int interfaceIndex = getLocalBusinessInterfaceIndex ( interfaceName ) ; if ( interfaceIndex == - 1 ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) Tr . debug ( tc , "getRequiredLocalBusinessInterfaceIndex : IllegalStateException : " + "Requested business interface not found : " + interfaceName ) ; throw new IllegalStateException ( "Requested business interface not found : " + interfaceName ) ; } return interfaceIndex ; }
Gets the index of the local busines interface . This method will throw an IllegalStateException if a local interface could not be matched . If it is known that a match must occur on a local business interface then this method should be used .
122
49
159,759
public int getRemoteBusinessInterfaceIndex ( String interfaceName ) { if ( ivBusinessRemoteInterfaceClasses != null ) { for ( int i = 0 ; i < ivBusinessRemoteInterfaceClasses . length ; i ++ ) { String bInterface = ivBusinessRemoteInterfaceClasses [ i ] . getName ( ) ; if ( bInterface . equals ( interfaceName ) ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) Tr . debug ( tc , "getRemoteBusinessInterfaceIndex : " + bInterface + " at index " + i ) ; return i ; } } } return - 1 ; }
Gets the index of the remote business interface .
136
10
159,760
public int getRequiredRemoteBusinessInterfaceIndex ( String interfaceName ) throws IllegalStateException { int interfaceIndex = getRemoteBusinessInterfaceIndex ( interfaceName ) ; if ( interfaceIndex == - 1 ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) Tr . debug ( tc , "getRequiredRemoteBusinessInterfaceIndex : IllegalStateException : " + "Requested business interface not found : " + interfaceName ) ; throw new IllegalStateException ( "Requested business interface not found : " + interfaceName ) ; } return interfaceIndex ; }
Gets the index of the remote busines interface . This method will throw an IllegalStateException if a remte interface could not be matched . If it is known that a match must occur on a remote business interface then this method should be used .
122
50
159,761
public String [ ] [ ] getMethodLevelCustomFinderMethodSignatures ( String cfprocessstring ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) Tr . entry ( tc , "getMethodLevelCustomFinderMethodSignatures:" + cfprocessstring ) ; StringTokenizer st = new StringTokenizer ( cfprocessstring , ":" ) ; // array form [item#][CFMethodName]=methodname, e.g. findByCustomerName // array form [item#][CFMethodParms]]=parameter list, e.g. int,java.lang.String String cfMethodSignatureArray [ ] [ ] = new String [ st . countTokens ( ) ] [ 2 ] ; int methodCounter = 0 ; while ( st . hasMoreTokens ( ) ) { String methodSignature = st . nextToken ( ) ; StringTokenizer methodSignaturest = new StringTokenizer ( methodSignature , "()" ) ; // format exepected, first attribute method name (can't be nul) // second are the signatures parms, in order try { cfMethodSignatureArray [ methodCounter ] [ CF_METHOD_NAME_OFFSET ] = methodSignaturest . nextToken ( ) ; if ( methodSignature . equals ( "()" ) ) { cfMethodSignatureArray [ methodCounter ] [ CF_METHOD_SIG_OFFSET ] = null ; // no signature given, but followed expected format } else { cfMethodSignatureArray [ methodCounter ] [ CF_METHOD_SIG_OFFSET ] = methodSignaturest . nextToken ( ) ; } } catch ( java . util . NoSuchElementException ex ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) && methodSignature != null ) Tr . debug ( tc , "Processing offset [" + methodCounter + "] " + methodSignature + " failed, incorrect format" ) ; // badSignatureGiven=true; } methodCounter ++ ; } // while if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) Tr . exit ( tc , "getMethodLevelCustomFinderMethodSignatures: " + cfMethodSignatureArray ) ; return cfMethodSignatureArray ; }
d112604 . 1
493
5
159,762
public JsMessage transcribeToJmf ( ) throws MessageCopyFailedException , IncorrectMessageTypeException , UnsupportedEncodingException { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( this , tc , "transcribeToJmf" ) ; JsMsgObject newJmo = null ; // Try/catch block in case we get an MFPUnsupportedEncodingRuntimeException because the // payload is in an unsupported codepage. d252277.2 try { if ( this instanceof JsJmsMessageImpl ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "Transcribing from JsJmsMessageImpl" ) ; newJmo = jmo . transcribeToJmf ( ) ; } else { // Non-JMS messages are not supported - they should have been converted into JMS by now if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "Non-JMS Messages are not yet supported" ) ; String exString = nls . getFormattedMessage ( "UNEXPECTED_MESSAGE_TYPE_CWSIF0102" , new Object [ ] { getJsMessageType ( ) , MessageType . JMS } , "The Message can not be represented as a pure JMF Message" ) ; throw new IncorrectMessageTypeException ( exString ) ; } } catch ( MFPUnsupportedEncodingRuntimeException e ) { FFDCFilter . processException ( e , "com.ibm.ws.sib.mfp.impl.JsMessageImpl.transcribeToJmf" , "721" ) ; // Throw the original UnsupportedEncodingException throw ( UnsupportedEncodingException ) e . getCause ( ) ; } JsMessage newMsg ; // if we have a new jmo, create a new message from it if ( newJmo != this . jmo ) { newMsg = createNewGeneralized ( newJmo ) ; } // otherwise, just return ourself else { newMsg = this ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( this , tc , "transcribeToJmf" , newMsg ) ; return newMsg ; }
Transcribe this message to pure JMF
537
9
159,763
public int getApproximateLength ( ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( this , tc , "getApproximateLength" ) ; if ( approxLength == - 1 ) approxLength = guessApproxLength ( ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( this , tc , "getApproximateLength" , Integer . valueOf ( approxLength ) ) ; return approxLength ; }
Return an approximate size for the flattened message . It is important that this method is quick and cheap rather than highly accurate .
122
24
159,764
private final JsMessageImpl createNew ( ) throws MessageCopyFailedException { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( this , tc , "createNew" ) ; JsMessageImpl newMsg = null ; Class msgClass = this . getClass ( ) ; try { /* Create the new JsMessage*/ newMsg = ( JsMessageImpl ) msgClass . newInstance ( ) ; /* copy transients before copying JMO to ensure safe ordering - see SIB0121.mfp.2 */ copyTransients ( newMsg ) ; /* Get a new copy of the JMO and set it into the new message*/ JsMsgObject newJmo = jmo . getCopy ( ) ; newMsg . setJmo ( newJmo ) ; } catch ( IllegalAccessException e1 ) { FFDCFilter . processException ( e1 , "com.ibm.ws.sib.mfp.impl.JsMessageImpl.createNew" , "jsm1600" ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "IllegalAccessException " + e1 . getMessage ( ) + " instantiating class " + msgClass . getName ( ) ) ; throw new MessageCopyFailedException ( e1 ) ; } catch ( InstantiationException e2 ) { FFDCFilter . processException ( e2 , "com.ibm.ws.sib.mfp.impl.JsMessageImpl.createNew" , "jsm1610" ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "InstantiationException " + e2 . getMessage ( ) + " instantiating class " + msgClass . getName ( ) ) ; throw new MessageCopyFailedException ( e2 ) ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( this , tc , "createNew" , newMsg ) ; return newMsg ; }
Return a new Jsmessage of the same specialization as this containing the given JsMsgObject .
472
20
159,765
private final JsMessageImpl createNewGeneralized ( JsMsgObject newJmo ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( this , tc , "createNewGeneralized" ) ; JsMessageImpl newMsg = null ; /* Now create the new JsMessage */ newMsg = new JsMessageImpl ( newJmo ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( this , tc , "createNewGeneralized" , newMsg ) ; return newMsg ; }
Return a new JsMessage generalizing the message to just be a JsMessageImpl . The new message contains the given JsMsgObject .
138
30
159,766
@ SuppressWarnings ( "rawtypes" ) public static Hashtable parsePostData ( ServletInputStream in , String encoding , boolean multireadPropertyEnabled ) /* 157338 add throws */ throws IOException { int inputLen ; byte [ ] postedBytes = null ; String postedBody ; if ( com . ibm . ejs . ras . TraceComponent . isAnyTracingEnabled ( ) && logger . isLoggable ( Level . FINE ) ) logger . logp ( Level . FINE , CLASS_NAME , "parsePostData" , "parsing chunked post data. encoding = " + encoding ) ; if ( in == null ) throw new IllegalArgumentException ( "post data inputstream is null" ) ; try { // // Make sure we read the entire POSTed body. // ByteArrayOutputStream byteOS = new ByteArrayOutputStream ( DEFAULT_BUFFER_SIZE ) ; do { byte [ ] readInBytes = new byte [ DEFAULT_BUFFER_SIZE ] ; inputLen = in . read ( readInBytes , 0 , DEFAULT_BUFFER_SIZE ) ; if ( inputLen > 0 ) { byteOS . write ( readInBytes , 0 , inputLen ) ; } } while ( inputLen != - 1 ) ; // MultiRead Start if ( multireadPropertyEnabled ) { in . close ( ) ; } // MultiRead End postedBytes = byteOS . toByteArray ( ) ; if ( com . ibm . ejs . ras . TraceComponent . isAnyTracingEnabled ( ) && logger . isLoggable ( Level . FINE ) ) logger . logp ( Level . FINE , CLASS_NAME , "parsePostData" , "finished reading [" + postedBytes . length + "] bytes" ) ; } catch ( IOException e ) { com . ibm . wsspi . webcontainer . util . FFDCWrapper . processException ( e , "com.ibm.ws.webcontainer.servlet.RequestUtils.parsePostData" , "598" ) ; // begin 157338 throw e ; //return new Hashtable(); // begin 157338 } // XXX we shouldn't assume that the only kind of POST body // is FORM data encoded using ASCII or ISO Latin/1 ... or // that the body should always be treated as FORM data. // try { postedBody = new String ( postedBytes , encoding ) ; } catch ( UnsupportedEncodingException e ) { com . ibm . wsspi . webcontainer . util . FFDCWrapper . processException ( e , "com.ibm.ws.webcontainer.servlet.RequestUtils.parsePostData" , "618" ) ; postedBody = new String ( postedBytes ) ; } if ( WCCustomProperties . PARSE_UTF8_POST_DATA && encoding . equalsIgnoreCase ( "UTF-8" ) ) { for ( byte nextByte : postedBytes ) { if ( nextByte < ( byte ) 0 ) { encoding = "8859_1" ; if ( com . ibm . ejs . ras . TraceComponent . isAnyTracingEnabled ( ) && logger . isLoggable ( Level . FINE ) ) logger . logp ( Level . FINE , CLASS_NAME , "parsePostData" , "UTF8 post data, set encoing to 8859_1 to prevent futrther encoding" ) ; break ; } } } return parseQueryString ( postedBody , encoding ) ; }
begin 231634 Support posts with query parms in chunked body WAS . webcontainer
748
18
159,767
public final Item findOldestItem ( ) throws MessageStoreException { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( this , tc , "findOldestItem" ) ; ItemCollection ic = ( ( ItemCollection ) _getMembership ( ) ) ; if ( null == ic ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( this , tc , "findOldestItem" ) ; throw new NotInMessageStore ( ) ; } Item item = null ; if ( ic != null ) { item = ( Item ) ic . findOldestItem ( ) ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( this , tc , "findOldestItem" , item ) ; return item ; }
Find the item that has been known to the stream for longest . The item returned may be in any of the states defined in the state model . The caller should not assume that the item can be used for any particular purpose .
198
45
159,768
protected void abort ( ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEventEnabled ( ) ) { Tr . event ( tc , "Aborting connection" ) ; } this . aborted = true ; }
Abort this context to trigger immediate exceptions on future IO requests .
49
13
159,769
protected void setTimeoutTime ( int time ) { int timeout = time ; if ( timeout == TCPRequestContext . NO_TIMEOUT ) { this . timeoutTime = TCPRequestContext . NO_TIMEOUT ; this . timeoutInterval = 0 ; } else { if ( timeout == TCPRequestContext . USE_CHANNEL_TIMEOUT ) { timeout = getConfig ( ) . getInactivityTimeout ( ) ; } if ( timeout != ValidateUtils . INACTIVITY_TIMEOUT_NO_TIMEOUT ) { this . timeoutTime = System . currentTimeMillis ( ) + timeout ; this . timeoutInterval = timeout ; } else { this . timeoutTime = TCPRequestContext . NO_TIMEOUT ; this . timeoutInterval = 0 ; } } }
Sets the timeout value returned by getTimeoutTime .
162
11
159,770
public boolean updateIOCounts ( long byteCount , int type ) { setLastIOAmt ( byteCount ) ; setIODoneAmount ( getIODoneAmount ( ) + byteCount ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEventEnabled ( ) ) { String dbString = null ; if ( type == 0 ) { dbString = "Read " ; } else { dbString = "Wrote " ; } SocketIOChannel channel = getTCPConnLink ( ) . getSocketIOChannel ( ) ; Tr . event ( tc , dbString + byteCount + "(" + + getIODoneAmount ( ) + ")" + " bytes, " + getIOAmount ( ) + " requested on local: " + channel . getSocket ( ) . getLocalSocketAddress ( ) + " remote: " + channel . getSocket ( ) . getRemoteSocketAddress ( ) ) ; } boolean rc ; if ( getIODoneAmount ( ) >= getIOAmount ( ) ) { // read is complete on current thread if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { if ( type == 0 ) { Tr . debug ( tc , "read complete, at least minimum amount of data read" ) ; } else { Tr . debug ( tc , "write complete, at least minimum amount of data written" ) ; } } rc = true ; } else { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { if ( type == 0 ) { Tr . debug ( tc , "read not complete, more data needed" ) ; } else { Tr . debug ( tc , "write not complete, more data needs to be written" ) ; } } rc = false ; } return rc ; }
rather than in extension classes
386
5
159,771
public ConversationReceiveListener acceptConnection ( Conversation cfConversation ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( tc , "acceptConnection" , cfConversation ) ; // Add this conversation to our active conversations list synchronized ( activeConversations ) { Object connectionReference = cfConversation . getConnectionReference ( ) ; ArrayList list = ( ArrayList ) activeConversations . get ( connectionReference ) ; if ( list == null ) { list = new ArrayList ( ) ; activeConversations . put ( connectionReference , list ) ; } else { // This is mank - but if TRM does a redirect it is possible that we may get a // connection but then they close the Conversation directly without sending us any // kind of close flow. As such, every time we connect we should have a check on all // the conversations to ensure they are not closed, and if they are remove them from // the list. ArrayList removeList = new ArrayList ( ) ; for ( int x = 0 ; x < list . size ( ) ; x ++ ) { Conversation conv = ( Conversation ) list . get ( x ) ; if ( conv . isClosed ( ) ) { removeList . add ( conv ) ; } } // Actually do the remove... for ( int x = 0 ; x < removeList . size ( ) ; x ++ ) { list . remove ( removeList . get ( x ) ) ; } } list . add ( cfConversation ) ; // At this point we have a look to see if the connection closed listener has been set. // If it has not been set then this is a new connection (or one with no active // Conversations on it. We must set ourselves as the listener in the event that the // socket terminates before any SI connections are established and so any cleanup // required. // Note that once a connection to the ME is established, this listener is overwritten // with one in ServerSideConnection. This also performs the same cleanup but also does // MFP cleanup as well (which is not appropriate if the connection goes down at this // stage). if ( cfConversation . getConnectionClosedListener ( ConversationUsageType . JFAP ) == null ) { cfConversation . addConnectionClosedListener ( this , ConversationUsageType . JFAP ) ; } } if ( cfConversation . getAttachment ( ) == null ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( tc , "Creating conversation state" ) ; cfConversation . setAttachment ( new ConversationState ( ) ) ; } if ( cfConversation . getLinkLevelAttachment ( ) == null ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( tc , "Creating link level state" ) ; cfConversation . setLinkLevelAttachment ( new ServerLinkLevelState ( ) ) ; } // Set a hint that this conversation is being used for ME to client communications. cfConversation . setConversationType ( Conversation . CLIENT ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( tc , "acceptConnection" , serverTransportReceiveListener ) ; return serverTransportReceiveListener ; }
Called when we are about to accept a connection from a peer .
732
14
159,772
public void removeConversation ( Conversation conv ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( this , tc , "removeConversation" , conv ) ; synchronized ( activeConversations ) { Object connectionReference = conv . getConnectionReference ( ) ; ArrayList list = ( ArrayList ) activeConversations . get ( connectionReference ) ; if ( list != null ) { list . remove ( conv ) ; if ( list . size ( ) == 0 ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "List is now empty, removing connection object" ) ; activeConversations . remove ( connectionReference ) ; } } } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( this , tc , "removeConversation" ) ; }
This method removes a conversation from the list of active conversations . This would be called if the connection is closed or if a failure is deteceted .
213
31
159,773
public void connectionClosed ( Object connectionReference ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( this , tc , "connectionClosed" , connectionReference ) ; removeAllConversations ( connectionReference ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( this , tc , "connectionClosed" ) ; }
Driven in the event that the underlying connection closes . This will only be driven if the socket dies before a connection to the ME has had chance to be established .
101
33
159,774
public void removeAllConversations ( Object connectionReference ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( this , tc , "removeAllConversations" , connectionReference ) ; final ArrayList list ; synchronized ( activeConversations ) { list = ( ArrayList ) activeConversations . remove ( connectionReference ) ; } // Remove the connection reference from the list if ( list != null ) { try { for ( int x = 0 ; x < list . size ( ) ; x ++ ) { Conversation conv = ( Conversation ) list . get ( x ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "Found a Conversation in the table: " , conv ) ; // Now call the server transport receive listener to clean up the resources serverTransportReceiveListener . cleanupConnection ( conv ) ; } } catch ( Throwable t ) { FFDCFilter . processException ( t , CLASS_NAME + ".removeAllConversations" , CommsConstants . SERVERTRANSPORTACCEPTLISTENER_REMOVEALL_01 , this ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "Caught an exception cleaning up a connection" , t ) ; } // Now clear the list list . clear ( ) ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( this , tc , "removeAllConversations" ) ; }
This method is used to clean up any resources that
362
10
159,775
protected final ObjectFactoryInfo getObjectFactoryInfo ( Class < ? > klass , String className ) // F743-32443 { final boolean isTraceOn = TraceComponent . isAnyTracingEnabled ( ) ; if ( isTraceOn && tc . isEntryEnabled ( ) ) Tr . entry ( tc , "getObjectFactory: " + klass + ", " + className ) ; if ( ivObjectFactoryMap == null ) { if ( isTraceOn && tc . isEntryEnabled ( ) ) Tr . exit ( tc , "getObjectFactory: no factories" ) ; return null ; } if ( klass != null && klass != Object . class ) // d700708 { ObjectFactoryInfo result = ivObjectFactoryMap . get ( klass ) ; if ( isTraceOn && tc . isEntryEnabled ( ) ) Tr . exit ( tc , "getObjectFactory: " + result ) ; return result ; } if ( ivObjectFactoryByNameMap == null ) { ivObjectFactoryByNameMap = new HashMap < String , ObjectFactoryInfo > ( ) ; for ( Map . Entry < Class < ? > , ObjectFactoryInfo > entry : ivObjectFactoryMap . entrySet ( ) ) { ivObjectFactoryByNameMap . put ( entry . getKey ( ) . getName ( ) , entry . getValue ( ) ) ; } } ObjectFactoryInfo result = ivObjectFactoryByNameMap . get ( className ) ; if ( isTraceOn && tc . isEntryEnabled ( ) ) Tr . exit ( tc , "getObjectFactory (by-name): " + result ) ; return result ; }
Gets an object factory for the specified class or class name . This method must be used to support configurations without a class loader .
348
26
159,776
private void updateInjectionBinding ( String jndiName , InjectionBinding < A > injectionBinding ) // d675172 { // If the annotation didn't have a name or the binding implementation // constructor did not set it, then the binding needs to be updated // with the default name or name (if not set by constructor). // d682415 if ( ! jndiName . equals ( injectionBinding . getJndiName ( ) ) ) // d675172.1 { injectionBinding . setJndiName ( jndiName ) ; } }
Updates an InjectionBinding created for an annotation .
124
12
159,777
private < P extends Annotation > InjectionBinding < ? > addOrMergeOverrideInjectionBinding ( Class < ? > instanceClass , Member member , A annotation , String jndiName ) // d675843.2 throws InjectionException { @ SuppressWarnings ( "unchecked" ) InjectionProcessor < P , ? > processor = ( InjectionProcessor < P , ? > ) ivOverrideProcessor ; if ( processor != null ) { // This logic is the same as addOrMergeInjectionBinding, except it // uses OverrideInjectionProcessor methods to create and merge // injection bindings rather than InjectionProcessor and // InjectionBinding methods. InjectionBinding < P > injectionBinding = processor . getInjectionBindingForAnnotation ( jndiName ) ; @ SuppressWarnings ( "unchecked" ) OverrideInjectionProcessor < P , A > overrideProcessor = ( OverrideInjectionProcessor < P , A > ) processor ; if ( injectionBinding == null ) { injectionBinding = overrideProcessor . createOverrideInjectionBinding ( instanceClass , member , annotation , jndiName ) ; if ( injectionBinding != null ) { processor . updateInjectionBinding ( jndiName , injectionBinding ) ; processor . addInjectionBinding ( injectionBinding ) ; return injectionBinding ; } } else { overrideProcessor . mergeOverrideInjectionBinding ( instanceClass , member , annotation , injectionBinding ) ; return injectionBinding ; } } return null ; }
Creates and adds a new override injection binding or merges the data in an annotation with an existing override injection binding .
339
24
159,778
void performJavaNameSpaceBinding ( ) throws InjectionException { final boolean isTraceOn = TraceComponent . isAnyTracingEnabled ( ) ; if ( isTraceOn && tc . isEntryEnabled ( ) ) Tr . entry ( tc , "performJavaNameSpaceBinding: " + this ) ; for ( InjectionBinding < A > injectionBinding : ivAllAnnotationsCollection . values ( ) ) { // F743-31682 - Only bind to java:global/:app/:module if needed. if ( injectionBinding . getInjectionScope ( ) == InjectionScope . COMP || ivContext . ivBindNonCompInjectionBindings ) { if ( injectionBinding . getBindingObject ( ) == null ) { if ( isTraceOn && tc . isDebugEnabled ( ) ) Tr . debug ( tc , "skipping empty " + injectionBinding ) ; } else { injectionBinding . bindInjectedObject ( ) ; } } else { if ( isTraceOn && tc . isEntryEnabled ( ) ) Tr . debug ( tc , "skipping non-java:comp " + injectionBinding . toSimpleString ( ) ) ; } } if ( isTraceOn && tc . isEntryEnabled ( ) ) Tr . exit ( tc , "performJavaNameSpaceBinding" ) ; }
Bind all the jndi annotation entries found .
289
10
159,779
public final void addInjectionBinding ( InjectionBinding < A > injectionBinding ) { final boolean isTraceOn = TraceComponent . isAnyTracingEnabled ( ) ; if ( isTraceOn && tc . isDebugEnabled ( ) ) Tr . debug ( tc , "addInjectionBinding: " + injectionBinding ) ; // jndi name not found in collection, simple add ivAllAnnotationsCollection . put ( injectionBinding . getJndiName ( ) , injectionBinding ) ; }
Add the InjectionBinding to the annotationCollection . The collection will be used later when binding and resolving injection targets .
112
24
159,780
protected final String getJavaBeansPropertyName ( Member fieldOrMethod ) { final boolean isTraceOn = TraceComponent . isAnyTracingEnabled ( ) ; if ( isTraceOn && tc . isEntryEnabled ( ) ) Tr . entry ( tc , "getJavaBeansPropertyName : " + fieldOrMethod ) ; String propertyName ; if ( fieldOrMethod instanceof Field ) { Field field = ( Field ) fieldOrMethod ; propertyName = field . getName ( ) ; } else { Method method = ( Method ) fieldOrMethod ; String name = method . getName ( ) ; if ( name . startsWith ( "set" ) && name . length ( ) > 3 && Character . isUpperCase ( name . charAt ( 3 ) ) ) { propertyName = Character . toLowerCase ( name . charAt ( 3 ) ) + ( name . length ( ) > 4 ? name . substring ( 4 ) : "" ) ; } else { propertyName = null ; } } if ( isTraceOn && tc . isEntryEnabled ( ) ) Tr . exit ( tc , "getJavaBeansPropertyName : " + propertyName ) ; return propertyName ; }
F50309 . 5
252
5
159,781
public Set < String > getServerFeatures ( ) { ServerTask serverTask = runningServer . get ( ) ; try { if ( serverTask != null ) return serverTask . getServerFeatures ( ) ; } catch ( InterruptedException e ) { // nothing to do here, we couldn't get the results from the server } return Collections . emptySet ( ) ; }
The feature gather operation needs to launch the server far enough for it to read config and figure out all of the features that would be loaded . It doesn t actually start any of those features but it needs to get far enough to evaluate the full feature set including features and auto - features that are part of Liberty or are provided by product extensions .
76
68
159,782
protected Node findNode ( int nodeStreamID ) { // mainline debug in this recursive method is way to verbose, so only debug when we find what we are looking for if ( nodeStreamID == this . streamID ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "findNode exit: bottom of recursion, found node: " + this ) ; } return this ; } else { Iterator < Node > iter = dependents . iterator ( ) ; Node found = null ; while ( iter . hasNext ( ) ) { found = iter . next ( ) . findNode ( nodeStreamID ) ; if ( found != null ) { return found ; } } return null ; } }
Starting with this node find the node matching the input stream ID look at this node and all dependents recursively . To search the whole tree start by calling findNode on the root node .
162
39
159,783
protected void addDependent ( Node nodeToAdd ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "addDependent entry: node to add: " + nodeToAdd ) ; } dependents . add ( nodeToAdd ) ; }
Add a new dependent to this node .
69
8
159,784
protected void removeDependent ( Node nodeToRemove ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "removeDependent entry: node to remove: " + nodeToRemove ) ; } dependents . remove ( nodeToRemove ) ; }
Remove a dependent from the dependent list this node is keeping
69
11
159,785
protected void clearDependentsWriteCount ( ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "clearDependentsWriteCount entry: for this node: " + this ) ; } dependentWriteCount = 0 ; if ( ( dependents == null ) || ( dependents . size ( ) == 0 ) ) { return ; } for ( int i = 0 ; i < dependents . size ( ) ; i ++ ) { dependents . get ( i ) . setWriteCount ( 0 ) ; } }
clear counts for all direct dependents of this node . also clear the dependent write counter
125
17
159,786
protected Node findNextWrite ( ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "findNextWrite entry: on node " + this + "With status: " + status + "and positive ratio of: " + getPriorityRatioPositive ( ) ) ; } if ( status == NODE_STATUS . REQUESTING_WRITE ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "findNextWrite exit: node to write next is: " + this . toStringDetails ( ) ) ; } return this ; } else { // go through all dependents in order for ( int i = 0 ; i < dependents . size ( ) ; i ++ ) { Node n = dependents . get ( i ) ; Node nextWrite = n . findNextWrite ( ) ; if ( nextWrite != null ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "findNextWrite exit: next write node found. stream-id: " + nextWrite . getStreamID ( ) + " node hc: " + nextWrite . hashCode ( ) ) ; } return nextWrite ; } } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "findNextWrite exit: null" ) ; } return null ; } }
recursively go through the tree finding the highest priority node that is requesting to write .
332
18
159,787
protected int incrementDependentWriteCount ( ) { dependentWriteCount ++ ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "incrementDependentWriteCount entry: new dependentWriteCount of: " + dependentWriteCount + " for node: " + this ) ; } return dependentWriteCount ; }
increment the count since of the number of writes the direct dependents have done since that last reset .
80
21
159,788
protected void setParent ( Node newParent , boolean removeDep ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "setParent entry: new parent will be: " + newParent + " for node: " + this ) ; } Node oldParent = parent ; parent = newParent ; if ( newParent != null ) { parent . addDependent ( this ) ; } // removing dependents can cause ConcurrentModificationException if calling is iterating over a list of dependent nodes // therefore removeDep should be false if setParent is being called while iterating or looping over a list of // dependent nodes. if ( removeDep ) { // remove this node from the old parents list of dependents. if ( oldParent != null ) { if ( newParent == null ) { oldParent . removeDependent ( this ) ; } else if ( oldParent . getStreamID ( ) != parent . getStreamID ( ) ) { oldParent . removeDependent ( this ) ; } } } }
Give this node a new parent . Remove this node as a dependent of the old parent Add this node as a dependent of the new parent .
226
28
159,789
private final AbstractItemLink _next ( long lockID ) throws SevereMessageStoreException { // first look for an available link that we can lock. We scan the tree // removing each element as we find it. If we are able to lock the link // we use it. AbstractItemLink lockedMatchingLink = null ; if ( _jumpbackEnabled ) { while ( null == lockedMatchingLink ) { AbstractItemLink link ; // Get and remove the first AIL in the list of AILs behind the current position synchronized ( this ) { link = _behindList . getFirst ( true ) ; } if ( link == null ) { break ; } else if ( link . lockItemIfAvailable ( lockID ) ) { lockedMatchingLink = link ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "using available: " + lockedMatchingLink ) ; } } } if ( null == lockedMatchingLink ) { // we didn't find and lock an available link, so we must now resume // the traverse of the linked list AbstractItemLink lookAtLink ; synchronized ( this ) { lookAtLink = ( AbstractItemLink ) advance ( ) ; } while ( null != lookAtLink && null == lockedMatchingLink ) { // update our position for each link we examine in the chain long pos = lookAtLink . getPosition ( ) ; synchronized ( this ) { if ( pos > _highestPosition ) { _highestPosition = pos ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "examine " + lookAtLink + "(seq = " + _highestPosition + ")" ) ; } } // try to lock the link // // PAY ATTENTION // // This can read from the persistence layer so we MUST not be synchronized // on this subcursor for the sake of concurrency (although it will not deadlock). // Defect 298364 (sev 1) was raised to reflect a delay of several minutes due to this if ( lookAtLink . lockIfMatches ( _filter , lockID ) ) { // we matched and locked the link lockedMatchingLink = lookAtLink ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "found: " + lockedMatchingLink ) ; } else { // we didn't get the link - it didn't match or didn't lock. Advance synchronized ( this ) { lookAtLink = ( AbstractItemLink ) advance ( ) ; } } } } return lockedMatchingLink ; }
Finds and locks the next matching item .
575
9
159,790
public final void available ( AbstractItemLink link ) throws SevereMessageStoreException { if ( _jumpbackEnabled ) { final long newPos = link . getPosition ( ) ; // we need to synchronize the read of the position // or we can miss out items when reading an empty queue fast. // More importantly, the removal of the next from the cursor cannot // happen while we are adding the available synchronized ( this ) { if ( newPos <= _highestPosition ) { // Only store matching links, 'coz its quicker if ( null != link . matches ( _filter ) ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "availableLink adding: " + link ) ; _behindList . insert ( link ) ; } else { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "availableLink does not match: " + link ) ; } } else { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "availableLink seq(" + newPos + ") too large (" + _highestPosition + ")" ) ; } } } else { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "available link - jumpbackDisabled: " + link ) ; } }
The cursor is being told that a link has become available . Add it to the list to revisit but only if it is older than the current cursor position .
328
31
159,791
public final AbstractItem next ( long lockID ) throws SevereMessageStoreException { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( this , tc , "next" , Long . valueOf ( lockID ) ) ; final AbstractItemLink lockedMatchingLink = _next ( lockID ) ; // retrieve the item from the link AbstractItem lockedMatchingItem = null ; if ( null != lockedMatchingLink ) { lockedMatchingItem = lockedMatchingLink . getItem ( ) ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( this , tc , "next" , lockedMatchingItem ) ; return lockedMatchingItem ; }
Return the next item that is deemed a match by the filter specified when the cursor was created . Items returned by this method are locked .
168
27
159,792
public final void finished ( ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( this , tc , "finished" ) ; if ( null != _lastLink ) { _lastLink . cursorRemoved ( ) ; _lastLink = null ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( this , tc , "finished" ) ; }
Signals that use of the cursor has finished . The cursor is removed from the AIL that it currently rests on .
105
24
159,793
private void callTransactionalLifecycleInterceptors ( InterceptorProxy [ ] proxies , int methodId ) throws RemoteException { final boolean isTraceOn = TraceComponent . isAnyTracingEnabled ( ) ; LifecycleInterceptorWrapper wrapper = new LifecycleInterceptorWrapper ( container , this ) ; EJSDeployedSupport s = new EJSDeployedSupport ( ) ; // F743761.CodRv - Exceptions from lifecycle callback interceptors do not // throw application exceptions. s . ivIgnoreApplicationExceptions = true ; try { container . preInvokeForLifecycleInterceptors ( wrapper , methodId , s , this ) ; // F743-1751CodRev - Inline callLifecycleInterceptors. We need to // manage HandleList separately. if ( isTraceOn ) // d527372 { if ( TEBeanLifeCycleInfo . isTraceEnabled ( ) ) TEBeanLifeCycleInfo . traceEJBCallEntry ( LifecycleInterceptorWrapper . TRACE_NAMES [ methodId ] ) ; if ( tc . isDebugEnabled ( ) ) Tr . debug ( tc , "callLifecycleInterceptors" ) ; } InvocationContextImpl < ? > inv = getInvocationContext ( ) ; BeanMetaData bmd = home . beanMetaData ; inv . doLifeCycle ( proxies , bmd . _moduleMetaData ) ; // F743-14982 } catch ( Throwable t ) { s . setUncheckedLocalException ( t ) ; } finally { if ( isTraceOn && TEBeanLifeCycleInfo . isTraceEnabled ( ) ) { TEBeanLifeCycleInfo . traceEJBCallExit ( LifecycleInterceptorWrapper . TRACE_NAMES [ methodId ] ) ; } container . postInvokeForLifecycleInterceptors ( wrapper , methodId , s ) ; } }
Invoke PostConstruct or PreDestroy interceptors associated with this bean using the transaction and security context specified in the method info .
420
25
159,794
@ Override public void postInvoke ( int id , EJSDeployedSupport s ) throws RemoteException { final boolean isTraceOn = TraceComponent . isAnyTracingEnabled ( ) ; if ( isTraceOn && tc . isEntryEnabled ( ) ) { Tr . entry ( tc , "postInvoke" ) ; } // Release lock acquired if container managed concurrency control. if ( ivContainerManagedConcurrency && s . ivLockAcquired ) { // Get the lock type to use for the method being invoked. EJBMethodInfoImpl mInfo = s . methodInfo ; LockType lockType = mInfo . ivLockType ; if ( lockType == LockType . READ ) { ivReadLock . unlock ( ) ; if ( isTraceOn && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "postInvoke released read lock: " + ivLock . toString ( ) ) ; } } else { ivWriteLock . unlock ( ) ; if ( isTraceOn && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "postInvoke released write lock: " + ivLock . toString ( ) ) ; } } } if ( isTraceOn && tc . isEntryEnabled ( ) ) { Tr . exit ( tc , "postInvoke" ) ; } }
Release lock acquired by preInvoke .
285
8
159,795
private Class < ? > resolveClassWithCL ( String name ) throws ClassNotFoundException { SecurityManager security = System . getSecurityManager ( ) ; if ( security != null ) { return Class . forName ( name , false , getClassLoader ( thisClass ) ) ; } // The platform classloader is null if we failed to get it when using java 9, or if we are // running with a java level below 9. In those cases, the bootstrap classloader // is used to resolve the needed class. // Note that this change is being made to account for the fact that in java 9, classes // such as java.sql.* (java.sql module) are no longer discoverable through the bootstrap // classloader. Those classes are now discoverable through the java 9 platform classloader. // The platform classloader is between the bootstrap classloader and the app classloader. return Class . forName ( name , false , platformClassloader ) ; }
Resolves a class using the appropriate classloader .
200
10
159,796
@ Override protected Class < ? > resolveProxyClass ( String [ ] interfaceNames ) throws ClassNotFoundException { ClassLoader proxyClassLoader = classLoader ; Class < ? > [ ] interfaces = new Class [ interfaceNames . length ] ; Class < ? > nonPublicInterface = null ; for ( int i = 0 ; i < interfaceNames . length ; i ++ ) { Class < ? > intf = loadClass ( interfaceNames [ i ] ) ; if ( ! Modifier . isPublic ( intf . getModifiers ( ) ) ) { ClassLoader classLoader = getClassLoader ( intf ) ; if ( nonPublicInterface != null ) { if ( classLoader != proxyClassLoader ) { throw new IllegalAccessError ( nonPublicInterface + " and " + intf + " both declared non-public in different class loaders" ) ; } } else { nonPublicInterface = intf ; proxyClassLoader = classLoader ; } } interfaces [ i ] = intf ; } try { return Proxy . getProxyClass ( proxyClassLoader , interfaces ) ; } catch ( IllegalArgumentException ex ) { throw new ClassNotFoundException ( null , ex ) ; } }
Delegates class loading to the specified class loader .
247
10
159,797
private static ClassLoader getPlatformClassLoader ( ) { if ( JavaInfo . majorVersion ( ) >= 9 ) { return AccessController . doPrivileged ( new PrivilegedAction < ClassLoader > ( ) { @ Override public ClassLoader run ( ) { ClassLoader pcl = null ; try { Method getPlatformClassLoader = ClassLoader . class . getMethod ( "getPlatformClassLoader" ) ; pcl = ( ClassLoader ) getPlatformClassLoader . invoke ( null ) ; } catch ( Throwable t ) { // Log an FFDC. } return pcl ; } } ) ; } return null ; }
Returns the PlatformClassloader when running with java 9 and above ; otherwise returns null .
129
17
159,798
@ Override public void setAsynchConsumerCallback ( int requestNumber , int maxActiveMessages , long messageLockExpiry , int batchsize , OrderingContext orderContext , boolean stoppable , int maxSequentialFailures , long hiddenMessageDelay ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( this , tc , "setAsynchConsumerCallback" , new Object [ ] { requestNumber , maxActiveMessages , messageLockExpiry , batchsize , orderContext , stoppable , maxSequentialFailures , hiddenMessageDelay } ) ; try { // Here we need to examine the config parameter that will denote whether we are telling // MP to inline our async callbacks or not. We will default to false, but this can // be overrideen. boolean inlineCallbacks = CommsUtils . getRuntimeBooleanProperty ( CommsConstants . INLINE_ASYNC_CBACKS_KEY , CommsConstants . INLINE_ASYNC_CBACKS ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( tc , "Inline async callbacks: " + inlineCallbacks ) ; MPConsumerSession session = ( MPConsumerSession ) getConsumerSession ( ) ; if ( stoppable ) { session . registerStoppableAsynchConsumerCallback ( this , maxActiveMessages , messageLockExpiry , batchsize , getUnrecoverableReliability ( ) , inlineCallbacks , orderContext , maxSequentialFailures , hiddenMessageDelay ) ; } else { session . registerAsynchConsumerCallback ( this , maxActiveMessages , messageLockExpiry , batchsize , getUnrecoverableReliability ( ) , inlineCallbacks , orderContext ) ; } try { getConversation ( ) . send ( poolManager . allocate ( ) , JFapChannelConstants . SEG_REGISTER_ASYNC_CONSUMER_R , requestNumber , JFapChannelConstants . PRIORITY_MEDIUM , true , ThrottlingPolicy . BLOCK_THREAD , null ) ; } catch ( SIException e ) { FFDCFilter . processException ( e , CLASS_NAME + ".setAsynchConsumerCallback" , CommsConstants . CATASYNCHCONSUMER_SETCALLBACK_01 , this ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , e . getMessage ( ) , e ) ; SibTr . error ( tc , "COMMUNICATION_ERROR_SICO2017" , e ) ; } // End d175222 } catch ( SIException e ) { //No FFDC code needed //Only FFDC if we haven't received a meTerminated event. if ( ! ( ( ConversationState ) getConversation ( ) . getAttachment ( ) ) . hasMETerminated ( ) ) { FFDCFilter . processException ( e , CLASS_NAME + ".setAsynchConsumerCallback" , CommsConstants . CATASYNCHCONSUMER_SETCALLBACK_02 , this ) ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( tc , e . getMessage ( ) , e ) ; StaticCATHelper . sendExceptionToClient ( e , CommsConstants . CATASYNCHCONSUMER_SETCALLBACK_02 , getConversation ( ) , requestNumber ) ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( this , tc , "setAsynchConsumerCallback" ) ; }
Creates a normal or stoppable async consumer for this session . This is called in response to the request from a client . This differs from readahead or synchronous sessions where an async callback is registered without the client knowing .
832
45
159,799
@ Override public void flush ( int requestNumber ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( this , tc , "flush" , "" + requestNumber ) ; try { // Make sure it is stopped before we activate it if ( mainConsumer . isStarted ( ) ) getConsumerSession ( ) . stop ( ) ; getConsumerSession ( ) . activateAsynchConsumer ( true ) ; if ( mainConsumer . isStarted ( ) ) getConsumerSession ( ) . start ( false ) ; short jfapPriority = JFapChannelConstants . getJFAPPriority ( Integer . valueOf ( mainConsumer . getLowestPriority ( ) ) ) ; // d172528 if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "Sending with JFAP priority of " + jfapPriority ) ; // d172528 try { getConversation ( ) . send ( poolManager . allocate ( ) , JFapChannelConstants . SEG_FLUSH_SESS_R , requestNumber , jfapPriority , true , ThrottlingPolicy . BLOCK_THREAD , null ) ; } catch ( SIException e ) { FFDCFilter . processException ( e , CLASS_NAME + ".flush" , CommsConstants . CATASYNCHCONSUMER_FLUSH_01 , this ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( tc , e . getMessage ( ) , e ) ; SibTr . error ( tc , "COMMUNICATION_ERROR_SICO2017" , e ) ; } } catch ( SIException e ) { //No FFDC code needed //Only FFDC if we haven't received a meTerminated event. if ( ! ( ( ConversationState ) getConversation ( ) . getAttachment ( ) ) . hasMETerminated ( ) ) { FFDCFilter . processException ( e , CLASS_NAME + ".flush" , CommsConstants . CATASYNCHCONSUMER_FLUSH_02 , this ) ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , e . getMessage ( ) , e ) ; StaticCATHelper . sendExceptionToClient ( e , CommsConstants . CATASYNCHCONSUMER_FLUSH_02 , getConversation ( ) , requestNumber ) ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( this , tc , "flush" ) ; }
This method will flush the consumer to ensure it is completely out of messages .
616
15