idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
9,300
public static br_broker force_reboot ( nitro_service client , br_broker resource ) throws Exception { return ( ( br_broker [ ] ) resource . perform_operation ( client , "force_reboot" ) ) [ 0 ] ; }
Use this operation to force reboot Unified Repeater Instance .
9,301
public static br_broker force_stop ( nitro_service client , br_broker resource ) throws Exception { return ( ( br_broker [ ] ) resource . perform_operation ( client , "force_stop" ) ) [ 0 ] ; }
Use this operation to force stop Unified Repeater Instance .
9,302
public static br_broker start ( nitro_service client , br_broker resource ) throws Exception { return ( ( br_broker [ ] ) resource . perform_operation ( client , "start" ) ) [ 0 ] ; }
Use this operation to start Unified Repeater Instance .
9,303
public void visit ( Visitable visitable ) { if ( isCommitable ( visitable ) ) { ObjectUtils . setField ( visitable , "lastModifiedBy" , ( ( Auditable ) visitable ) . getModifiedBy ( ) ) ; ObjectUtils . setField ( visitable , "lastModifiedOn" , ( ( Auditable ) visitable ) . getModifiedOn ( ) ) ; ObjectUtils . setField ( visitable , "lastModifiedWith" , ( ( Auditable ) visitable ) . getModifiedWith ( ) ) ; } }
Visits all objects in an application domain object graph hierarchy targeting objects to be committed .
9,304
protected boolean isCommitable ( Object visitable ) { return ( visitable instanceof Auditable && ( target == null || identity ( visitable ) == identity ( target ) ) ) ; }
Determines whether the specified visitable object is commit - able . The object is commit - able if the object is Auditable and this Visitor is not targeting a specific object in the application domain object graph hierarchy .
9,305
@ TargetApi ( Build . VERSION_CODES . GINGERBREAD ) public void apply ( ) { if ( editing == null ) { return ; } try { editing . apply ( ) ; } catch ( Exception ex ) { editing . commit ( ) ; } editing = null ; }
Call to apply changes .
9,306
public boolean commit ( ) { if ( editing == null ) { return false ; } final boolean result = editing . commit ( ) ; editing = null ; return result ; }
Call to commit changes .
9,307
public static sdxtools_image [ ] get_filtered ( nitro_service service , filtervalue [ ] filter ) throws Exception { sdxtools_image obj = new sdxtools_image ( ) ; options option = new options ( ) ; option . set_filter ( filter ) ; sdxtools_image [ ] response = ( sdxtools_image [ ] ) obj . getfiltered ( service , option ) ; return response ; }
Use this API to fetch filtered set of sdxtools_image resources . set the filter parameter values in filtervalue object .
9,308
public static synchronized void set ( final ObjectFactory objectFactory ) { Assert . state ( objectFactoryReference == null , "The ObjectFactory reference is already set to ({0})" , objectFactoryReference ) ; objectFactoryReference = objectFactory ; }
Sets a reference to the ObjectFactory used by the application in this holder .
9,309
public static ns_ns_runningconfig get ( nitro_service client , ns_ns_runningconfig resource ) throws Exception { resource . validate ( "get" ) ; return ( ( ns_ns_runningconfig [ ] ) resource . get_resources ( client ) ) [ 0 ] ; }
Use this operation to get running configuration from NetScaler Instance .
9,310
protected void setUp ( ) throws SQLException { Connection connection = getConnection ( ) ; try { if ( ! isSetUp ( connection ) ) { Statement stmt = connection . createStatement ( ) ; stmt . execute ( Query . CREATE_TABLE_RECORDS ) ; stmt . execute ( Query . CREATE_TABLE_FILEHASHES ) ; stmt . execute ( Query . CREATE_TABLE_META ) ; stmt . execute ( Query . CREATE_TABLE_CVES ) ; stmt . close ( ) ; } } finally { connection . close ( ) ; } }
Initializes a database by created required tables .
9,311
protected PreparedStatement statement ( Connection connection , String query ) throws SQLException { return connection . prepareStatement ( query ) ; }
Wrapper to create a prepared statement .
9,312
protected PreparedStatement setObjects ( Connection connection , String query , Object ... objects ) throws SQLException { PreparedStatement ps = statement ( connection , query ) ; setObjects ( ps , objects ) ; return ps ; }
Give a query and list of objects to set a prepared statement is created cached and returned with the objects set in the order they are provided .
9,313
protected int selectRecordId ( String hash ) throws SQLException { int id = - 1 ; Connection connection = getConnection ( ) ; try { PreparedStatement ps = setObjects ( connection , Query . GET_RECORD_ID , hash ) ; ResultSet rs = ps . executeQuery ( ) ; try { while ( rs . next ( ) ) { id = rs . getInt ( "id" ) ; break ; } } finally { rs . close ( ) ; ps . close ( ) ; } } finally { connection . close ( ) ; } return id ; }
Given a hash get the first occurance s record id .
9,314
protected int insertRecord ( Connection connection , String hash ) throws SQLException { int id = - 1 ; PreparedStatement ps = setObjects ( connection , Query . INSERT_RECORD , hash ) ; ps . execute ( ) ; ResultSet rs = ps . getGeneratedKeys ( ) ; try { while ( rs . next ( ) ) { id = rs . getInt ( 1 ) ; break ; } } finally { rs . close ( ) ; ps . close ( ) ; } return id ; }
Insert a new record with the given hash and return the record id .
9,315
protected void deleteRecord ( Connection connection , String hash ) throws SQLException { int id = selectRecordId ( hash ) ; if ( id > 0 ) { String [ ] queries = new String [ ] { Query . DELETE_FILEHASHES , Query . DELETE_METAS , Query . DELETE_CVES , Query . DELETE_RECORD_ID } ; for ( String query : queries ) { PreparedStatement ps = setObjects ( connection , query , id ) ; ps . execute ( ) ; ps . close ( ) ; } } }
Remove records matching a given hash . This will cascade to all references .
9,316
protected VALUE withCaching ( KEY key , Supplier < VALUE > cacheLoader ) { return getCache ( ) . map ( CachingTemplate :: with ) . < VALUE > map ( template -> template . withCaching ( key , ( ) -> { setCacheMiss ( ) ; return cacheLoader . get ( ) ; } ) ) . orElseGet ( cacheLoader ) ; }
Enables an application service method to optionally apply and use caching to carry out its function .
9,317
public static xen_websensevpx_image [ ] get_filtered ( nitro_service service , filtervalue [ ] filter ) throws Exception { xen_websensevpx_image obj = new xen_websensevpx_image ( ) ; options option = new options ( ) ; option . set_filter ( filter ) ; xen_websensevpx_image [ ] response = ( xen_websensevpx_image [ ] ) obj . getfiltered ( service , option ) ; return response ; }
Use this API to fetch filtered set of xen_websensevpx_image resources . set the filter parameter values in filtervalue object .
9,318
public int compare ( final Ordered ordered1 , final Ordered ordered2 ) { return ( ordered1 . getIndex ( ) < ordered2 . getIndex ( ) ? - 1 : ( ordered1 . getIndex ( ) > ordered2 . getIndex ( ) ? 1 : 0 ) ) ; }
Compares two Ordered objects to determine their relative order by index .
9,319
private static boolean safeSleep ( long milliseconds ) { boolean interrupted = false ; long timeout = ( System . currentTimeMillis ( ) + milliseconds ) ; while ( System . currentTimeMillis ( ) < timeout ) { try { Thread . sleep ( milliseconds ) ; } catch ( InterruptedException cause ) { interrupted = true ; } finally { milliseconds = Math . min ( timeout - System . currentTimeMillis ( ) , 0 ) ; } } if ( interrupted ) { Thread . currentThread ( ) . interrupt ( ) ; } return ! Thread . currentThread ( ) . isInterrupted ( ) ; }
Safely sleeps for the given amount of milliseconds .
9,320
public void accumulate ( List < ? extends StandardMetricResult > metricValues ) { if ( metricValues == null || metricValues . isEmpty ( ) ) return ; for ( StandardMetricResult v : metricValues ) { if ( lastOffset < v . offset ) values . put ( v . value . intValue ( ) ) ; } lastOffset = ListUtils . last ( metricValues ) . offset ; }
Adds a metric value to the metric value queue .
9,321
public boolean isExceeded ( ) { lastAggregatedValue = getAggregatedValue ( ) ; lastExceededValue = false ; switch ( operator ) { case lessThan : lastExceededValue = ( lastAggregatedValue < thresholdValue ) ; break ; case greaterThan : lastExceededValue = ( lastAggregatedValue > thresholdValue ) ; break ; } return lastExceededValue ; }
Returns true of this threshold has been exceeded .
9,322
public String getReason ( ) { if ( lastExceededValue ) { return String . format ( "Metric '%s' has aggregated-value=%d %s %d as threshold" , metric . name ( ) , lastAggregatedValue , operator . symbol , thresholdValue ) ; } else { return String . format ( "Metric %s: aggregated-value=%d" , metric . name ( ) , lastAggregatedValue ) ; } }
Returns summary intended for logging .
9,323
public static ns_ssl_certkey_policy get ( nitro_service client ) throws Exception { ns_ssl_certkey_policy resource = new ns_ssl_certkey_policy ( ) ; resource . validate ( "get" ) ; return ( ( ns_ssl_certkey_policy [ ] ) resource . get_resources ( client ) ) [ 0 ] ; }
Use this operation to get the polling frequency of the NetScaler SSL certificates .
9,324
public static < T , E extends Throwable > Consumer < T > rethrowConsumer ( final ThrowingConsumer < T , E > consumer ) { return consumer ; }
Returns the same throwing consumer .
9,325
public static < T , U , E extends Throwable > BiConsumer < T , U > rethrowBiConsumer ( final ThrowingBiConsumer < T , U , E > consumer ) { return consumer ; }
Returns the same throwing bi - consumer .
9,326
public static < T , R , E extends Throwable > Function < T , R > rethrowFunction ( final ThrowingFunction < T , R , E > function ) { return function ; }
Returns the same throwing function .
9,327
public static < T , U , R , E extends Throwable > BiFunction < T , U , R > rethrowBiFunction ( final ThrowingBiFunction < T , U , R , E > function ) { return function ; }
Returns the same throwing bi - function .
9,328
public static < T , E extends Throwable > Predicate < T > rethrowPredicate ( final ThrowingPredicate < T , E > predicate ) { return predicate ; }
Returns the same throwing predicate .
9,329
public static < E extends Throwable > Runnable rethrowRunnable ( final ThrowingRunnable < E > runnable ) { return runnable ; }
Runs a throwable and sneakily re - throws any exceptions it encounters .
9,330
public static < T , E extends Throwable > Supplier < T > rethrowSupplier ( final ThrowingSupplier < T , E > supplier ) { return supplier ; }
Returns the same throwing supplier .
9,331
public static < E extends Throwable > RuntimeException rethrow ( final Throwable exception ) throws E { throw ( E ) exception ; }
Re - throws an exception sneakily .
9,332
public static Throwable unwrap ( final Throwable throwable ) { if ( throwable instanceof InvocationTargetException ) { final Throwable cause = throwable . getCause ( ) ; if ( cause != null ) { return cause ; } } return throwable ; }
Unwraps a throwable .
9,333
public static ns_ns_savedconfig get ( nitro_service client , ns_ns_savedconfig resource ) throws Exception { resource . validate ( "get" ) ; return ( ( ns_ns_savedconfig [ ] ) resource . get_resources ( client ) ) [ 0 ] ; }
Use this operation to get saved configuration from NetScaler Instance .
9,334
protected void create ( File cache ) throws VictimsException { try { FileUtils . forceMkdir ( cache ) ; } catch ( IOException e ) { throw new VictimsException ( "Could not create an on disk cache" , e ) ; } }
Create the parent caching directory .
9,335
public void purge ( ) throws VictimsException { try { File cache = new File ( location ) ; if ( cache . exists ( ) ) { FileUtils . deleteDirectory ( cache ) ; } create ( cache ) ; } catch ( IOException e ) { throw new VictimsException ( "Could not purge on disk cache." , e ) ; } }
Purge the cache . The cache directory is removed and re - recreated .
9,336
protected String hash ( String key ) throws VictimsException { try { MessageDigest mda = MessageDigest . getInstance ( MessageDigestAlgorithms . SHA_256 ) ; return Hex . encodeHexString ( mda . digest ( key . getBytes ( ) ) ) ; } catch ( NoSuchAlgorithmException e ) { throw new VictimsException ( String . format ( "Could not hash key: %s" , key ) , e ) ; } }
The hashing function used by the Cache .
9,337
public boolean exists ( String key ) { try { key = hash ( key ) ; return FileUtils . getFile ( location , key ) . exists ( ) ; } catch ( VictimsException e ) { return false ; } }
Test if the given key is cached .
9,338
public void delete ( String key ) throws VictimsException { key = hash ( key ) ; try { FileUtils . forceDelete ( FileUtils . getFile ( location , key ) ) ; } catch ( IOException e ) { throw new VictimsException ( String . format ( "Could not delete the cached entry from disk: %s" , key ) , e ) ; } }
Delete the cache entry for a given key .
9,339
public void add ( String key , Collection < String > cves ) throws VictimsException { key = hash ( key ) ; if ( exists ( key ) ) { delete ( key ) ; } String result = "" ; if ( cves != null ) { result = StringUtils . join ( cves , "," ) ; } try { FileOutputStream fos = new FileOutputStream ( FileUtils . getFile ( location , key ) ) ; try { fos . write ( result . getBytes ( ) ) ; } finally { fos . close ( ) ; } } catch ( IOException e ) { throw new VictimsException ( String . format ( "Could not add disk entry for key: %s" , key ) , e ) ; } }
Add a new cache entry .
9,340
public HashSet < String > get ( String key ) throws VictimsException { key = hash ( key ) ; try { HashSet < String > cves = new HashSet < String > ( ) ; String result = FileUtils . readFileToString ( FileUtils . getFile ( location , key ) ) . trim ( ) ; for ( String cve : StringUtils . split ( result , "," ) ) { cves . add ( cve ) ; } return cves ; } catch ( IOException e ) { throw new VictimsException ( String . format ( "Could not read contents of entry with key: %s" , key ) , e ) ; } }
Get the CVEs mapped by a key
9,341
public final static byte [ ] decode ( byte [ ] sArr ) { int sLen = sArr . length ; int sepCnt = 0 ; for ( int i = 0 ; i < sLen ; i ++ ) { if ( IA [ sArr [ i ] & 0xff ] < 0 ) { sepCnt ++ ; } } if ( ( sLen - sepCnt ) % 4 != 0 ) { return null ; } int pad = 0 ; for ( int i = sLen ; i > 1 && IA [ sArr [ -- i ] & 0xff ] <= 0 ; ) { if ( sArr [ i ] == '=' ) { pad ++ ; } } int len = ( ( sLen - sepCnt ) * 6 >> 3 ) - pad ; byte [ ] dArr = new byte [ len ] ; for ( int s = 0 , d = 0 ; d < len ; ) { int i = 0 ; for ( int j = 0 ; j < 4 ; j ++ ) { int c = IA [ sArr [ s ++ ] & 0xff ] ; if ( c >= 0 ) { i |= c << ( 18 - j * 6 ) ; } else { j -- ; } } dArr [ d ++ ] = ( byte ) ( i >> 16 ) ; if ( d < len ) { dArr [ d ++ ] = ( byte ) ( i >> 8 ) ; if ( d < len ) { dArr [ d ++ ] = ( byte ) i ; } } } return dArr ; }
Decodes a BASE64 encoded byte array . All illegal characters will be ignored and can handle both arrays with and without line separators .
9,342
public < E > List < E > sort ( final List < E > elements ) { for ( int index = 0 , size = elements . size ( ) , length = ( size - 1 ) ; index < length ; index ++ ) { int minIndex = index ; for ( int j = ( index + 1 ) ; j < size ; j ++ ) { if ( getOrderBy ( ) . compare ( elements . get ( j ) , elements . get ( minIndex ) ) < 0 ) { minIndex = j ; } } if ( minIndex != index ) { swap ( elements , minIndex , index ) ; } } return elements ; }
Uses the Selection Sort algorithm to sort a List of elements as defined by the Comparator or as determined by the elements in the collection if the elements are Comparable .
9,343
public static backup_policy get ( nitro_service client , backup_policy resource ) throws Exception { resource . validate ( "get" ) ; return ( ( backup_policy [ ] ) resource . get_resources ( client ) ) [ 0 ] ; }
Use this operation to get backup policy to view the number of previous backups to retain .
9,344
public static synchronized void registerFieldsToFilter ( Class < ? > containingClass , String ... fieldNames ) { fieldFilterMap = registerFilter ( fieldFilterMap , containingClass , fieldNames ) ; }
fieldNames must contain only interned Strings
9,345
public static synchronized void registerMethodsToFilter ( Class < ? > containingClass , String ... methodNames ) { methodFilterMap = registerFilter ( methodFilterMap , containingClass , methodNames ) ; }
methodNames must contain only interned Strings
9,346
public static Calendar create ( long timeInMilliseconds ) { Calendar dateTime = Calendar . getInstance ( ) ; dateTime . clear ( ) ; dateTime . setTimeInMillis ( timeInMilliseconds ) ; return dateTime ; }
Creates a Calendar instance with a date and time set to the time in milliseconds .
9,347
public void execute ( ChannelQueryListener listener ) { addChannelQueryListener ( listener ) ; Result localResult = result ; if ( localResult != null ) { listener . queryExecuted ( localResult ) ; } else { execute ( ) ; } }
Executes the query and calls the listener with the result . If the query was already executed the listener is called immediately with the result .
9,348
public static current_timezone get ( nitro_service client ) throws Exception { current_timezone resource = new current_timezone ( ) ; resource . validate ( "get" ) ; return ( ( current_timezone [ ] ) resource . get_resources ( client ) ) [ 0 ] ; }
Use this operation to get the current time zone .
9,349
public static mps_network_config get ( nitro_service client ) throws Exception { mps_network_config resource = new mps_network_config ( ) ; resource . validate ( "get" ) ; return ( ( mps_network_config [ ] ) resource . get_resources ( client ) ) [ 0 ] ; }
Use this operation to get MPS network configuration .
9,350
@ SuppressWarnings ( "unchecked" ) public void visit ( final Visitable visitable ) { if ( visitable instanceof Identifiable ) { ( ( Identifiable ) visitable ) . setId ( null ) ; } }
Visits any Visitable object implementing the Identifiable interface clearing the Identifiable objects identifier .
9,351
public int compare ( final Orderable < T > orderable1 , final Orderable < T > orderable2 ) { return orderable1 . getOrder ( ) . compareTo ( orderable2 . getOrder ( ) ) ; }
Compares two Orderable objects to determine their relative order by their order property .
9,352
public static xen_supplemental_pack install ( nitro_service client , xen_supplemental_pack resource ) throws Exception { return ( ( xen_supplemental_pack [ ] ) resource . perform_operation ( client , "install" ) ) [ 0 ] ; }
Use this operation to install new xen supplemental pack .
9,353
public static jazz_license get ( nitro_service client ) throws Exception { jazz_license resource = new jazz_license ( ) ; resource . validate ( "get" ) ; return ( ( jazz_license [ ] ) resource . get_resources ( client ) ) [ 0 ] ; }
Use this operation to get license information .
9,354
public static xen_hotfix apply ( nitro_service client , xen_hotfix resource ) throws Exception { return ( ( xen_hotfix [ ] ) resource . perform_operation ( client , "apply" ) ) [ 0 ] ; }
Use this operation to apply new xen hotfixes .
9,355
public static String toInitialCase ( String s ) { if ( isBlank ( s ) ) return s ; if ( s . length ( ) == 1 ) return s . toUpperCase ( ) ; return s . substring ( 0 , 1 ) . toUpperCase ( ) + s . substring ( 1 ) ; }
Makes the initial letter upper - case .
9,356
public static String replicate ( String s , int times ) { if ( s == null ) return null ; if ( times <= 0 || s . length ( ) == 0 ) return "" ; StringBuilder b = new StringBuilder ( s . length ( ) * times ) ; for ( int k = 1 ; k <= times ; ++ k ) b . append ( s ) ; return b . toString ( ) ; }
Replicates a string .
9,357
public static String md5 ( String s ) { try { MessageDigest md5 = MessageDigest . getInstance ( "MD5" ) ; byte [ ] digest = md5 . digest ( s . getBytes ( Charset . forName ( "UTF-8" ) ) ) ; StringBuilder buf = new StringBuilder ( 2 * digest . length ) ; for ( byte oneByte : digest ) { buf . append ( Integer . toHexString ( ( oneByte & 0xFF ) | 0x100 ) . substring ( 1 , 3 ) ) ; } return buf . toString ( ) ; } catch ( NoSuchAlgorithmException ignore ) { } return s ; }
Computes a MD5 fingerprint of a text - string and returns as a HEX encoded string .
9,358
public static String percentageBar ( double percentage ) { final char dot = '.' ; final char mark = '#' ; final int slots = 40 ; StringBuilder bar = new StringBuilder ( replicate ( String . valueOf ( dot ) , slots ) ) ; int numSlots = ( int ) ( slots * percentage / 100.0 ) ; for ( int k = 0 ; k < numSlots ; ++ k ) bar . setCharAt ( k , mark ) ; return String . format ( "[%s] %3.0f%%" , bar , percentage ) ; }
Creates a percentage ASCII bar .
9,359
public static final ChannelInitializer < Channel > httpServer ( final SimpleChannelInboundHandler < HttpRequest > handler ) { Preconditions . checkArgument ( handler . isSharable ( ) ) ; return new ChannelInitializer < Channel > ( ) { protected void initChannel ( Channel channel ) throws Exception { ChannelPipeline pipeline = channel . pipeline ( ) ; pipeline . addLast ( "httpCodec" , new HttpServerCodec ( ) ) ; pipeline . addLast ( "aggregator" , new HttpObjectAggregator ( 10 * 1024 * 1024 ) ) ; pipeline . addLast ( "httpServerHandler" , handler ) ; } } ; }
Returns a new chanel initializer suited to decode and process HTTP requests .
9,360
public static final ChannelInitializer < Channel > httpClient ( final SimpleChannelInboundHandler < HttpResponse > handler ) { return new ChannelInitializer < Channel > ( ) { protected void initChannel ( Channel channel ) throws Exception { ChannelPipeline pipeline = channel . pipeline ( ) ; pipeline . addLast ( "httpCodec" , new HttpClientCodec ( ) ) ; pipeline . addLast ( "aggregator" , new HttpObjectAggregator ( 10 * 1024 * 1024 ) ) ; pipeline . addLast ( "httpClientHandler" , handler ) ; } } ; }
Returns a channel initializer suited to decode and process HTTP responses .
9,361
public static boolean isBlocked ( Thread thread ) { return ( thread != null && Thread . State . BLOCKED . equals ( thread . getState ( ) ) ) ; }
Determines whether the specified Thread is in a blocked state . A Thread may be currently blocked waiting on a lock or performing some IO operation .
9,362
public static boolean isNew ( Thread thread ) { return ( thread != null && Thread . State . NEW . equals ( thread . getState ( ) ) ) ; }
Determines whether the specified Thread is a new Thread . A new Thread is any Thread that has not been started yet .
9,363
public static boolean isTimedWaiting ( Thread thread ) { return ( thread != null && Thread . State . TIMED_WAITING . equals ( thread . getState ( ) ) ) ; }
Determines whether the specified Thread is currently in a timed wait .
9,364
public static boolean isWaiting ( Thread thread ) { return ( thread != null && Thread . State . WAITING . equals ( thread . getState ( ) ) ) ; }
Determines whether the specified Thread is currently in a wait .
9,365
public static ClassLoader getContextClassLoader ( Thread thread ) { return ( thread != null ? thread . getContextClassLoader ( ) : ThreadUtils . class . getClassLoader ( ) ) ; }
A null - safe method for getting the Thread s context ClassLoader .
9,366
public static String getName ( Thread thread ) { return ( thread != null ? thread . getName ( ) : null ) ; }
A null - safe method for getting the Thread s name .
9,367
public static StackTraceElement [ ] getStackTrace ( Thread thread ) { return ( thread != null ? thread . getStackTrace ( ) : new StackTraceElement [ 0 ] ) ; }
A null - safe method for getting a snapshot of the Thread s current stack trace .
9,368
public static Thread . State getState ( Thread thread ) { return ( thread != null ? thread . getState ( ) : null ) ; }
A null - safe method for getting the Thread s current state .
9,369
public static ThreadGroup getThreadGroup ( Thread thread ) { return ( thread != null ? thread . getThreadGroup ( ) : null ) ; }
A null - safe method for getting the Thread s ThreadGroup .
9,370
public static void interrupt ( Thread thread ) { Optional . ofNullable ( thread ) . ifPresent ( Thread :: interrupt ) ; }
Null - safe operation to interrupt the specified Thread .
9,371
public static boolean join ( Thread thread , long milliseconds , int nanoseconds ) { try { if ( thread != null ) { thread . join ( milliseconds , nanoseconds ) ; return true ; } } catch ( InterruptedException e ) { Thread . currentThread ( ) . interrupt ( ) ; } return false ; }
Causes the current Thread to join with the specified Thread . If the current Thread is interrupted while waiting for the specified Thread then the current Threads interrupt bit will be set and this method will return false . Otherwise the current Thread will wait on the specified Thread until it dies or until the time period has expired and then the method will return true .
9,372
public static boolean sleep ( long milliseconds , int nanoseconds ) { try { Thread . sleep ( milliseconds , nanoseconds ) ; return true ; } catch ( InterruptedException e ) { Thread . currentThread ( ) . interrupt ( ) ; return false ; } }
Causes the current Thread to sleep for the specified number of milliseconds and nanoseconds . If the current Thread is interrupted the sleep is aborted however the interrupt bit is reset and this method returns false .
9,373
protected void runEchoService ( ServerSocket serverSocket ) { if ( isRunning ( serverSocket ) ) { echoService = newExecutorService ( ) ; echoService . submit ( ( ) -> { try { while ( isRunning ( serverSocket ) ) { Socket echoClient = serverSocket . accept ( ) ; getLogger ( ) . info ( ( ) -> String . format ( "EchoClient connected from [%s]" , echoClient . getRemoteSocketAddress ( ) ) ) ; echoService . submit ( ( ) -> { sendResponse ( echoClient , receiveMessage ( echoClient ) ) ; close ( echoClient ) ; } ) ; } } catch ( IOException cause ) { if ( isRunning ( serverSocket ) ) { getLogger ( ) . warning ( ( ) -> String . format ( "An IO error occurred while listening for EchoClients:%n%s" , ThrowableUtils . getStackTrace ( cause ) ) ) ; } } } ) ; getLogger ( ) . info ( ( ) -> String . format ( "EchoServer running on port [%d]" , getPort ( ) ) ) ; } }
Starts the echo service .
9,374
protected boolean stopEchoService ( ) { return Optional . ofNullable ( getEchoService ( ) ) . map ( localEchoService -> { localEchoService . shutdown ( ) ; try { if ( ! localEchoService . awaitTermination ( 30 , TimeUnit . SECONDS ) ) { localEchoService . shutdownNow ( ) ; if ( ! localEchoService . awaitTermination ( 30 , TimeUnit . SECONDS ) ) { getLogger ( ) . warning ( "Failed to shutdown EchoService" ) ; } } } catch ( InterruptedException ignore ) { Thread . currentThread ( ) . interrupt ( ) ; } return localEchoService . isShutdown ( ) ; } ) . orElse ( false ) ; }
Stops the Echo Service taking it offline and out - of - service .
9,375
public static ns reboot ( nitro_service client , ns resource ) throws Exception { return ( ( ns [ ] ) resource . perform_operation ( client , "reboot" ) ) [ 0 ] ; }
Use this operation to reboot NetScaler Instance .
9,376
public static ns stop ( nitro_service client , ns resource ) throws Exception { return ( ( ns [ ] ) resource . perform_operation ( client , "stop" ) ) [ 0 ] ; }
Use this operation to stop NetScaler Instance .
9,377
public static ns force_reboot ( nitro_service client , ns resource ) throws Exception { return ( ( ns [ ] ) resource . perform_operation ( client , "force_reboot" ) ) [ 0 ] ; }
Use this operation to force reboot NetScaler Instance .
9,378
public static ns force_stop ( nitro_service client , ns resource ) throws Exception { return ( ( ns [ ] ) resource . perform_operation ( client , "force_stop" ) ) [ 0 ] ; }
Use this operation to force stop NetScaler Instance .
9,379
public static ns start ( nitro_service client , ns resource ) throws Exception { return ( ( ns [ ] ) resource . perform_operation ( client , "start" ) ) [ 0 ] ; }
Use this operation to start NetScaler Instance .
9,380
public static ns [ ] get_filtered ( nitro_service service , filtervalue [ ] filter ) throws Exception { ns obj = new ns ( ) ; options option = new options ( ) ; option . set_filter ( filter ) ; ns [ ] response = ( ns [ ] ) obj . getfiltered ( service , option ) ; return response ; }
Use this API to fetch filtered set of ns resources . set the filter parameter values in filtervalue object .
9,381
public void put ( ElementType x ) { if ( full ( ) ) { getIdx = ( getIdx + 1 ) % elements . length ; } else { size ++ ; } elements [ putIdx ] = x ; putIdx = ( putIdx + 1 ) % elements . length ; }
Inserts an element and overwrites old one when full .
9,382
public ElementType get ( ) { if ( empty ( ) ) throw new IllegalArgumentException ( "Empty queue" ) ; ElementType x = ( ElementType ) elements [ getIdx ] ; getIdx = ( getIdx + 1 ) % elements . length ; size -- ; return x ; }
Removes the first element .
9,383
public Iterator < ElementType > iterator ( ) { return new Iterator < ElementType > ( ) { int idx = getIdx ; int N = size ; public boolean hasNext ( ) { return N > 0 ; } public ElementType next ( ) { ElementType x = ( ElementType ) elements [ idx ] ; idx = ( idx + 1 ) % elements . length ; N -- ; return x ; } public void remove ( ) { throw new UnsupportedOperationException ( "remove" ) ; } } ; }
Returns an iterator intended usage in a foreach loop
9,384
public List < ElementType > toList ( ) { List < ElementType > result = new ArrayList < ElementType > ( size ( ) ) ; for ( ElementType e : this ) result . add ( e ) ; return result ; }
Returns a new list with all the elements in order
9,385
protected < T > T defaultIfNotSet ( String propertyName , T defaultValue , Class < T > type ) { return ( isSet ( propertyName ) ? convert ( propertyName , type ) : defaultValue ) ; }
Defaults of the value for the named property if the property does not exist .
9,386
public PropertiesAdapter filter ( Filter < String > filter ) { Properties properties = new Properties ( ) ; for ( String propertyName : this ) { if ( filter . accept ( propertyName ) ) { properties . setProperty ( propertyName , get ( propertyName ) ) ; } } return from ( properties ) ; }
Filters the properties from this adapter by name .
9,387
public static mail_profile get ( nitro_service client , mail_profile resource ) throws Exception { resource . validate ( "get" ) ; return ( ( mail_profile [ ] ) resource . get_resources ( client ) ) [ 0 ] ; }
Use this operation to get mail profile ..
9,388
public int compare ( final TimeUnit timeUnitOne , final TimeUnit timeUnitTwo ) { return Integer . valueOf ( String . valueOf ( TIME_UNIT_VALUE . get ( timeUnitOne ) ) ) . compareTo ( TIME_UNIT_VALUE . get ( timeUnitTwo ) ) ; }
Compares 2 TimeUnit values for order .
9,389
public static Class [ ] getArgumentTypes ( Object ... arguments ) { Class [ ] argumentTypes = null ; if ( arguments != null ) { argumentTypes = new Class [ arguments . length ] ; for ( int index = 0 ; index < arguments . length ; index ++ ) { argumentTypes [ index ] = getClass ( arguments [ index ] ) ; } } return argumentTypes ; }
Determines the class types for all the given arguments .
9,390
public static final long nextPermutation ( long val ) { long tmp = val | ( val - 1 ) ; return ( tmp + 1 ) | ( ( ( - tmp & - ~ tmp ) - 1 ) >> ( Long . numberOfTrailingZeros ( val ) + 1 ) ) ; }
Compute the lexicographically next bit permutation .
9,391
public static final int [ ] getBitsSet ( final long val ) { long tmp = val ; int [ ] retVal = new int [ Long . bitCount ( val ) ] ; for ( int i = 0 ; i < retVal . length ; i ++ ) { retVal [ i ] = Long . numberOfTrailingZeros ( tmp ) ; tmp = tmp ^ Long . lowestOneBit ( tmp ) ; } return retVal ; }
Returns the number of bits set .
9,392
@ SuppressWarnings ( "unchecked" ) public < E > E [ ] sort ( final E ... elements ) { return ( E [ ] ) sort ( new SortableArrayList ( elements ) ) . toArray ( ( E [ ] ) Array . newInstance ( elements . getClass ( ) . getComponentType ( ) , elements . length ) ) ; }
Uses the Merge Sort to sort an array of elements as defined by the Comparator or as determined by the elements in the array if the elements are Comparable .
9,393
public < E > List < E > sort ( final List < E > elements ) { if ( elements . size ( ) > 1 ) { int size = elements . size ( ) ; int count = ( ( size / 2 ) + ( size % 2 ) ) ; List < E > leftElements = sort ( elements . subList ( 0 , count ) ) ; List < E > rightElements = sort ( elements . subList ( count , size ) ) ; return merge ( leftElements , rightElements ) ; } return elements ; }
Uses the Merge Sort algorithm to sort a List of elements as defined by the Comparator or as determined by the elements in the collection if the elements are Comparable .
9,394
public static Metadata fromPomProperties ( InputStream is ) { Metadata metadata = new Metadata ( ) ; BufferedReader input = new BufferedReader ( new InputStreamReader ( is ) ) ; try { String line ; while ( ( line = input . readLine ( ) ) != null ) { if ( line . startsWith ( "#" ) ) continue ; String [ ] property = line . trim ( ) . split ( "=" ) ; if ( property . length == 2 ) metadata . put ( property [ 0 ] , property [ 1 ] ) ; } } catch ( IOException e ) { } return metadata ; }
Attempts to parse a pom . xml file .
9,395
public static Metadata fromManifest ( InputStream is ) { try { Manifest mf = new Manifest ( is ) ; return fromManifest ( mf ) ; } catch ( IOException e ) { } return new Metadata ( ) ; }
Attempts to parse a MANIFEST . MF file from an input stream .
9,396
public static af_persistant_stat_info [ ] get_filtered ( nitro_service service , filtervalue [ ] filter ) throws Exception { af_persistant_stat_info obj = new af_persistant_stat_info ( ) ; options option = new options ( ) ; option . set_filter ( filter ) ; af_persistant_stat_info [ ] response = ( af_persistant_stat_info [ ] ) obj . getfiltered ( service , option ) ; return response ; }
Use this API to fetch filtered set of af_persistant_stat_info resources . set the filter parameter values in filtervalue object .
9,397
@ SuppressWarnings ( "unchecked" ) public < T extends VALUE > T withCaching ( KEY key , Supplier < VALUE > cacheableOperation ) { Assert . notNull ( key , "Key is required" ) ; Assert . notNull ( cacheableOperation , "Supplier is required" ) ; ReadWriteLock lock = getLock ( ) ; return ( T ) Optional . ofNullable ( read ( lock , key ) ) . orElseGet ( ( ) -> Optional . ofNullable ( cacheableOperation . get ( ) ) . map ( value -> write ( lock , key , value ) ) . orElse ( null ) ) ; }
Implementation of the look - aside cache pattern .
9,398
public static syslog_server [ ] get_filtered ( nitro_service service , filtervalue [ ] filter ) throws Exception { syslog_server obj = new syslog_server ( ) ; options option = new options ( ) ; option . set_filter ( filter ) ; syslog_server [ ] response = ( syslog_server [ ] ) obj . getfiltered ( service , option ) ; return response ; }
Use this API to fetch filtered set of syslog_server resources . set the filter parameter values in filtervalue object .
9,399
public Object string_to_resource ( Class < ? > responseClass , String response ) { try { Gson gson = new Gson ( ) ; return gson . fromJson ( response , responseClass ) ; } catch ( Exception e ) { System . out . println ( e . getMessage ( ) ) ; } return null ; }
Converts Json string to NetScaler SDX resource .