idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
139,400
public void addEngineCommand ( String command ) { if ( command == null || command . length ( ) == 0 ) { return ; } int p = command . indexOf ( ' ' ) ; String arg = "" ; if ( p > 0 ) { arg = command . substring ( p + 1 ) ; command = command . substring ( 0 , p ) ; } StringBuilder sb = new StringBuilder ( ) ; sb . append ( _engineCommands ) ; sb . append ( "\1" ) ; sb . append ( command ) ; sb . append ( "\1" ) ; sb . append ( arg ) ; _engineCommands = sb . toString ( ) ; }
Sets the engine - commands
149
6
139,401
public void nextProtocols ( String ... protocols ) { if ( protocols == null || protocols . length == 0 ) { _nextProtocols = null ; return ; } StringBuilder sb = new StringBuilder ( ) ; for ( String protocol : protocols ) { if ( protocol == null || "" . equals ( protocol ) ) { continue ; } sb . append ( ( char ) protocol . length ( ) ) ; sb . append ( protocol ) ; } _nextProtocols = sb . toString ( ) ; }
Sets the next protocols .
111
6
139,402
public void setVerifyClient ( String verifyClient ) throws ConfigException { if ( ! "optional_no_ca" . equals ( verifyClient ) && ! "optional-no-ca" . equals ( verifyClient ) && ! "optional" . equals ( verifyClient ) && ! "require" . equals ( verifyClient ) && ! "none" . equals ( verifyClient ) ) throw new ConfigException ( L . l ( "'{0}' is an unknown value for verify-client. Valid values are 'optional-no-ca', 'optional', and 'require'." , verifyClient ) ) ; if ( "none" . equals ( verifyClient ) ) _verifyClient = null ; else _verifyClient = verifyClient ; }
Sets the verifyClient .
155
6
139,403
public synchronized ByteBuffer allocateHeaderBuffer ( ) { Stack < ByteBuffer > pool = pools . get ( HEADER_SIZE ) ; if ( pool . isEmpty ( ) ) { return ByteBuffer . allocate ( HEADER_SIZE ) ; } else { return pool . pop ( ) ; } }
Returns a buffer that has the size of the Bitmessage network message header 24 bytes .
61
17
139,404
public boolean compileIsModified ( ) { if ( _compileIsModified ) return true ; CompileThread compileThread = new CompileThread ( ) ; ThreadPool . current ( ) . start ( compileThread ) ; try { synchronized ( compileThread ) { if ( ! compileThread . isDone ( ) ) compileThread . wait ( 5000 ) ; } if ( _compileIsModified ) return true ; else if ( compileThread . isDone ( ) ) { //setDependPath(getClassPath()); return reloadIsModified ( ) ; } else return true ; } catch ( Throwable e ) { } return false ; }
Returns true if the compile doesn t avoid the dependency .
135
11
139,405
ServiceRefAmp lookup ( String path , PodRef podCaller ) { if ( _linkServiceRef . address ( ) . startsWith ( "local:" ) ) { int p = path . indexOf ( ' ' , 1 ) ; if ( p > 0 ) { // champ path is /pod.0/path // return (ServiceRefAmp) _champService.lookup(path); return ( ServiceRefAmp ) _rampManager . service ( path . substring ( p ) ) ; } else { return ( ServiceRefAmp ) _rampManager . service ( path ) ; //return (ServiceRefAmp) _rampManager.lookup("local://"); } } else { ServiceRefAmp linkRef = getLinkServiceRef ( podCaller ) ; return linkRef . onLookup ( path ) ; } }
Lookup returns a ServiceRef for the foreign path and calling pod .
181
14
139,406
public static StdoutStream create ( ) { if ( _stdout == null ) { _stdout = new StdoutStream ( ) ; ConstPath path = new ConstPath ( null , _stdout ) ; path . setScheme ( "stdout" ) ; //_stdout.setPath(path); } return _stdout ; }
Returns the StdoutStream singleton
75
8
139,407
public void write ( byte [ ] buf , int offset , int length , boolean isEnd ) throws IOException { System . out . write ( buf , offset , length ) ; System . out . flush ( ) ; }
Writes the data to the System . out .
45
10
139,408
public static ThreadDump create ( ) { ThreadDump threadDump = _threadDumpRef . get ( ) ; if ( threadDump == null ) { threadDump = new ThreadDumpPro ( ) ; _threadDumpRef . compareAndSet ( null , threadDump ) ; threadDump = _threadDumpRef . get ( ) ; } return threadDump ; }
Returns the singleton instance creating if necessary . An instance of com . caucho . server . admin . ProThreadDump will be returned if available and licensed . ProThreadDump includes the URI of the request the thread is processing if applicable .
85
51
139,409
public String getThreadDump ( int depth , boolean onlyActive ) { ThreadMXBean threadBean = ManagementFactory . getThreadMXBean ( ) ; long [ ] ids = threadBean . getAllThreadIds ( ) ; ThreadInfo [ ] info = threadBean . getThreadInfo ( ids , depth ) ; StringBuilder sb = new StringBuilder ( ) ; sb . append ( "Thread Dump generated " + new Date ( CurrentTime . currentTime ( ) ) ) ; Arrays . sort ( info , new ThreadCompare ( ) ) ; buildThreads ( sb , info , Thread . State . RUNNABLE , false ) ; buildThreads ( sb , info , Thread . State . RUNNABLE , true ) ; if ( ! onlyActive ) { buildThreads ( sb , info , Thread . State . BLOCKED , false ) ; buildThreads ( sb , info , Thread . State . WAITING , false ) ; buildThreads ( sb , info , Thread . State . TIMED_WAITING , false ) ; buildThreads ( sb , info , null , false ) ; } return sb . toString ( ) ; }
Returns dump of threads . Optionally uses cached dump .
257
11
139,410
private boolean readFlow ( ReadStream is , int length , int streamId ) throws IOException { if ( length != 4 ) { error ( "Invalid window update length {0}" , length ) ; return false ; } int credit = BitsUtil . readInt ( is ) ; if ( streamId == 0 ) { _conn . channelZero ( ) . addSendCredit ( credit ) ; return true ; } ChannelHttp2 channel = _conn . getChannel ( streamId ) ; if ( channel == null ) { return true ; } channel . getOutChannel ( ) . addSendCredit ( _conn . outHttp ( ) , credit ) ; return true ; }
window - update
138
3
139,411
private boolean readGoAway ( ReadStream is , int length ) throws IOException { int lastStream = BitsUtil . readInt ( is ) ; int errorCode = BitsUtil . readInt ( is ) ; is . skip ( length - 8 ) ; _isGoAway = true ; _conn . onReadGoAway ( ) ; if ( onCloseStream ( ) <= 0 ) { _inHandler . onGoAway ( ) ; } return true ; }
go - away
101
3
139,412
private boolean readMetaHeader ( ) throws IOException { try ( ReadStream is = openRead ( 0 , META_SEGMENT_SIZE ) ) { int crc = 17 ; long magic = BitsUtil . readLong ( is ) ; if ( magic != KELP_MAGIC ) { System . out . println ( "WRONG_MAGIC: " + magic ) ; return false ; } crc = Crc32Caucho . generate ( crc , magic ) ; _nonce = BitsUtil . readInt ( is ) ; crc = Crc32Caucho . generateInt32 ( crc , _nonce ) ; int headers = BitsUtil . readInt ( is ) ; crc = Crc32Caucho . generateInt32 ( crc , headers ) ; for ( int i = 0 ; i < headers ; i ++ ) { int key = BitsUtil . readInt ( is ) ; crc = Crc32Caucho . generateInt32 ( crc , key ) ; int value = BitsUtil . readInt ( is ) ; crc = Crc32Caucho . generateInt32 ( crc , value ) ; } int count = BitsUtil . readInt ( is ) ; crc = Crc32Caucho . generateInt32 ( crc , count ) ; ArrayList < Integer > segmentSizes = new ArrayList <> ( ) ; for ( int i = 0 ; i < count ; i ++ ) { int size = BitsUtil . readInt ( is ) ; crc = Crc32Caucho . generateInt32 ( crc , size ) ; segmentSizes . add ( size ) ; } int crcFile = BitsUtil . readInt ( is ) ; if ( crc != crcFile ) { System . out . println ( "MISMATCHED_CRC: " + crcFile ) ; return false ; } _metaSegment = new SegmentExtent10 ( 0 , 0 , META_SEGMENT_SIZE ) ; _segmentId = 1 ; _metaOffset = is . position ( ) ; } return true ; }
Reads the initial metadata for the store file as a whole .
462
13
139,413
private boolean readMetaData ( ) throws IOException { SegmentExtent10 segment = _metaSegment ; try ( ReadStream is = openRead ( segment . address ( ) , segment . length ( ) ) ) { is . position ( META_OFFSET ) ; while ( readMetaEntry ( is ) ) { } } return true ; }
Reads the metadata entries for the tables and the segments .
73
12
139,414
private boolean readMetaTable ( ReadStream is , int crc ) throws IOException { byte [ ] key = new byte [ TABLE_KEY_SIZE ] ; is . read ( key , 0 , key . length ) ; crc = Crc32Caucho . generate ( crc , key ) ; int rowLength = BitsUtil . readInt16 ( is ) ; crc = Crc32Caucho . generateInt16 ( crc , rowLength ) ; int keyOffset = BitsUtil . readInt16 ( is ) ; crc = Crc32Caucho . generateInt16 ( crc , keyOffset ) ; int keyLength = BitsUtil . readInt16 ( is ) ; crc = Crc32Caucho . generateInt16 ( crc , keyLength ) ; int dataLength = BitsUtil . readInt16 ( is ) ; crc = Crc32Caucho . generateInt16 ( crc , dataLength ) ; byte [ ] data = new byte [ dataLength ] ; is . read ( data ) ; crc = Crc32Caucho . generate ( crc , data ) ; int crcFile = BitsUtil . readInt ( is ) ; if ( crcFile != crc ) { log . fine ( "meta-table crc mismatch" ) ; System . out . println ( "meta-table crc mismatch" ) ; return false ; } RowUpgrade row = new RowUpgrade10 ( keyOffset , keyLength ) . read ( data ) ; TableEntry10 table = new TableEntry10 ( key , rowLength , keyOffset , keyLength , row ) ; _tableList . add ( table ) ; return true ; }
Reads metadata for a table .
362
7
139,415
private void readSegments ( ) throws IOException { for ( SegmentExtent10 extent : _segmentExtents ) { try ( ReadStream is = openRead ( extent . address ( ) , extent . length ( ) ) ) { is . skip ( extent . length ( ) - BLOCK_SIZE ) ; long sequence = BitsUtil . readLong ( is ) ; byte [ ] tableKey = new byte [ TABLE_KEY_SIZE ] ; is . readAll ( tableKey , 0 , tableKey . length ) ; // XXX: crc if ( sequence > 0 ) { Segment10 segment = new Segment10 ( sequence , tableKey , extent ) ; _segments . add ( segment ) ; } } } }
Reads the segment metadata the sequence and table key .
154
11
139,416
private void upgradeDatabase ( KelpUpgrade upgradeKelp ) throws IOException { Collections . sort ( _tableList , ( x , y ) -> x . row ( ) . name ( ) . compareTo ( y . row ( ) . name ( ) ) ) ; for ( TableEntry10 table : _tableList ) { TableUpgrade upgradeTable = upgradeKelp . table ( table . key ( ) , table . row ( ) ) ; upgradeTable ( table , upgradeTable ) ; } }
Upgrade the store
104
3
139,417
private void upgradeTable ( TableEntry10 table , TableUpgrade upgradeTable ) throws IOException { _pageMap = new TreeMap <> ( ) ; readTableIndex ( table ) ; for ( Page10 page : _pageMap . values ( ) ) { upgradeLeaf ( table , upgradeTable , page ) ; List < Delta10 > deltas = page . deltas ( ) ; if ( deltas != null ) { for ( Delta10 delta : deltas ) { upgradeDelta ( table , upgradeTable , page , delta ) ; } } } }
Upgrade rows from a table .
119
6
139,418
private void readTableIndex ( TableEntry10 table ) throws IOException { for ( Segment10 segment : tableSegments ( table ) ) { try ( ReadStream is = openRead ( segment . address ( ) , segment . length ( ) ) ) { readSegmentIndex ( is , segment ) ; } } }
Read all page metadata for a table .
66
8
139,419
private void readSegmentIndex ( ReadStream is , Segment10 segment ) throws IOException { int address = segment . length ( ) - BLOCK_SIZE ; TempBuffer tBuf = TempBuffer . create ( ) ; byte [ ] buffer = tBuf . buffer ( ) ; is . position ( address ) ; is . read ( buffer , 0 , BLOCK_SIZE ) ; int tail = BitsUtil . readInt16 ( buffer , FOOTER_OFFSET ) ; if ( tail < TABLE_KEY_SIZE + 8 || tail > BLOCK_SIZE - 8 ) { return ; } int offset = INDEX_OFFSET ; while ( offset < tail ) { int type = buffer [ offset ++ ] & 0xff ; int pid = BitsUtil . readInt ( buffer , offset ) ; offset += 4 ; int nextPid = BitsUtil . readInt ( buffer , offset ) ; offset += 4 ; int entryAddress = BitsUtil . readInt ( buffer , offset ) ; offset += 4 ; int entryLength = BitsUtil . readInt ( buffer , offset ) ; offset += 4 ; if ( pid <= 1 ) { System . out . println ( "INVALID_PID: " + pid ) ; return ; } switch ( PageType10 . values ( ) [ type ] ) { case LEAF : addLeaf ( segment , pid , nextPid , entryAddress , entryLength ) ; break ; case LEAF_DELTA : addLeafDelta ( segment , pid , nextPid , entryAddress , entryLength ) ; break ; default : System . out . println ( "UNKNOWN-SEGMENT: " + PageType10 . values ( ) [ type ] ) ; } } }
Read page index from a segment .
366
7
139,420
private void addLeaf ( Segment10 segment , int pid , int nextPid , int address , int length ) { Page10 page = _pageMap . get ( pid ) ; if ( page != null && page . sequence ( ) < segment . sequence ( ) ) { return ; } page = new Page10 ( PageType10 . LEAF , segment , pid , nextPid , address , length ) ; _pageMap . put ( pid , page ) ; }
Adds a new leaf entry to the page list .
99
10
139,421
private void addLeafDelta ( Segment10 segment , int pid , int nextPid , int address , int length ) { Page10 page = _pageMap . get ( pid ) ; if ( page != null && page . sequence ( ) < segment . sequence ( ) ) { return ; } if ( page != null ) { page . addDelta ( address , length ) ; } }
Adds a new leaf delta to the page list .
81
10
139,422
private ArrayList < Segment10 > tableSegments ( TableEntry10 table ) { ArrayList < Segment10 > tableSegments = new ArrayList <> ( ) ; for ( Segment10 segment : _segments ) { if ( Arrays . equals ( segment . key ( ) , table . key ( ) ) ) { tableSegments . add ( segment ) ; } } Collections . sort ( tableSegments , ( x , y ) -> Long . signum ( y . sequence ( ) - x . sequence ( ) ) ) ; return tableSegments ; }
Returns segments for a table in reverse sequence order .
120
10
139,423
private void upgradeLeaf ( TableEntry10 table , TableUpgrade upgradeTable , Page10 page ) throws IOException { try ( ReadStream is = openRead ( page . segment ( ) . address ( ) , page . segment ( ) . length ( ) ) ) { is . position ( page . address ( ) ) ; byte [ ] minKey = new byte [ table . keyLength ( ) ] ; byte [ ] maxKey = new byte [ table . keyLength ( ) ] ; is . read ( minKey , 0 , minKey . length ) ; is . read ( maxKey , 0 , maxKey . length ) ; int blocks = BitsUtil . readInt16 ( is ) ; for ( int i = 0 ; i < blocks ; i ++ ) { upgradeLeafBlock ( is , table , upgradeTable , page ) ; } } }
Upgrade a table page .
177
5
139,424
private void upgradeLeafBlock ( ReadStream is , TableEntry10 table , TableUpgrade upgradeTable , Page10 page ) throws IOException { TempBuffer tBuf = TempBuffer . create ( ) ; byte [ ] buffer = tBuf . buffer ( ) ; int blobLen = BitsUtil . readInt16 ( is ) ; is . readAll ( buffer , 0 , blobLen ) ; int rowDataLen = BitsUtil . readInt16 ( is ) ; int rowOffset = buffer . length - rowDataLen ; is . readAll ( buffer , rowOffset , rowDataLen ) ; int rowLen = table . rowLength ( ) ; int keyLen = table . keyLength ( ) ; while ( rowOffset < buffer . length ) { int code = buffer [ rowOffset ] & CODE_MASK ; switch ( code ) { case INSERT : rowInsert ( table . row ( ) , upgradeTable , buffer , rowOffset ) ; rowOffset += rowLen ; break ; case REMOVE : rowOffset += keyLen + STATE_LENGTH ; break ; default : System . out . println ( "UNKNOWN: " + Integer . toHexString ( code ) ) ; return ; } } tBuf . free ( ) ; }
Reads data for a leaf .
263
7
139,425
private void upgradeDelta ( TableEntry10 table , TableUpgrade upgradeTable , Page10 page , Delta10 delta ) throws IOException { try ( ReadStream is = openRead ( page . segment ( ) . address ( ) , page . segment ( ) . length ( ) ) ) { is . position ( delta . address ( ) ) ; long tail = delta . address ( ) + delta . length ( ) ; while ( is . position ( ) < tail ) { upgradeDelta ( is , table , upgradeTable , page ) ; } } }
Upgrade a table leaf delta .
111
6
139,426
private void rowInsert ( RowUpgrade row , TableUpgrade upgradeTable , byte [ ] buffer , int offset ) { Cursor10 cursor = new Cursor10 ( row , buffer , offset ) ; upgradeTable . row ( cursor ) ; }
Insert a row .
49
4
139,427
private ReadStream openRead ( long address , int size ) { InStore inStore = _store . openRead ( address , size ) ; InStoreStream is = new InStoreStream ( inStore , address , address + size ) ; return new ReadStream ( new VfsStream ( is ) ) ; }
Open a read stream to a segment .
64
8
139,428
public void writeClass ( String className ) throws IOException { ConstantPool pool = _javaClass . getConstantPool ( ) ; ClassConstant classConst = pool . getClass ( className ) ; if ( classConst != null ) writeShort ( classConst . getIndex ( ) ) ; else writeShort ( 0 ) ; }
Writes a class constant .
70
6
139,429
public void writeUTF8Const ( String value ) throws IOException { ConstantPool pool = _javaClass . getConstantPool ( ) ; Utf8Constant entry = pool . getUTF8 ( value ) ; if ( entry != null ) writeShort ( entry . getIndex ( ) ) ; else throw new NullPointerException ( L . l ( "utf8 constant {0} does not exist" , value ) ) ; }
Writes a UTF8 constant .
91
7
139,430
public void writeFloat ( float v ) throws IOException { int bits = Float . floatToIntBits ( v ) ; _os . write ( bits >> 24 ) ; _os . write ( bits >> 16 ) ; _os . write ( bits >> 8 ) ; _os . write ( bits ) ; }
Writes a float
65
4
139,431
public void writeDouble ( double v ) throws IOException { long bits = Double . doubleToLongBits ( v ) ; _os . write ( ( int ) ( bits >> 56 ) ) ; _os . write ( ( int ) ( bits >> 48 ) ) ; _os . write ( ( int ) ( bits >> 40 ) ) ; _os . write ( ( int ) ( bits >> 32 ) ) ; _os . write ( ( int ) ( bits >> 24 ) ) ; _os . write ( ( int ) ( bits >> 16 ) ) ; _os . write ( ( int ) ( bits >> 8 ) ) ; _os . write ( ( int ) bits ) ; }
Writes a double
143
4
139,432
public String getDefaultArg ( ) { String defaultArg = null ; if ( _defaultArgs . length > 0 ) { defaultArg = _defaultArgs [ 0 ] ; } return defaultArg ; }
finds first argument that follows no dash prefixed token
41
11
139,433
private Iterator detailChildrenIterator ( Detail detail ) { /* sb.append("<ns2:AccessDeniedWebServiceException xmlns:ns2=\"http://exceptionthrower.system.services.v4_0.soap.server.nameapi.org/\">"); sb.append("<blame>CLIENT</blame>"); sb.append("<errorCode>2101</errorCode>"); sb.append("<faultCause>AccessDenied</faultCause>"); */ DetailEntry firstDetailEntry = getFirstDetailEntry ( detail ) ; if ( firstDetailEntry != null ) { String localName = firstDetailEntry . getElementName ( ) . getLocalName ( ) ; if ( localName . endsWith ( "Exception" ) ) { //got a subtag return firstDetailEntry . getChildElements ( ) ; } } return detail . getDetailEntries ( ) ; }
It can either e within an extra tag or directly .
206
11
139,434
private boolean [ ] parseRange ( String range , int rangeMin , int rangeMax ) throws ConfigException { boolean [ ] values = new boolean [ rangeMax + 1 ] ; int j = 0 ; while ( j < range . length ( ) ) { char ch = range . charAt ( j ) ; int min = 0 ; int max = 0 ; int step = 1 ; if ( ch == ' ' ) { min = rangeMin ; max = rangeMax ; j ++ ; } else if ( ' ' <= ch && ch <= ' ' ) { for ( ; j < range . length ( ) && ' ' <= ( ch = range . charAt ( j ) ) && ch <= ' ' ; j ++ ) { min = 10 * min + ch - ' ' ; } if ( j < range . length ( ) && ch == ' ' ) { for ( j ++ ; j < range . length ( ) && ' ' <= ( ch = range . charAt ( j ) ) && ch <= ' ' ; j ++ ) { max = 10 * max + ch - ' ' ; } } else max = min ; } else throw new ConfigException ( L . l ( "'{0}' is an illegal cron range" , range ) ) ; if ( min < rangeMin ) throw new ConfigException ( L . l ( "'{0}' is an illegal cron range (min value is too small)" , range ) ) ; else if ( rangeMax < max ) throw new ConfigException ( L . l ( "'{0}' is an illegal cron range (max value is too large)" , range ) ) ; if ( j < range . length ( ) && ( ch = range . charAt ( j ) ) == ' ' ) { step = 0 ; for ( j ++ ; j < range . length ( ) && ' ' <= ( ch = range . charAt ( j ) ) && ch <= ' ' ; j ++ ) { step = 10 * step + ch - ' ' ; } if ( step == 0 ) throw new ConfigException ( L . l ( "'{0}' is an illegal cron range" , range ) ) ; } if ( range . length ( ) <= j ) { } else if ( ch == ' ' ) j ++ ; else { throw new ConfigException ( L . l ( "'{0}' is an illegal cron range" , range ) ) ; } for ( ; min <= max ; min += step ) values [ min ] = true ; } return values ; }
parses a range following cron rules .
526
10
139,435
public void init ( StreamImpl source ) { _disableClose = false ; _isDisableCloseSource = false ; _readTime = 0 ; if ( _source != null && _source != source ) { close ( ) ; } if ( source == null ) { throw new IllegalArgumentException ( ) ; } _source = source ; if ( source . canRead ( ) ) { if ( _tempRead == null ) { _tempRead = TempBuffer . create ( ) ; _readBuffer = _tempRead . buffer ( ) ; } } _readOffset = 0 ; _readLength = 0 ; _readEncoding = null ; _readEncodingName = "ISO-8859-1" ; }
Initializes the stream with a given source .
148
9
139,436
public void setEncoding ( String encoding ) throws UnsupportedEncodingException { String mimeName = Encoding . getMimeName ( encoding ) ; if ( mimeName != null && mimeName . equals ( _readEncodingName ) ) return ; _readEncoding = Encoding . getReadEncoding ( this , encoding ) ; _readEncodingName = mimeName ; }
Sets the current read encoding . The encoding can either be a Java encoding name or a mime encoding .
84
22
139,437
public final int readChar ( ) throws IOException { if ( _readEncoding != null ) { int ch = _readEncoding . read ( ) ; return ch ; } if ( _readLength <= _readOffset ) { if ( ! readBuffer ( ) ) return - 1 ; } return _readBuffer [ _readOffset ++ ] & 0xff ; }
Reads a character from the stream returning - 1 on end of file .
76
15
139,438
public final int read ( char [ ] buf , int offset , int length ) throws IOException { if ( _readEncoding != null ) { return _readEncoding . read ( buf , offset , length ) ; } byte [ ] readBuffer = _readBuffer ; if ( readBuffer == null ) return - 1 ; int readOffset = _readOffset ; int readLength = _readLength ; int sublen = Math . min ( length , readLength - readOffset ) ; if ( readLength <= readOffset ) { if ( ! readBuffer ( ) ) { return - 1 ; } readLength = _readLength ; readOffset = _readOffset ; sublen = Math . min ( length , readLength - readOffset ) ; } for ( int i = sublen - 1 ; i >= 0 ; i -- ) { buf [ offset + i ] = ( char ) ( readBuffer [ readOffset + i ] & 0xff ) ; } _readOffset = readOffset + sublen ; return sublen ; }
Reads into a character buffer from the stream . Like the byte array version read may return less characters even though more characters are available .
212
27
139,439
public int read ( CharBuffer buf , int length ) throws IOException { int len = buf . length ( ) ; buf . length ( len + length ) ; int readLength = read ( buf . buffer ( ) , len , length ) ; if ( readLength < 0 ) { buf . length ( len ) ; } else if ( readLength < length ) { buf . length ( len + readLength ) ; } return length ; }
Reads characters from the stream appending to the character buffer .
90
13
139,440
public int readInt ( ) throws IOException { if ( _readOffset + 4 < _readLength ) { return ( ( ( _readBuffer [ _readOffset ++ ] & 0xff ) << 24 ) + ( ( _readBuffer [ _readOffset ++ ] & 0xff ) << 16 ) + ( ( _readBuffer [ _readOffset ++ ] & 0xff ) << 8 ) + ( ( _readBuffer [ _readOffset ++ ] & 0xff ) ) ) ; } else { return ( ( read ( ) << 24 ) + ( read ( ) << 16 ) + ( read ( ) << 8 ) + ( read ( ) ) ) ; } }
Reads a 4 - byte network encoded integer
138
9
139,441
public int readUTF8ByByteLength ( char [ ] buffer , int offset , int byteLength ) throws IOException { int k = 0 ; for ( int i = 0 ; i < byteLength ; i ++ ) { if ( _readLength <= _readOffset ) { readBuffer ( ) ; } int ch = _readBuffer [ _readOffset ++ ] & 0xff ; if ( ch < 0x80 ) { buffer [ k ++ ] = ( char ) ch ; } else if ( ( ch & 0xe0 ) == 0xc0 ) { int c2 = read ( ) ; i += 1 ; buffer [ k ++ ] = ( char ) ( ( ( ch & 0x1f ) << 6 ) + ( c2 & 0x3f ) ) ; } else { int c2 = read ( ) ; int c3 = read ( ) ; i += 2 ; buffer [ k ++ ] = ( char ) ( ( ( ch & 0x1f ) << 12 ) + ( ( c2 & 0x3f ) << 6 ) + ( ( c3 & 0x3f ) ) ) ; } } return k ; }
Reads a utf - 8 string
241
8
139,442
public boolean fillIfLive ( long timeout ) throws IOException { StreamImpl source = _source ; byte [ ] readBuffer = _readBuffer ; if ( readBuffer == null || source == null ) { _readOffset = 0 ; _readLength = 0 ; return false ; } if ( _readOffset > 0 ) { System . arraycopy ( readBuffer , _readOffset , readBuffer , 0 , _readLength - _readOffset ) ; _readLength -= _readOffset ; _readOffset = 0 ; } if ( _readLength == readBuffer . length ) return true ; int readLength = source . readTimeout ( _readBuffer , _readLength , _readBuffer . length - _readLength , timeout ) ; if ( readLength >= 0 ) { _readLength += readLength ; _position += readLength ; if ( _isEnableReadTime ) _readTime = CurrentTime . currentTime ( ) ; return true ; } else if ( readLength == READ_TIMEOUT ) { // timeout return true ; } else { // return false on end of file return false ; } }
Fills the buffer with a timed read testing for the end of file . Used for cases like comet to test if the read stream has closed .
229
29
139,443
@ Override public boolean isSecure ( ) { if ( _s == null || _sslSocketClass == null ) return false ; else return _sslSocketClass . isAssignableFrom ( _s . getClass ( ) ) ; }
Returns true if the connection is secure .
50
8
139,444
@ Override public int cipherBits ( ) { if ( ! ( _s instanceof SSLSocket ) ) return super . cipherBits ( ) ; SSLSocket sslSocket = ( SSLSocket ) _s ; SSLSession sslSession = sslSocket . getSession ( ) ; if ( sslSession != null ) return _sslKeySizes . get ( sslSession . getCipherSuite ( ) ) ; else return 0 ; }
Returns the bits in the socket .
99
7
139,445
public void postMultipart ( String url , Map < String , String > map ) throws Exception { String boundaryStr = "-----boundary0" ; StringBuilder sb = new StringBuilder ( ) ; map . forEach ( ( k , v ) -> { sb . append ( boundaryStr + "\r" ) ; sb . append ( "Content-Disposition: form-data; name=\"" + k + "\"\r" ) ; sb . append ( "\r" ) ; sb . append ( v ) ; sb . append ( "\r" ) ; } ) ; String request = "POST " + url + " HTTP/1.0\r" + "Content-Type: multipart/form-data; boundary=" + boundaryStr + "\r" + "Content-Length: " + sb . length ( ) + "\r" + "\r" + sb ; request ( request , null ) ; }
Performs multipart post
201
5
139,446
public void setBackgroundInterval ( long interval , TimeUnit unit ) { if ( ! isValid ( ) ) { return ; } long period = unit . toMillis ( interval ) ; if ( _state == StateProfile . IDLE ) { if ( period > 0 ) { _profileTask . setPeriod ( period ) ; _profileTask . start ( ) ; _state = StateProfile . BACKGROUND ; } } else if ( _state == StateProfile . BACKGROUND ) { if ( period <= 0 ) { _profileTask . stop ( ) ; _state = StateProfile . IDLE ; } else if ( period != _backgroundPeriod ) { _profileTask . stop ( ) ; _profileTask . setPeriod ( period ) ; _profileTask . start ( ) ; } } _backgroundPeriod = period ; }
Sets the time interval for the background profile .
174
10
139,447
public void start ( long interval , TimeUnit unit ) { if ( ! isValid ( ) ) { return ; } long period = unit . toMillis ( interval ) ; if ( period < 0 ) { return ; } _profileTask . stop ( ) ; _profileTask . setPeriod ( period ) ; _profileTask . start ( ) ; _state = StateProfile . ACTIVE ; }
Starts a dedicated profile .
83
6
139,448
public ProfileReport stop ( ) { if ( ! isValid ( ) ) { return null ; } if ( _state != StateProfile . ACTIVE ) { return null ; } _profileTask . stop ( ) ; ProfileReport report = _profileTask . getReport ( ) ; if ( _backgroundPeriod > 0 ) { _profileTask . setPeriod ( _backgroundPeriod ) ; _profileTask . start ( ) ; _state = StateProfile . BACKGROUND ; } else { _state = StateProfile . IDLE ; } return report ; }
Ends the dedicated profile restarting the background .
115
10
139,449
private MethodRefAmp findLocalMethod ( ) { ServiceRefAmp serviceRefLocal = _serviceRef . getLocalService ( ) ; if ( serviceRefLocal == null ) { return null ; } if ( _type != null ) { return serviceRefLocal . methodByName ( _name , _type ) ; } else { return serviceRefLocal . methodByName ( _name ) ; } }
Return the local method for this pod method when the pod is on the same jvm .
84
18
139,450
private MethodRefActive createMethodRefActive ( ServiceRefAmp serviceRef ) { MethodRefAmp methodRef ; if ( _type != null ) { methodRef = serviceRef . methodByName ( _name , _type ) ; } else { methodRef = serviceRef . methodByName ( _name ) ; } MethodShim methodShim ; ClassLoader methodLoader = methodRef . serviceRef ( ) . classLoader ( ) ; //System.out.println("SR: " + serviceRef + " " + serviceRef.getActor()); if ( methodLoader == _sourceLoader || serviceRef . stub ( ) instanceof StubLink ) { //methodShim = new MethodShimIdentity(methodRef.getMethod()); methodShim = new MethodShimIdentity ( methodRef , isLocalService ( serviceRef ) ) ; } else { PodImport importContext ; importContext = PodImportContext . create ( _sourceLoader ) . getPodImport ( methodLoader ) ; //importContext = ImportContext.create(methodLoader).getModuleImport(_sourceLoader); //methodShim = new MethodShimImport(methodRef.getMethod(), importContext); methodShim = new MethodShimImport ( methodRef , importContext , isLocalService ( serviceRef ) ) ; } return new MethodRefActive ( serviceRef , methodRef , methodShim ) ; }
Create an MethodRefActive for the given serviceRef .
290
11
139,451
private IProvider getProviderFromTemplate ( eu . atos . sla . parser . data . wsag . Template templateXML ) throws ModelConversionException { Context context = templateXML . getContext ( ) ; String provider = null ; try { ServiceProvider ctxProvider = ServiceProvider . fromString ( context . getServiceProvider ( ) ) ; switch ( ctxProvider ) { case AGREEMENT_RESPONDER : provider = context . getAgreementResponder ( ) ; break ; case AGREEMENT_INITIATOR : provider = context . getAgreementInitiator ( ) ; break ; } } catch ( IllegalArgumentException e ) { throw new ModelConversionException ( "The Context/ServiceProvider field must match with the word " + ServiceProvider . AGREEMENT_RESPONDER + " or " + ServiceProvider . AGREEMENT_INITIATOR ) ; } IProvider providerObj = providerDAO . getByUUID ( provider ) ; return providerObj ; }
we retrieve the providerUUID from the template and get the provider object from the database
216
17
139,452
@ Override public void write ( byte [ ] buf , int offset , int length , boolean isEnd ) throws IOException { while ( length > 0 ) { if ( _tail == null ) { addBuffer ( TempBuffer . create ( ) ) ; } else if ( _tail . buffer ( ) . length <= _tail . length ( ) ) { addBuffer ( TempBuffer . create ( ) ) ; } TempBuffer tail = _tail ; int sublen = Math . min ( length , tail . buffer ( ) . length - tail . length ( ) ) ; System . arraycopy ( buf , offset , tail . buffer ( ) , tail . length ( ) , sublen ) ; length -= sublen ; offset += sublen ; _tail . length ( _tail . length ( ) + sublen ) ; } }
Writes a chunk of data to the temp stream .
170
11
139,453
public TempStream copy ( ) { TempStream newStream = new TempStream ( ) ; TempBuffer ptr = _head ; for ( ; ptr != null ; ptr = ptr . next ( ) ) { TempBuffer newPtr = TempBuffer . create ( ) ; if ( newStream . _tail != null ) newStream . _tail . next ( newPtr ) ; else newStream . _head = newPtr ; newStream . _tail = newPtr ; newPtr . write ( ptr . buffer ( ) , 0 , ptr . length ( ) ) ; } return newStream ; }
Copies the temp stream ;
120
6
139,454
@ Override public void flush ( ) { // server/021g _logWriterQueue . wake ( ) ; waitForFlush ( 10 ) ; try { super . flush ( ) ; } catch ( IOException e ) { log . log ( Level . FINER , e . toString ( ) , e ) ; } }
must be synchronized by _bufferLock .
68
8
139,455
public boolean isModified ( ) { I instance = _instance ; if ( instance == null ) { return true ; } if ( DeployMode . MANUAL . equals ( _strategy . redeployMode ( ) ) ) { return false ; } return instance . isModified ( ) ; }
Returns true if the entry is modified .
61
8
139,456
public void startOnInit ( Result < I > result ) { DeployFactory2 < I > builder = builder ( ) ; if ( builder == null ) { result . ok ( null ) ; return ; } if ( ! _lifecycle . toInit ( ) ) { result . ok ( get ( ) ) ; return ; } _strategy . startOnInit ( this , result ) ; }
Starts the entry on initialization
81
6
139,457
public final void shutdown ( ShutdownModeAmp mode , Result < Boolean > result ) { _strategy . shutdown ( this , mode , result ) ; }
Stops the controller from an admin command .
32
9
139,458
public final void request ( Result < I > result ) { I instance = _instance ; if ( instance != null && _lifecycle . isActive ( ) && ! isModified ( ) ) { result . ok ( instance ) ; } else if ( _lifecycle . isDestroyed ( ) ) { result . ok ( null ) ; } else { _strategy . request ( this , result ) ; } }
Returns the instance for a top - level request
86
9
139,459
public void startImpl ( Result < I > result ) { DeployFactory2 < I > builder = builder ( ) ; if ( builder == null ) { result . ok ( null ) ; return ; } if ( ! _lifecycle . toStarting ( ) ) { result . ok ( _instance ) ; return ; } I deployInstance = null ; boolean isActive = false ; try { deployInstance = builder . get ( ) ; _instance = deployInstance ; isActive = true ; result . ok ( deployInstance ) ; } catch ( ConfigException e ) { log . log ( Level . FINEST , e . toString ( ) , e ) ; log . log ( Level . FINE , e . toString ( ) , e ) ; result . fail ( e ) ; } catch ( Throwable e ) { log . log ( Level . FINEST , e . toString ( ) , e ) ; log . log ( Level . FINE , e . toString ( ) , e ) ; result . fail ( e ) ; } finally { if ( isActive ) { _lifecycle . toActive ( ) ; } else { _lifecycle . toError ( ) ; } } }
Starts the entry .
246
5
139,460
@ Override public void validate ( byte [ ] blockBuffer , int rowOffset , int rowHead , int blobTail ) { int offset = rowOffset + offset ( ) ; int blobLen = BitsUtil . readInt16 ( blockBuffer , offset + 2 ) ; int blobOffset = BitsUtil . readInt16 ( blockBuffer , offset ) ; if ( blobLen == 0 ) { return ; } if ( blobOffset < 0 || blobTail < blobOffset ) { throw new IllegalStateException ( L . l ( "{0}: corrupted blob offset {1} with blobTail={2}" , this , blobOffset , blobTail ) ) ; } if ( ( blobLen & LARGE_BLOB_MASK ) != 0 ) { blobLen &= ~ LARGE_BLOB_MASK ; if ( blobLen != 4 ) { throw new IllegalStateException ( L . l ( "{0}: corrupted blob len {1} for large blob." , this , blobOffset ) ) ; } } if ( blobLen < 0 || blobTail < blobLen + blobOffset ) { throw new IllegalStateException ( L . l ( "{0}: corrupted blob len {1} with blobOffset={2} blobTail={3}" , this , blobLen , blobOffset , blobTail ) ) ; } }
Validates the column checking for corruption .
280
8
139,461
public MonitoringRules getMonitoringRulesByTemplateId ( String monitoringRuleTemplateId ) { return getJerseyClient ( ) . target ( getEndpoint ( ) + "/planner/monitoringrules/" + monitoringRuleTemplateId ) . request ( ) . buildGet ( ) . invoke ( ) . readEntity ( MonitoringRules . class ) ; }
Creates proxied HTTP GET request to SeaClouds Planner which returns the monitoring rules according to the template id
72
23
139,462
public String getAdps ( String aam ) { Entity content = Entity . entity ( aam , MediaType . TEXT_PLAIN ) ; Invocation invocation = getJerseyClient ( ) . target ( getEndpoint ( ) + "/planner/plan" ) . request ( ) . buildPost ( content ) ; return invocation . invoke ( ) . readEntity ( String . class ) ; }
Creates proxied HTTP POST request to SeaClouds Planner which returns a list TOSCA compliant SeaClouds ADP in JSON format
83
29
139,463
public String getDam ( String adp ) { Entity content = Entity . entity ( adp , MediaType . TEXT_PLAIN ) ; Invocation invocation = getJerseyClient ( ) . target ( getEndpoint ( ) + "/planner/damgen" ) . request ( ) . buildPost ( content ) ; return invocation . invoke ( ) . readEntity ( String . class ) ; }
Creates proxied HTTP POST request to SeaClouds Planner which returns a SeaClouds TOSCA DAM file
83
24
139,464
public static boolean isMatch ( Class < ? > [ ] paramA , Class < ? > [ ] paramB ) { if ( paramA . length != paramB . length ) return false ; for ( int i = paramA . length - 1 ; i >= 0 ; i -- ) { if ( ! paramA [ i ] . equals ( paramB [ i ] ) ) return false ; } return true ; }
Tests if parameters match a method s parameter types .
86
11
139,465
@ Override public boolean isServerPrimary ( ServerBartender server ) { for ( int i = 0 ; i < Math . min ( 1 , _owners . length ) ; i ++ ) { ServerBartender serverBar = server ( i ) ; if ( serverBar == null ) { continue ; } else if ( serverBar . isSameServer ( server ) ) { return true ; } } return false ; }
Test if the server is the primary for the node .
87
11
139,466
@ Override public boolean isServerOwner ( ServerBartender server ) { for ( int i = 0 ; i < _owners . length ; i ++ ) { ServerBartender serverBar = server ( i ) ; if ( serverBar == null ) { continue ; } else if ( serverBar . isSameServer ( server ) ) { return server . isUp ( ) ; } else if ( serverBar . isUp ( ) ) { return false ; } } return false ; }
Test if the server is the current owner of the node . The owner is the first live server in the backup list .
101
24
139,467
@ Override public boolean isServerCopy ( ServerBartender server ) { for ( int i = 0 ; i < _owners . length ; i ++ ) { ServerBartender serverBar = server ( i ) ; if ( serverBar != null && serverBar . isSameServer ( server ) ) { return true ; } } return false ; }
Test if the server is the one of the node copies .
73
12
139,468
public ServerBartender owner ( ) { for ( int i = 0 ; i < _owners . length ; i ++ ) { ServerBartender serverBar = server ( i ) ; if ( serverBar != null && serverBar . isUp ( ) ) { return serverBar ; } } return null ; }
Return the current server owner .
65
6
139,469
@ Override public BartenderBuilderPod pod ( String id , String clusterId ) { Objects . requireNonNull ( id ) ; Objects . requireNonNull ( clusterId ) ; ClusterHeartbeat cluster = createCluster ( clusterId ) ; return new PodBuilderConfig ( id , cluster , this ) ; }
Create a configured pod .
64
5
139,470
private UpdatePod initLocalPod ( ) { ServerBartender serverSelf = _bartender . serverSelf ( ) ; ServicesAmp rampManager = AmpSystem . currentManager ( ) ; UpdatePodBuilder podBuilder = new UpdatePodBuilder ( ) ; podBuilder . name ( "local" ) ; podBuilder . cluster ( _bartender . serverSelf ( ) . getCluster ( ) ) ; // int count = Math.min(3, rack.getServerLength()); ServerPod serverPod = new ServerPod ( 0 , serverSelf ) ; ServerPod [ ] servers = new ServerPod [ ] { serverPod } ; podBuilder . pod ( servers ) ; // int depth = Math.min(3, handles.length); podBuilder . primaryCount ( 1 ) ; podBuilder . depth ( 1 ) ; UpdatePod updatePod = podBuilder . build ( ) ; return new UpdatePod ( updatePod , new String [ ] { serverSelf . getId ( ) } , 0 ) ; }
The local pod refers to the server itself .
207
9
139,471
public static JavaCompilerUtil create ( ClassLoader loader ) { JavacConfig config = JavacConfig . getLocalConfig ( ) ; String javac = config . getCompiler ( ) ; JavaCompilerUtil javaCompiler = new JavaCompilerUtil ( ) ; if ( loader == null ) { loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; } javaCompiler . setClassLoader ( loader ) ; javaCompiler . setCompiler ( javac ) ; javaCompiler . setArgs ( config . getArgs ( ) ) ; javaCompiler . setEncoding ( config . getEncoding ( ) ) ; javaCompiler . setMaxBatch ( config . getMaxBatch ( ) ) ; javaCompiler . setStartTimeout ( config . getStartTimeout ( ) ) ; javaCompiler . setMaxCompileTime ( config . getMaxCompileTime ( ) ) ; return javaCompiler ; }
Creates a new compiler .
203
6
139,472
public String getClassPath ( ) { String rawClassPath = buildClassPath ( ) ; if ( true ) return rawClassPath ; char sep = CauchoUtil . getPathSeparatorChar ( ) ; String [ ] splitClassPath = rawClassPath . split ( "[" + sep + "]" ) ; String javaHome = System . getProperty ( "java.home" ) ; PathImpl pwd = VfsOld . lookup ( System . getProperty ( "user.dir" ) ) ; ArrayList < String > cleanClassPath = new ArrayList < String > ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( String pathName : splitClassPath ) { PathImpl path = pwd . lookup ( pathName ) ; pathName = path . getNativePath ( ) ; if ( ! pathName . startsWith ( javaHome ) && ! cleanClassPath . contains ( pathName ) ) { cleanClassPath . add ( pathName ) ; if ( sb . length ( ) > 0 ) sb . append ( sep ) ; sb . append ( pathName ) ; } } return sb . toString ( ) ; }
Returns the classpath .
247
5
139,473
private String buildClassPath ( ) { String classPath = null ; //_classPath; if ( classPath != null ) { return classPath ; } if ( classPath == null && _loader instanceof DynamicClassLoader ) { classPath = ( ( DynamicClassLoader ) _loader ) . getClassPath ( ) ; } else { // if (true || _loader instanceof URLClassLoader) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( CauchoUtil . getClassPath ( ) ) ; if ( _loader != null ) buildClassPath ( sb , _loader ) ; classPath = sb . toString ( ) ; } //else if (classPath == null) //classPath = CauchoSystem.getClassPath(); String srcDirName = getSourceDirName ( ) ; String classDirName = getClassDirName ( ) ; char sep = CauchoUtil . getPathSeparatorChar ( ) ; if ( _extraClassPath != null ) classPath = classPath + sep + _extraClassPath ; // Adding the srcDir lets javac and jikes find source files if ( ! srcDirName . equals ( classDirName ) ) classPath = srcDirName + sep + classPath ; classPath = classDirName + sep + classPath ; return classPath ; }
Returns the classpath for the compiler .
287
8
139,474
public void setArgs ( String argString ) { try { if ( argString != null ) { String [ ] args = Pattern . compile ( "[\\s,]+" ) . split ( argString ) ; _args = new ArrayList < String > ( ) ; for ( int i = 0 ; i < args . length ; i ++ ) { if ( ! args [ i ] . equals ( "" ) ) _args . add ( args [ i ] ) ; } } } catch ( Exception e ) { log . log ( Level . WARNING , e . toString ( ) , e ) ; } }
Sets any additional arguments for the compiler .
125
9
139,475
public void setEncoding ( String encoding ) { _charEncoding = encoding ; String javaEncoding = Encoding . getJavaName ( encoding ) ; if ( "ISO8859_1" . equals ( javaEncoding ) ) _charEncoding = null ; }
Sets the Java encoding for the compiler .
57
9
139,476
public static String mangleName ( String name ) { boolean toLower = CauchoUtil . isCaseInsensitive ( ) ; CharBuffer cb = new CharBuffer ( ) ; cb . append ( "_" ) ; for ( int i = 0 ; i < name . length ( ) ; i ++ ) { char ch = name . charAt ( i ) ; if ( ch == ' ' || ch == CauchoUtil . getPathSeparatorChar ( ) ) { if ( i == 0 ) { } else if ( cb . charAt ( cb . length ( ) - 1 ) != ' ' && ( i + 1 < name . length ( ) && name . charAt ( i + 1 ) != ' ' ) ) cb . append ( "._" ) ; } else if ( ch == ' ' ) cb . append ( "__" ) ; else if ( ch == ' ' ) cb . append ( "_0" ) ; else if ( Character . isJavaIdentifierPart ( ch ) ) cb . append ( toLower ? Character . toLowerCase ( ch ) : ch ) ; else if ( ch <= 256 ) cb . append ( "_2" + encodeHex ( ch >> 4 ) + encodeHex ( ch ) ) ; else cb . append ( "_4" + encodeHex ( ch >> 12 ) + encodeHex ( ch >> 8 ) + encodeHex ( ch >> 4 ) + encodeHex ( ch ) ) ; } if ( cb . length ( ) == 0 ) cb . append ( "_z" ) ; return cb . toString ( ) ; }
Mangles the path into a valid Java class name .
349
11
139,477
public void compileBatch ( String [ ] files ) throws IOException , ClassNotFoundException { if ( _compileParent ) { try { if ( _loader instanceof Make ) ( ( Make ) _loader ) . make ( ) ; } catch ( Exception e ) { throw new IOException ( e ) ; } } if ( files . length == 0 ) return ; // only batch a number of files at a time int batchCount = _maxBatch ; if ( batchCount < 0 ) batchCount = Integer . MAX_VALUE / 2 ; else if ( batchCount == 0 ) batchCount = 1 ; IOException exn = null ; ArrayList < String > uniqueFiles = new ArrayList < String > ( ) ; for ( int i = 0 ; i < files . length ; i ++ ) { if ( ! uniqueFiles . contains ( files [ i ] ) ) uniqueFiles . add ( files [ i ] ) ; } files = new String [ uniqueFiles . size ( ) ] ; uniqueFiles . toArray ( files ) ; LineMap lineMap = null ; _compilerService . compile ( this , files , lineMap ) ; /* synchronized (LOCK) { for (int i = 0; i < files.length; i += batchCount) { int len = files.length - i; len = Math.min(len, batchCount); String []batchFiles = new String[len]; System.arraycopy(files, i, batchFiles, 0, len); Arrays.sort(batchFiles); try { compileInt(batchFiles, null); } catch (IOException e) { if (exn == null) exn = e; else log.log(Level.WARNING, e.toString(), e); } } } if (exn != null) throw exn; */ }
Compiles a batch list of classes .
379
8
139,478
final public void write ( char [ ] buf ) { try { _out . print ( buf , 0 , buf . length ) ; } catch ( IOException e ) { log . log ( Level . FINE , e . toString ( ) , e ) ; } }
Writes a character buffer .
56
6
139,479
void waitForExit ( ) { Runtime runtime = Runtime . getRuntime ( ) ; ShutdownSystem shutdown = _resinSystem . getSystem ( ShutdownSystem . class ) ; if ( shutdown == null ) { throw new IllegalStateException ( L . l ( "'{0}' requires an active {1}" , this , ShutdownSystem . class . getSimpleName ( ) ) ) ; } /* * If the server has a parent process watching over us, close * gracefully when the parent dies. */ while ( ! _server . isClosing ( ) ) { try { Thread . sleep ( 10 ) ; if ( ! checkMemory ( runtime ) ) { shutdown . shutdown ( ShutdownModeAmp . IMMEDIATE , ExitCode . MEMORY , "Server shutdown from out of memory" ) ; // dumpHeapOnExit(); return ; } if ( ! checkFileDescriptor ( ) ) { shutdown . shutdown ( ShutdownModeAmp . IMMEDIATE , ExitCode . MEMORY , "Server shutdown from out of file descriptors" ) ; //dumpHeapOnExit(); return ; } synchronized ( this ) { wait ( 10000 ) ; } } catch ( OutOfMemoryError e ) { String msg = "Server shutdown from out of memory" ; ShutdownSystem . shutdownOutOfMemory ( msg ) ; } catch ( Throwable e ) { log . log ( Level . WARNING , e . toString ( ) , e ) ; return ; } } }
Thread to wait until Resin should be stopped .
304
10
139,480
public ServiceRefAmp getLocalService ( ) { ServiceRefAmp serviceRefRoot = _podRoot . getLocalService ( ) ; //ServiceRefAmp serviceRefRoot = _podRoot.getClientService(); if ( serviceRefRoot == null ) { return null ; } ServiceRefActive serviceRefLocal = _serviceRefLocal ; if ( serviceRefLocal != null ) { ServiceRefAmp serviceRef = serviceRefLocal . getService ( serviceRefRoot ) ; if ( serviceRef != null ) { return serviceRef ; } } ServiceRefAmp serviceRef = serviceRefRoot . onLookup ( _path ) ; _serviceRefLocal = new ServiceRefActive ( serviceRefRoot , serviceRef ) ; // serviceRef.start(); return serviceRef ; }
Returns the active service for this pod and path s hash .
161
12
139,481
@ Override public PathImpl lookupImpl ( String userPath , Map < String , Object > newAttributes , boolean isAllowRoot ) { String newPath ; if ( userPath == null ) return _root . fsWalk ( getPath ( ) , newAttributes , "/" ) ; int length = userPath . length ( ) ; int colon = userPath . indexOf ( ' ' ) ; int slash = userPath . indexOf ( ' ' ) ; int query = userPath . indexOf ( ' ' ) ; // parent handles scheme:xxx if ( colon != - 1 && ( colon < slash || slash == - 1 ) ) return super . lookupImpl ( userPath , newAttributes , isAllowRoot ) ; // //hostname if ( slash == 0 && length > 1 && userPath . charAt ( 1 ) == ' ' ) return schemeWalk ( userPath , newAttributes , userPath , 0 ) ; // /path else if ( slash == 0 ) { String queryString = "" ; if ( query >= 0 ) { queryString = userPath . substring ( query ) ; userPath = userPath . substring ( 0 , query ) ; } newPath = normalizePath ( "/" , userPath , 0 , ' ' ) ; if ( query >= 0 ) newPath += queryString ; } // path else { String queryString = "" ; if ( query >= 0 ) { queryString = userPath . substring ( query ) ; userPath = userPath . substring ( 0 , query ) ; } newPath = normalizePath ( _pathname , userPath , 0 , ' ' ) ; if ( query >= 0 ) newPath += queryString ; } // XXX: does missing root here cause problems with restrictions? return _root . fsWalk ( userPath , newAttributes , newPath ) ; }
Overrides the default lookup to parse the host and port before parsing the path .
380
17
139,482
@ Override public PathImpl schemeWalk ( String userPath , Map < String , Object > attributes , String uri , int offset ) { int length = uri . length ( ) ; if ( length < 2 + offset || uri . charAt ( offset ) != ' ' || uri . charAt ( offset + 1 ) != ' ' ) throw new RuntimeException ( L . l ( "bad scheme in `{0}'" , uri ) ) ; CharBuffer buf = CharBuffer . allocate ( ) ; int i = 2 + offset ; int ch = 0 ; boolean isInBrace = false ; for ( ; i < length && ( ( ch = uri . charAt ( i ) ) != ' ' || isInBrace ) && ch != ' ' && ch != ' ' ; i ++ ) { buf . append ( ( char ) ch ) ; if ( ch == ' ' ) isInBrace = true ; else if ( ch == ' ' ) isInBrace = false ; } String host = buf . close ( ) ; if ( host . length ( ) == 0 ) throw new RuntimeException ( L . l ( "bad host in `{0}'" , uri ) ) ; int port = 0 ; if ( ch == ' ' ) { for ( i ++ ; i < length && ( ch = uri . charAt ( i ) ) >= ' ' && ch <= ' ' ; i ++ ) { port = 10 * port + uri . charAt ( i ) - ' ' ; } } if ( port == 0 ) port = 80 ; HttpPath root = create ( host , port ) ; return root . fsWalk ( userPath , attributes , uri . substring ( i ) ) ; }
Walk down the path starting from the portion immediately following the scheme . i . e . schemeWalk is responsible for parsing the host and port from the URL .
366
31
139,483
public PathImpl fsWalk ( String userPath , Map < String , Object > attributes , String uri ) { String path ; String query = null ; int queryIndex = uri . indexOf ( ' ' ) ; if ( queryIndex >= 0 ) { path = uri . substring ( 0 , queryIndex ) ; query = uri . substring ( queryIndex + 1 ) ; } else path = uri ; if ( path . length ( ) == 0 ) path = "/" ; return create ( _root , userPath , attributes , path , query ) ; }
Scans the path portion of the URI i . e . everything after the host and port .
120
19
139,484
public String getURL ( ) { int port = getPort ( ) ; return ( getScheme ( ) + "://" + getHost ( ) + ( port == 80 ? "" : ":" + getPort ( ) ) + getPath ( ) + ( _query == null ? "" : "?" + _query ) ) ; }
Returns a full URL for the path .
70
8
139,485
private V putImpl ( K key , V value ) { V item = null ; int hash = key . hashCode ( ) & _mask ; int count = _values . length ; for ( ; count > 0 ; count -- ) { item = _values [ hash ] ; // No matching item, so create one if ( item == null ) { _keys [ hash ] = key ; _values [ hash ] = value ; _size ++ ; return null ; } // matching item gets replaced if ( _keys [ hash ] . equals ( key ) ) { _values [ hash ] = value ; return item ; } hash = ( hash + 1 ) & _mask ; } throw new IllegalStateException ( ) ; }
Implementation of the put .
148
6
139,486
public String getURL ( ) { if ( ! isWindows ( ) ) return escapeURL ( "file:" + getFullPath ( ) ) ; String path = getFullPath ( ) ; int length = path . length ( ) ; CharBuffer cb = new CharBuffer ( ) ; // #2725, server/1495 cb . append ( "file:" ) ; char ch ; int offset = 0 ; // For windows, convert /c: to c: if ( length >= 3 && path . charAt ( 0 ) == ' ' && path . charAt ( 2 ) == ' ' && ( ' ' <= ( ch = path . charAt ( 1 ) ) && ch <= ' ' || ' ' <= ch && ch <= ' ' ) ) { // offset = 1; } else if ( length >= 3 && path . charAt ( 0 ) == ' ' && path . charAt ( 1 ) == ' ' && path . charAt ( 2 ) == ' ' ) { cb . append ( ' ' ) ; cb . append ( ' ' ) ; cb . append ( ' ' ) ; cb . append ( ' ' ) ; offset = 3 ; } for ( ; offset < length ; offset ++ ) { ch = path . charAt ( offset ) ; if ( ch == ' ' ) cb . append ( ' ' ) ; else cb . append ( ch ) ; } return escapeURL ( cb . toString ( ) ) ; }
Returns the full url for the given path .
307
9
139,487
@ Override public String getNativePath ( ) { if ( ! isWindows ( ) ) { return getFullPath ( ) ; } String path = getFullPath ( ) ; int length = path . length ( ) ; CharBuffer cb = new CharBuffer ( ) ; char ch ; int offset = 0 ; // For windows, convert /c: to c: if ( length >= 3 && path . charAt ( 0 ) == ' ' && path . charAt ( 2 ) == ' ' && ( ' ' <= ( ch = path . charAt ( 1 ) ) && ch <= ' ' || ' ' <= ch && ch <= ' ' ) ) { offset = 1 ; } else if ( length >= 3 && path . charAt ( 0 ) == ' ' && path . charAt ( 1 ) == ' ' && path . charAt ( 2 ) == ' ' ) { cb . append ( ' ' ) ; cb . append ( ' ' ) ; offset = 3 ; } for ( ; offset < length ; offset ++ ) { ch = path . charAt ( offset ) ; if ( ch == ' ' ) cb . append ( _separatorChar ) ; else cb . append ( ch ) ; } return cb . toString ( ) ; }
Returns the native path .
265
5
139,488
public String [ ] list ( ) throws IOException { try { String [ ] list = getFile ( ) . list ( ) ; if ( list != null ) return list ; } catch ( AccessControlException e ) { log . finer ( e . toString ( ) ) ; } return new String [ 0 ] ; }
Returns a list of files in the directory .
66
9
139,489
public StreamImpl openReadImpl ( ) throws IOException { if ( _isWindows && isAux ( ) ) throw new FileNotFoundException ( _file . toString ( ) ) ; /* XXX: only for Solaris (?) if (isDirectory()) throw new IOException("is directory"); */ return new FileReadStream ( new FileInputStream ( getFile ( ) ) , this ) ; }
Returns the stream implementation for a read stream .
84
9
139,490
public boolean isAux ( ) { if ( ! _isWindows ) return false ; File file = getFile ( ) ; String path = getFullPath ( ) . toLowerCase ( Locale . ENGLISH ) ; int len = path . length ( ) ; int p = path . indexOf ( "/aux" ) ; int ch ; if ( p >= 0 && ( len <= p + 4 || path . charAt ( p + 4 ) == ' ' ) ) return true ; p = path . indexOf ( "/con" ) ; if ( p >= 0 && ( len <= p + 4 || path . charAt ( p + 4 ) == ' ' ) ) return true ; p = path . indexOf ( "/lpt" ) ; if ( p >= 0 && ( len <= p + 5 || path . charAt ( p + 5 ) == ' ' ) && ' ' <= ( ch = path . charAt ( p + 4 ) ) && ch <= ' ' ) { return true ; } p = path . indexOf ( "/nul" ) ; if ( p >= 0 && ( len <= p + 4 || path . charAt ( p + 4 ) == ' ' ) ) return true ; return false ; }
Special case for the evil windows special
258
7
139,491
public void clearCache ( ) { // skip the clear on restart if ( _lifecycle . isStopping ( ) ) { return ; } if ( log . isLoggable ( Level . FINER ) ) { log . finest ( "clearCache" ) ; } // the invocation cache must be cleared first because the old // filter chain entries must not point to the cache's // soon-to-be-invalid entries getInvocationManager ( ) . clearCache ( ) ; /* if (_httpCache != null) { _httpCache.clear(); } */ }
Clears the proxy cache .
118
6
139,492
public void init ( ) { _offset = 0 ; if ( _tempBuffer == null ) { _tempBuffer = TempBuffer . create ( ) ; _buffer = _tempBuffer . buffer ( ) ; _bufferEnd = _buffer . length ; } }
Initialize the output stream .
53
6
139,493
@ Override public void write ( byte [ ] buffer , int offset , int length ) throws IOException { while ( length > 0 ) { if ( _bufferEnd <= _offset ) { flushBlock ( false ) ; } int sublen = Math . min ( _bufferEnd - _offset , length ) ; System . arraycopy ( buffer , offset , _buffer , _offset , sublen ) ; offset += sublen ; _offset += sublen ; length -= sublen ; } }
Writes a buffer .
101
5
139,494
@ Override public void close ( ) throws IOException { if ( _isClosed ) { return ; } _isClosed = true ; flushBlock ( true ) ; _cursor . setBlob ( _column . index ( ) , this ) ; }
Completes the stream .
55
6
139,495
private void flushBlock ( boolean isClose ) throws IOException { if ( isClose ) { if ( ! _isLargeBlob && _offset <= _table . getInlineBlobMax ( ) ) { return ; } } _isLargeBlob = true ; if ( _blobOut == null ) { _blobOut = _table . getTempStore ( ) . openWriter ( ) ; } if ( _offset != _bufferEnd && ! isClose ) { throw new IllegalStateException ( ) ; } _blobOut . write ( _tempBuffer . buffer ( ) , 0 , _offset ) ; _offset = 0 ; if ( ! isClose ) { return ; } StreamSource ss = _blobOut . getStreamSource ( ) ; _blobOut = null ; int len = ( int ) ss . getLength ( ) ; int blobPageSizeMax = _table . getBlobPageSizeMax ( ) ; int pid = - 1 ; int nextPid = - 1 ; int tailLen = len % blobPageSizeMax ; // long seq = 0; PageServiceSync tableService = _table . getTableService ( ) ; if ( tailLen > 0 ) { int tailOffset = len - tailLen ; pid = tableService . writeBlob ( pid , ss . openChild ( ) , tailOffset , tailLen ) ; len -= tailLen ; } while ( len > 0 ) { int sublen = blobPageSizeMax ; int offset = len - blobPageSizeMax ; pid = tableService . writeBlob ( pid , ss . openChild ( ) , offset , sublen ) ; len -= sublen ; } ss . close ( ) ; _blobId = Math . max ( pid , 0 ) ; }
flushes a block of the blob to the temp store if larger than the inline size .
369
18
139,496
public static Integer getSPECint ( String providerName , String instanceType ) { String key = providerName + "." + instanceType ; return SPECint . get ( key ) ; }
Gets the SPECint of the specified instance of the specified offerings provider
38
14
139,497
public static String toHex ( byte [ ] bytes , int offset , int len ) { if ( bytes == null ) return "null" ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < len ; i ++ ) { int d1 = ( bytes [ offset + i ] >> 4 ) & 0xf ; int d2 = ( bytes [ offset + i ] ) & 0xf ; if ( d1 < 10 ) sb . append ( ( char ) ( ' ' + d1 ) ) ; else sb . append ( ( char ) ( ' ' + d1 - 10 ) ) ; if ( d2 < 10 ) sb . append ( ( char ) ( ' ' + d2 ) ) ; else sb . append ( ( char ) ( ' ' + d2 - 10 ) ) ; } return sb . toString ( ) ; }
Convert bytes to hex
189
5
139,498
public static byte [ ] toBytes ( String hex ) { if ( hex == null ) return null ; int len = hex . length ( ) ; byte [ ] bytes = new byte [ len / 2 ] ; int k = 0 ; for ( int i = 0 ; i < len ; i += 2 ) { int digit = 0 ; char ch = hex . charAt ( i ) ; if ( ' ' <= ch && ch <= ' ' ) digit = ch - ' ' ; else if ( ' ' <= ch && ch <= ' ' ) digit = ch - ' ' + 10 ; else if ( ' ' <= ch && ch <= ' ' ) digit = ch - ' ' + 10 ; ch = hex . charAt ( i + 1 ) ; if ( ' ' <= ch && ch <= ' ' ) digit = 16 * digit + ch - ' ' ; else if ( ' ' <= ch && ch <= ' ' ) digit = 16 * digit + ch - ' ' + 10 ; else if ( ' ' <= ch && ch <= ' ' ) digit = 16 * digit + ch - ' ' + 10 ; bytes [ k ++ ] = ( byte ) digit ; } return bytes ; }
Convert hex to bytes
246
5
139,499
public static Class < ? > loadClass ( String name , boolean init , ClassLoader loader ) throws ClassNotFoundException { if ( loader == null ) loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; if ( loader == null || loader . equals ( CauchoUtil . class . getClassLoader ( ) ) ) return Class . forName ( name ) ; else return Class . forName ( name , init , loader ) ; }
Loads a class from a classloader . If the loader is null uses the context class loader .
96
20