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...
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 = _seg...
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 ...
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 ...
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 keyOff...
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 &...
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 = va...
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 ,...
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...
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 -= subl...
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 ( ) ; } els...
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 - _...
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 ...
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 ) ; } ca...
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 =...
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 . getSim...
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 ) ; re...
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 . writ...
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_SIZ...
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 sto...
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 ...
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 = KeyManag...
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 ( ) ) )...
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 ( ) , - 1...
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 , p...
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 ( bindin...
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 ) ; }...
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 ) _scop...
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 ) . isBeforeActi...
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 ( ...
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 , "ac...
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 ) ; notifyLi...
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 ( _leve...
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 . getLog...
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." ) ) ; _executorTa...
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 ; boo...
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 = ...
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 . findOneAndDele...
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 i...
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...
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...
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...
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...
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 nu...
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 ...
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 . ne...
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 < Stri...
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-V...
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]...
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 ( Lev...
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 > vi...
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 ...
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 *...
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 , ...
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 .