tests that java info java annotation processing returned from java common compile looks as expected , and specifically , looks as if java library was used instead

public void test java common compile exposes annotation processing info ( ) throws exception { / / set up a starlark rule that uses java common compile and supports annotation processing in / / the same way as java library , then use a helper method to test that the custom rule produces / / the same annotation processing information as java library would write build file for java toolchain ( ) ; scratch file ( " java / test / custom rule bzl " , " def impl ( ctx ) : " , " output jar = ctx actions declare file ( ' lib ' + ctx label name + ' jar ' ) " , " return java common compile ( " , " ctx , " , " source files = ctx files srcs , " , " deps = [ d [ java info ] for d in ctx attr deps ] , " , " exports = [ e [ java info ] for e in ctx attr exports ] , " , " plugins = [ p [ java info ] for p in ctx attr plugins ] , " , " output = output jar , " , " java toolchain = ctx attr java toolchain [ java common java toolchain info ] , " , " ) " , " java custom library = rule ( " , " implementation = impl , " , " outputs = { " , " ' my output ' : ' lib % { name } jar ' " , " } , " , " attrs = { " , " ' srcs ' : attr label list ( allow files = [ ' java ' ] ) , " , " ' deps ' : attr label list ( ) , " , " ' exports ' : attr label list ( ) , " , " ' plugins ' : attr label list ( ) , " , " ' java toolchain ' : attr label ( default = label ( ' / / java / com / google / test : toolchain ' ) ) , " , " } , " , " fragments = [ ' java ' ] " , " ) " ) ; test annotation processing info is starlark accessible ( / * to be processed rule name = * / " java custom library " , / * extra load = * / " load ( ' : custom rule bzl ' , ' java custom library ' ) " ) ; }


whether retry is supported when operation fails

boolean should retry ( int retried , long elapsed , boolean sleep ) ;


< code > optional aapt pb style style = 2 ; < code >

public boolean has style ( ) { return instance has style ( ) ; }


gets a read - only view all the { @ link item } s recursively matching supplied type and predicate conditions in the { @ link item group } tree visible to the supplied authentication without concern for the order in which items are returned each iteration of the view will be " live " reflecting the items available between the time the iteration was started and the time the iteration was completed , however if items are moved during an iteration - depending on the move - it may be possible for such items to escape the entire iteration

public static < t extends item > iterable < t > all items 2 ( authentication authentication , item group root , class < t > type , predicate < t > pred ) { return new all items iterable < > ( root , authentication , type , pred ) ; }


handle the block exception and provide fallback result

result handle ( invoker < ? > invoker , invocation invocation , block exception ex ) ;


decrement this client ' s reference count

int dec and get count ( ) { return ref count decrement and get ( ) ; }


the character for the key that was type valid for : key typed

public char get character ( ) { return character ; }


returns an immutable view of this array ' s values as a { @ code list } ; note that { @ code double } values are boxed into { @ link double } instances on demand , which can be very expensive the returned list should be used once and discarded for any usages beyond that , pass the returned list to { @ link com google common collect immutable list # copy of ( collection ) immutable list copy of } and use that list instead

public list < double > as list ( ) { / * * typically we cache this kind of thing , but much repeated use of this view is a performance * anti - pattern anyway if we cache , then everyone pays a price in memory footprint even if * they never use this method * / return new as list ( this ) ; }


parses the config for the load balancing policy unpacked from the service config this will return a { @ link config or error } which contains either the successfully parsed config , or the { @ link status } representing the failure to parse implementations are expected to not throw exceptions but return a status representing the failure if successful , the load balancing policy config should be immutable

public config or error parse load balancing policy config ( map < string , ? > raw load balancing policy config ) { return unknown config ; }


returns the { @ link rule class provider } of this { @ link package factory }

public rule class provider get rule class provider ( ) { return rule class provider ; }


accumulates a new reading by keeping a running account of the value distance from the beginning of the bucket to the end of this reading

protected void extend internal ( double new progress , int new value ) { if ( state = = null ) { return ; } state current accumulation + = ( double ) ( new value - previous value ) ; previous value = new value ; }


returns the string path of a dwarf entry always returns a name for the passed - in entry , but you should probably only use this for entries that are { @ link d i e aggregate # is named type ( ) }

private d w a r f name info get d w a r f name info ( d i e aggregate diea , d w a r f name info local root d n i ) { d w a r f name info parent d n i = local root d n i ; d i e aggregate decl parent = diea get decl parent ( ) ; if ( ( decl parent ! = null ) & & decl parent get tag ( ) ! = d w a r f tag dw tag compile unit ) { parent d n i = lookup d n i by offset ( decl parent get offset ( ) ) ; if ( parent d n i = = null ) { parent d n i = get d w a r f name info ( decl parent , local root d n i ) ; if ( parent d n i ! = null ) { cache d n i by offset ( decl parent get offset ( ) , parent d n i ) ; } } } string name = get entry name ( diea ) ; / / mangled names can occur in linkage attributes or in the regular name attribute if ( name ! = null & & name contains ( " z " ) / * mangler start seq * / & & ! name starts with ( " global " ) / * compiler generated , don ' t demangle as they tend to conflict with existing names * / ) { list < string > nestings = ensure safe name lengths ( d w a r f util parse mangled nestings ( name ) ) ; if ( ! nestings is empty ( ) ) { name = nestings remove ( nestings size ( ) - 1 ) ; if ( parent d n i = = local root d n i & & ! nestings is empty ( ) ) { parent d n i = d w a r f name info from list ( local root d n i , nestings ) ; } } } / / if namespace info got squashed due to compiler / linker flags , try to / / dig it up from the mangled linkage info that might be present in our children if ( local root d n i equals ( parent d n i ) ) { list < string > nestings = d w a r f util find linkage name in children ( diea get head fragment ( ) ) ; if ( ! nestings is empty ( ) ) { nestings remove ( nestings size ( ) - 1 ) ; parent d n i = d w a r f name info from list ( local root d n i , nestings ) ; } } if ( name = = null ) { / / check to see if there is a single inbound typedef that we can / / steal its name d i e aggregate referring typedef = d w a r f util get referring typedef ( diea ) ; if ( referring typedef ! = null ) { return get d w a r f name info ( referring typedef , local root d n i ) ; } } boolean is anon = false ; if ( name = = null ) { switch ( diea get tag ( ) ) { case d w a r f tag dw tag base type : name = get anon base type name ( diea ) ; is anon = true ; break ; case d w a r f tag dw tag enumeration type : name = get anon enum name ( diea ) ; is anon = true ; break ; case d w a r f tag dw tag subroutine type : / / unnamed subroutines ( c func ptrs ) / / see { @ link # is anon subroutine ( data type ) } name = " anon subr " ; is anon = true ; break ; case d w a r f tag dw tag lexical block : name = d w a r f util get lexical block name ( diea ) ; break ; case d w a r f tag dw tag formal parameter : name = " param " + d w a r f util get my position in parent ( diea get head fragment ( ) ) ; is anon = true ; break ; case d w a r f tag dw tag subprogram : case d w a r f tag dw tag inlined subroutine : if ( decl parent ! = null & & decl parent is structure type ( ) & & diea get bool ( d w a r f attribute dw at artificial , false ) ) { name = parent d n i get name ( ) ; } else { name = " anon func " ; is anon = true ; } break ; default : if ( decl parent ! = null & & decl parent is name space container ( ) ) { name = d w a r f util get anon name for me from parent context 2 ( diea ) ; } break ; } } / / name was not found if ( is anon d w a r f name ( name ) ) { name = create anon name ( " anon " + d w a r f util get container type name ( diea ) , diea ) ; is anon = true ; } string orig name = is anon ? null : name ; string working name = ensure safe name length ( name ) ; switch ( diea get tag ( ) ) { / / fixup dwarf entries that are related to ghidra symbols case d w a r f tag dw tag subroutine type : case d w a r f tag dw tag subprogram : case d w a r f tag dw tag inlined subroutine : working name = symbol utilities replace invalid chars ( working name , false ) ; break ; } d w a r f name info result = parent d n i create child ( orig name , working name , d w a r f util get symbol type from d i e ( diea ) ) ; return result ; }


returns a generic iso datetime parser where the date is mandatory and the time is optional the returned formatter can only be used for parsing , printing is unsupported this parser can parse zoned datetimes the parser is strict by default , thus time string { @ code 24 : 00 } cannot be parsed it accepts formats described by the following syntax : date - opt - time = date - element [ ' t ' [ time - element ] [ offset ] ] date - element = std - date - element | ord - date - element | week - date - element std - date - element = yyyy [ ' - ' mm [ ' - ' dd ] ] ord - date - element = yyyy [ ' - ' ddd ] week - date - element = xxxx ' - w ' ww [ ' - ' e ] time - element = hh [ minute - element ] | [ fraction ] minute - element = ' : ' mm [ second - element ] | [ fraction ] second - element = ' : ' ss [ fraction ] fraction = ( ' ' | ' , ' ) digit +

public static date time formatter date optional time parser ( ) { return constants dotp ; }


check if the actual layout will be performed

public boolean is cancelled ( ) { return cancelled ; }


public boolean succeeded ( ) { return is done ( ) & & ! failed ( ) ; }


public static void print ascii art warning ( final logger out , final string additional ) { val ascii = ' \ n ' + " \ n " + " / | / \ \ | \ \ | | \ n " + " \ \ \ \ | | | | | | | ) | | \ n " + " ) | | | | | | | / | | \ n " + " | / | | \ \ / | | ( ) \ n " + " \ n " ; out warn ( ascii art logger marker , ansi cyan ) ; out warn ( ascii art logger marker , " \ n \ n " concat ( ascii ) concat ( additional ) ) ; out warn ( ascii art logger marker , ansi reset ) ; }


returns true if the array has one or more items

public boolean not empty ( ) { return size > 0 ; }


returns the { @ link help location } for this service

public help location get help location ( ) ;


sets new values to all fields of the tuple


perform a upgrade using the test image corresponding to test case name

private static void run layout upgrade test ( final string test case name , final string expected storage id ) throws i o exception { test d f s upgrade from image upgrade = new test d f s upgrade from image ( ) ; upgrade unpack storage ( test case name + " tgz " , test case name + " txt " ) ; configuration conf = new configuration ( test d f s upgrade from image upgrade conf ) ; init storage dirs ( conf , test case name ) ; upgrade and verify ( upgrade , conf , new cluster verifier ( ) { @ override public void verify cluster post upgrade ( mini d f s cluster cluster ) throws i o exception { / / verify that a guid - based storage id was generated final string bpid = cluster get namesystem ( ) get block pool id ( ) ; storage report [ ] reports = cluster get data nodes ( ) get ( 0 ) get f s dataset ( ) get storage reports ( bpid ) ; assert that ( reports length , is ( 1 ) ) ; final string storage i d = reports [ 0 ] get storage ( ) get storage i d ( ) ; assert true ( datanode storage is valid storage id ( storage i d ) ) ; if ( expected storage id ! = null ) { assert that ( storage i d , is ( expected storage id ) ) ; } } } ) ; }


grant a vote to a candidate and become a follower for this epoch we will remain in this state until either the election timeout expires or a leader is elected in particular , we do not begin fetching until the election has concluded and { @ link # transition to follower ( int , int ) } is invoked

public void transition to voted ( int epoch , int candidate id ) throws i o exception { if ( candidate id = = local id ) { throw new illegal state exception ( " cannot transition to voted with voted id = " + candidate id + " and epoch = " + epoch + " since it matches the local broker id " ) ; } else if ( is observer ( ) ) { throw new illegal state exception ( " cannot transition to voted with voted id = " + candidate id + " and epoch = " + epoch + " since the local broker id = " + local id + " is not a voter " ) ; } else if ( ! is voter ( candidate id ) ) { throw new illegal state exception ( " cannot transition to voted with voter id = " + candidate id + " and epoch = " + epoch + " since it is not one of the voters " + voters ) ; } int current epoch = state epoch ( ) ; if ( epoch < current epoch ) { throw new illegal state exception ( " cannot transition to voted with voted id = " + candidate id + " and epoch = " + epoch + " since the current epoch " + current epoch + " is larger " ) ; } else if ( epoch = = current epoch & & ! is unattached ( ) ) { throw new illegal state exception ( " cannot transition to voted with voted id = " + candidate id + " and epoch = " + epoch + " from the current state " + state ) ; } / / note that we reset the election timeout after voting for a candidate because we / / know that the candidate has at least as good of a chance of getting elected as us transition to ( new voted state ( time , epoch , candidate id , voters , state high watermark ( ) , random election timeout ms ( ) ) ) ; }


returns the dynamic symbol table as defined in this elf file

public elf symbol table get dynamic symbol table ( ) { return dynamic symbol table ; }


public void array of string test ( ) { / / todo : test array of string }


adds a new violation to this collector this also sets { @ code violation occurred } to { @ code true } prefer the method with explicit message parameters if you want to interpolate the message

public void add violation ( string property name , integer index , string message ) { add violation ( property name , index , message , collections empty map ( ) ) ; }


private void check census ( metrics record record , boolean is server , collection < ? extends message lite > requests , collection < ? extends message lite > responses ) { int uncompressed requests size = 0 ; for ( message lite request : requests ) { uncompressed requests size + = request get serialized size ( ) ; } int uncompressed responses size = 0 ; for ( message lite response : responses ) { uncompressed responses size + = response get serialized size ( ) ; } if ( is server ) { assert equals ( requests size ( ) , record get metric as long or fail ( deprecated census constants rpc server request count ) ) ; assert equals ( responses size ( ) , record get metric as long or fail ( deprecated census constants rpc server response count ) ) ; assert equals ( uncompressed requests size , record get metric as long or fail ( deprecated census constants rpc server uncompressed request bytes ) ) ; assert equals ( uncompressed responses size , record get metric as long or fail ( deprecated census constants rpc server uncompressed response bytes ) ) ; assert not null ( record get metric ( deprecated census constants rpc server server latency ) ) ; / / it ' s impossible to get the expected wire sizes because it may be compressed , so we just / / check if they are recorded assert not null ( record get metric ( deprecated census constants rpc server request bytes ) ) ; assert not null ( record get metric ( deprecated census constants rpc server response bytes ) ) ; } else { assert equals ( requests size ( ) , record get metric as long or fail ( deprecated census constants rpc client request count ) ) ; assert equals ( responses size ( ) , record get metric as long or fail ( deprecated census constants rpc client response count ) ) ; assert equals ( uncompressed requests size , record get metric as long or fail ( deprecated census constants rpc client uncompressed request bytes ) ) ; assert equals ( uncompressed responses size , record get metric as long or fail ( deprecated census constants rpc client uncompressed response bytes ) ) ; assert not null ( record get metric ( deprecated census constants rpc client roundtrip latency ) ) ; / / it ' s impossible to get the expected wire sizes because it may be compressed , so we just / / check if they are recorded assert not null ( record get metric ( deprecated census constants rpc client request bytes ) ) ; assert not null ( record get metric ( deprecated census constants rpc client response bytes ) ) ; } }


processes the manifest for a binary and return the manifest path

public path process manifest ( string application id , int version code , string version name , path manifest , path processed manifest , boolean log warnings ) { if ( version code ! = - 1 | | version name ! = null | | application id ! = null ) { process manifest ( version code , version name , manifest , processed manifest , merge type application , application id , log warnings ) ; return processed manifest ; } return manifest ; }


public optional < duration > get system execution time ( ) { return system execution time ; }


writes a pkgdummy bzl file that prints a marker phrase when it finishes evaluating , and an accompanying build file that loads it

private void write pkg bzl ( string lines ) throws exception { scratch file ( " pkg / build " , " load ( ' : dummy bzl ' , ' dummy symbol ' ) " ) ; scratch file ( " pkg / dummy " ) ; list < string > modified lines = new array list < > ( arrays as list ( lines ) ) ; modified lines add ( " dummy symbol = none " ) ; / / the marker phrase might not be needed , but i don ' t entirely trust build view test case modified lines add ( " print ( ' dummy bzl evaluation completed ' ) " ) ; scratch file ( " pkg / dummy bzl " , modified lines to array ( lines ) ) ; }


check whether this transaction object has a connection holder

public boolean has connection holder ( ) { return ( this connection holder ! = null ) ; }


public future < channel > renegotiate ( final promise < channel > promise ) { object util check not null ( promise , " promise " ) ; channel handler context ctx = this ctx ; if ( ctx = = null ) { throw new illegal state exception ( ) ; } event executor executor = ctx executor ( ) ; if ( ! executor in event loop ( ) ) { executor execute ( new runnable ( ) { @ override public void run ( ) { renegotiate on event loop ( promise ) ; } } ) ; return promise ; } renegotiate on event loop ( promise ) ; return promise ; }


asserts that a zero byte file has a status of file and not directory or symlink

public void test zero byte files are files ( ) throws exception { path src = path ( " test zero byte files are files " ) ; / / create a zero byte file f s data output stream out = fs create ( src ) ; out close ( ) ; assert is file ( src ) ; }


returns the presentation time of the current sample in microseconds

public long get current sample presentation time us ( ) { return ! currently in fragment ? moov sample table timestamps us [ current sample index ] : fragment get sample presentation time us ( current sample index ) ; }


retrieves { @ link input stream } of image by uri ( image is accessed using { @ link content resolver } )

protected input stream get stream from content ( string image uri , object extra ) throws file not found exception { content resolver res = context get content resolver ( ) ; uri uri = uri parse ( image uri ) ; if ( is video content uri ( uri ) ) { / / video thumbnail long orig id = long value of ( uri get last path segment ( ) ) ; bitmap bitmap = media store video thumbnails get thumbnail ( res , orig id , media store images thumbnails mini kind , null ) ; if ( bitmap ! = null ) { byte array output stream bos = new byte array output stream ( ) ; bitmap compress ( compress format png , 0 , bos ) ; return new byte array input stream ( bos to byte array ( ) ) ; } } else if ( image uri starts with ( content contacts uri prefix ) ) { / / contacts photo return get contact photo stream ( uri ) ; } return res open input stream ( uri ) ; }


gets the option value associated with this check box

private int get option ( ) { return option ; }


the ' root ' process instance when using call activity for example , the process instance set will not always be the root this method returns the topmost process instance

string get root process instance id ( ) ;


returns the next datetime < i > after < i > the given datetime which satisfies the cron expression

public long get next valid time after ( final long time ) { / / computation is based on gregorian year only calendar cl = new java util gregorian calendar ( utc , locale root ) ; / / move ahead one second , since we ' re computing the time * after * the / / given time final long after time = time + 1000 ; / / cron trigger does not deal with milliseconds cl set time in millis ( after time ) ; cl set ( calendar millisecond , 0 ) ; boolean got one = false ; / / loop until we ' ve computed the next time , or we ' ve past the end time while ( ! got one ) { if ( cl get ( calendar year ) > 2999 ) { / / prevent endless loop return - 1 ; } sorted set < integer > st = null ; int t = 0 ; int sec = cl get ( calendar second ) ; int min = cl get ( calendar minute ) ; / / get second st = seconds tail set ( sec ) ; if ( st ! = null & & st size ( ) ! = 0 ) { sec = st first ( ) ; } else { sec = seconds first ( ) ; min + + ; cl set ( calendar minute , min ) ; } cl set ( calendar second , sec ) ; min = cl get ( calendar minute ) ; int hr = cl get ( calendar hour of day ) ; t = - 1 ; / / get minute st = minutes tail set ( min ) ; if ( st ! = null & & st size ( ) ! = 0 ) { t = min ; min = st first ( ) ; } else { min = minutes first ( ) ; hr + + ; } if ( min ! = t ) { cl set ( calendar second , 0 ) ; cl set ( calendar minute , min ) ; set calendar hour ( cl , hr ) ; continue ; } cl set ( calendar minute , min ) ; hr = cl get ( calendar hour of day ) ; int day = cl get ( calendar day of month ) ; t = - 1 ; / / get hour st = hours tail set ( hr ) ; if ( st ! = null & & st size ( ) ! = 0 ) { t = hr ; hr = st first ( ) ; } else { hr = hours first ( ) ; day + + ; } if ( hr ! = t ) { cl set ( calendar second , 0 ) ; cl set ( calendar minute , 0 ) ; cl set ( calendar day of month , day ) ; set calendar hour ( cl , hr ) ; continue ; } cl set ( calendar hour of day , hr ) ; day = cl get ( calendar day of month ) ; int mon = cl get ( calendar month ) + 1 ; / / ' + 1 ' because calendar is 0 - based for this field , and we are / / 1 - based t = - 1 ; int tmon = mon ; / / get day boolean day of m spec = ! days of month contains ( no spec ) ; boolean day of w spec = ! days of week contains ( no spec ) ; if ( day of m spec & & ! day of w spec ) { / / get day by day of month rule st = days of month tail set ( day ) ; if ( lastday of month ) { if ( ! nearest weekday ) { t = day ; day = get last day of month ( mon , cl get ( calendar year ) ) ; day - = lastday offset ; if ( t > day ) { mon + + ; if ( mon > 12 ) { mon = 1 ; tmon = 3333 ; / / ensure test of mon ! = tmon further below fails cl add ( calendar year , 1 ) ; } day = 1 ; } } else { t = day ; day = get last day of month ( mon , cl get ( calendar year ) ) ; day - = lastday offset ; calendar tcal = calendar get instance ( utc , locale root ) ; tcal set ( calendar second , 0 ) ; tcal set ( calendar minute , 0 ) ; tcal set ( calendar hour of day , 0 ) ; tcal set ( calendar day of month , day ) ; tcal set ( calendar month , mon - 1 ) ; tcal set ( calendar year , cl get ( calendar year ) ) ; int ldom = get last day of month ( mon , cl get ( calendar year ) ) ; int dow = tcal get ( calendar day of week ) ; if ( dow = = calendar saturday & & day = = 1 ) { day + = 2 ; } else if ( dow = = calendar saturday ) { day - = 1 ; } else if ( dow = = calendar sunday & & day = = ldom ) { day - = 2 ; } else if ( dow = = calendar sunday ) { day + = 1 ; } tcal set ( calendar second , sec ) ; tcal set ( calendar minute , min ) ; tcal set ( calendar hour of day , hr ) ; tcal set ( calendar day of month , day ) ; tcal set ( calendar month , mon - 1 ) ; long n time = tcal get time in millis ( ) ; if ( n time < after time ) { day = 1 ; mon + + ; } } } else if ( nearest weekday ) { t = day ; day = days of month first ( ) ; calendar tcal = calendar get instance ( utc , locale root ) ; tcal set ( calendar second , 0 ) ; tcal set ( calendar minute , 0 ) ; tcal set ( calendar hour of day , 0 ) ; tcal set ( calendar day of month , day ) ; tcal set ( calendar month , mon - 1 ) ; tcal set ( calendar year , cl get ( calendar year ) ) ; int ldom = get last day of month ( mon , cl get ( calendar year ) ) ; int dow = tcal get ( calendar day of week ) ; if ( dow = = calendar saturday & & day = = 1 ) { day + = 2 ; } else if ( dow = = calendar saturday ) { day - = 1 ; } else if ( dow = = calendar sunday & & day = = ldom ) { day - = 2 ; } else if ( dow = = calendar sunday ) { day + = 1 ; } tcal set ( calendar second , sec ) ; tcal set ( calendar minute , min ) ; tcal set ( calendar hour of day , hr ) ; tcal set ( calendar day of month , day ) ; tcal set ( calendar month , mon - 1 ) ; long n time = tcal get time in millis ( ) ; if ( n time < after time ) { day = days of month first ( ) ; mon + + ; } } else if ( st ! = null & & st size ( ) ! = 0 ) { t = day ; day = st first ( ) ; / / make sure we don ' t over - run a short month , such as february int last day = get last day of month ( mon , cl get ( calendar year ) ) ; if ( day > last day ) { day = days of month first ( ) ; mon + + ; } } else { day = days of month first ( ) ; mon + + ; } if ( day ! = t | | mon ! = tmon ) { cl set ( calendar second , 0 ) ; cl set ( calendar minute , 0 ) ; cl set ( calendar hour of day , 0 ) ; cl set ( calendar day of month , day ) ; cl set ( calendar month , mon - 1 ) ; / / ' - 1 ' because calendar is 0 - based for this field , and we / / are 1 - based continue ; } } else if ( day of w spec & & ! day of m spec ) { / / get day by day of week rule if ( lastday of week ) { / / are we looking for the last xxx day of / / the month ? int dow = days of week first ( ) ; / / desired / / d - o - w int c dow = cl get ( calendar day of week ) ; / / current d - o - w int days to add = 0 ; if ( c dow < dow ) { days to add = dow - c dow ; } if ( c dow > dow ) { days to add = dow + ( 7 - c dow ) ; } int l day = get last day of month ( mon , cl get ( calendar year ) ) ; if ( day + days to add > l day ) { / / did we already miss the / / last one ? cl set ( calendar second , 0 ) ; cl set ( calendar minute , 0 ) ; cl set ( calendar hour of day , 0 ) ; cl set ( calendar day of month , 1 ) ; cl set ( calendar month , mon ) ; / / no ' - 1 ' here because we are promoting the month continue ; } / / find date of last occurrence of this day in this month while ( ( day + days to add + 7 ) < = l day ) { days to add + = 7 ; } day + = days to add ; if ( days to add > 0 ) { cl set ( calendar second , 0 ) ; cl set ( calendar minute , 0 ) ; cl set ( calendar hour of day , 0 ) ; cl set ( calendar day of month , day ) ; cl set ( calendar month , mon - 1 ) ; / / ' - 1 ' here because we are not promoting the month continue ; } } else if ( nthday of week ! = 0 ) { / / are we looking for the nth xxx day in the month ? int dow = days of week first ( ) ; / / desired / / d - o - w int c dow = cl get ( calendar day of week ) ; / / current d - o - w int days to add = 0 ; if ( c dow < dow ) { days to add = dow - c dow ; } else if ( c dow > dow ) { days to add = dow + ( 7 - c dow ) ; } boolean day shifted = false ; if ( days to add > 0 ) { day shifted = true ; } day + = days to add ; int week of month = day / 7 ; if ( day % 7 > 0 ) { week of month + + ; } days to add = ( nthday of week - week of month ) * 7 ; day + = days to add ; if ( days to add < 0 | | day > get last day of month ( mon , cl get ( calendar year ) ) ) { cl set ( calendar second , 0 ) ; cl set ( calendar minute , 0 ) ; cl set ( calendar hour of day , 0 ) ; cl set ( calendar day of month , 1 ) ; cl set ( calendar month , mon ) ; / / no ' - 1 ' here because we are promoting the month continue ; } else if ( days to add > 0 | | day shifted ) { cl set ( calendar second , 0 ) ; cl set ( calendar minute , 0 ) ; cl set ( calendar hour of day , 0 ) ; cl set ( calendar day of month , day ) ; cl set ( calendar month , mon - 1 ) ; / / ' - 1 ' here because we are not promoting the month continue ; } } else { int c dow = cl get ( calendar day of week ) ; / / current d - o - w int dow = days of week first ( ) ; / / desired / / d - o - w st = days of week tail set ( c dow ) ; if ( st ! = null & & st size ( ) > 0 ) { dow = st first ( ) ; } int days to add = 0 ; if ( c dow < dow ) { days to add = dow - c dow ; } if ( c dow > dow ) { days to add = dow + ( 7 - c dow ) ; } int l day = get last day of month ( mon , cl get ( calendar year ) ) ; if ( day + days to add > l day ) { / / will we pass the end of / / the month ? cl set ( calendar second , 0 ) ; cl set ( calendar minute , 0 ) ; cl set ( calendar hour of day , 0 ) ; cl set ( calendar day of month , 1 ) ; cl set ( calendar month , mon ) ; / / no ' - 1 ' here because we are promoting the month continue ; } else if ( days to add > 0 ) { / / are we swithing days ? cl set ( calendar second , 0 ) ; cl set ( calendar minute , 0 ) ; cl set ( calendar hour of day , 0 ) ; cl set ( calendar day of month , day + days to add ) ; cl set ( calendar month , mon - 1 ) ; / / ' - 1 ' because calendar is 0 - based for this field , / / and we are 1 - based continue ; } } } else { / / day of w spec & & ! day of m spec return - 1 ; / / throw new unsupported operation exception ( / / " support for specifying both a day - of - week and a day - of - month parameter is not implemented " ) ; } cl set ( calendar day of month , day ) ; mon = cl get ( calendar month ) + 1 ; / / ' + 1 ' because calendar is 0 - based for this field , and we are / / 1 - based int year = cl get ( calendar year ) ; t = - 1 ; / / test for expressions that never generate a valid fire date , / / but keep looping if ( year > max year ) { return - 1 ; / / throw new elasticsearch illegal argument exception ( " given time is not supported by cron [ " + formatter print ( time ) + " ] " ) ; } / / get month st = months tail set ( mon ) ; if ( st ! = null & & st size ( ) ! = 0 ) { t = mon ; mon = st first ( ) ; } else { mon = months first ( ) ; year + + ; } if ( mon ! = t ) { cl set ( calendar second , 0 ) ; cl set ( calendar minute , 0 ) ; cl set ( calendar hour of day , 0 ) ; cl set ( calendar day of month , 1 ) ; cl set ( calendar month , mon - 1 ) ; / / ' - 1 ' because calendar is 0 - based for this field , and we are / / 1 - based cl set ( calendar year , year ) ; continue ; } cl set ( calendar month , mon - 1 ) ; / / ' - 1 ' because calendar is 0 - based for this field , and we are / / 1 - based year = cl get ( calendar year ) ; t = - 1 ; / / get year st = years tail set ( year ) ; if ( st ! = null & & st size ( ) ! = 0 ) { t = year ; year = st first ( ) ; } else { return - 1 ; / / throw new elasticsearch illegal argument exception ( " given time is not supported by cron [ " + formatter print ( time ) + " ] " ) ; } if ( year ! = t ) { cl set ( calendar second , 0 ) ; cl set ( calendar minute , 0 ) ; cl set ( calendar hour of day , 0 ) ; cl set ( calendar day of month , 1 ) ; cl set ( calendar month , 0 ) ; / / ' - 1 ' because calendar is 0 - based for this field , and we are / / 1 - based cl set ( calendar year , year ) ; continue ; } cl set ( calendar year , year ) ; got one = true ; } / / while ( ! done ) return cl get time in millis ( ) ; }


verify that successful znode create result becomes active and monitoring is started

public void test create node result become active ( ) throws exception { mock no prior active ( ) ; elector join election ( data ) ; elector process result ( code ok int value ( ) , zk lock name , mock z k , zk lock name ) ; mockito verify ( mock app , mockito times ( 1 ) ) become active ( ) ; verify exist call ( 1 ) ; / / monitor callback verifies the leader is ephemeral owner of lock but does / / not call become active since its already active stat stat = new stat ( ) ; stat set ephemeral owner ( 1l ) ; mockito when ( mock z k get session id ( ) ) then return ( 1l ) ; elector process result ( code ok int value ( ) , zk lock name , mock z k , stat ) ; / / should not call neutral mode / standby / active mockito verify ( mock app , mockito times ( 0 ) ) enter neutral mode ( ) ; mockito verify ( mock app , mockito times ( 0 ) ) become standby ( ) ; mockito verify ( mock app , mockito times ( 1 ) ) become active ( ) ; / / another join election not called mockito verify ( mock z k , mockito times ( 1 ) ) create ( zk lock name , data , ids open acl unsafe , create mode ephemeral , elector , mock z k ) ; / / no new monitor called verify exist call ( 1 ) ; }


shuts { @ link simple drawee view } down

public static void shut down ( ) { s draweecontrollerbuildersupplier = null ; }


determine if a record exists with the specified value within the specified column the table must have been created with a secondary index on the specified column index

public boolean has record ( field field , int column index ) throws i o exception { synchronized ( db ) { index table index table = secondary indexes get ( column index ) ; if ( index table = = null ) { throw new i o exception ( " index required ( " + get name ( ) + " , " + column index + " ) " ) ; } return index table has record ( field ) ; } }


returns a path fragment from a given from - dir to a given to - path

public static path fragment relative path ( path fragment from dir , path fragment to ) { if ( to equals ( from dir ) ) { return path fragment empty fragment ; } if ( to starts with ( from dir ) ) { return to relative to ( from dir ) ; / / easy case - - it ' s a descendant } path fragment ancestor = common ancestor ( from dir , to ) ; if ( ancestor = = null ) { return to ; / / no common ancestor , use ' to ' } int levels = from dir relative to ( ancestor ) segment count ( ) ; string builder dotdots = new string builder ( ) ; for ( int i = 0 ; i < levels ; i + + ) { dotdots append ( " / " ) ; } return path fragment create ( dotdots to string ( ) ) get relative ( to relative to ( ancestor ) ) ; }


set the ( new ) value of the { @ code upgrade } header

public void set upgrade ( @ nullable string upgrade ) { set or remove ( upgrade , upgrade ) ; }


disconnects a task manager specified by the given resource i d from the { @ link resource manager }

void disconnect task manager ( resource i d resource i d , exception cause ) ;


java doesn ' t have multiline string literals , so having to join a bunch of lines is a very common problem so , here ' s a static method that we can static import in such situations

public static string join lines ( string lines ) { return newline joiner join ( lines ) ; }


see { @ link commit operations # abort multipart commit ( string , string ) }

public void abort multipart commit ( final string dest key , final string upload id ) throws i o exception { commit operations this abort multipart commit ( dest key , upload id ) ; }


the number of missing fields that had been configured for analysis

public long get missing field count ( ) { return missing field count ; }


implements equals for a map of string arrays the map of string arrays is used in some x pack protocol classes but does ' t work with equal

public static boolean equals ( map < string , string [ ] > a , map < string , string [ ] > b ) { if ( a = = null ) { return b = = null ; } if ( b = = null ) { return false ; } if ( a size ( ) ! = b size ( ) ) { return false ; } for ( map entry < string , string [ ] > entry : a entry set ( ) ) { string [ ] val = entry get value ( ) ; string key = entry get key ( ) ; if ( val = = null ) { if ( b get ( key ) ! = null | | b contains key ( key ) = = false ) { return false ; } } else { if ( arrays equals ( val , b get ( key ) ) = = false ) { return false ; } } } return true ; }


a reference to the xml attribute < code > optional aapt pb reference key = 3 ; < code >

private void set key ( com android aapt resources reference builder builder for value ) { key = builder for value build ( ) ; bit field 0 | = 0x 0 0 0 0 0 0 0 4 ; }


returns map from { @ link index } to index metadata generation

public map < index , long > get index generations ( ) { return index generations ; }


removes the value for the { @ link fragment options } with the given fragment options class

public builder remove fragment options ( class < ? extends fragment options > key ) { fragment options remove ( key ) ; return this ; }


returns the value of the current option , throwing an exception if the value is missing

public string get required value ( string value description ) throws options exception { if ( m last option value ! = null ) { string result = m last option value ; m last option value = null ; return result ; } if ( m index > = m params length ) { / / no more parameters left throw new options exception ( value description + " missing after " + m last option original form ) ; } string param = m params [ m index ] ; if ( " - - " equals ( param ) ) { / / end of options marker throw new options exception ( value description + " missing after " + m last option original form ) ; } m index + + ; return param ; }


protected object prim transform ( object an object ) throws exception { return format format ( ( big decimal ) an object ) ; }


generate an s 3 a file status instance , including etag and version id , if present

public s 3 a file status to s 3 a file status ( ) { return new s 3 a file status ( get path ( ) , is directory ( ) , is empty directory , get len ( ) , get modification time ( ) , get block size ( ) , get owner ( ) , get e tag ( ) , get version id ( ) ) ; }


find a class on the classpath , starting with a specific classloader ( or die trying )

public class < ? > class for name ( string name , class loader class loader ) throws class not found exception { return class for name ( name , get class loaders ( class loader ) ) ; }


returns true if restore process completed ( either successfully or with failure )

public boolean completed ( ) { return this = = success | | this = = failure ; }


handles failure to finalize a snapshot if the exception indicates that this node was unable to publish a cluster state and stopped being the master node , then fail all snapshot create and delete listeners executing on this node by delegating to { @ link # fail all listeners on master fail over } otherwise , i e as a result of failing to write to the snapshot repository for some reason , remove the snapshot ' s { @ link snapshots in progress entry } from the cluster state and move on with other queued snapshot operations if there are any

private void handle finalization failure ( exception e , snapshots in progress entry entry , repository data repository data ) { snapshot snapshot = entry snapshot ( ) ; if ( exceptions helper unwrap ( e , not master exception class , failed to commit cluster state exception class ) ! = null ) { / / failure due to not being master any more , don ' t try to remove snapshot from cluster state the next master / / will try ending this snapshot again logger debug ( ( ) - > new parameterized message ( " [ { } ] failed to update cluster state during snapshot finalization " , snapshot ) , e ) ; fail snapshot completion listeners ( snapshot , new snapshot exception ( snapshot , " failed to update cluster state during snapshot finalization " , e ) ) ; fail all listeners on master fail over ( e ) ; } else { logger warn ( ( ) - > new parameterized message ( " [ { } ] failed to finalize snapshot " , snapshot ) , e ) ; remove failed snapshot from cluster state ( snapshot , e , repository data ) ; } }


patch another - fakedummy : to test special tags to test special tags and operation id starting with number

default mono < response entity < client > > call 1 2 3test special tags ( mono < client > body , server web exchange exchange ) { mono < void > result = mono empty ( ) ; exchange get response ( ) set status code ( http status not implemented ) ; for ( media type media type : exchange get request ( ) get headers ( ) get accept ( ) ) { if ( media type is compatible with ( media type value of ( " application / json " ) ) ) { string example string = " { \ " client \ " : \ " client \ " } " ; result = api util get example response ( exchange , example string ) ; break ; } } return result then ( mono empty ( ) ) ; }


increments the element of this big array at specified index

public void increment ( long index ) { array [ segment ( index ) ] [ offset ( index ) ] + + ; }


< code > optional uint 3 2 type = 1 ; < code >

public int get type ( ) { return instance get type ( ) ; }


check if there are any recoveries pending in - sync

public boolean pending in sync ( ) { assert assert primary mode ( ) ; return replication tracker pending in sync ( ) ; }


make sure we have ' need ' elements from current position { @ link # p p } last valid { @ code p } index is { @ code data length - 1 } { @ code p + need - 1 } is the char index ' need ' elements ahead if we need 1 element , { @ code ( p + 1 - 1 ) = = p } must be less than { @ code data length }

protected void sync ( int want ) { int need = ( p + want - 1 ) - n + 1 ; / / how many more elements we need ? if ( need > 0 ) { fill ( need ) ; } }


alternative to { @ link # expect body list ( class ) } that accepts information about a target type with generics

< e > list body spec < e > expect body list ( parameterized type reference < e > element type ) ;


sets the require alias request flag on the destination index

public reindex request set require alias ( boolean require alias ) { this get destination ( ) set require alias ( require alias ) ; return this ; }


public user get user or null ( ) { return user get ( user , false , collections empty map ( ) ) ; }


formats time in ms and appends difference ( finish time - start time ) as returned by format time diff ( ) if finish time is 0 , empty string is returned , if start time is 0 then difference is not appended to return value

public static string get formatted time with diff ( string formatted finish time , long finish time , long start time ) { string builder buf = new string builder ( ) ; if ( 0 ! = finish time ) { buf append ( formatted finish time ) ; if ( 0 ! = start time ) { buf append ( " ( " + format time diff ( finish time , start time ) + " ) " ) ; } } return buf to string ( ) ; }


for cli connection that goes through http , sometimes you need to pass in the custom authentication header ( before jenkins even get to authenticate the cli channel ) this method lets you specify the value of this header

public c l i connection factory authorization ( string value ) { this authorization = value ; return this ; }


if somebody is unlucky enough to have to serialize one of these , serialize it as a linked hash map so that they won ' t need gson on the other side to deserialize it using serialization defeats our do s defence , so most apps shouldn ' t use it

private object write replace ( ) throws object stream exception { return new linked hash map < k , v > ( this ) ; }


manually run this to write binary snapshot data remove @ ignore to run

public void write reader snapshot ( ) throws exception { file test folder = temp folder new folder ( ) ; timestamped file input split split 1 = new timestamped file input split ( 0 , 3 , new path ( " test / test 1 " ) , 0 , 100 , null ) ; timestamped file input split split 2 = new timestamped file input split ( 10 , 2 , new path ( " test / test 2 " ) , 101 , 200 , null ) ; timestamped file input split split 3 = new timestamped file input split ( 10 , 1 , new path ( " test / test 2 " ) , 0 , 100 , null ) ; timestamped file input split split 4 = new timestamped file input split ( 11 , 0 , new path ( " test / test 3 " ) , 0 , 100 , null ) ; / / this always blocks to ensure that the reader doesn ' t to any actual processing so that / / we keep the state for the four splits final one shot latch blocking latch = new one shot latch ( ) ; blocking file input format format = new blocking file input format ( blocking latch , new path ( test folder get absolute path ( ) ) ) ; one input stream operator test harness < timestamped file input split , file input split > test harness = create harness ( format ) ; test harness set time characteristic ( time characteristic event time ) ; test harness open ( ) ; / / create some state in the reader test harness process element ( new stream record < > ( split 1 ) ) ; test harness process element ( new stream record < > ( split 2 ) ) ; test harness process element ( new stream record < > ( split 3 ) ) ; test harness process element ( new stream record < > ( split 4 ) ) ; / / take a snapshot of the operator ' s state this will be used / / to initialize another reader and compare the results of the / / two operators final operator subtask state snapshot ; synchronized ( test harness get checkpoint lock ( ) ) { snapshot = test harness snapshot ( 0l , 0l ) ; } operator snapshot util write state handle ( snapshot , " src / test / resources / reader - migration - test - flink " + flink generate savepoint version + " - snapshot " ) ; }


private < t > t [ ] sort ( t [ ] a ) { arrays sort ( a , new comparator < t > ( ) { public int compare ( t o 1 , t o 2 ) { return o 1 get class ( ) get name ( ) compare to ( o 2 get class ( ) get name ( ) ) ; } } ) ; return a ; }


test method refresh super user groups configuration this method present and it works

public void test refresh super user groups configuration ( ) throws exception { refresh super user groups configuration request request = record factory new record instance ( refresh super user groups configuration request class ) ; refresh super user groups configuration response response = client refresh super user groups configuration ( request ) ; assert not null ( response ) ; }


public void load ( ) throws i o exception { final file nodes dir = get nodes dir ( ) ; final file [ ] subdirs = nodes dir list files ( new file filter ( ) { public boolean accept ( file child ) { return child is directory ( ) ; } } ) ; final map < string , node > new nodes = new tree map < > ( ) ; if ( subdirs ! = null ) { for ( file subdir : subdirs ) { try { xml file xml file = new xml file ( jenkins xstream , new file ( subdir , " config xml " ) ) ; if ( xml file exists ( ) ) { node node = ( node ) xml file read ( ) ; new nodes put ( node get node name ( ) , node ) ; } } catch ( i o exception e ) { logger get logger ( nodes class get name ( ) ) log ( level warning , " could not load " + subdir , e ) ; } } } queue with lock ( new runnable ( ) { @ override public void run ( ) { nodes entry set ( ) remove if ( string node entry - > ! ( string node entry get value ( ) instanceof ephemeral node ) ) ; nodes put all ( new nodes ) ; jenkins update computer list ( ) ; jenkins trim labels ( ) ; } } ) ; }


notify any parent data types that my size has changed

protected void notify size changed ( ) { iterator < data type > it = parent list iterator ( ) ; while ( it has next ( ) ) { data type dt = it next ( ) ; dt data type size changed ( this ) ; } }


create a test filesystem which is always unguarded this filesystem must be closed in test teardown

private s 3 a file system create unguarded f s ( ) throws exception { s 3 a file system test f s = get file system ( ) ; configuration config = new configuration ( test f s get conf ( ) ) ; uri uri = test f s get uri ( ) ; remove base and bucket overrides ( uri get host ( ) , config , s3 metadata store impl , metadatastore authoritative , authoritative path ) ; s 3 a file system fs 2 = new s 3 a file system ( ) ; fs 2 initialize ( uri , config ) ; return fs 2 ; }


returns { @ code n } choose { @ code k } , also known as the binomial coefficient of { @ code n } and { @ code k } , or { @ link integer # max value } if the result does not fit in an { @ code int }

public static int binomial ( int n , int k ) { check non negative ( " n " , n ) ; check non negative ( " k " , k ) ; check argument ( k < = n , " k ( % s ) > n ( % s ) " , k , n ) ; if ( k > ( n > > 1 ) ) { k = n - k ; } if ( k > = biggest binomials length | | n > biggest binomials [ k ] ) { return integer max value ; } switch ( k ) { case 0 : return 1 ; case 1 : return n ; default : long result = 1 ; for ( int i = 0 ; i < k ; i + + ) { result * = n - i ; result / = i + 1 ; } return ( int ) result ; } }


returns an index that will always be associated to the given key as long as the key remains in the table if the key already exists , then the index where that key is stored is returned if the key is new , then a new index is allocated , the key is stored at that index , and the new index is returned

public short put ( short key ) { / / check if the key already exists short index = find key ( key ) ; / / if not , then we need to add it if ( index = = - 1 ) { / / make sure there is enough room if ( indexer get size ( ) > = capacity ) { / / if not enough room , grow the key capacity grow ( ) ; } / / now use the hashcode as the list i d and get a new index / / to put on that list then store the key at the new index short hashcode = ( short ) ( ( key & 0x 7fff ) % capacity ) ; index = indexer add ( hashcode ) ; if ( index < 0 ) { throw new index out of bounds exception ( " maximum capacity reached " ) ; } keys [ index ] = key ; } / / return the index associated with the given key return index ; }


calculates the approximate size of a text , depending on a demo text avoid repeated calls ( e g inside drawing methods )

public static void calc text size ( paint paint , string demo text , f size output f size ) { rect r = m calc text size rect ; r set ( 0 , 0 , 0 , 0 ) ; paint get text bounds ( demo text , 0 , demo text length ( ) , r ) ; output f size width = r width ( ) ; output f size height = r height ( ) ; }


test that if the % of timeouts is higher than the threshold that the circuit trips

public void test trip circuit on timeouts above threshold ( ) { string key = " cmd - e " ; try { hystrix command < boolean > cmd 1 = new success command ( key , 60 ) ; hystrix circuit breaker cb = cmd 1 circuit breaker ; / / this should start as allowing requests assert true ( cb allow request ( ) ) ; assert false ( cb is open ( ) ) ; / / success with high latency cmd 1 execute ( ) ; hystrix command < boolean > cmd 2 = new success command ( key , 1 ) ; cmd 2 execute ( ) ; hystrix command < boolean > cmd 3 = new timeout command ( key ) ; cmd 3 execute ( ) ; hystrix command < boolean > cmd 4 = new success command ( key , 1 ) ; cmd 4 execute ( ) ; hystrix command < boolean > cmd 5 = new timeout command ( key ) ; cmd 5 execute ( ) ; hystrix command < boolean > cmd 6 = new timeout command ( key ) ; cmd 6 execute ( ) ; hystrix command < boolean > cmd 7 = new success command ( key , 1 ) ; cmd 7 execute ( ) ; hystrix command < boolean > cmd 8 = new timeout command ( key ) ; cmd 8 execute ( ) ; hystrix command < boolean > cmd 9 = new timeout command ( key ) ; cmd 9 execute ( ) ; / / this should trip the circuit as the error percentage is above the threshold thread sleep ( 100 ) ; assert true ( cb is open ( ) ) ; } catch ( exception e ) { e print stack trace ( ) ; fail ( " error occurred : " + e get message ( ) ) ; } }


return the value of the first ( and maybe only ) text field

public string get value ( ) { return input values [ 0 ] ; }


public outer enum get outer enum ( ) { return outer enum ; }


public x pack info response info ( x pack info request request , request options options ) throws i o exception { return rest high level client perform request and parse entity ( request , x pack request converters : : info , options , x pack info response : : from x content , empty set ( ) ) ; }


public collection < action > get ( int from state , assembly symbol next ) { return map get ( new table entry key ( from state , next ) ) ; }


replaces the given instruction by an infinite loop

private void replace by infinite loop ( clazz clazz , int offset ) { if ( debug ) system out println ( " inserting infinite loop at [ " + offset + " ] " ) ; / / mark the instruction mark instruction ( offset ) ; / / replace the instruction by an infinite loop instruction replacement instruction = new branch instruction ( instruction constants op goto , 0 ) ; code attribute editor replace instruction ( offset , replacement instruction ) ; }


retrieves the { @ link transitive option details } containing data on this configuration ' s options

transitive option details get transitive option details ( ) { return transitive option details ; }


set the erasure coding policy for this entity ( default = null )

public builder ec policy ( erasure coding policy ec policy ) { this ec policy = ec policy ; return this ; }


returns the path up to the random directory component

private path get path to delete ( path local path ) { path del path = local path get parent ( ) ; string name = del path get name ( ) ; matcher matcher = random dir pattern matcher ( name ) ; if ( matcher matches ( ) ) { return del path ; } else { log warn ( " random directory component did not match " + " deleting localized path only " ) ; return local path ; } }


this method will use the thread to send packets added to the queued packets list

private void send packets ( ) throws interrupted exception { long trace mask = zoo trace server packet trace mask ; while ( true ) { try { quorum packet p ; p = queued packets poll ( ) ; if ( p = = null ) { buffered output flush ( ) ; p = queued packets take ( ) ; } server metrics get metrics ( ) learner handler qp size add ( long to string ( this sid ) , queued packets size ( ) ) ; if ( p instanceof marker quorum packet ) { marker quorum packet m = ( marker quorum packet ) p ; server metrics get metrics ( ) learner handler qp time add ( long to string ( this sid ) , ( system nano time ( ) - m time ) / 1000000l ) ; continue ; } queued packets size add and get ( - packet size ( p ) ) ; if ( p = = proposal of death ) { / / packet of death ! break ; } if ( p get type ( ) = = leader ping ) { trace mask = zoo trace server ping trace mask ; } if ( p get type ( ) = = leader proposal ) { sync limit check update proposal ( p get zxid ( ) , system nano time ( ) ) ; } if ( log is trace enabled ( ) ) { zoo trace log quorum packet ( log , trace mask , ' o ' , p ) ; } / / log the zxid of the last request , if it is a valid zxid if ( p get zxid ( ) > 0 ) { last zxid = p get zxid ( ) ; } oa write record ( p , " packet " ) ; packets sent increment and get ( ) ; message tracker track sent ( p get type ( ) ) ; } catch ( i o exception e ) { log error ( " exception while sending packets in learner handler " , e ) ; / / this will cause everything to shutdown on / / this learner handler and will help notify / / the learner / observer instantaneously close socket ( ) ; break ; } } }


destroy and then close ( ) a metastore instance exceptions are caught and logged at debug

private static void destroy ( final dynamo d b metadata store ddbms ) { if ( ddbms ! = null ) { try { ddbms destroy ( ) ; i o utils close stream ( ddbms ) ; } catch ( i o exception e ) { log debug ( " on ddbms shutdown " , e ) ; } } }


secure method for deleting the contents of a directory using { @ code secure directory stream } returns a collection of exceptions that occurred or null if no exceptions were thrown

private static @ nullable collection < i o exception > delete directory contents secure ( secure directory stream < path > dir ) { collection < i o exception > exceptions = null ; try { for ( path path : dir ) { exceptions = concat ( exceptions , delete recursively secure ( dir , path get file name ( ) ) ) ; } return exceptions ; } catch ( directory iterator exception e ) { return add exception ( exceptions , e get cause ( ) ) ; } }


public list < file > find n recent snapshots ( int n ) throws i o exception { file snap snaplog = new file snap ( snap dir ) ; return snaplog find n recent snapshots ( n ) ; }


adds a dependency on a skyframe - external event if the given future is already complete , this method silently returns without doing anything ( to avoid unnecessary function restarts ) otherwise , skyframe adds a listener to the passed - in future , and only re - enqueues the current node after the future completes and all requested deps are done the added listener will perform the minimum amount of work on the thread completing the future necessary for skyframe bookkeeping callers of this method must check { @ link # values missing } before returning { @ code null } from a { @ link sky function } this api is intended for performing async computations ( e g , remote execution ) in another thread pool without blocking the current skyframe thread

void depend on future ( listenable future < ? > future ) ;


public long get storage bytes read ( ) { return get conf ( ) get long ( storage bytes read , - 1 ) ; }


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


single - writer reset of completed counter

public void reset completed ( ) { / / we can avoid the full barrier cost of a volatile set given that / / the counter can be reset from a single thread and it should be reset / / only after any submitted tasks are completed done updater lazy set ( this , 0 ) ; }


computes and updates the steady shares of { @ link f s queue } s as per the { @ link scheduling policy } the steady share does not differentiate between queues with and without running applications under them the steady share is not used for scheduling , it is displayed on the web ui for better visibility

public abstract void compute steady shares ( collection < ? extends f s queue > queues , resource total resources ) ;


tests that we can correctly recognize multiple conflicts with both the tag merger and the tag listing merger in this case we do the following : 1 add tags a , b and c to both programs 2 rename a in latest , and delete b 3 rename a and c in my , and add b to a function 4 verify we have 2 conflicts ( the edit of a , and the add of a deleted tag - b , in my )

public void test multiple tag and listing conflicts ( ) throws exception { mtf initialize ( notepad , new original program modifier listener ( ) { @ override public void modify latest ( program d b program ) throws exception { int transaction i d = program start transaction ( " latest " ) ; try { edit tag name ( program , tag name a , tag name a latest ) ; delete tag ( program , tag name b ) ; } finally { program end transaction ( transaction i d , true ) ; } } @ override public void modify private ( program d b program ) throws exception { int transaction i d = program start transaction ( " my " ) ; try { edit tag name ( program , tag name a , tag name a my ) ; add tag to function ( tag name b , program , " 1 0 0 1 9 4b " ) ; } finally { program end transaction ( transaction i d , true ) ; } } @ override public void modify original ( program d b program ) throws exception { int transaction i d = program start transaction ( " original " ) ; try { function tag manager tag manager = get tag manager ( program ) ; tag manager create function tag ( tag name a , " " ) ; tag manager create function tag ( tag name b , " " ) ; tag manager create function tag ( tag name c , " " ) ; } finally { program end transaction ( transaction i d , true ) ; } } } ) ; execute merge ( ask user ) ; choose function tag button ( my button , true ) ; choose listing function tag button ( my button , addr ( " 1 0 0 1 9 4b " ) , false ) ; wait for merge completion ( ) ; assert true ( is tag in program ( tag name a my , mtf get result program ( ) ) ) ; assert true ( is tag in program ( tag name b , mtf get result program ( ) ) ) ; assert true ( is tag in program ( tag name c , mtf get result program ( ) ) ) ; assert true ( is tag in function ( tag name b , mtf get result program ( ) , " 1 0 0 1 9 4b " ) ) ; }


returns the string representing the type of this parameter with the link to the documentation for the type if available if the parameter type is object , then returns the empty string if the parameter type is not a generic , then this method returns a string representing the type name with a link to the documentation for the type if available if the parameter type is a generic , then this method returns a string " container of type " ( with html link markup )

public string get type ( ) { string builder sb = new string builder ( ) ; for ( int i = 0 ; i < param allowed types ( ) length ; i + + ) { param type param type = param allowed types ( ) [ i ] ; / / todo ( adonovan ) : make generic 1 an array if ( param type generic 1 ( ) = = object class ) { sb append ( get type anchor ( param type type ( ) ) ) ; } else { sb append ( get type anchor ( param type type ( ) , param type generic 1 ( ) ) ) ; } if ( i < param allowed types ( ) length - 1 ) { sb append ( " ; or " ) ; } } return sb to string ( ) ; }


gets a referenced repeatable comment as a ref repeat comment object

public string [ ] get referenced repeatable comments ( address ref address ) { object [ ] ref repeat array = display comment arrays [ ref repeatables ] ; for ( object element : ref repeat array ) { ref repeat comment ref repeat comment = ( ref repeat comment ) element ; if ( ref repeat comment get address ( ) equals ( ref address ) ) { return ref repeat comment get comment lines ( ) ; } } return null ; }


return true if the provided query contains a mandatory clauses ( must ) that doesn ' t track the maximum scores per block

static boolean has inf max score ( query query ) { max score query visitor visitor = new max score query visitor ( ) ; query visit ( visitor ) ; return visitor has inf max score ; }


configure a { @ code content negotiation manager } to help determine the media types for resources being served if the manager contains a path extension strategy it will be checked for registered file extension

public void set content negotiation manager ( @ nullable content negotiation manager content negotiation manager ) { this content negotiation manager = content negotiation manager ; }


test whether different data sources can share the same zk client when the connection parameters are the same

public void test zoo keeper data source same zk client ( ) throws exception { testing server server = new testing server ( 21813 ) ; server start ( ) ; final string remote address = server get connect string ( ) ; final string flow path = " / sentinel - zk - ds - demo / flow - hk " ; final string degrade path = " / sentinel - zk - ds - demo / degrade - hk " ; zookeeper data source < list < flow rule > > flow rule zk data source = new zookeeper data source < > ( remote address , flow path , new converter < string , list < flow rule > > ( ) { @ override public list < flow rule > convert ( string source ) { return json parse object ( source , new type reference < list < flow rule > > ( ) { } ) ; } } ) ; zookeeper data source < list < degrade rule > > degrade rule zk data source = new zookeeper data source < > ( remote address , degrade path , new converter < string , list < degrade rule > > ( ) { @ override public list < degrade rule > convert ( string source ) { return json parse object ( source , new type reference < list < degrade rule > > ( ) { } ) ; } } ) ; assert assert true ( flow rule zk data source get zk client ( ) = = degrade rule zk data source get zk client ( ) ) ; final string group id = " sentinel - zk - ds - demo " ; final string flow data id = " flow - hk " ; final string degrade data id = " degrade - hk " ; final string scheme = " digest " ; final string auth = " root : 123456 " ; auth info auth info = new auth info ( scheme , auth get bytes ( ) ) ; list < auth info > auth info list = collections singleton list ( auth info ) ; zookeeper data source < list < flow rule > > flow rule zk auto data source = new zookeeper data source < list < flow rule > > ( remote address , auth info list , group id , flow data id , new converter < string , list < flow rule > > ( ) { @ override public list < flow rule > convert ( string source ) { return json parse object ( source , new type reference < list < flow rule > > ( ) { } ) ; } } ) ; zookeeper data source < list < degrade rule > > degrade rule zk auto data source = new zookeeper data source < list < degrade rule > > ( remote address , auth info list , group id , degrade data id , new converter < string , list < degrade rule > > ( ) { @ override public list < degrade rule > convert ( string source ) { return json parse object ( source , new type reference < list < degrade rule > > ( ) { } ) ; } } ) ; assert assert true ( flow rule zk auto data source get zk client ( ) = = degrade rule zk auto data source get zk client ( ) ) ; server stop ( ) ; }


show that if the service failed during an init operation , stop was called

public void test stop failing init and stop ( ) throws throwable { breakable service svc = new breakable service ( true , false , true ) ; svc register service listener ( new logging state change listener ( ) ) ; try { svc init ( new configuration ( ) ) ; fail ( " expected a failure , got " + svc ) ; } catch ( breakable service broken lifecycle event e ) { assert equals ( service state inited , e state ) ; } / / the service state is stopped assert service state stopped ( svc ) ; assert equals ( service state inited , svc get failure state ( ) ) ; throwable failure cause = svc get failure cause ( ) ; assert not null ( " null failure cause in " + svc , failure cause ) ; breakable service broken lifecycle event cause = ( breakable service broken lifecycle event ) failure cause ; assert not null ( " null state in " + cause + " raised by " + svc , cause state ) ; assert equals ( service state inited , cause state ) ; }


public static < k > atomic long map < k > create ( ) { return new atomic long map < k > ( new concurrent hash map < k , atomic long > ( ) ) ; }


{ @ inherit doc } the default implementation returns the result of calling { @ link # visit children } on { @ code ctx }

@ override public t visit match query ( sql base parser match query context ctx ) { return visit children ( ctx ) ; }


make sure we are adjusting subscriber request ( ) for filtered items

public void with backpressure 2 ( ) throws interrupted exception { flowable < integer > w = flowable range ( 1 , flowable buffer size ( ) * 2 ) ; flowable < integer > f = w filter ( new predicate < integer > ( ) { @ override public boolean test ( integer t 1 ) { return t 1 > 100 ; } } ) ; final count down latch latch = new count down latch ( 1 ) ; final test subscriber < integer > ts = new test subscriber < integer > ( ) { @ override public void on complete ( ) { system out println ( " on complete " ) ; latch count down ( ) ; } @ override public void on error ( throwable e ) { e print stack trace ( ) ; latch count down ( ) ; } @ override public void on next ( integer t ) { system out println ( " received : " + t ) ; / / request more each time we receive request ( 1 ) ; } } ; / / this means it will only request 1 item and expect to receive more ts request ( 1 ) ; f subscribe ( ts ) ; / / this will wait forever unless operator take handles the request ( n ) on filtered items latch await ( ) ; }


read a long , 64 - bits like data input stream read long except little endian

public final long read long ( ) throws i o exception { dis read fully ( work , 0 , 8 ) ; return ( long ) ( work [ 7 ] ) < < 56 | / * long cast needed or shift done modulo 32 * / ( long ) ( work [ 6 ] & 0xff ) < < 48 | ( long ) ( work [ 5 ] & 0xff ) < < 40 | ( long ) ( work [ 4 ] & 0xff ) < < 32 | ( long ) ( work [ 3 ] & 0xff ) < < 24 | ( long ) ( work [ 2 ] & 0xff ) < < 16 | ( long ) ( work [ 1 ] & 0xff ) < < 8 | work [ 0 ] & 0xff ; }


extract dynamic index pattern string from index pattern string

string extract dynamic index pattern str ( string index ) { int start = index index of ( " { " ) ; int end = index last index of ( " } " ) ; return index substring ( start , end + 1 ) ; }


public status enum get status ( ) { return status ; }


grows the array the new array capacity will be the maximum of min capacity and twice the current capacity

private void adjust array sizes ( int size ) { if ( size < min size ) { size = min size ; } int len = math min ( size , starts length ) ; int [ ] new starts = new int [ size ] ; short [ ] new lengths = new short [ size ] ; system arraycopy ( starts , 0 , new starts , 0 , len ) ; system arraycopy ( lengths , 0 , new lengths , 0 , len ) ; starts = new starts ; lengths = new lengths ; }


tests the static { @ link blob client # upload files ( inet socket address , configuration , job i d , list ) } } helper

static void upload jar file ( blob server blob server , configuration blob client config ) throws exception { final file test file = file create temp file ( " testfile " , " dat " ) ; test file delete on exit ( ) ; prepare test file ( test file ) ; inet socket address server address = new inet socket address ( " localhost " , blob server get port ( ) ) ; upload jar file ( server address , blob client config , test file ) ; upload jar file ( server address , blob client config , test file ) ; }


stop searching long running searches can be stopped from another thread

public void stop searching ( ) { stop searching = true ; }


returns true if field num used workers is set ( has been assigned a value ) and false otherwise

public boolean is set num used workers ( ) { return isset bit vector get ( num used workers isset id ) ; }


set the value of the < code > name < code > property to a < code > double < code >

public void set double ( string name , double value ) { set ( name , double to string ( value ) ) ; }


schedule a read from some new source dn if some dn is corrupted or slow , this is called from the read iteration initially we may only have < code > min required sources < code > number of striped block reader if the position is at the end of target block , don ' t need to do real read , and return the array index of source dn , otherwise - 1

private int schedule new read ( bit set used , int reconstruct length , corrupted blocks corrupted blocks ) { striped block reader reader = null ; / / step 1 : initially we may only have < code > min required sources < / code > / / number of striped block reader , and there may be some source d ns we never / / read before , so will try to create striped block reader for one new source / / dn and try to read from it if found , go to step 3 int m = readers size ( ) ; int to read = 0 ; while ( reader = = null & & m < sources length ) { reader = create reader ( m , reconstructor get position in block ( ) ) ; readers add ( reader ) ; to read = get read length ( live indices [ m ] , reconstruct length ) ; if ( to read > 0 ) { if ( reader get block reader ( ) = = null ) { reader = null ; m + + ; } } else { used set ( m ) ; return m ; } } / / step 2 : if there is no new source dn we can use , try to find a source / / dn we ever read from but because some reason , e g , slow , it / / is not in the success dn list at the begin of this iteration , so / / we have not tried it in this iteration now we have a chance to / / revisit it again for ( int i = 0 ; reader = = null & & i < readers size ( ) ; i + + ) { if ( ! used get ( i ) ) { striped block reader striped reader = readers get ( i ) ; to read = get read length ( live indices [ i ] , reconstruct length ) ; if ( to read > 0 ) { striped reader close block reader ( ) ; striped reader reset block reader ( reconstructor get position in block ( ) ) ; if ( striped reader get block reader ( ) ! = null ) { striped reader get read buffer ( ) position ( 0 ) ; m = i ; reader = striped reader ; } } else { used set ( i ) ; striped reader get read buffer ( ) position ( 0 ) ; return i ; } } } / / step 3 : schedule if find a correct source dn and need to do real read if ( reader ! = null ) { callable < block read stats > read callable = reader read from block ( to read , corrupted blocks ) ; future < block read stats > f = read service submit ( read callable ) ; futures put ( f , m ) ; used set ( m ) ; } return - 1 ; }


use { @ link # get labels map ( ) } instead

public java util map < java lang string , java lang string > get labels ( ) { return get labels map ( ) ; }


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


creates a temporary directory which will be used for storing the unpacked database files

private static file create d b dir ( ) throws i o exception { file tmp dir = new file ( system get property ( " java io tmpdir " ) ) ; int tries = 0 ; while ( tries + + < 10 ) { file dir = new file ( tmp dir , tempdb dir prefix + get random string ( ) + tempdb dir ext ) ; if ( dir mkdir ( ) ) { return dir ; } } throw new i o exception ( " unable to create temporary database " ) ; }


handles { @ link state # expect marker byte } the byte determines which stream we will be using , and will set { @ link # selected stream }

private void parse marker byte ( int marker byte ) throws i o exception { if ( marker byte < 0 | | marker byte > byte max value ) { string msg = " illegal marker byte ( " + marker byte + " ) " ; throw new illegal argument exception ( msg ) ; } if ( marker byte > output streams length | | output streams [ marker byte ] = = null ) { throw new i o exception ( " stream " + marker byte + " not registered " ) ; } selected stream = output streams [ marker byte ] ; state = state expect size ; current size byte = 0 ; }


returns true if the two sets contain function tags with the same namecomment pairs

static boolean equivalent tag sets ( set < function tag > set a , set < function tag > set b ) { / / to do this easily , just convert the sets to sorted lists and use a equals call since / / function tag d b overrides the equals method to compare the internal name / comment , / / this will do the job / / / / note that the lists must be sorted first , which works since function tag d b is a / / comparable list < function tag > list a = new array list < > ( set a ) ; list < function tag > list b = new array list < > ( set b ) ; collections sort ( list a ) ; collections sort ( list b ) ; return list a equals ( list b ) ; }


inverse of { @ link # has visible drawable ( int ) }

public component assert does not have visible drawable ( @ drawable res int drawable res ) { assert that litho view ( ) does not have visible drawable ( drawable res ) ; return this ; }


returns the { @ link type } for a specific byte value as defined in the proxy protocol 1 5 spec if the byte value is not an official one , it will return { @ link type # other }

public static type type for byte value ( byte byte value ) { switch ( byte value ) { case 0x 0 1 : return pp2 type alpn ; case 0x 0 2 : return pp2 type authority ; case 0x 2 0 : return pp2 type ssl ; case 0x 2 1 : return pp2 type ssl version ; case 0x 2 2 : return pp2 type ssl cn ; case 0x 3 0 : return pp2 type netns ; default : return other ; } }


removes the specified element from this set if it is present more formally , removes an element < tt > e < tt > such that < tt > ( o = = null & nbsp ; ? & nbsp ; e = = null & nbsp ; : & nbsp ; o equals ( e ) ) < tt > , if this set contains such an element returns < tt > true < tt > if this set contained the element ( or equivalently , if this set changed as a result of the call ) ( this set will not contain the element once the call returns )

public boolean remove ( object o ) { return map remove ( o ) = = present ; }


this method has the same semantics as { @ link runnable # run ( ) }

protected abstract void do run ( ) throws exception ;


returns individual application cache directory ( for only image caching from image loader ) cache directory will be created on sd card ( " androiddata [ app package name ] cacheuil - images " ) if card is mounted and app has appropriate permission else - android defines cache directory on device ' s file system

public static file get individual cache directory ( context context , string cache dir ) { file app cache dir = get cache directory ( context ) ; file individual cache dir = new file ( app cache dir , cache dir ) ; if ( ! individual cache dir exists ( ) ) { if ( ! individual cache dir mkdir ( ) ) { individual cache dir = app cache dir ; } } return individual cache dir ; }


add a built path set map to the provided bundle

private static void add path set map to bundle ( map < string , map < string , string > > path set map , map < string , object > bundle ) { / / we previously built a mapping from path to path id and regular / / expression - see from operation for details sort it and add an / / index , and then add it to the objects that we ' re about to pass to / / the templates to process list < map entry < string , map < string , string > > > path set entry list = new array list ( path set map entry set ( ) ) ; collections sort ( path set entry list , new comparator < map entry < string , map < string , string > > > ( ) { public int compare ( map entry < string , map < string , string > > a , map entry < string , map < string , string > > b ) { return a get value ( ) get ( " path " ) compare to ( b get value ( ) get ( " path " ) ) ; } } ) ; list path set = new array list < map < string , string > > ( ) ; int index = 0 ; for ( map entry < string , map < string , string > > path set entry : path set entry list ) { map < string , string > path set entry value = path set entry get value ( ) ; path set entry value put ( " index " , integer to string ( index ) ) ; index + + ; path set add ( path set entry value ) ; } bundle put ( " path set " , path set ) ; }


public final void write ( final data output data output ) throws i o exception { worker id write ( data output ) ; hostname write ( data output ) ; ip add write ( data output ) ; }


returns the record number of the underlying type of this enum

public record number get underlying record number ( ) { return underlying record number ; }


public void file test ( ) { / / todo : test file }


get the list of { @ link resource } s allocated to the job

public final r l e sparse resource allocation get skyline list ( ) { return skyline list ; }


public void test get host ( ) { assertions assert equals ( " 127 0 0 1 " , parameter parser get host ( ) ) ; }


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

public boolean add ( e e ) { check not null ( e ) ; / / check before removing if ( max size = = 0 ) { return true ; } if ( size ( ) = = max size ) { delegate remove ( ) ; } delegate add ( e ) ; return true ; }


getter for the connection type ( based on url + user + password )

public int get connection type code ( ) { return connection type code ; }


public void add and override r r set ( resource request set request set ) throws yarn exception { if ( request set = = null ) { return ; } for ( resource request rr : request set get r rs ( ) ) { add and override r r ( rr ) ; } }


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


public mutable gauge int new gauge ( string name , string desc , int i val ) { return new gauge ( interns info ( name , desc ) , i val ) ; }


get the log aggregation directory suffix

public string get remote root log dir suffix ( ) { return this remote root log dir suffix ; }


inserts the pixmap if name was not null , you can later retrieve the image ' s position in the output image via { @ link # get rect ( string ) }

public synchronized rectangle pack ( string name , pixmap image ) { if ( disposed ) return null ; if ( name ! = null & & get rect ( name ) ! = null ) throw new gdx runtime exception ( " pixmap has already been packed with name : " + name ) ; pixmap packer rectangle rect ; pixmap pixmap to dispose = null ; if ( name ! = null & & name ends with ( " 9 " ) ) { rect = new pixmap packer rectangle ( 0 , 0 , image get width ( ) - 2 , image get height ( ) - 2 ) ; pixmap to dispose = new pixmap ( image get width ( ) - 2 , image get height ( ) - 2 , image get format ( ) ) ; pixmap to dispose set blending ( blending none ) ; rect splits = get splits ( image ) ; rect pads = get pads ( image , rect splits ) ; pixmap to dispose draw pixmap ( image , 0 , 0 , 1 , 1 , image get width ( ) - 1 , image get height ( ) - 1 ) ; image = pixmap to dispose ; name = name split ( " \ \ " ) [ 0 ] ; } else { if ( strip whitespace x | | strip whitespace y ) { int original width = image get width ( ) ; int original height = image get height ( ) ; / / strip whitespace , manipulate the pixmap and return corrected rect int top = 0 ; int bottom = image get height ( ) ; if ( strip whitespace y ) { outer : for ( int y = 0 ; y < image get height ( ) ; y + + ) { for ( int x = 0 ; x < image get width ( ) ; x + + ) { int pixel = image get pixel ( x , y ) ; int alpha = ( ( pixel & 0x 0 0 0 0 0 0ff ) ) ; if ( alpha > alpha threshold ) break outer ; } top + + ; } outer : for ( int y = image get height ( ) ; - - y > = top ; ) { for ( int x = 0 ; x < image get width ( ) ; x + + ) { int pixel = image get pixel ( x , y ) ; int alpha = ( ( pixel & 0x 0 0 0 0 0 0ff ) ) ; if ( alpha > alpha threshold ) break outer ; } bottom - - ; } } int left = 0 ; int right = image get width ( ) ; if ( strip whitespace x ) { outer : for ( int x = 0 ; x < image get width ( ) ; x + + ) { for ( int y = top ; y < bottom ; y + + ) { int pixel = image get pixel ( x , y ) ; int alpha = ( ( pixel & 0x 0 0 0 0 0 0ff ) ) ; if ( alpha > alpha threshold ) break outer ; } left + + ; } outer : for ( int x = image get width ( ) ; - - x > = left ; ) { for ( int y = top ; y < bottom ; y + + ) { int pixel = image get pixel ( x , y ) ; int alpha = ( ( pixel & 0x 0 0 0 0 0 0ff ) ) ; if ( alpha > alpha threshold ) break outer ; } right - - ; } } int new width = right - left ; int new height = bottom - top ; pixmap to dispose = new pixmap ( new width , new height , image get format ( ) ) ; pixmap to dispose set blending ( blending none ) ; pixmap to dispose draw pixmap ( image , 0 , 0 , left , top , new width , new height ) ; image = pixmap to dispose ; rect = new pixmap packer rectangle ( 0 , 0 , new width , new height , left , top , original width , original height ) ; } else { rect = new pixmap packer rectangle ( 0 , 0 , image get width ( ) , image get height ( ) ) ; } } if ( rect get width ( ) > page width | | rect get height ( ) > page height ) { if ( name = = null ) throw new gdx runtime exception ( " page size too small for pixmap " ) ; throw new gdx runtime exception ( " page size too small for pixmap : " + name ) ; } page page = pack strategy pack ( this , name , rect ) ; if ( name ! = null ) { page rects put ( name , rect ) ; page added rects add ( name ) ; } int rect x = ( int ) rect x , rect y = ( int ) rect y , rect width = ( int ) rect width , rect height = ( int ) rect height ; if ( pack to texture & & ! duplicate border & & page texture ! = null & & ! page dirty ) { page texture bind ( ) ; gdx gl gl tex sub image 2 d ( page texture gl target , 0 , rect x , rect y , rect width , rect height , image get g l format ( ) , image get g l type ( ) , image get pixels ( ) ) ; } else page dirty = true ; page image draw pixmap ( image , rect x , rect y ) ; if ( duplicate border ) { int image width = image get width ( ) , image height = image get height ( ) ; / / copy corner pixels to fill corners of the padding page image draw pixmap ( image , 0 , 0 , 1 , 1 , rect x - 1 , rect y - 1 , 1 , 1 ) ; page image draw pixmap ( image , image width - 1 , 0 , 1 , 1 , rect x + rect width , rect y - 1 , 1 , 1 ) ; page image draw pixmap ( image , 0 , image height - 1 , 1 , 1 , rect x - 1 , rect y + rect height , 1 , 1 ) ; page image draw pixmap ( image , image width - 1 , image height - 1 , 1 , 1 , rect x + rect width , rect y + rect height , 1 , 1 ) ; / / copy edge pixels into padding page image draw pixmap ( image , 0 , 0 , image width , 1 , rect x , rect y - 1 , rect width , 1 ) ; page image draw pixmap ( image , 0 , image height - 1 , image width , 1 , rect x , rect y + rect height , rect width , 1 ) ; page image draw pixmap ( image , 0 , 0 , 1 , image height , rect x - 1 , rect y , 1 , rect height ) ; page image draw pixmap ( image , image width - 1 , 0 , 1 , image height , rect x + rect width , rect y , 1 , rect height ) ; } if ( pixmap to dispose ! = null ) { pixmap to dispose dispose ( ) ; } return rect ; }


get the configuration constructed from the command line arguments

public final configuration get configuration ( ) { return configuration ; }


simulate a block and note the results in the lattice

private void simulate block ( ssa basic block block ) { for ( ssa insn insn : block get insns ( ) ) { if ( insn instanceof phi insn ) { simulate phi ( ( phi insn ) insn ) ; } else { simulate stmt ( insn ) ; } } }


returns an instance that is identical to this one , except that the type bearer is replaced by the actual underlying type ( thereby stripping off non - type information ) with any initialization information stripped away as well

public register spec with simple type ( ) { type bearer orig = type ; type new type ; if ( orig instanceof type ) { new type = ( type ) orig ; } else { new type = orig get type ( ) ; } if ( new type is uninitialized ( ) ) { new type = new type get initialized type ( ) ; } if ( new type = = orig ) { return this ; } return make local optional ( reg , new type , local ) ; }


called when done processing response to signal more data is needed

void done ( time value extra keep alive ) ;


public int get slot idx ( ) { return ints checked cast ( ( slot address - base address ) / bytes per slot ) ; }


add set storage policy id record to edit log

void log set storage policy ( string src , byte policy id ) { set storage policy op op = set storage policy op get instance ( cache get ( ) ) set path ( src ) set policy id ( policy id ) ; log edit ( op ) ; }


a convenience method to directly run a { @ link monitored runnable } in a separate thread as a { @ link task } , displaying a non - modal progress dialog < code > task launcher launch non modal ( " my task " , < br > & nbsp ; & nbsp ; null , parent < br > & nbsp ; & nbsp ; monitor - & gt ; { while ( ! monitor is canceled ( ) ) { long running work ( ) ; } } < br > ) ; < code > note : the task created by this call will be both cancellable and have progress if you task cannot be cancelled or does not have progress , then do not use this convenience method , but rather call one of the constructors of this class see < a href = " # modal usage " > notes on non - modal usage

public static void launch non modal ( string title , monitored runnable runnable ) { new task launcher ( new task ( title , true , true , false ) { @ override public void run ( task monitor monitor ) { runnable monitored run ( monitor ) ; } } , null , initial delay ms ) ; }


obtain the { @ link connection factory } for actual use

private connection factory obtain connection factory ( ) { return this connection factory ; }


reinitialize the events happened and return the number of events stored since last execution of this method used to send via telemetry the events and restart the events store

/ * package * / synchronized @ non null concurrent hash map < list < stack trace element > , missing class event > get events and clean ( ) { concurrent hash map < list < stack trace element > , missing class event > current events = events ; events = new concurrent hash map < > ( max events per send ) ; return current events ; }


return the byte that { @ code n } stores , or throws an exception if the stored value cannot be converted to a byte that stores the exact same value

public static byte to byte exact ( number n ) { long l = to long exact ( n ) ; if ( l ! = ( byte ) l ) { throw new arithmetic exception ( " byte overflow : " + l ) ; } return ( byte ) l ; }


locate a constructor on the type there are three kinds of match that might occur : an exact match where the types of the arguments match the types of the constructor an in - exact match where the types we are looking for are subtypes of those defined on the constructor a match where we are able to convert the arguments into those expected by the constructor , according to the registered type converter

public constructor executor resolve ( evaluation context context , string type name , list < type descriptor > argument types ) throws access exception { try { type converter type converter = context get type converter ( ) ; class < ? > type = context get type locator ( ) find type ( type name ) ; constructor < ? > [ ] ctors = type get constructors ( ) ; arrays sort ( ctors , ( c 1 , c 2 ) - > { int c 1pl = c 1 get parameter count ( ) ; int c 2pl = c 2 get parameter count ( ) ; return integer compare ( c 1pl , c 2pl ) ; } ) ; constructor < ? > close match = null ; constructor < ? > match requiring conversion = null ; for ( constructor < ? > ctor : ctors ) { int param count = ctor get parameter count ( ) ; list < type descriptor > param descriptors = new array list < > ( param count ) ; for ( int i = 0 ; i < param count ; i + + ) { param descriptors add ( new type descriptor ( new method parameter ( ctor , i ) ) ) ; } reflection helper arguments match info match info = null ; if ( ctor is var args ( ) & & argument types size ( ) > = param count - 1 ) { / / * sigh * complicated / / basically we have to have all parameters match up until the varargs one , then the rest of what is / / being provided should be / / the same type whilst the final argument to the method must be an array of that ( oh , how easy not ) - / / or the final parameter / / we are supplied does match exactly ( it is an array already ) match info = reflection helper compare arguments varargs ( param descriptors , argument types , type converter ) ; } else if ( param count = = argument types size ( ) ) { / / worth a closer look match info = reflection helper compare arguments ( param descriptors , argument types , type converter ) ; } if ( match info ! = null ) { if ( match info is exact match ( ) ) { return new reflective constructor executor ( ctor ) ; } else if ( match info is close match ( ) ) { close match = ctor ; } else if ( match info is match requiring conversion ( ) ) { match requiring conversion = ctor ; } } } if ( close match ! = null ) { return new reflective constructor executor ( close match ) ; } else if ( match requiring conversion ! = null ) { return new reflective constructor executor ( match requiring conversion ) ; } else { return null ; } } catch ( evaluation exception ex ) { throw new access exception ( " failed to resolve constructor " , ex ) ; } }


called to allow plugins to initialize themselves this method is called after { @ link # set servlet context ( servlet context ) } is invoked you can also use { @ link jenkins model jenkins # get instance ( ) } to access the singleton hudson instance , although the plugin start up happens relatively early in the initialization stage and not all the data are loaded in hudson if a plugin wants to run an initialization step after all plugins and extension points are registered , a good place to do that is { @ link # post initialize ( ) } if a plugin wants to run an initialization step after all the jobs are loaded , { @ link item listener # on loaded ( ) } is a good place

public void start ( ) throws exception { }


returns the recovery change set data file for reading or null if one is not available the caller must dispose of the returned file before peforming generating any new recovery snapshots

public local buffer file get recovery change set file ( ) throws i o exception { return buffer mgr get recovery change set file ( ) ; }


increment the per - policy snapshot taken count for the given policy id

public void snapshot taken ( string slm policy ) { this policy stats compute if absent ( slm policy , snapshot policy stats : : new ) snapshot taken ( ) ; }