idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
15,800
public List < String > extractMetricNames ( ) { List < String > result = new ArrayList < > ( ) ; for ( MonitoringRule rule : monitoringRules . getMonitoringRules ( ) ) { for ( Action action : rule . getActions ( ) . getActions ( ) ) { if ( action . getName ( ) . equalsIgnoreCase ( "OutputMetric" ) ) { for ( Parameter parameter : action . getParameters ( ) ) { if ( parameter . getName ( ) . equalsIgnoreCase ( "metric" ) ) { result . add ( parameter . getValue ( ) ) ; } } } } } return result ; }
Helper method to extract metric names from Monitoring Rules
15,801
public static String escapeHtml ( String s ) { if ( s == null ) return null ; StringBuilder cb = new StringBuilder ( ) ; int lineCharacter = 0 ; boolean startsWithSpace = false ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char ch = s . charAt ( i ) ; lineCharacter ++ ; if ( ch == '<' ) cb . append ( "&lt;" ) ; else if ( ch == '&' ) cb . append ( "&amp;" ) ; else if ( ch == '\n' || ch == '\r' ) { lineCharacter = 0 ; cb . append ( ch ) ; startsWithSpace = false ; } else if ( lineCharacter > 70 && ch == ' ' && ! startsWithSpace ) { lineCharacter = 0 ; cb . append ( '\n' ) ; for ( ; i + 1 < s . length ( ) && s . charAt ( i + 1 ) == ' ' ; i ++ ) { } } else if ( lineCharacter == 1 && ( ch == ' ' || ch == '\t' ) ) { cb . append ( ( char ) ch ) ; startsWithSpace = true ; } else cb . append ( ch ) ; } return cb . toString ( ) ; }
Escapes special symbols in a string . For example < becomes &lt ;
15,802
public static void inc ( byte [ ] nonce , byte value ) { int i = nonce . length - 1 ; nonce [ i ] += value ; if ( value > 0 && ( nonce [ i ] < 0 || nonce [ i ] >= value ) ) return ; if ( value < 0 && ( nonce [ i ] < 0 && nonce [ i ] >= value ) ) return ; for ( i = i - 1 ; i >= 0 ; i -- ) { nonce [ i ] ++ ; if ( nonce [ i ] != 0 ) break ; } }
Increases nonce by value which is used as an unsigned byte value .
15,803
public < T > T run ( long timeout , TimeUnit unit , Consumer < Result < T > > task ) { try ( OutboxAmp outbox = OutboxAmp . currentOrCreate ( this ) ) { ResultFuture < T > future = new ResultFuture < > ( ) ; task . accept ( future ) ; return future . get ( timeout , unit ) ; } }
Run a task that returns a future in an outbox context .
15,804
public String address ( Class < ? > api , String address ) { Objects . requireNonNull ( address ) ; if ( address . isEmpty ( ) ) { address = addressDefault ( api ) ; } int slash = address . indexOf ( "/" ) ; if ( address . endsWith ( ":" ) && slash < 0 ) { address += "//" ; } int p = address . indexOf ( "://" ) ; int q = - 1 ; if ( p > 0 ) { q = address . indexOf ( '/' , p + 3 ) ; } if ( address . indexOf ( '{' ) > 0 ) { return addressBraces ( api , address ) ; } boolean isPrefix = address . startsWith ( "session:" ) || address . startsWith ( "pod:" ) ; if ( address . isEmpty ( ) || p > 0 && q < 0 && isPrefix ) { if ( Vault . class . isAssignableFrom ( api ) ) { TypeRef itemRef = TypeRef . of ( api ) . to ( Vault . class ) . param ( "T" ) ; Class < ? > assetClass = itemRef . rawClass ( ) ; address = address + "/" + apiAddress ( assetClass ) ; } else { address = address + "/" + apiAddress ( api ) ; } } return address ; }
Calculate address from an API with an address default
15,805
public ServiceRefAmp bind ( ServiceRefAmp service , String address ) { if ( log . isLoggable ( Level . FINEST ) ) { log . finest ( L . l ( "bind {0} for {1} in {2}" , address , service . api ( ) . getType ( ) , this ) ) ; } address = toCanonical ( address ) ; registry ( ) . bind ( address , service ) ; return service ; }
Publish reusing the mailbox for an existing service .
15,806
private boolean isSeedHeartbeatValid ( ) { boolean isSeed = false ; for ( ServerHeartbeat server : _serverSelf . getCluster ( ) . getSeedServers ( ) ) { if ( server . port ( ) > 0 ) { isSeed = true ; if ( server . isUp ( ) ) { return true ; } } } return ! isSeed ; }
Returns true if one of the cluster seeds is an active server .
15,807
public UpdateRackHeartbeat join ( String extAddress , int extPort , String clusterId , String address , int port , int portBartender , String displayName , String serverHash , int seedIndex ) { Objects . requireNonNull ( extAddress ) ; Objects . requireNonNull ( address ) ; ClusterHeartbeat cluster = _root . findCluster ( clusterId ) ; if ( cluster == null ) { cluster = _root . createCluster ( clusterId ) ; log . fine ( "Heartbeat create new cluster " + clusterId ) ; } boolean isSSL = false ; ServerHeartbeat server = cluster . createDynamicServer ( address , port , isSSL ) ; ClusterTarget clusterTarget = null ; RackHeartbeat rack = server . getRack ( ) ; if ( rack == null ) { rack = getRack ( cluster , address ) ; server = rack . createServer ( address , port , isSSL ) ; log . fine ( "join-server" + " int=" + address + ":" + port + ";" + portBartender + " " + displayName + " hash=" + serverHash + " ext=" + extAddress + ":" + extPort + " (" + _serverSelf . getDisplayName ( ) + ")" ) ; } if ( cluster != _serverSelf . getCluster ( ) ) { server . toKnown ( ) ; clusterTarget = createClusterTarget ( cluster ) ; if ( clusterTarget . addServer ( server ) ) { } } server . setPortBartender ( portBartender ) ; if ( extAddress != null ) { _serverSelf . setSeedIndex ( seedIndex ) ; _serverSelf . setLastSeedTime ( CurrentTime . currentTime ( ) ) ; _serverSelf . update ( ) ; } if ( server . isSelf ( ) ) { joinSelf ( server , extAddress , extPort , address , port , serverHash ) ; } server . clearConnectionFailTime ( ) ; server . update ( ) ; updateHeartbeats ( ) ; if ( server . isSelf ( ) ) { return null ; } else if ( clusterId . equals ( _serverSelf . getClusterId ( ) ) ) { return server . getRack ( ) . getUpdate ( ) ; } else { return _serverSelf . getRack ( ) . getUpdate ( ) ; } }
joinServer message to an external configured address from a new server including SelfServer .
15,808
private void joinSelf ( ServerHeartbeat server , String extAddress , int extPort , String address , int port , String serverHash ) { if ( server != _serverSelf ) { throw new IllegalStateException ( L . l ( "Invalid self: {0} vs {1}" , server , _serverSelf ) ) ; } if ( ! serverHash . equals ( _serverSelf . getMachineHash ( ) ) ) { throw new IllegalStateException ( L . l ( "Invalid server hash {0} against {1}:{2}({3})" , _serverSelf , address , port , serverHash ) ) ; } if ( port != _serverSelf . port ( ) ) { throw new IllegalStateException ( L . l ( "Invalid server port {0} against {1}:{2}({3})" , _serverSelf , address , port , serverHash ) ) ; } boolean isSSL = false ; ServerHeartbeat extServer = getCluster ( ) . createServer ( extAddress , extPort , isSSL ) ; server . setExternalServer ( extServer ) ; server . setMachineHash ( serverHash ) ; server . getRack ( ) . update ( server . getUpdate ( ) ) ; heartbeatStart ( server ) ; updateHubHeartbeatSelf ( ) ; log . fine ( "join self " + server ) ; }
received a join from this server . Used to update external IPs .
15,809
public void hubHeartbeat ( UpdateServerHeartbeat updateServer , UpdateRackHeartbeat updateRack , UpdatePodSystem updatePod , long sourceTime ) { RackHeartbeat rack = getCluster ( ) . findRack ( updateRack . getId ( ) ) ; if ( rack == null ) { rack = getRack ( ) ; } updateRack ( updateRack ) ; updateServerStart ( updateServer ) ; updateTargetServers ( ) ; PodHeartbeatService podHeartbeat = getPodHeartbeat ( ) ; if ( podHeartbeat != null && updatePod != null ) { podHeartbeat . updatePodSystem ( updatePod ) ; } _joinState = _joinState . onHubHeartbeat ( this ) ; updateHeartbeats ( ) ; }
Heartbeat from a hub server includes the heartbeat status of its rack .
15,810
private void updateHubHeartbeatSelf ( ) { _isHubHeartbeatSelf = true ; if ( _hubHeartbeatCount < 2 ) { for ( Result < Boolean > result : _hubHeartbeatList ) { result . ok ( true ) ; } _hubHeartbeatList . clear ( ) ; } }
If the join is to the self server and there s only one successful join update immediately .
15,811
void updateRack ( UpdateRackHeartbeat updateRack ) { ClusterHeartbeat cluster = findCluster ( updateRack . getClusterId ( ) ) ; if ( cluster == null ) { return ; } RackHeartbeat rack ; if ( cluster != _serverSelf . getCluster ( ) ) { rack = cluster . createRack ( "external" ) ; ClusterTarget target = createClusterTarget ( cluster ) ; } else { rack = cluster . findRack ( updateRack . getId ( ) ) ; } if ( rack == null ) { return ; } rack . updateRack ( this , updateRack ) ; updateHeartbeats ( ) ; }
Process an update message for a rack of servers .
15,812
private void updateServerStart ( UpdateServerHeartbeat update ) { boolean isSSL = false ; ServerHeartbeat server = _root . createServer ( update . getAddress ( ) , update . getPort ( ) , isSSL , 0 , getCluster ( ) ) ; server . setDisplayName ( update . getDisplayName ( ) ) ; updateServer ( server , update ) ; if ( server . getRack ( ) != null ) { server . getRack ( ) . update ( ) ; } }
Update a server where the update is directly from the peer .
15,813
void updateServer ( ServerHeartbeat server , UpdateServerHeartbeat update ) { if ( server . isSelf ( ) ) { return ; } String externalId = update . getExternalId ( ) ; updateExternal ( server , externalId ) ; server . setSeedIndex ( update . getSeedIndex ( ) ) ; if ( server . onHeartbeatUpdate ( update ) ) { if ( server . isUp ( ) ) { onServerStart ( server ) ; } else { onServerStop ( server ) ; } } }
Update a server with a heartbeat update .
15,814
private void updateExternal ( ServerHeartbeat server , String externalId ) { if ( externalId != null ) { ServerHeartbeat serverExternal = _root . getServer ( externalId ) ; server . setExternalServer ( serverExternal ) ; } else { server . setExternalServer ( null ) ; } }
Update the external server delegation .
15,815
private void onServerLinkClose ( String hostName ) { ServerHeartbeat server = _root . getServer ( hostName ) ; if ( server == null ) { return ; } if ( ! isHub ( server ) && ! isHub ( _serverSelf ) ) { return ; } if ( server . onHeartbeatStop ( ) ) { onServerStop ( server ) ; if ( server . getRack ( ) != null ) { server . getRack ( ) . update ( ) ; } updateHeartbeats ( ) ; } }
The peer server is now down .
15,816
private boolean isHub ( ServerBartender server ) { int upCount = 0 ; for ( ServerHeartbeat rackServer : _rack . getServers ( ) ) { if ( rackServer == null || ! rackServer . isUp ( ) ) { continue ; } if ( rackServer == server && upCount < _hubCount ) { return true ; } upCount ++ ; if ( _hubCount <= upCount ) { return false ; } } return false ; }
Test if the server is a hub server for its rack .
15,817
private void sendHubHeartbeats ( ) { RackHeartbeat rack = _rack ; UpdateRackHeartbeat updateRack = rack . getUpdate ( ) ; UpdatePodSystem updatePod = getUpdatePodSystem ( ) ; long now = CurrentTime . currentTime ( ) ; if ( ! isJoinComplete ( ) ) { updatePod = null ; } for ( ServerHeartbeat rackServer : _rack . getServers ( ) ) { if ( rackServer == null || rackServer == _serverSelf ) { continue ; } ServerTarget target = createTargetServer ( rackServer ) ; target . hubHeartbeat ( getServerSelf ( ) . getUpdate ( ) , updateRack , updatePod , now ) ; } }
Sends full heartbeat messages to all targets . Hub heartbeat messages contains all the servers in the hub and all the pods known to the hub server .
15,818
private void sendSpokeHeartbeats ( ) { for ( ServerTarget target : _targets ) { ServerHeartbeat server = target . getServer ( ) ; if ( server . getRack ( ) != _rack ) { continue ; } if ( isHub ( server ) ) { target . sendServerHeartbeat ( getServerSelf ( ) . getUpdate ( ) ) ; } } }
Sends a server status message to the hub servers . The server message contains the status for the current server .
15,819
public static boolean isAvailable ( ) { try { return create ( ) != null ; } catch ( Exception e ) { log . log ( Level . FINEST , e . toString ( ) , e ) ; return false ; } }
Checks if the heap is available
15,820
public void cleanup ( ) { state = null ; if ( headerBuffer != null ) { bufferPool . deallocate ( headerBuffer ) ; } if ( dataBuffer != null ) { bufferPool . deallocate ( dataBuffer ) ; } }
De - allocates all buffers . This method should be called iff the reader isn t used anymore i . e . when its connection is severed .
15,821
void clusterHeartbeat ( String clusterId , UpdateServerHeartbeat updateSelf , UpdateRackHeartbeat updateRack , UpdatePodSystem updatePod , long sequence ) { if ( startUpdate ( updateRack , updatePod ) ) { getHeartbeat ( ) . clusterHeartbeat ( clusterId , updateSelf , updateRack , updatePod , sequence ) ; } }
Sends a cluster heartbeat message if the update has changed or it s time for a periodic heartbeat .
15,822
void hubHeartbeat ( UpdateServerHeartbeat updateServer , UpdateRackHeartbeat updateRack , UpdatePodSystem updatePod , long sequence ) { if ( startUpdate ( updateRack , updatePod ) ) { getHeartbeat ( ) . hubHeartbeat ( updateServer , updateRack , updatePod , sequence ) ; } }
Sends a hub heartbeat message if the update has changed or it s time for a periodic heartbeat .
15,823
private boolean startUpdate ( UpdateRackHeartbeat updateRack , UpdatePodSystem updatePod ) { long now = CurrentTime . currentTime ( ) ; if ( _lastHubTime + getTimeout ( ) < now ) { } else if ( _lastRackCrc != updateRack . getCrc ( ) ) { } else if ( updatePod != null && _lastPodCrc != updatePod . getCrc ( ) ) { } else { return false ; } _lastHubTime = now ; _lastRackCrc = updateRack . getCrc ( ) ; if ( updatePod != null ) { _lastPodCrc = updatePod . getCrc ( ) ; } return true ; }
Only send updates on changes or timeouts .
15,824
public int owner ( int hash ) { NodePodAmp delegate = delegate ( ) ; if ( delegate != null ) { return delegate ( ) . owner ( hash ) ; } else { return 0 ; } }
The owner index for the node .
15,825
public void run ( ) { try { while ( ! isClosed ( ) && _is . read ( ) > 0 && _in . readMessage ( _is ) ) { ServiceRef . flushOutbox ( ) ; } } catch ( EOFException e ) { log . finer ( this + " end of file" ) ; if ( log . isLoggable ( Level . ALL ) ) { log . log ( Level . ALL , e . toString ( ) , e ) ; } } catch ( SocketException e ) { e . printStackTrace ( ) ; log . finer ( this + " socket closed:" + e ) ; if ( log . isLoggable ( Level . ALL ) ) { log . log ( Level . ALL , e . toString ( ) , e ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; throw new RuntimeException ( e ) ; } catch ( Throwable e ) { e . printStackTrace ( ) ; throw e ; } finally { close ( ) ; } }
Receive messages from the client
15,826
protected CharSequence getHost ( ) { if ( _host != null ) return _host ; if ( _uriHost . length ( ) > 0 ) { _host = _uriHost ; } else if ( ( _host = getForwardedHostHeader ( ) ) != null ) { } else { _host = getHostHeader ( ) ; } return _host ; }
Returns the virtual host of the request
15,827
private CharSequence hostInvocation ( ) throws IOException { if ( _host != null ) { } else if ( _uriHost . length ( ) > 0 ) { _host = _uriHost ; } else if ( ( _host = getForwardedHostHeader ( ) ) != null ) { } else if ( ( _host = getHostHeader ( ) ) != null ) { } else if ( HTTP_1_1 <= version ( ) ) { throw new BadRequestException ( L . l ( "HTTP/1.1 requires a Host header (Remote IP={0})" , connTcp ( ) . ipRemote ( ) ) ) ; } return _host ; }
Returns the virtual host from the invocation
15,828
public String header ( String key ) { CharSegment buf = getHeaderBuffer ( key ) ; if ( buf != null ) return buf . toString ( ) ; else return null ; }
Returns the header .
15,829
public CharSegment getHeaderBuffer ( char [ ] testBuf , int length ) { char [ ] keyBuf = _headerBuffer ; CharSegment [ ] headerKeys = _headerKeys ; char [ ] toLowerAscii = _toLowerAscii ; for ( int i = _headerSize - 1 ; i >= 0 ; i -- ) { CharSegment key = headerKeys [ i ] ; if ( key . length ( ) != length ) continue ; int offset = key . offset ( ) ; int j ; for ( j = length - 1 ; j >= 0 ; j -- ) { char a = testBuf [ j ] ; char b = keyBuf [ offset + j ] ; if ( a == b ) { continue ; } else if ( toLowerAscii [ a ] != toLowerAscii [ b ] ) { break ; } } if ( j < 0 ) { return _headerValues [ i ] ; } } return null ; }
Returns the matching header .
15,830
public CharSegment getHeaderBuffer ( String key ) { int i = matchNextHeader ( 0 , key ) ; if ( i >= 0 ) { return _headerValues [ i ] ; } else { return null ; } }
Returns the header value for the key returned as a CharSegment .
15,831
public void getHeaderBuffers ( String key , ArrayList < CharSegment > values ) { int i = - 1 ; while ( ( i = matchNextHeader ( i + 1 , key ) ) >= 0 ) { values . add ( _headerValues [ i ] ) ; } }
Fills an ArrayList with the header values matching the key .
15,832
public Enumeration < String > getHeaders ( String key ) { ArrayList < String > values = new ArrayList < String > ( ) ; int i = - 1 ; while ( ( i = matchNextHeader ( i + 1 , key ) ) >= 0 ) { values . add ( _headerValues [ i ] . toString ( ) ) ; } return Collections . enumeration ( values ) ; }
Return an enumeration of headers matching a key .
15,833
private int matchNextHeader ( int i , String key ) { int size = _headerSize ; int length = key . length ( ) ; char [ ] keyBuf = _headerBuffer ; char [ ] toLowerAscii = _toLowerAscii ; for ( ; i < size ; i ++ ) { CharSegment header = _headerKeys [ i ] ; if ( header . length ( ) != length ) continue ; int offset = header . offset ( ) ; int j ; for ( j = 0 ; j < length ; j ++ ) { char a = key . charAt ( j ) ; char b = keyBuf [ offset + j ] ; if ( a == b ) { continue ; } else if ( toLowerAscii [ a ] != toLowerAscii [ b ] ) { break ; } } if ( j == length ) { return i ; } } return - 1 ; }
Returns the index of the next header matching the key .
15,834
public void setHeader ( String key , String value ) { int tail ; if ( _headerSize > 0 ) { tail = ( _headerValues [ _headerSize - 1 ] . offset ( ) + _headerValues [ _headerSize - 1 ] . length ( ) ) ; } else { tail = 0 ; } int keyLength = key . length ( ) ; int valueLength = value . length ( ) ; char [ ] headerBuffer = _headerBuffer ; for ( int i = keyLength - 1 ; i >= 0 ; i -- ) { headerBuffer [ tail + i ] = key . charAt ( i ) ; } _headerKeys [ _headerSize ] . init ( headerBuffer , tail , keyLength ) ; tail += keyLength ; for ( int i = valueLength - 1 ; i >= 0 ; i -- ) { headerBuffer [ tail + i ] = value . charAt ( i ) ; } _headerValues [ _headerSize ] . init ( headerBuffer , tail , valueLength ) ; _headerSize ++ ; }
Adds a new header . Used only by the caching to simulate If - Modified - Since .
15,835
private boolean parseRequest ( ) throws IOException { try { ReadStream is = connTcp ( ) . readStream ( ) ; if ( ! readRequest ( is ) ) { clearRequest ( ) ; return false ; } _sequence = connHttp ( ) . nextSequenceRead ( ) ; if ( log . isLoggable ( Level . FINE ) ) { log . fine ( _method + " " + new String ( _uri , 0 , _uriLength ) + " " + _protocol + " (" + dbgId ( ) + ")" ) ; log . fine ( "Remote-IP: " + connTcp ( ) . addressRemote ( ) + ":" + connTcp ( ) . portRemote ( ) + " (" + dbgId ( ) + ")" ) ; } parseHeaders ( is ) ; return true ; } catch ( ClientDisconnectException e ) { throw e ; } catch ( SocketTimeoutException e ) { log . log ( Level . FINER , e . toString ( ) , e ) ; return false ; } catch ( ArrayIndexOutOfBoundsException e ) { log . log ( Level . FINEST , e . toString ( ) , e ) ; throw new BadRequestException ( L . l ( "Invalid request: URL or headers are too long" ) , e ) ; } catch ( Throwable e ) { log . log ( Level . FINEST , e . toString ( ) , e ) ; throw new BadRequestException ( String . valueOf ( e ) , e ) ; } }
Parses a http request .
15,836
protected void initRequest ( ) { super . initRequest ( ) ; _state = _state . toActive ( ) ; HttpBufferStore bufferStore = getHttpBufferStore ( ) ; _method . clear ( ) ; _methodString = null ; _protocol . clear ( ) ; _uriLength = 0 ; if ( bufferStore == null ) { _uri = getSmallUriBuffer ( ) ; _headerBuffer = getSmallHeaderBuffer ( ) ; _headerKeys = getSmallHeaderKeys ( ) ; _headerValues = getSmallHeaderValues ( ) ; } _uriHost . clear ( ) ; _host = null ; _keepalive = KeepaliveState . INIT ; _headerSize = 0 ; _headerLength = 0 ; _inOffset = 0 ; _isChunkedIn = false ; _isFirst = true ; }
Clear the request variables in preparation for a new request .
15,837
public void onTimeout ( ) { try { if ( true ) throw new UnsupportedOperationException ( ) ; } catch ( Exception e ) { log . log ( Level . FINEST , e . toString ( ) , e ) ; } closeResponse ( ) ; }
Handles a timeout .
15,838
@ Path ( "{uuid}" ) public Penalty getPenaltyByUuid ( @ PathParam ( "uuid" ) UUID uuid ) { logger . debug ( "StartOf getPenaltyByUuid - REQUEST for /penalties/{}" , uuid ) ; PenaltyHelperE penaltyRestHelper = getPenaltyHelper ( ) ; Penalty result = penaltyRestHelper . getPenaltyByUuid ( uuid ) ; logger . debug ( "EndOf getPenaltyByUuid" ) ; return result ; }
Returns the information of an specific penalty given an uuid .
15,839
public List < Penalty > getPenalties ( @ QueryParam ( "agreementId" ) String agreementId , @ QueryParam ( "guaranteeTerm" ) String guaranteeTerm , @ QueryParam ( "begin" ) DateParam begin , @ QueryParam ( "end" ) DateParam end ) throws InternalException { logger . debug ( "StartOf getPenalties REQUEST for /penalties/?agreementId={}&guaranteeTerm={}&begin={}&end={}" , agreementId , guaranteeTerm , begin , end ) ; Date dBegin = ( begin == null ) ? null : begin . getDate ( ) ; Date dEnd = ( end == null ) ? null : end . getDate ( ) ; PenaltyHelperE penaltyRestHelper = getPenaltyHelper ( ) ; List < Penalty > penalties ; try { penalties = penaltyRestHelper . getPenalties ( agreementId , guaranteeTerm , dBegin , dEnd ) ; } catch ( ParserHelperException e ) { throw new InternalException ( e . getMessage ( ) ) ; } logger . debug ( "EndOf getPenalties" ) ; return penalties ; }
Search penalties given several query terms .
15,840
public final ClientSocketFactory getLoadBalanceSocketPool ( ) { ClientSocketFactory factory = getLoadBalanceSocketFactory ( ) ; if ( factory == null ) return null ; if ( _serverBartender . getState ( ) . isDisableSoft ( ) ) { factory . enableSessionOnly ( ) ; } else if ( _serverBartender . getState ( ) . isDisabled ( ) ) { factory . disable ( ) ; } else { factory . enable ( ) ; } return factory ; }
Returns the socket pool as a load - balancer .
15,841
boolean onHeartbeatStop ( ) { SocketPool clusterSocketPool ; if ( isExternal ( ) ) { clusterSocketPool = _clusterSocketPool . getAndSet ( null ) ; } else { clusterSocketPool = _clusterSocketPool . get ( ) ; } if ( clusterSocketPool != null ) { clusterSocketPool . getFactory ( ) . notifyHeartbeatStop ( ) ; } log . fine ( "notify-heartbeat-stop " + this ) ; return true ; }
Notify that a stop event has been received .
15,842
public void close ( ) { SocketPool loadBalancePool = _loadBalanceSocketPool . get ( ) ; if ( loadBalancePool != null ) loadBalancePool . getFactory ( ) . close ( ) ; SocketPool clusterPool = _clusterSocketPool . get ( ) ; if ( clusterPool != null ) clusterPool . getFactory ( ) . close ( ) ; }
Close any ports .
15,843
public void schema ( Class < ? > type ) { Objects . requireNonNull ( type ) ; _context . schema ( type ) ; }
Adds a predefined schema
15,844
public static long getRandomLong ( ) { Random random = getRandom ( ) ; long value = random . nextLong ( ) ; if ( ! _isTest ) { _freeRandomList . free ( random ) ; } return value ; }
Returns the next random long .
15,845
public static int nextInt ( int n ) { Random random = getRandom ( ) ; int value = random . nextInt ( n ) ; if ( ! _isTest ) _freeRandomList . free ( random ) ; return value ; }
Returns the next random int .
15,846
public static double nextDouble ( ) { Random random = getRandom ( ) ; double value = random . nextDouble ( ) ; if ( ! _isTest ) _freeRandomList . free ( random ) ; return value ; }
Returns the next random double between 0 and 1
15,847
public static Random getRandom ( ) { if ( _isTest ) { return _testRandom ; } Random random = _freeRandomList . allocate ( ) ; if ( random == null ) { random = new SecureRandom ( ) ; } return random ; }
Returns the random generator .
15,848
public void writeChunk ( long length , boolean isFinal ) { long chunk ; if ( isFinal ) { chunk = length << 1 ; } else { chunk = ( length << 1 ) + 1 ; } writeUnsigned ( chunk ) ; }
chunked header . LSB
15,849
public void writeStringData ( String value , int offset , int length ) { char [ ] cBuf = _charBuffer ; int cBufLength = cBuf . length ; for ( int i = 0 ; i < length ; i += cBufLength ) { int sublen = Math . min ( length - i , cBufLength ) ; value . getChars ( offset + i , offset + i + sublen , cBuf , 0 ) ; writeStringChunk ( cBuf , 0 , sublen ) ; } }
string data without length
15,850
public void writeBinaryData ( byte [ ] sBuf , int sOffset , int sLength ) { byte [ ] tBuf = _buffer ; int tOffset = _offset ; int tLength = tBuf . length ; int end = sOffset + sLength ; while ( sOffset < end ) { if ( tLength - tOffset < 1 ) { tOffset = flush ( tOffset ) ; } int sublen = Math . min ( tLength - tOffset , end - sOffset ) ; System . arraycopy ( sBuf , sOffset , tBuf , tOffset , sublen ) ; tOffset += sublen ; sOffset += sublen ; } _offset = tOffset ; }
binary data without type or length
15,851
private void require ( int len ) { int offset = _offset ; int length = _length ; if ( offset + len < length ) { return ; } flush ( _offset ) ; }
Require empty space in the output buffer .
15,852
private int flush ( int offset ) { try { _os . write ( _buffer , 0 , offset ) ; _offset = 0 ; return 0 ; } catch ( IOException e ) { throw new H3ExceptionOut ( e ) ; } }
Flush the buffer and set the offset to zero .
15,853
public void writeRef ( int ref ) { require ( 1 ) ; _buffer [ _offset ++ ] = ( byte ) ConstH3 . REF ; writeUnsigned ( ref ) ; }
write graph reference
15,854
public final PathImpl lookup ( URL url ) { String name = URLDecoder . decode ( url . toString ( ) ) ; return lookup ( name , null ) ; }
Looks up a path by a URL .
15,855
public String lookupRelativeNativePath ( PathImpl path ) { String thisNative = getNativePath ( ) ; String pathNative = path . getNativePath ( ) ; if ( pathNative . startsWith ( thisNative ) ) { int i = thisNative . length ( ) ; while ( i < pathNative . length ( ) ) { if ( pathNative . charAt ( i ) != getFileSeparatorChar ( ) ) break ; i ++ ; } return i == pathNative . length ( ) ? "" : pathNative . substring ( i ) ; } else return pathNative ; }
Returns a native path relative to this native path if the passed path is relative to this path or an absolute path if the passed path is not relative to this path .
15,856
public ArrayList < PathImpl > getResources ( String name ) { ArrayList < PathImpl > list = new ArrayList < PathImpl > ( ) ; PathImpl path = lookup ( name ) ; if ( path . exists ( ) ) list . add ( path ) ; return list ; }
Looks up all the resources matching a name . ( Generally only useful with MergePath .
15,857
public ArrayList < PathImpl > getResources ( ) { ArrayList < PathImpl > list = new ArrayList < PathImpl > ( ) ; list . add ( this ) ; return list ; }
Looks up all the existing resources . ( Generally only useful with MergePath .
15,858
protected String scanScheme ( String uri ) { int i = 0 ; if ( uri == null ) return null ; int length = uri . length ( ) ; if ( length == 0 ) return null ; int ch = uri . charAt ( 0 ) ; if ( ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z' ) { for ( i = 1 ; i < length ; i ++ ) { ch = uri . charAt ( i ) ; if ( ch == ':' ) return uri . substring ( 0 , i ) . toLowerCase ( Locale . ENGLISH ) ; if ( ! ( ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z' || ch >= '0' && ch <= '0' || ch == '+' || ch == '-' || ch == '.' ) ) break ; } } return null ; }
Returns the scheme portion of a uri . Since schemes are case - insensitive normalize them to lower case .
15,859
public boolean isWindowsInsecure ( ) { String lower = getPath ( ) . toLowerCase ( Locale . ENGLISH ) ; int lastCh ; if ( ( lastCh = lower . charAt ( lower . length ( ) - 1 ) ) == '.' || lastCh == ' ' || lastCh == '*' || lastCh == '?' || ( ( lastCh == '/' || lastCh == '\\' ) && ! isDirectory ( ) ) || lower . endsWith ( "::$data" ) || isWindowsSpecial ( lower , "/con" ) || isWindowsSpecial ( lower , "/aux" ) || isWindowsSpecial ( lower , "/prn" ) || isWindowsSpecial ( lower , "/nul" ) || isWindowsSpecial ( lower , "/com1" ) || isWindowsSpecial ( lower , "/com2" ) || isWindowsSpecial ( lower , "/com3" ) || isWindowsSpecial ( lower , "/com4" ) || isWindowsSpecial ( lower , "/lpt1" ) || isWindowsSpecial ( lower , "/lpt2" ) || isWindowsSpecial ( lower , "/lpt3" ) ) { return true ; } return false ; }
Returns true for windows security issues .
15,860
public Iterator < String > iterator ( ) throws IOException { String list [ ] = list ( ) ; if ( list == null ) list = new String [ 0 ] ; return new ArrayIterator ( list ) ; }
Returns a jdk1 . 2 Iterator for the contents of this directory .
15,861
public boolean removeAll ( ) throws IOException { if ( isDirectory ( ) && ! isLink ( ) ) { String [ ] list = list ( ) ; for ( int i = 0 ; i < list . length ; i ++ ) { PathImpl subpath = lookup ( list [ i ] ) ; subpath . removeAll ( ) ; } } return remove ( ) ; }
Removes the all files and directories below this path .
15,862
public boolean createNewFile ( ) throws IOException { synchronized ( LOCK ) { if ( ! exists ( ) ) { clearStatusCache ( ) ; WriteStreamOld s = openWrite ( ) ; s . close ( ) ; return true ; } } return false ; }
Creates the file named by this Path and returns true if the file is new .
15,863
public long getCrc64 ( ) { try { if ( isDirectory ( ) ) { String [ ] list = list ( ) ; long digest = 0x1 ; for ( int i = 0 ; i < list . length ; i ++ ) { digest = Crc64 . generate ( digest , list [ i ] ) ; } return digest ; } else if ( canRead ( ) ) { ReadStreamOld is = openRead ( ) ; try { long digest = 0x1 ; byte [ ] buffer = is . buffer ( ) ; while ( is . fillBuffer ( ) > 0 ) { int length = is . getLength ( ) ; digest = Crc64 . generate ( digest , buffer , 0 , length ) ; } return digest ; } finally { is . close ( ) ; } } else { return 0 ; } } catch ( IOException e ) { e . printStackTrace ( ) ; return - 1 ; } }
Returns the crc64 code .
15,864
void put ( RowCursor cursor ) { boolean isValid ; do { isValid = true ; try ( JournalOutputStream os = openItem ( ) ) { os . write ( CODE_PUT ) ; cursor . writeJournal ( os ) ; isValid = os . complete ( ) ; } catch ( IOException e ) { log . log ( Level . FINER , e . toString ( ) , e ) ; } } while ( ! isValid ) ; }
Writes the put to the journal .
15,865
void remove ( RowCursor cursor ) { boolean isValid ; do { isValid = true ; try ( JournalOutputStream os = openItem ( ) ) { os . write ( CODE_REMOVE ) ; cursor . getKey ( _buffer , 0 ) ; os . write ( _buffer , 0 , getKeyLength ( ) ) ; try { BitsUtil . writeLong ( os , cursor . getVersion ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } isValid = os . complete ( ) ; } } while ( ! isValid ) ; }
Writes the remove to the journal .
15,866
private MultivaluedMapWrapper < String , IGuaranteeTerm > initTermsMap ( IAgreement agreement ) { MultivaluedMapWrapper < String , IGuaranteeTerm > result = new MultivaluedMapWrapper < String , IGuaranteeTerm > ( ) ; for ( IGuaranteeTerm term : agreement . getGuaranteeTerms ( ) ) { String variable = constraintEvaluator . getConstraintVariable ( term . getServiceLevel ( ) ) ; result . add ( variable , term ) ; } return result ; }
Inits a MultivaluedMap with metrickey as key and the terms that evaluate the metrickey as values .
15,867
public boolean accept ( SocketBar socket ) throws IOException { JniSocketImpl jniSocket = ( JniSocketImpl ) socket ; if ( _fd == 0 ) throw new IOException ( "accept from closed socket" ) ; return jniSocket . accept ( this , _fd , _socketTimeout ) ; }
Accepts a new connection from the socket .
15,868
public void setIdleMax ( int idleMax ) { if ( idleMax <= _idleMin ) { throw new IllegalArgumentException ( L . l ( "idle-max '{0}' must be greater than idle-min '{1}'." , idleMax , _idleMin ) ) ; } _launcher . setIdleMax ( _idleMax ) ; }
Returns the thread idle max .
15,869
public boolean schedule ( Runnable task ) { ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; boolean isPriority = false ; boolean isQueue = true ; boolean isWake = true ; return scheduleImpl ( task , loader , MAX_EXPIRE , isPriority , isQueue , isWake ) ; }
Schedules a new task .
15,870
private void wakeThreads ( int count ) { while ( true ) { int taskCount = Math . max ( 0 , _taskCount . get ( ) ) ; int spinIdleCount = _spinIdleCount . get ( ) ; long threadWakeHead = _threadWakeHead . get ( ) ; long threadWakeTail = _threadWakeTail . get ( ) ; long threadCount = spinIdleCount + threadWakeHead - threadWakeTail ; if ( taskCount <= threadCount ) { return ; } if ( count <= threadCount ) { return ; } ThreadAmp thread = _idleThreadRing . poll ( ) ; if ( thread == null ) { return ; } if ( _threadWakeHead . compareAndSet ( threadWakeHead , threadWakeHead + 1 ) ) { thread . setWakeThread ( ) ; LockSupport . unpark ( thread ) ; } else { _idleThreadRing . offer ( thread ) ; } } }
wake enough threads to process the tasks
15,871
public void clearIdleThreads ( ) { _launcher . resetThrottle ( ) ; int idleCount = _idleThreadRing . size ( ) ; ThreadAmp thread ; while ( idleCount -- > 0 && ( thread = _idleThreadRing . poll ( ) ) != null ) { thread . close ( ) ; } }
interrupts all the idle threads .
15,872
public void start ( ) { if ( _lifecycle . isActive ( ) ) { return ; } synchronized ( _lifecycle ) { if ( ! _lifecycle . toInit ( ) ) { return ; } init ( _stubMain ) ; } start ( _stubMain ) ; }
Start is called lazily when a service is first used .
15,873
private void init ( StubAmp stub ) { OnInitMessage onInitMsg = new OnInitMessage ( this ) ; _queue . offer ( onInitMsg ) ; _queue . wake ( ) ; }
Init calls the
15,874
public void shutdown ( ShutdownModeAmp mode ) { if ( ! _lifecycle . toStopping ( ) ) { return ; } _lifecycle . toDestroy ( ) ; OnShutdownMessage shutdownMessage = new OnShutdownMessage ( this , mode , isSingle ( ) ) ; _queue . offer ( shutdownMessage ) ; _queue . wakeAllAndWait ( ) ; shutdownMessage . waitFor ( 1 , TimeUnit . SECONDS ) ; super . shutdown ( mode ) ; try ( OutboxAmp outbox = OutboxAmp . currentOrCreate ( manager ( ) ) ) { Object ctx = outbox . getAndSetContext ( this ) ; try { outbox . flush ( ) ; if ( ! isSingle ( ) ) { _worker . shutdown ( mode ) ; } } finally { outbox . getAndSetContext ( ctx ) ; } } }
Closes the inbox
15,875
public void setLocalTime ( long time ) { if ( _timeZone != _gmtTimeZone ) { calculateSplit ( time ) ; } else { calculateSplit ( time - _localTimeZone . getRawOffset ( ) ) ; try { long offset = _localTimeZone . getOffset ( GregorianCalendar . AD , ( int ) _year , ( int ) _month , ( int ) _dayOfMonth + 1 , getDayOfWeek ( ) , ( int ) _timeOfDay ) ; calculateSplit ( time - offset ) ; } catch ( Exception e ) { log . log ( Level . FINE , e . toString ( ) , e ) ; } } }
Sets the time in milliseconds since the epoch and calculate the internal variables .
15,876
public long getLocalTime ( ) { if ( _timeZone != _gmtTimeZone ) { return _localTimeOfEpoch ; } else { long offset = _localTimeZone . getOffset ( GregorianCalendar . AD , ( int ) _year , ( int ) _month , ( int ) _dayOfMonth + 1 , getDayOfWeek ( ) , ( int ) _timeOfDay ) ; return _localTimeOfEpoch + offset ; } }
Returns the time in milliseconds since the epoch .
15,877
public void setMonth ( int month ) { if ( month < 0 || DAYS_IN_MONTH . length <= month ) return ; _month = month ; if ( DAYS_IN_MONTH [ month ] <= _dayOfMonth ) _dayOfMonth = DAYS_IN_MONTH [ month ] - 1 ; calculateJoin ( ) ; calculateSplit ( _localTimeOfEpoch ) ; }
Sets the month in the year .
15,878
public int getWeek ( ) { int dow4th = ( int ) ( ( _dayOfEpoch - _dayOfYear + 3 ) % 7 + 10 ) % 7 ; int ww1monday = 3 - dow4th ; if ( _dayOfYear < ww1monday ) return 53 ; int week = ( _dayOfYear - ww1monday ) / 7 + 1 ; if ( _dayOfYear >= 360 ) { int days = 365 + ( _isLeapYear ? 1 : 0 ) ; long nextNewYear = ( _dayOfEpoch - _dayOfYear + days ) ; int dowNext4th = ( int ) ( ( nextNewYear + 3 ) % 7 + 10 ) % 7 ; int nextWw1Monday = 3 - dowNext4th ; if ( days <= _dayOfYear - nextWw1Monday ) return 1 ; } return week ; }
Returns the week in the year .
15,879
public long get ( int field ) { switch ( field ) { case TIME : return getLocalTime ( ) ; case YEAR : return getYear ( ) ; case MONTH : return getMonth ( ) ; case DAY_OF_MONTH : return getDayOfMonth ( ) ; case DAY : return getDayOfWeek ( ) ; case DAY_OF_WEEK : return getDayOfWeek ( ) ; case HOUR : return getHour ( ) ; case MINUTE : return getMinute ( ) ; case SECOND : return getSecond ( ) ; case MILLISECOND : return getMillisecond ( ) ; case TIME_ZONE : return getZoneOffset ( ) / 1000 ; default : return Long . MAX_VALUE ; } }
Gets values based on a field .
15,880
public long set ( int field , long value ) { switch ( field ) { case YEAR : setYear ( ( int ) value ) ; break ; case MONTH : setMonth ( ( int ) value ) ; break ; case DAY_OF_MONTH : setDayOfMonth ( ( int ) value ) ; break ; case HOUR : setHour ( ( int ) value ) ; break ; case MINUTE : setMinute ( ( int ) value ) ; break ; case SECOND : setSecond ( ( int ) value ) ; break ; case MILLISECOND : setMillisecond ( value ) ; break ; default : throw new RuntimeException ( ) ; } return _localTimeOfEpoch ; }
Sets values based on a field .
15,881
public void printDate ( WriteStreamOld os ) throws IOException { os . print ( DAY_NAMES [ ( int ) ( _dayOfEpoch % 7 + 11 ) % 7 ] ) ; os . write ( ',' ) ; os . write ( ' ' ) ; os . print ( ( _dayOfMonth + 1 ) / 10 ) ; os . print ( ( _dayOfMonth + 1 ) % 10 ) ; os . write ( ' ' ) ; os . print ( MONTH_NAMES [ ( int ) _month ] ) ; os . write ( ' ' ) ; os . print ( _year ) ; os . write ( ' ' ) ; os . print ( ( _timeOfDay / 36000000 ) % 10 ) ; os . print ( ( _timeOfDay / 3600000 ) % 10 ) ; os . write ( ':' ) ; os . print ( ( _timeOfDay / 600000 ) % 6 ) ; os . print ( ( _timeOfDay / 60000 ) % 10 ) ; os . write ( ':' ) ; os . print ( ( _timeOfDay / 10000 ) % 6 ) ; os . print ( ( _timeOfDay / 1000 ) % 10 ) ; if ( _zoneName == null ) { os . print ( " GMT" ) ; return ; } long offset = _zoneOffset ; if ( offset < 0 ) { os . write ( ' ' ) ; os . write ( '-' ) ; offset = - offset ; } else { os . write ( ' ' ) ; os . write ( '+' ) ; } os . print ( ( offset / 36000000 ) % 10 ) ; os . print ( ( offset / 3600000 ) % 10 ) ; os . print ( ( offset / 600000 ) % 6 ) ; os . print ( ( offset / 60000 ) % 10 ) ; os . write ( ' ' ) ; os . write ( '(' ) ; os . print ( _zoneName ) ; os . write ( ')' ) ; }
Prints the date to a stream .
15,882
public String printISO8601 ( ) { StringBuilder sb = new StringBuilder ( ) ; if ( _year > 0 ) { sb . append ( ( _year / 1000 ) % 10 ) ; sb . append ( ( _year / 100 ) % 10 ) ; sb . append ( ( _year / 10 ) % 10 ) ; sb . append ( _year % 10 ) ; sb . append ( '-' ) ; sb . append ( ( ( _month + 1 ) / 10 ) % 10 ) ; sb . append ( ( _month + 1 ) % 10 ) ; sb . append ( '-' ) ; sb . append ( ( ( _dayOfMonth + 1 ) / 10 ) % 10 ) ; sb . append ( ( _dayOfMonth + 1 ) % 10 ) ; } long time = _timeOfDay / 1000 ; long ms = _timeOfDay % 1000 ; sb . append ( 'T' ) ; sb . append ( ( time / 36000 ) % 10 ) ; sb . append ( ( time / 3600 ) % 10 ) ; sb . append ( ':' ) ; sb . append ( ( time / 600 ) % 6 ) ; sb . append ( ( time / 60 ) % 10 ) ; sb . append ( ':' ) ; sb . append ( ( time / 10 ) % 6 ) ; sb . append ( ( time / 1 ) % 10 ) ; if ( ms != 0 ) { sb . append ( '.' ) ; sb . append ( ( ms / 100 ) % 10 ) ; sb . append ( ( ms / 10 ) % 10 ) ; sb . append ( ms % 10 ) ; } if ( _zoneName == null ) { sb . append ( "Z" ) ; return sb . toString ( ) ; } long offset = _zoneOffset ; if ( offset < 0 ) { sb . append ( "-" ) ; offset = - offset ; } else sb . append ( "+" ) ; sb . append ( ( offset / 36000000 ) % 10 ) ; sb . append ( ( offset / 3600000 ) % 10 ) ; sb . append ( ':' ) ; sb . append ( ( offset / 600000 ) % 6 ) ; sb . append ( ( offset / 60000 ) % 10 ) ; return sb . toString ( ) ; }
Prints the time in ISO 8601
15,883
public String printISO8601Date ( ) { CharBuffer cb = new CharBuffer ( ) ; if ( _year > 0 ) { cb . append ( ( _year / 1000 ) % 10 ) ; cb . append ( ( _year / 100 ) % 10 ) ; cb . append ( ( _year / 10 ) % 10 ) ; cb . append ( _year % 10 ) ; cb . append ( '-' ) ; cb . append ( ( ( _month + 1 ) / 10 ) % 10 ) ; cb . append ( ( _month + 1 ) % 10 ) ; cb . append ( '-' ) ; cb . append ( ( ( _dayOfMonth + 1 ) / 10 ) % 10 ) ; cb . append ( ( _dayOfMonth + 1 ) % 10 ) ; } return cb . toString ( ) ; }
Prints just the date component of ISO 8601
15,884
public synchronized static String formatGMT ( long gmtTime , String format ) { _gmtDate . setGMTTime ( gmtTime ) ; return _gmtDate . format ( new CharBuffer ( ) , format ) . toString ( ) ; }
Formats a date .
15,885
public String format ( String format ) { CharBuffer cb = new CharBuffer ( ) ; return format ( cb , format ) . close ( ) ; }
Formats the current date .
15,886
private long yearToDayOfEpoch ( long year ) { if ( year > 0 ) { year -= 1601 ; return ( 365 * year + year / 4 - year / 100 + year / 400 - ( ( 1970 - 1601 ) * 365 + ( 1970 - 1601 ) / 4 - 3 ) ) ; } else { year = 2000 - year ; return ( ( 2000 - 1970 ) * 365 + ( 2000 - 1970 ) / 4 - ( 365 * year + year / 4 - year / 100 + year / 400 ) ) ; } }
Based on the year return the number of days since the epoch .
15,887
private long monthToDayOfYear ( long month , boolean isLeapYear ) { long day = 0 ; for ( int i = 0 ; i < month && i < 12 ; i ++ ) { day += DAYS_IN_MONTH [ i ] ; if ( i == 1 && isLeapYear ) day ++ ; } return day ; }
Calculates the day of the year for the beginning of the month .
15,888
public long setDate ( long year , long month , long day ) { year += ( long ) Math . floor ( month / 12.0 ) ; month -= ( long ) 12 * Math . floor ( month / 12.0 ) ; _year = year ; _month = month ; _dayOfMonth = day - 1 ; calculateJoin ( ) ; calculateSplit ( _localTimeOfEpoch ) ; return _localTimeOfEpoch ; }
Sets date in the local time .
15,889
private void calculateSplit ( long localTime ) { _localTimeOfEpoch = localTime ; _dayOfEpoch = divFloor ( _localTimeOfEpoch , MS_PER_DAY ) ; _timeOfDay = _localTimeOfEpoch - MS_PER_DAY * _dayOfEpoch ; calculateYear ( ) ; calculateMonth ( ) ; _hour = _timeOfDay / 3600000 ; _minute = _timeOfDay / 60000 % 60 ; _second = _timeOfDay / 1000 % 60 ; _ms = _timeOfDay % 1000 ; if ( _timeZone == _gmtTimeZone ) { _isDaylightTime = false ; _zoneName = _stdName ; _zoneOffset = 0 ; } else { long tempOffset = _timeZone . getOffset ( _localTimeOfEpoch ) ; _zoneOffset = _timeZone . getOffset ( _localTimeOfEpoch - tempOffset ) ; if ( _zoneOffset == _timeZone . getRawOffset ( ) ) { _isDaylightTime = false ; _zoneName = _stdName ; } else { _isDaylightTime = true ; _zoneName = _dstName ; } } _calendar . setTimeInMillis ( _localTimeOfEpoch ) ; }
Calculate and set the calendar components based on the given time .
15,890
private void calculateYear ( ) { long days = _dayOfEpoch ; days += ( 1970 - 1601 ) * 365 + ( 1970 - 1601 ) / 4 - 3 ; long n400 = divFloor ( days , 400 * 365 + 100 - 3 ) ; days -= n400 * ( 400 * 365 + 100 - 3 ) ; long n100 = divFloor ( days , 100 * 365 + 25 - 1 ) ; if ( n100 == 4 ) n100 = 3 ; days -= n100 * ( 100 * 365 + 25 - 1 ) ; long n4 = divFloor ( days , 4 * 365 + 1 ) ; if ( n4 == 25 ) n4 = 24 ; days -= n4 * ( 4 * 365 + 1 ) ; long n1 = divFloor ( days , 365 ) ; if ( n1 == 4 ) n1 = 3 ; _year = 400 * n400 + 100 * n100 + 4 * n4 + n1 + 1601 ; _dayOfYear = ( int ) ( days - 365 * n1 ) ; _isLeapYear = isLeapYear ( _year ) ; }
Calculates the year the dayOfYear and whether this is a leap year from the current days since the epoch .
15,891
private void calculateMonth ( ) { _dayOfMonth = _dayOfYear ; for ( _month = 0 ; _month < 12 ; _month ++ ) { if ( _month == 1 && _isLeapYear ) { if ( _dayOfMonth < 29 ) return ; else _dayOfMonth -= 29 ; } else if ( _dayOfMonth < DAYS_IN_MONTH [ ( int ) _month ] ) return ; else _dayOfMonth -= DAYS_IN_MONTH [ ( int ) _month ] ; } }
Calculates the month based on the day of the year .
15,892
private long calculateJoin ( ) { _year += divFloor ( _month , 12 ) ; _month -= 12 * divFloor ( _month , 12 ) ; _localTimeOfEpoch = MS_PER_DAY * ( yearToDayOfEpoch ( _year ) + monthToDayOfYear ( _month , isLeapYear ( _year ) ) + _dayOfMonth ) ; _localTimeOfEpoch += _ms + 1000 * ( _second + 60 * ( _minute + 60 * _hour ) ) ; return _localTimeOfEpoch ; }
Based on the current data calculate the time since the epoch .
15,893
public boolean logModified ( Logger log ) { for ( int i = _dependencyList . size ( ) - 1 ; i >= 0 ; i -- ) { Dependency dependency = _dependencyList . get ( i ) ; if ( dependency . logModified ( log ) ) return true ; } return false ; }
Log the reason for the modification
15,894
public void getSafe ( RowCursor cursor , Result < Boolean > result ) { result . ok ( getImpl ( cursor ) ) ; }
Non - peek get .
15,895
public void getStream ( RowCursor cursor , Result < GetStreamResult > result ) { long version = cursor . getVersion ( ) ; PageLeafImpl leaf = getLeafByCursor ( cursor ) ; if ( leaf == null ) { result . ok ( new GetStreamResult ( false , null ) ) ; return ; } if ( ! leaf . get ( cursor ) ) { result . ok ( new GetStreamResult ( false , null ) ) ; return ; } if ( version == cursor . getVersion ( ) ) { result . ok ( new GetStreamResult ( true , null ) ) ; return ; } StreamSource ss = leaf . getStream ( cursor , this ) ; boolean isFound = ss != null ; result . ok ( new GetStreamResult ( isFound , ss ) ) ; }
For cluster calls returns a stream to the new value if the value has changed .
15,896
long getSequenceSize ( SegmentKelp segment ) { int tailPid = _tailPid . get ( ) ; long size = 0 ; for ( int i = 0 ; i <= tailPid ; i ++ ) { Page page = _pages . get ( i ) ; if ( page != null && page . getSegment ( ) == segment ) { size += page . size ( ) ; } } return size ; }
Returns the size in bytes of all pages with the given sequence .
15,897
public void checkpoint ( Result < Boolean > result ) { if ( ! _journalStream . saveStart ( ) ) { result . ok ( true ) ; return ; } TableWriterService readWrite = _table . getReadWrite ( ) ; int tailPid = _tailPid . get ( ) ; for ( int pid = 1 ; pid <= tailPid ; pid ++ ) { Page page = _pages . get ( pid ) ; if ( page != null ) { page . write ( _table , this , readWrite ) ; } } readWrite . fsync ( new CheckpointResult ( result ) ) ; }
Requests a checkpoint flushing the in - memory data to disk .
15,898
boolean compareAndSetLeaf ( Page oldPage , Page page ) { if ( oldPage == page ) { return true ; } int pid = ( int ) page . getId ( ) ; updateTailPid ( pid ) ; if ( oldPage instanceof PageLeafImpl && page instanceof PageLeafImpl ) { PageLeafImpl oldLeaf = ( PageLeafImpl ) oldPage ; PageLeafImpl newLeaf = ( PageLeafImpl ) page ; if ( BlockTree . compareKey ( oldLeaf . getMaxKey ( ) , newLeaf . getMaxKey ( ) , 0 ) < 0 ) { System . err . println ( " DERP: " + oldPage + " " + page ) ; Thread . dumpStack ( ) ; } } boolean result = _pages . compareAndSet ( pid , oldPage , page ) ; return result ; }
Updates the leaf to a new page . Called only from TableService .
15,899
public static DynamicClassLoader getDynamicClassLoader ( ClassLoader loader ) { for ( ; loader != null ; loader = loader . getParent ( ) ) { if ( loader instanceof DynamicClassLoader ) { return ( DynamicClassLoader ) loader ; } } return null ; }
Returns the topmost dynamic class loader .