idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
139,900 | @ Override public ClientSocket open ( ) { State state = _state ; if ( ! state . isInit ( ) ) return null ; ClientSocket stream = openRecycle ( ) ; if ( stream != null ) return stream ; return connect ( ) ; } | Open a stream to the target server for the load balancer . | 54 | 13 |
139,901 | private ClientSocket openRecycle ( ) { long now = CurrentTime . currentTime ( ) ; ClientSocket stream = null ; synchronized ( this ) { if ( _idleHead != _idleTail ) { stream = _idle [ _idleHead ] ; long freeTime = stream . getIdleStartTime ( ) ; _idle [ _idleHead ] = null ; _idleHead = ( _idleHead + _idle . length - 1 ) % _idle . length ; // System.out.println("RECYCLE: " + stream + " " + (freeTime - now) + " " + _loadBalanceIdleTime); if ( now < freeTime + _loadBalanceIdleTime ) { _activeCount . incrementAndGet ( ) ; _keepaliveCountTotal ++ ; stream . clearIdleStartTime ( ) ; stream . toActive ( ) ; return stream ; } } } if ( stream != null ) { if ( log . isLoggable ( Level . FINER ) ) log . finer ( this + " close idle " + stream + " expire=" + QDate . formatISO8601 ( stream . getIdleStartTime ( ) + _loadBalanceIdleTime ) ) ; stream . closeImpl ( ) ; } return null ; } | Returns a valid recycled stream from the idle pool to the backend . | 278 | 13 |
139,902 | private ClientSocket connect ( ) { if ( _maxConnections <= _activeCount . get ( ) + _startingCount . get ( ) ) { if ( log . isLoggable ( Level . WARNING ) ) { log . warning ( this + " connect exceeded max-connections" + "\n max-connections=" + _maxConnections + "\n activeCount=" + _activeCount . get ( ) + "\n startingCount=" + _startingCount . get ( ) ) ; } return null ; } _startingCount . incrementAndGet ( ) ; State state = _state ; if ( ! state . isInit ( ) ) { _startingCount . decrementAndGet ( ) ; IllegalStateException e = new IllegalStateException ( L . l ( "'{0}' connection cannot be opened because the server pool has not been started." , this ) ) ; log . log ( Level . WARNING , e . toString ( ) , e ) ; throw e ; } if ( getPort ( ) <= 0 ) { return null ; } long connectionStartTime = CurrentTime . currentTime ( ) ; try { ReadWritePair pair = openTCPPair ( ) ; ReadStreamOld rs = pair . getReadStream ( ) ; rs . setEnableReadTime ( true ) ; //rs.setAttribute("timeout", new Integer((int) _loadBalanceSocketTimeout)); _activeCount . incrementAndGet ( ) ; _connectCountTotal . incrementAndGet ( ) ; ClientSocket stream = new ClientSocket ( this , _streamCount ++ , rs , pair . getWriteStream ( ) ) ; if ( log . isLoggable ( Level . FINER ) ) log . finer ( "connect " + stream ) ; if ( _firstSuccessTime <= 0 ) { if ( _state . isStarting ( ) ) { if ( _loadBalanceWarmupTime > 0 ) _state = State . WARMUP ; else _state = State . ACTIVE ; _firstSuccessTime = CurrentTime . currentTime ( ) ; } if ( _warmupState < 0 ) _warmupState = 0 ; } return stream ; } catch ( IOException e ) { if ( log . isLoggable ( Level . FINEST ) ) log . log ( Level . FINEST , this + " " + e . toString ( ) , e ) ; else log . finer ( this + " " + e . toString ( ) ) ; failConnect ( connectionStartTime ) ; return null ; } finally { _startingCount . decrementAndGet ( ) ; } } | Connect to the backend server . | 539 | 6 |
139,903 | public boolean canConnect ( ) { try { wake ( ) ; ClientSocket stream = open ( ) ; if ( stream != null ) { stream . free ( stream . getIdleStartTime ( ) ) ; return true ; } return false ; } catch ( Exception e ) { log . log ( Level . FINER , e . toString ( ) , e ) ; return false ; } } | Returns true if can connect to the client . | 81 | 9 |
139,904 | @ Override public void write ( byte [ ] buffer , int offset , int length ) { write ( buffer , offset , length , true ) ; } | Write a final binary chunk . | 31 | 6 |
139,905 | @ Override public void writePart ( byte [ ] buffer , int offset , int length ) { write ( buffer , offset , length , false ) ; } | Write a non - final binary chunk . | 32 | 8 |
139,906 | private void write ( byte [ ] buffer , int offset , int length , boolean isFinal ) { Objects . requireNonNull ( buffer ) ; _frameOut . write ( buffer , offset , length , isFinal ) ; } | Write a binary chunk . | 46 | 5 |
139,907 | @ Override public void close ( WebSocketClose reason , String text ) { Objects . requireNonNull ( reason ) ; if ( _state . isClosed ( ) ) { return ; } _state = _state . closeSelf ( ) ; _frameOut . close ( reason , text ) ; if ( _state . isClosed ( ) ) { disconnect ( ) ; } } | Close the websocket . | 80 | 5 |
139,908 | private void readClose ( FrameIn fIs ) throws IOException { if ( _state . isClosed ( ) ) { return ; } _state = _state . closePeer ( ) ; int code = fIs . readClose ( ) ; StringBuilder sb = new StringBuilder ( ) ; fIs . readText ( sb ) ; if ( _service != null ) { WebSocketClose codeWs = WebSocketCloses . of ( code ) ; try { _service . close ( codeWs , sb . toString ( ) , this ) ; } catch ( Exception e ) { throw new IOException ( e ) ; } } else { close ( ) ; } if ( _state . isClosed ( ) ) { disconnect ( ) ; } //System.out.println("READ_C: " + code + " " + sb);; } | Read a close frame . | 182 | 5 |
139,909 | @ Override public void fail ( Throwable exn ) { log . log ( Level . WARNING , exn . toString ( ) , exn ) ; } | Close the websocket with a failure . | 34 | 8 |
139,910 | public static PathImpl lookup ( String url ) { PathImpl pwd = getPwd ( ) ; if ( ! url . startsWith ( "/" ) ) { return pwd . lookup ( url , null ) ; } else { return PWD . lookup ( url , null ) ; } } | Returns a new path relative to the current directory . | 61 | 10 |
139,911 | public static PathImpl getPwd ( ) { PathImpl pwd = ENV_PWD . get ( ) ; if ( pwd == null ) { if ( PWD == null ) { /* JNI set later PWD = JniFilePath.create(); if (PWD == null) PWD = new FilePath(null); */ PWD = new FilePath ( null ) ; } pwd = PWD ; ENV_PWD . setGlobal ( pwd ) ; } return pwd ; } | Returns a path for the current directory . | 109 | 8 |
139,912 | public static PathImpl lookupNative ( String url , Map < String , Object > attr ) { return getPwd ( ) . lookupNative ( url , attr ) ; } | Returns a native filesystem path with attributes . | 37 | 8 |
139,913 | public static ReadStreamOld openRead ( InputStream is ) { if ( is instanceof ReadStreamOld ) return ( ReadStreamOld ) is ; VfsStreamOld s = new VfsStreamOld ( is , null ) ; return new ReadStreamOld ( s ) ; } | Creates new ReadStream from an InputStream | 57 | 9 |
139,914 | public static ReadStreamOld openRead ( Reader reader ) { if ( reader instanceof ReadStreamOld . StreamReader ) return ( ( ReadStreamOld . StreamReader ) reader ) . getStream ( ) ; ReaderWriterStream s = new ReaderWriterStream ( reader , null ) ; ReadStreamOld is = new ReadStreamOld ( s ) ; try { is . setEncoding ( "utf-8" ) ; } catch ( Exception e ) { } return is ; } | Creates a ReadStream from a Reader | 97 | 8 |
139,915 | public static WriteStreamOld openWrite ( CharBuffer cb ) { com . caucho . v5 . vfs . VfsStringWriter s = new com . caucho . v5 . vfs . VfsStringWriter ( cb ) ; WriteStreamOld os = new WriteStreamOld ( s ) ; try { os . setEncoding ( "utf-8" ) ; } catch ( Exception e ) { } return os ; } | Creates a write stream to a CharBuffer . This is the standard way to write to a string . | 94 | 21 |
139,916 | public static void initJNI ( ) { if ( _isInitJNI . getAndSet ( true ) ) { return ; } // order matters because of static init and license checking FilesystemPath jniFilePath = JniFilePath . create ( ) ; if ( jniFilePath != null ) { DEFAULT_SCHEME_MAP . put ( "file" , jniFilePath ) ; SchemeMap localMap = _localSchemeMap . get ( ) ; if ( localMap != null ) localMap . put ( "file" , jniFilePath ) ; localMap = _localSchemeMap . get ( ClassLoader . getSystemClassLoader ( ) ) ; if ( localMap != null ) localMap . put ( "file" , jniFilePath ) ; VfsOld . PWD = jniFilePath ; VfsOld . setPwd ( jniFilePath ) ; } } | Initialize the JNI . | 196 | 6 |
139,917 | private void writeMetaTable ( TableEntry entry ) { TempBuffer tBuf = TempBuffer . create ( ) ; byte [ ] buffer = tBuf . buffer ( ) ; int offset = 0 ; buffer [ offset ++ ] = CODE_TABLE ; offset += BitsUtil . write ( buffer , offset , entry . tableKey ( ) ) ; offset += BitsUtil . writeInt16 ( buffer , offset , entry . rowLength ( ) ) ; offset += BitsUtil . writeInt16 ( buffer , offset , entry . keyOffset ( ) ) ; offset += BitsUtil . writeInt16 ( buffer , offset , entry . keyLength ( ) ) ; byte [ ] data = entry . data ( ) ; offset += BitsUtil . writeInt16 ( buffer , offset , data . length ) ; System . arraycopy ( data , 0 , buffer , offset , data . length ) ; offset += data . length ; int crc = _nonce ; crc = Crc32Caucho . generate ( crc , buffer , 0 , offset ) ; offset += BitsUtil . writeInt ( buffer , offset , crc ) ; // XXX: overflow try ( OutStore sOut = openWrite ( _metaOffset , offset ) ) { sOut . write ( _metaOffset , buffer , 0 , offset ) ; _metaOffset += offset ; } tBuf . free ( ) ; if ( _metaTail - _metaOffset < 16 ) { writeMetaContinuation ( ) ; } } | Metadata for a table entry . | 315 | 7 |
139,918 | private void writeMetaContinuation ( ) { TempBuffer tBuf = TempBuffer . create ( ) ; byte [ ] buffer = tBuf . buffer ( ) ; int metaLength = _segmentMeta [ 0 ] . size ( ) ; SegmentExtent extent = new SegmentExtent ( 0 , _addressTail , metaLength ) ; _metaExtents . add ( extent ) ; _addressTail += metaLength ; int offset = 0 ; buffer [ offset ++ ] = CODE_META_SEGMENT ; long address = extent . address ( ) ; int length = extent . length ( ) ; long value = ( address & ~ 0xffff ) | ( length >> 16 ) ; offset += BitsUtil . writeLong ( buffer , offset , value ) ; int crc = _nonce ; crc = Crc32Caucho . generate ( crc , buffer , 0 , offset ) ; offset += BitsUtil . writeInt ( buffer , offset , crc ) ; try ( OutStore sOut = openWrite ( _metaOffset , offset ) ) { sOut . write ( _metaOffset , buffer , 0 , offset ) ; } tBuf . free ( ) ; _metaAddress = address ; _metaOffset = address ; _metaTail = address + length ; } | Writes a continuation entry which points to a new meta - data segment . | 276 | 15 |
139,919 | private boolean readMetaData ( ) throws IOException { SegmentExtent metaExtentInit = new SegmentExtent ( 0 , 0 , META_SEGMENT_SIZE ) ; try ( InSegment reader = openRead ( metaExtentInit ) ) { ReadStream is = reader . in ( ) ; if ( ! readMetaDataHeader ( is ) ) { return false ; } _segmentId = 1 ; } int metaLength = _segmentMeta [ 0 ] . size ( ) ; SegmentExtent metaExtent = new SegmentExtent ( 0 , 0 , metaLength ) ; _metaExtents . clear ( ) ; _metaExtents . add ( metaExtent ) ; _metaAddress = 0 ; _metaOffset = META_OFFSET ; _metaTail = _metaOffset + metaLength ; while ( true ) { try ( InSegment reader = openRead ( metaExtent ) ) { ReadStream is = reader . in ( ) ; if ( metaExtent . address ( ) == 0 ) { is . position ( META_OFFSET ) ; } long metaAddress = _metaAddress ; while ( readMetaDataEntry ( is ) ) { } if ( _metaAddress == metaAddress ) { return true ; } metaExtent = new SegmentExtent ( 0 , _metaAddress , metaLength ) ; } } } | Reads metadata header for entire database . | 291 | 8 |
139,920 | private boolean readMetaDataHeader ( ReadStream is ) throws IOException { long magic = BitsUtil . readLong ( is ) ; if ( magic != KELP_MAGIC ) { log . info ( L . l ( "Mismatched kelp version {0} {1}\n" , Long . toHexString ( magic ) , _path ) ) ; return false ; } int crc = CRC_INIT ; 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 ) { log . info ( L . l ( "Mismatched crc files in kelp meta header" ) ) ; return false ; } SegmentMeta [ ] segmentMetaList = new SegmentMeta [ segmentSizes . size ( ) ] ; for ( int i = 0 ; i < segmentMetaList . length ; i ++ ) { segmentMetaList [ i ] = new SegmentMeta ( segmentSizes . get ( i ) ) ; } _segmentMeta = segmentMetaList ; _metaOffset = is . position ( ) ; _addressTail = META_SEGMENT_SIZE ; return true ; } | The first metadata for the store includes the sizes of the segments the crc nonce and optional headers . | 524 | 21 |
139,921 | private boolean readMetaDataEntry ( ReadStream is ) throws IOException { int crc = _nonce ; int code = is . read ( ) ; crc = Crc32Caucho . generate ( crc , code ) ; switch ( code ) { case CODE_TABLE : readMetaTable ( is , crc ) ; break ; case CODE_SEGMENT : readMetaSegment ( is , crc ) ; break ; case CODE_META_SEGMENT : readMetaContinuation ( is , crc ) ; break ; default : return false ; } _metaOffset = is . position ( ) ; return true ; } | Reads meta - data entries . | 135 | 7 |
139,922 | 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 . readAll ( data , 0 , data . length ) ; crc = Crc32Caucho . generate ( crc , data ) ; int crcFile = BitsUtil . readInt ( is ) ; if ( crcFile != crc ) { log . fine ( "meta-table crc mismatch" ) ; return false ; } TableEntry entry = new TableEntry ( key , rowLength , keyOffset , keyLength , data ) ; _tableList . add ( entry ) ; return true ; } | Read metadata for a table . | 330 | 6 |
139,923 | private boolean readMetaSegment ( ReadStream is , int crc ) throws IOException { long value = BitsUtil . readLong ( is ) ; crc = Crc32Caucho . generate ( crc , value ) ; int crcFile = BitsUtil . readInt ( is ) ; if ( crcFile != crc ) { log . fine ( "meta-segment crc mismatch" ) ; return false ; } long address = value & ~ 0xffff ; int length = ( int ) ( ( value & 0xffff ) << 16 ) ; SegmentExtent segment = new SegmentExtent ( _segmentId ++ , address , length ) ; SegmentMeta segmentMeta = findSegmentMeta ( length ) ; segmentMeta . addSegment ( segment ) ; return true ; } | metadata for a segment | 173 | 4 |
139,924 | private boolean readMetaContinuation ( ReadStream is , int crc ) throws IOException { long value = BitsUtil . readLong ( is ) ; crc = Crc32Caucho . generate ( crc , value ) ; int crcFile = BitsUtil . readInt ( is ) ; if ( crcFile != crc ) { log . fine ( "meta-segment crc mismatch" ) ; return false ; } long address = value & ~ 0xffff ; int length = ( int ) ( ( value & 0xffff ) << 16 ) ; if ( length != _segmentMeta [ 0 ] . size ( ) ) { throw new IllegalStateException ( ) ; } SegmentExtent extent = new SegmentExtent ( 0 , address , length ) ; _metaExtents . add ( extent ) ; _metaAddress = address ; _metaOffset = address ; _metaTail = address + length ; // false continues to the next segment return false ; } | Continuation segment for the metadata . | 209 | 7 |
139,925 | private SegmentMeta findSegmentMeta ( int size ) { for ( SegmentMeta segmentMeta : this . _segmentMeta ) { if ( segmentMeta . size ( ) == size ) { return segmentMeta ; } } throw new IllegalStateException ( L . l ( "{0} is an invalid segment size" , size ) ) ; } | Finds the segment group for a given size . | 72 | 10 |
139,926 | public SegmentKelp createSegment ( int length , byte [ ] tableKey , long sequence ) { SegmentMeta segmentMeta = findSegmentMeta ( length ) ; SegmentKelp segment ; SegmentExtent extent = segmentMeta . allocate ( ) ; if ( extent == null ) { extent = allocateSegment ( segmentMeta ) ; } segment = new SegmentKelp ( extent , sequence , tableKey , this ) ; segment . writing ( ) ; segmentMeta . addLoaded ( segment ) ; return segment ; } | Create a new writing sequence with the given sequence id . | 114 | 11 |
139,927 | private void findAfterLocal ( Result < Cursor > result , RowCursor cursor , Object [ ] args , Cursor cursorLocal ) { long version = 0 ; if ( cursorLocal != null ) { version = cursorLocal . getVersion ( ) ; long time = cursorLocal . getUpdateTime ( ) ; long timeout = cursorLocal . getTimeout ( ) ; long now = CurrentTime . currentTime ( ) ; if ( now <= time + timeout ) { result . ok ( cursorLocal ) ; return ; } } TablePod tablePod = _table . getTablePod ( ) ; tablePod . getIfUpdate ( cursor . getKey ( ) , version , result . then ( ( table , r ) -> _selectQueryLocal . findOne ( r , args ) ) ) ; } | After finding the local cursor if it s expired check with the cluster to find the most recent value . | 163 | 20 |
139,928 | @ Override public boolean containsKey ( Object key ) { if ( key == null ) { return false ; } K [ ] keys = _keys ; for ( int i = _size - 1 ; i >= 0 ; i -- ) { K testKey = keys [ i ] ; if ( key . equals ( testKey ) ) { return true ; } } return false ; } | Returns true if the map contains the value . | 78 | 9 |
139,929 | public void start ( ) { _state = _state . toStart ( ) ; _bufferCapacity = DEFAULT_SIZE ; _tBuf = TempBuffer . create ( ) ; _buffer = _tBuf . buffer ( ) ; _startOffset = bufferStart ( ) ; _offset = _startOffset ; _contentLength = 0 ; } | Starts the response stream . | 74 | 6 |
139,930 | @ Override public void write ( int ch ) throws IOException { if ( isClosed ( ) || isHead ( ) ) { return ; } int offset = _offset ; if ( SIZE <= offset ) { flushByteBuffer ( ) ; offset = _offset ; } _buffer [ offset ++ ] = ( byte ) ch ; _offset = offset ; } | Writes a byte to the output . | 75 | 8 |
139,931 | @ Override public void write ( byte [ ] buffer , int offset , int length ) { if ( isClosed ( ) || isHead ( ) ) { return ; } int byteLength = _offset ; while ( true ) { int sublen = Math . min ( length , SIZE - byteLength ) ; System . arraycopy ( buffer , offset , _buffer , byteLength , sublen ) ; offset += sublen ; length -= sublen ; byteLength += sublen ; if ( length <= 0 ) { break ; } _offset = byteLength ; flushByteBuffer ( ) ; byteLength = _offset ; } _offset = byteLength ; } | Writes a chunk of bytes to the stream . | 136 | 10 |
139,932 | @ Override public byte [ ] nextBuffer ( int offset ) throws IOException { if ( offset < 0 || SIZE < offset ) { throw new IllegalStateException ( L . l ( "Invalid offset: " + offset ) ) ; } if ( _bufferCapacity <= SIZE || _bufferCapacity <= offset + _bufferSize ) { _offset = offset ; flushByteBuffer ( ) ; return buffer ( ) ; } else { _tBuf . length ( offset ) ; _bufferSize += offset ; TempBuffer tempBuf = TempBuffer . create ( ) ; _tBuf . next ( tempBuf ) ; _tBuf = tempBuf ; _buffer = _tBuf . buffer ( ) ; _offset = _startOffset ; return _buffer ; } } | Returns the next byte buffer . | 166 | 6 |
139,933 | @ Override public final void close ( ) throws IOException { State state = _state ; if ( state . isClosing ( ) ) { return ; } _state = state . toClosing ( ) ; try { flush ( true ) ; } finally { try { _state = _state . toClose ( ) ; } catch ( RuntimeException e ) { throw new RuntimeException ( state + ": " + e , e ) ; } } } | Closes the response stream | 94 | 5 |
139,934 | private void flush ( boolean isEnd ) { if ( _startOffset == _offset && _bufferSize == 0 ) { if ( ! isCommitted ( ) || isEnd ) { flush ( null , isEnd ) ; _startOffset = bufferStart ( ) ; _offset = _startOffset ; } return ; } int sublen = _offset - _startOffset ; _tBuf . length ( _offset ) ; _contentLength += _offset - _startOffset ; _bufferSize = 0 ; if ( _startOffset > 0 ) { fillChunkHeader ( _tBuf , sublen ) ; } flush ( _tBuf , isEnd ) ; if ( ! isEnd ) { _tBuf = TempBuffer . create ( ) ; _startOffset = bufferStart ( ) ; _offset = _startOffset ; _tBuf . length ( _offset ) ; _buffer = _tBuf . buffer ( ) ; } else { _tBuf = null ; } } | Flushes the buffered response to the output stream . | 210 | 11 |
139,935 | private boolean readSend ( InH3 hIn , OutboxAmp outbox , HeadersAmp headers ) throws IOException { MethodRefHamp methodHamp = null ; try { methodHamp = readMethod ( hIn ) ; } catch ( Throwable e ) { log . log ( Level . FINER , e . toString ( ) , e ) ; skipArgs ( hIn ) ; return true ; } MethodRefAmp method = methodHamp . getMethod ( ) ; //ClassLoader loader = method.getService().getManager().getClassLoader(); ClassLoader loader = methodHamp . getClassLoader ( ) ; Thread thread = Thread . currentThread ( ) ; thread . setContextClassLoader ( loader ) ; // XXX: _serializer.setClassLoader(loader); Object [ ] args = readArgs ( methodHamp , hIn ) ; if ( log . isLoggable ( _logLevel ) ) { log . log ( _logLevel , this + " send-r " + method . getName ( ) + debugArgs ( args ) + " {to:" + method + ", " + headers + "}" ) ; } // XXX: s/b systemMailbox SendMessage_N sendMessage = new SendMessage_N ( outbox , headers , method . serviceRef ( ) , method . method ( ) , args ) ; long timeout = 1000L ; // mailbox delay timeout try { //sendMessage.offer(timeout); //sendMessage.offerQueue(timeout); // // sendMessage.getWorker().wake(); sendMessage . offer ( timeout ) ; } catch ( Throwable e ) { log . fine ( e . toString ( ) ) ; if ( log . isLoggable ( Level . FINEST ) ) { log . log ( Level . FINEST , e . toString ( ) , e ) ; } } return true ; } | The send message is a on - way call to a service . | 397 | 13 |
139,936 | private void readQuery ( InH3 hIn , OutboxAmp outbox , HeadersAmp headers ) throws IOException { GatewayReply from = readFromAddress ( hIn ) ; long qid = hIn . readLong ( ) ; long timeout = 120 * 1000L ; /* AmpQueryRef queryRef = new QueryItem(NullMethodRef.NULL, _context, headers, timeout); */ MethodRefHamp methodHamp = null ; MethodRefAmp methodRef = null ; try { try { methodHamp = readMethod ( hIn ) ; } catch ( Throwable e ) { skipArgs ( hIn ) ; throw e ; } methodRef = methodHamp . getMethod ( ) ; ClassLoader loader = methodHamp . getClassLoader ( ) ; Thread thread = Thread . currentThread ( ) ; thread . setContextClassLoader ( loader ) ; // XXX: _serializer.setClassLoader(loader); Object [ ] args = readArgs ( methodHamp , hIn ) ; QueryGatewayReadMessage_N msg = new QueryGatewayReadMessage_N ( outbox , getInboxCaller ( ) , headers , from , qid , methodRef . serviceRef ( ) , methodRef . method ( ) , timeout , args ) ; //msg.offer(_queueTimeout); //msg.offerQueue(_queueTimeout); // msg.getWorker().wake(); msg . offer ( _queueTimeout ) ; //outbox.flush(); if ( log . isLoggable ( _logLevel ) ) { log . log ( _logLevel , "hamp-query " + methodRef . getName ( ) + " " + debugArgs ( args ) + " (in " + this + ")" + "\n {qid:" + qid + ", to:" + methodRef . serviceRef ( ) + ", from:" + from + "," + headers + "}" ) ; } } catch ( Throwable e ) { if ( log . isLoggable ( Level . FINE ) ) { log . fine ( "hamp-query error " + e + " (in " + this + ")" + "\n {id:" + qid + ", from:" + from + "," + headers + "," + methodRef + "}" ) ; } if ( log . isLoggable ( Level . FINER ) ) { log . log ( Level . FINER , e . toString ( ) , e ) ; } ServiceRefAmp serviceRef = getInboxCaller ( ) . serviceRef ( ) ; MethodRefError methodErr ; if ( methodRef == null ) { methodErr = new MethodRefError ( serviceRef , "unknown-method" ) ; } else { methodErr = new MethodRefError ( serviceRef , methodRef . getName ( ) ) ; } QueryGatewayReadMessage_N queryRef = new QueryGatewayReadMessage_N ( outbox , getInboxCaller ( ) , headers , from , qid , serviceRef , methodErr . method ( ) , timeout , null ) ; queryRef . toSent ( ) ; // queryRef.failed(headers, e); //System.out.println("FAIL: " + e); if ( e instanceof ServiceException ) { queryRef . fail ( e ) ; outbox . flush ( ) ; } else { HampException exn = new HampException ( L . l ( "{0}\n while reading {1}" , e . toString ( ) , methodRef ) , e ) ; queryRef . fail ( exn ) ; } } } | The query message is a RPC call to a service . | 760 | 11 |
139,937 | private void readQueryResult ( InH3 hIn , HeadersAmp headers ) throws IOException { ServiceRefAmp serviceRef = readToAddress ( hIn ) ; long id = hIn . readLong ( ) ; QueryRefAmp queryRef = serviceRef . removeQueryRef ( id ) ; if ( queryRef != null ) { ClassLoader loader = queryRef . getClassLoader ( ) ; Thread thread = Thread . currentThread ( ) ; thread . setContextClassLoader ( loader ) ; // XXX: _serializer.setClassLoader(loader); } else { // XX: _serializer.setClassLoader(null); } Object value = hIn . readObject ( ) ; if ( log . isLoggable ( _logLevel ) ) { log . log ( _logLevel , "query-result-r " + value + " (in " + this + ")" + "\n {id:" + id + ", to:" + serviceRef + "," + headers + "}" ) ; } if ( queryRef != null ) { queryRef . complete ( headers , value ) ; } else if ( log . isLoggable ( Level . WARNING ) ) { log . warning ( "query-result qid=" + id + " for service " + serviceRef + " does not match any known queries.\n" + headers ) ; } } | query reply parsing | 289 | 3 |
139,938 | public void addInclude ( PathPatternType pattern ) { if ( _includeList == null ) _includeList = new ArrayList < PathPatternType > ( ) ; _includeList . add ( pattern ) ; } | Adds an include pattern . | 45 | 5 |
139,939 | public void setUserPathPrefix ( String prefix ) { if ( prefix != null && ! prefix . equals ( "" ) && ! prefix . endsWith ( "/" ) ) _userPathPrefix = prefix + "/" ; else _userPathPrefix = prefix ; } | Sets the user - path prefix for better error reporting . | 57 | 12 |
139,940 | @ Override public ExprKraken getKeyExpr ( String name ) { if ( name . equals ( _column . getColumn ( ) . name ( ) ) ) { return getRight ( ) ; } else { return null ; } } | Returns the assigned key expression | 52 | 5 |
139,941 | @ Override public void write ( byte [ ] buf , int offset , int length , boolean isEnd ) throws IOException { OutputStream stream = getStream ( ) ; if ( stream == null ) { return ; } synchronized ( stream ) { stream . write ( buf , offset , length ) ; if ( isEnd ) { stream . flush ( ) ; } } } | Write data to the stream . | 76 | 6 |
139,942 | @ Override public void flush ( ) throws IOException { OutputStream stream = getStream ( ) ; if ( stream == null ) { return ; } synchronized ( stream ) { stream . flush ( ) ; } } | Flush data to the stream . | 44 | 7 |
139,943 | public synchronized static void setStdout ( OutputStream os ) { if ( _stdoutStream == null ) { initStdout ( ) ; } if ( os == _systemErr || os == _systemOut ) { return ; } if ( os instanceof WriteStream ) { WriteStream out = ( WriteStream ) os ; /* if (out.getSource() == StdoutStream.create() || out.getSource() == StderrStream.create()) { return; } */ } _stdoutStream . setStream ( os ) ; } | Sets the backing stream for System . out | 118 | 9 |
139,944 | public static synchronized void setStderr ( OutputStream os ) { if ( _stderrStream == null ) { initStderr ( ) ; } if ( os == _systemErr || os == _systemOut ) { return ; } if ( os instanceof WriteStream ) { WriteStream out = ( WriteStream ) os ; /* if (out.getSource() == StdoutStream.create() || out.getSource() == StderrStream.create()) { return; } */ } _stderrStream . setStream ( os ) ; } | Sets path as the backing stream for System . err | 120 | 11 |
139,945 | protected static < E extends SubSystemBase > SystemManager preCreate ( Class < E > serviceClass ) { SystemManager system = SystemManager . getCurrent ( ) ; if ( system == null ) throw new IllegalStateException ( L . l ( "{0} must be created before {1}" , SystemManager . class . getSimpleName ( ) , serviceClass . getSimpleName ( ) ) ) ; if ( system . getSystem ( serviceClass ) != null ) throw new IllegalStateException ( L . l ( "{0} was previously created" , serviceClass . getSimpleName ( ) ) ) ; return system ; } | convenience method for subclass s create methods | 129 | 9 |
139,946 | public String addConnectionRequirement ( NodeTemplate target , String type , String varName ) { Map < String , Object > requirement = new LinkedHashMap ( ) ; String requirementName = "endpoint" ; Map requirementMap = new LinkedHashMap < String , Object > ( ) ; requirement . put ( requirementName , requirementMap ) ; requirementMap . put ( "node" , target . getName ( ) ) ; requirementMap . put ( "type" , type ) ; if ( ! varName . isEmpty ( ) ) { Map < String , String > properties = new LinkedHashMap ( ) ; properties . put ( "prop.name" , varName ) ; requirementMap . put ( "properties" , properties ) ; } requirements ( ) . add ( requirement ) ; return requirementName ; } | Add an endpoint requirement to a NodeTemplate | 170 | 8 |
139,947 | @ Override public boolean stop ( ) { if ( ! _lifecycle . toStopping ( ) ) return false ; log . finest ( this + " stopping" ) ; closeConnections ( ) ; destroy ( ) ; return true ; } | Closing the manager . | 50 | 5 |
139,948 | int writePageIndex ( byte [ ] buffer , int head , int type , int pid , int nextPid , int entryOffset , int entryLength ) { int sublen = 1 + 4 * 4 ; if ( BLOCK_SIZE - 8 < head + sublen ) { return - 1 ; } buffer [ head ] = ( byte ) type ; head ++ ; BitsUtil . writeInt ( buffer , head , pid ) ; head += 4 ; BitsUtil . writeInt ( buffer , head , nextPid ) ; head += 4 ; BitsUtil . writeInt ( buffer , head , entryOffset ) ; head += 4 ; BitsUtil . writeInt ( buffer , head , entryLength ) ; head += 4 ; return head ; } | Writes a page index . | 156 | 6 |
139,949 | public void readEntries ( TableKelp table , InSegment reader , SegmentEntryCallback cb ) { TempBuffer tBuf = TempBuffer . createLarge ( ) ; byte [ ] buffer = tBuf . buffer ( ) ; InStore sIn = reader . getStoreRead ( ) ; byte [ ] tableKey = new byte [ TableKelp . TABLE_KEY_SIZE ] ; for ( int ptr = length ( ) - BLOCK_SIZE ; ptr > 0 ; ptr -= BLOCK_SIZE ) { sIn . read ( getAddress ( ) + ptr , buffer , 0 , buffer . length ) ; int index = 0 ; long seq = BitsUtil . readLong ( buffer , index ) ; index += 8 ; if ( seq != getSequence ( ) ) { log . warning ( L . l ( "Invalid sequence {0} expected {1} at 0x{2}" , seq , getSequence ( ) , Long . toHexString ( getAddress ( ) + ptr ) ) ) ; break ; } System . arraycopy ( buffer , index , tableKey , 0 , tableKey . length ) ; index += tableKey . length ; if ( ! Arrays . equals ( tableKey , _tableKey ) ) { log . warning ( L . l ( "Invalid table {0} table {1} at 0x{2}" , Hex . toShortHex ( tableKey ) , Hex . toShortHex ( _tableKey ) , Long . toHexString ( getAddress ( ) + ptr ) ) ) ; break ; } /* int tail = BitsUtil.readInt16(buffer, index); index += 2; if (tail <= 0) { throw new IllegalStateException(); } */ int head = index ; while ( head < BLOCK_SIZE && buffer [ head ] != 0 ) { head = readEntry ( table , buffer , head , cb , getAddress ( ) ) ; } boolean isCont = buffer [ head + 1 ] != 0 ; if ( ! isCont ) { break ; } } tBuf . free ( ) ; } | Reads index entries from the segment . | 444 | 8 |
139,950 | public int getSize ( ) { int size = length ( ) ; if ( _blobs == null ) { return size ; } for ( BlobOutputStream blob : _blobs ) { if ( blob != null ) { size += blob . getSize ( ) ; } } return size ; } | The size includes the dynamic size from any blobs | 62 | 10 |
139,951 | public final OutputStream openOutputStream ( int index ) { Column column = _row . columns ( ) [ index ] ; return column . openOutputStream ( this ) ; } | Set a blob value with an open blob stream . | 36 | 10 |
139,952 | public static Path currentDataDirectory ( ) { RootDirectorySystem rootService = getCurrent ( ) ; if ( rootService == null ) throw new IllegalStateException ( L . l ( "{0} must be active for getCurrentDataDirectory()." , RootDirectorySystem . class . getSimpleName ( ) ) ) ; return rootService . dataDirectory ( ) ; } | Returns the data directory for current active directory service . | 75 | 10 |
139,953 | public static JournalStore create ( Path path , boolean isMmap ) throws IOException { // RampManager rampManager = Ramp.newManager(); long segmentSize = 4 * 1024 * 1024 ; JournalStore . Builder builder = JournalStore . Builder . create ( path ) ; builder . segmentSize ( segmentSize ) ; // builder.rampManager(rampManager); builder . mmap ( isMmap ) ; JournalStore store = builder . build ( ) ; return store ; } | Creates an independent store . | 99 | 6 |
139,954 | public static void clearJarCache ( ) { LruCache < PathImpl , Jar > jarCache = _jarCache ; if ( jarCache == null ) return ; ArrayList < Jar > jars = new ArrayList < Jar > ( ) ; synchronized ( jarCache ) { Iterator < Jar > iter = jarCache . values ( ) ; while ( iter . hasNext ( ) ) jars . add ( iter . next ( ) ) ; } for ( int i = 0 ; i < jars . size ( ) ; i ++ ) { Jar jar = jars . get ( i ) ; if ( jar != null ) jar . clearCache ( ) ; } } | Clears all the cached files in the jar . Needed to avoid some windows NT issues . | 135 | 19 |
139,955 | private Path keyStoreFile ( ) { String fileName = _config . get ( _prefix + ".ssl.key-store" ) ; if ( fileName == null ) { return null ; } return Vfs . path ( fileName ) ; } | Returns the certificate file . | 52 | 5 |
139,956 | private String keyStorePassword ( ) { String password = _config . get ( _prefix + ".ssl.key-store-password" ) ; if ( password != null ) { return password ; } else { return _config . get ( _prefix + ".ssl.password" ) ; } } | Returns the key - store password | 61 | 6 |
139,957 | private SSLSocketFactory createFactory ( ) throws Exception { SSLSocketFactory ssFactory = null ; String host = "localhost" ; int port = 8086 ; if ( _keyStore == null ) { return createAnonymousFactory ( null , port ) ; } SSLContext sslContext = SSLContext . getInstance ( _sslContext ) ; KeyManagerFactory kmf = KeyManagerFactory . getInstance ( keyManagerFactory ( ) ) ; kmf . init ( _keyStore , keyStorePassword ( ) . toCharArray ( ) ) ; sslContext . init ( kmf . getKeyManagers ( ) , null , null ) ; /* if (_cipherSuites != null) sslContext.createSSLEngine().setEnabledCipherSuites(_cipherSuites); */ SSLEngine engine = sslContext . createSSLEngine ( ) ; _enabledProtocols = enabledProtocols ( engine . getEnabledProtocols ( ) ) ; engine . setEnabledProtocols ( _enabledProtocols ) ; ssFactory = sslContext . getSocketFactory ( ) ; return ssFactory ; } | Creates the SSLSocketFactory | 240 | 7 |
139,958 | public static InjectorImpl current ( ClassLoader loader ) { if ( loader instanceof DynamicClassLoader ) { return _localManager . getLevel ( loader ) ; } else { SoftReference < InjectorImpl > injectRef = _loaderManagerMap . get ( loader ) ; if ( injectRef != null ) { return injectRef . get ( ) ; } else { return null ; } } } | Returns the current inject manager . | 83 | 6 |
139,959 | @ Override public < T > T instance ( Class < T > type ) { Key < T > key = Key . of ( type ) ; return instance ( key ) ; } | Creates a new instance for a given type . | 37 | 10 |
139,960 | @ Override public < T > T instance ( Key < T > key ) { Objects . requireNonNull ( key ) ; Class < T > type = ( Class ) key . rawClass ( ) ; if ( type . equals ( Provider . class ) ) { TypeRef typeRef = TypeRef . of ( key . type ( ) ) ; TypeRef param = typeRef . param ( 0 ) ; return ( T ) provider ( Key . of ( param . type ( ) ) ) ; } Provider < T > provider = provider ( key ) ; if ( provider != null ) { return provider . get ( ) ; } else { return null ; } } | Creates a new instance for a given key . | 135 | 10 |
139,961 | @ Override public < T > T instance ( InjectionPoint < T > ip ) { Objects . requireNonNull ( ip ) ; Provider < T > provider = provider ( ip ) ; if ( provider != null ) { return provider . get ( ) ; } else { return null ; } } | Creates a new bean instance for a given InjectionPoint such as a method or field . | 61 | 19 |
139,962 | @ Override public < T > Provider < T > provider ( InjectionPoint < T > ip ) { Objects . requireNonNull ( ip ) ; Provider < T > provider = lookupProvider ( ip ) ; if ( provider != null ) { return provider ; } provider = autoProvider ( ip ) ; if ( provider != null ) { return provider ; } return new ProviderNull ( ip . key ( ) , - 10000 , new InjectScopeSingleton ( ) ) ; } | Creates an instance provider for a given InjectionPoint such as a method or field . | 98 | 18 |
139,963 | @ Override public < T > Provider < T > provider ( Key < T > key ) { Objects . requireNonNull ( key ) ; Provider < T > provider = ( Provider ) _providerMap . get ( key ) ; if ( provider == null ) { provider = lookupProvider ( key ) ; if ( provider == null ) { provider = autoProvider ( key ) ; } _providerMap . putIfAbsent ( key , provider ) ; provider = ( Provider ) _providerMap . get ( key ) ; } return provider ; } | Returns a bean instance provider for a key . | 114 | 9 |
139,964 | private < T > Provider < T > lookupProvider ( Key < T > key ) { BindingInject < T > bean = findBean ( key ) ; if ( bean != null ) { return bean . provider ( ) ; } BindingAmp < T > binding = findBinding ( key ) ; if ( binding != null ) { return binding . provider ( ) ; } binding = findObjectBinding ( key ) ; if ( binding != null ) { return binding . provider ( InjectionPoint . of ( key ) ) ; } return null ; } | Search for a matching provider for a key . | 115 | 9 |
139,965 | private < T > Provider < T > lookupProvider ( InjectionPoint < T > ip ) { Key < T > key = ip . key ( ) ; BindingInject < T > bean = findBean ( key ) ; if ( bean != null ) { return bean . provider ( ip ) ; } BindingAmp < T > provider = findBinding ( key ) ; if ( provider != null ) { return provider . provider ( ip ) ; } provider = findObjectBinding ( key ) ; if ( provider != null ) { return provider . provider ( ip ) ; } return null ; } | Create a provider for an injection point . | 124 | 8 |
139,966 | private < T > InjectScope < T > findScope ( AnnotatedElement annElement ) { for ( Annotation ann : annElement . getAnnotations ( ) ) { Class < ? extends Annotation > annType = ann . annotationType ( ) ; if ( annType . isAnnotationPresent ( Scope . class ) ) { Supplier < InjectScope < T >> scopeGen = ( Supplier ) _scopeMap . get ( annType ) ; if ( scopeGen != null ) { return scopeGen . get ( ) ; } else { log . fine ( L . l ( "@{0} is an unknown scope" , annType . getSimpleName ( ) ) ) ; } } } return new InjectScopeFactory <> ( ) ; } | Finds the scope for a bean producing declaration either a method or a type . | 159 | 16 |
139,967 | @ Override public < T > Iterable < Binding < T > > bindings ( Class < T > type ) { BindingSet < T > set = ( BindingSet ) _bindingSetMap . get ( type ) ; if ( set != null ) { return ( Iterable ) set ; } else { return Collections . EMPTY_LIST ; } } | Returns all bindings matching a type . | 72 | 7 |
139,968 | @ Override public < T > List < Binding < T > > bindings ( Key < T > key ) { BindingSet < T > set = ( BindingSet ) _bindingSetMap . get ( key . rawClass ( ) ) ; if ( set != null ) { return set . bindings ( key ) ; } else { return Collections . EMPTY_LIST ; } } | Returns all bindings matching a key . | 77 | 7 |
139,969 | < T > InjectScope < T > scope ( Class < ? extends Annotation > scopeType ) { Supplier < InjectScope < T >> scopeGen = ( Supplier ) _scopeMap . get ( scopeType ) ; if ( scopeGen == null ) { throw error ( "{0} is an unknown scope" , scopeType . getSimpleName ( ) ) ; } return scopeGen . get ( ) ; } | Returns the scope given a scope annotation . | 88 | 8 |
139,970 | @ Override public < T > Consumer < T > injector ( Class < T > type ) { ArrayList < InjectProgram > injectList = new ArrayList <> ( ) ; introspectInject ( injectList , type ) ; introspectInit ( injectList , type ) ; return new InjectProgramImpl < T > ( injectList ) ; } | Create an injector for a bean type . The consumer will inject the bean s fields . | 75 | 18 |
139,971 | @ Override public Provider < ? > [ ] program ( Parameter [ ] params ) { Provider < ? > [ ] program = new Provider < ? > [ params . length ] ; for ( int i = 0 ; i < program . length ; i ++ ) { //Key<?> key = Key.of(params[i]); program [ i ] = provider ( InjectionPoint . of ( params [ i ] ) ) ; } return program ; } | Create a program for method arguments . | 94 | 7 |
139,972 | private < T > BindingInject < T > findBean ( Key < T > key ) { for ( InjectProvider provider : _providerList ) { BindingInject < T > bean = ( BindingInject ) provider . lookup ( key . rawClass ( ) ) ; if ( bean != null ) { return bean ; } } return null ; } | Find a binding by the key . | 75 | 7 |
139,973 | private < T > BindingAmp < T > findObjectBinding ( Key < T > key ) { Objects . requireNonNull ( key ) ; if ( key . qualifiers ( ) . length != 1 ) { throw new IllegalArgumentException ( ) ; } return ( BindingAmp ) findBinding ( Key . of ( Object . class , key . qualifiers ( ) [ 0 ] ) ) ; } | Returns an object producer . | 84 | 5 |
139,974 | private < T > BindingAmp < T > findBinding ( Key < T > key ) { BindingSet < T > set = ( BindingSet ) _bindingSetMap . get ( key . rawClass ( ) ) ; if ( set != null ) { BindingAmp < T > binding = set . find ( key ) ; if ( binding != null ) { return binding ; } } return null ; } | Finds a producer for the given target type . | 85 | 10 |
139,975 | public void setLevel ( Level level ) { _level = level ; if ( level . intValue ( ) < _lowLevel . intValue ( ) ) _lowLevel = level ; } | Sets the lifecycle logging level . | 39 | 8 |
139,976 | public boolean waitForActive ( long timeout ) { LifecycleState state = getState ( ) ; if ( state . isActive ( ) ) { return true ; } else if ( state . isAfterActive ( ) ) { return false ; } // server/1d2j long waitEnd = CurrentTime . getCurrentTimeActual ( ) + timeout ; synchronized ( this ) { while ( ( state = _state ) . isBeforeActive ( ) && CurrentTime . getCurrentTimeActual ( ) < waitEnd ) { if ( state . isActive ( ) ) { return true ; } else if ( state . isAfterActive ( ) ) { return false ; } try { long delta = waitEnd - CurrentTime . getCurrentTimeActual ( ) ; if ( delta > 0 ) { wait ( delta ) ; } } catch ( InterruptedException e ) { } } } return _state . isActive ( ) ; } | Wait for a period of time until the service starts . | 193 | 11 |
139,977 | public boolean toPostInit ( ) { synchronized ( this ) { if ( _state == STOPPED ) { _state = INIT ; _lastChangeTime = CurrentTime . currentTime ( ) ; notifyListeners ( STOPPED , INIT ) ; return true ; } else { return _state . isInit ( ) ; } } } | Changes to the init from the stopped state . | 72 | 9 |
139,978 | public boolean toStarting ( ) { LifecycleState state ; synchronized ( this ) { state = _state ; if ( state . isAfterStarting ( ) && ! state . isStopped ( ) ) { return false ; } _state = STARTING ; _lastChangeTime = CurrentTime . currentTime ( ) ; if ( _log != null && _log . isLoggable ( _level ) && _log . isLoggable ( Level . FINER ) ) { _log . finer ( "starting " + _name ) ; } } notifyListeners ( state , STARTING ) ; return true ; } | Changes to the starting state . | 128 | 6 |
139,979 | public boolean toActive ( ) { LifecycleState state ; synchronized ( this ) { state = _state ; if ( state . isAfterActive ( ) && ! state . isStopped ( ) ) { return false ; } _state = ACTIVE ; _lastChangeTime = CurrentTime . currentTime ( ) ; } if ( _log != null && _log . isLoggable ( _level ) ) _log . log ( _level , "active " + _name ) ; notifyListeners ( state , ACTIVE ) ; return true ; } | Changes to the active state . | 115 | 6 |
139,980 | public boolean toFail ( ) { LifecycleState state ; synchronized ( this ) { state = _state ; if ( state . isAfterDestroying ( ) ) { return false ; } _state = FAILED ; _lastChangeTime = CurrentTime . currentTime ( ) ; } if ( _log != null && _log . isLoggable ( _level ) ) _log . log ( _level , "fail " + _name ) ; notifyListeners ( state , FAILED ) ; _failCount ++ ; return true ; } | Changes to the failed state . | 114 | 6 |
139,981 | public boolean toStopping ( ) { LifecycleState state ; synchronized ( this ) { state = _state ; if ( state . isAfterStopping ( ) || state . isStarting ( ) ) { return false ; } _state = STOPPING ; _lastChangeTime = CurrentTime . currentTime ( ) ; } if ( _log != null && _log . isLoggable ( _level ) ) { _log . log ( _level , "stopping " + _name ) ; } notifyListeners ( state , STOPPING ) ; return true ; } | Changes to the stopping state . | 120 | 6 |
139,982 | public void addListener ( LifecycleListener listener ) { synchronized ( this ) { if ( isDestroyed ( ) ) { IllegalStateException e = new IllegalStateException ( "attempted to add listener to a destroyed lifecyle " + this ) ; if ( _log != null ) _log . log ( Level . WARNING , e . toString ( ) , e ) ; else Logger . getLogger ( Lifecycle . class . getName ( ) ) . log ( Level . WARNING , e . toString ( ) , e ) ; return ; } if ( _listeners == null ) _listeners = new ArrayList < WeakReference < LifecycleListener > > ( ) ; for ( int i = _listeners . size ( ) - 1 ; i >= 0 ; i -- ) { LifecycleListener oldListener = _listeners . get ( i ) . get ( ) ; if ( listener == oldListener ) return ; else if ( oldListener == null ) _listeners . remove ( i ) ; } _listeners . add ( new WeakReference < LifecycleListener > ( listener ) ) ; } } | Adds a listener to detect lifecycle changes . | 234 | 9 |
139,983 | @ Override public String serialize ( Object obj ) throws JsonMarshallingException { try { return serializeChecked ( obj ) ; } catch ( Exception e ) { throw new JsonMarshallingException ( e ) ; } } | Serialize the given Java object into JSON string . | 49 | 10 |
139,984 | public void setExecutorTaskMax ( int max ) { if ( getThreadMax ( ) < max ) throw new ConfigException ( L . l ( "<thread-executor-max> ({0}) must be less than <thread-max> ({1})" , max , getThreadMax ( ) ) ) ; if ( max == 0 ) throw new ConfigException ( L . l ( "<thread-executor-max> must not be zero." ) ) ; _executorTaskMax = max ; } | Sets the maximum number of executor threads . | 106 | 10 |
139,985 | public boolean scheduleExecutorTask ( Runnable task ) { ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; synchronized ( _executorLock ) { _executorTaskCount ++ ; if ( _executorTaskCount <= _executorTaskMax || _executorTaskMax < 0 ) { boolean isPriority = false ; boolean isQueue = true ; boolean isWake = true ; return scheduleImpl ( task , loader , MAX_EXPIRE , isPriority , isQueue , isWake ) ; } else { ExecutorQueueItem item = new ExecutorQueueItem ( task , loader ) ; if ( _executorQueueTail != null ) _executorQueueTail . _next = item ; else _executorQueueHead = item ; _executorQueueTail = item ; return false ; } } } | Schedules an executor task . | 182 | 8 |
139,986 | public void completeExecutorTask ( ) { ExecutorQueueItem item = null ; synchronized ( _executorLock ) { _executorTaskCount -- ; assert ( _executorTaskCount >= 0 ) ; if ( _executorQueueHead != null ) { item = _executorQueueHead ; _executorQueueHead = item . _next ; if ( _executorQueueHead == null ) _executorQueueTail = null ; } } if ( item != null ) { Runnable task = item . getRunnable ( ) ; ClassLoader loader = item . getLoader ( ) ; boolean isPriority = false ; boolean isQueue = true ; boolean isWake = true ; scheduleImpl ( task , loader , MAX_EXPIRE , isPriority , isQueue , isWake ) ; } } | Called when an executor task completes | 173 | 8 |
139,987 | public Offering getOffering ( String offeringName ) { BasicDBObject query = new BasicDBObject ( "offering_name" , offeringName ) ; FindIterable < Document > cursor = this . offeringsCollection . find ( query ) ; return Offering . fromDB ( cursor . first ( ) ) ; } | Get an offering | 66 | 3 |
139,988 | public String addOffering ( Offering offering ) { this . offeringsCollection . insertOne ( offering . toDBObject ( ) ) ; this . offeringNames . add ( offering . getName ( ) ) ; return offering . getName ( ) ; } | Add a new offering in the repository | 52 | 7 |
139,989 | public boolean removeOffering ( String offeringName ) { if ( offeringName == null ) throw new NullPointerException ( "The parameter \"cloudOfferingId\" cannot be null." ) ; BasicDBObject query = new BasicDBObject ( "offering_name" , offeringName ) ; Document removedOffering = this . offeringsCollection . findOneAndDelete ( query ) ; return removedOffering != null ; } | Remove an offering | 87 | 3 |
139,990 | public void initializeOfferings ( ) { FindIterable < Document > offerings = this . offeringsCollection . find ( ) ; for ( Document d : offerings ) { offeringNames . add ( ( String ) d . get ( "offering_name" ) ) ; } } | Initialize the list of offerings known by the discoverer | 57 | 12 |
139,991 | public void generateSingleOffering ( String offeringNodeTemplates ) { this . removeOffering ( "0" ) ; Offering singleOffering = new Offering ( "all" ) ; singleOffering . toscaString = offeringNodeTemplates ; this . addOffering ( singleOffering ) ; } | Generates a single offering file containing all node templates fetched | 66 | 12 |
139,992 | public JClass getSuperClass ( ) { lazyLoad ( ) ; if ( _superClass == null ) return null ; else return getClassLoader ( ) . forName ( _superClass . replace ( ' ' , ' ' ) ) ; } | Gets the super class name . | 51 | 7 |
139,993 | public void addInterface ( String className ) { _interfaces . add ( className ) ; if ( _isWrite ) getConstantPool ( ) . addClass ( className ) ; } | Adds an interface . | 41 | 4 |
139,994 | public JClass [ ] getInterfaces ( ) { lazyLoad ( ) ; JClass [ ] interfaces = new JClass [ _interfaces . size ( ) ] ; for ( int i = 0 ; i < _interfaces . size ( ) ; i ++ ) { String name = _interfaces . get ( i ) ; name = name . replace ( ' ' , ' ' ) ; interfaces [ i ] = getClassLoader ( ) . forName ( name ) ; } return interfaces ; } | Gets the interfaces . | 103 | 5 |
139,995 | public JavaField getField ( String name ) { ArrayList < JavaField > fieldList = getFieldList ( ) ; for ( int i = 0 ; i < fieldList . size ( ) ; i ++ ) { JavaField field = fieldList . get ( i ) ; if ( field . getName ( ) . equals ( name ) ) return field ; } return null ; } | Returns a fields . | 79 | 4 |
139,996 | public JavaMethod getMethod ( String name ) { ArrayList < JavaMethod > methodList = getMethodList ( ) ; for ( int i = 0 ; i < methodList . size ( ) ; i ++ ) { JavaMethod method = methodList . get ( i ) ; if ( method . getName ( ) . equals ( name ) ) return method ; } return null ; } | Returns a method . | 79 | 4 |
139,997 | public JavaMethod findMethod ( String name , String descriptor ) { ArrayList < JavaMethod > methodList = getMethodList ( ) ; for ( int i = 0 ; i < methodList . size ( ) ; i ++ ) { JavaMethod method = methodList . get ( i ) ; if ( method . getName ( ) . equals ( name ) && method . getDescriptor ( ) . equals ( descriptor ) ) return method ; } return null ; } | Finds a method . | 96 | 5 |
139,998 | public JField [ ] getDeclaredFields ( ) { ArrayList < JavaField > fieldList = getFieldList ( ) ; JField [ ] fields = new JField [ fieldList . size ( ) ] ; fieldList . toArray ( fields ) ; return fields ; } | Returns the array of declared fields . | 59 | 7 |
139,999 | public JField [ ] getFields ( ) { ArrayList < JField > fieldList = new ArrayList < JField > ( ) ; getFields ( fieldList ) ; JField [ ] fields = new JField [ fieldList . size ( ) ] ; fieldList . toArray ( fields ) ; return fields ; } | Returns the array of fields . | 69 | 6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.