test that bad request exception behavior works the same on a cached response

public void test bad request exception via queue in thread on response from cache ( ) throws exception { test circuit breaker circuit breaker = new test circuit breaker ( ) ; / / execute once to cache the value bad request command command 1 = null ; try { command 1 = new bad request command ( circuit breaker , execution isolation strategy thread ) ; command 1 execute ( ) ; } catch ( throwable e ) { / / ignore } bad request command command 2 = null ; try { command 2 = new bad request command ( circuit breaker , execution isolation strategy thread ) ; command 2 queue ( ) get ( ) ; fail ( " we expect to receive a " + hystrix bad request exception class get simple name ( ) ) ; } catch ( execution exception e ) { e print stack trace ( ) ; if ( e get cause ( ) instanceof hystrix bad request exception ) { / / success } else { fail ( " we expect a " + hystrix bad request exception class get simple name ( ) + " but got a " + e get class ( ) get simple name ( ) ) ; } } assert command execution events ( command 1 , hystrix event type bad request ) ; assert command execution events ( command 2 , hystrix event type bad request , hystrix event type response from cache ) ; assert equals ( 0 , circuit breaker metrics get current concurrent execution count ( ) ) ; assert sane hystrix request log ( 2 ) ; }


sets this task to be skipped returns true if the task will be skipped , false if the task has already started

boolean skip ( ) { / * * threads may still get run although future # cancel returns true we make sure that a task is either cancelled ( or skipped ) , * or entirely run in the odd case that future # cancel returns true and the thread still runs , the task won ' t do anything * in case future # cancel returns true but the task has already started , this state change will not succeed hence this method * returns false and the task will normally run * / return task state compare and set ( task state waiting , task state skipped ) ; }


save away the user ' s original partitioner before we override it

static void set java partitioner ( job conf conf , class cls ) { conf set ( submitter partitioner , cls get name ( ) ) ; }


public void update n clob ( int column index , reader reader , long length ) throws s q l exception { }


a set of pairs of reported source file path and the actual source file path , relative to the workspace directory , if the two values are different if the reported source file is the same as the actual source path it will not be included in this set this is useful for virtual include paths in c + + , which get reported at the include location and not the real source path for example , the reported include source file can be " bazel - outk 8 - fastbuildbinincludecommon virtual includesstrategystrategy h " , but its actual source path is " includecommonstrategy h "

public nested set < pair < string , string > > get reported to actual sources ( ) { return reported to actual sources ; }


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


generate variable storage serialization string

public static string get serialization string ( varnode varnodes ) { if ( varnodes = = null | | varnodes length = = 0 ) { throw new illegal argument exception ( " varnodes may not be null or empty " ) ; } string builder str builder = new string builder ( ) ; for ( varnode v : varnodes ) { if ( str builder length ( ) ! = 0 ) { str builder append ( " , " ) ; } str builder append ( v get address ( ) to string ( true ) ) ; str builder append ( " : " ) ; str builder append ( integer to string ( v get size ( ) ) ) ; } return str builder to string ( ) ; }


resets everything including the input buffers ( user and direct )

public synchronized void reset ( ) { check stream ( ) ; end ( stream ) ; stream = init ( conserve memory ? 1 : 0 ) ; finished = false ; compressed direct buf off = compressed direct buf len = 0 ; uncompressed direct buf limit ( direct buffer size ) ; uncompressed direct buf position ( direct buffer size ) ; user buf off = user buf len = 0 ; }


when parameter is annotated then jersey classifies such parameter as { @ link org glassfish jersey server model parameter source # unknown } instead of { @ link org glassfish jersey server model parameter source # entity } which is used for unannotated parameters value factory provider resolution logic is different for these two sources therefore must be tested separately

public void annotated json principal entity resource without auth 2 0 0 ( ) { string principal name = " astar seran " ; assert that ( target ( " / no - auth - test / annotated - json - principal - entity " ) request ( ) header ( http headers authorization , " anything here " ) post ( entity entity ( new json principal ( principal name ) , media type application json ) ) read entity ( string class ) ) is equal to ( principal name ) ; }


returns the name to use when converting into a structure data type

public string get name ( ) { return " image nt headers " + ( optional header is 6 4bit ( ) ? " 64 " : " 32 " ) ; }


the main loop for the thread the loop does the following : check the states of the running jobs update the states of waiting jobs submit the jobs in ready state

public void run ( ) { if ( is circular ( jobs in progress ) ) { throw new illegal argument exception ( " job control has circular dependency " ) ; } try { this runner state = thread state running ; while ( true ) { while ( this runner state = = thread state suspended ) { try { thread sleep ( 5000 ) ; } catch ( exception e ) { / / todo the thread was interrupted , do something ! ! ! } } synchronized ( this ) { iterator < controlled job > it = jobs in progress iterator ( ) ; while ( it has next ( ) ) { controlled job j = it next ( ) ; log debug ( " checking state of job " + j ) ; switch ( j check state ( ) ) { case success : successful jobs add ( j ) ; it remove ( ) ; break ; case failed : case dependent failed : failed jobs add ( j ) ; it remove ( ) ; break ; case ready : j submit ( ) ; break ; case running : case waiting : / / do nothing break ; } } } if ( this runner state ! = thread state running & & this runner state ! = thread state suspended ) { break ; } try { thread sleep ( 5000 ) ; } catch ( exception e ) { / / todo the thread was interrupted , do something ! ! ! } if ( this runner state ! = thread state running & & this runner state ! = thread state suspended ) { break ; } } } catch ( throwable t ) { log error ( " error while trying to run jobs " , t ) ; / / mark all jobs as failed because we got something bad fail all jobs ( t ) ; } this runner state = thread state stopped ; }


reads the mapping file , ignoring comments and replacing placeholders for random types

private static string read mapping ( url resource ) throws i o exception { try ( buffered reader reader = test utils reader ( resource ) ) { string builder b = new string builder ( ) ; string line ; while ( ( line = reader read line ( ) ) ! = null ) { if ( line starts with ( " # " ) = = false ) { for ( entry < string , string [ ] > entry : replacement patterns entry set ( ) ) { line = line replace ( entry get key ( ) , random of ( entry get value ( ) ) ) ; } b append ( line ) ; } } return b to string ( ) ; } }


obtient la valeur de la propriété loginname

public string get loginname ( ) { return loginname ; }


convenient method to find a single object given a single int parameter and a context

public t find object ( int p 1 , @ nullable map < ? , ? > context ) throws data access exception { return find object ( new object [ ] { p 1 } , context ) ; }


public void write ( byte [ ] bytes , int offset , int length ) { int write at = cursor ; int end = write at + length ; int bytes end = offset + length ; / / twos - complement math trick : ( ( x < 0 ) | | ( y < 0 ) ) < = > ( ( x | y ) < 0 ) if ( ( ( offset | length | end ) < 0 ) | | ( bytes end > bytes length ) ) { throw new index out of bounds exception ( " bytes length " + bytes length + " ; " + offset + " ! " + end ) ; } if ( stretchy ) { ensure capacity ( end ) ; } else if ( end > data length ) { throw bounds ( ) ; return ; } system arraycopy ( bytes , offset , data , write at , length ) ; cursor = end ; }


gets the memory footprint of the jvm in a string representation

public static string get memory usage stats as string ( memory m x bean memory m x bean ) { memory usage heap = memory m x bean get heap memory usage ( ) ; memory usage non heap = memory m x bean get non heap memory usage ( ) ; long heap used = heap get used ( ) > > 20 ; long heap committed = heap get committed ( ) > > 20 ; long heap max = heap get max ( ) > > 20 ; long non heap used = non heap get used ( ) > > 20 ; long non heap committed = non heap get committed ( ) > > 20 ; long non heap max = non heap get max ( ) > > 20 ; return string format ( " memory usage stats : [ heap : % d / % d / % d mb , " + " non heap : % d / % d / % d mb ( used / committed / max ) ] " , heap used , heap committed , heap max , non heap used , non heap committed , non heap max ) ; }


replace the root pane to enable the themed title bar

private static void replace root pane ( final u i defaults defaults ) { defaults put ( " root pane u i " , m t root pane u i class get name ( ) ) ; defaults put ( m t root pane u i class get name ( ) , m t root pane u i class ) ; }


determine whether the hash code of the content of this value holder note that value holder does not implement { @ code hash code } directly , to allow for multiple value holder instances with the same content to reside in the same set

private int content hash code ( ) { return object utils null safe hash code ( this value ) * 29 + object utils null safe hash code ( this type ) ; }


add a configuration resource the properties of this resource will override properties of previously added resources , unless they were marked < a href = " # final " > final

public void add resource ( input stream in , string name ) { add resource object ( new resource ( in , name ) ) ; }


finds the most appropriate field to place the cursor for the given horizontal position if the position is between fields , first try to the left and if that doesn ' t work , try to the right

int find appropriate field index ( int x , int y ) { y - = height above ; / / first check to the left for ( int i = fields length - 1 ; i > = 0 ; i - - ) { if ( fields [ i ] ! = null ) { if ( y > = - fields [ i ] get height above ( ) & & y < fields [ i ] get height below ( ) & & fields [ i ] get start x ( ) < = x ) { return i ; } } } / / didn ' t work , check to the right for ( int i = 0 ; i < fields length ; i + + ) { if ( fields [ i ] ! = null ) { if ( y > = - fields [ i ] get height above ( ) & & y < fields [ i ] get height below ( ) & & fields [ i ] get start x ( ) > x ) { return i ; } } } / / no matches return - 1 ; } / * * * draws the selection background for individual fields * / / / private void draw selection ( graphics g , int start field , int end field ) { / / int start = fields [ start field ] get start x ( ) ; / / int end = fields [ end field ] get start x ( ) + fields [ end field ] get width ( ) ; / / int width = end - start ; / / g fill rect ( start , 0 , width , height above + height below ) ; / / }


gets the map section this is package - scope in order to allow the header section to query it

/ * package * / mixed item section get map ( ) { return map ; }


check whether the state handle is existing


record statistics and perform rule checking for the given method

entry entry ( method method ) throws block exception ;


tells this provider to refresh , which means to rebuild the graph and relayout the vertices

private void refresh ( boolean keep perspective ) { f g data function graph data = controller get function graph data ( ) ; if ( function graph data has results ( ) ) { / / / / we use the graph ' s data over the ' current x x x ' data , as there is a chance that the / / latter values have been set to new values , while the graph has differing data in / / that case we have made the decision to prefer the graph ' s data / / function function = function graph data get function ( ) ; address address = function get entry point ( ) ; address current address = current location get address ( ) ; if ( function get body ( ) contains ( current address ) ) { / / prefer the current address if it is within the current function ( i e , the / / location hasn ' t changed out from under the graph due to threading issues ) address = current address ; } program program = function get program ( ) ; program location program location = new program location ( program , address ) ; controller rebuild display ( program , program location , keep perspective ) ; return ; } controller rebuild display ( current program , current location , keep perspective ) ; }


connect a { @ link channel } to the remote peer

public channel future connect ( string inet host , int inet port ) { return connect ( inet socket address create unresolved ( inet host , inet port ) ) ; }


creates a table source andor table sink from a descriptor descriptors allow for declaring the communication to external systems in an implementation - agnostic way the classpath is scanned for suitable table factories that match the desired configuration the following example shows how to read from a kafka connector using a json format and registering a table source " my table " in append mode : { @ code table env connect ( new kafka ( ) version ( " 0 11 " ) topic ( " clicks " ) property ( " group id " , " click - group " ) start from earliest ( ) ) with format ( new json ( ) json schema ( " { } " ) fail on missing field ( false ) ) with schema ( new schema ( ) field ( " user - name " , " varchar " ) from ( " u name " ) field ( " count " , " decimal " ) field ( " proc - time " , " timestamp " ) proctime ( ) ) in append mode ( ) create temporary table ( " my table " ) }

stream table descriptor connect ( connector descriptor connector descriptor ) ;


try to retrieve another batch note that for the initial batch , { @ link object listing iterator } does not generate a request ; it simply returns the initial set

private boolean request next batch ( ) throws i o exception { / / look for more object listing batches being available while ( source has next ( ) ) { / / if available , retrieve it and build the next status if ( build next status batch ( source next ( ) ) ) { / / this batch successfully generated entries matching / / the filters / acceptors ; / / declare that the request was successful return true ; } else { log debug ( " all entries in batch were filtered continuing " ) ; } } / / if this code is reached , it means that all remaining / / object lists have been retrieved , and there are no new entries / / to return return false ; }


appends the key - val pair to the passed builder in the following format < pair - delim > key = value

static void add ( keys key , string value , string builder b ) { b append ( audit constants pair separator ) append ( key name ( ) ) append ( audit constants key val separator ) append ( value ) ; }


returns one of the something alphabet byte arrays depending on the options specified it ' s possible , though silly , to specify ordered < b > and < b > urlsafe in which case one of them will be picked , though there is no guarantee as to which one will be picked

private final static byte [ ] get alphabet ( int options ) { if ( ( options & url safe ) = = url safe ) { return url safe alphabet ; } else if ( ( options & ordered ) = = ordered ) { return ordered alphabet ; } else { return standard alphabet ; } }


returns the number of audio samples represented by the given true h d syncframe , or 0 if the buffer is not the start of a syncframe

public static int parse true hd syncframe audio sample count ( byte [ ] syncframe ) { / / see " dolby true h d ( mlp ) high - level bitstream description " on the dolby developer site , / / subsections 2 2 and 4 2 1 the syncword ends 0x b a for true h d or 0x b b for mlp if ( syncframe [ 4 ] ! = ( byte ) 0x f 8 | | syncframe [ 5 ] ! = ( byte ) 0x 7 2 | | syncframe [ 6 ] ! = ( byte ) 0x 6 f | | ( syncframe [ 7 ] & 0x f e ) ! = 0x b a ) { return 0 ; } boolean is mlp = ( syncframe [ 7 ] & 0x f f ) = = 0x b b ; return 40 < < ( ( syncframe [ is mlp ? 9 : 8 ] > > 4 ) & 0x 0 7 ) ; }


merges aspects defined by { @ code aspect keys } into the { @ code target } using previously computed { @ code values }

private static configured target get base target ( configured target target , immutable list < aspect key > aspect keys , map < sky key , sky value > values ) throws duplicate exception { array list < configured aspect > aspect values = new array list < > ( ) ; for ( aspect key aspect key : aspect keys ) { aspect value aspect value = ( aspect value ) values get ( aspect key ) ; configured aspect configured aspect = aspect value get configured aspect ( ) ; aspect values add ( configured aspect ) ; } return merged configured target of ( target , aspect values ) ; }


convenience method to create a model with a single node containing a cone shape the resources the material might contain are not managed , use { @ link model # manage disposable ( disposable ) } to add those to the model

public model create cone ( float width , float height , float depth , int divisions , int primitive type , final material material , final long attributes , float angle from , float angle to ) { begin ( ) ; part ( " cone " , primitive type , attributes , material ) cone ( width , height , depth , divisions , angle from , angle to ) ; return end ( ) ; }


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


retrieve the name of the value class for this sequence file

public string get value class name ( ) { return in get value class name ( ) ; }


writes project - specific ant properties , which get imported by the module project ' s language build xml file to allow building against a ghidra that lives in an external location if the given project is not a ghidra module project , or if the ghidra module project does not have a language build language xml ant file , this method has no effect

public static void write ant properties ( i project project , ghidra application layout ghidra layout ) throws i o exception { if ( ! ghidra project utils is ghidra module project ( project ) ) { return ; } i folder data folder = project get folder ( " data " ) ; if ( ! data folder exists ( ) ) { return ; } i file build xml file = data folder get file ( " build language xml " ) ; if ( ! build xml file exists ( ) ) { return ; } file ghidra install dir = ghidra layout get application installation dir ( ) get file ( false ) ; file ant file = new file ( project get location ( ) to file ( ) , " ant properties xml " ) ; / / hidden try ( print writer writer = new print writer ( new file writer ( ant file ) ) ) { writer println ( " < ! - - this file is generated on each \ " link ghidra \ " command do not modify - - > " ) ; writer println ( ) ; writer println ( " < project > " ) ; writer println ( " < property name = \ " ghidra install dir \ " value = \ " " + ghidra install dir get absolute path ( ) + " \ " / > " ) ; writer println ( " < / project > " ) ; } }


create a primary logger for the given class and wrap it with a composite that delegates to it or to the fallback logger " org springframework web http logging " , if the primary is not enabled

public static log for log name ( class < ? > primary logger class ) { log primary logger = log factory get log ( primary logger class ) ; return for log ( primary logger ) ; }


returns those node properties which can be configured as global node properties

public static list < node property descriptor > get global node property descriptors ( ) { list < node property descriptor > result = new array list < > ( ) ; collection < node property descriptor > list = ( collection ) jenkins get ( ) get descriptor list ( node property class ) ; for ( node property descriptor npd : list ) { if ( npd is applicable as global ( ) ) { result add ( npd ) ; } } return result ; }


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 " ) ; }


check whether this resolver is supposed to apply ( i e if the supplied handler matches any of the configured { @ linkplain # set mapped handlers handlers } or { @ linkplain # set mapped handler classes handler classes } ) , and then delegate to the { @ link # do resolve exception } template method

public model and view resolve exception ( http servlet request request , http servlet response response , @ nullable object handler , exception ex ) { if ( should apply to ( request , handler ) ) { prepare response ( ex , response ) ; model and view result = do resolve exception ( request , response , handler , ex ) ; if ( result ! = null ) { / / print debug message when warn logger is not enabled if ( logger is debug enabled ( ) & & ( this warn logger = = null | | ! this warn logger is warn enabled ( ) ) ) { logger debug ( " resolved [ " + ex + " ] " + ( result is empty ( ) ? " " : " to " + result ) ) ; } / / explicitly configured warn logger in log exception method log exception ( ex , request ) ; } return result ; } else { return null ; } }


allow access to the rpc server for testing

server get rpc server ( ) { return server ; }


find the fields constant that matches name , or null if its not found

public static fields find by name ( string name ) { return by name get ( name ) ; }


called when data is written to the audio processor

void handle buffer ( byte buffer buffer ) ;


public void extinguish ( ) { logger info ( " > > > { } shutting down " , name ) ; try { if ( server ! = null ) { server stop ( ) ; } } catch ( exception e ) { logger error ( " stop failed " , e ) ; system exit ( 100 ) ; / / nosonar } logger info ( " done " ) ; }


iterates over all the mappings in the state the iterator cannot remove elements

public iterator < map entry < k , v > > iterator ( ) { return collections unmodifiable set ( state entry set ( ) ) iterator ( ) ; }


gets the register spec to use to hold the object to synchronize on , for a synchronized method

private register spec get synch reg ( ) { / * * we use the register that is just past the deepest possible * stack element , with a minimum of v 1 since v 0 is what ' s * always used to hold the caught exception when unwinding we * don ' t need to do anything else special at this level , since * later passes will merely notice the highest register used * by explicit inspection * / int reg = get normal reg count ( ) ; return register spec make ( ( reg < 1 ) ? 1 : reg , type object ) ; }


get the address that this function would thunk if it is a valid thunk

public static address get thunked addr ( program program , address entry , boolean check for side effects ) { / / general algorithm : / / / / get function , if has no other calls , and no other flow / / if does no other computation than computing the jump ? ? ? / / simple number of instructions ? specialized for a given processor ? / / danger that side - effects are not found / / all other instruction refs are just reads , and have good addresses ? / / all instructions go into the computation of the jump , simplified away ? / / put it in the patterns file ? / / small number of instructions , look at pcode , all loads , arith / / no branching other than final computed jump / / check if the first instruction is an indirect jump listing listing = program get listing ( ) ; instruction instr = listing get instruction at ( entry ) ; if ( instr = = null ) { return null ; } flow type flow type ; / / treat single jump or call - return as thunk address simple flow addr = get simple flow ( instr ) ; if ( simple flow addr ! = null ) { return simple flow addr ; } / / 8 - bit registers are normally flag registers / / for 16 - bit address spaces , the registers may be too small , so don ' t allow / / non - use of an 8 - bit register boolean allow 8bit non use = true ; if ( program get address factory ( ) get default address space ( ) get size ( ) < = 16 ) { allow 8bit non use = false ; } / / only go three instructions deep / / keep a list of outputs and inputs / / if inputs are used , get rid of them / / if only output is the pc , and small registers , assume ok / / any write to memory is bad int num instr = 1 ; hash set < varnode > set at start registers = new hash set < > ( ) ; hash set < varnode > set registers = new hash set < > ( ) ; hash set < varnode > used registers = new hash set < > ( ) ; / / add in the registers that are set at the beginning of the function add set registers ( program , entry , set at start registers ) ; while ( instr ! = null & & num instr + + < = max number of thunking instructions ) { flow type = instr get flow type ( ) ; / / keep track of any read / writes to registers , need to see if there are any side - effects / / check pcode , any writes to memory are bad pcode op [ ] pcode = instr get pcode ( false ) ; for ( pcode op element : pcode ) { pcode op pcode op = element ; / / storing to a location is not allowed for a thunk / / as a side - effect of the thunk if ( pcode op get opcode ( ) = = pcode op store ) { return null ; } / / record any used registers , checking for use of an unexpected unset register if ( check for side effects & & ! add register usage ( program , set at start registers , set registers , used registers , pcode op , allow 8bit non use ) ) { return null ; } } / / any instruction with a delay slot is actually a branching instruction / / only do this for instructions that aren ' t delay slot instructions if ( instr is fallthrough ( ) & & instr get delay slot depth ( ) = = 0 ) { address fall addr = instr get fall through ( ) ; instr = listing get instruction at ( fall addr ) ; continue ; } / / keep going if flow target is right below , allow only a simple branch if ( is local branch ( listing , instr , flow type ) ) { continue ; } / / reached a flow , end of the line , gotta see what we have return get flowing addr from final state ( program , instr , flow type , check for side effects , set registers , used registers ) ; } return null ; }


setter factory method containing required values all optional arguments can be set via the chained methods

public static setter with collapser key ( hystrix collapser key collapser key ) { return new setter ( collapser key ) ; }


public boolean get prefix boolean ( ) { return prefix boolean ; }


{ @ link span # timestamp ( ) } = = 0 is likely to be a mistake , and coerces to null it is not helpful to index rows who have no timestamp

@ test public void doesnt index spans missing timestamp ( test info test info ) throws exception { string test suffix = test suffix ( test info ) ; accept ( span builder ( test suffix ) timestamp ( 0l ) duration ( 0l ) build ( ) ) ; assert that ( row count for trace by service span ( storage ) ) is zero ( ) ; }


creates list of users with given input array

void create users with array input ( list < user > body ) ;


public long get pending deletion replicated blocks ( ) { return invalidate blocks get blocks ( ) ; }


returns a string indicating whether the given flag is enabled or disabled

private string disabled ( boolean flag ) { return flag ? " " : " ( disabled ) " ; }


returns the sum of this double value and the given specific double value

public double value add ( specific double value other ) { return add ( ( double value ) other ) ; }


returns pet inventories by status returns a map of status codes to quantities

map < string , integer > get inventory ( ) ;


resets the channel mapping after calling this method , call { @ link # configure ( audio format ) } to start using the new channel map

public void set channel map ( @ nullable int [ ] output channels ) { pending output channels = output channels ; }


public builder set groups ( group config groups ) { this groups = groups ; return this ; }


gets the declared inputs to the specified component

public map < global stream id , grouping > get sources ( string component id ) { return get component common ( component id ) get inputs ( ) ; }


determines whether two { @ code rule class name predicate } s should be considered incompatible as rule class predicate and rule class warning predicate specifically , if both list sets of explicit rule class names to permit , those two sets must be disjoint , so the restriction only applies when both predicates have been created by { @ link # only }

boolean considered overlapping ( rule class name predicate that ) { return this overlappable ! = null & & that overlappable ! = null & & ! collections disjoint ( this overlappable , that overlappable ) ; }


test inline additional properties ( asynchronously )

public okhttp 3 call test inline additional properties async ( map < string , string > param , final api callback < void > callback ) throws api exception { okhttp 3 call local var call = test inline additional properties validate before call ( param , callback ) ; local var api client execute async ( local var call , callback ) ; return local var call ; }


postmultiplies this matrix by a translation matrix

public affine 2 translate ( vector 2 trn ) { return translate ( trn x , trn y ) ; }


enter a parse tree produced by the { @ code cast } labeled alternative in { @ link sql base parser # primary expression }

void enter cast ( sql base parser cast context ctx ) ;


public static void remove ( long flow id ) { now calls map remove ( flow id ) ; }


creates a writer that writes to the given stream

bulk writer < t > create ( f s data output stream out ) throws i o exception ;


convert an item ' s ( parent , child ) key to a string value for logging there is no validation of the item

static string primary key to string ( primary key item ) { collection < key attribute > c = item get components ( ) ; string parent = " " ; string child = " " ; for ( key attribute attr : c ) { switch ( attr get name ( ) ) { case parent : parent = attr get value ( ) to string ( ) ; break ; case child : child = attr get value ( ) to string ( ) ; break ; default : } } return " s 3a : / / " + parent + " / " + child ; }


return a single bean of the given type or subtypes , not looking in ancestor factories useful convenience method when we expect a single bean and don ' t care about the bean name does consider objects created by factory beans , which means that factory beans will get initialized if the object created by the factory bean doesn ' t match , the raw factory bean itself will be matched against the type this version of { @ code bean of type } automatically includes prototypes and factory beans

public static < t > t bean of type ( listable bean factory lbf , class < t > type ) throws beans exception { assert not null ( lbf , " listable bean factory must not be null " ) ; map < string , t > beans of type = lbf get beans of type ( type ) ; return unique bean ( type , beans of type ) ; }


atomically sets to the given value if this { @ link attribute } ' s value is { @ code null } if it was not possible to set the value as it contains a value it will just return the current value


public void test special model name ( ) { / / todo : test special model name }


returns all registers located at the specified address

public register [ ] get registers ( address addr ) { address space space = addr get address space ( ) ; if ( space is register space ( ) | | space has mapped registers ( ) ) { list < register > list = register address map get ( get global address ( addr ) ) ; if ( list ! = null ) { register [ ] regs = new register [ list size ( ) ] ; list to array ( regs ) ; return regs ; } } return new register [ 0 ] ; }


list the next set of objects retry policy : retry untranslated

completable future < s 3 list result > continue list objects async ( s 3 list request request , s 3 list result prev result , duration tracker factory tracker factory ) throws i o exception ;


public void prefix ns string test ( ) { / / todo : test prefix ns string }


given a hash family , find raw matches in the fid service

private list < hash match > lookup family ( hash family family , task monitor monitor ) throws cancelled exception { array list < hash match > result = new array list < hash match > ( ) ; list < function record > functions by full hash = fid query service find functions by full hash ( family get hash ( ) get full hash ( ) ) ; for ( function record function record : functions by full hash ) { monitor check canceled ( ) ; hash match match = score match ( function record , family , monitor ) ; if ( match ! = null ) { result add ( match ) ; } } collections sort ( result , most significant ) ; return result ; }


allows to override the node client username

protected string node client username ( ) { return security default settings node client username ( ) ; }


public void name integer test ( ) { / / todo : test name integer }


protected string canonical field name ( string field ) { return property accessor utils canonical property name ( field ) ; }


create a new read only representation of headers used by clients

public static read only http 2 headers client headers ( boolean validate headers , ascii string method , ascii string path , ascii string scheme , ascii string authority , ascii string other headers ) { return new read only http 2 headers ( validate headers , new ascii string [ ] { pseudo header name method value ( ) , method , pseudo header name path value ( ) , path , pseudo header name scheme value ( ) , scheme , pseudo header name authority value ( ) , authority } , other headers ) ; }


flush all unmodified projects from memory

protected void dispose unmodified projects ( ) { synchronized ( this ) { for ( long id : projects metadata key set ( ) ) { project metadata metadata = get project metadata ( id ) ; project project = projects get ( id ) ; if ( project ! = null & & ! project get process manager ( ) has pending ( ) & & metadata get modified ( ) at zone ( zone id system default ( ) ) to instant ( ) to epoch milli ( ) < project get last save ( ) at zone ( zone id system default ( ) ) to instant ( ) to epoch milli ( ) ) { projects remove ( id ) dispose ( ) ; } } } }


this test validates the correctness of { @ link r m web service protocol # submit application ( ) } inside router

public void test submit application x m l ( ) throws exception { / / test with a wrong http method client response bad response = perform call ( rm web service path + apps , null , null , null , put ) ; assert equals ( sc internal server error , bad response get status ( ) ) ; / / test with the correct http method application submission context info context = new application submission context info ( ) ; context set application id ( get new application id ( ) get application id ( ) ) ; client response response = perform call ( rm web service path + apps , null , null , context , post ) ; assert equals ( sc accepted , response get status ( ) ) ; string ci = response get entity ( string class ) ; assert not null ( ci ) ; }


set the name of the language meant for evaluating the scripts ( e g " groovy " ) this is effectively an alias for { @ link # set engine name " engine name " } , potentially ( but not yet ) providing common abbreviations for certain languages beyond what the jsr - 223 script engine factory exposes

public void set language ( string language ) { this engine name = language ; }


sets the maximum number of unique values for which permits can be held at once in the to - be - constructed { @ link multiset semaphore }

public builder max num unique values ( int max num unique values ) { preconditions check state ( max num unique values > 0 , " max num unique values must be positive ( was % s ) " , max num unique values ) ; this max num unique values = max num unique values ; return this ; }


test that we can recover properly after a failed build

public void test failure recovery ( ) throws exception { / / [ action ] - > foo artifact foo = create derived artifact ( " foo " ) ; callable < void > make foo = new callable < void > ( ) { @ override public void call ( ) throws i o exception { throw new i o exception ( " building ' foo ' is supposed to fail " ) ; } } ; register action ( new test action ( make foo , empty nested set , immutable set of ( foo ) ) ) ; / / [ action ] - > bar artifact bar = create derived artifact ( " bar " ) ; register action ( new test action ( test action no effect , empty nested set , immutable set of ( bar ) ) ) ; / / don ' t fail fast when we encounter the error reporter remove handler ( fail fast handler ) ; / / test that building ' foo ' fails build failed exception e = assert throws ( build failed exception class , ( ) - > build artifacts ( foo ) ) ; if ( ! e get message ( ) contains ( " building ' foo ' is supposed to fail " ) ) { throw e ; } / / make sure the reporter reported the error message assert contains event ( " building ' foo ' is supposed to fail " ) ; / / test that a subsequent build of ' bar ' succeeds build artifacts ( bar ) ; }


public void test type holder default ( ) { / / todo : test type holder default }


public void trace ( throwable cause , supplier < ? extends char sequence > message supplier ) { if ( this log is trace enabled ( ) ) { this log trace ( log message of ( message supplier ) , cause ) ; } }


return the locale of the rendered template

public locale get locale ( ) { return this locale ; }


test for task inclusionexclusion when additional filter is specified ( like assignee ) , ordered

public void test query by assignee exclude subtasks ordered ( ) throws exception { simple date format sdf = new simple date format ( " dd / mm / yyyy hh : mm : ss sss " ) ; / / gonzo has 2 root tasks and 3 + 2 subtasks assigned / / include subtasks task query query = task service create task query ( ) task assignee ( " gonzo " ) order by task create time ( ) desc ( ) ; assert that ( query count ( ) ) is equal to ( 7 ) ; assert that ( query list ( ) ) has size ( 7 ) ; assert that ( query list ( ) get ( 0 ) get create time ( ) ) is equal to ( sdf parse ( " 02 / 01 / 2009 01 : 01 : 01 000 " ) ) ; / / exclude subtasks query = task service create task query ( ) task assignee ( " gonzo " ) exclude subtasks ( ) order by task create time ( ) asc ( ) ; assert that ( query count ( ) ) is equal to ( 2 ) ; assert that ( query list ( ) ) has size ( 2 ) ; assert that ( query list ( ) get ( 0 ) get create time ( ) ) is equal to ( sdf parse ( " 01 / 02 / 2008 02 : 02 : 02 000 " ) ) ; assert that ( query list ( ) get ( 1 ) get create time ( ) ) is equal to ( sdf parse ( " 05 / 02 / 2008 02 : 02 : 02 000 " ) ) ; / / kermit has no root tasks and no subtasks assigned include subtasks query = task service create task query ( ) task assignee ( kermit ) order by task create time ( ) asc ( ) ; assert that ( query count ( ) ) is equal to ( 0 ) ; assert that ( query list ( ) ) has size ( 0 ) ; assert that ( query single result ( ) ) is null ( ) ; / / exclude subtasks query = task service create task query ( ) task assignee ( kermit ) exclude subtasks ( ) order by task create time ( ) desc ( ) ; assert that ( query count ( ) ) is equal to ( 0 ) ; assert that ( query list ( ) ) has size ( 0 ) ; assert that ( query single result ( ) ) is null ( ) ; }


return a value fetcher for this leaf implementation

default doc value fetcher leaf get leaf value fetcher ( doc value format format ) { sorted binary doc values values = get bytes values ( ) ; return new doc value fetcher leaf ( ) { @ override public boolean advance exact ( int doc id ) throws i o exception { return values advance exact ( doc id ) ; } @ override public int doc value count ( ) throws i o exception { return values doc value count ( ) ; } @ override public object next value ( ) throws i o exception { return format format ( values next value ( ) ) ; } } ; }


waits for a given persistent task to comply with a given predicate , then call back the listener accordingly

public void wait for persistent task condition ( final string task id , final predicate < persistent task < ? > > predicate , final @ nullable time value timeout , final wait for persistent task listener < ? > listener ) { final predicate < cluster state > cluster state predicate = cluster state - > predicate test ( persistent tasks custom metadata get task with id ( cluster state , task id ) ) ; final cluster state observer observer = new cluster state observer ( cluster service , timeout , logger , thread pool get thread context ( ) ) ; final cluster state cluster state = observer set and get observed state ( ) ; if ( cluster state predicate test ( cluster state ) ) { listener on response ( persistent tasks custom metadata get task with id ( cluster state , task id ) ) ; } else { observer wait for next change ( new cluster state observer listener ( ) { @ override public void on new cluster state ( cluster state state ) { listener on response ( persistent tasks custom metadata get task with id ( state , task id ) ) ; } @ override public void on cluster service close ( ) { listener on failure ( new node closed exception ( cluster service local node ( ) ) ) ; } @ override public void on timeout ( time value timeout ) { listener on timeout ( timeout ) ; } } , cluster state predicate ) ; } }


is it just in first memory segment , we use quick way to do something

private static boolean in first segment ( memory segment [ ] segments , int offset , int num bytes ) { return num bytes + offset < = segments [ 0 ] size ( ) ; }


return the end of the range ( inclusive ) given the total length of a representation

public abstract long get range end ( long length ) ;


test sps x attr on directory x attr should be removed from the directory once all the files blocks moved to specific storage

public void test s p sx attr when sps called for dir ( ) throws exception { try { cluster set up ( ) ; path parent = new path ( " / parent " ) ; / / create parent dir fs mkdirs ( parent ) ; / / create 10 child files for ( int i = 0 ; i < 5 ; i + + ) { d f s test util create file ( fs , new path ( parent , " f " + i ) , 1024 , ( short ) 3 , 0 ) ; } / / set storage policy for parent directory fs set storage policy ( parent , " cold " ) ; / / stop one dn so we can check the sps x attr for directory data node properties stop data node = cluster stop data node ( 0 ) ; fs satisfy storage policy ( parent ) ; / / check x attr for parent directory f s namesystem namesystem = cluster get namesystem ( ) ; i node inode = namesystem get f s directory ( ) get i node ( " / parent " ) ; x attr feature f = inode get x attr feature ( ) ; assert true ( " sps x attr should be exist " , f get x attr ( xattr satisfy storage policy ) ! = null ) ; / / check for the child , sps x attr should not be there for ( int i = 0 ; i < 5 ; i + + ) { inode = namesystem get f s directory ( ) get i node ( " / parent / f " + i ) ; f = inode get x attr feature ( ) ; assert true ( f = = null ) ; } cluster restart data node ( stop data node , false ) ; / / wait and check all the file block moved in archive for ( int i = 0 ; i < 5 ; i + + ) { d f s test util wait expected storage type ( " / parent / f " + i , storage type archive , 3 , 30000 , cluster get file system ( ) ) ; } d f s test util wait for xattr removed ( " / parent " , xattr satisfy storage policy , namesystem , 10000 ) ; } finally { cluster shutdown ( ) ; } }


return the originating bean definition , or { @ code null } if none allows for retrieving the decorated bean definition , if any note that this method returns the immediate originator iterate through the originator chain to find the original bean definition as defined by the user

public bean definition get originating bean definition ( ) { return ( this resource instanceof bean definition resource ? ( ( bean definition resource ) this resource ) get bean definition ( ) : null ) ; }


returns the { @ link aspect definition builder } this object wraps call this when done with config - specific building to re - expose the builder methods in { @ link aspect definition builder }

public aspect definition builder original builder ( ) { return aspect builder ; }


return the sessions for the user the returned set is a copy and will never be modified


upgrade old stack and register variable symbol address to variable addresses also force associated references to be updated to new variable addresses

private void process old variable addresses ( task monitor monitor ) throws i o exception , cancelled exception { monitor set message ( " upgrading variable symbols " ) ; monitor initialize ( adapter get symbol count ( ) ) ; int cnt = 0 ; table table = adapter get table ( ) ; record iterator symbol record iterator = adapter get symbols ( ) ; while ( symbol record iterator has next ( ) ) { monitor check canceled ( ) ; monitor set progress ( + + cnt ) ; d b record rec = symbol record iterator next ( ) ; long addr = rec get long value ( symbol database adapter symbol addr col ) ; address old address = addr map decode address ( addr ) ; if ( ! ( old address instanceof old generic namespace address ) ) { continue ; / / added by function manager upgrade } byte type i d = rec get byte value ( symbol database adapter symbol type col ) ; symbol type type = symbol type get symbol type ( type i d ) ; if ( type ! = symbol type local var & & type ! = symbol type parameter & & type ! = symbol type global var ) { continue ; } address storage addr = old address get new address ( old address get offset ( ) ) ; / / move variable references - eliminate variable symbol bindings which are no longer supported ref manager move references to ( old address , storage addr , monitor ) ; try { address variable addr = get upgraded variable address ( storage addr , rec get long value ( symbol database adapter symbol data1 col ) ) ; / / fix symbol address rec set long value ( symbol database adapter symbol addr col , addr map get key ( variable addr , true ) ) ; table put record ( rec ) ; / / symbol key is preserved } catch ( invalid input exception e ) { symbol parent = get symbol ( rec get long value ( symbol database adapter symbol parent col ) ) ; msg warn ( this , " variable symbol upgrade problem : " + parent get name ( ) + " : " + rec get string ( symbol database adapter symbol name col ) ) ; } } }


private void verify open files ( map < path , f s data output stream > open files ) throws i o exception { verify open files ( open files , open files iterator filter path default ) ; }


updates the digest with the supplied map

public fingerprint add string map ( map < string , string > inputs ) { add int ( inputs size ( ) ) ; for ( map entry < string , string > entry : inputs entry set ( ) ) { add string ( entry get key ( ) ) ; add string ( entry get value ( ) ) ; } return this ; }


the core constraint semantics check that if rule a depends on rule b , b must support all of a ' s environments to model this in the tests below , we construct two rules : a " depending " rule ( i e a ) that depends on a " dependency " rule ( i e b ) each test can construct its own instance of these rules with its own environments specifications by calling this method and { @ link # get dependency rule } with appropriate environment settings passed in as custom attributes this method constructs and returns the depending rule ( i e a )

protected static string get depending rule ( string custom attributes ) { list < string > attrs as list = lists new array list ( custom attributes ) ; attrs as list add ( get attr def ( " deps " , " dep " ) ) ; return get rule def ( " sh library " , " main " , attrs as list to array ( new string [ 0 ] ) ) ; }


process the web request and ( optionally ) delegate to the next { @ code web filter } through the given { @ link web filter chain }

mono < void > filter ( server web exchange exchange , web filter chain chain ) ;


returns a client to communicate with the embedded node


determine the shards with a specific state

public list < shard routing > shards with state ( shard routing state states ) { if ( states length = = 1 ) { if ( states [ 0 ] = = shard routing state initializing ) { return new array list < > ( initializing shards ) ; } else if ( states [ 0 ] = = shard routing state relocating ) { return new array list < > ( relocating shards ) ; } } list < shard routing > shards = new array list < > ( ) ; for ( shard routing shard entry : this ) { for ( shard routing state state : states ) { if ( shard entry state ( ) = = state ) { shards add ( shard entry ) ; } } } return shards ; }


copies an iterable ' s elements into an array

static object [ ] to array ( iterable < ? > iterable ) { return cast or copy to collection ( iterable ) to array ( ) ; }


public void class name test ( ) { / / todo : test class name }


a convenience method that will take a given sort state and remove from it any columns that cannot be sorted this is useful if the client is restoring a sort state that contains columns that have been removed or are no longer sortable ( such as during major table model rewrites )

protected table sort state cleanup table sort state ( table sort state state ) { int column count = get column count ( ) ; table sort state editor editor = new table sort state editor ( state ) ; int n = editor get sorted column count ( ) ; for ( int i = 0 ; i < n ; i + + ) { column sort state ss = editor get column sort state ( i ) ; int column index = ss get column model index ( ) ; if ( column index > = column count ) { editor remove sorted column ( column index ) ; } if ( ! is sortable ( column index ) ) { editor remove sorted column ( column index ) ; } } return editor create table sort state ( ) ; }


method to allow setting preallocate size of log file to pad the file

public static void set prealloc size ( long size ) { pre alloc size = size ; }


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 " ) ; }


exception to be thrown when a feature action requires a valid license , but license has expired < code > feature < code > accessible through { @ link # expired feature metadata } in the exception ' s rest header

public static elasticsearch security exception new compliance exception ( string feature ) { elasticsearch security exception e = new elasticsearch security exception ( " current license is non - compliant for [ { } ] " , rest status forbidden , feature ) ; e add metadata ( expired feature metadata , feature ) ; return e ; }


this fans out into a number of requests corresponding to query input in simplest case , there is less than a day of data queried , and only one expression this implies one call to fetch trace i ds and another to retrieve the span details the amount of backend calls increase in dimensions of query complexity , days of data , and limit of traces requested for example , a query like " http path = foo and error " will be two select statements for the expression , possibly follow - up calls for pagination ( when over 5k rows match ) once i ds are parsed , there ' s one call for each 5k rows of span data this means " http path = foo and error " is minimally 3 network calls , the first two in parallel

@ override public call < list < list < span > > > get traces ( query request request ) { if ( ! search enabled ) return call empty list ( ) ; timestamp range timestamp range = timestamp range ( request ) ; / / if we have to make multiple queries , over fetch on indexes as they don ' t return distinct / / ( trace id , timestamp ) rows this mitigates intersection resulting in < limit traces final int trace index fetch size = request limit ( ) * index fetch multiplier ; list < call < map < string , long > > > calls to intersect = new array list < > ( ) ; list < string > annotation keys = cassandra util annotation keys ( request ) ; for ( string annotation key : annotation keys ) { if ( span table = = null ) { throw new illegal argument exception ( request annotation query string ( ) + " query unsupported due to missing annotation query index " ) ; } calls to intersect add ( span table new call ( request service name ( ) , annotation key , timestamp range , trace index fetch size ) ) ; } / / bucketed calls can be expensive when service name isn ' t specified this guards against abuse if ( request remote service name ( ) ! = null | | request span name ( ) ! = null | | request min duration ( ) ! = null | | calls to intersect is empty ( ) ) { calls to intersect add ( new bucketed trace id call ( request , timestamp range , trace index fetch size ) ) ; } if ( calls to intersect size ( ) = = 1 ) { return calls to intersect get ( 0 ) map ( trace ids sorted by desc timestamp ( ) ) flat map ( spans new flat mapper ( request ) ) ; } / / we achieve the and goal , by intersecting each of the key sets intersect key sets intersected trace ids = new intersect key sets ( calls to intersect ) ; / / @ xxx the sorting by timestamp desc is broken here ^ return intersected trace ids flat map ( spans new flat mapper ( request ) ) ; }


update the current master key for generating delegation tokens it should be called only by token remover thread

void roll master key ( ) throws i o exception { synchronized ( this ) { remove expired keys ( ) ; / * set final expiry date for retiring current key * / current key set expiry date ( time now ( ) + token max lifetime ) ; / * * current key might have been removed by remove expired keys ( ) , if * update master key ( ) isn ' t called at expected interval add it back to * all keys just in case * / update delegation key ( current key ) ; } update current key ( ) ; }


sets the maximum number of suggested term to be retrieved from each individual shard during the reduce phase the only the top n suggestions are returned based on the < code > size < code > option defaults to the < code > size < code > option setting this to a value higher than the ` size ` can be useful in order to get a more accurate document frequency for suggested terms due to the fact that terms are partitioned amongst shards , the shard level document frequencies of suggestions may not be precise increasing this will make these document frequencies more precise

public t shard size ( integer shard size ) { this shard size = shard size ; return ( t ) this ; }


called every time an item has been parsedresolved

void on item completed ( string item name ) ;


compare the content of a file created from file system and path with the specified byte [ ] buffer ' s content

public static void check full file ( file system fs , path name , int len , final byte [ ] compare content , string message ) throws i o exception { check full file ( fs , name , len , compare content , message , true ) ; }


returns a string representing current build time

private string get build time ( ) { date format date format = new simple date format ( " yyyy - mm - dd ' t ' hh : mm ' z ' " ) ; date format set time zone ( time zone get time zone ( " utc " ) ) ; return date format format ( new date ( ) ) ; }


returns whether this version is considered stable

public boolean is stable version ( ) { return is stable ; }


public string get failure ( ) { return failure ; }


returns all nodes in this graph adjacent to { @ code node } which can be reached by traversing { @ code node } ' s incoming edges against the direction ( if any ) of the edge in an undirected graph , this is equivalent to { @ link # adjacent nodes ( object ) }


calculate md5 hex string with encode charset

public static string md 5 hex ( string value , string encode ) { try { return md 5 hex ( value get bytes ( encode ) ) ; } catch ( exception e ) { throw new runtime exception ( e ) ; } }


return the http method of the request ( usually get or post )

public string get method ( ) { return this method ; }


public < t > f with operator ( string uid , bootstrap transformation < t > transformation ) { metadata add operator ( uid , transformation ) ; return ( f ) this ; }


invalidate all managed texture arrays this is an internal method do not use it !

public static void invalidate all texture arrays ( application app ) { array < texture array > managed texture array = managed texture arrays get ( app ) ; if ( managed texture array = = null ) return ; for ( int i = 0 ; i < managed texture array size ; i + + ) { texture array texture array = managed texture array get ( i ) ; texture array reload ( ) ; } }


specify which properties must be present , to be verified by { @ link # validate required properties ( ) }

void set required properties ( string required properties ) ;


public static < t > http response < t > http request ( logger logger , string url , string method , object request body data , type reference < t > response format ) throws i o exception { http u r l connection connection = null ; try { string serialized body = request body data = = null ? null : json util json serde write value as string ( request body data ) ; logger debug ( " sending { } with input { } to { } " , method , serialized body , url ) ; connection = ( http u r l connection ) new url ( url ) open connection ( ) ; connection set request method ( method ) ; connection set request property ( " user - agent " , " kafka " ) ; connection set request property ( " accept " , " application / json " ) ; / / connection get response code ( ) implicitly calls get input stream , so always set / / this to true connection set do input ( true ) ; connection set use caches ( false ) ; if ( request body data ! = null ) { connection set request property ( " content - type " , " application / json " ) ; connection set do output ( true ) ; output stream os = connection get output stream ( ) ; os write ( serialized body get bytes ( standard charsets utf 8 ) ) ; os flush ( ) ; os close ( ) ; } int response code = connection get response code ( ) ; if ( response code = = http u r l connection http no content ) { return new http response < > ( null , new error response ( response code , connection get response message ( ) ) ) ; } else if ( ( response code > = 200 ) & & ( response code < 300 ) ) { input stream is = connection get input stream ( ) ; t result = json util json serde read value ( is , response format ) ; is close ( ) ; return new http response < > ( result , null ) ; } else { / / if the resposne code was not in the 2 0 0s , we assume that this is an error / / response input stream es = connection get error stream ( ) ; if ( es = = null ) { / / handle the case where http u r l connection # get error stream returns null return new http response < > ( null , new error response ( response code , " " ) ) ; } / / try to read the error response json error response error = json util json serde read value ( es , error response class ) ; es close ( ) ; return new http response < > ( null , error ) ; } } finally { if ( connection ! = null ) { connection disconnect ( ) ; } } }


< code > optional string value = 1 ; < code >

public java lang string get value ( ) { return value ; }


public static string get size ( final file file ) { if ( file = = null ) return " " ; if ( file is directory ( ) ) { return get dir size ( file ) ; } return get file size ( file ) ; }


the number of permutations with repeated elements is calculated as follows : for an empty list , it is 1 ( base case ) when r numbers are added to a list of n - r elements , the number of permutations is increased by a factor of ( n choose r )

private static < e > int calculate size ( list < e > sorted input list , comparator < ? super e > comparator ) { int permutations = 1 ; int n = 1 ; int r = 1 ; while ( n < sorted input list size ( ) ) { int comparison = comparator compare ( sorted input list get ( n - 1 ) , sorted input list get ( n ) ) ; if ( comparison < 0 ) { / / we move to the next non - repeated element permutations = int math saturated multiply ( permutations , int math binomial ( n , r ) ) ; r = 0 ; if ( permutations = = integer max value ) { return integer max value ; } } n + + ; r + + ; } return int math saturated multiply ( permutations , int math binomial ( n , r ) ) ; }


create a new instance of a class with a defined factory

public static writable new instance ( class < ? extends writable > c ) { return new instance ( c , null ) ; }


convenience method for setting the value to an int value ;

public void set value ( int new value ) { set value ( big integer value of ( new value ) ) ; }


returns the first sample index of this chunk in the specified sample queue in the output must not be used if { @ link # should splice in } is true

public int get first sample index ( int sample queue index ) { assertions check state ( ! should splice in ) ; if ( sample queue index > = sample queue first sample indices size ( ) ) { / / the sample queue was created by this chunk or a later chunk return 0 ; } return sample queue first sample indices get ( sample queue index ) ; }


set the owner for this entity ( default = null )

public builder owner ( string owner ) { this owner = owner ; return this ; }


public static staggered grid recycler configuration create with recycler binder configuration ( int num spans , recycler binder configuration recycler binder configuration ) { return new staggered grid recycler configuration ( num spans , staggered grid layout manager vertical , false , staggered grid layout manager gap handling none , recycler binder configuration , builder staggered grid layout info factory ) ; }


temporary files they get moved to the finalized block directory when the block is finalized

file create tmp file ( string bpid , block b ) throws i o exception { check reference ( ) ; reserve space for replica ( b get num bytes ( ) ) ; try { return get block pool slice ( bpid ) create tmp file ( b ) ; } catch ( i o exception exception ) { release reserved space ( b get num bytes ( ) ) ; throw exception ; } }


parses the provided { @ link string } into a { @ link package specification } the { @ link string } must have one of the following forms : the full name of a single package , without repository qualification , prefixed with " " ( e g " foobar " ) this results in a { @ link package specification } that contains exactly the named package the full name of a single package , without repository qualification , prefixed with " " , and suffixed with " " ( e g " foobar " ) this results in a { @ link package specification } that contains all transitive subpackages of that package , inclusive exactly " " this results in a { @ link package specification } that contains all packages if and only if the { @ link string } is one of the first two forms , the returned { @ link package specification } is specific to the provided { @ link repository name } note that it is not possible to construct a repository - specific { @ link package specification } for all transitive subpackages of the root package ( i e a repository - specific " " ) throws { @ link invalid package specification exception } if the { @ link string } cannot be parsed

public static package specification from string ( repository name repository name , string spec ) throws invalid package specification exception { string result = spec ; boolean negative = false ; if ( result starts with ( negative prefix ) ) { negative = true ; result = result substring ( negative prefix length ( ) ) ; } package specification package specification = from string positive ( repository name , result ) ; return negative ? new negative package specification ( package specification ) : package specification ; }


adds a namevalue pair to the formatted output in { @ code name = value } format

public to string helper add ( string name , char value ) { return add holder ( name , string value of ( value ) ) ; }


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 " ) ; }


removes the current key from < b > all < b > known states in the state backend

public void remove ( ) { if ( current key = = null ) { return ; } for ( state descriptor < ? , ? > descriptor : descriptors ) { try { state state = backend get partitioned state ( void namespace instance , void namespace serializer instance , descriptor ) ; state clear ( ) ; } catch ( exception e ) { throw new runtime exception ( " failed to drop partitioned state from state backend " , e ) ; } } }


check whether current service belongs endpoint catalog

public static boolean in endpoint catalog ( int scope id ) { return endpoint catalog contains key ( scope id ) ; }


determine if the address for this model is within a loaded and initialized block in the program

public final boolean is loaded and initialized address ( ) { return is loaded and initialized ; }


set the ( new ) value of the { @ code if - unmodified - since } header the date should be specified as the number of milliseconds since january 1 , 1970 gmt

public void set if unmodified since ( long if unmodified since ) { set date ( if unmodified since , if unmodified since ) ; }


checks that the edits file has all op codes

private boolean has all op codes ( string in filename ) throws i o exception { string out filename = in filename + " stats " ; file output stream fout = new file output stream ( out filename ) ; statistics edits visitor visitor = new statistics edits visitor ( fout ) ; offline edits viewer oev = new offline edits viewer ( ) ; if ( oev go ( in filename , out filename , " stats " , new flags ( ) , visitor ) ! = 0 ) return false ; log info ( " statistics for " + in filename + " \ n " + visitor get statistics string ( ) ) ; boolean has all op codes = true ; for ( f s edit log op codes op code : f s edit log op codes values ( ) ) { / / don ' t need to test obsolete op codes if ( skipped ops contains ( op code ) ) continue ; long count = visitor get statistics ( ) get ( op code ) ; if ( ( count = = null ) | | ( count = = 0 ) ) { has all op codes = false ; log info ( " opcode " + op code + " not tested in " + in filename ) ; } } return has all op codes ; }


create a new { @ code k stream } that consists all records of this stream which do not satisfy the given predicate all records that do satisfy the predicate are dropped this is a stateless record - by - record operation

k stream < k , v > filter not ( final predicate < ? super k , ? super v > predicate ) ;


public t from file ( file json file ) throws i o exception , json parse exception , json mapping exception { file absolute file = json file get absolute file ( ) ; try { return mapper read value ( absolute file , class type ) ; } catch ( i o exception e ) { log error ( " exception while parsing json file { } " , absolute file , e ) ; throw e ; } }


instrument a { @ litho handler } or returns the same given { @ litho handler } if the { @ litho handler } given as input is null , the return value will be null too

litho handler instrument litho handler ( litho handler litho handler ) ;


get action cache if present or reload it from the on - disk cache

private action cache get action cache ( ) throws abrupt exit exception { try { return env get persistent action cache ( ) ; } catch ( i o exception e ) { / / todo ( bazel - team ) : ( 2010 ) ideally we should just remove all cache data and reinitialize / / caches logging util log to remote ( level warning , " failed to initialize action cache : " + e get message ( ) , e ) ; string message = string format ( " couldn ' t create action cache : % s if error persists , use ' bazel clean ' " , e get message ( ) ) ; throw new abrupt exit exception ( detailed exit code of ( failure detail new builder ( ) set message ( message ) set action cache ( failure details action cache new builder ( ) set code ( failure details action cache code initialization failure ) ) build ( ) ) , e ) ; } }


this method is called when a server channel signals it is ready to accept a connection all of the accept logic should occur in this call

protected void accept channel ( server channel context context ) throws i o exception { context accept channels ( selector supplier ) ; }


generate the hash smash for a superior full hashinferior id

public static long generate inferior full hash smash ( function record superior function , function record inferior function ) { long hash value = inferior function get key ( ) * f n v 1a 6 4 message digest fnv 64 prime ; / / improve bit diversity on key return hash value ^ superior function get full hash ( ) ; }


invalidates the cached values of any values in error transiently if a future call to { @ link memoizing evaluator # evaluate } requests a value that transitively depends on any value that was in an error state ( or is one of these ) , they will be re - computed

default void invalidate transient errors ( ) { / / all transient error values have a dependency on the single global error transience value , / / so we only have to invalidate that one value to catch everything invalidate ( immutable list of ( error transience value key ) ) ; }


public dns name resolver builder resolve cache ( dns cache resolve cache ) { this resolve cache = resolve cache ; return this ; }


the name of the action must be unique across actions

public string name ( ) { return this name ; }


calculate the number of levels needed for a specific precision quad tree cells will not exceed the specified size ( diagonal ) of the precision

public static int quad tree levels for precision ( string distance ) { return quad tree levels for precision ( distance unit meters parse ( distance , distance unit default ) ) ; }


public int get port ( ) { return this port ; }


enables stubbing methods use it when you want the mock to return particular value when particular method is called simply put : " < b > when < b > the x method is called < b > then < b > return y " examples : < pre class = " code " > < code class = " java " > < b > when < b > ( mock some method ( ) ) < b > then return < b > ( 10 ) ; you can use flexible argument matchers , e g : when ( mock some method ( < b > any string ( ) < b > ) ) then return ( 10 ) ; setting exception to be thrown : when ( mock some method ( " some arg " ) ) then throw ( new runtime exception ( ) ) ; you can set different behavior for consecutive method calls last stubbing ( e g : then return ( " foo " ) ) determines the behavior of further consecutive calls when ( mock some method ( " some arg " ) ) then throw ( new runtime exception ( ) ) then return ( " foo " ) ; alternative , shorter version for consecutive stubbing : when ( mock some method ( " some arg " ) ) then return ( " one " , " two " ) ; is the same as : when ( mock some method ( " some arg " ) ) then return ( " one " ) then return ( " two " ) ; shorter version for consecutive method calls throwing exceptions : when ( mock some method ( " some arg " ) ) then throw ( new runtime exception ( ) , new null pointer exception ( ) ; < code > for stubbing void methods with throwables see : { @ link mockito # do throw ( throwable ) } stubbing can be overridden : for example common stubbing can go to fixture setup but the test methods can override it please note that overridding stubbing is a potential code smell that points out too much stubbing once stubbed , the method will always return stubbed value regardless of how many times it is called last stubbing is more important - when you stubbed the same method with the same arguments many times although it is possible to verify a stubbed invocation , usually < b > it ' s just redundant < b > let ' s say you ' ve stubbed < code > foo bar ( ) < code > if your code cares what < code > foo bar ( ) < code > returns then something else breaks ( often before even < code > verify ( ) < code > gets executed ) if your code doesn ' t care what < code > get ( 0 ) < code > returns then it should not be stubbed see examples in javadoc for { @ link mockito } class

public static < t > ongoing stubbing < t > when ( t method call ) { return mockito core when ( method call ) ; }


returns true if at least one of the provided domain files is hijacked

public boolean is enabled for context ( domain file context context ) { list < domain file > domain files = context get selected files ( ) ; for ( domain file domain file : domain files ) { if ( domain file is hijacked ( ) ) { return true ; / / at least one hijacked file selected } } return false ; }


fast method of finding the next power of 2 greater than or equal to the supplied value if the value is { @ code < = 0 } then 1 will be returned this method is not suitable for { @ link integer # min value } or numbers greater than 2 ^ 30

public static int find next positive power of two ( final int value ) { assert value > integer min value & & value < 0x 4 0 0 0 0 0 0 0 ; return 1 < < ( 32 - integer number of leading zeros ( value - 1 ) ) ; }


returns the string literal representing { @ code value } , including wrapping double quotes

string builder result = new string builder ( value length ( ) + 2 ) ; result append ( ' " ' ) ; for ( int i = 0 ; i < value length ( ) ; i + + ) { char c = value char at ( i ) ; / / trivial case : single quote must not be escaped if ( c = = ' \ ' ' ) { result append ( " ' " ) ; continue ; } / / trivial case : double quotes must be escaped if ( c = = ' \ " ' ) { result append ( " \ \ \ " " ) ; continue ; } / / default case : just let character literal do its work result append ( character literal without single quotes ( c ) ) ; / / need to append indent after linefeed ? if ( c = = ' \ n ' & & i + 1 < value length ( ) ) { result append ( " \ " \ n " ) append ( indent ) append ( indent ) append ( " + \ " " ) ; } }


returns the given unknown integer value , shifted right by this integer value

public integer value shift right of ( unknown integer value other ) { return shift right of ( ( integer value ) other ) ; }


adds several symlinks neither keys nor values may be null

public builder add symlinks ( map < path fragment , artifact > symlinks ) { for ( map entry < path fragment , artifact > symlink : symlinks entry set ( ) ) { symlinks builder add ( new symlink entry ( symlink get key ( ) , symlink get value ( ) ) ) ; } return this ; }


private int find key ( int key ) { int hashcode = ( key & 0x 7fffffff ) % capacity ; int p = indexer first ( hashcode ) ; while ( p ! = - 1 ) { if ( keys [ p ] = = key ) { return p ; } p = indexer next ( p ) ; } return - 1 ; }


return the { @ link socket address } to which is bound local or { @ code null } if none


build a string that consists of the names of the classesinterfaces in the given collection basically like { @ code abstract collection to string ( ) } , but stripping the " class " " interface " prefix before every class name

public static string class names to string ( @ nullable collection < class < ? > > classes ) { if ( collection utils is empty ( classes ) ) { return " [ ] " ; } string joiner string joiner = new string joiner ( " , " , " [ " , " ] " ) ; for ( class < ? > clazz : classes ) { string joiner add ( clazz get name ( ) ) ; } return string joiner to string ( ) ; }


public client config get default client config ( ) { client config client config = new client config ( ) ; client config register ( multi part feature class ) ; client config register ( json ) ; client config register ( jackson feature class ) ; client config property ( http url connector provider set method workaround , true ) ; / / turn off compliance validation to be able to send payloads with delete calls client config property ( client properties suppress http compliance validation , true ) ; if ( debugging ) { client config register ( new logging feature ( java util logging logger get logger ( logging feature default logger name ) , java util logging level info , logging feature verbosity payload any , 1024 * 50 / * log payloads up to 50k * / ) ) ; client config property ( logging feature logging feature verbosity , logging feature verbosity payload any ) ; / / set logger to all java util logging logger get logger ( logging feature default logger name ) set level ( java util logging level all ) ; } else { / / suppress warnings for payloads with delete calls : java util logging logger get logger ( " org glassfish jersey client " ) set level ( java util logging level severe ) ; } return client config ; }


public boolean add child ( i node node , final boolean set mod time , final int latest snapshot id ) { final int low = search children ( node get local name bytes ( ) ) ; if ( low > = 0 ) { return false ; } if ( is in latest snapshot ( latest snapshot id ) ) { / / create snapshot feature if necessary directory with snapshot feature sf = this get directory with snapshot feature ( ) ; if ( sf = = null ) { sf = this add snapshot feature ( null ) ; } return sf add child ( this , node , set mod time , latest snapshot id ) ; } add child ( node , low ) ; if ( set mod time ) { / / update modification time of the parent directory update modification time ( node get modification time ( ) , latest snapshot id ) ; } return true ; }


override this to perform actions after the call to { @ code actual on subscribe ( this ) } happened

protected void after downstream ( ) { / / default no - op }


defines and displays a component for resolving merge conflicts

void set merge component ( j component component , string component i d ) { provider set merge component ( component , component i d ) ; }


returns { @ code true } if and only if the io thread will perform the requested write operation immediately any write requests made when this method returns { @ code false } are queued until the io thread is ready to process the queued write requests


checks if this retention leases collection would supersede a retention leases collection with the specified primary term and version a retention leases collection supersedes another retention leases collection if its primary term is higher , or if for equal primary terms its version is higher

boolean supersedes ( final long primary term , final long version ) { return this primary term > primary term | | this primary term = = primary term & & this version > version ; }


to test the collection format in query parameters

public void test query parameter collection format test ( ) { list < string > pipe = null ; list < string > ioutil = null ; list < string > http = null ; list < string > url = null ; list < string > context = null ; / / api test query parameter collection format ( pipe , ioutil , http , url , context ) ; / / todo : test validations }


the response resources wrapped in the common mcp resource message these are typed resources that match the type url in the request resources message when ` incremental ` is true , this contains an array of resources to addupdate for the specified collection this modifies the existing collection at the sink when ` incremental ` is false , this contains the full set of resources for the specified collection this replaces any previously delivered resources < code > repeated istio mcp v 1alpha 1 resource resources = 3 ; < code >

public builder set resources ( int index , com alibaba nacos istio model mcp resource value ) { if ( resources builder = = null ) { if ( value = = null ) { throw new null pointer exception ( ) ; } ensure resources is mutable ( ) ; resources set ( index , value ) ; on changed ( ) ; } else { resources builder set message ( index , value ) ; } return this ; }


public sqlxml create s q l x m l ( ) throws s q l exception { return null ; }


returns whether this path is an ancestor of another path a path is considered an ancestor of itself

public boolean starts with ( path other ) { if ( file system ! = other file system ) { return false ; } return starts with ( other path , other drive str length ) ; }


returns a required broadcast shuffle type

public static required shuffle broadcast ( ) { return new required shuffle ( shuffle type broadcast ) ; }


creates a synthetic binding to { @ code provider < t > } , i e a binding to the provider from { @ code binding < t > }

private < t > binding impl < provider < t > > create provider binding ( key < provider < t > > key , errors errors ) throws errors exception { type provider type = key get type literal ( ) get type ( ) ; / / if the provider has no type parameter ( raw provider ) if ( ! ( provider type instanceof parameterized type ) ) { throw errors cannot inject raw provider ( ) to exception ( ) ; } type entry type = ( ( parameterized type ) provider type ) get actual type arguments ( ) [ 0 ] ; @ suppress warnings ( " unchecked " ) / / safe because t came from key < provider < t > > key < t > provided key = ( key < t > ) key of type ( entry type ) ; binding impl < t > delegate = get binding or throw ( provided key , errors ) ; return new provider binding impl < > ( this , key , delegate ) ; }


order by the last update time of the models ( needs to be followed by { @ link # asc ( ) } or { @ link # desc ( ) } )

model query order by last update time ( ) ;


returns an immutable map of the extension names and their values

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


public long get end pointer ( ) { return end pointer ; }


gets the status code of the previous request

public int get status code ( ) { return status code ; }


< code > repeated io netty example worldclock local time local time = 1 ; < code >

public io netty example worldclock world clock protocol local time or builder get local time or builder ( int index ) { return local time get ( index ) ; }


copies all bytes from a file to an output stream < b > { @ link java nio file path } equivalent : < b > { @ link java nio file files # copy ( java nio file path , output stream ) }

public static void copy ( file from , output stream to ) throws i o exception { as byte source ( from ) copy to ( to ) ; }


public big decimal get prefix number ( ) { return prefix number ; }


returns all provided libraries needed to run the program

public list < url > get job jar and dependencies ( ) { list < url > libs = new array list < url > ( extracted temp libraries size ( ) + 1 ) ; if ( jar file ! = null ) { libs add ( jar file ) ; } for ( file tmp lib : extracted temp libraries ) { try { libs add ( tmp lib get absolute file ( ) to u r i ( ) to u r l ( ) ) ; } catch ( malformed u r l exception e ) { throw new runtime exception ( " url is invalid this should not happen " , e ) ; } } if ( is python ) { libs add ( packaged program utils get python jar ( ) ) ; } return libs ; }


returns the rtti number : { 0 - 4 , or - 1 if not an rtti }

public int get r t t i number ( ) { return basic name get r t t i number ( ) ; }


public hdfs data output stream append ( final string src , final int buffersize , enum set < create flag > flag , final progressable progress , final file system statistics statistics , final inet socket address [ ] favored nodes ) throws i o exception { final d f s output stream out = append ( src , buffersize , flag , get favored nodes str ( favored nodes ) , progress ) ; return create wrapped output stream ( out , statistics , out get initial len ( ) ) ; }


test case for https : activiti atlassian netbrowse a c t - 1978

public void test signal delete on redeploy ( ) { / / deploy test processes repository service create deployment ( ) add classpath resource ( " org / activiti / engine / test / bpmn / event / signal / signal event test test signal start event bpmn 2 0 xml " ) deploy ( ) ; / / deploy new versions repository service create deployment ( ) add classpath resource ( " org / activiti / engine / test / bpmn / event / signal / signal event test test signal start event bpmn 2 0 xml " ) deploy ( ) ; repository service create deployment ( ) add classpath resource ( " org / activiti / engine / test / bpmn / event / signal / signal event test test signal start event bpmn 2 0 xml " ) deploy ( ) ; / / firing a signal start event should only start one process instance / / this used to be two , due to subscriptions not being cleaned up runtime service signal event received ( " the signal " ) ; assert that ( runtime service create process instance query ( ) count ( ) ) is equal to ( 3 ) ; / / cleanup for ( org activiti engine repository deployment deployment : repository service create deployment query ( ) list ( ) ) { repository service delete deployment ( deployment get id ( ) , true ) ; } }


add instruction bit pattern to the current pattern group

public void add instruction pattern ( int offset , pattern block maskvalue ) { current group add ( new instruction bit pattern ( offset , maskvalue ) ) ; }


creates a result might start threads or opens sockets so every created result must be closed

public < t > dynamic result < t > create result ( environment env , table schema schema , execution config config ) { if ( env get execution ( ) in streaming mode ( ) ) { / / determine gateway address ( and port if possible ) final inet address gateway address = get gateway address ( env get deployment ( ) ) ; final int gateway port = get gateway port ( env get deployment ( ) ) ; if ( env get execution ( ) is changelog mode ( ) | | env get execution ( ) is tableau mode ( ) ) { return new changelog collect stream result < > ( schema , config , gateway address , gateway port ) ; } else { return new materialized collect stream result < > ( schema , config , gateway address , gateway port , env get execution ( ) get max table result rows ( ) ) ; } } else { / / batch execution if ( env get execution ( ) is table mode ( ) | | env get execution ( ) is tableau mode ( ) ) { return new materialized collect batch result < > ( schema , config ) ; } else { throw new sql execution exception ( " results of batch queries can only be served in table or tableau mode " ) ; } } }


public boolean is compatible ( dalv insn insn ) { register spec list regs = insn get registers ( ) ; return ( insn instanceof simple insn ) & & ( regs size ( ) = = 1 ) & & unsigned fits in byte ( regs get ( 0 ) get reg ( ) ) ; }


retry a test in case of a failure with a specific exception

public void evaluate ( ) throws throwable { for ( current run = 0 ; current run < = times on failure ; current run + + ) { try { statement evaluate ( ) ; break ; / / success } catch ( throwable t ) { log warn ( string format ( " test run failed ( % d / % d ) " , current run , times on failure + 1 ) , t ) ; if ( ! exception class is assignable from ( t get class ( ) ) | | current run > = times on failure ) { / / throw the failure if retried too often , or if it is the wrong exception throw t ; } } } }


public void set id ( long id ) { this id = id ; }


public boolean get name boolean ( ) { return name boolean ; }


add a configuration resource the properties form this configuration will overwrite corresponding already loaded property and system property

public void add configuration ( file config file ) throws config exception { log info ( " reading configuration from : { } " , config file get absolute path ( ) ) ; try { config file = ( new verifying file factory builder ( log ) warn for relative path ( ) fail for non existing path ( ) build ( ) ) validate ( config file ) ; properties cfg = new properties ( ) ; file input stream in = new file input stream ( config file ) ; try { cfg load ( in ) ; } finally { in close ( ) ; } parse properties ( cfg ) ; } catch ( i o exception | illegal argument exception e ) { log error ( " error while configuration from : { } " , config file get absolute path ( ) , e ) ; throw new config exception ( " error while processing " + config file get absolute path ( ) , e ) ; } }


returns the relocation table associated to the specified section header , or null if one does not exist

public elf relocation table get relocation table ( elf section header reloc section ) { return get relocation table at offset ( reloc section get offset ( ) ) ; }


gets the target for this reindex request in the for of an { @ link index request }

public index request get destination ( ) { return destination ; }


returns a { @ link path converter } for the uploaded files , or { @ code null } when the uploaded failed

default listenable future < path converter > upload referenced local files ( collection < local file > local files ) { map < path , local file > local file map = maps new hash map with expected size ( local files size ( ) ) ; for ( local file local file : local files ) { / / it is possible for targets to have duplicate artifacts ( same path but different owners ) / / in their output groups since they didn ' t trigger an artifact conflict they are the / / same file , so just skip either one local file map put if absent ( local file path , local file ) ; } return upload ( local file map ) ; }


returns the next buffer to write data into

public byte buffer get next buffer ( byte buffer last buffer ) { if ( m buffers = = null ) { throw new runtime exception ( when closed ) ; } if ( last buffer ! = m buffers peek last ( ) ) { m buffers add last ( last buffer ) ; } if ( last buffer has remaining ( ) ) { return last buffer ; } else { return byte buffer allocate direct ( 8096 ) ; } }


starts source preparation and enables the source , see { @ link # prepare source ( media source caller , transfer listener ) } this method is called at most once until the next call to { @ link # release source internal ( ) }

protected abstract void prepare source internal ( @ nullable transfer listener media transfer listener ) ;


public void handle transport error ( stomp session session , throwable exception ) { }


returns the number of audio samples represented by the given dts frame

public static int parse dts audio sample count ( byte [ ] data ) { int nblks ; switch ( data [ 0 ] ) { case first byte le : nblks = ( ( data [ 5 ] & 0x 0 1 ) < < 6 ) | ( ( data [ 4 ] & 0x f c ) > > 2 ) ; break ; case first byte 14b le : nblks = ( ( data [ 4 ] & 0x 0 7 ) < < 4 ) | ( ( data [ 7 ] & 0x 3 c ) > > 2 ) ; break ; case first byte 14b be : nblks = ( ( data [ 5 ] & 0x 0 7 ) < < 4 ) | ( ( data [ 6 ] & 0x 3 c ) > > 2 ) ; break ; default : / / we blindly assume first byte be if none of the others match nblks = ( ( data [ 4 ] & 0x 0 1 ) < < 6 ) | ( ( data [ 5 ] & 0x f c ) > > 2 ) ; } return ( nblks + 1 ) * 32 ; }


returns true if these options contain the given { @ link fragment options }

public boolean contains ( class < ? extends fragment options > options class ) { return fragment options map contains key ( options class ) ; }


lock storage to provide exclusive access locking is not supported by all file systems e g , nfs does not consistently support exclusive locks if locking is supported we guarantee exclusive access to the storage directory otherwise , no guarantee is given

public void lock ( ) throws i o exception { if ( is shared ( ) ) { log info ( " locking is disabled for { } " , this root ) ; return ; } file lock new lock = try lock ( ) ; if ( new lock = = null ) { string msg = " cannot lock storage " + this root + " the directory is already locked " ; log info ( msg ) ; throw new i o exception ( msg ) ; } / / don ' t overwrite lock until success - this way if we accidentally / / call lock twice , the internal state won ' t be cleared by the second / / ( failed ) lock attempt lock = new lock ; }


write a portion of an array , flushing to the underlying stream at most once if necessary

private int write 1 ( byte b [ ] , int off , int len ) throws i o exception { if ( count = = 0 & & len > = buf length ) { / / local buffer is empty and user buffer size > = local buffer size , so / / simply checksum the user buffer and send it directly to the underlying / / stream final int length = buf length ; write checksum chunks ( b , off , length ) ; return length ; } / / copy user data to local buffer int bytes to copy = buf length - count ; bytes to copy = ( len < bytes to copy ) ? len : bytes to copy ; system arraycopy ( b , off , buf , count , bytes to copy ) ; count + = bytes to copy ; if ( count = = buf length ) { / / local buffer is full flush buffer ( ) ; } return bytes to copy ; }


increases the size of the backing array to accommodate the specified number of additional items load factor useful before adding many items to avoid multiple backing array resizes

public void ensure capacity ( int additional capacity ) { int table size = table size ( size + additional capacity , load factor ) ; if ( key table length < table size ) resize ( table size ) ; }


returns a fluent iterable whose iterators traverse first the elements of this fluent iterable , followed by those of { @ code other } the iterators are not polled until necessary the returned iterable ' s { @ code iterator } supports { @ code remove ( ) } when the corresponding { @ code iterator } supports it < b > { @ code stream } equivalent : < b > { @ link stream # concat }

public final fluent iterable < e > append ( iterable < ? extends e > other ) { return fluent iterable concat ( get delegate ( ) , other ) ; }


logs in to the wikibase instance , using owner - only consumer if failed to login , the connection will be set to null

public boolean login ( string media wiki api endpoint , string consumer token , string consumer secret , string access token , string access secret ) { o auth api connection connection = new o auth api connection ( media wiki api endpoint , consumer token , consumer secret , access token , access secret ) ; setup connection ( connection ) ; try { / / check if the credentials are valid connection check credentials ( ) ; endpoint to connection put ( media wiki api endpoint , connection ) ; return true ; } catch ( i o exception | media wiki api error exception e ) { logger error ( e get message ( ) , e ) ; return false ; } }


determines whether the given method takes a guard as its first parameter

private static boolean is guarded ( method method ) { class < ? > [ ] parameter types = method get parameter types ( ) ; return parameter types length > = 1 & & parameter types [ 0 ] = = monitor guard class ; }


causes the contents to be clipped if they exceed the table ' s bounds enabling clipping sets { @ link # set transform ( boolean ) } to true

public void set clip ( boolean enabled ) { clip = enabled ; set transform ( enabled ) ; invalidate ( ) ; }


make sure the i ds of striped blocks do not conflict

public void test allocate block id ( ) throws exception { path test path = new path ( " / testfile " ) ; / / create a file while allocates a new block d f s test util write file ( dfs , test path , " hello , world ! " ) ; located blocks lb = dfs get client ( ) get located blocks ( test path to string ( ) , 0 ) ; final long first id = lb get ( 0 ) get block ( ) get block id ( ) ; / / delete the file dfs delete ( test path , true ) ; / / allocate a new block , and make sure the new block ' s id does not conflict / / with the previous one d f s test util write file ( dfs , test path , " hello again " ) ; lb = dfs get client ( ) get located blocks ( test path to string ( ) , 0 ) ; final long second id = lb get ( 0 ) get block ( ) get block id ( ) ; assert equals ( first id + hdfs server constants max blocks in group , second id ) ; }


returns { @ code true } if the { @ link throwable } was caused by an timeout or transport error these methods can be used on the { @ link future # cause ( ) } that is returned by the various methods exposed by this { @ link dns name resolver }

public static boolean is transport or timeout error ( throwable cause ) { return cause ! = null & & cause get cause ( ) instanceof dns name resolver exception ; }


public static boolean enable epoll ( ) { return netty base config server channel clazz equals ( epoll server socket channel class ) & & epoll is available ( ) ; }


invoked only if the converter type is { @ code mapping jackson 2 http message converter }

protected abstract void before body write internal ( mapping jackson value body container , media type content type , method parameter return type , server http request request , server http response response ) ;


tests restart of namenode while datanode hosts are added to exclude file

public void test decommission with namenode restart ( ) throws i o exception , interrupted exception { log info ( " starting test test decommission with namenode restart " ) ; int num namenodes = 1 ; int num datanodes = 1 ; int replicas = 1 ; get conf ( ) set long ( d f s config keys dfs blockreport interval msec key , d f s config keys dfs blockreport interval msec default ) ; get conf ( ) set long ( d f s config keys dfs blockreport initial delay key , 5 ) ; start cluster ( num namenodes , num datanodes ) ; path file 1 = new path ( " test decommission with namenode restart dat " ) ; file system file sys = get cluster ( ) get file system ( ) ; write file ( file sys , file 1 , replicas ) ; d f s client client = get dfs client ( 0 ) ; datanode info [ ] info = client datanode report ( datanode report type live ) ; datanode i d excluded datanode i d = info [ 0 ] ; string excluded datanode name = info [ 0 ] get xfer addr ( ) ; init exclude host ( excluded datanode name ) ; / / add a new datanode to cluster get cluster ( ) start data nodes ( get conf ( ) , 1 , true , null , null , null , null ) ; num datanodes + = 1 ; assert equals ( " number of datanodes should be 2 " , 2 , get cluster ( ) get data nodes ( ) size ( ) ) ; / / restart the namenode get cluster ( ) restart name node ( ) ; datanode info datanode info = name node adapter get datanode ( get cluster ( ) get namesystem ( ) , excluded datanode i d ) ; wait node state ( datanode info , admin states decommissioned ) ; / / ensure decommissioned datanode is not automatically shutdown assert equals ( " all datanodes must be alive " , num datanodes , client datanode report ( datanode report type live ) length ) ; assert true ( " checked if block was replicated after decommission " , check file ( file sys , file 1 , replicas , datanode info get xfer addr ( ) , num datanodes ) = = null ) ; cleanup file ( file sys , file 1 ) ; / / restart the cluster and ensure recommissioned datanodes / / are allowed to register with the namenode shutdown cluster ( ) ; start cluster ( num namenodes , num datanodes ) ; }