idx
int64 0
41.2k
| question
stringlengths 83
4.15k
| target
stringlengths 5
715
|
|---|---|---|
2,500
|
public static Function newStoredJsFunction ( String bucket , String key ) { return new Builder ( ) . withBucket ( bucket ) . withKey ( key ) . build ( ) ; }
|
Static factory method for Stored Javascript Functions .
|
2,501
|
public static Function newErlangFunction ( String module , String function ) { return new Builder ( ) . withModule ( module ) . withFunction ( function ) . build ( ) ; }
|
Static factory method for Erlang Functions .
|
2,502
|
public List < Cell > getCellsCopy ( ) { final ArrayList < Cell > cells = new ArrayList < > ( this . getCellsCount ( ) ) ; for ( Cell c : this ) { cells . add ( c ) ; } return cells ; }
|
Get a shallow copy of the cells in this row .
|
2,503
|
public Iterator < Cell > iterator ( ) { if ( cells != null ) { return cells . iterator ( ) ; } else { assert pbRow != null ; return ConvertibleIteratorUtils . iterateAsCell ( pbRow . getCellsList ( ) . iterator ( ) , pbColumnDescriptions == null ? Collections . emptyIterator ( ) : pbColumnDescriptions . iterator ( ) ) ; } }
|
An iterator of the Cells in this row .
|
2,504
|
public static void set ( Charset charset ) { final Charset current = instance . currentCharset . get ( ) ; logger . info ( "Setting client charset from '{}' to '{}'" , current . name ( ) , charset . name ( ) ) ; instance . currentCharset . set ( charset ) ; }
|
Set the classloader - wide default Charset for the Riak client .
|
2,505
|
public MapUpdate removeCounter ( String key ) { BinaryValue k = BinaryValue . create ( key ) ; removes . add ( new MapOp . MapField ( MapOp . FieldType . COUNTER , k ) ) ; return this ; }
|
Update the map in Riak by removing the counter mapped to the provided key .
|
2,506
|
public MapUpdate removeRegister ( String key ) { BinaryValue k = BinaryValue . create ( key ) ; removes . add ( new MapOp . MapField ( MapOp . FieldType . REGISTER , k ) ) ; return this ; }
|
Update the map in Riak by removing the register mapped to the provided key .
|
2,507
|
public MapUpdate removeFlag ( String key ) { BinaryValue k = BinaryValue . create ( key ) ; removes . add ( new MapOp . MapField ( MapOp . FieldType . FLAG , k ) ) ; return this ; }
|
Update the map in Riak by removing the flag mapped to the provided key .
|
2,508
|
public MapUpdate removeSet ( String key ) { BinaryValue k = BinaryValue . create ( key ) ; removes . add ( new MapOp . MapField ( MapOp . FieldType . SET , k ) ) ; return this ; }
|
Update the map in Riak by removing the set mapped to the provided key .
|
2,509
|
public MapUpdate removeMap ( String key ) { BinaryValue k = BinaryValue . create ( key ) ; removes . add ( new MapOp . MapField ( MapOp . FieldType . MAP , k ) ) ; return this ; }
|
Update the map in Riak by removing the map mapped to the provided key .
|
2,510
|
public Iterator < Row > iterator ( ) { if ( this . rows != null ) { return Arrays . asList ( this . rows ) . iterator ( ) ; } else { return ConvertibleIteratorUtils . iterateAsRow ( this . pbRows . iterator ( ) , this . pbColumnDescriptions ) ; } }
|
An iterator of the Rows in this QueryResult .
|
2,511
|
public List < Row > getRowsCopy ( ) { final List < Row > rows = new ArrayList < > ( this . getRowsCount ( ) ) ; for ( Row cells : this ) { rows . add ( cells ) ; } return rows ; }
|
Get a shallow copy of the rows in this query result .
|
2,512
|
public < T extends RiakIndex < ? > > boolean hasIndex ( RiakIndex . Name < T > name ) { return indexes . containsKey ( name . getFullname ( ) ) ; }
|
Returns whether a specific RiakIndex is present
|
2,513
|
public < V , T extends RiakIndex < V > > T removeIndex ( RiakIndex . Name < T > name ) { RiakIndex < ? > removed = indexes . remove ( name . getFullname ( ) ) ; if ( removed != null ) { T index = name . wrap ( removed ) . createIndex ( ) ; return index ; } else { return null ; } }
|
Remove the named RiakIndex
|
2,514
|
public RiakNode setMaxConnections ( int maxConnections ) { stateCheck ( State . CREATED , State . RUNNING , State . HEALTH_CHECKING ) ; if ( maxConnections >= getMinConnections ( ) ) { permits . setMaxPermits ( maxConnections ) ; } else { throw new IllegalArgumentException ( "Max connections less than min connections" ) ; } return this ; }
|
Sets the maximum number of connections allowed .
|
2,515
|
public int getMaxConnections ( ) { stateCheck ( State . CREATED , State . RUNNING , State . HEALTH_CHECKING ) ; return permits . getMaxPermits ( ) ; }
|
Returns the maximum number of connections allowed .
|
2,516
|
public RiakNode setMinConnections ( int minConnections ) { stateCheck ( State . CREATED , State . RUNNING , State . HEALTH_CHECKING ) ; if ( minConnections <= getMaxConnections ( ) ) { this . minConnections = minConnections ; } else { throw new IllegalArgumentException ( "Min connections greater than max connections" ) ; } return this ; }
|
Sets the minimum number of active connections to be maintained .
|
2,517
|
public RiakNode setIdleTimeout ( int idleTimeoutInMillis ) { stateCheck ( State . CREATED , State . RUNNING , State . HEALTH_CHECKING ) ; this . idleTimeoutInNanos = TimeUnit . NANOSECONDS . convert ( idleTimeoutInMillis , TimeUnit . MILLISECONDS ) ; return this ; }
|
Sets the connection idle timeout for connections .
|
2,518
|
public int getIdleTimeout ( ) { stateCheck ( State . CREATED , State . RUNNING , State . HEALTH_CHECKING ) ; return ( int ) TimeUnit . MILLISECONDS . convert ( idleTimeoutInNanos , TimeUnit . NANOSECONDS ) ; }
|
Returns the connection idle timeout for connections in milliseconds .
|
2,519
|
public RiakNode setConnectionTimeout ( int connectionTimeoutInMillis ) { stateCheck ( State . CREATED , State . RUNNING , State . HEALTH_CHECKING ) ; this . connectionTimeout = connectionTimeoutInMillis ; bootstrap . option ( ChannelOption . CONNECT_TIMEOUT_MILLIS , connectionTimeout ) ; return this ; }
|
Sets the connection timeout for new connections .
|
2,520
|
public int availablePermits ( ) { stateCheck ( State . CREATED , State . RUNNING , State . HEALTH_CHECKING ) ; return permits . availablePermits ( ) ; }
|
Returns the number of permits currently available . The number of available permits indicates how many additional connections can be made without blocking .
|
2,521
|
public boolean execute ( FutureOperation operation ) { stateCheck ( State . RUNNING , State . HEALTH_CHECKING ) ; operation . setLastNode ( this ) ; Channel channel = getConnection ( ) ; if ( channel != null ) { inProgressMap . put ( channel , operation ) ; ChannelFuture writeFuture = channel . writeAndFlush ( operation ) ; writeFuture . addListener ( writeListener ) ; logger . debug ( "Operation {} being executed on RiakNode {}:{}" , System . identityHashCode ( operation ) , remoteAddress , port ) ; return true ; } else { logger . debug ( "Operation {} not being executed Riaknode {}:{}; no connections available" , System . identityHashCode ( operation ) , remoteAddress , port ) ; return false ; } }
|
Submits the operation to be executed on this node .
|
2,522
|
private void returnConnection ( Channel c ) { switch ( state ) { case SHUTTING_DOWN : case SHUTDOWN : closeConnection ( c ) ; break ; case RUNNING : case HEALTH_CHECKING : default : if ( inProgressMap . containsKey ( c ) ) { logger . error ( "Channel returned to pool while still in use. id: {}" , c . hashCode ( ) ) ; } else { if ( c . isOpen ( ) ) { logger . debug ( "Channel id:{} returned to pool" , c . hashCode ( ) ) ; c . closeFuture ( ) . removeListener ( inProgressCloseListener ) ; c . closeFuture ( ) . addListener ( inAvailableCloseListener ) ; available . offerFirst ( new ChannelWithIdleTime ( c ) ) ; } else { logger . debug ( "Closed channel id:{} returned to pool; discarding" , c . hashCode ( ) ) ; } logger . debug ( "Released pool permit" ) ; permits . release ( ) ; } } }
|
Return a Netty channel .
|
2,523
|
public void onSuccess ( Channel channel , final RiakMessage response ) { logger . debug ( "Operation onSuccess() channel: id:{} {}:{}" , channel . hashCode ( ) , remoteAddress , port ) ; consecutiveFailedOperations . set ( 0 ) ; final FutureOperation inProgress = inProgressMap . get ( channel ) ; if ( inProgress != null ) { inProgress . setResponse ( response ) ; if ( inProgress . isDone ( ) ) { try { inProgressMap . remove ( channel ) ; returnConnection ( channel ) ; } finally { inProgress . setComplete ( ) ; } } } }
|
End ConnectionPool stuff
|
2,524
|
public T resolve ( List < T > siblings ) throws UnresolvedConflictException { if ( siblings . size ( ) > 1 ) { throw new UnresolvedConflictException ( "Siblings found" , siblings ) ; } else if ( siblings . size ( ) == 1 ) { return siblings . get ( 0 ) ; } else { return null ; } }
|
Detects conflict but does not resolve it .
|
2,525
|
public Collection < FullColumnDescription > getPartitionKeyColumnDescriptions ( ) { if ( partitionKeys == null ) { partitionKeys = new LinkedList < > ( ) ; for ( FullColumnDescription col : fullColumnDescriptions . values ( ) ) { if ( col . isPartitionKeyMember ( ) ) { this . partitionKeys . add ( col ) ; } } Collections . sort ( this . partitionKeys , PartitionKeyComparator . INSTANCE ) ; } return this . partitionKeys ; }
|
Get the collection of Partition Key FullColumnDescriptions in order .
|
2,526
|
public FullColumnDescription getQuantumDescription ( ) { if ( quantumField == null ) { for ( FullColumnDescription fd : getPartitionKeyColumnDescriptions ( ) ) { if ( fd . hasQuantum ( ) ) { if ( quantumField != null ) { throw new IllegalStateException ( "Table definition has more than one quantum." ) ; } else { quantumField = fd ; } } } } return quantumField ; }
|
Get the FullColumnDescription for a quantum field if any .
|
2,527
|
public Collection < FullColumnDescription > getLocalKeyColumnDescriptions ( ) { if ( localKeys == null ) { localKeys = new LinkedList < > ( ) ; for ( FullColumnDescription col : fullColumnDescriptions . values ( ) ) { if ( col . isLocalKeyMember ( ) ) { this . localKeys . add ( col ) ; } } Collections . sort ( this . localKeys , LocalKeyComparator . INSTANCE ) ; } return this . localKeys ; }
|
Get the collection of Local Key FullColumnDescriptions in order .
|
2,528
|
public synchronized final void setResponse ( RiakMessage rawResponse ) { stateCheck ( State . CREATED , State . WRITTEN , State . RETRY ) ; U decodedMessage = decode ( rawResponse ) ; processMessage ( decodedMessage ) ; exception = null ; if ( done ( decodedMessage ) ) { logger . debug ( "Setting to Cleanup Wait State" ) ; remainingTries -- ; if ( retrier != null ) { retrier . operationComplete ( this , remainingTries ) ; } state = State . CLEANUP_WAIT ; } }
|
Exposed for testing .
|
2,529
|
public T toDomain ( RiakObject obj , Location location ) { T domainObject ; if ( obj . isDeleted ( ) ) { domainObject = newDomainInstance ( ) ; } else { domainObject = toDomain ( obj . getValue ( ) , obj . getContentType ( ) ) ; AnnotationUtil . populateIndexes ( obj . getIndexes ( ) , domainObject ) ; AnnotationUtil . populateLinks ( obj . getLinks ( ) , domainObject ) ; AnnotationUtil . populateUsermeta ( obj . getUserMeta ( ) , domainObject ) ; AnnotationUtil . setContentType ( domainObject , obj . getContentType ( ) ) ; AnnotationUtil . setVTag ( domainObject , obj . getVTag ( ) ) ; } AnnotationUtil . setKey ( domainObject , location . getKey ( ) ) ; AnnotationUtil . setBucketName ( domainObject , location . getNamespace ( ) . getBucketName ( ) ) ; AnnotationUtil . setBucketType ( domainObject , location . getNamespace ( ) . getBucketType ( ) ) ; AnnotationUtil . setVClock ( domainObject , obj . getVClock ( ) ) ; AnnotationUtil . setTombstone ( domainObject , obj . isDeleted ( ) ) ; AnnotationUtil . setLastModified ( domainObject , obj . getLastModified ( ) ) ; return domainObject ; }
|
Converts from a RiakObject to a domain object .
|
2,530
|
public static BinaryValue create ( String data , Charset charset ) { byte [ ] bytes = null ; if ( data != null ) { bytes = data . getBytes ( charset ) ; } return new BinaryValue ( bytes ) ; }
|
Create a BinaryValue containing a copy of the supplied string encoded using the supplied Charset .
|
2,531
|
public final RiakIndex < T > add ( Collection < T > values ) { for ( T value : values ) { add ( value ) ; } return this ; }
|
Add a asSet of values to this secondary index .
|
2,532
|
public final RiakIndex < T > remove ( Collection < T > values ) { for ( T value : values ) { remove ( value ) ; } return this ; }
|
Remove a asSet of values from this index
|
2,533
|
public static String addUtf8Charset ( String contentType ) { if ( contentType == null ) { return "text/plain;charset=utf-8" ; } Matcher matcher = CHARSET_PATT . matcher ( contentType ) ; if ( matcher . find ( ) ) { return contentType . substring ( 0 , matcher . start ( 1 ) ) + "utf-8" + contentType . substring ( matcher . end ( 1 ) ) ; } return contentType + ";charset=utf-8" ; }
|
Adds the utf - 8 charset to a content type .
|
2,534
|
public static String addCharset ( String charset , String contentType ) { if ( null == contentType ) { return "text/plain;charset=" + charset ; } else { Matcher matcher = CHARSET_PATT . matcher ( contentType ) ; if ( matcher . find ( ) ) { return contentType . substring ( 0 , matcher . start ( 1 ) ) + charset + contentType . substring ( matcher . end ( 1 ) ) ; } else { return contentType + ";charset=" + charset ; } } }
|
Adds the charset to a content type .
|
2,535
|
public static boolean hasCharset ( String ctype ) { if ( ctype == null ) { return false ; } Matcher matcher = CHARSET_PATT . matcher ( ctype ) ; if ( matcher . find ( ) ) { return true ; } else { return false ; } }
|
Check if a content - type string has a charset field appended .
|
2,536
|
public static Cell newTimestamp ( long rawTimestampValue ) { final Cell cell = new Cell ( ) ; cell . initTimestamp ( rawTimestampValue ) ; return cell ; }
|
Creates a new Timestamp cell from the provided raw value .
|
2,537
|
public static String generateToken ( final Integer apiKey , final String apiSecret ) throws OpenTokException { final long defaultExpireTime = System . currentTimeMillis ( ) / 1000L + TimeUnit . MINUTES . toSeconds ( 3 ) ; final JwtClaims claims = new JwtClaims ( ) ; claims . setIssuer ( apiKey . toString ( ) ) ; claims . setStringClaim ( ISSUER_TYPE , PROJECT_ISSUER_TYPE ) ; claims . setGeneratedJwtId ( ) ; return getToken ( claims , defaultExpireTime , apiSecret ) ; }
|
Used by the REST Endpoints
|
2,538
|
public Map < String , Collection < String > > toMap ( ) { Map < String , Collection < String > > params = new HashMap < String , Collection < String > > ( ) ; if ( null != type ) { ArrayList < String > valueList = new ArrayList < String > ( ) ; valueList . add ( type ) ; params . put ( "type" , valueList ) ; } if ( null != data ) { ArrayList < String > valueList = new ArrayList < String > ( ) ; valueList . add ( data ) ; params . put ( "data" , valueList ) ; } return params ; }
|
Returns the signal properties as a Map .
|
2,539
|
public Map < String , Collection < String > > toMap ( ) { Map < String , Collection < String > > params = new HashMap < String , Collection < String > > ( ) ; if ( name != null ) { ArrayList < String > valueList = new ArrayList < String > ( ) ; valueList . add ( name ) ; params . put ( "name" , valueList ) ; } if ( resolution != null ) { ArrayList < String > valueList = new ArrayList < String > ( ) ; valueList . add ( resolution ) ; params . put ( "resolution" , valueList ) ; } ArrayList < String > valueList = new ArrayList < String > ( ) ; valueList . add ( Boolean . toString ( hasAudio ) ) ; params . put ( "hasAudio" , valueList ) ; valueList = new ArrayList < String > ( ) ; valueList . add ( Boolean . toString ( hasVideo ) ) ; params . put ( "hasVideo" , valueList ) ; valueList = new ArrayList < String > ( ) ; valueList . add ( outputMode . toString ( ) ) ; params . put ( "outputMode" , valueList ) ; if ( layout != null ) { valueList = new ArrayList < String > ( ) ; valueList . add ( layout . toString ( ) ) ; params . put ( "layout" , valueList ) ; } return params ; }
|
Returns the archive properties as a Map .
|
2,540
|
public Map < String , Collection < String > > toMap ( ) { Map < String , Collection < String > > params = new HashMap < String , Collection < String > > ( ) ; if ( null != location ) { ArrayList < String > valueList = new ArrayList < String > ( ) ; valueList . add ( location ) ; params . put ( "location" , valueList ) ; } ArrayList < String > mediaModeValueList = new ArrayList < String > ( ) ; mediaModeValueList . add ( mediaMode . toString ( ) ) ; params . put ( "p2p.preference" , mediaModeValueList ) ; ArrayList < String > archiveModeValueList = new ArrayList < String > ( ) ; archiveModeValueList . add ( archiveMode . toString ( ) ) ; params . put ( "archiveMode" , archiveModeValueList ) ; return params ; }
|
Returns the session properties as a Map .
|
2,541
|
public static < T extends Number > Func2 < T , T , T > add ( ) { return new Func2 < T , T , T > ( ) { @ SuppressWarnings ( "unchecked" ) public T call ( T a , T b ) { if ( a instanceof Integer ) return ( T ) ( Number ) ( a . intValue ( ) + b . intValue ( ) ) ; else if ( a instanceof Long ) return ( T ) ( Number ) ( a . longValue ( ) + b . longValue ( ) ) ; else if ( a instanceof Double ) return ( T ) ( Number ) ( a . doubleValue ( ) + b . doubleValue ( ) ) ; else if ( a instanceof Float ) return ( T ) ( Number ) ( a . floatValue ( ) + b . floatValue ( ) ) ; else if ( a instanceof Byte ) return ( T ) ( Number ) ( a . byteValue ( ) + b . byteValue ( ) ) ; else if ( a instanceof Short ) return ( T ) ( Number ) ( a . shortValue ( ) + b . shortValue ( ) ) ; else throw new RuntimeException ( "not implemented" ) ; } } ; }
|
Returns a Func2 that adds numbers . Useful for Observable . reduce but not particularly performant as it does instanceOf checks .
|
2,542
|
public static final < T > Transformer < T , List < T > > bufferWhile ( Func1 < ? super T , Boolean > predicate ) { return bufferWhile ( predicate , 10 ) ; }
|
Buffers the elements into continuous non - overlapping Lists where the boundary is determined by a predicate receiving each item before or after being buffered and returns true to indicate a new buffer should start .
|
2,543
|
public static final < T > Transformer < T , List < T > > bufferWhile ( Func1 < ? super T , Boolean > predicate , int capacityHint ) { return new OperatorBufferPredicateBoundary < T > ( predicate , RxRingBuffer . SIZE , capacityHint , false ) ; }
|
Buffers the elements into continuous non - overlapping Lists where the boundary is determined by a predicate receiving each item before being buffered and returns true to indicate a new buffer should start .
|
2,544
|
public void setUUID ( UUID uuid ) { if ( uuid == null ) { throw new IllegalArgumentException ( "'uuid' is null." ) ; } mUUID = uuid ; long msbits = uuid . getMostSignificantBits ( ) ; long lsbits = uuid . getLeastSignificantBits ( ) ; byte [ ] data = getData ( ) ; data [ UUID_INDEX + 0 ] = ( byte ) ( ( msbits >> 56 ) & 0xFF ) ; data [ UUID_INDEX + 1 ] = ( byte ) ( ( msbits >> 48 ) & 0xFF ) ; data [ UUID_INDEX + 2 ] = ( byte ) ( ( msbits >> 40 ) & 0xFF ) ; data [ UUID_INDEX + 3 ] = ( byte ) ( ( msbits >> 32 ) & 0xFF ) ; data [ UUID_INDEX + 4 ] = ( byte ) ( ( msbits >> 24 ) & 0xFF ) ; data [ UUID_INDEX + 5 ] = ( byte ) ( ( msbits >> 16 ) & 0xFF ) ; data [ UUID_INDEX + 6 ] = ( byte ) ( ( msbits >> 8 ) & 0xFF ) ; data [ UUID_INDEX + 7 ] = ( byte ) ( ( msbits ) & 0xFF ) ; data [ UUID_INDEX + 8 ] = ( byte ) ( ( lsbits >> 56 ) & 0xFF ) ; data [ UUID_INDEX + 9 ] = ( byte ) ( ( lsbits >> 48 ) & 0xFF ) ; data [ UUID_INDEX + 10 ] = ( byte ) ( ( lsbits >> 40 ) & 0xFF ) ; data [ UUID_INDEX + 11 ] = ( byte ) ( ( lsbits >> 32 ) & 0xFF ) ; data [ UUID_INDEX + 12 ] = ( byte ) ( ( lsbits >> 24 ) & 0xFF ) ; data [ UUID_INDEX + 13 ] = ( byte ) ( ( lsbits >> 16 ) & 0xFF ) ; data [ UUID_INDEX + 14 ] = ( byte ) ( ( lsbits >> 8 ) & 0xFF ) ; data [ UUID_INDEX + 15 ] = ( byte ) ( ( lsbits >> 0 ) & 0xFF ) ; }
|
Set the proximity UUID .
|
2,545
|
public void setMajor ( int major ) { if ( major < 0 || 0xFFFF < major ) { throw new IllegalArgumentException ( "'major' is out of the valid range: " + major ) ; } mMajor = major ; byte [ ] data = getData ( ) ; data [ MAJOR_INDEX ] = ( byte ) ( ( major >> 8 ) & 0xFF ) ; data [ MAJOR_INDEX + 1 ] = ( byte ) ( ( major ) & 0xFF ) ; }
|
Set the major number .
|
2,546
|
public void setMinor ( int minor ) { if ( minor < 0 || 0xFFFF < minor ) { throw new IllegalArgumentException ( "'minor' is out of the valid range: " + minor ) ; } mMinor = minor ; byte [ ] data = getData ( ) ; data [ MINOR_INDEX ] = ( byte ) ( ( minor >> 8 ) & 0xFF ) ; data [ MINOR_INDEX + 1 ] = ( byte ) ( ( minor ) & 0xFF ) ; }
|
Set the minor number .
|
2,547
|
public void registerBuilder ( int type , ADStructureBuilder builder ) { if ( type < 0 || 0xFF < type ) { String message = String . format ( "'type' is out of the valid range: %d" , type ) ; throw new IllegalArgumentException ( message ) ; } if ( builder == null ) { return ; } Integer key = Integer . valueOf ( type ) ; List < ADStructureBuilder > builders = mBuilders . get ( key ) ; if ( builders == null ) { builders = new ArrayList < ADStructureBuilder > ( ) ; mBuilders . put ( key , builders ) ; } builders . add ( 0 , builder ) ; }
|
Register an AD structure builder for the AD type . The given builder is added at the beginning of the list of the builders for the AD type .
|
2,548
|
public void registerManufacturerSpecificBuilder ( int companyId , ADManufacturerSpecificBuilder builder ) { if ( companyId < 0 || 0xFFFF < companyId ) { String message = String . format ( "'companyId' is out of the valid range: %d" , companyId ) ; throw new IllegalArgumentException ( message ) ; } if ( builder == null ) { return ; } Integer key = Integer . valueOf ( companyId ) ; List < ADManufacturerSpecificBuilder > builders = mMSBuilders . get ( key ) ; if ( builders == null ) { builders = new ArrayList < ADManufacturerSpecificBuilder > ( ) ; mMSBuilders . put ( key , builders ) ; } builders . add ( 0 , builder ) ; }
|
Register a builder for the company ID . The given builder is added at the beginning of the list of the builders for the company ID .
|
2,549
|
public static long parseBE4BytesAsUnsigned ( byte [ ] data , int offset ) { long value = ( ( long ) ( data [ offset + 0 ] & 0xFF ) << 24 ) | ( ( long ) ( data [ offset + 1 ] & 0xFF ) << 16 ) | ( ( long ) ( data [ offset + 2 ] & 0xFF ) << 8 ) | ( ( long ) ( data [ offset + 3 ] & 0xFF ) << 0 ) ; return value ; }
|
Parse 4 bytes in big endian byte order as an unsigned integer .
|
2,550
|
public static byte [ ] copyOfRange ( byte [ ] source , int from , int to ) { if ( source == null || from < 0 || to < 0 ) { return null ; } int length = to - from ; if ( length < 0 ) { return null ; } if ( source . length < from + length ) { return null ; } byte [ ] destination = new byte [ length ] ; System . arraycopy ( source , from , destination , 0 , length ) ; return destination ; }
|
Copy a range of a given byte array .
|
2,551
|
public static UUID from16 ( byte [ ] data , int offset , boolean littleEndian ) { if ( data == null || offset < 0 || data . length <= ( offset + 1 ) || Integer . MAX_VALUE == offset ) { return null ; } int v2 , v3 ; if ( littleEndian ) { v2 = data [ offset + 1 ] & 0xFF ; v3 = data [ offset + 0 ] & 0xFF ; } else { v2 = data [ offset + 0 ] & 0xFF ; v3 = data [ offset + 1 ] & 0xFF ; } return fromBase ( 0 , 0 , v2 , v3 ) ; }
|
Create a UUID instance from 16 - bit UUID data .
|
2,552
|
public static UUID from32 ( byte [ ] data , int offset , boolean littleEndian ) { if ( data == null || offset < 0 || data . length <= ( offset + 3 ) || ( Integer . MAX_VALUE - 3 ) < offset ) { return null ; } int v0 , v1 , v2 , v3 ; if ( littleEndian ) { v0 = data [ offset + 3 ] & 0xFF ; v1 = data [ offset + 2 ] & 0xFF ; v2 = data [ offset + 1 ] & 0xFF ; v3 = data [ offset + 0 ] & 0xFF ; } else { v0 = data [ offset + 0 ] & 0xFF ; v1 = data [ offset + 1 ] & 0xFF ; v2 = data [ offset + 2 ] & 0xFF ; v3 = data [ offset + 3 ] & 0xFF ; } return fromBase ( v0 , v1 , v2 , v3 ) ; }
|
Create a UUID instance from 32 - bit UUID data .
|
2,553
|
public static UUID from128 ( byte [ ] data , int offset , boolean littleEndian ) { if ( data == null || offset < 0 || data . length <= ( offset + 15 ) || ( Integer . MAX_VALUE - 15 ) < offset ) { return null ; } String uuid ; if ( littleEndian ) { uuid = String . format ( GENERIC_UUID_FORMAT , data [ offset + 15 ] & 0xFF , data [ offset + 14 ] & 0xFF , data [ offset + 13 ] & 0xFF , data [ offset + 12 ] & 0xFF , data [ offset + 11 ] & 0xFF , data [ offset + 10 ] & 0xFF , data [ offset + 9 ] & 0xFF , data [ offset + 8 ] & 0xFF , data [ offset + 7 ] & 0xFF , data [ offset + 6 ] & 0xFF , data [ offset + 5 ] & 0xFF , data [ offset + 4 ] & 0xFF , data [ offset + 3 ] & 0xFF , data [ offset + 2 ] & 0xFF , data [ offset + 1 ] & 0xFF , data [ offset + 0 ] & 0xFF ) ; } else { uuid = String . format ( GENERIC_UUID_FORMAT , data [ offset + 0 ] & 0xFF , data [ offset + 1 ] & 0xFF , data [ offset + 2 ] & 0xFF , data [ offset + 3 ] & 0xFF , data [ offset + 4 ] & 0xFF , data [ offset + 5 ] & 0xFF , data [ offset + 6 ] & 0xFF , data [ offset + 7 ] & 0xFF , data [ offset + 8 ] & 0xFF , data [ offset + 9 ] & 0xFF , data [ offset + 10 ] & 0xFF , data [ offset + 11 ] & 0xFF , data [ offset + 12 ] & 0xFF , data [ offset + 13 ] & 0xFF , data [ offset + 14 ] & 0xFF , data [ offset + 15 ] & 0xFF ) ; } return UUID . fromString ( uuid ) ; }
|
Create a UUID instance from 128 - bit UUID data .
|
2,554
|
public void setVersion ( int version ) { if ( version < 0 || 255 < version ) { throw new IllegalArgumentException ( "'version' is out of the valid range: " + version ) ; } mVersion = version ; getData ( ) [ VERSION_INDEX ] = ( byte ) ( version & 0xFF ) ; }
|
Set the version of the packet format of Bluetooth LE ucode Marker .
|
2,555
|
public void setUcode ( String ucode ) { if ( ucode == null ) { throw new IllegalArgumentException ( "'ucode' is null." ) ; } if ( UCODE_PATTERN . matcher ( ucode ) . matches ( ) == false ) { throw new IllegalArgumentException ( "The format of 'ucode' is wrong: " + ucode ) ; } mUcode = ucode ; byte [ ] data = getData ( ) ; for ( int i = 0 ; i < 32 ; i += 2 ) { byte value = readHex ( ucode , i ) ; int offset = UCODE_INDEX + ( 15 - i / 2 ) ; data [ offset ] = value ; } }
|
Set the ucode .
|
2,556
|
public void setPower ( int power ) { if ( power < - 128 || 127 < power ) { throw new IllegalArgumentException ( "'power' is out of the valid range: " + power ) ; } mPower = power ; getData ( ) [ POWER_INDEX ] = ( byte ) power ; }
|
Set the transmission power in dBm .
|
2,557
|
public void setCount ( int count ) { if ( count < 0 || 0xFF < count ) { throw new IllegalArgumentException ( "'count' is out of the valid range: " + count ) ; } mCount = count ; getData ( ) [ COUNT_INDEX ] = ( byte ) count ; }
|
Set the transmission count .
|
2,558
|
public String getNamespaceIdAsString ( ) { if ( mNamespaceIdAsString == null ) { mNamespaceIdAsString = Bytes . toHexString ( getNamespaceId ( ) , true ) ; } return mNamespaceIdAsString ; }
|
Get the 10 - byte namespace ID as an upper - case hex string .
|
2,559
|
public String getInstanceIdAsString ( ) { if ( mInstanceIdAsString == null ) { mInstanceIdAsString = Bytes . toHexString ( getInstanceId ( ) , true ) ; } return mInstanceIdAsString ; }
|
Get the 6 - byte instance ID as an upper - case hex string .
|
2,560
|
public String getBeaconIdAsString ( ) { if ( mBeaconIdAsString == null ) { mBeaconIdAsString = Bytes . toHexString ( getBeaconId ( ) , true ) ; } return mBeaconIdAsString ; }
|
Get the 16 - byte beacon ID as an upper - case hex string .
|
2,561
|
private static PaxContext getContext ( ) { if ( m_context == null && m_paxLogging != null ) { m_context = ( m_paxLogging . getPaxLoggingService ( ) != null ) ? m_paxLogging . getPaxLoggingService ( ) . getPaxContext ( ) : null ; } return m_context != null ? m_context : m_defaultContext ; }
|
For all the methods that operate against the context return true if the MDC should use the PaxContext object from the PaxLoggingManager or if the logging manager is not set or does not have its context available yet use a default context local to this MDC .
|
2,562
|
public void setThreshold ( final Level level ) { Level oldValue = this . thresholdLevel ; thresholdLevel = level ; firePropertyChange ( "threshold" , oldValue , this . thresholdLevel ) ; }
|
Sets the receiver theshold to the given level .
|
2,563
|
public void doPost ( final LoggingEvent event ) { if ( ! isAsSevereAsThreshold ( event . getLevel ( ) ) ) { return ; } Logger localLogger = getLoggerRepository ( ) . getLogger ( event . getLoggerName ( ) ) ; if ( event . getLevel ( ) . isGreaterOrEqual ( localLogger . getEffectiveLevel ( ) ) ) { localLogger . callAppenders ( event ) ; } }
|
Posts the logging event to a logger in the configured logger repository .
|
2,564
|
public void activateOptions ( ) { if ( ! isActive ( ) ) { try { remoteInfo = topicFactoryName + ":" + topicName ; Context ctx = null ; if ( jndiPath == null || jndiPath . equals ( "" ) ) { ctx = new InitialContext ( ) ; } else { FileInputStream is = new FileInputStream ( jndiPath ) ; Properties p = new Properties ( ) ; p . load ( is ) ; is . close ( ) ; ctx = new InitialContext ( p ) ; } providerUrl = ( String ) ctx . getEnvironment ( ) . get ( Context . PROVIDER_URL ) ; TopicConnectionFactory topicConnectionFactory ; topicConnectionFactory = ( TopicConnectionFactory ) lookup ( ctx , topicFactoryName ) ; if ( userId != null && password != null ) { topicConnection = topicConnectionFactory . createTopicConnection ( userId , password ) ; } else { topicConnection = topicConnectionFactory . createTopicConnection ( ) ; } TopicSession topicSession = topicConnection . createTopicSession ( false , Session . AUTO_ACKNOWLEDGE ) ; Topic topic = ( Topic ) ctx . lookup ( topicName ) ; TopicSubscriber topicSubscriber = topicSession . createSubscriber ( topic ) ; topicSubscriber . setMessageListener ( this ) ; topicConnection . start ( ) ; setActive ( true ) ; } catch ( Exception e ) { setActive ( false ) ; if ( topicConnection != null ) { try { topicConnection . close ( ) ; } catch ( Exception e2 ) { } topicConnection = null ; } getLogger ( ) . error ( "Could not start JMSReceiver." , e ) ; } } }
|
Starts the JMSReceiver with the current options .
|
2,565
|
public synchronized void shutdown ( ) { if ( isActive ( ) ) { setActive ( false ) ; if ( topicConnection != null ) { try { topicConnection . close ( ) ; } catch ( Exception e ) { } topicConnection = null ; } } }
|
Called when the receiver should be stopped .
|
2,566
|
public int decide ( final LoggingEvent event ) { if ( expressionRule . evaluate ( event , null ) ) { if ( acceptOnMatch ) { return Filter . ACCEPT ; } else { return Filter . DENY ; } } return Filter . NEUTRAL ; }
|
Determines if event matches the filter .
|
2,567
|
public ConcurrentMap < String , L > getLoggersInContext ( final LoggerContext context ) { ConcurrentMap < String , L > loggers ; lock . readLock ( ) . lock ( ) ; try { loggers = registry . get ( context ) ; } finally { lock . readLock ( ) . unlock ( ) ; } if ( loggers != null ) { return loggers ; } else { lock . writeLock ( ) . lock ( ) ; try { loggers = registry . get ( context ) ; if ( loggers == null ) { loggers = new ConcurrentHashMap < > ( ) ; registry . put ( context , loggers ) ; } return loggers ; } finally { lock . writeLock ( ) . unlock ( ) ; } } }
|
Gets or creates the ConcurrentMap of named loggers for a given LoggerContext .
|
2,568
|
public synchronized void shutdown ( ) { active = false ; try { if ( socketNode != null ) { socketNode . close ( ) ; socketNode = null ; } } catch ( Exception e ) { getLogger ( ) . info ( "Excpetion closing socket" , e ) ; } if ( connector != null ) { connector . interrupted = true ; connector = null ; } if ( advertiseViaMulticastDNS ) { zeroConf . unadvertise ( ) ; } }
|
Called when the receiver should be stopped . Closes the socket
|
2,569
|
private synchronized void fireConnector ( final boolean isReconnect ) { if ( active && connector == null ) { getLogger ( ) . debug ( "Starting a new connector thread." ) ; connector = new Connector ( isReconnect ) ; connector . setDaemon ( true ) ; connector . setPriority ( Thread . MIN_PRIORITY ) ; connector . start ( ) ; } }
|
Fire connectors .
|
2,570
|
private synchronized void setSocket ( final Socket newSocket ) { connector = null ; socketNode = new SocketNode13 ( newSocket , this ) ; socketNode . addSocketNodeEventListener ( this ) ; synchronized ( listenerList ) { for ( Iterator iter = listenerList . iterator ( ) ; iter . hasNext ( ) ; ) { SocketNodeEventListener listener = ( SocketNodeEventListener ) iter . next ( ) ; socketNode . addSocketNodeEventListener ( listener ) ; } } new Thread ( socketNode ) . start ( ) ; }
|
Set socket .
|
2,571
|
public void activateOptions ( ) { try { clip = Applet . newAudioClip ( new URL ( audioURL ) ) ; } catch ( MalformedURLException mue ) { LogLog . error ( "unable to initialize SoundAppender" , mue ) ; } if ( clip == null ) { LogLog . error ( "Unable to initialize SoundAppender" ) ; } }
|
Attempt to initialize the appender by creating a reference to an AudioClip .
|
2,572
|
public boolean isRule ( final String symbol ) { return ( ( symbol != null ) && ( RULES . contains ( symbol . toLowerCase ( Locale . ENGLISH ) ) ) ) ; }
|
Determine if specified string is a known operator .
|
2,573
|
public Rule getRule ( final String symbol , final Stack stack ) { if ( AND_RULE . equals ( symbol ) ) { return AndRule . getRule ( stack ) ; } if ( OR_RULE . equals ( symbol ) ) { return OrRule . getRule ( stack ) ; } if ( NOT_RULE . equals ( symbol ) ) { return NotRule . getRule ( stack ) ; } if ( NOT_EQUALS_RULE . equals ( symbol ) ) { return NotEqualsRule . getRule ( stack ) ; } if ( EQUALS_RULE . equals ( symbol ) ) { return EqualsRule . getRule ( stack ) ; } if ( PARTIAL_TEXT_MATCH_RULE . equals ( symbol ) ) { return PartialTextMatchRule . getRule ( stack ) ; } if ( RULES . contains ( LIKE_RULE ) && LIKE_RULE . equalsIgnoreCase ( symbol ) ) { return LikeRule . getRule ( stack ) ; } if ( EXISTS_RULE . equalsIgnoreCase ( symbol ) ) { return ExistsRule . getRule ( stack ) ; } if ( LESS_THAN_RULE . equals ( symbol ) ) { return InequalityRule . getRule ( LESS_THAN_RULE , stack ) ; } if ( GREATER_THAN_RULE . equals ( symbol ) ) { return InequalityRule . getRule ( GREATER_THAN_RULE , stack ) ; } if ( LESS_THAN_EQUALS_RULE . equals ( symbol ) ) { return InequalityRule . getRule ( LESS_THAN_EQUALS_RULE , stack ) ; } if ( GREATER_THAN_EQUALS_RULE . equals ( symbol ) ) { return InequalityRule . getRule ( GREATER_THAN_EQUALS_RULE , stack ) ; } throw new IllegalArgumentException ( "Invalid rule: " + symbol ) ; }
|
Create rule from applying operator to stack .
|
2,574
|
public void activateOptions ( ) { if ( rollingPolicy == null ) { LogLog . warn ( "Please set a rolling policy for the RollingFileAppender named '" + getName ( ) + "'" ) ; return ; } if ( ( triggeringPolicy == null ) && rollingPolicy instanceof TriggeringPolicy ) { triggeringPolicy = ( TriggeringPolicy ) rollingPolicy ; } if ( triggeringPolicy == null ) { LogLog . warn ( "Please set a TriggeringPolicy for the RollingFileAppender named '" + getName ( ) + "'" ) ; return ; } Exception exception = null ; synchronized ( this ) { triggeringPolicy . activateOptions ( ) ; rollingPolicy . activateOptions ( ) ; try { RolloverDescription rollover = rollingPolicy . initialize ( getFile ( ) , getAppend ( ) ) ; if ( rollover != null ) { Action syncAction = rollover . getSynchronous ( ) ; if ( syncAction != null ) { syncAction . execute ( ) ; } setFile ( rollover . getActiveFileName ( ) ) ; setAppend ( rollover . getAppend ( ) ) ; lastRolloverAsyncAction = rollover . getAsynchronous ( ) ; if ( lastRolloverAsyncAction != null ) { Thread runner = new Thread ( lastRolloverAsyncAction ) ; runner . start ( ) ; } } File activeFile = new File ( getFile ( ) ) ; if ( getAppend ( ) ) { fileLength = activeFile . length ( ) ; } else { fileLength = 0 ; } super . activateOptions ( ) ; } catch ( Exception ex ) { exception = ex ; } } if ( exception != null ) { LogLog . warn ( "Exception while initializing RollingFileAppender named '" + getName ( ) + "'" , exception ) ; } }
|
Prepare instance of use .
|
2,575
|
private FileOutputStream createFileOutputStream ( String newFileName , boolean append ) throws FileNotFoundException { try { return new FileOutputStream ( newFileName , append ) ; } catch ( FileNotFoundException ex ) { String parentName = new File ( newFileName ) . getParent ( ) ; if ( parentName != null ) { File parentDir = new File ( parentName ) ; if ( ! parentDir . exists ( ) && parentDir . mkdirs ( ) ) { return new FileOutputStream ( newFileName , append ) ; } else { throw ex ; } } else { throw ex ; } } }
|
Creates a new FileOutputStream of a new log file possibly creating first all the needed parent directories
|
2,576
|
public static void appendValue ( final StringBuilder stringBuilder , final Object obj ) { if ( obj == null || obj instanceof String ) { stringBuilder . append ( ( String ) obj ) ; } else if ( obj instanceof StringBuilderFormattable ) { ( ( StringBuilderFormattable ) obj ) . formatTo ( stringBuilder ) ; } else if ( obj instanceof CharSequence ) { stringBuilder . append ( ( CharSequence ) obj ) ; } else if ( obj instanceof Integer ) { stringBuilder . append ( ( ( Integer ) obj ) . intValue ( ) ) ; } else if ( obj instanceof Long ) { stringBuilder . append ( ( ( Long ) obj ) . longValue ( ) ) ; } else if ( obj instanceof Double ) { stringBuilder . append ( ( ( Double ) obj ) . doubleValue ( ) ) ; } else if ( obj instanceof Boolean ) { stringBuilder . append ( ( ( Boolean ) obj ) . booleanValue ( ) ) ; } else if ( obj instanceof Character ) { stringBuilder . append ( ( ( Character ) obj ) . charValue ( ) ) ; } else if ( obj instanceof Short ) { stringBuilder . append ( ( ( Short ) obj ) . shortValue ( ) ) ; } else if ( obj instanceof Float ) { stringBuilder . append ( ( ( Float ) obj ) . floatValue ( ) ) ; } else { stringBuilder . append ( obj ) ; } }
|
Appends a text representation of the specified object to the specified StringBuilder if possible without allocating temporary objects .
|
2,577
|
public static boolean equalsIgnoreCase ( final CharSequence left , final int leftOffset , final int leftLength , final CharSequence right , final int rightOffset , final int rightLength ) { if ( leftLength == rightLength ) { for ( int i = 0 ; i < rightLength ; i ++ ) { if ( toLowerCase ( left . charAt ( i + leftOffset ) ) != toLowerCase ( right . charAt ( i + rightOffset ) ) ) { return false ; } } return true ; } return false ; }
|
Returns true if the specified section of the left CharSequence equals ignoring case the specified section of the right CharSequence .
|
2,578
|
private static boolean setContext ( ) { if ( m_context == null && m_paxLogging != null ) { m_context = ( m_paxLogging . getPaxLoggingService ( ) != null ) ? m_paxLogging . getPaxLoggingService ( ) . getPaxContext ( ) : null ; } return m_context != null ; }
|
For all the methods that operate against the context return true if the MDC should use the PaxContext object ffrom the PaxLoggingManager or if the logging manager is not set or does not have its context available yet use a default context local to this MDC .
|
2,579
|
public Vector decode ( final URL url ) throws IOException { LineNumberReader reader ; boolean isZipFile = url . getPath ( ) . toLowerCase ( ) . endsWith ( ".zip" ) ; InputStream inputStream ; if ( isZipFile ) { inputStream = new ZipInputStream ( url . openStream ( ) ) ; ( ( ZipInputStream ) inputStream ) . getNextEntry ( ) ; } else { inputStream = url . openStream ( ) ; } if ( owner != null ) { reader = new LineNumberReader ( new InputStreamReader ( new ProgressMonitorInputStream ( owner , "Loading " + url , inputStream ) , ENCODING ) ) ; } else { reader = new LineNumberReader ( new InputStreamReader ( inputStream , ENCODING ) ) ; } Vector v = new Vector ( ) ; String line ; Vector events ; try { while ( ( line = reader . readLine ( ) ) != null ) { StringBuffer buffer = new StringBuffer ( line ) ; for ( int i = 0 ; i < 1000 ; i ++ ) { buffer . append ( reader . readLine ( ) ) . append ( "\n" ) ; } events = decodeEvents ( buffer . toString ( ) ) ; if ( events != null ) { v . addAll ( events ) ; } } } finally { partialEvent = null ; try { if ( reader != null ) { reader . close ( ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; } } return v ; }
|
Decodes a File into a Vector of LoggingEvents .
|
2,580
|
public LoggingEvent decode ( final String data ) { Document document = parse ( data ) ; if ( document == null ) { return null ; } Vector events = decodeEvents ( document ) ; if ( events . size ( ) > 0 ) { return ( LoggingEvent ) events . firstElement ( ) ; } return null ; }
|
Converts the string data into an XML Document and then soaks out the relevant bits to form a new LoggingEvent instance which can be used by any Log4j element locally .
|
2,581
|
private String getCData ( final Node n ) { StringBuffer buf = new StringBuffer ( ) ; NodeList nl = n . getChildNodes ( ) ; for ( int x = 0 ; x < nl . getLength ( ) ; x ++ ) { Node innerNode = nl . item ( x ) ; if ( ( innerNode . getNodeType ( ) == Node . TEXT_NODE ) || ( innerNode . getNodeType ( ) == Node . CDATA_SECTION_NODE ) ) { buf . append ( innerNode . getNodeValue ( ) ) ; } } return buf . toString ( ) ; }
|
Get contents of CDATASection .
|
2,582
|
public Vector decodeEvents ( final String document ) { if ( document != null ) { if ( document . trim ( ) . equals ( "" ) ) { return null ; } String newDoc ; String newPartialEvent = null ; if ( document . lastIndexOf ( RECORD_END ) == - 1 ) { partialEvent = partialEvent + document ; return null ; } if ( document . lastIndexOf ( RECORD_END ) + RECORD_END . length ( ) < document . length ( ) ) { newDoc = document . substring ( 0 , document . lastIndexOf ( RECORD_END ) + RECORD_END . length ( ) ) ; newPartialEvent = document . substring ( document . lastIndexOf ( RECORD_END ) + RECORD_END . length ( ) ) ; } else { newDoc = document ; } if ( partialEvent != null ) { newDoc = partialEvent + newDoc ; } partialEvent = newPartialEvent ; Document doc = parse ( newDoc ) ; if ( doc == null ) { return null ; } return decodeEvents ( doc ) ; } return null ; }
|
Decodes a String representing a number of events into a Vector of LoggingEvents .
|
2,583
|
public String getFormattedMessage ( ) { return message = message == null ? String . valueOf ( charSequence ) : message ; }
|
Returns the message .
|
2,584
|
public void removeAllAppenders ( ) { for ( Appender appender : aai . getAppenders ( ) ) { aai . removeAppender ( appender ) ; fireRemoveAppenderEvent ( appender ) ; } }
|
Remove all previously added appenders from this Category instance .
|
2,585
|
public void removeAppender ( Appender appender ) { boolean wasAttached = aai . isAttached ( appender ) ; if ( wasAttached ) { aai . removeAppender ( appender ) ; fireRemoveAppenderEvent ( appender ) ; } }
|
Remove the appender passed as parameter form the list of appenders .
|
2,586
|
public void setLoggerRepository ( final LoggerRepository repository ) { if ( this . repository == null ) { this . repository = repository ; } else if ( this . repository != repository ) { throw new IllegalStateException ( "Repository has been already set" ) ; } }
|
Set the owning repository . The owning repository cannot be set more than once .
|
2,587
|
private void inflateTable ( final int toSize ) { threshold = toSize ; keys = new String [ toSize ] ; values = new Object [ toSize ] ; }
|
Inflates the table .
|
2,588
|
public T getLogger ( final String name , final MessageFactory messageFactory ) { return getOrCreateInnerMap ( factoryKey ( messageFactory ) ) . get ( name ) ; }
|
Returns an ExtendedLogger .
|
2,589
|
public boolean hasLogger ( final String name , final MessageFactory messageFactory ) { return getOrCreateInnerMap ( factoryKey ( messageFactory ) ) . containsKey ( name ) ; }
|
Detects if a Logger with the specified name and MessageFactory exists .
|
2,590
|
public boolean hasLogger ( final String name , final Class < ? extends MessageFactory > messageFactoryClass ) { return getOrCreateInnerMap ( factoryClassKey ( messageFactoryClass ) ) . containsKey ( name ) ; }
|
Detects if a Logger with the specified name and MessageFactory type exists .
|
2,591
|
public static Logger getLogger ( String name ) { PaxLogger paxLogger ; if ( m_paxLogging == null ) { paxLogger = FallbackLogFactory . createFallbackLog ( null , name ) ; } else { paxLogger = m_paxLogging . getLogger ( name , LOG4J_FQCN ) ; } Logger logger = new Logger ( paxLogger ) ; m_loggers . put ( name , logger ) ; return logger ; }
|
Retrieve a logger by name . If the named logger already exists then the existing instance will be reutrned . Otherwise a new instance is created .
|
2,592
|
public void cleanUp ( ) { if ( outSocket != null ) { try { outSocket . close ( ) ; } catch ( Exception e ) { LogLog . error ( "Could not close outSocket." , e ) ; } outSocket = null ; } }
|
Close the UDP Socket and release the underlying connector thread if it has been created
|
2,593
|
private synchronized void doShutdown ( ) { active = false ; getLogger ( ) . debug ( "{} doShutdown called" , getName ( ) ) ; closeServerSocket ( ) ; closeAllAcceptedSockets ( ) ; if ( advertiseViaMulticastDNS ) { zeroConf . unadvertise ( ) ; } }
|
Does the actual shutting down by closing the server socket and any connected sockets that have been created .
|
2,594
|
private void closeServerSocket ( ) { getLogger ( ) . debug ( "{} closing server socket" , getName ( ) ) ; try { if ( serverSocket != null ) { serverSocket . close ( ) ; } } catch ( Exception e ) { } serverSocket = null ; }
|
Closes the server socket if created .
|
2,595
|
int findIndex ( final Job job ) { int size = jobList . size ( ) ; boolean found = false ; int i = 0 ; for ( ; i < size ; i ++ ) { ScheduledJobEntry se = ( ScheduledJobEntry ) jobList . get ( i ) ; if ( se . job == job ) { found = true ; break ; } } if ( found ) { return i ; } else { return - 1 ; } }
|
Find the index of a given job .
|
2,596
|
public synchronized boolean delete ( final Job job ) { if ( shutdown ) { return false ; } int i = findIndex ( job ) ; if ( i != - 1 ) { ScheduledJobEntry se = ( ScheduledJobEntry ) jobList . remove ( i ) ; if ( se . job != job ) { new IllegalStateException ( "Internal programming error" ) ; } if ( i == 0 ) { this . notifyAll ( ) ; } return true ; } else { return false ; } }
|
Delete the given job .
|
2,597
|
public synchronized void run ( ) { while ( ! shutdown ) { if ( jobList . isEmpty ( ) ) { linger ( ) ; } else { ScheduledJobEntry sje = ( ScheduledJobEntry ) jobList . get ( 0 ) ; long now = System . currentTimeMillis ( ) ; if ( now >= sje . desiredExecutionTime ) { executeInABox ( sje . job ) ; jobList . remove ( 0 ) ; if ( sje . period > 0 ) { sje . desiredExecutionTime = now + sje . period ; schedule ( sje ) ; } } else { linger ( sje . desiredExecutionTime - now ) ; } } } jobList . clear ( ) ; jobList = null ; System . out . println ( "Leaving scheduler run method" ) ; }
|
Run scheduler .
|
2,598
|
void executeInABox ( final Job job ) { try { job . execute ( ) ; } catch ( Exception e ) { System . err . println ( "The execution of the job threw an exception" ) ; e . printStackTrace ( System . err ) ; } }
|
We do not want a single failure to affect the whole scheduler .
|
2,599
|
protected void process ( BufferedReader bufferedReader ) throws IOException { Matcher eventMatcher ; Matcher exceptionMatcher ; String line ; while ( ( line = bufferedReader . readLine ( ) ) != null ) { eventMatcher = regexpPattern . matcher ( line ) ; if ( line . trim ( ) . equals ( "" ) ) { continue ; } exceptionMatcher = exceptionPattern . matcher ( line ) ; if ( eventMatcher . matches ( ) ) { LoggingEvent event = buildEvent ( ) ; if ( event != null ) { if ( passesExpression ( event ) ) { doPost ( event ) ; } } currentMap . putAll ( processEvent ( eventMatcher . toMatchResult ( ) ) ) ; } else if ( exceptionMatcher . matches ( ) ) { additionalLines . add ( line ) ; } else { if ( appendNonMatches ) { String lastTime = ( String ) currentMap . get ( TIMESTAMP ) ; if ( currentMap . size ( ) > 0 ) { LoggingEvent event = buildEvent ( ) ; if ( event != null ) { if ( passesExpression ( event ) ) { doPost ( event ) ; } } } if ( lastTime != null ) { currentMap . put ( TIMESTAMP , lastTime ) ; } currentMap . put ( MESSAGE , line ) ; } else { additionalLines . add ( line ) ; } } } LoggingEvent event = buildEvent ( ) ; if ( event != null ) { if ( passesExpression ( event ) ) { doPost ( event ) ; } } }
|
Read parse and optionally tail the log file converting entries into logging events .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.