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 p...
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;" ) ; els...
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 [...
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...
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 . findCluste...
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 . getMachineHas...
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 ( update...
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 = createClusterTarge...
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 ( serv...
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...
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...
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 fa...
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 . getServe...
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 {...
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 ( SocketE...
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 BadReque...
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 ; ...
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...
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 = _...
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 , _...
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 = getSmallHea...
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...
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/?...
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 ( )...
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 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 ) ; writeStringC...
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 ,...
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 ) != getFileSeparatorCh...
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 == ':' ...
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 ( ...
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 [ ]...
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 ...
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...
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 - threa...
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 , Tim...
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 (...
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 ...
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 ( ) ; c...
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 ) ; brea...
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 ) _mont...
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 . appen...
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 ...
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 + ye...
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 = _...
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 ...
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 ) _mon...
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 ) ...
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 GetStreamR...
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 !=...
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 ...
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 .