returns the { @ link type } corresponding to the response headers provided

public static int infer file type from response headers ( map < string , list < string > > response headers ) { @ nullable list < string > content types = response headers get ( header content type ) ; @ nullable string mime type = content types = = null | | content types is empty ( ) ? null : content types get ( 0 ) ; return infer file type from mime type ( mime type ) ; }


if receive a frame with end - of - stream set , send a pre - canned response

private static void on data read ( channel handler context ctx , http 2 data frame data ) throws exception { if ( data is end stream ( ) ) { send response ( ctx , data content ( ) ) ; } else { / / we do not send back the response to the remote - peer , so we need to release it data release ( ) ; } }


{ @ inherit doc } < b > note : < b > this tests exact equality of the calculated statistics , including the floating point values two instances are guaranteed to be considered equal if one is copied from the other using { @ code second = new paired stats accumulator ( ) add all ( first ) snapshot ( ) } , if both were obtained by calling { @ code snapshot ( ) } on the same { @ link paired stats accumulator } without adding any values in between the two calls , or if one is obtained from the other after round - tripping through java serialization however , floating point rounding errors mean that it may be false for some instances where the statistics are mathematically equal , including instances constructed from the same values in a different order or ( in the general case ) even in the same order ( it is guaranteed to return true for instances constructed from the same values in the same order if { @ code strictfp } is in effect , or if the system architecture guarantees { @ code strictfp } - like semantics )

public boolean equals ( @ nullable decl object obj ) { if ( obj = = null ) { return false ; } if ( get class ( ) ! = obj get class ( ) ) { return false ; } paired stats other = ( paired stats ) obj ; return x stats equals ( other x stats ) & & y stats equals ( other y stats ) & & double to long bits ( sum of products of deltas ) = = double to long bits ( other sum of products of deltas ) ; }


set the color that indicates gaps in memory

void set separator color ( color c ) { index factory set missing value color ( c ) ; for ( int i = 0 ; i < view list size ( ) ; i + + ) { byte viewer component comp = view list get ( i ) ; comp set separator color ( c ) ; } }


return the element in this set which is equal to the given key , if such an element exists otherwise returns null

public t get element ( final t key ) { / / validate key if ( key = = null ) { throw new illegal argument exception ( " null element is not supported " ) ; } / / find element final int hash code = key hash code ( ) ; final int index = get index ( hash code ) ; return get contained elem ( index , key , hash code ) ; }


test an async flowable that emits more async observables

public void nested async concat ( ) throws interrupted exception { subscriber < string > subscriber = test helper mock subscriber ( ) ; final test observable < string > o 1 = new test observable < > ( " one " , " two " , " three " ) ; final test observable < string > o 2 = new test observable < > ( " four " , " five " , " six " ) ; final test observable < string > o 3 = new test observable < > ( " seven " , " eight " , " nine " ) ; final count down latch allow third = new count down latch ( 1 ) ; final atomic reference < thread > parent = new atomic reference < > ( ) ; final count down latch parent has started = new count down latch ( 1 ) ; final count down latch parent has finished = new count down latch ( 1 ) ; flowable < flowable < string > > observable of observables = flowable unsafe create ( new publisher < flowable < string > > ( ) { @ override public void subscribe ( final subscriber < ? super flowable < string > > subscriber ) { final disposable d = disposable empty ( ) ; subscriber on subscribe ( new subscription ( ) { @ override public void request ( long n ) { } @ override public void cancel ( ) { d dispose ( ) ; } } ) ; parent set ( new thread ( new runnable ( ) { @ override public void run ( ) { try { / / emit first if ( ! d is disposed ( ) ) { system out println ( " emit o 1 " ) ; subscriber on next ( flowable unsafe create ( o 1 ) ) ; } / / emit second if ( ! d is disposed ( ) ) { system out println ( " emit o 2 " ) ; subscriber on next ( flowable unsafe create ( o 2 ) ) ; } / / wait until sometime later and emit third try { allow third await ( ) ; } catch ( interrupted exception e ) { subscriber on error ( e ) ; } if ( ! d is disposed ( ) ) { system out println ( " emit o 3 " ) ; subscriber on next ( flowable unsafe create ( o 3 ) ) ; } } catch ( throwable e ) { subscriber on error ( e ) ; } finally { system out println ( " done parent flowable " ) ; subscriber on complete ( ) ; parent has finished count down ( ) ; } } } ) ) ; parent get ( ) start ( ) ; parent has started count down ( ) ; } } ) ; flowable concat ( observable of observables ) subscribe ( subscriber ) ; / / wait for parent to start parent has started await ( ) ; try { / / wait for first 2 async observables to complete system out println ( " thread 1 is starting waiting for it to complete " ) ; o 1 wait for thread done ( ) ; system out println ( " thread 2 is starting waiting for it to complete " ) ; o 2 wait for thread done ( ) ; } catch ( throwable e ) { throw new runtime exception ( " failed waiting on threads " , e ) ; } in order in order = in order ( subscriber ) ; in order verify ( subscriber , times ( 1 ) ) on next ( " one " ) ; in order verify ( subscriber , times ( 1 ) ) on next ( " two " ) ; in order verify ( subscriber , times ( 1 ) ) on next ( " three " ) ; in order verify ( subscriber , times ( 1 ) ) on next ( " four " ) ; in order verify ( subscriber , times ( 1 ) ) on next ( " five " ) ; in order verify ( subscriber , times ( 1 ) ) on next ( " six " ) ; / / we shouldn ' t have the following 3 yet in order verify ( subscriber , never ( ) ) on next ( " seven " ) ; in order verify ( subscriber , never ( ) ) on next ( " eight " ) ; in order verify ( subscriber , never ( ) ) on next ( " nine " ) ; / / we should not be completed yet verify ( subscriber , never ( ) ) on complete ( ) ; verify ( subscriber , never ( ) ) on error ( any ( throwable class ) ) ; / / now allow the third allow third count down ( ) ; try { / / wait for 3rd to complete o 3 wait for thread done ( ) ; } catch ( throwable e ) { throw new runtime exception ( " failed waiting on threads " , e ) ; } try { / / wait for the parent to complete if ( ! parent has finished await ( 5 , time unit seconds ) ) { fail ( " parent didn ' t finish within the time limit " ) ; } } catch ( throwable e ) { throw new runtime exception ( " failed waiting on threads " , e ) ; } in order verify ( subscriber , times ( 1 ) ) on next ( " seven " ) ; in order verify ( subscriber , times ( 1 ) ) on next ( " eight " ) ; in order verify ( subscriber , times ( 1 ) ) on next ( " nine " ) ; verify ( subscriber , never ( ) ) on error ( any ( throwable class ) ) ; in order verify ( subscriber , times ( 1 ) ) on complete ( ) ; }


public action analysis metadata get action ( ) { return action ; }


set the non - stack variable info for the function

private void set non stack var info ( variable [ ] vars ) { int variable index = 0 ; for ( int i = 0 ; i < vars length ; i + + ) { if ( vars [ i ] is stack variable ( ) ) { continue ; / / skip stack variables } var names [ variable index ] = vars [ i ] get name ( ) ; var sources [ variable index ] = vars [ i ] get source ( ) ; varnode first varnode = vars [ i ] get first storage varnode ( ) ; var addrs [ variable index ] = first varnode ! = null ? first varnode get address ( ) : address no address ; var f u offsets [ variable index ] = vars [ i ] get first use offset ( ) ; var comments [ variable index ] = vars [ i ] get comment ( ) ; + + variable index ; } } / / / / private void write object ( object output stream oos ) throws i o exception { / / / / write out all of the serializable objects / / oos default write object ( ) ; / / / / / / now write out the non - serializable variables ( the ones we ' ve marked as ' transient ' ) / / oos write int ( var addrs length ) ; / / for ( address address : var addrs ) { / / address space address space = address get address space ( ) ; / / string space name = address space get name ( ) ; / / oos write chars ( space name ) ; / / / / int space size = address space get size ( ) ; / / oos write int ( space size ) ; / / / / int space unit size = address space get addressable unit size ( ) ; / / oos write int ( space unit size ) ; / / / / int space type = address space get type ( ) ; / / oos write int ( space type ) ; / / / / int space unique value = address space get unique ( ) ; / / oos write int ( space unique value ) ; / / / / long address offset = address get offset ( ) ; / / oos write long ( address offset ) ; / / } / / } / / / / private void read object ( object input stream ois ) throws i o exception , class not found exception { / / / / read in all of the serializable objects / / ois default read object ( ) ; / / / / / / now read in the non - serializable variables ( the ones we ' ve marked as ' transient ' ) / / int var addrs size = ois read int ( ) ; / / if ( var addrs size = = 0 ) { / / var addrs = empty addr array ; / / } / / else { / / var addrs = new address [ var addrs size ] ; / / for ( int i = 0 ; i < var addrs size ; i + + ) { / / string space name = ois read u t f ( ) ; / / int space size = ois read int ( ) ; / / int space unit size = ois read int ( ) ; / / int space type = ois read int ( ) ; / / int space unique value = ois read int ( ) ; / / long address offset = ois read long ( ) ; / / / / generic address space address space = new generic address space ( space name , / / space size , space unit size , space type , space unique value ) ; / / var addrs [ i ] = address space get address ( address offset ) ; / / } / / } / / }


public < t > t execute ( function < response , t > handler ) { return handler apply ( rest assured given ( ) spec ( req spec build ( ) ) expect ( ) spec ( resp spec build ( ) ) when ( ) request ( req method , req uri ) ) ; }


restores the given filtered vertices into the graph this will only happen if both endpoints are in the graph

public void unfilter vertices ( collection < v > to unfilter ) { maybe restore vertices ( to unfilter ) ; maybe restore related edges ( to unfilter ) ; }


public table statistics get statistics ( ) throws i o exception { synchronized ( db ) { table statistics stats = new table statistics ( ) ; stats name = get name ( ) ; try { accumulate node statistics ( stats , root buffer id ) ; stats size = stats buffer count * node mgr get buffer mgr ( ) get buffer size ( ) ; } finally { node mgr release nodes ( ) ; } return stats ; } }


gets the object that coordinates the workspace allocation on this computer

public workspace list get workspace list ( ) { return workspace list ; }


gets the value type of the given map type does not validate that the given type is a map

public static type get value type ( type type ) { return type get type parameters ( ) get ( 1 ) ; }


returns whether this node is a leader node


return the bitmap with image watermarking

public static bitmap add image watermark ( final bitmap src , final bitmap watermark , final int x , final int y , final int alpha ) { return add image watermark ( src , watermark , x , y , alpha , false ) ; }


test the property ' name wrapped array '

public void name wrapped array test ( ) { / / todo : test name wrapped array }


simple pattern match to determine whether an ip should be checked could stand to be extended to support " real " ip addresses and patterns , but for the local first implementation regex made more sense

protected boolean ip pattern matches ( final string remote ip ) { val matcher = this ips to check pattern matcher ( remote ip ) ; if ( matcher find ( ) ) { logger debug ( " remote ip address [ { } ] should be checked based on the defined pattern [ { } ] " , remote ip , this ips to check pattern pattern ( ) ) ; return true ; } logger debug ( " no pattern or remote ip defined , or pattern does not match remote ip [ { } ] " , remote ip ) ; return false ; }


returns the value of a request parsed parameter

public < v , t extends param < v > > v get ( string name , class < t > klass ) { list < param < ? > > multi params = ( list < param < ? > > ) params get ( name ) ; if ( multi params ! = null & & multi params size ( ) > 0 ) { return ( ( t ) multi params get ( 0 ) ) value ( ) ; / / return first value ; } return null ; }


get the name of the catalog for this context

public string get catalog name ( ) { return this catalog name ; }


stop tracking a slot must be called with the endpoint shm manager lock held

void free slot ( slot slot ) { dfs client shm shm = ( dfs client shm ) slot get shm ( ) ; shm unregister slot ( slot get slot idx ( ) ) ; if ( shm is disconnected ( ) ) { / / stale shared memory segments should not be tracked here preconditions check state ( ! full contains key ( shm get shm id ( ) ) ) ; preconditions check state ( ! not full contains key ( shm get shm id ( ) ) ) ; if ( shm is empty ( ) ) { log trace ( " { } : freeing empty stale { } " , this , shm ) ; shm free ( ) ; } } else { shm id shm id = shm get shm id ( ) ; full remove ( shm id ) ; / / the shm can ' t be full if we just freed a slot if ( shm is empty ( ) ) { not full remove ( shm id ) ; / / if the shared memory segment is now empty , we call shutdown ( 2 ) on / / the unix domain socket associated with it the domain socket watcher , / / which is watching this socket , will call dfs client shm # handle , / / cleaning up this shared memory segment / / / / see # { dfs client shm manager # domain socket watcher } for details about why / / we don ' t want to call domain socket watcher # remove directly here / / / / note that we could experience ' fragmentation ' here , where the / / d f s client allocates a bunch of slots in different shared memory / / segments , and then frees most of them , but never fully empties out / / any segment we make some attempt to avoid this fragmentation by / / always allocating new slots out of the shared memory segment with the / / lowest id , but it could still occur in most workloads , / / fragmentation should not be a major concern , since it doesn ' t impact / / peak file descriptor usage or the speed of allocation log trace ( " { } : shutting down unix domain socket for empty { } " , this , shm ) ; shutdown ( shm ) ; } else { not full put ( shm id , shm ) ; } } }


returns the link to be displayed in the footer of the ui

public static string get footer u r l ( ) { if ( footer u r l = = null ) { footer u r l = system properties get string ( " hudson footer u r l " ) ; if ( string utils is blank ( footer u r l ) ) { footer u r l = " https : / / jenkins io / " ; } } return footer u r l ; }


test serialization of outer string types

public string fake outer string serialize ( string body ) throws api exception { api response < string > local var resp = fake outer string serialize with http info ( body ) ; return local var resp get data ( ) ; }


testing purposes only returns true if the collection of plugins in this instance contains one of the provided type

boolean plugins contain ( class < ? extends blaze java compiler plugin > klass ) { for ( blaze java compiler plugin plugin : plugins ) { if ( klass is instance ( plugin ) ) { return true ; } } return false ; }


these assertions ensure the { @ link public suffix database } remains correct the specification is very flexible regarding wildcard rules , but this flexibility is not something currently used in practice to simplify the implementation , we ' ve avoided implementing the flexible rules in favor of supporting what ' s actually used in practice that means if these assertions ever fail , the implementation will need to be revisited to support a more flexible rule

private static void assert wildcard rule ( string rule ) { if ( rule index of ( wildcard char ) ! = 0 ) { throw new runtime exception ( " wildcard assertion failure : " + rule + " \ n a wildcard rule was " + " added with a wildcard that is not in leftmost position ! we ' ll need to change the " + public suffix database class get name ( ) + " to handle this " ) ; } if ( rule index of ( wildcard char , 1 ) ! = - 1 ) { throw new runtime exception ( " wildcard assertion failure : " + rule + " \ n a wildcard rule was " + " added with multiple wildcards ! we ' ll need to change " + public suffix database class get name ( ) + " to handle this " ) ; } if ( rule length ( ) = = 1 ) { throw new runtime exception ( " wildcard assertion failure : " + rule + " \ n a wildcard rule was " + " added that wildcards the first level ! we ' ll need to change the " + public suffix database class get name ( ) + " to handle this " ) ; } }


get the set of voters which have yet to acknowledge the resignation this node will send ` end quorum epoch ` requests to this set until these voters acknowledge the request or we transition to another state

public set < integer > unacked voters ( ) { return unacked voters ; }


private void register metrics ( metric group metric group ) { metric group gauge ( number of checkpoints metric , new checkpoints counter ( ) ) ; metric group gauge ( number of in progress checkpoints metric , new in progress checkpoints counter ( ) ) ; metric group gauge ( number of completed checkpoints metric , new completed checkpoints counter ( ) ) ; metric group gauge ( number of failed checkpoints metric , new failed checkpoints counter ( ) ) ; metric group gauge ( latest restored checkpoint timestamp metric , new latest restored checkpoint timestamp gauge ( ) ) ; metric group gauge ( latest completed checkpoint size metric , new latest completed checkpoint size gauge ( ) ) ; metric group gauge ( latest completed checkpoint duration metric , new latest completed checkpoint duration gauge ( ) ) ; metric group gauge ( latest completed checkpoint processed data metric , new latest completed checkpoint processed data gauge ( ) ) ; metric group gauge ( latest completed checkpoint persisted data metric , new latest completed checkpoint persisted data gauge ( ) ) ; metric group gauge ( latest completed checkpoint external path metric , new latest completed checkpoint external path gauge ( ) ) ; }


adds the given statistics to the dataset , as if the individual values used to compute the statistics had been added directly

public void add all ( stats values ) { if ( values count ( ) = = 0 ) { return ; } merge ( values count ( ) , values mean ( ) , values sum of squares of deltas ( ) , values min ( ) , values max ( ) ) ; }


downloads an image from http ( s ) url and passes it as a { @ link pixmap } to the specified { @ link download pixmap response listener }

public static void download from url ( string url , final download pixmap response listener response listener ) { net http request request = new net http request ( net http methods get ) ; request set url ( url ) ; gdx net send http request ( request , new net http response listener ( ) { @ override public void handle http response ( net http response http response ) { final byte [ ] result = http response get result ( ) ; gdx app post runnable ( new runnable ( ) { @ override public void run ( ) { try { pixmap pixmap = new pixmap ( result , 0 , result length ) ; response listener download complete ( pixmap ) ; } catch ( throwable t ) { failed ( t ) ; } } } ) ; } @ override public void failed ( throwable t ) { response listener download failed ( t ) ; } @ override public void cancelled ( ) { / / no way to cancel , will never get called } } ) ; }


post fakecreate xml item : creates an xml item this route creates an xml item

default response entity < void > create xml item ( @ api param ( value = " xml item body " , required = true ) @ valid @ request body xml item xml item ) { return new response entity < > ( http status not implemented ) ; }


a helper method equivalent to calling { @ link # download only ( ) } ( ) } and then { @ link request builder # load ( object ) } with the given model

public request builder < file > download ( @ nullable object model ) { return download only ( ) load ( model ) ; }


removes a number of occurrences of the specified element from this multiset if the multiset contains fewer than this number of occurrences to begin with , all occurrences will be removed

public int remove ( @ nullable object element , int occurrences ) { if ( occurrences = = 0 ) { return count ( element ) ; } check argument ( occurrences > 0 , " invalid occurrences : % s " , occurrences ) ; while ( true ) { int current = count ( element ) ; if ( current = = 0 ) { return 0 ; } if ( occurrences > = current ) { if ( count map remove ( element , current ) ) { return current ; } } else { / / we know it ' s an " e " because it already exists in the map @ suppress warnings ( " unchecked " ) e casted = ( e ) element ; if ( count map replace ( casted , current , current - occurrences ) ) { return current ; } } / / if we ' re still here , there was a race , so just try again } }


the bean seata data source bean post processor

public seata data source bean post processor seata data source bean post processor ( seata properties seata properties ) { return new seata data source bean post processor ( seata properties get excludes for auto proxying ( ) , seata properties get data source proxy mode ( ) ) ; }


public type bearer get category 2 ( int idx ) { return primary get category 2 ( idx ) ; }


return the required { @ link resolvable type } of the missing bean , if it was a lookup by type that failed

public resolvable type get resolvable type ( ) { return this resolvable type ; }


returns all { @ link node } s in the system , excluding { @ link jenkins } instance itself which represents the master

public list < node > get nodes ( ) { return nodes get nodes ( ) ; }


public static object reference get object ref by path ( final string path ) { if ( path = = null ) { return null ; } return object reference builder ( ) selector ( path ) build ( ) ; }


the arity of the plural < code > optional aapt pb plural arity arity = 3 ; < code >


get the production applied to create this branch

public assembly production get production ( ) { return prod ; }


private static file system get file system ( final string ns id ) { if ( ns id equals ( " ns 0 " ) ) { return nn fs 0 ; } if ( ns id equals ( " ns 1 " ) ) { return nn fs 1 ; } return null ; }


manually run this to write binary snapshot data

public void write snapshot ( ) throws exception { write snapshot ( " src / test / resources / kafka - consumer - migration - test - flink " + flink generate savepoint version + " - snapshot " , partition state ) ; final hash map < kafka topic partition , long > empty state = new hash map < > ( ) ; write snapshot ( " src / test / resources / kafka - consumer - migration - test - flink " + flink generate savepoint version + " - empty - state - snapshot " , empty state ) ; }


assuming - feature - is sorted and - hash - is empty , count the features and populate - hash - and - tf - for every unique feature , look up its idf via - idflookup -

private void install features ( int [ ] feature , weight factory wfactory , i d f lookup idflookup ) { if ( feature length = = 0 ) { return ; / / no features } int lasthash = feature [ 0 ] ; int idf ; int count = 1 ; int sz = 1 ; for ( int i = 0 ; i < feature length ; + + i ) { if ( feature [ i ] ! = lasthash ) { lasthash = feature [ i ] ; sz + = 1 ; } } hash = new hash entry [ sz ] ; lasthash = feature [ 0 ] ; sz = 0 ; if ( ! idflookup empty ( ) ) { idf = idflookup get count ( lasthash ) ; for ( int i = 1 ; i < feature length ; + + i ) { int featurei = feature [ i ] ; if ( featurei ! = lasthash ) { hash [ sz ] = new hash entry ( lasthash , count , idf , wfactory ) ; sz + = 1 ; lasthash = featurei ; count = 1 ; idf = idflookup get count ( lasthash ) ; } else { count + = 1 ; } } } else { idf = 0 ; for ( int i = 1 ; i < feature length ; + + i ) { int featurei = feature [ i ] ; if ( featurei ! = lasthash ) { hash [ sz ] = new hash entry ( lasthash , count , idf , wfactory ) ; sz + = 1 ; lasthash = featurei ; count = 1 ; } else { count + = 1 ; } } } hash [ sz ] = new hash entry ( lasthash , count , idf , wfactory ) ; }


check if the expected character exist at the given offset in the value

private static boolean check offset ( string value , int offset , char expected ) { return ( offset < value length ( ) ) & & ( value char at ( offset ) = = expected ) ; }


generate method invocation statement and return it if necessary

private string generate return and invocation ( method method ) { string return statement = method get return type ( ) equals ( void class ) ? " " : " return " ; string args = int stream range ( 0 , method get parameters ( ) length ) map to obj ( i - > string format ( code extension method invoke argument , i ) ) collect ( collectors joining ( " , " ) ) ; return return statement + string format ( " extension % s ( % s ) ; \ n " , method get name ( ) , args ) ; }


sets the { @ link menu data } to be used to put this action in the tool ' s popup menu

public void set popup menu data ( menu data new menu data ) { popup menu data old data = popup menu data ; popup menu data new data copy = new menu data = = null ? null : new popup menu data ( this , new menu data ) ; popup menu data = new data copy ; fire property changed ( popup menu data property , old data , new data copy ) ; }


applies { @ link json path expectations helper # assert value is boolean ( string ) }

public web test client body content spec is boolean ( ) { this path helper assert value is boolean ( this content ) ; return this body spec ; }


dispatch a { @ link service instances changed event } when the { @ link heartbeat event } raised , use for these scenarios : eureka : { @ link cloud eureka client # on cache refreshed ( ) } publishes a { @ link heartbeat event } instead of { @ link cache refreshed event } zookeeper : { @ link zookeeper service watch # child event ( curator framework , tree cache event ) } publishes a { @ link heartbeat event } when { @ link zookeeper discovery properties # get root ( ) the services ' root path } has been changed consul : { @ link consul catalog watch # catalog services watch ( ) } publishes a { @ link heartbeat event } when < a href = " https : www consul ioapifeaturesblocking html " > consul ' s blocking queries response nacos : { @ link nacos watch # nacos services watch ( ) } publishes a { @ link heartbeat event } under a { @ link task scheduler } every { @ link nacos discovery properties # get watch delay ( ) } milliseconds in order to reduce the duplicated handling for { @ link service instances changed event } , { @ link # default heartbeat event change predicate ( ) } method providers the default implementation to detect whether the { @ link heartbeat event # get value ( ) state } is changed or not if and only if changed , the { @ link # dispatch service instances changed event ( string , collection ) } will be executed < b > note : < b > spring cloud { @ link heartbeat event } has a critical flaw that can ' t figure out which service was changed precisely , it ' s just used for a notification that the { @ link dubbo service metadata repository # get subscribed services ( ) subscribed services } used to { @ link notify listener # notify ( list ) notify } the dubbo consumer cached { @ link url u r ls } because of some { @ link discovery client } implementations have the better and fine - grained the event mechanism for service instances change , thus { @ link heartbeat event } handle will be ignored in these scenarios : zookeeper : { @ link watcher } , see { @ link zookeeper configuration # heartbeat event changed predicate ( ) } nacos : { @ link com alibaba nacos api naming listener event listener } , see { @ link nacos configuration # heartbeat event changed predicate ( ) } if the customized { @ link discovery client } also providers the similar mechanism , the implementation could declare a spring bean of { @ link predicate } of { @ link heartbeat event } to override { @ link # default heartbeat event change predicate ( ) default one }

public void on heartbeat event ( heartbeat event event ) { / * * * try to re - initialize the subscribed services , in order to sense the change of * services if { @ link dubbo cloud properties # get subscribed services ( ) } is wildcard * that indicates all services should be subscribed * / stream < string > subscribed services = dubbo service metadata repository init subscribed services ( ) ; heartbeat event changed predicate if available ( predicate - > { if ( predicate test ( event ) ) { / / dispatch service instances changed event for each service subscribed services for each ( service name - > { list < service instance > service instances = get instances ( service name ) ; dispatch service instances changed event ( service name , service instances ) ; } ) ; } } ) ; }


returns a key identifying the declared provider ( only for non - legacy providers )

public provider key get key ( ) { preconditions check state ( ! is legacy ( ) , " check ! is legacy ( ) first " ) ; return key ; }


public static byte get byte ( memory segment [ ] segments , int offset ) { if ( in first segment ( segments , offset , 1 ) ) { return segments [ 0 ] get ( offset ) ; } else { return get byte multi segments ( segments , offset ) ; } }


visit a parse tree produced by { @ link eql base parser # single expression }

t visit single expression ( eql base parser single expression context ctx ) ;


moves the cursor in the listing to the next search result past , or before ( depending on the given direction ) the current address

public address get next address ( direction direction , list < instruction metadata > search results ) { address current address = search plugin get program location ( ) get byte address ( ) ; / / if forward - searching , just find the first address in the given result set that is / / greater than the current address / / / / the reason for the getting the code unit is that the instruction might be an off - cut , / / and if that ' s the case , then we can ' t navigate directly to it what we have to do / / is find the code unit containing the instruction and navigate to that if ( direction = = direction forward ) { for ( instruction metadata instr : search results ) { code unit unit = search plugin get current program ( ) get listing ( ) get code unit containing ( instr get addr ( ) ) ; if ( unit get min address ( ) compare to ( current address ) > 0 ) { return unit get min address ( ) ; } } } / / if backwards , iterate over the list in reverse order and find the first address in / / the result set that is one less than the current address / / / / see above for an explanation for why we need to get the code unit in this block if ( direction = = direction backward ) { list iterator < instruction metadata > iter = search results list iterator ( search results size ( ) ) ; while ( iter has previous ( ) ) { instruction metadata instr = iter previous ( ) ; code unit unit = search plugin get current program ( ) get listing ( ) get code unit containing ( instr get addr ( ) ) ; if ( unit get min address ( ) compare to ( current address ) < 0 ) { return unit get min address ( ) ; } } } return null ; }


this test creates a long random sequence of inputs , then a lot of differently configured sinks process it ; all should produce the same answer , the only difference should be the number of process ( ) process remaining ( ) invocations , due to alignment

public void test exhaustive ( ) throws exception { random random = new random ( 0 ) ; / / will iteratively make more debuggable , each time it breaks for ( int total insertions = 0 ; total insertions < 200 ; total insertions + + ) { list < sink > sinks = lists new array list ( ) ; for ( int chunk size = 4 ; chunk size < = 32 ; chunk size + + ) { for ( int buffer size = chunk size ; buffer size < = chunk size * 4 ; buffer size + = chunk size ) { / / yes , that ' s a lot of sinks ! sinks add ( new sink ( chunk size , buffer size ) ) ; / / for convenience , testing only with big endianness , to match data output stream / / i regard highly unlikely that both the little endianness tests above and this one / / passes , and there is still a little endianness bug lurking around } } control control = new control ( ) ; hasher control sink = control new hasher ( 1024 ) ; iterable < hasher > sinks and control = iterables concat ( sinks , collections singleton ( control sink ) ) ; for ( int insertion = 0 ; insertion < total insertions ; insertion + + ) { random hasher action pick at random ( random ) perform action ( random , sinks and control ) ; } / / we need to ensure that at least 4 bytes have been put into the hasher or else / / hasher # hash will throw an ise int int to put = random next int ( ) ; for ( hasher hasher : sinks and control ) { hasher put int ( int to put ) ; } for ( sink sink : sinks ) { hash code unused = sink hash ( ) ; } byte [ ] expected = control sink hash ( ) as bytes ( ) ; for ( sink sink : sinks ) { sink assert invariants ( expected length ) ; sink assert bytes ( expected ) ; } } }


create an instance of the { @ code model m bean info support } class supplied with all jmx implementations and populates the metadata through calls to the subclass

public model m bean info get m bean info ( object managed bean , string bean key ) throws j m exception { check managed bean ( managed bean ) ; model m bean info info = new model m bean info support ( get class name ( managed bean , bean key ) , get description ( managed bean , bean key ) , get attribute info ( managed bean , bean key ) , get constructor info ( managed bean , bean key ) , get operation info ( managed bean , bean key ) , get notification info ( managed bean , bean key ) ) ; descriptor desc = info get m bean descriptor ( ) ; populate m bean descriptor ( desc , managed bean , bean key ) ; info set m bean descriptor ( desc ) ; return info ; }


obtain a property accessor for the given target object , accessing properties in direct field style

public static configurable property accessor for direct field access ( object target ) { return new direct field accessor ( target ) ; }


for example , assume the following class definition : < pre class = " code " > public class foo { private string bar ; private list & lt ; string & gt ; red ; } type list parameterized type = new type token & lt ; list & lt ; string & gt ; & gt ; ( ) { } get type ( ) ; this method would return { @ code string class } for the { @ code bar } field and { @ code list parameterized type } for the { @ code red } field

public type get declared type ( ) { return field get generic type ( ) ; }


gets the maximum degree of parallelism defined for the program the maximum degree of parallelism specifies the upper limit for dynamic scaling it also defines the number of key groups used for partitioned state

public int get max parallelism ( ) { return config get max parallelism ( ) ; }


finds the index of the segment in a java path fragment that precedes the source root starts from the first " java " or " javatests " or " src " or " testsrc " segment if the found item was " src " , check if this is followed by " main " or " test " and then " java " or " resources " ( maven layout ) if the found item was " src " , or " java " " javatests " at the first segment , check for a nested root directory ( src , java or javatests ) a nested root must be followed by ( com | net | org ) , or matching maven structure for nested " src " , to be accepted , to avoid false positives

private static int java segment index ( path fragment path ) { if ( path is absolute ( ) ) { throw new illegal argument exception ( " path must not be absolute : ' " + path + " ' " ) ; } int root index = path get first segment ( known source roots ) ; if ( root index < 0 ) { return root index ; } final boolean is src = " src " equals ( path get segment ( root index ) ) ; int check maven index = is src ? root index : - 1 ; if ( root index = = 0 | | is src ) { / / check for a nested root directory for ( int i = root index + 1 , max = path segment count ( ) - 2 ; i < = max ; i + + ) { string segment = path get segment ( i ) ; if ( " src " equals ( segment ) | | ( is src & & ( " javatests " equals ( segment ) | | " java " equals ( segment ) ) ) ) { string next = path get segment ( i + 1 ) ; if ( " com " equals ( next ) | | " org " equals ( next ) | | " net " equals ( next ) ) { / / check for common first element of java package , to avoid false positives root index = i ; } else if ( " src " equals ( segment ) ) { / / also accept maven style src / ( main | test ) / ( java | resources ) check maven index = i ; } break ; } } } / / check for ( main | test ) / ( java | resources ) after / src / if ( check maven index > = 0 & & check maven index + 2 < path segment count ( ) ) { string next = path get segment ( check maven index + 1 ) ; if ( " main " equals ( next ) | | " test " equals ( next ) ) { next = path get segment ( check maven index + 2 ) ; if ( " java " equals ( next ) | | " resources " equals ( next ) ) { root index = check maven index + 2 ; } } } return root index ; }


combine " this " request mapping info ( i e the current instance ) with another request mapping info instance example : combine type - and method - level request mappings

public request mapping info combine ( request mapping info other ) { string name = combine names ( other ) ; path patterns request condition path patterns = ( this path patterns condition ! = null & & other path patterns condition ! = null ? this path patterns condition combine ( other path patterns condition ) : null ) ; patterns request condition patterns = ( this patterns condition ! = null & & other patterns condition ! = null ? this patterns condition combine ( other patterns condition ) : null ) ; request methods request condition methods = this methods condition combine ( other methods condition ) ; params request condition params = this params condition combine ( other params condition ) ; headers request condition headers = this headers condition combine ( other headers condition ) ; consumes request condition consumes = this consumes condition combine ( other consumes condition ) ; produces request condition produces = this produces condition combine ( other produces condition ) ; request condition holder custom = this custom condition holder combine ( other custom condition holder ) ; return new request mapping info ( name , path patterns , patterns , methods , params , headers , consumes , produces , custom ) ; }


reduces the size of the backing arrays to be the specified capacity load factor , or less if the capacity is already less , nothing is done if the map contains more items than the specified capacity , the next highest power of two capacity is used instead

public void shrink ( int maximum capacity ) { if ( maximum capacity < 0 ) throw new illegal argument exception ( " maximum capacity must be > = 0 : " + maximum capacity ) ; int table size = table size ( maximum capacity , load factor ) ; if ( key table length > table size ) resize ( table size ) ; }


fake endpoint for testing various parameters 가짜 엔드 포인트 fake endpoint for testing various parameters 가짜 엔드 포인트

void test endpoint parameters ( @ param ( " number " ) big decimal number , @ param ( " double " ) double double , @ param ( " pattern without delimiter " ) string pattern without delimiter , @ param ( " byte " ) byte [ ] byte , @ param ( " integer " ) integer integer , @ param ( " int 3 2 " ) integer int 3 2 , @ param ( " int 6 4 " ) long int 6 4 , @ param ( " float " ) float float , @ param ( " string " ) string string , @ param ( " binary " ) file binary , @ param ( " date " ) local date date , @ param ( " date time " ) offset date time date time , @ param ( " password " ) string password , @ param ( " param callback " ) string param callback ) ;


returns the date value of a header with the specified name if there are more than one values for the specified name , the first value is returned

public abstract long get time millis ( char sequence name ) ;


scroll to the beginning of the section with the given key and an additional offset one notable difference between this and the { @ link # request focus ( section context , string ) } api is that this will always take an action , while { @ link # request focus ( section context , string ) } will ignore the command if the item is visible on the screen

public static void request focus with offset ( section context c , string section key , int offset ) { request focus with offset ( c , section key , 0 , offset ) ; }


gets the register that begins the method ' s parameter range ( including the ' this ' parameter for non - static methods ) the range continues until { @ code reg size }

private int get param base ( ) { return reg size - desc get parameter types ( ) get word count ( ) - ( is static ? 0 : 1 ) ; }


public int get eh frame table encoding ( ) { return eh frame table encoding ; }


sets the < code > declawed < code > property

public void set declawed ( boolean declawed ) { this declawed = declawed ; }


returns the name of the blaze action this action config applies to

string get action name ( ) { return action name ; }


convert the given object to string with each line indented by 4 spaces ( except the first line )

private string to indented string ( object o ) { if ( o = = null ) { return " null " ; } return o to string ( ) replace ( " \ n " , " \ n " ) ; }


whether playback will proceed when { @ link # get playback state ( ) } = = { @ link # state ready }


flushes the given program ' s events before waiting for the swing update manager

public static void wait for program ( program program ) { if ( program ! = null ) { program flush events ( ) ; } wait for swing ( ) ; }


creates an empty multiset containing the given initial elements , sorted according to the elements ' natural order this implementation is highly efficient when { @ code elements } is itself a { @ link multiset } the type specification is { @ code < e extends comparable > } , instead of the more specific { @ code < e extends comparable < ? super e > > } , to support classes defined without generics

public static < e extends comparable > tree multiset < e > create ( iterable < ? extends e > elements ) { tree multiset < e > multiset = create ( ) ; iterables add all ( multiset , elements ) ; return multiset ; }


check if the given class or any of its super classes have a super method with the given name private methods are ignored since the generated subclass can ' t call super on those

protected boolean has super method ( type element class element , element attribute ) { if ( ! utils is epoxy model ( class element as type ( ) ) ) { return false ; } for ( element sub element : synchronization kt get enclosed elements thread safe ( class element ) ) { if ( sub element get kind ( ) = = element kind method ) { executable element method = ( executable element ) sub element ; list < variable element > parameters = synchronization kt get parameters thread safe ( method ) ; if ( ! method get modifiers ( ) contains ( modifier private ) & & method get simple name ( ) to string ( ) equals ( attribute get simple name ( ) to string ( ) ) & & parameters size ( ) = = 1 & & parameters get ( 0 ) as type ( ) equals ( attribute as type ( ) ) ) { return true ; } } } element super class = kotlin utils kt super class element ( class element , type utils ) ; return ( super class instanceof type element ) & & has super method ( ( type element ) super class , attribute ) ; }


public cancellable delete auto follow pattern async ( delete auto follow pattern request request , request options options , action listener < acknowledged response > listener ) { return rest high level client perform request async and parse entity ( request , ccr request converters : : delete auto follow pattern , options , acknowledged response : : from x content , listener , collections empty set ( ) ) ; }


creates a bitmap from encoded jpeg bytes supports a partial jpeg image

public closeable reference < bitmap > decode j p e g from encoded image with color space ( encoded image encoded image , bitmap config bitmap config , @ nullable rect region to decode , int length , @ nullable final color space color space ) { boolean is jpeg complete = encoded image is complete at ( length ) ; final bitmap factory options options = get decode options for stream ( encoded image , bitmap config ) ; input stream jpeg data stream = encoded image get input stream ( ) ; / / at this point the input stream from the encoded image should not be null since in the / / pipeline , this comes from a call stack where this was checked before also this method needs / / the input stream to decode the image so this can ' t be null preconditions check not null ( jpeg data stream ) ; if ( encoded image get size ( ) > length ) { jpeg data stream = new limited input stream ( jpeg data stream , length ) ; } if ( ! is jpeg complete ) { jpeg data stream = new tail appending input stream ( jpeg data stream , eoi tail ) ; } boolean retry on fail = options in preferred config ! = bitmap config argb 8888 ; try { return decode from stream ( jpeg data stream , options , region to decode , color space ) ; } catch ( runtime exception re ) { if ( retry on fail ) { return decode j p e g from encoded image with color space ( encoded image , bitmap config argb 8888 , region to decode , length , color space ) ; } throw re ; } finally { try { jpeg data stream close ( ) ; } catch ( i o exception e ) { e print stack trace ( ) ; } } }


verify that , when the callback fails to enter active state , the elector rejoins the election after sleeping for a short period

public void test fail to become active ( ) throws exception { mock no prior active ( ) ; elector join election ( data ) ; assert assert equals ( 0 , elector slept for ) ; mockito do throw ( new service failed exception ( " failed to become active " ) ) when ( mock app ) become active ( ) ; elector process result ( code ok int value ( ) , zk lock name , mock z k , zk lock name ) ; / / should have tried to become active mockito verify ( mock app ) become active ( ) ; / / should re - join mockito verify ( mock z k , mockito times ( 2 ) ) create ( zk lock name , data , ids open acl unsafe , create mode ephemeral , elector , mock z k ) ; assert assert equals ( 2 , count ) ; assert assert true ( elector slept for > 0 ) ; }


adapt the given arguments to the target signature in the given method , if necessary : in particular , if a given vararg argument array does not match the array type of the declared vararg parameter in the method

static object [ ] adapt arguments if necessary ( method method , @ nullable object [ ] arguments ) { if ( object utils is empty ( arguments ) ) { return new object [ 0 ] ; } if ( method is var args ( ) ) { if ( method get parameter count ( ) = = arguments length ) { class < ? > [ ] param types = method get parameter types ( ) ; int vararg index = param types length - 1 ; class < ? > vararg type = param types [ vararg index ] ; if ( vararg type is array ( ) ) { object vararg array = arguments [ vararg index ] ; if ( vararg array instanceof object [ ] & & ! vararg type is instance ( vararg array ) ) { object [ ] new arguments = new object [ arguments length ] ; system arraycopy ( arguments , 0 , new arguments , 0 , vararg index ) ; class < ? > target element type = vararg type get component type ( ) ; int vararg length = array get length ( vararg array ) ; object new vararg array = array new instance ( target element type , vararg length ) ; system arraycopy ( vararg array , 0 , new vararg array , 0 , vararg length ) ; new arguments [ vararg index ] = new vararg array ; return new arguments ; } } } } return arguments ; }


derive a bean name from one of the annotations on the class

protected string determine bean name from annotation ( annotated bean definition annotated def ) { annotation metadata amd = annotated def get metadata ( ) ; set < string > types = amd get annotation types ( ) ; string bean name = null ; for ( string type : types ) { annotation attributes attributes = annotation config utils attributes for ( amd , type ) ; if ( attributes ! = null ) { set < string > meta types = this meta annotation types cache compute if absent ( type , key - > { set < string > result = amd get meta annotation types ( key ) ; return ( result is empty ( ) ? collections empty set ( ) : result ) ; } ) ; if ( is stereotype with name value ( type , meta types , attributes ) ) { object value = attributes get ( " value " ) ; if ( value instanceof string ) { string str val = ( string ) value ; if ( string utils has length ( str val ) ) { if ( bean name ! = null & & ! str val equals ( bean name ) ) { throw new illegal state exception ( " stereotype annotations suggest inconsistent " + " component names : ' " + bean name + " ' versus ' " + str val + " ' " ) ; } bean name = str val ; } } } } } return bean name ; }


convert secret to bytes honoring { @ link registered service property registered service properties # token secrets are base64 encoded } config parameter

private static byte [ ] get secret bytes ( final string secret , final boolean secret is base 6 4 encoded ) { return secret is base 6 4 encoded ? new base 6 4 ( secret ) decode ( ) : secret get bytes ( utf 8 ) ; }


build a composite input split from the child input formats by assigning the ith split from each child to the ith composite split

public list < input split > get splits ( job context job ) throws i o exception , interrupted exception { set format ( job get configuration ( ) ) ; job get configuration ( ) set long ( " mapreduce input fileinputformat split minsize " , long max value ) ; return root get splits ( job ) ; }


attempts to asynchronously index a snapshot lifecycle management history entry

public void put async ( snapshot history item item ) { if ( slm history enabled = = false ) { logger trace ( " not recording snapshot history item because [ { } ] is [ false ] : [ { } ] " , slm history index enabled setting get key ( ) , item ) ; return ; } logger trace ( " about to index snapshot history item in data stream [ { } ] : [ { } ] " , slm history data stream , item ) ; metadata metadata = cluster service state ( ) get metadata ( ) ; if ( metadata data streams ( ) contains key ( slm history data stream ) = = false & & metadata templates v 2 ( ) contains key ( slm template name ) = = false ) { logger error ( new parameterized message ( " failed to index snapshot history item , data stream [ { } ] and template [ { } ] don ' t exist " , slm history data stream , slm template name ) ) ; return ; } try ( x content builder builder = x content factory json builder ( ) ) { item to x content ( builder , to x content empty params ) ; index request request = new index request ( slm history data stream ) op type ( doc write request op type create ) source ( builder ) ; client index ( request , action listener wrap ( index response - > { logger debug ( " successfully indexed snapshot history item with id [ { } ] in data stream [ { } ] : [ { } ] " , index response get id ( ) , slm history data stream , item ) ; } , exception - > { logger error ( new parameterized message ( " failed to index snapshot history item in data stream [ { } ] : [ { } ] " , slm history data stream , item ) , exception ) ; } ) ) ; } catch ( i o exception exception ) { logger error ( new parameterized message ( " failed to index snapshot history item in data stream [ { } ] : [ { } ] " , slm history data stream , item ) , exception ) ; } }


the field with which to construct the terms grouping

public builder set field ( string field ) { this field = field ; return this ; }


security tokens were traditionally stored on the main security index but after version { @ code # version tokens index introduced } they have been stored on a dedicated separate index this move has been implemented without requiring user intervention , so the newly created tokens started to be created in the new index , while the old tokens were still usable out of the main security index , subject to their maximum lifetime of { @ code expired token remover # maximum token lifetime hours } hours once the dedicated tokens index has been automatically created , all the onwards created tokens will be stored inside it this function returns the list of the indices names that might contain tokens unless there are availability or version issues , the dedicated tokens index always contains tokens the main security index might contain tokens if the tokens index has not been created yet , or if it has been created recently so that there might still be tokens that have not yet exceeded their maximum lifetime

private void source indices with tokens and run ( action listener < list < string > > listener ) { final list < string > indices with tokens = new array list < > ( 2 ) ; final security index manager frozen tokens index = security tokens index freeze ( ) ; if ( frozen tokens index index exists ( ) ) { / / an existing tokens index always contains tokens ( if available and version allows ) if ( false = = frozen tokens index is available ( ) ) { listener on failure ( frozen tokens index get unavailable reason ( ) ) ; return ; } if ( false = = frozen tokens index is index up to date ( ) ) { listener on failure ( new illegal state exception ( " index [ " + frozen tokens index alias name ( ) + " ] is not on the current version features relying on the index " + " will not be available until the upgrade api is run on the index " ) ) ; return ; } indices with tokens add ( frozen tokens index alias name ( ) ) ; } final security index manager frozen main index = security main index freeze ( ) ; if ( frozen main index index exists ( ) ) { / / main security index might contain tokens if the tokens index has been created recently if ( false = = frozen tokens index index exists ( ) | | frozen tokens index get creation time ( ) is after ( clock instant ( ) minus ( expired token remover maximum token lifetime hours , chrono unit hours ) ) ) { if ( false = = frozen main index is available ( ) ) { listener on failure ( frozen main index get unavailable reason ( ) ) ; return ; } if ( false = = frozen main index is index up to date ( ) ) { listener on failure ( new illegal state exception ( " index [ " + frozen main index alias name ( ) + " ] is not on the current version features relying on the index " + " will not be available until the upgrade api is run on the index " ) ) ; return ; } indices with tokens add ( frozen main index alias name ( ) ) ; } } listener on response ( indices with tokens ) ; }


protected void inject environment info into banner ( final formatter formatter , final environment environment , final class < ? > source class ) { }


this method can be called after get match for returned a match it will overwrite the record that was found by get match for warning : the new record should have the same key as the old ! warning ; don ' t do any modifications to the table between get match for and update match !

public void update match ( t new record ) throws i o exception { if ( closed ) { return ; } if ( cur elem ptr = = end of list ) { throw new runtime exception ( " update match was called after get match for returned no match " ) ; } try { / / determine the new size staging segments out view reset ( ) ; build side serializer serialize ( new record , staging segments out view ) ; final int new record size = ( int ) staging segments out view get write position ( ) ; staging segments in view set read position ( 0 ) ; / / determine the size of the place of the old record final int old record size = ( int ) ( record end - ( cur elem ptr + record offset in link ) ) ; if ( new record size = = old record size ) { / / overwrite record at its original place record area overwrite record at ( cur elem ptr + record offset in link , staging segments in view , new record size ) ; } else { / / new record has a different size than the old one , append new at the end of / / the record area / / note : we have to do this , even if the new record is smaller , because / / otherwise entry iterator / / wouldn ' t know the size of this place , and wouldn ' t know where does the next / / record start final long pointer to appended = record area append pointer and copy record ( next ptr , staging segments in view , new record size ) ; / / modify the pointer in the previous link if ( prev elem ptr = = invalid prev pointer ) { / / list had only one element , so prev is in the bucket segments bucket segments [ bucket segment index ] put long ( bucket offset , pointer to appended ) ; } else { record area overwrite pointer at ( prev elem ptr , pointer to appended ) ; } / / write the negated size of the hole to the place where the next pointer was , / / so that entry iterator / / will know the size of the place without reading the old record / / the negative sign will mean that the record is abandoned , and the / / the - 1 is for avoiding trouble in case of a record having 0 size ( though i / / think this should / / never actually happen ) / / note : the last record in the record area can ' t be abandoned ( entry iterator / / makes use of this fact ) record area overwrite pointer at ( cur elem ptr , - old record size - 1 ) ; holes + = old record size ; } } catch ( e o f exception ex ) { compact or throw ( ) ; insert or replace record ( new record ) ; } }


tests the serializationdeserialization of an abstract id

public void test serialization ( ) throws exception { final abstract i d orig i d = new abstract i d ( ) ; final abstract i d copy i d = common test utils create copy serializable ( orig i d ) ; assert equals ( orig i d hash code ( ) , copy i d hash code ( ) ) ; assert equals ( orig i d , copy i d ) ; }


returns the default button for the dialog

public j button get default button ( ) { return default button ; }


serializes the provided value in sql - compatible way based on the client mode

public static x content builder value ( x content builder builder , mode mode , object value ) throws i o exception { if ( value instanceof zoned date time ) { zoned date time zdt = ( zoned date time ) value ; / / use the iso format builder value ( string utils to string ( zdt ) ) ; } else if ( mode = = cli & & value ! = null & & value get class ( ) get superclass ( ) get simple name ( ) equals ( interval class name ) ) { / / use the sql format for intervals when sending back the response for cli / / all other clients will receive iso 8601 formatted intervals builder value ( value to string ( ) ) ; } else { builder value ( value ) ; } return builder ; }


public map < string , string > get map string ( ) { return map string ; }


add a new pet to the store < b > 200 < b > - successful operation < b > 405 < b > - invalid input

public response entity < void > add pet with http info ( pet body ) throws rest client exception { object post body = body ; / / verify the required parameter ' body ' is set if ( body = = null ) { throw new http client error exception ( http status bad request , " missing the required parameter ' body ' when calling add pet " ) ; } string path = api client expand path ( " / pet " , collections < string , object > empty map ( ) ) ; final multi value map < string , string > query params = new linked multi value map < string , string > ( ) ; final http headers header params = new http headers ( ) ; final multi value map < string , string > cookie params = new linked multi value map < string , string > ( ) ; final multi value map < string , object > form params = new linked multi value map < string , object > ( ) ; final string [ ] local var accepts = { } ; final list < media type > local var accept = api client select header accept ( local var accepts ) ; final string [ ] content types = { " application / json " , " application / xml " } ; final media type content type = api client select header content type ( content types ) ; string [ ] auth names = new string [ ] { " petstore auth " } ; parameterized type reference < void > return type = new parameterized type reference < void > ( ) { } ; return api client invoke a p i ( path , http method post , query params , post body , header params , cookie params , form params , local var accept , content type , auth names , return type ) ; }


take a snapshot of the uncheckpointed split assignments

public void snapshot state ( long checkpoint id , simple versioned serializer < split t > split serializer , data output stream out ) throws exception { / / include the uncheckpointed assignments to the snapshot assignments by checkpoint id put ( checkpoint id , uncheckpointed assignments ) ; uncheckpointed assignments = new hash map < > ( ) ; write assignments by checkpoint id ( assignments by checkpoint id , split serializer , out ) ; }


public string get log prefix ( ) { return this log prefix ; }


gets the data sinks from this optimized plan

public collection < sink plan node > get data sinks ( ) { return data sinks ; }


tests the upgrade from one version of federation to another federation version test without clusterid case : - upgrade expected to reuse existing clusterid

public void test startup opt upgrade from federation ( ) throws exception { / / test assumes clusterid already exists , set the clusterid storage set cluster i d ( " currentcid " ) ; layout version = feature federation get info ( ) get layout version ( ) ; storage process startup options for upgrade ( start opt , layout version ) ; assert equals ( " clusterid should match with the existing one " , " currentcid " , storage get cluster i d ( ) ) ; }


performs any actions conditional on this context not only being registered but triggered as used because its identifier was requested and it was not overridden

default void used context ( action context registry action context registry ) { }


returns the correct ghidra data converter static instance for the requested endian - ness

public static ghidra data converter get instance ( boolean is big endian ) { return is big endian ? ghidra big endian data converter instance : ghidra little endian data converter instance ; }


constructs a merkle tree from a lexicographically sorted map of inputs ( files )

public static merkle tree build ( sorted map < path fragment , action input > inputs , metadata provider metadata provider , path exec root , digest util digest util ) throws i o exception { try ( silent closeable c = profiler instance ( ) profile ( " merkle tree build ( action input ) " ) ) { directory tree tree = directory tree builder from action inputs ( inputs , metadata provider , exec root , digest util ) ; return build ( tree , digest util ) ; } }


public static http response error j s o n ( @ non null string message ) { return new j s o n object response ( ) error ( message ) ; }


determine whether to apply disappear animation to the given { @ link mount item }

private static boolean is item disappearing ( final transitions extension state state , transitions extension input input , int index ) { if ( ! should animate transitions ( state , input ) | | ! has transitions to animate ( state ) ) { return false ; } if ( state m transition manager = = null | | state m last transitions extension input = = null ) { return false ; } final animatable item animatable item = state m last transitions extension input get animatable item ( state m last transitions extension input get mountable output at ( index ) get render unit ( ) ) ; final transition id transition id = animatable item get transition id ( ) ; if ( transition id = = null ) { return false ; } return state m transition manager is disappearing ( transition id ) ; }


shutdown the serveral publisher instance which notifycenter has

public static void shutdown ( ) { if ( ! closed compare and set ( false , true ) ) { return ; } logger warn ( " [ notify center ] start destroying publisher " ) ; for ( map entry < string , event publisher > entry : instance publisher map entry set ( ) ) { try { event publisher event publisher = entry get value ( ) ; event publisher shutdown ( ) ; } catch ( throwable e ) { logger error ( " [ event publisher ] shutdown has error : { } " , e ) ; } } try { instance share publisher shutdown ( ) ; } catch ( throwable e ) { logger error ( " [ share publisher ] shutdown has error : { } " , e ) ; } logger warn ( " [ notify center ] destruction of the end " ) ; }


throws { @ link unsupported operation exception }

public boolean kill task ( org apache hadoop mapreduce task attempt i d task id , boolean should fail ) throws i o exception { throw new unsupported operation exception ( " killing tasks in " + " local job runner is not supported " ) ; }


a { @ link channel } is active now , which means it is connected this will result in having the { @ link channel inbound handler # channel active ( channel handler context ) } method called of the next { @ link channel inbound handler } contained in the { @ link channel pipeline } of the { @ link channel }

channel inbound invoker fire channel active ( ) ;


public void incr ( int delta ) { value add and get ( delta ) ; set changed ( ) ; }


return a predicate by which a snapshot info can be tested to see whether it should be deleted according to this retention policy

public predicate < snapshot info > get snapshot deletion predicate ( final list < snapshot info > all snapshots ) { final int total snapshot count = all snapshots size ( ) ; final list < snapshot info > sorted snapshots = all snapshots stream ( ) sorted ( comparator comparing long ( snapshot info : : start time ) ) collect ( collectors to list ( ) ) ; final long successful snapshot count = all snapshots stream ( ) filter ( snap - > snapshot state success equals ( snap state ( ) ) ) count ( ) ; final long newest successful timestamp = all snapshots stream ( ) filter ( snap - > snapshot state success equals ( snap state ( ) ) ) map to long ( snapshot info : : start time ) max ( ) or else ( long min value ) ; final set < snapshot state > unsuccessful states = set of ( snapshot state failed , snapshot state partial ) ; return si - > { final string snap name = si snapshot id ( ) get name ( ) ; / / first , if there ' s no expire after and a more recent successful snapshot , we can delete all the failed ones if ( this expire after = = null & & unsuccessful states contains ( si state ( ) ) & & newest successful timestamp > si start time ( ) ) { / / there ' s no expire after and there ' s a more recent successful snapshot , delete this failed one logger trace ( " [ { } ] : eligible as it is { } and there is a more recent successful snapshot " , snap name , si state ( ) ) ; return true ; } / / next , enforce the maximum count , if the size is over the maximum number of / / snapshots , then allow the oldest n ( where n is the number over the maximum snapshot / / count ) snapshots to be eligible for deletion if ( this maximum snapshot count ! = null ) { if ( successful snapshot count > this maximum snapshot count ) { final long snaps to delete = successful snapshot count - this maximum snapshot count ; final boolean eligible = sorted snapshots stream ( ) limit ( snaps to delete ) any match ( s - > s equals ( si ) ) ; if ( eligible ) { logger trace ( " [ { } ] : eligible as it is one of the { } oldest snapshots with " + " { } non - failed snapshots ( { } total ) , over the limit of { } maximum snapshots " , snap name , snaps to delete , successful snapshot count , total snapshot count , this maximum snapshot count ) ; return true ; } else { logger trace ( " [ { } ] : ineligible as it is not one of the { } oldest snapshots with " + " { } non - failed snapshots ( { } total ) , over the limit of { } maximum snapshots " , snap name , snaps to delete , successful snapshot count , total snapshot count , this maximum snapshot count ) ; return false ; } } } / / next check the minimum count , since that is a blanket requirement regardless of time , / / if we haven ' t hit the minimum then we need to keep the snapshot regardless of / / expiration time if ( this minimum snapshot count ! = null ) { if ( successful snapshot count < = this minimum snapshot count ) if ( unsuccessful states contains ( si state ( ) ) = = false ) { logger trace ( " [ { } ] : ineligible as there are { } non - failed snapshots ( { } total ) and { } minimum snapshots needed " , snap name , successful snapshot count , total snapshot count , this minimum snapshot count ) ; return false ; } else { logger trace ( " [ { } ] : skipping minimum snapshot count check as this snapshot is { } and not counted " + " towards the minimum snapshot count " , snap name , si state ( ) ) ; } } / / finally , check the expiration time of the snapshot , if it is past , then it is / / eligible for deletion if ( this expire after ! = null ) { final time value snapshot age = new time value ( now supplier get as long ( ) - si start time ( ) ) ; if ( this minimum snapshot count ! = null ) { final long eligible for expiration = math max ( 0 , successful snapshot count - minimum snapshot count ) ; / / only the oldest n snapshots are actually eligible , since if we went below this we / / would fall below the configured minimum number of snapshots to keep final stream < snapshot info > successful snaps eligible for expiration = sorted snapshots stream ( ) filter ( snap - > snapshot state success equals ( snap state ( ) ) ) limit ( eligible for expiration ) ; final stream < snapshot info > unsucessful snaps = sorted snapshots stream ( ) filter ( snap - > unsuccessful states contains ( snap state ( ) ) ) ; final set < snapshot info > snaps eligible for expiration = stream concat ( successful snaps eligible for expiration , unsucessful snaps ) collect ( collectors to set ( ) ) ; if ( snaps eligible for expiration contains ( si ) = = false ) { / / this snapshot is * not * one of the n oldest snapshots , so even if it were / / old enough , the other snapshots would be deleted before it logger trace ( " [ { } ] : ineligible as snapshot expiration would pass the " + " minimum number of configured snapshots ( { } ) to keep , regardless of age " , snap name , this minimum snapshot count ) ; return false ; } } if ( snapshot age compare to ( this expire after ) > 0 ) { logger trace ( " [ { } ] : eligible as snapshot age of { } is older than { } " , snap name , snapshot age to human readable string ( 3 ) , this expire after to human readable string ( 3 ) ) ; return true ; } else { logger trace ( " [ { } ] : ineligible as snapshot age of { } is newer than { } " , snap name , snapshot age to human readable string ( 3 ) , this expire after to human readable string ( 3 ) ) ; return false ; } } / / if nothing matched , the snapshot is not eligible for deletion logger trace ( " [ { } ] : ineligible as no retention predicates matched " , snap name ) ; return false ; } ; }


public boolean is empty ( ) { return size = = 0 ; }


excludes the defined { @ link documentation feature } from the set of supported features

public builder exclude documentation features ( documentation feature documentation feature ) { this documentation features remove all ( arrays stream ( documentation feature ) collect ( collectors to list ( ) ) ) ; return this ; }


converts this demangled datatype into the corresponding ghidra datatype

public data type get data type ( data type manager data type manager ) { string name = get name ( ) ; if ( name = = null ) { return data type default ; } data type dt = null ; if ( namespace = = null ) { dt = get built in type ( data type manager ) ; } if ( dt = = null ) { dt = find data type ( data type manager , namespace , name ) ; data type base type = dt ; if ( dt instanceof type def ) { base type = ( ( type def ) dt ) get base data type ( ) ; } if ( is struct ( ) ) { if ( base type = = null | | ! ( base type instanceof structure ) ) { / / fill it with nonsense dt = create place holder structure ( name , get namespace ( ) ) ; } } else if ( is union ( ) ) { if ( base type = = null | | ! ( base type instanceof union ) ) { dt = new union data type ( get demangler category path ( name , get namespace ( ) ) , name ) ; } } else if ( is enum ( ) ) { if ( base type = = null | | ! ( base type instanceof enum ) ) { if ( enum type = = null | | int equals ( enum type ) | | unsigned int equals ( enum type ) ) { / / can ' t tell how big an enum is , just use the size of a pointer dt = new enum data type ( get demangler category path ( name , get namespace ( ) ) , name , data type manager get data organization ( ) get integer size ( ) ) ; } else if ( char equals ( enum type ) | | unsigned char equals ( enum type ) ) { dt = new enum data type ( get demangler category path ( name , get namespace ( ) ) , name , data type manager get data organization ( ) get char size ( ) ) ; } else if ( short equals ( enum type ) | | unsigned short equals ( enum type ) ) { dt = new enum data type ( get demangler category path ( name , get namespace ( ) ) , name , data type manager get data organization ( ) get short size ( ) ) ; } else if ( long equals ( enum type ) | | unsigned long equals ( enum type ) ) { dt = new enum data type ( get demangler category path ( name , get namespace ( ) ) , name , data type manager get data organization ( ) get long size ( ) ) ; } else { dt = new enum data type ( get demangler category path ( name , get namespace ( ) ) , name , data type manager get data organization ( ) get integer size ( ) ) ; } } } else if ( is class ( ) | | name equals ( string ) ) { if ( base type = = null | | ! ( base type instanceof structure ) ) { / / try creating empty structures for unknown types instead dt = create place holder structure ( name , get namespace ( ) ) ; } } else if ( dt = = null ) { / / i don ' t know what this is / / if it isn ' t pointed to , or isn ' t a referent , then assume typedef if ( ! ( is reference ( ) | | is pointer ( ) ) ) { / / unknown type dt = new typedef data type ( get demangler category path ( name , get namespace ( ) ) , name , new d word data type ( ) ) ; } else { / / try creating empty structures for unknown types instead dt = create place holder structure ( name , get namespace ( ) ) ; } } } int num pointers = get pointer levels ( ) ; if ( is reference ( ) ) { num pointers + + ; } for ( int i = 0 ; i < num pointers ; + + i ) { dt = pointer data type get pointer ( dt , data type manager ) ; } return dt ; }


set the entity manager factory that this instance should manage transactions for alternatively , specify the persistence unit name of the target entity manager factory by default , a default entity manager factory will be retrieved by finding a single unique bean of type entity manager factory in the containing bean factory

public void set entity manager factory ( @ nullable entity manager factory emf ) { this entity manager factory = emf ; }


public collection < ws get groups result > get groups for subject id ( final string subject id ) { try { val results = fetch groups for ( subject id ) ; if ( results = = null | | results length = = 0 ) { logger warn ( " subject id [ { } ] could not be located " , subject id ) ; return new array list < > ( 0 ) ; } logger debug ( " found [ { } ] groups for [ { } ] " , results length , subject id ) ; return collection utils wrap list ( results ) ; } catch ( final exception e ) { logger warn ( " grouper ws did not respond successfully ensure your credentials are correct " + " , the url endpoint for grouper ws is correctly configured and the subject [ { } ] exists in grouper " , subject id , e ) ; } return new array list < > ( 0 ) ; }


creates an instruction at the specified address

public instruction create code unit ( address address , instruction prototype prototype , mem buffer mem buf , processor context view context ) throws code unit insertion exception { lock acquire ( ) ; creating instruction = true ; try { address end addr = address add no wrap ( prototype get length ( ) - 1 ) ; check valid address range ( address , end addr ) ; instruction d b inst = add instruction ( address , end addr , prototype , mem buf , context ) ; / / fire event program set changed ( change manager docr code added , address , end addr , null , inst ) ; return inst ; } catch ( address overflow exception e ) { throw new code unit insertion exception ( " code unit would extend beyond address space " ) ; } catch ( i o exception e ) { program db error ( e ) ; } finally { creating instruction = false ; lock release ( ) ; } return null ; }


this isn ' t a test of what we " should " accept as a span , rather that characters that trip - up json don ' t fail in span parser

public void span special chars in json ( ) { / / service name is surrounded by control characters endpoint e = endpoint new builder ( ) service name ( new string ( new char [ ] { 0 , ' a ' , 1 } ) ) build ( ) ; span worst span in the world = span new builder ( ) trace id ( " 1 " ) id ( " 1 " ) / / name is terrible name ( new string ( new char [ ] { ' " ' , ' \ \ ' , ' \ t ' , ' \ b ' , ' \ n ' , ' \ r ' , ' \ f ' } ) ) local endpoint ( e ) / / annotation value includes some json newline characters add annotation ( 1l , " \ u 2 0 2 8 and \ u 2 0 2 9 " ) / / binary annotation key includes a quote and value newlines put tag ( " \ " foo " , " database error : ora - 00942 : \ u 2 0 2 8 and \ u 2 0 2 9 table or view does not exist \ n " ) build ( ) ; assert that ( parse ( span parser , new string ( span bytes encoder json v2 encode ( worst span in the world ) , utf 8 ) ) ) is equal to ( worst span in the world ) ; }


int get bytes per line ( ) { return bytes in line int value ( ) ; }


default links produced by { @ link test objects # new trace ( string ) }

static iterable < ? extends dependency link > links ( string test suffix ) { string frontend = append suffix ( test objects frontend service name ( ) , test suffix ) ; string backend = append suffix ( test objects backend service name ( ) , test suffix ) ; string db = append suffix ( test objects db service name ( ) , test suffix ) ; return as list ( dependency link new builder ( ) parent ( frontend ) child ( backend ) call count ( 1l ) build ( ) , dependency link new builder ( ) parent ( backend ) child ( db ) call count ( 1l ) error count ( 1l ) build ( ) ) ; }


links an { @ link event } to a specific { @ link handler }

public < e extends event > void register handler ( class < e > event type , handler < e > handler ) { handlers put ( event type , handler ) ; }


a sensible default implementation of { @ link # list iterator ( int ) } , in terms of { @ link # size } , { @ link # get ( int ) } , { @ link # set ( int , object ) } , { @ link # add ( int , object ) } , and { @ link # remove ( int ) } if you override any of these methods , you may wish to override { @ link # list iterator ( int ) } to forward to this implementation

protected list iterator < e > standard list iterator ( int start ) { return lists list iterator impl ( this , start ) ; }


check the origin and determine the origin for the response the default implementation simply delegates to { @ link cors configuration # check origin ( string ) }

protected string check origin ( cors configuration config , @ nullable string request origin ) { return config check origin ( request origin ) ; }


configure notification sender notification sender

notification sender configure notification sender ( ) ;


if reset block report time is false then the next block report must be scheduled exactly at ( now + block report interval sec )

public void test schedule next block report 2 ( ) { for ( final long now : get timestamps ( ) ) { scheduler scheduler = make mock scheduler ( now ) ; scheduler reset block report time = false ; scheduler schedule next block report ( ) ; assert that ( scheduler next block report time , is ( now + block report interval ms ) ) ; } }


attempts to inflate { @ code length } bytes of data into { @ code b } any gzipped bytes consumed by this method will be added to the counter returned by { @ link # get and reset bytes consumed ( ) } this method may consume gzipped bytes without writing any data to { @ code b } , and may also write data to { @ code b } without consuming additional gzipped bytes ( if the inflater on an earlier call consumed the bytes necessary to produce output )

int inflate bytes ( byte [ ] b , int offset , int length ) throws data format exception , zip exception { check state ( ! closed , " gzip inflating buffer is closed " ) ; int bytes read = 0 ; int missing bytes ; boolean made progress = true ; while ( made progress & & ( missing bytes = length - bytes read ) > 0 ) { switch ( state ) { case header : made progress = process header ( ) ; break ; case header extra len : made progress = process header extra len ( ) ; break ; case header extra : made progress = process header extra ( ) ; break ; case header name : made progress = process header name ( ) ; break ; case header comment : made progress = process header comment ( ) ; break ; case header crc : made progress = process header crc ( ) ; break ; case initialize inflater : made progress = initialize inflater ( ) ; break ; case inflating : bytes read + = inflate ( b , offset + bytes read , missing bytes ) ; if ( state = = state trailer ) { / / eagerly process trailer , if available , to validate crc made progress = process trailer ( ) ; } else { / / continue in inflating until we have the required bytes or we transition to / / inflater needs input made progress = true ; } break ; case inflater needs input : made progress = fill ( ) ; break ; case trailer : made progress = process trailer ( ) ; break ; default : throw new assertion error ( " invalid state : " + state ) ; } } / / if we finished a gzip block , check if we have enough bytes to read another header is stalled = ! made progress | | ( state = = state header & & gzip metadata reader readable bytes ( ) < gzip header min size ) ; return bytes read ; }


given a string representation of a rack for a specific network location to be overridden in subclasses for specific network topology implementations , as alternative to overriding the full { @ link # get rack ( string ) } method

public string get rack ( string loc ) { return loc ; }


returns a random int within 0 - integer max value

public static int next int ( ) { return next int ( 0 , integer max value ) ; }


public void delete pet test ( ) { long pet id = null ; string api key = null ; / / api delete pet ( pet id , api key ) ; / / todo : test validations }


dispose of the completion window resources

protected void destroy completion window ( ) { completion window remove ( content ) ; completion window dispose ( ) ; completion window = null ; }


returns whether or not to use the inlined version of bzl load function in this test

protected boolean uses inlining bzl load function ( ) { return false ; }


register a new { @ link default application events } instance to be used for the current thread

static void register application events ( ) { application events set ( new default application events ( ) ) ; }


public list < integer > get array item ( ) { return array item ; }


long last end time ms ( ) { return last end time ms ; }


protected boolean is grant type supported by ( final o auth registered service registered service , final string type ) { return o auth 2 0 utils is authorized grant type for service ( type , registered service ) ; }


tests delta evictor , evict after behavior

public void test delta evictor evict after ( ) throws exception { atomic integer close called = new atomic integer ( 0 ) ; final int trigger count = 2 ; final boolean evict after = true ; final int threshold = 2 ; @ suppress warnings ( { " unchecked " , " rawtypes " } ) type serializer < stream record < tuple 2 < string , integer > > > stream record serializer = ( type serializer < stream record < tuple 2 < string , integer > > > ) new stream element serializer ( string int tuple create serializer ( new execution config ( ) ) ) ; list state descriptor < stream record < tuple 2 < string , integer > > > state desc = new list state descriptor < > ( " window - contents " , stream record serializer ) ; evicting window operator < string , tuple 2 < string , integer > , tuple 2 < string , integer > , global window > operator = new evicting window operator < > ( global windows create ( ) , new global window serializer ( ) , new tuple key selector ( ) , basic type info string type info create serializer ( new execution config ( ) ) , state desc , new internal iterable window function < > ( new rich sum reducer < global window > ( close called ) ) , count trigger of ( trigger count ) , delta evictor of ( threshold , new delta function < tuple 2 < string , integer > > ( ) { @ override public double get delta ( tuple 2 < string , integer > old data point , tuple 2 < string , integer > new data point ) { return new data point f 1 - old data point f 1 ; } } , evict after ) , 0 , null / * late data output tag * / ) ; one input stream operator test harness < tuple 2 < string , integer > , tuple 2 < string , integer > > test harness = new keyed one input stream operator test harness < > ( operator , new tuple key selector ( ) , basic type info string type info ) ; long initial time = 0l ; concurrent linked queue < object > expected output = new concurrent linked queue < > ( ) ; test harness open ( ) ; test harness process element ( new stream record < > ( new tuple 2 < > ( " key 2 " , 1 ) , initial time + 3000 ) ) ; test harness process element ( new stream record < > ( new tuple 2 < > ( " key 2 " , 4 ) , initial time + 3999 ) ) ; test harness process element ( new stream record < > ( new tuple 2 < > ( " key 1 " , 1 ) , initial time + 20 ) ) ; test harness process element ( new stream record < > ( new tuple 2 < > ( " key 1 " , 1 ) , initial time ) ) ; test harness process element ( new stream record < > ( new tuple 2 < > ( " key 1 " , 5 ) , initial time + 999 ) ) ; test harness process element ( new stream record < > ( new tuple 2 < > ( " key 2 " , 5 ) , initial time + 1998 ) ) ; test harness process element ( new stream record < > ( new tuple 2 < > ( " key 2 " , 6 ) , initial time + 1999 ) ) ; test harness process element ( new stream record < > ( new tuple 2 < > ( " key 2 " , 1 ) , initial time + 1000 ) ) ; expected output add ( new stream record < > ( new tuple 2 < > ( " key 2 " , 5 ) , long max value ) ) ; expected output add ( new stream record < > ( new tuple 2 < > ( " key 2 " , 15 ) , long max value ) ) ; expected output add ( new stream record < > ( new tuple 2 < > ( " key 1 " , 2 ) , long max value ) ) ; test harness util assert output equals sorted ( " output was not correct " , expected output , test harness get output ( ) , new result sort comparator ( ) ) ; test harness process element ( new stream record < > ( new tuple 2 < > ( " key 1 " , 9 ) , initial time + 10999 ) ) ; test harness process element ( new stream record < > ( new tuple 2 < > ( " key 2 " , 10 ) , initial time + 1000 ) ) ; expected output add ( new stream record < > ( new tuple 2 < > ( " key 1 " , 16 ) , long max value ) ) ; expected output add ( new stream record < > ( new tuple 2 < > ( " key 2 " , 22 ) , long max value ) ) ; test harness util assert output equals sorted ( " output was not correct " , expected output , test harness get output ( ) , new result sort comparator ( ) ) ; test harness close ( ) ; assert assert equals ( " close was not called " , 1 , close called get ( ) ) ; }


test if block scheduled counter decrement if scheduled blocks file is deleted

public void test scheduled blocks counter decrement on deleted block ( ) throws exception { final configuration conf = new hdfs configuration ( ) ; conf set long ( d f s config keys dfs block size key , 1024 ) ; conf set long ( d f s config keys dfs heartbeat interval key , 1 ) ; conf set int ( d f s config keys dfs namenode redundancy interval seconds key , 1 ) ; cluster = new mini d f s cluster builder ( conf ) num data nodes ( 5 ) build ( ) ; cluster wait active ( ) ; block manager bm = cluster get namesystem ( ) get block manager ( ) ; try { distributed file system dfs = cluster get file system ( ) ; / / 1 create a file path file path = new path ( " / tmp txt " ) ; d f s test util create file ( dfs , file path , 1024 , ( short ) 3 , 0l ) ; / / 2 disable the heartbeats for ( data node dn : cluster get data nodes ( ) ) { data node test utils set heartbeats disabled for tests ( dn , true ) ; } datanode manager datanode manager = cluster get namesystem ( ) get block manager ( ) get datanode manager ( ) ; array list < datanode descriptor > dn list = new array list < datanode descriptor > ( ) ; datanode manager fetch datanodes ( dn list , dn list , false ) ; / / 3 mark a couple of blocks as corrupt located block block = name node adapter get block locations ( cluster get name node ( ) , file path to string ( ) , 0 , 1 ) get ( 0 ) ; datanode info [ ] locs = block get locations ( ) ; cluster get namesystem ( ) write lock ( ) ; try { bm find and mark block as corrupt ( block get block ( ) , locs [ 0 ] , " storage id " , " test " ) ; bm find and mark block as corrupt ( block get block ( ) , locs [ 1 ] , " storage id " , " test " ) ; block manager test util compute all pending work ( bm ) ; block manager test util update state ( bm ) ; assert equals ( 1l , bm get pending reconstruction blocks count ( ) ) ; } finally { cluster get namesystem ( ) write unlock ( ) ; } / / 4 delete the file dfs delete ( file path , true ) ; int blocks scheduled = 0 ; for ( datanode descriptor descriptor : dn list ) { if ( descriptor get blocks scheduled ( ) ! = 0 ) { blocks scheduled + = descriptor get blocks scheduled ( ) ; } } assert equals ( 0 , blocks scheduled ) ; } finally { cluster shutdown ( ) ; } }


returns a { @ link package identifier } identifying the most specific containing directory of the patterns that could be matched by this pattern note that we are using the { @ link package identifier } type as a convenience ; there may not actually be a package corresponding to this directory ! this returns a { @ link package identifier } that identifies the referred - to directory for example , for " foobar " , this method returns a { @ link package identifier } for " foobar "

public package identifier get directory ( ) { return directory ; }


public list < file path > list directories ( ) throws i o exception , interrupted exception { return list ( new directory filter ( ) ) ; }


public object remove ( int index ) { object o = opt ( index ) ; this my array list remove ( index ) ; return o ; }


gets all the topologies which needs scheduling

public list < topology details > needs scheduling topologies ( topologies topologies ) { list < topology details > ret = new array list < topology details > ( ) ; for ( topology details topology : topologies get topologies ( ) ) { if ( needs scheduling ( topology ) ) { ret add ( topology ) ; } } return ret ; }


ensures that all middleman artifacts in the action input are expanded so that the real inputs are also included

protected iterable < artifact > get expanded action inputs ( action action ) { list < artifact > contained artifacts = new array list < > ( ) ; for ( artifact input : action get inputs ( ) to list ( ) ) { if ( input is middleman artifact ( ) ) { action middleman action = get generating action ( input ) ; iterables add all ( contained artifacts , get expanded action inputs ( middleman action ) ) ; } contained artifacts add ( input ) ; } return contained artifacts ; }


returns whether the minimum os version is explicitly set for the current platform

public dotted version get minimum os version ( ) { dotted version option option ; switch ( apple platform type ) { case ios : case catalyst : option = ios minimum os ; break ; case macos : option = macos minimum os ; break ; case tvos : option = tvos minimum os ; break ; case watchos : option = watchos minimum os ; break ; default : throw new illegal state exception ( ) ; } return dotted version maybe unwrap ( option ) ; }


creates a { @ link state ttl config } depends on retention time parameter

public static state ttl config create ttl config ( long retention time ) { if ( retention time > 0 ) { return state ttl config new builder ( time milliseconds ( retention time ) ) set update type ( state ttl config update type on create and write ) set state visibility ( state ttl config state visibility never return expired ) build ( ) ; } else { return state ttl config disabled ; } }


injects the metadata of a file this can be used to save filesystem operations when the metadata is already known { @ linkplain artifact # is tree artifact tree artifacts } and their { @ linkplain artifact # is child of declared directory children } must not be passed here instead , they should be passed to { @ link # inject tree }

void inject file ( artifact output , file artifact value metadata ) ;


adds the given element to this queue if the queue is currently full , the element at the head of the queue is evicted to make room

public boolean offer ( e e ) { return add ( e ) ; }


selects the given row this is a convenience method for { @ link # set row selection interval ( int , int ) }

public void select row ( int row ) { set row selection interval ( row , row ) ; }


checks whether a specific text matches the defined grok expression

public boolean match ( string text ) { matcher matcher = compiled expression matcher ( text get bytes ( standard charsets utf 8 ) ) ; int result ; try { matcher watchdog register ( matcher ) ; result = matcher search ( 0 , text length ( ) , option default ) ; } finally { matcher watchdog unregister ( matcher ) ; } return ( result ! = - 1 ) ; }


reads the output file and parses the summation of lengths , the word count , and the lengths squared , to perform a quick calculation of the standard deviation

private double read and calc std dev ( path path , configuration conf ) throws i o exception { file system fs = file system get ( conf ) ; path file = new path ( path , " part - r - 00000 " ) ; if ( ! fs exists ( file ) ) throw new i o exception ( " output not found ! " ) ; double stddev = 0 ; buffered reader br = null ; try { br = new buffered reader ( new input stream reader ( fs open ( file ) , charsets utf 8 ) ) ; long count = 0 ; long length = 0 ; long square = 0 ; string line ; while ( ( line = br read line ( ) ) ! = null ) { string tokenizer st = new string tokenizer ( line ) ; / / grab type string type = st next token ( ) ; / / differentiate if ( type equals ( count to string ( ) ) ) { string count lit = st next token ( ) ; count = long parse long ( count lit ) ; } else if ( type equals ( length to string ( ) ) ) { string length lit = st next token ( ) ; length = long parse long ( length lit ) ; } else if ( type equals ( square to string ( ) ) ) { string square lit = st next token ( ) ; square = long parse long ( square lit ) ; } } / / average = total sum / number of elements ; double mean = ( ( ( double ) length ) / ( ( double ) count ) ) ; / / standard deviation = sqrt ( ( sum ( lengths ^ 2 ) / count ) - ( mean ^ 2 ) ) mean = math pow ( mean , 2 0 ) ; double term = ( ( ( double ) square / ( ( double ) count ) ) ) ; stddev = math sqrt ( ( term - mean ) ) ; system out println ( " the standard deviation is : " + stddev ) ; } finally { if ( br ! = null ) { br close ( ) ; } } return stddev ; }


the same logic as { @ link # expand jobs ids ( string , boolean , boolean , persistent tasks custom metadata , boolean , action listener ) } but the full anomaly detector job configuration is returned see { @ link # expand jobs ids ( string , boolean , boolean , persistent tasks custom metadata , boolean , action listener ) }

public void expand jobs ( string expression , boolean allow no match , boolean exclude deleting , action listener < list < job builder > > listener ) { string [ ] tokens = expanded ids matcher tokenize expression ( expression ) ; search source builder source builder = new search source builder ( ) query ( build job wildcard query ( tokens , exclude deleting ) ) ; source builder sort ( job id get preferred name ( ) ) ; search request search request = client prepare search ( ml config index index name ( ) ) set indices options ( indices options lenient expand open ( ) ) set source ( source builder ) set size ( anomaly detectors index config index max results window ) request ( ) ; expanded ids matcher required matches = new expanded ids matcher ( tokens , allow no match ) ; execute async with origin ( client thread pool ( ) get thread context ( ) , ml origin , search request , action listener < search response > wrap ( response - > { list < job builder > jobs = new array list < > ( ) ; set < string > job and group ids = new hash set < > ( ) ; search hit [ ] hits = response get hits ( ) get hits ( ) ; for ( search hit hit : hits ) { try { bytes reference source = hit get source ref ( ) ; job builder job = parse job leniently from source ( source ) ; jobs add ( job ) ; job and group ids add ( job get id ( ) ) ; job and group ids add all ( job get groups ( ) ) ; } catch ( i o exception e ) { / / todo a better way to handle this rather than just ignoring the error ? logger error ( " error parsing anomaly detector job configuration [ " + hit get id ( ) + " ] " , e ) ; } } required matches filter matched ids ( job and group ids ) ; if ( required matches has unmatched ids ( ) ) { / / some required jobs were not found listener on failure ( exceptions helper missing job exception ( required matches unmatched ids string ( ) ) ) ; return ; } listener on response ( jobs ) ; } , listener : : on failure ) , client : : search ) ; }


get the sources of the function scope symbols

public source type [ ] get function scope symbol sources ( ) { return function scope symbol sources ; }


public void verify saml profile request if needed ( final request abstract type profile request , final saml registered service service provider metadata facade adaptor , final http servlet request request , final message context context ) throws exception { verify saml profile request if needed ( profile request , adaptor get metadata resolver ( ) , request , context ) ; }


creates a new ewma which is equivalent to the unix five minute load average and which expects to be ticked every 5 seconds

public static ewma five minute e w m a ( ) { return new ewma ( m5 alpha , interval , time unit seconds ) ; }


configure the { @ code encoder } to use for server - sent events by default if this is not set , and jackson is available , the { @ link # jackson 2 json encoder } override is used instead use this method to customize the sse encoder

void server sent event encoder ( encoder < ? > encoder ) ;


returns a predicate that always evaluates to { @ code true }

public static < t > predicate < t > always true ( ) { return object predicate always true with narrowed type ( ) ; }


install a custom e g l context factory if this method is called , it must be called before { @ link # set renderer ( renderer ) } is called if this method is not called , then by default a context will be created with no shared context and with a null attribute list

public void set e g l context factory ( e g l context factory factory ) { check render thread state ( ) ; egl context factory = factory ; }