idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
139,500 | @ Override protected void flush ( Buffer data , boolean isEnd ) { if ( isClosed ( ) ) { throw new IllegalStateException ( ) ; } _request . outProxy ( ) . write ( _request , data , isEnd ) ; /* boolean isHeader = ! isCommitted(); toCommitted(); MessageResponseHttp2 message; TempBuffer next = head; TempBuffer tBuf = null; if (head != null) { int headLength = head.length(); if (headLength > 0) { tBuf = head; next = TempBuffer.allocate(); } } message = new MessageResponseHttp2(_request, tBuf, isHeader, isEnd); _request.getOutHttp().offer(message); return next; */ } | Writes data to the output . If the headers have not been written they should be written . | 161 | 19 |
139,501 | private Client getClient ( ) { Client client = hostMap . get ( basePath ) ; if ( client != null ) return client ; final ClientConfig clientConfig = new ClientConfig ( ) ; clientConfig . register ( MultiPartFeature . class ) ; if ( debug ) { clientConfig . register ( LoggingFilter . class ) ; } client = ClientBuilder . newClient ( clientConfig ) ; hostMap . putIfAbsent ( basePath , client ) ; return hostMap . get ( basePath ) ; //be sure to use the same in case of a race condition. } | Get an existing client or create a new client to handle HTTP request . | 121 | 14 |
139,502 | @ Override public void onAccept ( ) { if ( _request != null ) { System . out . println ( "OLD_REQUEST: " + _request ) ; } _sequenceClose . set ( - 1 ) ; /* _request = protocol().newRequest(this); _request.onAccept(); */ } | Called first when the connection is first accepted . | 66 | 10 |
139,503 | @ Override public StateConnection service ( ) throws IOException { try { ConnectionProtocol request = requestOrCreate ( ) ; if ( request == null ) { log . warning ( "Unexpected empty request: " + this ) ; return StateConnection . CLOSE ; } //_requestHttp.parseInvocation(); /* if (requestFacade == null) { _requestHttp.startRequest(); requestFacade = _requestHttp.getRequestFacade(); //return NextState.CLOSE; } */ StateConnection next = request . service ( ) ; if ( next != StateConnection . CLOSE ) { return next ; } else { return onCloseRead ( ) ; } } catch ( OutOfMemoryError e ) { String msg = "Out of memory in RequestProtocolHttp" ; ShutdownSystem . shutdownOutOfMemory ( msg ) ; log . log ( Level . WARNING , e . toString ( ) , e ) ; } catch ( Throwable e ) { e . printStackTrace ( ) ; log . log ( Level . WARNING , e . toString ( ) , e ) ; } return StateConnection . CLOSE ; } | Service a HTTP request . | 236 | 5 |
139,504 | @ Override public StateConnection onCloseRead ( ) { ConnectionProtocol request = request ( ) ; if ( request != null ) { request . onCloseRead ( ) ; } _sequenceClose . set ( _sequenceRead . get ( ) ) ; if ( _sequenceFlush . get ( ) < _sequenceClose . get ( ) ) { _isClosePending . set ( true ) ; if ( _sequenceFlush . get ( ) < _sequenceClose . get ( ) ) { return StateConnection . CLOSE_READ_S ; } else { _isClosePending . set ( false ) ; return StateConnection . CLOSE ; } } else { return StateConnection . CLOSE ; } } | Called by reader thread on reader end of file . | 148 | 11 |
139,505 | public boolean isWriteComplete ( ) { long seqClose = _sequenceClose . get ( ) ; long seqWrite = _sequenceWrite . get ( ) ; return seqClose > 0 && seqClose <= seqWrite ; } | The last write has completed after the read . | 45 | 9 |
139,506 | @ Deprecated public Map < String , HashSet < String > > match ( Map < String , IndexedNodeType > aamModules , Map < String , NodeTemplate > offerings ) { Map < String , HashSet < String > > mathedOfferings = new HashMap <> ( ) ; for ( String moduleName : aamModules . keySet ( ) ) { IndexedNodeType module = aamModules . get ( moduleName ) ; mathedOfferings . put ( moduleName , new HashSet < String > ( ) ) ; for ( String offerName : offerings . keySet ( ) ) { NodeTemplate offer = offerings . get ( offerName ) ; if ( match ( module , offer ) ) { mathedOfferings . get ( moduleName ) . add ( offerName ) ; } } } return mathedOfferings ; } | Matches for each module the technical requirement with the available offerings . | 184 | 13 |
139,507 | public static String encodeURL ( String uri ) { CharBuffer cb = CharBuffer . allocate ( ) ; for ( int i = 0 ; i < uri . length ( ) ; i ++ ) { char ch = uri . charAt ( i ) ; switch ( ch ) { case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : cb . append ( ' ' ) ; cb . append ( encodeHex ( ch >> 4 ) ) ; cb . append ( encodeHex ( ch ) ) ; break ; default : cb . append ( ch ) ; } } return cb . close ( ) ; } | Encode the url with % encoding . | 144 | 8 |
139,508 | public long extractAlarm ( long now , boolean isTest ) { long lastTime = _now . getAndSet ( now ) ; long nextTime = _nextAlarmTime . get ( ) ; if ( now < nextTime ) { return nextTime ; } _nextAlarmTime . set ( now + CLOCK_NEXT ) ; int delta ; delta = ( int ) ( now - lastTime ) / CLOCK_INTERVAL ; delta = Math . min ( delta , CLOCK_PERIOD ) ; Alarm alarm ; int bucket = getBucket ( lastTime ) ; for ( int i = 0 ; i <= delta ; i ++ ) { // long time = lastTime + i; while ( ( alarm = extractNextAlarm ( bucket , now , isTest ) ) != null ) { dispatch ( alarm , now , isTest ) ; } bucket = ( bucket + 1 ) % CLOCK_PERIOD ; } while ( ( alarm = extractNextCurrentAlarm ( ) ) != null ) { dispatch ( alarm , now , isTest ) ; } long next = updateNextAlarmTime ( now ) ; _lastTime = now ; return next ; } | Returns the next alarm ready to run | 247 | 7 |
139,509 | public static int createIpAddress ( byte [ ] address , char [ ] buffer ) { if ( isIpv4 ( address ) ) { return createIpv4Address ( address , 0 , buffer , 0 ) ; } int offset = 0 ; boolean isZeroCompress = false ; boolean isInZeroCompress = false ; buffer [ offset ++ ] = ' ' ; for ( int i = 0 ; i < 16 ; i += 2 ) { int value = ( address [ i ] & 0xff ) * 256 + ( address [ i + 1 ] & 0xff ) ; if ( value == 0 && i != 14 ) { if ( isInZeroCompress ) continue ; else if ( ! isZeroCompress ) { isZeroCompress = true ; isInZeroCompress = true ; continue ; } } if ( isInZeroCompress ) { isInZeroCompress = false ; buffer [ offset ++ ] = ' ' ; buffer [ offset ++ ] = ' ' ; } else if ( i != 0 ) { buffer [ offset ++ ] = ' ' ; } if ( value == 0 ) { buffer [ offset ++ ] = ' ' ; continue ; } offset = writeHexDigit ( buffer , offset , value >> 12 ) ; offset = writeHexDigit ( buffer , offset , value >> 8 ) ; offset = writeHexDigit ( buffer , offset , value >> 4 ) ; offset = writeHexDigit ( buffer , offset , value ) ; } buffer [ offset ++ ] = ' ' ; return offset ; } | Convert a system ip address to an actual address . | 326 | 11 |
139,510 | public void setAttribute ( String name , Object value ) { if ( _stream != null ) { _stream . setAttribute ( name , value ) ; } } | Sets a header for the request . | 33 | 8 |
139,511 | public UpdatePodBuilder name ( String name ) { Objects . requireNonNull ( name ) ; if ( name . indexOf ( ' ' ) >= 0 ) { throw new IllegalArgumentException ( name ) ; } _name = name ; return this ; } | name is the name of the pod | 53 | 7 |
139,512 | public UpdatePod build ( ) { if ( getServers ( ) == null ) { int count = Math . max ( _primaryServerCount , _depth ) ; if ( _type == PodType . off ) { count = 0 ; } _servers = buildServers ( count ) ; } Objects . requireNonNull ( getServers ( ) ) ; /* if (getServers().length < _primaryServerCount) { throw new IllegalStateException(); } */ return new UpdatePod ( this ) ; } | Builds the configured pod . | 107 | 6 |
139,513 | public long getLength ( ) { StreamSource indirectSource = _indirectSource ; if ( indirectSource != null ) { return indirectSource . getLength ( ) ; } TempOutputStream out = _out ; if ( out != null ) { return out . getLength ( ) ; } else { return - 1 ; } } | Returns the length of the stream if known . | 67 | 9 |
139,514 | public void freeUseCount ( ) { if ( _indirectSource != null ) { _indirectSource . freeUseCount ( ) ; } else if ( _useCount != null ) { if ( _useCount . decrementAndGet ( ) < 0 ) { closeSelf ( ) ; } } } | Frees a use - counter so getInputStream can be called multiple times . | 64 | 16 |
139,515 | public InputStream openInputStream ( ) throws IOException { StreamSource indirectSource = _indirectSource ; if ( indirectSource != null ) { return indirectSource . openInputStream ( ) ; } TempOutputStream out = _out ; if ( out != null ) { return out . openInputStreamNoFree ( ) ; } // System.err.println("OpenInputStream: fail to open input stream for " + this); throw new IOException ( L . l ( "{0}: no input stream is available" , this ) ) ; } | Returns an input stream without freeing the results | 113 | 8 |
139,516 | public final < T > SerializerJson < T > serializer ( Class < T > cl ) { return ( SerializerJson ) _serMap . get ( cl ) ; } | The serializer for the given class . | 39 | 8 |
139,517 | public final < T > SerializerJson < T > serializer ( Type type ) { SerializerJson < T > ser = ( SerializerJson < T > ) _serTypeMap . get ( type ) ; if ( ser == null ) { TypeRef typeRef = TypeRef . of ( type ) ; Class < T > rawClass = ( Class < T > ) typeRef . rawClass ( ) ; ser = serializer ( rawClass ) . withType ( typeRef , this ) ; _serTypeMap . putIfAbsent ( type , ser ) ; ser = ( SerializerJson < T > ) _serTypeMap . get ( type ) ; } return ser ; } | The serializer for the given type . | 147 | 8 |
139,518 | private JarDepend getJarDepend ( ) { if ( _depend == null || _depend . isModified ( ) ) _depend = new JarDepend ( new Depend ( getBacking ( ) ) ) ; return _depend ; } | Returns the dependency . | 51 | 4 |
139,519 | public Certificate [ ] getCertificates ( String path ) { if ( ! isSigned ( ) ) return null ; if ( path . length ( ) > 0 && path . charAt ( 0 ) == ' ' ) path = path . substring ( 1 ) ; try { if ( ! getBacking ( ) . canRead ( ) ) return null ; JarFile jarFile = getJarFile ( ) ; JarEntry entry ; InputStream is = null ; try { entry = jarFile . getJarEntry ( path ) ; if ( entry != null ) { is = jarFile . getInputStream ( entry ) ; while ( is . skip ( 65536 ) > 0 ) { } is . close ( ) ; return entry . getCertificates ( ) ; } } finally { closeJarFile ( jarFile ) ; } } catch ( IOException e ) { log . log ( Level . FINE , e . toString ( ) , e ) ; return null ; } return null ; } | Returns any certificates . | 207 | 4 |
139,520 | public long getLastModified ( String path ) { try { // this entry time can cause problems ... ZipEntry entry = getZipEntry ( path ) ; return entry != null ? entry . getTime ( ) : - 1 ; } catch ( IOException e ) { log . log ( Level . FINE , e . toString ( ) , e ) ; } return - 1 ; } | Returns the last - modified time of the entry in the jar file . | 80 | 14 |
139,521 | public long getLength ( String path ) { try { ZipEntry entry = getZipEntry ( path ) ; long length = entry != null ? entry . getSize ( ) : - 1 ; return length ; } catch ( IOException e ) { log . log ( Level . FINE , e . toString ( ) , e ) ; return - 1 ; } } | Returns the length of the entry in the jar file . | 75 | 11 |
139,522 | public boolean canRead ( String path ) { try { ZipEntry entry = getZipEntry ( path ) ; return entry != null && ! entry . isDirectory ( ) ; } catch ( IOException e ) { log . log ( Level . FINE , e . toString ( ) , e ) ; return false ; } } | Readable if the jar is readable and the path refers to a file . | 67 | 15 |
139,523 | public void clearCache ( ) { ZipFile zipFile = _zipFileRef . getAndSet ( null ) ; if ( zipFile != null ) try { zipFile . close ( ) ; } catch ( Exception e ) { } } | Clears any cached JarFile . | 49 | 7 |
139,524 | public ClassLoader buildClassLoader ( ClassLoader serviceLoader ) { synchronized ( _loaderMap ) { SoftReference < ClassLoader > extLoaderRef = _loaderMap . get ( serviceLoader ) ; if ( extLoaderRef != null ) { ClassLoader extLoader = extLoaderRef . get ( ) ; if ( extLoader != null ) { return extLoader ; } } } String parentId = EnvLoader . getEnvironmentName ( serviceLoader ) ; String id = _id + "!" + parentId ; //DynamicClassLoader extLoader = new PodExtClassLoader(serviceLoader, id); DynamicClassLoader extLoader = null ; /* LibraryLoader libLoader = new LibraryLoader(extLoader, getRootDirectory().lookup("lib")); libLoader.init(); CompilingLoader compLoader = new CompilingLoader(extLoader, getRootDirectory().lookup("classes")); compLoader.init(); synchronized (_loaderMap) { SoftReference<ClassLoader> extLoaderRef = _loaderMap.get(serviceLoader); if (extLoaderRef != null) { ClassLoader extLoaderOld = extLoaderRef.get(); if (extLoaderOld != null) { return extLoaderOld; } } _loaderMap.put(serviceLoader, new SoftReference<>(extLoader)); } */ return extLoader ; } | Builds a combined class - loader with the target service loader as a parent and this calling pod loader as a child . | 274 | 24 |
139,525 | @ Override public ServerHeartbeat getServer ( String serverId ) { ServerHeartbeat server = _serverMap . get ( serverId ) ; return server ; } | Returns the server with the given canonical id . | 34 | 9 |
139,526 | @ Override public ServerBartender findServerByName ( String name ) { for ( ClusterHeartbeat cluster : _clusterMap . values ( ) ) { ServerBartender server = cluster . findServerByName ( name ) ; if ( server != null ) { return server ; } } return null ; } | Returns the server with the given display name . | 66 | 9 |
139,527 | ClusterHeartbeat createCluster ( String clusterName ) { ClusterHeartbeat cluster = _clusterMap . get ( clusterName ) ; if ( cluster == null ) { cluster = new ClusterHeartbeat ( clusterName , this ) ; _clusterMap . putIfAbsent ( clusterName , cluster ) ; cluster = _clusterMap . get ( clusterName ) ; } return cluster ; } | Returns the cluster with the given name creating it if necessary . | 83 | 12 |
139,528 | @ Override public int read ( byte [ ] buffer , int offset , int length ) throws IOException { int sublen = getDelegate ( ) . read ( buffer , offset , length ) ; if ( sublen > 0 ) { logStream ( ) . write ( buffer , offset , sublen ) ; } return sublen ; } | Reads the next chunk from the stream . | 70 | 9 |
139,529 | @ Override public int readTimeout ( byte [ ] buffer , int offset , int length , long timeout ) throws IOException { int sublen = getDelegate ( ) . readTimeout ( buffer , offset , length , timeout ) ; if ( sublen > 0 ) { logStream ( ) . write ( buffer , offset , sublen ) ; } return sublen ; } | Reads the next chunk from the stream in non - blocking mode . | 77 | 14 |
139,530 | public static String ObjectToXml ( Object object ) throws JAXBException { JAXBContext jaxbContext = JAXBContext . newInstance ( object . getClass ( ) ) ; Marshaller marshaller = jaxbContext . createMarshaller ( ) ; StringWriter sw = new StringWriter ( ) ; marshaller . marshal ( object , sw ) ; return sw . toString ( ) ; } | Transforms an annotated Object to a XML string using javax . xml . bind . Marshaller | 93 | 21 |
139,531 | public void setEncoding ( String encoding ) throws UnsupportedEncodingException { if ( encoding != null ) { _readEncoding = Encoding . getReadEncoding ( this , encoding ) ; _readEncodingName = Encoding . getMimeName ( encoding ) ; } else { _readEncoding = null ; _readEncodingName = null ; } } | Sets the encoding for the converter . | 78 | 8 |
139,532 | public void addByte ( int b ) throws IOException { int nextHead = ( _byteHead + 1 ) % _byteBuffer . length ; while ( nextHead == _byteTail ) { int ch = readChar ( ) ; if ( ch < 0 ) { break ; } outputChar ( ch ) ; } _byteBuffer [ _byteHead ] = ( byte ) b ; _byteHead = nextHead ; } | Adds the next byte . | 88 | 5 |
139,533 | public void addChar ( char nextCh ) throws IOException { int ch ; while ( ( ch = readChar ( ) ) >= 0 ) { outputChar ( ( char ) ch ) ; } outputChar ( nextCh ) ; } | Adds the next character . | 48 | 5 |
139,534 | private int readChar ( ) throws IOException { Reader readEncoding = _readEncoding ; if ( readEncoding == null ) return read ( ) ; else { if ( readEncoding . read ( _charBuffer , 0 , 1 ) == 1 ) { return _charBuffer [ 0 ] ; } else { return - 1 ; } } } | Reads the next converted character . | 73 | 7 |
139,535 | public int read ( ) throws IOException { if ( _byteHead == _byteTail ) { return - 1 ; } int b = _byteBuffer [ _byteTail ] & 0xff ; _byteTail = ( _byteTail + 1 ) % _byteBuffer . length ; return b ; } | For internal use only . Reads the next byte from the byte buffer . | 66 | 15 |
139,536 | public void setNameAndType ( String name , String type ) { _nameAndTypeIndex = getConstantPool ( ) . addNameAndType ( name , type ) . getIndex ( ) ; } | Sets the method name and type | 43 | 7 |
139,537 | public void putWithVersion ( RowCursor cursor , Result < Boolean > cont ) { _tableService . put ( cursor , PutType . PUT , cont ) ; } | Put using the version in the cursor instead of clearing it . | 36 | 12 |
139,538 | void format ( StringBuilder sb , Temporal localDate ) { //Instant localDate = ClockCurrent.GMT.instant(); int len = _timestamp . length ; for ( int j = 0 ; j < len ; j ++ ) { _timestamp [ j ] . format ( sb , localDate ) ; } } | Formats the timestamp | 69 | 4 |
139,539 | @ InService ( TableWriterService . class ) public void writePage ( Page page , SegmentStream sOut , long oldSequence , int saveLength , int saveTail , int sequenceWrite , Result < Integer > result ) { try { sOut . writePage ( this , page , saveLength , saveTail , sequenceWrite , result ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } | Writes a page to the current segment | 92 | 8 |
139,540 | @ InService ( TableWriterService . class ) public void writeBlobPage ( PageBlob page , int saveSequence , Result < Integer > result ) { SegmentStream sOut = getBlobStream ( ) ; int saveLength = 0 ; int saveTail = 0 ; if ( _blobSizeMax < page . getLength ( ) ) { _blobSizeMax = page . getLength ( ) ; calculateSegmentSize ( ) ; } sOut . writePage ( this , page , saveLength , saveTail , saveSequence , result ) ; _isBlobDirty = true ; } | Writes a blob page to the current output segment . | 131 | 11 |
139,541 | public OutSegment openWriter ( ) { if ( isGcRequired ( ) ) { // _gcSequence = _seqGen.get(); _table . getGcService ( ) . gc ( _seqGen . get ( ) ) ; _seqSinceGcCount = 0 ; } _seqSinceGcCount ++ ; long sequence = _seqGen . get ( ) ; return openWriterSeq ( sequence ) ; } | Opens a new segment writer . The segment s sequence id will be the next sequence number . | 92 | 19 |
139,542 | private void calculateSegmentSize ( ) { DatabaseKelp db = _table . database ( ) ; _segmentSizeNew = calculateSegmentSize ( db . getSegmentSizeFactorNew ( ) , _segmentSizeNew ) ; _segmentSizeGc = calculateSegmentSize ( db . getSegmentSizeFactorGc ( ) , _segmentSizeGc ) ; } | Calculates the dynamic segment size based on the current table size . | 84 | 14 |
139,543 | private int calculateSegmentSize ( int factor , int segmentSizeOld ) { DatabaseKelp db = _table . database ( ) ; long segmentFactor = _tableLength / db . getSegmentSizeMin ( ) ; long segmentFactorNew = segmentFactor / factor ; // segment size is (tableSize / factor), restricted to a power of 4 // over the min segment size. if ( segmentFactorNew > 0 ) { int bit = 63 - Long . numberOfLeadingZeros ( segmentFactorNew ) ; bit &= ~ 0x1 ; long segmentFactorPower = ( 1 << bit ) ; if ( segmentFactorPower < segmentFactorNew ) { segmentFactorNew = 4 * segmentFactorPower ; } } long segmentSizeNew = segmentFactorNew * db . getSegmentSizeMin ( ) ; segmentSizeNew = Math . max ( db . getSegmentSizeMin ( ) , segmentSizeNew ) ; long segmentSizeBlob = _blobSizeMax * 4 ; while ( segmentSizeNew < segmentSizeBlob ) { segmentSizeNew *= 4 ; } segmentSizeNew = Math . min ( db . getSegmentSizeMax ( ) , segmentSizeNew ) ; return ( int ) Math . max ( segmentSizeNew , segmentSizeOld ) ; } | Calculate the dynamic segment size . | 267 | 8 |
139,544 | public void fsync ( Result < Boolean > result ) throws IOException { SegmentStream nodeStream = _nodeStream ; // FlushCompletion cont = new FlushCompletion(result, nodeStream, blobStream); if ( nodeStream != null ) { nodeStream . fsync ( result ) ; } else { result . ok ( true ) ; } } | sync the output stream with the filesystem when possible . | 75 | 10 |
139,545 | @ AfterBatch public void afterDeliver ( ) { SegmentStream nodeStream = _nodeStream ; if ( nodeStream != null ) { if ( _isBlobDirty ) { _isBlobDirty = false ; // nodeStream.flush(null); nodeStream . fsync ( Result . ignore ( ) ) ; } else { nodeStream . flush ( Result . ignore ( ) ) ; } } /* if (blobWriter != null) { try { blobWriter.flushSegment(); } catch (IOException e) { e.printStackTrace(); } } */ } | Flushes the stream after a batch of writes . | 125 | 10 |
139,546 | public void close ( Result < Boolean > result ) { _lifecycle . toDestroy ( ) ; SegmentStream nodeStream = _nodeStream ; _nodeStream = null ; if ( nodeStream != null ) { nodeStream . closeFsync ( result . then ( v -> closeImpl ( ) ) ) ; } else { result . ok ( true ) ; } } | Closes the store . | 76 | 5 |
139,547 | @ InService ( SegmentServiceImpl . class ) public Page writePage ( Page page , long oldSequence , int saveLength , int saveTail , int saveSequence , Result < Integer > result ) { if ( isClosed ( ) ) { return null ; } // Type type = page.getType(); int pid = page . getId ( ) ; int nextPid = page . getNextId ( ) ; WriteStream out = out ( ) ; int head = ( int ) out . position ( ) ; try { int available = getAvailable ( ) ; if ( available < head + page . size ( ) ) { return null ; } Page newPage = page . writeCheckpoint ( _table , this , oldSequence , saveLength , saveTail , saveSequence ) ; if ( newPage == null ) { return null ; } newPage . setSequence ( getSequence ( ) ) ; out = out ( ) ; int tail = ( int ) out . position ( ) ; if ( addIndex ( out , page , newPage , saveSequence , newPage . getLastWriteType ( ) , pid , nextPid , head , tail - head , result ) ) { return newPage ; } else { return null ; } } catch ( Exception e ) { e . printStackTrace ( ) ; return null ; } } | Writes the page to the segment . | 286 | 8 |
139,548 | public void flushData ( ) { if ( isClosed ( ) ) { if ( _pendingFlushEntries . size ( ) > 0 ) { System . out . println ( "PENDING_FLUSH" ) ; } return ; } WriteStream out = _out ; if ( out != null ) { try { out . flush ( ) ; } catch ( Exception e ) { log . log ( Level . FINER , e . toString ( ) , e ) ; } } // flush entries to allow for stubs to replace buffers completePendingFlush ( ) ; } | Flushes the buffered data to the segment . | 123 | 10 |
139,549 | @ Override public void write ( byte [ ] buffer , int offset , int length , boolean isEnd ) throws IOException { int position = _position ; if ( length < 0 ) { throw new IllegalArgumentException ( ) ; } if ( _indexAddress < position + length ) { throw new IllegalArgumentException ( L . l ( "Segment write overflow pos=0x{0} len=0x{1} entry-head=0x{2} seg-len=0x{3}. {4}" , Long . toHexString ( _position ) , Long . toHexString ( length ) , Long . toHexString ( _indexAddress ) , Long . toHexString ( _segment . length ( ) ) , _segment ) ) ; } //try (StoreWrite sOut = _readWrite.openWrite(_segment.getAddress(), // _segment.getLength())) { _sOut . write ( _segment . getAddress ( ) + position , buffer , offset , length ) ; _position = position + length ; _isDirty = true ; } | Writes to the file from the WriteStream flush . | 239 | 11 |
139,550 | private void completePendingFlush ( ) { int size = _pendingFlushEntries . size ( ) ; if ( size == 0 ) { return ; } // ArrayList<TableService.PageFlush> pageList = new ArrayList<>(); for ( int i = 0 ; i < size ; i ++ ) { PendingEntry entry = _pendingFlushEntries . get ( i ) ; entry . afterFlush ( ) ; _pendingFsyncEntries . add ( entry ) ; } // _tableService.afterDataFlush(pageList); _pendingFlushEntries . clear ( ) ; } | Notifies the calling service after the entry is written to the mmap . | 136 | 15 |
139,551 | private void fsyncImpl ( Result < Boolean > result , FsyncType fsyncType ) { try { flushData ( ) ; ArrayList < SegmentFsyncCallback > fsyncListeners = new ArrayList <> ( _fsyncListeners ) ; _fsyncListeners . clear ( ) ; Result < Boolean > resultNext = result . then ( ( v , r ) -> afterDataFsync ( r , _position , fsyncType , fsyncListeners ) ) ; if ( _isDirty || ! fsyncType . isSchedule ( ) ) { _isDirty = false ; try ( OutStore sOut = _readWrite . openWrite ( _segment . extent ( ) ) ) { if ( fsyncType . isSchedule ( ) ) { sOut . fsyncSchedule ( resultNext ) ; } else { sOut . fsync ( resultNext ) ; } } } else { resultNext . ok ( true ) ; } } catch ( Throwable e ) { e . printStackTrace ( ) ; result . fail ( e ) ; } } | Syncs the segment to the disk . After the segment s data is synced the headers can be written . A second sync is needed to complete the header writes . | 230 | 33 |
139,552 | private void afterDataFsync ( Result < Boolean > result , int position , FsyncType fsyncType , ArrayList < SegmentFsyncCallback > listeners ) { try { completeIndex ( position ) ; Result < Boolean > cont = result . then ( ( v , r ) -> afterIndexFsync ( r , fsyncType , listeners ) ) ; if ( fsyncType . isSchedule ( ) ) { _sOut . fsyncSchedule ( cont ) ; } else { _sOut . fsync ( cont ) ; } } catch ( Throwable e ) { result . fail ( e ) ; } } | Callback after the page data has been fynced so the index can be written . | 130 | 17 |
139,553 | private void afterIndexFsync ( Result < Boolean > result , FsyncType fsyncType , ArrayList < SegmentFsyncCallback > fsyncListeners ) { try { // completePendingEntries(_position); if ( fsyncType . isClose ( ) ) { _isClosed = true ; _segment . finishWriting ( ) ; if ( _pendingFlushEntries . size ( ) > 0 || _pendingFsyncEntries . size ( ) > 0 ) { System . out . println ( "BROKEN_PEND: flush=" + _pendingFlushEntries . size ( ) + " fsync=" + _pendingFsyncEntries . size ( ) + " " + _pendingFlushEntries ) ; } _readWrite . afterSequenceClose ( _segment . getSequence ( ) ) ; } for ( SegmentFsyncCallback listener : _fsyncListeners ) { listener . onFsync ( ) ; } result . ok ( true ) ; } catch ( Throwable exn ) { result . fail ( exn ) ; } } | Callback after the index has been flushed . | 236 | 8 |
139,554 | private void writeIndex ( int entryAddress , byte [ ] entryBuffer , int offset , int length ) { long address = _segment . getAddress ( ) + entryAddress ; if ( _segment . length ( ) < entryAddress + length ) { throw new IllegalStateException ( L . l ( "offset=0x{0} length={1}" , entryAddress , length ) ) ; } //try (StoreWrite os = _readWrite.openWrite(address, BLOCK_SIZE)) { _sOut . write ( address , entryBuffer , offset , length ) ; _isDirty = true ; // } } | Write the current header to the output . | 132 | 8 |
139,555 | private static Constructor < ? > createImpl ( Class < ? > cl , ClassLoader loader ) { /** if (! Modifier.isAbstract(cl.getModifiers())) { throw new IllegalArgumentException(); } */ ClassGeneratorVault < ? > generator = new ClassGeneratorVault <> ( cl , loader ) ; Class < ? > proxyClass = generator . generate ( ) ; return proxyClass . getConstructors ( ) [ 0 ] ; } | Must return Constructor not MethodHandle because MethodHandles cache the type in the permgen . | 98 | 19 |
139,556 | private void introspectMethods ( JavaClass jClass ) { for ( Method method : getMethods ( ) ) { Class < ? > [ ] paramTypes = method . getParameterTypes ( ) ; int paramLen = paramTypes . length ; if ( ! Modifier . isAbstract ( method . getModifiers ( ) ) ) { continue ; } if ( Modifier . isStatic ( method . getModifiers ( ) ) ) { continue ; } if ( Modifier . isFinal ( method . getModifiers ( ) ) ) { continue ; } /* if (! Modifier.isPublic(method.getModifiers())) { throw new IllegalArgumentException("Method must be public {0}", method); } */ if ( method . getDeclaringClass ( ) . equals ( Object . class ) ) { continue ; } if ( method . getName ( ) . equals ( "toString" ) && paramLen == 0 ) { continue ; } if ( method . getName ( ) . equals ( "hashCode" ) && paramLen == 0 ) { continue ; } if ( method . getName ( ) . equals ( "equals" ) && paramLen == 1 && paramTypes [ 0 ] . equals ( Object . class ) ) { continue ; } // XXX: Need QA int ampResult = findAmpResult ( paramTypes , Result . class ) ; if ( isCreate ( method ) || isFind ( method ) ) { if ( ampResult < 0 ) { throw new IllegalStateException ( L . l ( "Result argument is required {0}" , method ) ) ; } if ( ! void . class . equals ( method . getReturnType ( ) ) ) { throw new IllegalArgumentException ( L . l ( "method must return void {0}" , method ) ) ; } } if ( paramLen > 0 && ampResult >= 0 ) { /* if (ampResult != paramTypes.length - 1) { throw new IllegalStateException(L.l("invalid Result position. Result must be the final argument.")); } */ createAmpResultMethod ( jClass , method , ampResult ) ; } else if ( ampResult < 0 ) { createAmpSendMethod ( jClass , method ) ; } else { throw new IllegalStateException ( method . toString ( ) ) ; } } } | Introspect the methods to find abstract methods . | 486 | 10 |
139,557 | public static DynamicClassLoader create ( PathImpl path ) { DynamicClassLoader loader = new DynamicClassLoader ( null ) ; CompilingLoader compilingLoader = new CompilingLoader ( loader , path ) ; compilingLoader . init ( ) ; loader . init ( ) ; return loader ; } | Create a class loader based on the compiling loader | 58 | 9 |
139,558 | public static DynamicClassLoader create ( ClassLoader parent , PathImpl classDir , PathImpl sourceDir , String args , String encoding ) { DynamicClassLoader loader = new DynamicClassLoader ( parent ) ; loader . addLoader ( new CompilingLoader ( loader , classDir , sourceDir , args , encoding ) ) ; loader . init ( ) ; return loader ; } | Creates a new compiling class loader | 75 | 7 |
139,559 | @ Override public void make ( ) { synchronized ( this ) { if ( CurrentTime . currentTime ( ) < _lastMakeTime + 2000 ) return ; try { makeImpl ( ) ; } catch ( Exception e ) { log . log ( Level . FINER , e . toString ( ) , e ) ; } _lastMakeTime = CurrentTime . currentTime ( ) ; } } | Compiles all changed files in the class directory . | 82 | 10 |
139,560 | private void findAllModifiedClasses ( String name , PathImpl sourceDir , PathImpl classDir , String sourcePath , ArrayList < String > sources ) throws IOException , ClassNotFoundException { String [ ] list ; try { list = sourceDir . list ( ) ; } catch ( IOException e ) { return ; } for ( int i = 0 ; list != null && i < list . length ; i ++ ) { if ( list [ i ] . startsWith ( "." ) ) continue ; if ( _excludedDirectories . contains ( list [ i ] ) ) continue ; PathImpl subSource = sourceDir . lookup ( list [ i ] ) ; if ( subSource . isDirectory ( ) ) { findAllModifiedClasses ( name + list [ i ] + "/" , subSource , classDir . lookup ( list [ i ] ) , sourcePath , sources ) ; } else if ( list [ i ] . endsWith ( _sourceExt ) ) { int tail = list [ i ] . length ( ) - _sourceExt . length ( ) ; String prefix = list [ i ] . substring ( 0 , tail ) ; PathImpl subClass = classDir . lookup ( prefix + ".class" ) ; if ( subClass . getLastModified ( ) < subSource . getLastModified ( ) ) { sources . add ( name + list [ i ] ) ; } } } if ( ! _requireSource ) return ; try { list = classDir . list ( ) ; } catch ( IOException e ) { return ; } for ( int i = 0 ; list != null && i < list . length ; i ++ ) { if ( list [ i ] . startsWith ( "." ) ) continue ; if ( _excludedDirectories . contains ( list [ i ] ) ) continue ; PathImpl subClass = classDir . lookup ( list [ i ] ) ; if ( list [ i ] . endsWith ( ".class" ) ) { String prefix = list [ i ] . substring ( 0 , list [ i ] . length ( ) - 6 ) ; PathImpl subSource = sourceDir . lookup ( prefix + _sourceExt ) ; if ( ! subSource . exists ( ) ) { String tail = subSource . getTail ( ) ; boolean doRemove = true ; if ( tail . indexOf ( ' ' ) > 0 ) { String subTail = tail . substring ( 0 , tail . indexOf ( ' ' ) ) + _sourceExt ; PathImpl subJava = subSource . getParent ( ) . lookup ( subTail ) ; if ( subJava . exists ( ) ) doRemove = false ; } if ( doRemove ) { log . finer ( L . l ( "removing obsolete class '{0}'." , subClass . getPath ( ) ) ) ; subClass . remove ( ) ; } } } } } | Returns the classes which need compilation . | 608 | 7 |
139,561 | @ Override protected ClassEntry getClassEntry ( String name , String pathName ) throws ClassNotFoundException { PathImpl classFile = _classDir . lookup ( pathName ) ; /* Path classDir = classFile.getParent(); if (! classDir.isDirectory()) return null; */ String javaName = name . replace ( ' ' , ' ' ) + _sourceExt ; PathImpl javaFile = _sourceDir . lookup ( javaName ) ; for ( int i = 0 ; i < INNER_CLASS_SEPARATORS . length ; i ++ ) { char sep = INNER_CLASS_SEPARATORS [ i ] ; if ( name . indexOf ( sep ) > 0 ) { String subName = name . substring ( 0 , name . indexOf ( sep ) ) ; String subJavaName = subName . replace ( ' ' , ' ' ) + _sourceExt ; PathImpl subJava = _sourceDir . lookup ( subJavaName ) ; if ( subJava . exists ( ) ) { javaFile = subJava ; } } } synchronized ( this ) { if ( _requireSource && ! javaFile . exists ( ) ) { boolean doRemove = true ; if ( doRemove ) { log . finer ( L . l ( "removing obsolete class `{0}'." , classFile . getPath ( ) ) ) ; try { classFile . remove ( ) ; } catch ( IOException e ) { log . log ( Level . WARNING , e . toString ( ) , e ) ; } return null ; } } if ( ! classFile . canRead ( ) && ! javaFile . canRead ( ) ) return null ; return new CompilingClassEntry ( this , getClassLoader ( ) , name , javaFile , classFile , getCodeSource ( classFile ) ) ; } } | Loads the specified class compiling if necessary . | 384 | 9 |
139,562 | boolean checkSource ( PathImpl sourceDir , String javaName ) { try { while ( javaName != null && ! javaName . equals ( "" ) ) { int p = javaName . indexOf ( ' ' ) ; String head ; if ( p >= 0 ) { head = javaName . substring ( 0 , p ) ; javaName = javaName . substring ( p + 1 ) ; } else { head = javaName ; javaName = null ; } String [ ] names = sourceDir . list ( ) ; int i ; for ( i = 0 ; i < names . length ; i ++ ) { if ( names [ i ] . equals ( head ) ) break ; } if ( i == names . length ) return false ; sourceDir = sourceDir . lookup ( head ) ; } } catch ( IOException e ) { log . log ( Level . FINE , e . toString ( ) , e ) ; return false ; } return true ; } | Checks that the case is okay for the source . | 202 | 11 |
139,563 | @ Override public PathImpl getPath ( String name ) { PathImpl path = _classDir . lookup ( name ) ; if ( path != null && path . exists ( ) ) return path ; path = _sourceDir . lookup ( name ) ; if ( path != null && path . exists ( ) ) return path ; return null ; } | Returns the path for the given name . | 71 | 8 |
139,564 | @ Override protected void buildClassPath ( ArrayList < String > pathList ) { if ( ! _classDir . getScheme ( ) . equals ( "file" ) ) return ; try { if ( ! _classDir . isDirectory ( ) && _sourceDir . isDirectory ( ) ) { try { _classDir . mkdirs ( ) ; } catch ( IOException e ) { } } if ( _classDir . isDirectory ( ) ) { String path = _classDir . getNativePath ( ) ; if ( ! pathList . contains ( path ) ) pathList . add ( path ) ; } if ( ! _classDir . equals ( _sourceDir ) ) { String path = _sourceDir . getNativePath ( ) ; if ( ! pathList . contains ( path ) ) pathList . add ( path ) ; } } catch ( java . security . AccessControlException e ) { log . log ( Level . WARNING , e . toString ( ) , e ) ; } } | Adds the classpath we re responsible for to the classpath | 212 | 12 |
139,565 | @ Override public ServiceRefAmp session ( String name ) { String address = "session:///" + name + "/" ; return sessionImpl ( address ) ; } | Find the session by its service name . | 35 | 8 |
139,566 | @ Override public < X > X session ( Class < X > type ) { String address = services ( ) . address ( type ) ; if ( address . startsWith ( "/" ) ) { address = "session://" + address ; } return sessionImpl ( address + "/" ) . as ( type ) ; } | Find the session by its service type . | 67 | 8 |
139,567 | private ServiceRefAmp sessionImpl ( String address ) { if ( ! address . startsWith ( "session:" ) || ! address . endsWith ( "/" ) ) { throw new IllegalArgumentException ( address ) ; } String sessionId = cookie ( "JSESSIONID" ) ; if ( sessionId == null ) { sessionId = generateSessionId ( ) ; cookie ( "JSESSIONID" , sessionId ) ; } return services ( ) . service ( address + sessionId ) ; } | Find or create a session cookie as the session id and find or create a session with the generated address . | 104 | 21 |
139,568 | @ Override public void upgrade ( Object protocol ) { Objects . requireNonNull ( protocol ) ; if ( protocol instanceof ServiceWebSocket ) { ServiceWebSocket < ? , ? > webSocket = ( ServiceWebSocket < ? , ? > ) protocol ; upgradeWebSocket ( webSocket ) ; } else { throw new IllegalArgumentException ( protocol . toString ( ) ) ; } } | Starts an upgrade of the HTTP request to a protocol on raw TCP . | 81 | 15 |
139,569 | public JMethod [ ] getMethods ( ) { Method [ ] methods = _class . getMethods ( ) ; JMethod [ ] jMethods = new JMethod [ methods . length ] ; for ( int i = 0 ; i < methods . length ; i ++ ) { jMethods [ i ] = new JMethodWrapper ( methods [ i ] , getClassLoader ( ) ) ; } return jMethods ; } | Returns the public methods . | 86 | 5 |
139,570 | public JMethod getMethod ( String name , JClass [ ] types ) { JClassLoader jClassLoader = getClassLoader ( ) ; return getMethod ( _class , name , types , jClassLoader ) ; } | Returns the matching methods . | 46 | 5 |
139,571 | public JMethod [ ] getConstructors ( ) { Constructor [ ] methods = _class . getConstructors ( ) ; JMethod [ ] jMethods = new JMethod [ methods . length ] ; for ( int i = 0 ; i < methods . length ; i ++ ) { jMethods [ i ] = new JConstructorWrapper ( methods [ i ] , getClassLoader ( ) ) ; } return jMethods ; } | Returns the public constructors . | 90 | 6 |
139,572 | @ Override public void scan ( InH3Amp in , PathH3Amp path , Object [ ] values ) { int ch = read ( ) ; switch ( ch ) { case 0xd0 : readDefinition ( in ) ; scan ( in , path , values ) ; return ; case 0xd1 : case 0xd2 : case 0xd3 : case 0xd4 : case 0xd5 : case 0xd6 : case 0xd7 : case 0xd8 : case 0xd9 : case 0xda : case 0xdb : case 0xdc : case 0xdd : case 0xde : case 0xdf : { int id = ch - 0xd0 ; in . serializer ( id ) . scan ( this , path , in , values ) ; return ; } case 0xe0 : case 0xe1 : case 0xe2 : case 0xe3 : case 0xe4 : case 0xe5 : case 0xe6 : case 0xe7 : case 0xe8 : case 0xe9 : case 0xea : case 0xeb : case 0xec : case 0xed : case 0xee : case 0xef : { int id = ( int ) readLong ( ch - 0xe0 , 4 ) ; in . serializer ( id ) . scan ( this , path , in , values ) ; return ; } default : throw error ( L . l ( "Unexpected opcode 0x{0} while scanning for {1}" , Integer . toHexString ( ch ) , path ) ) ; } } | Scan for a query . | 331 | 5 |
139,573 | @ Override public void setParent ( Logger parent ) { if ( parent . equals ( _parent ) ) return ; super . setParent ( parent ) ; if ( parent instanceof EnvironmentLogger ) { _parent = ( EnvironmentLogger ) parent ; _parent . addChild ( this ) ; } updateEffectiveLevel ( _systemClassLoader ) ; } | Sets the logger s parent . This should only be called by the LogManager code . | 74 | 18 |
139,574 | @ Override public Level getLevel ( ) { if ( _localLevel != null ) { Level level = _localLevel . get ( ) ; if ( level != null ) { return level ; } } return _systemLevel ; } | Returns the logger s assigned level . | 48 | 7 |
139,575 | @ Override public void setLevel ( Level level ) { ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; if ( loader == null ) { loader = _systemClassLoader ; } if ( loader != _systemClassLoader ) { if ( _localLevel == null ) _localLevel = new EnvironmentLocal < Level > ( ) ; _localLevel . set ( level ) ; if ( level != null ) { addLoader ( loader ) ; } } else { _systemLevel = level ; } updateEffectiveLevel ( loader ) ; } | Application API to set the level . | 117 | 7 |
139,576 | @ Override public Handler [ ] getHandlers ( ) { Handler [ ] handlers = _localHandlers . get ( ) ; if ( handlers != null ) return handlers ; else return EMPTY_HANDLERS ; } | Returns the handlers . | 47 | 4 |
139,577 | @ Override public void removeHandler ( Handler handler ) { synchronized ( this ) { ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; if ( loader == null ) { loader = _systemClassLoader ; } for ( int i = _loaders . size ( ) - 1 ; i >= 0 ; i -- ) { WeakReference < ClassLoader > ref = _loaders . get ( i ) ; ClassLoader refLoader = ref . get ( ) ; if ( refLoader == null ) { _loaders . remove ( i ) ; } if ( isParentLoader ( loader , refLoader ) ) { removeHandler ( handler , refLoader ) ; } } HandlerEntry ownHandlers = _ownHandlers . get ( ) ; if ( ownHandlers != null ) ownHandlers . removeHandler ( handler ) ; } } | Removes a handler . | 178 | 5 |
139,578 | @ Override public final boolean isLoggable ( Level level ) { if ( level == null ) return false ; int intValue = level . intValue ( ) ; if ( intValue < _finestEffectiveLevelValue ) return false ; else if ( ! _hasLocalEffectiveLevel ) { return true ; } else { Integer localValue = _localEffectiveLevel . get ( ) ; if ( localValue != null ) { int localIntValue = localValue . intValue ( ) ; if ( localIntValue == Level . OFF . intValue ( ) ) return false ; else return localIntValue <= intValue ; } else { if ( _systemEffectiveLevelValue == Level . OFF . intValue ( ) ) return false ; else return _systemEffectiveLevelValue <= intValue ; } } } | True if the level is loggable | 165 | 8 |
139,579 | @ Override public boolean getUseParentHandlers ( ) { Boolean value = _useParentHandlers . get ( ) ; if ( value != null ) return Boolean . TRUE . equals ( value ) ; else return true ; } | Returns the use - parent - handlers | 47 | 7 |
139,580 | @ Override public void log ( LogRecord record ) { if ( record == null ) return ; Level recordLevel = record . getLevel ( ) ; if ( ! isLoggable ( recordLevel ) ) return ; for ( Logger ptr = this ; ptr != null ; ptr = ptr . getParent ( ) ) { Handler handlers [ ] = ptr . getHandlers ( ) ; if ( handlers != null ) { for ( int i = 0 ; i < handlers . length ; i ++ ) { handlers [ i ] . publish ( record ) ; } } if ( ! ptr . getUseParentHandlers ( ) ) break ; } } | Logs the message . | 133 | 5 |
139,581 | private void addHandler ( Handler handler , ClassLoader loader ) { // handlers ordered by level ArrayList < Handler > handlers = new ArrayList < Handler > ( ) ; handlers . add ( handler ) ; for ( ClassLoader ptr = loader ; ptr != null ; ptr = ptr . getParent ( ) ) { Handler [ ] localHandlers = _localHandlers . getLevel ( ptr ) ; if ( localHandlers != null ) { for ( int i = 0 ; i < localHandlers . length ; i ++ ) { int p = handlers . indexOf ( localHandlers [ i ] ) ; if ( p < 0 ) { handlers . add ( localHandlers [ i ] ) ; } else { Handler oldHandler = handlers . get ( p ) ; if ( localHandlers [ i ] . getLevel ( ) . intValue ( ) < oldHandler . getLevel ( ) . intValue ( ) ) { handlers . set ( p , localHandlers [ i ] ) ; } } } } } Handler [ ] newHandlers = new Handler [ handlers . size ( ) ] ; handlers . toArray ( newHandlers ) ; if ( loader == _systemClassLoader ) loader = null ; _localHandlers . set ( newHandlers , loader ) ; } | Adds a new handler with a given classloader context . | 265 | 11 |
139,582 | private boolean isParentLoader ( ClassLoader parent , ClassLoader child ) { for ( ; child != null ; child = child . getParent ( ) ) { if ( child == parent ) return true ; } return false ; } | Returns true if parent is a parent classloader of child . | 46 | 12 |
139,583 | public boolean addCustomLogger ( Logger logger ) { if ( logger . getClass ( ) . getName ( ) . startsWith ( "java" ) ) return false ; Logger oldLogger = _localLoggers . get ( ) ; if ( oldLogger != null ) return false ; _localLoggers . set ( logger ) ; if ( _parent != null ) { logger . setParent ( _parent ) ; } return true ; } | Sets a custom logger if possible | 95 | 7 |
139,584 | private void addLoader ( ClassLoader loader ) { for ( int i = _loaders . size ( ) - 1 ; i >= 0 ; i -- ) { WeakReference < ClassLoader > ref = _loaders . get ( i ) ; ClassLoader refLoader = ref . get ( ) ; if ( refLoader == null ) _loaders . remove ( i ) ; if ( refLoader == loader ) return ; } _loaders . add ( new WeakReference < ClassLoader > ( loader ) ) ; EnvLoader . addClassLoaderListener ( this , loader ) ; } | Adds a class loader to the list of dependency loaders . | 120 | 12 |
139,585 | private synchronized void updateEffectiveLevel ( ClassLoader loader ) { if ( loader == null ) loader = _systemClassLoader ; int oldEffectiveLevel = getEffectiveLevel ( loader ) ; Level newEffectiveLevel = calculateEffectiveLevel ( loader ) ; /* if (loader == _systemClassLoader) { _finestEffectiveLevel = newEffectiveLevel; _finestEffectiveLevelValue = newEffectiveLevel.intValue(); super.setLevel(_finestEffectiveLevel); } */ if ( oldEffectiveLevel == newEffectiveLevel . intValue ( ) && loader != _systemClassLoader ) return ; _finestEffectiveLevel = newEffectiveLevel ; _hasLocalEffectiveLevel = false ; updateEffectiveLevelPart ( _systemClassLoader ) ; updateEffectiveLevelPart ( loader ) ; for ( int i = 0 ; i < _loaders . size ( ) ; i ++ ) { WeakReference < ClassLoader > loaderRef = _loaders . get ( i ) ; ClassLoader classLoader = loaderRef . get ( ) ; if ( classLoader != null ) updateEffectiveLevelPart ( classLoader ) ; } super . setLevel ( _finestEffectiveLevel ) ; _finestEffectiveLevelValue = _finestEffectiveLevel . intValue ( ) ; updateChildren ( ) ; } | Recalculate the dynamic assigned levels . | 261 | 9 |
139,586 | private Level getFinestLevel ( ) { Level level ; if ( _parent == null ) level = Level . INFO ; else if ( _parent . isLocalLevel ( ) ) level = selectFinestLevel ( _systemLevel , _parent . getFinestLevel ( ) ) ; else if ( _systemLevel != null ) level = _systemLevel ; else level = _parent . getFinestLevel ( ) ; if ( _localLevel == null ) return level ; for ( int i = _loaders . size ( ) - 1 ; i >= 0 ; i -- ) { WeakReference < ClassLoader > ref = _loaders . get ( i ) ; ClassLoader loader = ref . get ( ) ; if ( loader == null ) _loaders . remove ( i ) ; level = selectFinestLevel ( level , _localLevel . get ( loader ) ) ; } return level ; } | Returns the finest assigned level for any classloader environment . | 187 | 11 |
139,587 | private Level selectFinestLevel ( Level a , Level b ) { if ( a == null ) return b ; else if ( b == null ) return a ; else if ( b . intValue ( ) < a . intValue ( ) ) return b ; else return a ; } | Returns the finest of the two levels . | 58 | 8 |
139,588 | private Level getAssignedLevel ( ClassLoader loader ) { Level level = null ; if ( _localLevel != null ) { return _localLevel . get ( loader ) ; } return null ; } | Returns the most specific assigned level for the given classloader i . e . children override parents . | 41 | 19 |
139,589 | private synchronized void removeLoader ( ClassLoader loader ) { int i ; for ( i = _loaders . size ( ) - 1 ; i >= 0 ; i -- ) { WeakReference < ClassLoader > ref = _loaders . get ( i ) ; ClassLoader refLoader = ref . get ( ) ; if ( refLoader == null ) _loaders . remove ( i ) ; else if ( refLoader == loader ) _loaders . remove ( i ) ; } } | Removes the specified loader . | 99 | 6 |
139,590 | @ Override public void classLoaderDestroy ( DynamicClassLoader loader ) { removeLoader ( loader ) ; _localHandlers . remove ( loader ) ; HandlerEntry ownHandlers = _ownHandlers . getLevel ( loader ) ; if ( ownHandlers != null ) _ownHandlers . remove ( loader ) ; if ( ownHandlers != null ) ownHandlers . destroy ( ) ; if ( _localLevel != null ) _localLevel . remove ( loader ) ; updateEffectiveLevel ( _systemClassLoader ) ; } | Classloader destroy callback | 110 | 4 |
139,591 | public void init ( TempCharBuffer head ) { _top = head ; _head = head ; if ( head != null ) { _buffer = head . buffer ( ) ; _length = head . getLength ( ) ; } else _length = 0 ; _offset = 0 ; } | Initialize the reader . | 59 | 5 |
139,592 | public void close ( ) { if ( _isFree ) TempCharBuffer . freeAll ( _head ) ; _head = null ; _buffer = null ; _offset = 0 ; _length = 0 ; } | Closes the reader . | 44 | 5 |
139,593 | private void createValidation ( Class < ? > vaultClass , Class < ? > assetClass , Class < ? > idClass ) { for ( Method method : vaultClass . getMethods ( ) ) { if ( ! method . getName ( ) . startsWith ( "create" ) ) { continue ; } if ( ! Modifier . isAbstract ( method . getModifiers ( ) ) ) { continue ; } TypeRef resultRef = findResult ( method . getParameters ( ) ) ; if ( resultRef == null ) { continue ; } TypeRef typeRef = resultRef . to ( Result . class ) . param ( 0 ) ; Class < ? > typeClass = typeRef . rawClass ( ) ; // id return type if ( unbox ( idClass ) . equals ( unbox ( typeClass ) ) ) { continue ; } if ( void . class . equals ( unbox ( typeClass ) ) ) { continue ; } try { new ShimConverter <> ( assetClass , typeClass ) ; } catch ( Exception e ) { throw error ( e , "{0}.{1}: {2}" , vaultClass . getSimpleName ( ) , method . getName ( ) , e . getMessage ( ) ) ; } } } | Validate the create methods . | 261 | 6 |
139,594 | private void findValidation ( Class < ? > vaultClass , Class < ? > assetClass , Class < ? > idClass ) { for ( Method method : vaultClass . getMethods ( ) ) { if ( ! method . getName ( ) . startsWith ( "find" ) ) { continue ; } if ( ! Modifier . isAbstract ( method . getModifiers ( ) ) ) { continue ; } TypeRef resultRef = findResult ( method . getParameters ( ) ) ; if ( resultRef == null ) { continue ; } TypeRef typeRef = resultRef . to ( Result . class ) . param ( 0 ) ; Class < ? > typeClass = typeRef . rawClass ( ) ; // id return type if ( unbox ( idClass ) . equals ( unbox ( typeClass ) ) ) { continue ; } if ( Collection . class . isAssignableFrom ( typeClass ) ) { continue ; } else if ( Stream . class . isAssignableFrom ( typeClass ) ) { continue ; } else if ( Modifier . isAbstract ( typeClass . getModifiers ( ) ) ) { // assumed to be proxy continue ; } new ShimConverter <> ( assetClass , typeClass ) ; } } | Validate the find methods . | 261 | 6 |
139,595 | @ Override public void startOnInit ( DeployService2Impl < I > deploy , Result < I > result ) { deploy . startImpl ( result ) ; } | Called at initialization time for automatic start . | 34 | 9 |
139,596 | @ Override public void update ( DeployService2Impl < I > deploy , Result < I > result ) { LifecycleState state = deploy . getState ( ) ; if ( state . isStopped ( ) ) { deploy . startImpl ( result ) ; } else if ( state . isError ( ) ) { deploy . restartImpl ( result ) ; } else if ( deploy . isModifiedNow ( ) ) { deploy . restartImpl ( result ) ; } else { /* active */ result . ok ( deploy . get ( ) ) ; } } | Checks for updates from an admin command . The target state will be the initial state i . e . update will not start a lazy instance . | 115 | 29 |
139,597 | @ Override public void request ( DeployService2Impl < I > deploy , Result < I > result ) { result . ok ( deploy . get ( ) ) ; } | Returns the current instance . This strategy does not lazily restart the instance . | 35 | 15 |
139,598 | public static int getPodHash ( String key ) { byte [ ] buffer = new byte [ 16 ] ; int sublen = Math . min ( key . length ( ) , 8 ) ; for ( int i = 0 ; i < sublen ; i ++ ) { buffer [ i ] = ( byte ) key . charAt ( i ) ; } long hash = Murmur64 . generate ( Murmur64 . SEED , key ) ; BitsUtil . writeLong ( buffer , 8 , hash ) ; return calculatePodHash ( buffer , 0 , 16 ) ; } | Convenience for calculating the pod hash for a string . | 118 | 12 |
139,599 | public void get ( RowCursor cursor , Result < Boolean > result ) { TablePod tablePod = getTablePod ( ) ; int hash = getPodHash ( cursor ) ; if ( tablePod . getNode ( hash ) . isSelfCopy ( ) ) { _tableKelp . getDirect ( cursor , result ) ; } else { getTablePod ( ) . get ( cursor . getKey ( ) , result . then ( ( v , r ) -> getResult ( v , cursor , r ) ) ) ; } } | Gets a row from the table when the primary key is known . | 111 | 14 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.