idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
16,100
private JarDepend getJarDepend ( ) { if ( _depend == null || _depend . isModified ( ) ) _depend = new JarDepend ( new Depend ( getBacking ( ) ) ) ; return _depend ; }
Returns the dependency .
16,101
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 .
16,102
public long getLastModified ( String path ) { try { 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 .
16,103
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 .
16,104
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 .
16,105
public void clearCache ( ) { ZipFile zipFile = _zipFileRef . getAndSet ( null ) ; if ( zipFile != null ) try { zipFile . close ( ) ; } catch ( Exception e ) { } }
Clears any cached JarFile .
16,106
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 = null ; return extLoader ; }
Builds a combined class - loader with the target service loader as a parent and this calling pod loader as a child .
16,107
public ServerHeartbeat getServer ( String serverId ) { ServerHeartbeat server = _serverMap . get ( serverId ) ; return server ; }
Returns the server with the given canonical id .
16,108
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 .
16,109
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 .
16,110
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 .
16,111
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 .
16,112
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
16,113
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 .
16,114
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 .
16,115
public void addChar ( char nextCh ) throws IOException { int ch ; while ( ( ch = readChar ( ) ) >= 0 ) { outputChar ( ( char ) ch ) ; } outputChar ( nextCh ) ; }
Adds the next character .
16,116
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 .
16,117
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 .
16,118
public void setNameAndType ( String name , String type ) { _nameAndTypeIndex = getConstantPool ( ) . addNameAndType ( name , type ) . getIndex ( ) ; }
Sets the method name and type
16,119
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 .
16,120
void format ( StringBuilder sb , Temporal localDate ) { int len = _timestamp . length ; for ( int j = 0 ; j < len ; j ++ ) { _timestamp [ j ] . format ( sb , localDate ) ; } }
Formats the timestamp
16,121
@ 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
16,122
@ 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 .
16,123
public OutSegment openWriter ( ) { if ( isGcRequired ( ) ) { _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 .
16,124
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 .
16,125
private int calculateSegmentSize ( int factor , int segmentSizeOld ) { DatabaseKelp db = _table . database ( ) ; long segmentFactor = _tableLength / db . getSegmentSizeMin ( ) ; long segmentFactorNew = segmentFactor / factor ; 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 .
16,126
public void fsync ( Result < Boolean > result ) throws IOException { SegmentStream nodeStream = _nodeStream ; if ( nodeStream != null ) { nodeStream . fsync ( result ) ; } else { result . ok ( true ) ; } }
sync the output stream with the filesystem when possible .
16,127
public void afterDeliver ( ) { SegmentStream nodeStream = _nodeStream ; if ( nodeStream != null ) { if ( _isBlobDirty ) { _isBlobDirty = false ; nodeStream . fsync ( Result . ignore ( ) ) ; } else { nodeStream . flush ( Result . ignore ( ) ) ; } } }
Flushes the stream after a batch of writes .
16,128
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 .
16,129
@ InService ( SegmentServiceImpl . class ) public Page writePage ( Page page , long oldSequence , int saveLength , int saveTail , int saveSequence , Result < Integer > result ) { if ( isClosed ( ) ) { return null ; } 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 .
16,130
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 ) ; } } completePendingFlush ( ) ; }
Flushes the buffered data to the segment .
16,131
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 ) ) ; } _sOut . write ( _segment . getAddress ( ) + position , buffer , offset , length ) ; _position = position + length ; _isDirty = true ; }
Writes to the file from the WriteStream flush .
16,132
private void completePendingFlush ( ) { int size = _pendingFlushEntries . size ( ) ; if ( size == 0 ) { return ; } for ( int i = 0 ; i < size ; i ++ ) { PendingEntry entry = _pendingFlushEntries . get ( i ) ; entry . afterFlush ( ) ; _pendingFsyncEntries . add ( entry ) ; } _pendingFlushEntries . clear ( ) ; }
Notifies the calling service after the entry is written to the mmap .
16,133
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 .
16,134
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 .
16,135
private void afterIndexFsync ( Result < Boolean > result , FsyncType fsyncType , ArrayList < SegmentFsyncCallback > fsyncListeners ) { try { 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 .
16,136
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 ) ) ; } _sOut . write ( address , entryBuffer , offset , length ) ; _isDirty = true ; }
Write the current header to the output .
16,137
private static Constructor < ? > createImpl ( Class < ? > cl , ClassLoader loader ) { 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 .
16,138
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 ( 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 ; } 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 ) { createAmpResultMethod ( jClass , method , ampResult ) ; } else if ( ampResult < 0 ) { createAmpSendMethod ( jClass , method ) ; } else { throw new IllegalStateException ( method . toString ( ) ) ; } } }
Introspect the methods to find abstract methods .
16,139
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
16,140
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
16,141
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 .
16,142
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 .
16,143
protected ClassEntry getClassEntry ( String name , String pathName ) throws ClassNotFoundException { PathImpl classFile = _classDir . lookup ( pathName ) ; 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 .
16,144
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 .
16,145
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 .
16,146
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
16,147
public ServiceRefAmp session ( String name ) { String address = "session:///" + name + "/" ; return sessionImpl ( address ) ; }
Find the session by its service name .
16,148
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 .
16,149
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 .
16,150
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 .
16,151
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 .
16,152
public JMethod getMethod ( String name , JClass [ ] types ) { JClassLoader jClassLoader = getClassLoader ( ) ; return getMethod ( _class , name , types , jClassLoader ) ; }
Returns the matching methods .
16,153
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 .
16,154
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 .
16,155
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 .
16,156
public Level getLevel ( ) { if ( _localLevel != null ) { Level level = _localLevel . get ( ) ; if ( level != null ) { return level ; } } return _systemLevel ; }
Returns the logger s assigned level .
16,157
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 .
16,158
public Handler [ ] getHandlers ( ) { Handler [ ] handlers = _localHandlers . get ( ) ; if ( handlers != null ) return handlers ; else return EMPTY_HANDLERS ; }
Returns the handlers .
16,159
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 .
16,160
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
16,161
public boolean getUseParentHandlers ( ) { Boolean value = _useParentHandlers . get ( ) ; if ( value != null ) return Boolean . TRUE . equals ( value ) ; else return true ; }
Returns the use - parent - handlers
16,162
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 .
16,163
private void addHandler ( Handler handler , ClassLoader loader ) { 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 .
16,164
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 .
16,165
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
16,166
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 .
16,167
private synchronized void updateEffectiveLevel ( ClassLoader loader ) { if ( loader == null ) loader = _systemClassLoader ; int oldEffectiveLevel = getEffectiveLevel ( loader ) ; Level newEffectiveLevel = calculateEffectiveLevel ( loader ) ; 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 .
16,168
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 .
16,169
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 .
16,170
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 .
16,171
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 .
16,172
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
16,173
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 .
16,174
public void close ( ) { if ( _isFree ) TempCharBuffer . freeAll ( _head ) ; _head = null ; _buffer = null ; _offset = 0 ; _length = 0 ; }
Closes the reader .
16,175
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 ( ) ; 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 .
16,176
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 ( ) ; 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 ( ) ) ) { continue ; } new ShimConverter < > ( assetClass , typeClass ) ; } }
Validate the find methods .
16,177
public void startOnInit ( DeployService2Impl < I > deploy , Result < I > result ) { deploy . startImpl ( result ) ; }
Called at initialization time for automatic start .
16,178
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 { 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 .
16,179
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 .
16,180
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 .
16,181
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 .
16,182
public int read ( byte [ ] buffer , int offset , int length ) throws IOException { try { if ( _length < length ) length = ( int ) _length ; if ( length <= 0 ) return - 1 ; int len = _next . read ( buffer , offset , length ) ; if ( len > 0 ) { _length -= len ; } else { _length = - 1 ; } return len ; } catch ( SocketTimeoutException e ) { throw new ClientDisconnectException ( e ) ; } }
Reads from the buffer limiting to the content length .
16,183
public String format ( LogRecord log ) { StringBuilder sb = new StringBuilder ( ) ; int mark = 0 ; for ( FormatItem item : _formatList ) { item . format ( sb , log , mark ) ; if ( item instanceof PrettyPrintMarkItem ) { mark = sb . length ( ) ; } } return sb . toString ( ) ; }
Formats the record
16,184
public StreamBuilderImpl < T , U > reduce ( T init , BinaryOperatorSync < T > op ) { return new ReduceOpInitSync < > ( this , init , op ) ; }
Reduce with a binary function
16,185
public < R > StreamBuilderImpl < R , U > reduce ( R identity , BiFunctionSync < R , ? super T , R > accumulator , BinaryOperatorSync < R > combiner ) { return new ReduceAccumSync < > ( this , identity , accumulator , combiner ) ; }
Reduce with an accumulator and combiner
16,186
public void setModified ( boolean isModified ) { _isModified = isModified ; if ( _isModified ) _checkExpiresTime = Long . MAX_VALUE / 2 ; else _checkExpiresTime = CurrentTime . currentTime ( ) + _checkInterval ; if ( ! isModified ) _isModifiedLog = false ; }
Sets the modified .
16,187
private static ServiceWeb buildWebService ( WebBuilder builder , Function < RequestWeb , Object > beanFactory , Method method ) { Parameter [ ] params = method . getParameters ( ) ; WebParam [ ] webParam = new WebParam [ params . length ] ; for ( int i = 0 ; i < params . length ; i ++ ) { webParam [ i ] = buildParam ( builder , params [ i ] ) ; } return new WebServiceMethod ( beanFactory , method , webParam ) ; }
Builds a HTTP service from a method .
16,188
public String getAttribute ( String key ) { List < String > values = _headers . get ( key . toLowerCase ( Locale . ENGLISH ) ) ; if ( values != null && values . size ( ) > 0 ) return values . get ( 0 ) ; return null ; }
Returns a read attribute from the multipart mime .
16,189
public int getAvailable ( ) throws IOException { if ( _isPartDone ) return 0 ; else if ( _peekOffset < _peekLength ) return _peekLength - _peekOffset ; else { int ch = read ( ) ; if ( ch < 0 ) return 0 ; _peekOffset = 0 ; _peekLength = 1 ; _peek [ 0 ] = ( byte ) ch ; return 1 ; } }
Returns the number of available bytes .
16,190
public int read ( byte [ ] buffer , int offset , int length ) throws IOException { int b = - 1 ; if ( _isPartDone ) return - 1 ; int i = 0 ; while ( _peekOffset + 1 < _peekLength && length > 0 ) { buffer [ offset + i ++ ] = _peek [ _peekOffset ++ ] ; length -- ; } while ( i < length && ( b = read ( ) ) >= 0 ) { boolean hasCr = false ; if ( b == '\r' ) { hasCr = true ; b = read ( ) ; if ( b != '\n' ) { buffer [ offset + i ++ ] = ( byte ) '\r' ; _peek [ 0 ] = ( byte ) b ; _peekOffset = 0 ; _peekLength = 1 ; continue ; } } else if ( b != '\n' ) { buffer [ offset + i ++ ] = ( byte ) b ; continue ; } int j ; for ( j = 0 ; j < _boundaryLength && ( b = read ( ) ) >= 0 && _boundaryBuffer [ j ] == b ; j ++ ) { } if ( j == _boundaryLength ) { _isPartDone = true ; if ( ( b = read ( ) ) == '-' ) { if ( ( b = read ( ) ) == '-' ) { _isDone = true ; _isComplete = true ; } } for ( ; b > 0 && b != '\r' && b != '\n' ; b = read ( ) ) { } if ( b == '\r' && ( b = read ( ) ) != '\n' ) { _peek [ 0 ] = ( byte ) b ; _peekOffset = 0 ; _peekLength = 1 ; } return i > 0 ? i : - 1 ; } _peekLength = 0 ; if ( hasCr && i + 1 < length ) { buffer [ offset + i ++ ] = ( byte ) '\r' ; buffer [ offset + i ++ ] = ( byte ) '\n' ; } else if ( hasCr ) { buffer [ offset + i ++ ] = ( byte ) '\r' ; _peek [ _peekLength ++ ] = ( byte ) '\n' ; } else { buffer [ offset + i ++ ] = ( byte ) '\n' ; } int k = 0 ; while ( k < j && i + 1 < length ) buffer [ offset + i ++ ] = _boundaryBuffer [ k ++ ] ; while ( k < j ) _peek [ _peekLength ++ ] = _boundaryBuffer [ k ++ ] ; _peek [ _peekLength ++ ] = ( byte ) b ; _peekOffset = 0 ; } if ( i <= 0 ) { _isPartDone = true ; if ( b < 0 ) _isDone = true ; return - 1 ; } else { return i ; } }
Reads from the multipart mime buffer .
16,191
public ServiceRefAmp ref ( ) { if ( _isForeign ) { return null ; } if ( workers ( ) > 1 ) { return buildWorkers ( ) ; } if ( _worker != null ) { return buildWorker ( ) ; } else { return buildService ( ) ; } }
Build the service and return the service ref .
16,192
private ServiceRefAmp service ( StubFactoryAmp stubFactory ) { validateOpen ( ) ; Thread thread = Thread . currentThread ( ) ; ClassLoader oldLoader = thread . getContextClassLoader ( ) ; OutboxAmp outbox = OutboxAmp . current ( ) ; Object oldContext = null ; try { thread . setContextClassLoader ( _services . classLoader ( ) ) ; if ( outbox != null ) { oldContext = outbox . getAndSetContext ( _services . inboxSystem ( ) ) ; } ServiceRefAmp serviceRef = serviceImpl ( stubFactory ) ; String address = stubFactory . address ( ) ; if ( address != null ) { _services . bind ( serviceRef , address ) ; } if ( serviceRef . stub ( ) . isAutoStart ( ) || stubFactory . config ( ) . isAutoStart ( ) ) { _services . addAutoStart ( serviceRef ) ; } return serviceRef ; } finally { thread . setContextClassLoader ( oldLoader ) ; if ( outbox != null ) { outbox . getAndSetContext ( oldContext ) ; } } }
Main service builder . Called from ServiceBuilder and ServiceRefBean .
16,193
ServiceRefAmp service ( QueueServiceFactoryInbox serviceFactory , ServiceConfig config ) { QueueDeliverBuilderImpl < MessageAmp > queueBuilder = new QueueDeliverBuilderImpl < > ( ) ; queueBuilder . setClassLoader ( _services . classLoader ( ) ) ; queueBuilder . sizeMax ( config . queueSizeMax ( ) ) ; queueBuilder . size ( config . queueSize ( ) ) ; InboxAmp inbox = new InboxQueue ( _services , queueBuilder , serviceFactory , config ) ; return inbox . serviceRef ( ) ; }
Used by journal builder .
16,194
public QueryBuilderKraken parse ( ) { Token token = scanToken ( ) ; switch ( token ) { case CREATE : return parseCreate ( ) ; case EXPLAIN : return parseExplain ( ) ; case INSERT : return parseInsert ( ) ; case REPLACE : return parseReplace ( ) ; case SELECT : return parseSelect ( ) ; case SELECT_LOCAL : return parseSelectLocal ( ) ; case MAP : return parseMap ( ) ; case SHOW : return parseShow ( ) ; case UPDATE : return parseUpdate ( ) ; case DELETE : return parseDelete ( ) ; case WATCH : return parseWatch ( ) ; case IDENTIFIER : if ( _lexeme . equalsIgnoreCase ( "checkpoint" ) ) { return parseCheckpoint ( ) ; } default : throw error ( "unknown query at {0}" , token ) ; } }
Parses the query .
16,195
private ExprKraken parseSelectExpr ( ) { Token token = scanToken ( ) ; if ( token == Token . STAR ) { throw new UnsupportedOperationException ( getClass ( ) . getName ( ) ) ; } else { _token = token ; return parseExpr ( ) ; } }
Parses a select expression .
16,196
private QueryBuilderKraken parseCreate ( ) { Token token ; if ( ( token = scanToken ( ) ) != Token . TABLE ) throw error ( "expected TABLE at '{0}'" , token ) ; if ( ( token = scanToken ( ) ) != Token . IDENTIFIER ) throw error ( "expected identifier at '{0}'" , token ) ; String name = _lexeme ; String pod = null ; while ( peekToken ( ) == Token . DOT ) { scanToken ( ) ; if ( ( token = scanToken ( ) ) != Token . IDENTIFIER ) { throw error ( "expected identifier at '{0}'" , token ) ; } if ( pod == null ) { pod = name ; } else { pod = pod + '.' + name ; } name = _lexeme ; } if ( pod == null ) { pod = getPodName ( ) ; } TableBuilderKraken factory = new TableBuilderKraken ( pod , name , _sql ) ; if ( ( token = scanToken ( ) ) != Token . LPAREN ) { throw error ( "expected '(' at '{0}'" , token ) ; } do { token = scanToken ( ) ; switch ( token ) { case IDENTIFIER : parseCreateColumn ( factory , _lexeme ) ; break ; case PRIMARY : token = scanToken ( ) ; if ( token != Token . KEY ) throw error ( "expected 'key' at {0}" , token ) ; factory . addPrimaryKey ( parseColumnNames ( ) ) ; break ; case KEY : factory . addPrimaryKey ( parseColumnNames ( ) ) ; break ; default : throw error ( "unexpected token '{0}'" , token ) ; } token = scanToken ( ) ; } while ( token == Token . COMMA ) ; if ( token != Token . RPAREN ) { throw error ( "expected ')' at '{0}'" , token ) ; } token = scanToken ( ) ; HashMap < String , String > propMap = new HashMap < > ( ) ; if ( token == Token . WITH ) { do { String key = parseIdentifier ( ) ; ExprKraken expr = parseExpr ( ) ; if ( ! ( expr instanceof LiteralExpr ) ) { throw error ( "WITH expression must be a literal at '{0}'" , expr ) ; } String value = expr . evalString ( null ) ; propMap . put ( key , value ) ; } while ( ( token = scanToken ( ) ) == Token . COMMA ) ; } if ( token != Token . EOF ) { throw error ( "Expected end of file at '{0}'" , token ) ; } return new CreateQueryBuilder ( _tableManager , factory , _sql , propMap ) ; }
Parses the create .
16,197
public void parseReferences ( ArrayList < String > name ) { String foreignTable = parseIdentifier ( ) ; Token token = scanToken ( ) ; ArrayList < String > foreignColumns = new ArrayList < String > ( ) ; if ( token == Token . LPAREN ) { _token = token ; foreignColumns = parseColumnNames ( ) ; } else { _token = token ; } }
Parses the references clause .
16,198
public ArrayList < String > parseColumnNames ( ) { ArrayList < String > columns = new ArrayList < String > ( ) ; Token token = scanToken ( ) ; if ( token == Token . LPAREN ) { do { columns . add ( parseIdentifier ( ) ) ; token = scanToken ( ) ; } while ( token == Token . COMMA ) ; if ( token != Token . RPAREN ) { throw error ( "expected ')' at '{0}'" , token ) ; } } else if ( token == Token . IDENTIFIER ) { columns . add ( _lexeme ) ; _token = token ; } else { throw error ( "expected '(' at '{0}'" , token ) ; } return columns ; }
Parses a list of column names
16,199
private QueryBuilderKraken parseInsert ( ) { Token token ; if ( ( token = scanToken ( ) ) != Token . INTO ) { throw error ( "expected INTO at '{0}'" , token ) ; } TableKraken table = parseTable ( ) ; Objects . requireNonNull ( table ) ; TableKelp tableKelp = table . getTableKelp ( ) ; ArrayList < Column > columns = new ArrayList < > ( ) ; boolean isKeyHash = false ; if ( ( token = scanToken ( ) ) == Token . LPAREN ) { do { String columnName = parseIdentifier ( ) ; Column column = tableKelp . getColumn ( columnName ) ; if ( column == null ) { throw error ( "'{0}' is not a valid column in {1}" , columnName , table . getName ( ) ) ; } columns . add ( column ) ; } while ( ( token = scanToken ( ) ) == Token . COMMA ) ; if ( token != Token . RPAREN ) { throw error ( "expected ')' at '{0}'" , token ) ; } token = scanToken ( ) ; } else { for ( Column column : tableKelp . getColumns ( ) ) { if ( column . name ( ) . startsWith ( ":" ) ) { continue ; } columns . add ( column ) ; } } if ( token != Token . VALUES ) throw error ( "expected VALUES at '{0}'" , token ) ; if ( ( token = scanToken ( ) ) != Token . LPAREN ) { throw error ( "expected '(' at '{0}'" , token ) ; } ArrayList < ExprKraken > values = new ArrayList < > ( ) ; InsertQueryBuilder query ; query = new InsertQueryBuilder ( this , _sql , table , columns ) ; _query = query ; do { ExprKraken expr = parseExpr ( ) ; values . add ( expr ) ; } while ( ( token = scanToken ( ) ) == Token . COMMA ) ; if ( token != Token . RPAREN ) { throw error ( "expected ')' at '{0}'" , token ) ; } if ( columns . size ( ) != values . size ( ) ) { throw error ( "number of columns does not match number of values" ) ; } ParamExpr [ ] params = _params . toArray ( new ParamExpr [ _params . size ( ) ] ) ; query . setParams ( params ) ; query . setValues ( values ) ; return query ; }
Parses the insert .