idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
16,500
private void writeMetaContinuation ( ) { TempBuffer tBuf = TempBuffer . create ( ) ; byte [ ] buffer = tBuf . buffer ( ) ; int metaLength = _segmentMeta [ 0 ] . size ( ) ; SegmentExtent extent = new SegmentExtent ( 0 , _addressTail , metaLength ) ; _metaExtents . add ( extent ) ; _addressTail += metaLength ; int offset = 0 ; buffer [ offset ++ ] = CODE_META_SEGMENT ; long address = extent . address ( ) ; int length = extent . length ( ) ; long value = ( address & ~ 0xffff ) | ( length >> 16 ) ; offset += BitsUtil . writeLong ( buffer , offset , value ) ; int crc = _nonce ; crc = Crc32Caucho . generate ( crc , buffer , 0 , offset ) ; offset += BitsUtil . writeInt ( buffer , offset , crc ) ; try ( OutStore sOut = openWrite ( _metaOffset , offset ) ) { sOut . write ( _metaOffset , buffer , 0 , offset ) ; } tBuf . free ( ) ; _metaAddress = address ; _metaOffset = address ; _metaTail = address + length ; }
Writes a continuation entry which points to a new meta - data segment .
16,501
private boolean readMetaData ( ) throws IOException { SegmentExtent metaExtentInit = new SegmentExtent ( 0 , 0 , META_SEGMENT_SIZE ) ; try ( InSegment reader = openRead ( metaExtentInit ) ) { ReadStream is = reader . in ( ) ; if ( ! readMetaDataHeader ( is ) ) { return false ; } _segmentId = 1 ; } int metaLength = _segmentMeta [ 0 ] . size ( ) ; SegmentExtent metaExtent = new SegmentExtent ( 0 , 0 , metaLength ) ; _metaExtents . clear ( ) ; _metaExtents . add ( metaExtent ) ; _metaAddress = 0 ; _metaOffset = META_OFFSET ; _metaTail = _metaOffset + metaLength ; while ( true ) { try ( InSegment reader = openRead ( metaExtent ) ) { ReadStream is = reader . in ( ) ; if ( metaExtent . address ( ) == 0 ) { is . position ( META_OFFSET ) ; } long metaAddress = _metaAddress ; while ( readMetaDataEntry ( is ) ) { } if ( _metaAddress == metaAddress ) { return true ; } metaExtent = new SegmentExtent ( 0 , _metaAddress , metaLength ) ; } } }
Reads metadata header for entire database .
16,502
private boolean readMetaDataHeader ( ReadStream is ) throws IOException { long magic = BitsUtil . readLong ( is ) ; if ( magic != KELP_MAGIC ) { log . info ( L . l ( "Mismatched kelp version {0} {1}\n" , Long . toHexString ( magic ) , _path ) ) ; return false ; } int crc = CRC_INIT ; crc = Crc32Caucho . generate ( crc , magic ) ; _nonce = BitsUtil . readInt ( is ) ; crc = Crc32Caucho . generateInt32 ( crc , _nonce ) ; int headers = BitsUtil . readInt ( is ) ; crc = Crc32Caucho . generateInt32 ( crc , headers ) ; for ( int i = 0 ; i < headers ; i ++ ) { int key = BitsUtil . readInt ( is ) ; crc = Crc32Caucho . generateInt32 ( crc , key ) ; int value = BitsUtil . readInt ( is ) ; crc = Crc32Caucho . generateInt32 ( crc , value ) ; } int count = BitsUtil . readInt ( is ) ; crc = Crc32Caucho . generateInt32 ( crc , count ) ; ArrayList < Integer > segmentSizes = new ArrayList < > ( ) ; for ( int i = 0 ; i < count ; i ++ ) { int size = BitsUtil . readInt ( is ) ; crc = Crc32Caucho . generateInt32 ( crc , size ) ; segmentSizes . add ( size ) ; } int crcFile = BitsUtil . readInt ( is ) ; if ( crc != crcFile ) { log . info ( L . l ( "Mismatched crc files in kelp meta header" ) ) ; return false ; } SegmentMeta [ ] segmentMetaList = new SegmentMeta [ segmentSizes . size ( ) ] ; for ( int i = 0 ; i < segmentMetaList . length ; i ++ ) { segmentMetaList [ i ] = new SegmentMeta ( segmentSizes . get ( i ) ) ; } _segmentMeta = segmentMetaList ; _metaOffset = is . position ( ) ; _addressTail = META_SEGMENT_SIZE ; return true ; }
The first metadata for the store includes the sizes of the segments the crc nonce and optional headers .
16,503
private boolean readMetaDataEntry ( ReadStream is ) throws IOException { int crc = _nonce ; int code = is . read ( ) ; crc = Crc32Caucho . generate ( crc , code ) ; switch ( code ) { case CODE_TABLE : readMetaTable ( is , crc ) ; break ; case CODE_SEGMENT : readMetaSegment ( is , crc ) ; break ; case CODE_META_SEGMENT : readMetaContinuation ( is , crc ) ; break ; default : return false ; } _metaOffset = is . position ( ) ; return true ; }
Reads meta - data entries .
16,504
private boolean readMetaTable ( ReadStream is , int crc ) throws IOException { byte [ ] key = new byte [ TABLE_KEY_SIZE ] ; is . read ( key , 0 , key . length ) ; crc = Crc32Caucho . generate ( crc , key ) ; int rowLength = BitsUtil . readInt16 ( is ) ; crc = Crc32Caucho . generateInt16 ( crc , rowLength ) ; int keyOffset = BitsUtil . readInt16 ( is ) ; crc = Crc32Caucho . generateInt16 ( crc , keyOffset ) ; int keyLength = BitsUtil . readInt16 ( is ) ; crc = Crc32Caucho . generateInt16 ( crc , keyLength ) ; int dataLength = BitsUtil . readInt16 ( is ) ; crc = Crc32Caucho . generateInt16 ( crc , dataLength ) ; byte [ ] data = new byte [ dataLength ] ; is . readAll ( data , 0 , data . length ) ; crc = Crc32Caucho . generate ( crc , data ) ; int crcFile = BitsUtil . readInt ( is ) ; if ( crcFile != crc ) { log . fine ( "meta-table crc mismatch" ) ; return false ; } TableEntry entry = new TableEntry ( key , rowLength , keyOffset , keyLength , data ) ; _tableList . add ( entry ) ; return true ; }
Read metadata for a table .
16,505
private boolean readMetaSegment ( ReadStream is , int crc ) throws IOException { long value = BitsUtil . readLong ( is ) ; crc = Crc32Caucho . generate ( crc , value ) ; int crcFile = BitsUtil . readInt ( is ) ; if ( crcFile != crc ) { log . fine ( "meta-segment crc mismatch" ) ; return false ; } long address = value & ~ 0xffff ; int length = ( int ) ( ( value & 0xffff ) << 16 ) ; SegmentExtent segment = new SegmentExtent ( _segmentId ++ , address , length ) ; SegmentMeta segmentMeta = findSegmentMeta ( length ) ; segmentMeta . addSegment ( segment ) ; return true ; }
metadata for a segment
16,506
private boolean readMetaContinuation ( ReadStream is , int crc ) throws IOException { long value = BitsUtil . readLong ( is ) ; crc = Crc32Caucho . generate ( crc , value ) ; int crcFile = BitsUtil . readInt ( is ) ; if ( crcFile != crc ) { log . fine ( "meta-segment crc mismatch" ) ; return false ; } long address = value & ~ 0xffff ; int length = ( int ) ( ( value & 0xffff ) << 16 ) ; if ( length != _segmentMeta [ 0 ] . size ( ) ) { throw new IllegalStateException ( ) ; } SegmentExtent extent = new SegmentExtent ( 0 , address , length ) ; _metaExtents . add ( extent ) ; _metaAddress = address ; _metaOffset = address ; _metaTail = address + length ; return false ; }
Continuation segment for the metadata .
16,507
private SegmentMeta findSegmentMeta ( int size ) { for ( SegmentMeta segmentMeta : this . _segmentMeta ) { if ( segmentMeta . size ( ) == size ) { return segmentMeta ; } } throw new IllegalStateException ( L . l ( "{0} is an invalid segment size" , size ) ) ; }
Finds the segment group for a given size .
16,508
public SegmentKelp createSegment ( int length , byte [ ] tableKey , long sequence ) { SegmentMeta segmentMeta = findSegmentMeta ( length ) ; SegmentKelp segment ; SegmentExtent extent = segmentMeta . allocate ( ) ; if ( extent == null ) { extent = allocateSegment ( segmentMeta ) ; } segment = new SegmentKelp ( extent , sequence , tableKey , this ) ; segment . writing ( ) ; segmentMeta . addLoaded ( segment ) ; return segment ; }
Create a new writing sequence with the given sequence id .
16,509
private void findAfterLocal ( Result < Cursor > result , RowCursor cursor , Object [ ] args , Cursor cursorLocal ) { long version = 0 ; if ( cursorLocal != null ) { version = cursorLocal . getVersion ( ) ; long time = cursorLocal . getUpdateTime ( ) ; long timeout = cursorLocal . getTimeout ( ) ; long now = CurrentTime . currentTime ( ) ; if ( now <= time + timeout ) { result . ok ( cursorLocal ) ; return ; } } TablePod tablePod = _table . getTablePod ( ) ; tablePod . getIfUpdate ( cursor . getKey ( ) , version , result . then ( ( table , r ) -> _selectQueryLocal . findOne ( r , args ) ) ) ; }
After finding the local cursor if it s expired check with the cluster to find the most recent value .
16,510
public boolean containsKey ( Object key ) { if ( key == null ) { return false ; } K [ ] keys = _keys ; for ( int i = _size - 1 ; i >= 0 ; i -- ) { K testKey = keys [ i ] ; if ( key . equals ( testKey ) ) { return true ; } } return false ; }
Returns true if the map contains the value .
16,511
public void start ( ) { _state = _state . toStart ( ) ; _bufferCapacity = DEFAULT_SIZE ; _tBuf = TempBuffer . create ( ) ; _buffer = _tBuf . buffer ( ) ; _startOffset = bufferStart ( ) ; _offset = _startOffset ; _contentLength = 0 ; }
Starts the response stream .
16,512
public void write ( int ch ) throws IOException { if ( isClosed ( ) || isHead ( ) ) { return ; } int offset = _offset ; if ( SIZE <= offset ) { flushByteBuffer ( ) ; offset = _offset ; } _buffer [ offset ++ ] = ( byte ) ch ; _offset = offset ; }
Writes a byte to the output .
16,513
public void write ( byte [ ] buffer , int offset , int length ) { if ( isClosed ( ) || isHead ( ) ) { return ; } int byteLength = _offset ; while ( true ) { int sublen = Math . min ( length , SIZE - byteLength ) ; System . arraycopy ( buffer , offset , _buffer , byteLength , sublen ) ; offset += sublen ; length -= sublen ; byteLength += sublen ; if ( length <= 0 ) { break ; } _offset = byteLength ; flushByteBuffer ( ) ; byteLength = _offset ; } _offset = byteLength ; }
Writes a chunk of bytes to the stream .
16,514
public byte [ ] nextBuffer ( int offset ) throws IOException { if ( offset < 0 || SIZE < offset ) { throw new IllegalStateException ( L . l ( "Invalid offset: " + offset ) ) ; } if ( _bufferCapacity <= SIZE || _bufferCapacity <= offset + _bufferSize ) { _offset = offset ; flushByteBuffer ( ) ; return buffer ( ) ; } else { _tBuf . length ( offset ) ; _bufferSize += offset ; TempBuffer tempBuf = TempBuffer . create ( ) ; _tBuf . next ( tempBuf ) ; _tBuf = tempBuf ; _buffer = _tBuf . buffer ( ) ; _offset = _startOffset ; return _buffer ; } }
Returns the next byte buffer .
16,515
public final void close ( ) throws IOException { State state = _state ; if ( state . isClosing ( ) ) { return ; } _state = state . toClosing ( ) ; try { flush ( true ) ; } finally { try { _state = _state . toClose ( ) ; } catch ( RuntimeException e ) { throw new RuntimeException ( state + ": " + e , e ) ; } } }
Closes the response stream
16,516
private void flush ( boolean isEnd ) { if ( _startOffset == _offset && _bufferSize == 0 ) { if ( ! isCommitted ( ) || isEnd ) { flush ( null , isEnd ) ; _startOffset = bufferStart ( ) ; _offset = _startOffset ; } return ; } int sublen = _offset - _startOffset ; _tBuf . length ( _offset ) ; _contentLength += _offset - _startOffset ; _bufferSize = 0 ; if ( _startOffset > 0 ) { fillChunkHeader ( _tBuf , sublen ) ; } flush ( _tBuf , isEnd ) ; if ( ! isEnd ) { _tBuf = TempBuffer . create ( ) ; _startOffset = bufferStart ( ) ; _offset = _startOffset ; _tBuf . length ( _offset ) ; _buffer = _tBuf . buffer ( ) ; } else { _tBuf = null ; } }
Flushes the buffered response to the output stream .
16,517
private boolean readSend ( InH3 hIn , OutboxAmp outbox , HeadersAmp headers ) throws IOException { MethodRefHamp methodHamp = null ; try { methodHamp = readMethod ( hIn ) ; } catch ( Throwable e ) { log . log ( Level . FINER , e . toString ( ) , e ) ; skipArgs ( hIn ) ; return true ; } MethodRefAmp method = methodHamp . getMethod ( ) ; ClassLoader loader = methodHamp . getClassLoader ( ) ; Thread thread = Thread . currentThread ( ) ; thread . setContextClassLoader ( loader ) ; Object [ ] args = readArgs ( methodHamp , hIn ) ; if ( log . isLoggable ( _logLevel ) ) { log . log ( _logLevel , this + " send-r " + method . getName ( ) + debugArgs ( args ) + " {to:" + method + ", " + headers + "}" ) ; } SendMessage_N sendMessage = new SendMessage_N ( outbox , headers , method . serviceRef ( ) , method . method ( ) , args ) ; long timeout = 1000L ; try { sendMessage . offer ( timeout ) ; } catch ( Throwable e ) { log . fine ( e . toString ( ) ) ; if ( log . isLoggable ( Level . FINEST ) ) { log . log ( Level . FINEST , e . toString ( ) , e ) ; } } return true ; }
The send message is a on - way call to a service .
16,518
private void readQuery ( InH3 hIn , OutboxAmp outbox , HeadersAmp headers ) throws IOException { GatewayReply from = readFromAddress ( hIn ) ; long qid = hIn . readLong ( ) ; long timeout = 120 * 1000L ; MethodRefHamp methodHamp = null ; MethodRefAmp methodRef = null ; try { try { methodHamp = readMethod ( hIn ) ; } catch ( Throwable e ) { skipArgs ( hIn ) ; throw e ; } methodRef = methodHamp . getMethod ( ) ; ClassLoader loader = methodHamp . getClassLoader ( ) ; Thread thread = Thread . currentThread ( ) ; thread . setContextClassLoader ( loader ) ; Object [ ] args = readArgs ( methodHamp , hIn ) ; QueryGatewayReadMessage_N msg = new QueryGatewayReadMessage_N ( outbox , getInboxCaller ( ) , headers , from , qid , methodRef . serviceRef ( ) , methodRef . method ( ) , timeout , args ) ; msg . offer ( _queueTimeout ) ; if ( log . isLoggable ( _logLevel ) ) { log . log ( _logLevel , "hamp-query " + methodRef . getName ( ) + " " + debugArgs ( args ) + " (in " + this + ")" + "\n {qid:" + qid + ", to:" + methodRef . serviceRef ( ) + ", from:" + from + "," + headers + "}" ) ; } } catch ( Throwable e ) { if ( log . isLoggable ( Level . FINE ) ) { log . fine ( "hamp-query error " + e + " (in " + this + ")" + "\n {id:" + qid + ", from:" + from + "," + headers + "," + methodRef + "}" ) ; } if ( log . isLoggable ( Level . FINER ) ) { log . log ( Level . FINER , e . toString ( ) , e ) ; } ServiceRefAmp serviceRef = getInboxCaller ( ) . serviceRef ( ) ; MethodRefError methodErr ; if ( methodRef == null ) { methodErr = new MethodRefError ( serviceRef , "unknown-method" ) ; } else { methodErr = new MethodRefError ( serviceRef , methodRef . getName ( ) ) ; } QueryGatewayReadMessage_N queryRef = new QueryGatewayReadMessage_N ( outbox , getInboxCaller ( ) , headers , from , qid , serviceRef , methodErr . method ( ) , timeout , null ) ; queryRef . toSent ( ) ; if ( e instanceof ServiceException ) { queryRef . fail ( e ) ; outbox . flush ( ) ; } else { HampException exn = new HampException ( L . l ( "{0}\n while reading {1}" , e . toString ( ) , methodRef ) , e ) ; queryRef . fail ( exn ) ; } } }
The query message is a RPC call to a service .
16,519
private void readQueryResult ( InH3 hIn , HeadersAmp headers ) throws IOException { ServiceRefAmp serviceRef = readToAddress ( hIn ) ; long id = hIn . readLong ( ) ; QueryRefAmp queryRef = serviceRef . removeQueryRef ( id ) ; if ( queryRef != null ) { ClassLoader loader = queryRef . getClassLoader ( ) ; Thread thread = Thread . currentThread ( ) ; thread . setContextClassLoader ( loader ) ; } else { } Object value = hIn . readObject ( ) ; if ( log . isLoggable ( _logLevel ) ) { log . log ( _logLevel , "query-result-r " + value + " (in " + this + ")" + "\n {id:" + id + ", to:" + serviceRef + "," + headers + "}" ) ; } if ( queryRef != null ) { queryRef . complete ( headers , value ) ; } else if ( log . isLoggable ( Level . WARNING ) ) { log . warning ( "query-result qid=" + id + " for service " + serviceRef + " does not match any known queries.\n" + headers ) ; } }
query reply parsing
16,520
public void addInclude ( PathPatternType pattern ) { if ( _includeList == null ) _includeList = new ArrayList < PathPatternType > ( ) ; _includeList . add ( pattern ) ; }
Adds an include pattern .
16,521
public void setUserPathPrefix ( String prefix ) { if ( prefix != null && ! prefix . equals ( "" ) && ! prefix . endsWith ( "/" ) ) _userPathPrefix = prefix + "/" ; else _userPathPrefix = prefix ; }
Sets the user - path prefix for better error reporting .
16,522
public ExprKraken getKeyExpr ( String name ) { if ( name . equals ( _column . getColumn ( ) . name ( ) ) ) { return getRight ( ) ; } else { return null ; } }
Returns the assigned key expression
16,523
public void write ( byte [ ] buf , int offset , int length , boolean isEnd ) throws IOException { OutputStream stream = getStream ( ) ; if ( stream == null ) { return ; } synchronized ( stream ) { stream . write ( buf , offset , length ) ; if ( isEnd ) { stream . flush ( ) ; } } }
Write data to the stream .
16,524
public void flush ( ) throws IOException { OutputStream stream = getStream ( ) ; if ( stream == null ) { return ; } synchronized ( stream ) { stream . flush ( ) ; } }
Flush data to the stream .
16,525
public synchronized static void setStdout ( OutputStream os ) { if ( _stdoutStream == null ) { initStdout ( ) ; } if ( os == _systemErr || os == _systemOut ) { return ; } if ( os instanceof WriteStream ) { WriteStream out = ( WriteStream ) os ; } _stdoutStream . setStream ( os ) ; }
Sets the backing stream for System . out
16,526
public static synchronized void setStderr ( OutputStream os ) { if ( _stderrStream == null ) { initStderr ( ) ; } if ( os == _systemErr || os == _systemOut ) { return ; } if ( os instanceof WriteStream ) { WriteStream out = ( WriteStream ) os ; } _stderrStream . setStream ( os ) ; }
Sets path as the backing stream for System . err
16,527
protected static < E extends SubSystemBase > SystemManager preCreate ( Class < E > serviceClass ) { SystemManager system = SystemManager . getCurrent ( ) ; if ( system == null ) throw new IllegalStateException ( L . l ( "{0} must be created before {1}" , SystemManager . class . getSimpleName ( ) , serviceClass . getSimpleName ( ) ) ) ; if ( system . getSystem ( serviceClass ) != null ) throw new IllegalStateException ( L . l ( "{0} was previously created" , serviceClass . getSimpleName ( ) ) ) ; return system ; }
convenience method for subclass s create methods
16,528
public String addConnectionRequirement ( NodeTemplate target , String type , String varName ) { Map < String , Object > requirement = new LinkedHashMap ( ) ; String requirementName = "endpoint" ; Map requirementMap = new LinkedHashMap < String , Object > ( ) ; requirement . put ( requirementName , requirementMap ) ; requirementMap . put ( "node" , target . getName ( ) ) ; requirementMap . put ( "type" , type ) ; if ( ! varName . isEmpty ( ) ) { Map < String , String > properties = new LinkedHashMap ( ) ; properties . put ( "prop.name" , varName ) ; requirementMap . put ( "properties" , properties ) ; } requirements ( ) . add ( requirement ) ; return requirementName ; }
Add an endpoint requirement to a NodeTemplate
16,529
public boolean stop ( ) { if ( ! _lifecycle . toStopping ( ) ) return false ; log . finest ( this + " stopping" ) ; closeConnections ( ) ; destroy ( ) ; return true ; }
Closing the manager .
16,530
int writePageIndex ( byte [ ] buffer , int head , int type , int pid , int nextPid , int entryOffset , int entryLength ) { int sublen = 1 + 4 * 4 ; if ( BLOCK_SIZE - 8 < head + sublen ) { return - 1 ; } buffer [ head ] = ( byte ) type ; head ++ ; BitsUtil . writeInt ( buffer , head , pid ) ; head += 4 ; BitsUtil . writeInt ( buffer , head , nextPid ) ; head += 4 ; BitsUtil . writeInt ( buffer , head , entryOffset ) ; head += 4 ; BitsUtil . writeInt ( buffer , head , entryLength ) ; head += 4 ; return head ; }
Writes a page index .
16,531
public void readEntries ( TableKelp table , InSegment reader , SegmentEntryCallback cb ) { TempBuffer tBuf = TempBuffer . createLarge ( ) ; byte [ ] buffer = tBuf . buffer ( ) ; InStore sIn = reader . getStoreRead ( ) ; byte [ ] tableKey = new byte [ TableKelp . TABLE_KEY_SIZE ] ; for ( int ptr = length ( ) - BLOCK_SIZE ; ptr > 0 ; ptr -= BLOCK_SIZE ) { sIn . read ( getAddress ( ) + ptr , buffer , 0 , buffer . length ) ; int index = 0 ; long seq = BitsUtil . readLong ( buffer , index ) ; index += 8 ; if ( seq != getSequence ( ) ) { log . warning ( L . l ( "Invalid sequence {0} expected {1} at 0x{2}" , seq , getSequence ( ) , Long . toHexString ( getAddress ( ) + ptr ) ) ) ; break ; } System . arraycopy ( buffer , index , tableKey , 0 , tableKey . length ) ; index += tableKey . length ; if ( ! Arrays . equals ( tableKey , _tableKey ) ) { log . warning ( L . l ( "Invalid table {0} table {1} at 0x{2}" , Hex . toShortHex ( tableKey ) , Hex . toShortHex ( _tableKey ) , Long . toHexString ( getAddress ( ) + ptr ) ) ) ; break ; } int head = index ; while ( head < BLOCK_SIZE && buffer [ head ] != 0 ) { head = readEntry ( table , buffer , head , cb , getAddress ( ) ) ; } boolean isCont = buffer [ head + 1 ] != 0 ; if ( ! isCont ) { break ; } } tBuf . free ( ) ; }
Reads index entries from the segment .
16,532
public int getSize ( ) { int size = length ( ) ; if ( _blobs == null ) { return size ; } for ( BlobOutputStream blob : _blobs ) { if ( blob != null ) { size += blob . getSize ( ) ; } } return size ; }
The size includes the dynamic size from any blobs
16,533
public final OutputStream openOutputStream ( int index ) { Column column = _row . columns ( ) [ index ] ; return column . openOutputStream ( this ) ; }
Set a blob value with an open blob stream .
16,534
public static Path currentDataDirectory ( ) { RootDirectorySystem rootService = getCurrent ( ) ; if ( rootService == null ) throw new IllegalStateException ( L . l ( "{0} must be active for getCurrentDataDirectory()." , RootDirectorySystem . class . getSimpleName ( ) ) ) ; return rootService . dataDirectory ( ) ; }
Returns the data directory for current active directory service .
16,535
public static JournalStore create ( Path path , boolean isMmap ) throws IOException { long segmentSize = 4 * 1024 * 1024 ; JournalStore . Builder builder = JournalStore . Builder . create ( path ) ; builder . segmentSize ( segmentSize ) ; builder . mmap ( isMmap ) ; JournalStore store = builder . build ( ) ; return store ; }
Creates an independent store .
16,536
public static void clearJarCache ( ) { LruCache < PathImpl , Jar > jarCache = _jarCache ; if ( jarCache == null ) return ; ArrayList < Jar > jars = new ArrayList < Jar > ( ) ; synchronized ( jarCache ) { Iterator < Jar > iter = jarCache . values ( ) ; while ( iter . hasNext ( ) ) jars . add ( iter . next ( ) ) ; } for ( int i = 0 ; i < jars . size ( ) ; i ++ ) { Jar jar = jars . get ( i ) ; if ( jar != null ) jar . clearCache ( ) ; } }
Clears all the cached files in the jar . Needed to avoid some windows NT issues .
16,537
private Path keyStoreFile ( ) { String fileName = _config . get ( _prefix + ".ssl.key-store" ) ; if ( fileName == null ) { return null ; } return Vfs . path ( fileName ) ; }
Returns the certificate file .
16,538
private String keyStorePassword ( ) { String password = _config . get ( _prefix + ".ssl.key-store-password" ) ; if ( password != null ) { return password ; } else { return _config . get ( _prefix + ".ssl.password" ) ; } }
Returns the key - store password
16,539
private SSLSocketFactory createFactory ( ) throws Exception { SSLSocketFactory ssFactory = null ; String host = "localhost" ; int port = 8086 ; if ( _keyStore == null ) { return createAnonymousFactory ( null , port ) ; } SSLContext sslContext = SSLContext . getInstance ( _sslContext ) ; KeyManagerFactory kmf = KeyManagerFactory . getInstance ( keyManagerFactory ( ) ) ; kmf . init ( _keyStore , keyStorePassword ( ) . toCharArray ( ) ) ; sslContext . init ( kmf . getKeyManagers ( ) , null , null ) ; SSLEngine engine = sslContext . createSSLEngine ( ) ; _enabledProtocols = enabledProtocols ( engine . getEnabledProtocols ( ) ) ; engine . setEnabledProtocols ( _enabledProtocols ) ; ssFactory = sslContext . getSocketFactory ( ) ; return ssFactory ; }
Creates the SSLSocketFactory
16,540
public static InjectorImpl current ( ClassLoader loader ) { if ( loader instanceof DynamicClassLoader ) { return _localManager . getLevel ( loader ) ; } else { SoftReference < InjectorImpl > injectRef = _loaderManagerMap . get ( loader ) ; if ( injectRef != null ) { return injectRef . get ( ) ; } else { return null ; } } }
Returns the current inject manager .
16,541
public < T > T instance ( Class < T > type ) { Key < T > key = Key . of ( type ) ; return instance ( key ) ; }
Creates a new instance for a given type .
16,542
public < T > T instance ( Key < T > key ) { Objects . requireNonNull ( key ) ; Class < T > type = ( Class ) key . rawClass ( ) ; if ( type . equals ( Provider . class ) ) { TypeRef typeRef = TypeRef . of ( key . type ( ) ) ; TypeRef param = typeRef . param ( 0 ) ; return ( T ) provider ( Key . of ( param . type ( ) ) ) ; } Provider < T > provider = provider ( key ) ; if ( provider != null ) { return provider . get ( ) ; } else { return null ; } }
Creates a new instance for a given key .
16,543
public < T > T instance ( InjectionPoint < T > ip ) { Objects . requireNonNull ( ip ) ; Provider < T > provider = provider ( ip ) ; if ( provider != null ) { return provider . get ( ) ; } else { return null ; } }
Creates a new bean instance for a given InjectionPoint such as a method or field .
16,544
public < T > Provider < T > provider ( InjectionPoint < T > ip ) { Objects . requireNonNull ( ip ) ; Provider < T > provider = lookupProvider ( ip ) ; if ( provider != null ) { return provider ; } provider = autoProvider ( ip ) ; if ( provider != null ) { return provider ; } return new ProviderNull ( ip . key ( ) , - 10000 , new InjectScopeSingleton ( ) ) ; }
Creates an instance provider for a given InjectionPoint such as a method or field .
16,545
public < T > Provider < T > provider ( Key < T > key ) { Objects . requireNonNull ( key ) ; Provider < T > provider = ( Provider ) _providerMap . get ( key ) ; if ( provider == null ) { provider = lookupProvider ( key ) ; if ( provider == null ) { provider = autoProvider ( key ) ; } _providerMap . putIfAbsent ( key , provider ) ; provider = ( Provider ) _providerMap . get ( key ) ; } return provider ; }
Returns a bean instance provider for a key .
16,546
private < T > Provider < T > lookupProvider ( Key < T > key ) { BindingInject < T > bean = findBean ( key ) ; if ( bean != null ) { return bean . provider ( ) ; } BindingAmp < T > binding = findBinding ( key ) ; if ( binding != null ) { return binding . provider ( ) ; } binding = findObjectBinding ( key ) ; if ( binding != null ) { return binding . provider ( InjectionPoint . of ( key ) ) ; } return null ; }
Search for a matching provider for a key .
16,547
private < T > Provider < T > lookupProvider ( InjectionPoint < T > ip ) { Key < T > key = ip . key ( ) ; BindingInject < T > bean = findBean ( key ) ; if ( bean != null ) { return bean . provider ( ip ) ; } BindingAmp < T > provider = findBinding ( key ) ; if ( provider != null ) { return provider . provider ( ip ) ; } provider = findObjectBinding ( key ) ; if ( provider != null ) { return provider . provider ( ip ) ; } return null ; }
Create a provider for an injection point .
16,548
private < T > InjectScope < T > findScope ( AnnotatedElement annElement ) { for ( Annotation ann : annElement . getAnnotations ( ) ) { Class < ? extends Annotation > annType = ann . annotationType ( ) ; if ( annType . isAnnotationPresent ( Scope . class ) ) { Supplier < InjectScope < T > > scopeGen = ( Supplier ) _scopeMap . get ( annType ) ; if ( scopeGen != null ) { return scopeGen . get ( ) ; } else { log . fine ( L . l ( "@{0} is an unknown scope" , annType . getSimpleName ( ) ) ) ; } } } return new InjectScopeFactory < > ( ) ; }
Finds the scope for a bean producing declaration either a method or a type .
16,549
public < T > Iterable < Binding < T > > bindings ( Class < T > type ) { BindingSet < T > set = ( BindingSet ) _bindingSetMap . get ( type ) ; if ( set != null ) { return ( Iterable ) set ; } else { return Collections . EMPTY_LIST ; } }
Returns all bindings matching a type .
16,550
public < T > List < Binding < T > > bindings ( Key < T > key ) { BindingSet < T > set = ( BindingSet ) _bindingSetMap . get ( key . rawClass ( ) ) ; if ( set != null ) { return set . bindings ( key ) ; } else { return Collections . EMPTY_LIST ; } }
Returns all bindings matching a key .
16,551
< T > InjectScope < T > scope ( Class < ? extends Annotation > scopeType ) { Supplier < InjectScope < T > > scopeGen = ( Supplier ) _scopeMap . get ( scopeType ) ; if ( scopeGen == null ) { throw error ( "{0} is an unknown scope" , scopeType . getSimpleName ( ) ) ; } return scopeGen . get ( ) ; }
Returns the scope given a scope annotation .
16,552
public < T > Consumer < T > injector ( Class < T > type ) { ArrayList < InjectProgram > injectList = new ArrayList < > ( ) ; introspectInject ( injectList , type ) ; introspectInit ( injectList , type ) ; return new InjectProgramImpl < T > ( injectList ) ; }
Create an injector for a bean type . The consumer will inject the bean s fields .
16,553
public Provider < ? > [ ] program ( Parameter [ ] params ) { Provider < ? > [ ] program = new Provider < ? > [ params . length ] ; for ( int i = 0 ; i < program . length ; i ++ ) { program [ i ] = provider ( InjectionPoint . of ( params [ i ] ) ) ; } return program ; }
Create a program for method arguments .
16,554
private < T > BindingInject < T > findBean ( Key < T > key ) { for ( InjectProvider provider : _providerList ) { BindingInject < T > bean = ( BindingInject ) provider . lookup ( key . rawClass ( ) ) ; if ( bean != null ) { return bean ; } } return null ; }
Find a binding by the key .
16,555
private < T > BindingAmp < T > findObjectBinding ( Key < T > key ) { Objects . requireNonNull ( key ) ; if ( key . qualifiers ( ) . length != 1 ) { throw new IllegalArgumentException ( ) ; } return ( BindingAmp ) findBinding ( Key . of ( Object . class , key . qualifiers ( ) [ 0 ] ) ) ; }
Returns an object producer .
16,556
private < T > BindingAmp < T > findBinding ( Key < T > key ) { BindingSet < T > set = ( BindingSet ) _bindingSetMap . get ( key . rawClass ( ) ) ; if ( set != null ) { BindingAmp < T > binding = set . find ( key ) ; if ( binding != null ) { return binding ; } } return null ; }
Finds a producer for the given target type .
16,557
public void setLevel ( Level level ) { _level = level ; if ( level . intValue ( ) < _lowLevel . intValue ( ) ) _lowLevel = level ; }
Sets the lifecycle logging level .
16,558
public boolean waitForActive ( long timeout ) { LifecycleState state = getState ( ) ; if ( state . isActive ( ) ) { return true ; } else if ( state . isAfterActive ( ) ) { return false ; } long waitEnd = CurrentTime . getCurrentTimeActual ( ) + timeout ; synchronized ( this ) { while ( ( state = _state ) . isBeforeActive ( ) && CurrentTime . getCurrentTimeActual ( ) < waitEnd ) { if ( state . isActive ( ) ) { return true ; } else if ( state . isAfterActive ( ) ) { return false ; } try { long delta = waitEnd - CurrentTime . getCurrentTimeActual ( ) ; if ( delta > 0 ) { wait ( delta ) ; } } catch ( InterruptedException e ) { } } } return _state . isActive ( ) ; }
Wait for a period of time until the service starts .
16,559
public boolean toPostInit ( ) { synchronized ( this ) { if ( _state == STOPPED ) { _state = INIT ; _lastChangeTime = CurrentTime . currentTime ( ) ; notifyListeners ( STOPPED , INIT ) ; return true ; } else { return _state . isInit ( ) ; } } }
Changes to the init from the stopped state .
16,560
public boolean toStarting ( ) { LifecycleState state ; synchronized ( this ) { state = _state ; if ( state . isAfterStarting ( ) && ! state . isStopped ( ) ) { return false ; } _state = STARTING ; _lastChangeTime = CurrentTime . currentTime ( ) ; if ( _log != null && _log . isLoggable ( _level ) && _log . isLoggable ( Level . FINER ) ) { _log . finer ( "starting " + _name ) ; } } notifyListeners ( state , STARTING ) ; return true ; }
Changes to the starting state .
16,561
public boolean toActive ( ) { LifecycleState state ; synchronized ( this ) { state = _state ; if ( state . isAfterActive ( ) && ! state . isStopped ( ) ) { return false ; } _state = ACTIVE ; _lastChangeTime = CurrentTime . currentTime ( ) ; } if ( _log != null && _log . isLoggable ( _level ) ) _log . log ( _level , "active " + _name ) ; notifyListeners ( state , ACTIVE ) ; return true ; }
Changes to the active state .
16,562
public boolean toFail ( ) { LifecycleState state ; synchronized ( this ) { state = _state ; if ( state . isAfterDestroying ( ) ) { return false ; } _state = FAILED ; _lastChangeTime = CurrentTime . currentTime ( ) ; } if ( _log != null && _log . isLoggable ( _level ) ) _log . log ( _level , "fail " + _name ) ; notifyListeners ( state , FAILED ) ; _failCount ++ ; return true ; }
Changes to the failed state .
16,563
public boolean toStopping ( ) { LifecycleState state ; synchronized ( this ) { state = _state ; if ( state . isAfterStopping ( ) || state . isStarting ( ) ) { return false ; } _state = STOPPING ; _lastChangeTime = CurrentTime . currentTime ( ) ; } if ( _log != null && _log . isLoggable ( _level ) ) { _log . log ( _level , "stopping " + _name ) ; } notifyListeners ( state , STOPPING ) ; return true ; }
Changes to the stopping state .
16,564
public void addListener ( LifecycleListener listener ) { synchronized ( this ) { if ( isDestroyed ( ) ) { IllegalStateException e = new IllegalStateException ( "attempted to add listener to a destroyed lifecyle " + this ) ; if ( _log != null ) _log . log ( Level . WARNING , e . toString ( ) , e ) ; else Logger . getLogger ( Lifecycle . class . getName ( ) ) . log ( Level . WARNING , e . toString ( ) , e ) ; return ; } if ( _listeners == null ) _listeners = new ArrayList < WeakReference < LifecycleListener > > ( ) ; for ( int i = _listeners . size ( ) - 1 ; i >= 0 ; i -- ) { LifecycleListener oldListener = _listeners . get ( i ) . get ( ) ; if ( listener == oldListener ) return ; else if ( oldListener == null ) _listeners . remove ( i ) ; } _listeners . add ( new WeakReference < LifecycleListener > ( listener ) ) ; } }
Adds a listener to detect lifecycle changes .
16,565
public String serialize ( Object obj ) throws JsonMarshallingException { try { return serializeChecked ( obj ) ; } catch ( Exception e ) { throw new JsonMarshallingException ( e ) ; } }
Serialize the given Java object into JSON string .
16,566
public void setExecutorTaskMax ( int max ) { if ( getThreadMax ( ) < max ) throw new ConfigException ( L . l ( "<thread-executor-max> ({0}) must be less than <thread-max> ({1})" , max , getThreadMax ( ) ) ) ; if ( max == 0 ) throw new ConfigException ( L . l ( "<thread-executor-max> must not be zero." ) ) ; _executorTaskMax = max ; }
Sets the maximum number of executor threads .
16,567
public boolean scheduleExecutorTask ( Runnable task ) { ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; synchronized ( _executorLock ) { _executorTaskCount ++ ; if ( _executorTaskCount <= _executorTaskMax || _executorTaskMax < 0 ) { boolean isPriority = false ; boolean isQueue = true ; boolean isWake = true ; return scheduleImpl ( task , loader , MAX_EXPIRE , isPriority , isQueue , isWake ) ; } else { ExecutorQueueItem item = new ExecutorQueueItem ( task , loader ) ; if ( _executorQueueTail != null ) _executorQueueTail . _next = item ; else _executorQueueHead = item ; _executorQueueTail = item ; return false ; } } }
Schedules an executor task .
16,568
public void completeExecutorTask ( ) { ExecutorQueueItem item = null ; synchronized ( _executorLock ) { _executorTaskCount -- ; assert ( _executorTaskCount >= 0 ) ; if ( _executorQueueHead != null ) { item = _executorQueueHead ; _executorQueueHead = item . _next ; if ( _executorQueueHead == null ) _executorQueueTail = null ; } } if ( item != null ) { Runnable task = item . getRunnable ( ) ; ClassLoader loader = item . getLoader ( ) ; boolean isPriority = false ; boolean isQueue = true ; boolean isWake = true ; scheduleImpl ( task , loader , MAX_EXPIRE , isPriority , isQueue , isWake ) ; } }
Called when an executor task completes
16,569
public Offering getOffering ( String offeringName ) { BasicDBObject query = new BasicDBObject ( "offering_name" , offeringName ) ; FindIterable < Document > cursor = this . offeringsCollection . find ( query ) ; return Offering . fromDB ( cursor . first ( ) ) ; }
Get an offering
16,570
public String addOffering ( Offering offering ) { this . offeringsCollection . insertOne ( offering . toDBObject ( ) ) ; this . offeringNames . add ( offering . getName ( ) ) ; return offering . getName ( ) ; }
Add a new offering in the repository
16,571
public boolean removeOffering ( String offeringName ) { if ( offeringName == null ) throw new NullPointerException ( "The parameter \"cloudOfferingId\" cannot be null." ) ; BasicDBObject query = new BasicDBObject ( "offering_name" , offeringName ) ; Document removedOffering = this . offeringsCollection . findOneAndDelete ( query ) ; return removedOffering != null ; }
Remove an offering
16,572
public void initializeOfferings ( ) { FindIterable < Document > offerings = this . offeringsCollection . find ( ) ; for ( Document d : offerings ) { offeringNames . add ( ( String ) d . get ( "offering_name" ) ) ; } }
Initialize the list of offerings known by the discoverer
16,573
public void generateSingleOffering ( String offeringNodeTemplates ) { this . removeOffering ( "0" ) ; Offering singleOffering = new Offering ( "all" ) ; singleOffering . toscaString = offeringNodeTemplates ; this . addOffering ( singleOffering ) ; }
Generates a single offering file containing all node templates fetched
16,574
public JClass getSuperClass ( ) { lazyLoad ( ) ; if ( _superClass == null ) return null ; else return getClassLoader ( ) . forName ( _superClass . replace ( '/' , '.' ) ) ; }
Gets the super class name .
16,575
public void addInterface ( String className ) { _interfaces . add ( className ) ; if ( _isWrite ) getConstantPool ( ) . addClass ( className ) ; }
Adds an interface .
16,576
public JClass [ ] getInterfaces ( ) { lazyLoad ( ) ; JClass [ ] interfaces = new JClass [ _interfaces . size ( ) ] ; for ( int i = 0 ; i < _interfaces . size ( ) ; i ++ ) { String name = _interfaces . get ( i ) ; name = name . replace ( '/' , '.' ) ; interfaces [ i ] = getClassLoader ( ) . forName ( name ) ; } return interfaces ; }
Gets the interfaces .
16,577
public JavaField getField ( String name ) { ArrayList < JavaField > fieldList = getFieldList ( ) ; for ( int i = 0 ; i < fieldList . size ( ) ; i ++ ) { JavaField field = fieldList . get ( i ) ; if ( field . getName ( ) . equals ( name ) ) return field ; } return null ; }
Returns a fields .
16,578
public JavaMethod getMethod ( String name ) { ArrayList < JavaMethod > methodList = getMethodList ( ) ; for ( int i = 0 ; i < methodList . size ( ) ; i ++ ) { JavaMethod method = methodList . get ( i ) ; if ( method . getName ( ) . equals ( name ) ) return method ; } return null ; }
Returns a method .
16,579
public JavaMethod findMethod ( String name , String descriptor ) { ArrayList < JavaMethod > methodList = getMethodList ( ) ; for ( int i = 0 ; i < methodList . size ( ) ; i ++ ) { JavaMethod method = methodList . get ( i ) ; if ( method . getName ( ) . equals ( name ) && method . getDescriptor ( ) . equals ( descriptor ) ) return method ; } return null ; }
Finds a method .
16,580
public JField [ ] getDeclaredFields ( ) { ArrayList < JavaField > fieldList = getFieldList ( ) ; JField [ ] fields = new JField [ fieldList . size ( ) ] ; fieldList . toArray ( fields ) ; return fields ; }
Returns the array of declared fields .
16,581
public JField [ ] getFields ( ) { ArrayList < JField > fieldList = new ArrayList < JField > ( ) ; getFields ( fieldList ) ; JField [ ] fields = new JField [ fieldList . size ( ) ] ; fieldList . toArray ( fields ) ; return fields ; }
Returns the array of fields .
16,582
private void getFields ( ArrayList < JField > fieldList ) { for ( JField field : getDeclaredFields ( ) ) { if ( ! fieldList . contains ( field ) ) fieldList . add ( field ) ; } if ( getSuperClass ( ) != null ) { for ( JField field : getSuperClass ( ) . getFields ( ) ) { if ( ! fieldList . contains ( field ) ) fieldList . add ( field ) ; } } }
Returns all the fields
16,583
private void lazyLoad ( ) { if ( _major > 0 ) return ; try { if ( _url == null ) throw new IllegalStateException ( ) ; try ( InputStream is = _url . openStream ( ) ) { _major = 1 ; ByteCodeParser parser = new ByteCodeParser ( ) ; parser . setClassLoader ( _loader ) ; parser . setJavaClass ( this ) ; parser . parse ( is ) ; } } catch ( RuntimeException e ) { throw e ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
Lazily load the class .
16,584
public void write ( OutputStream os ) throws IOException { ByteCodeWriter out = new ByteCodeWriter ( os , this ) ; out . writeInt ( MAGIC ) ; out . writeShort ( _minor ) ; out . writeShort ( _major ) ; _constantPool . write ( out ) ; out . writeShort ( _accessFlags ) ; out . writeClass ( _thisClass ) ; out . writeClass ( _superClass ) ; out . writeShort ( _interfaces . size ( ) ) ; for ( int i = 0 ; i < _interfaces . size ( ) ; i ++ ) { String className = _interfaces . get ( i ) ; out . writeClass ( className ) ; } out . writeShort ( _fields . size ( ) ) ; for ( int i = 0 ; i < _fields . size ( ) ; i ++ ) { JavaField field = _fields . get ( i ) ; field . write ( out ) ; } out . writeShort ( _methods . size ( ) ) ; for ( int i = 0 ; i < _methods . size ( ) ; i ++ ) { JavaMethod method = _methods . get ( i ) ; method . write ( out ) ; } out . writeShort ( _attributes . size ( ) ) ; for ( int i = 0 ; i < _attributes . size ( ) ; i ++ ) { Attribute attr = _attributes . get ( i ) ; attr . write ( out ) ; } }
Writes the class to the output .
16,585
public final I getInvocation ( Object protocolKey ) { I invocation = null ; LruCache < Object , I > invocationCache = _invocationCache ; if ( invocationCache != null ) { invocation = invocationCache . get ( protocolKey ) ; } if ( invocation == null ) { return null ; } else if ( invocation . isModified ( ) ) { return null ; } else { return invocation ; } }
Returns the cached invocation .
16,586
public I buildInvocation ( Object protocolKey , I invocation ) throws ConfigException { Objects . requireNonNull ( invocation ) ; invocation = buildInvocation ( invocation ) ; LruCache < Object , I > invocationCache = _invocationCache ; if ( invocationCache != null ) { I oldInvocation ; oldInvocation = invocationCache . get ( protocolKey ) ; if ( oldInvocation != null && ! oldInvocation . isModified ( ) ) { return oldInvocation ; } if ( invocation . getURLLength ( ) < _maxURLLength ) { invocationCache . put ( protocolKey , invocation ) ; } } return invocation ; }
Builds the invocation saving its value keyed by the protocol key .
16,587
public void clearCache ( ) { LruCache < Object , I > invocationCache = _invocationCache ; if ( invocationCache != null ) { invocationCache . clear ( ) ; } }
Clears the invocation cache .
16,588
public ArrayList < I > getInvocations ( ) { LruCache < Object , I > invocationCache = _invocationCache ; ArrayList < I > invocationList = new ArrayList < > ( ) ; synchronized ( invocationCache ) { Iterator < I > iter ; iter = invocationCache . values ( ) ; while ( iter . hasNext ( ) ) { invocationList . add ( iter . next ( ) ) ; } } return invocationList ; }
Returns the invocations .
16,589
private void loadManifest ( ) { if ( _isManifestRead ) return ; synchronized ( this ) { if ( _isManifestRead ) return ; try { _manifest = _jarPath . getManifest ( ) ; if ( _manifest == null ) return ; Attributes attr = _manifest . getMainAttributes ( ) ; if ( attr != null ) addManifestPackage ( "" , attr ) ; Map < String , Attributes > entries = _manifest . getEntries ( ) ; for ( Map . Entry < String , Attributes > entry : entries . entrySet ( ) ) { String pkg = entry . getKey ( ) ; attr = entry . getValue ( ) ; if ( attr == null ) continue ; addManifestPackage ( pkg , attr ) ; } } catch ( IOException e ) { log . log ( Level . WARNING , e . toString ( ) , e ) ; } finally { _isManifestRead = true ; } } }
Reads the jar s manifest .
16,590
private void addManifestPackage ( String name , Attributes attr ) { if ( ! name . endsWith ( "/" ) && ! name . equals ( "" ) ) return ; String specTitle = attr . getValue ( "Specification-Title" ) ; String specVersion = attr . getValue ( "Specification-Version" ) ; String specVendor = attr . getValue ( "Specification-Vendor" ) ; String implTitle = attr . getValue ( "Implementation-Title" ) ; String implVersion = attr . getValue ( "Implementation-Version" ) ; String implVendor = attr . getValue ( "Implementation-Vendor" ) ; if ( specTitle == null && specVersion == null && specVendor != null && implTitle == null && implVersion == null && implVendor != null ) return ; ClassPackage pkg = new ClassPackage ( name ) ; pkg . setSpecificationTitle ( specTitle ) ; pkg . setSpecificationVersion ( specVersion ) ; pkg . setSpecificationVendor ( specVendor ) ; pkg . setImplementationTitle ( implTitle ) ; pkg . setImplementationVersion ( implVersion ) ; pkg . setImplementationVendor ( implVendor ) ; _packages . add ( pkg ) ; }
Adds package information from the manifest .
16,591
public void validate ( ) throws ConfigException { loadManifest ( ) ; if ( _manifest != null ) validateManifest ( _jarPath . getContainer ( ) . getURL ( ) , _manifest ) ; }
Validates the jar .
16,592
public static void validateManifest ( String manifestName , Manifest manifest ) throws ConfigException { Attributes attr = manifest . getMainAttributes ( ) ; if ( attr == null ) return ; String extList = attr . getValue ( "Extension-List" ) ; if ( extList == null ) return ; Pattern pattern = Pattern . compile ( "[, \t]+" ) ; String [ ] split = pattern . split ( extList ) ; for ( int i = 0 ; i < split . length ; i ++ ) { String ext = split [ i ] ; String name = attr . getValue ( ext + "-Extension-Name" ) ; if ( name == null ) continue ; Package pkg = Package . getPackage ( name ) ; if ( pkg == null ) { log . warning ( L . l ( "package {0} is missing. {1} requires package {0}." , name , manifestName ) ) ; continue ; } String version = attr . getValue ( ext + "-Specification-Version" ) ; if ( version == null ) continue ; if ( pkg . getSpecificationVersion ( ) == null || pkg . getSpecificationVersion ( ) . equals ( "" ) ) { log . warning ( L . l ( "installed {0} is not compatible with version `{1}'. {2} requires version {1}." , name , version , manifestName ) ) ; } else if ( ! pkg . isCompatibleWith ( version ) ) { log . warning ( L . l ( "installed {0} is not compatible with version `{1}'. {2} requires version {1}." , name , version , manifestName ) ) ; } } }
Validates the manifest .
16,593
public CodeSource getCodeSource ( String path ) { try { PathImpl jarPath = _jarPath . lookup ( path ) ; Certificate [ ] certificates = jarPath . getCertificates ( ) ; URL url = new URL ( _jarPath . getContainer ( ) . getURL ( ) ) ; return new CodeSource ( url , certificates ) ; } catch ( Exception e ) { log . log ( Level . WARNING , e . toString ( ) , e ) ; return null ; } }
Returns the code source .
16,594
public GuaranteeTermEvaluationResult evaluate ( IAgreement agreement , IGuaranteeTerm term , List < IMonitoringMetric > metrics , Date now ) { checkInitialized ( ) ; logger . debug ( "evaluate(agreement={}, term={}, now={})" , agreement . getAgreementId ( ) , term . getKpiName ( ) , now ) ; final List < IViolation > violations = serviceLevelEval . evaluate ( agreement , term , metrics , now ) ; logger . debug ( "Found " + violations . size ( ) + " violations" ) ; final List < ? extends ICompensation > compensations = businessEval . evaluate ( agreement , term , violations , now ) ; logger . debug ( "Found " + compensations . size ( ) + " compensations" ) ; GuaranteeTermEvaluationResult result = new GuaranteeTermEvaluationResult ( violations , compensations ) ; return result ; }
Evaluate violations and penalties for a given guarantee term and a list of metrics .
16,595
public int read ( byte [ ] buf , int offset , int len ) throws IOException { int available = _available ; if ( available > 0 ) { len = Math . min ( len , available ) ; len = _next . read ( buf , offset , len ) ; if ( len > 0 ) { _available -= len ; } } else if ( available == 0 ) { _available = readChunkLength ( ) ; if ( _available > 0 ) { len = Math . min ( len , _available ) ; len = _next . read ( buf , offset , len ) ; if ( len > 0 ) _available -= len ; } else { _available = - 1 ; len = - 1 ; } } else { len = - 1 ; } return len ; }
Reads more data from the input stream .
16,596
private int readChunkLength ( ) throws IOException { int length = 0 ; int ch ; ReadStream is = _next ; for ( ch = is . read ( ) ; ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n' ; ch = is . read ( ) ) { } for ( ; ch > 0 && ch != '\r' && ch != '\n' ; ch = is . read ( ) ) { if ( '0' <= ch && ch <= '9' ) length = 16 * length + ch - '0' ; else if ( 'a' <= ch && ch <= 'f' ) length = 16 * length + ch - 'a' + 10 ; else if ( 'A' <= ch && ch <= 'F' ) length = 16 * length + ch - 'A' + 10 ; else if ( ch == ' ' || ch == '\t' ) { } else { StringBuilder sb = new StringBuilder ( ) ; sb . append ( ( char ) ch ) ; for ( int ch1 = is . read ( ) ; ch1 >= 0 && ch1 != '\r' && ch1 != '\n' ; ch1 = is . read ( ) ) { sb . append ( ( char ) ch1 ) ; } throw new IOException ( "HTTP/1.1 protocol error: bad chunk at" + " '" + sb + "'" + " 0x" + Integer . toHexString ( ch ) + " length=" + length ) ; } } if ( ch == '\r' ) ch = is . read ( ) ; return length ; }
Reads the next chunk length from the input stream .
16,597
private String getSlaUrl ( String envSlaUrl , UriInfo uriInfo ) { String baseUrl = uriInfo . getBaseUri ( ) . toString ( ) ; if ( envSlaUrl == null ) { envSlaUrl = "" ; } String result = ( "" . equals ( envSlaUrl ) ) ? baseUrl : envSlaUrl ; logger . debug ( "getSlaUrl(env={}, supplied={}) = {}" , envSlaUrl , baseUrl , result ) ; return result ; }
Returns base url of the sla core .
16,598
private String getMetricsBaseUrl ( String suppliedBaseUrl , String envBaseUrl ) { String result = ( "" . equals ( suppliedBaseUrl ) ) ? envBaseUrl : suppliedBaseUrl ; logger . debug ( "getMetricsBaseUrl(env={}, supplied={}) = {}" , envBaseUrl , suppliedBaseUrl , result ) ; return result ; }
Return base url of the metrics endpoint of the Monitoring Platform .
16,599
public int read ( byte [ ] buffer , int offset , int length ) throws IOException { return _stream . read ( buffer , offset , length ) ; }
Reads a buffer to the underlying stream .