idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
139,200 | public IndexedSet < T > universe ( ) { IntSet allItems = indices . empty ( ) ; allItems . fill ( 0 , indexToItem . length - 1 ) ; return createFromIndices ( allItems ) ; } | Returns the collection of all possible elements | 49 | 7 |
139,201 | boolean expiringSoon ( TokenInfo info ) { // TODO(jasonhall): Consider varying the definition of "soon" based on the // original expires_in value (e.g., "soon" = 1/10th of the total time before // it's expired). return Double . valueOf ( info . getExpires ( ) ) < ( clock . now ( ) + TEN_MINUTES ) ; } | Returns whether or not the token will be expiring within the next ten minutes . | 90 | 16 |
139,202 | public DataBulkRequest insertBefore ( CRUDRequest request , CRUDRequest before ) { this . requests . add ( requests . indexOf ( before ) , request ) ; return this ; } | Inserts a request before another specified request . This guarantees that the first request parameter will be executed sequentially before the second request parameter . It does not guarantee consecutive execution . | 40 | 34 |
139,203 | public DataBulkRequest insertAfter ( CRUDRequest request , CRUDRequest after ) { this . requests . add ( requests . indexOf ( after ) + 1 , request ) ; return this ; } | Inserts a request after another specified request . This guarantees that the first request parameter will be executed sequentially after the second request parameter . It does not guarantee consecutive execution . | 42 | 34 |
139,204 | public static String readFileToString ( File file , final Charset charset ) throws IOException { String line = null ; BufferedReader reader = getBufferReader ( file , charset ) ; StringBuffer strBuffer = new StringBuffer ( ) ; while ( ( line = reader . readLine ( ) ) != null ) { strBuffer . append ( line ) ; } return strBuffer . toString ( ) ; } | Read file to string string . | 88 | 6 |
139,205 | public static void writeStringToFile ( File file , String content ) throws IOException { OutputStream outputStream = getOutputStream ( file ) ; outputStream . write ( content . getBytes ( ) ) ; } | Write string to file . | 44 | 5 |
139,206 | public static String getEncodingFileName ( String fn ) { try { return URLEncoder . encode ( fn , "UTF-8" ) ; } catch ( UnsupportedEncodingException e ) { throw new ValidationLibException ( "unSupported fiel encoding : " + e . getMessage ( ) , HttpStatus . INTERNAL_SERVER_ERROR ) ; } } | Gets encoding file name . | 82 | 6 |
139,207 | public static void initFileSendHeader ( HttpServletResponse res , String filename , String contentType ) { filename = getEncodingFileName ( filename ) ; if ( contentType != null ) { res . setContentType ( contentType ) ; } else { res . setContentType ( "applicaiton/download;charset=utf-8" ) ; } res . setHeader ( "Content-Disposition" , "attachment; filename=\"" + filename + "\";" ) ; res . setHeader ( "Content-Transfer-Encoding" , "binary" ) ; res . setHeader ( "file-name" , filename ) ; } | Init file send header . | 141 | 5 |
139,208 | public static DataError fromJson ( ObjectNode node ) { DataError error = new DataError ( ) ; JsonNode x = node . get ( "data" ) ; if ( x != null ) { error . entityData = x ; } x = node . get ( "errors" ) ; if ( x instanceof ArrayNode ) { error . errors = new ArrayList <> ( ) ; for ( Iterator < JsonNode > itr = ( ( ArrayNode ) x ) . elements ( ) ; itr . hasNext ( ) ; ) { error . errors . add ( Error . fromJson ( itr . next ( ) ) ) ; } } return error ; } | Parses a Json object node and returns the DataError corresponding to it . It is up to the client to make sure that the object node is a DataError representation . Any unrecognized elements are ignored . | 145 | 43 |
139,209 | public static DataError findErrorForDoc ( List < DataError > list , JsonNode node ) { for ( DataError x : list ) { if ( x . entityData == node ) { return x ; } } return null ; } | Returns the data error for the given json doc in the list | 50 | 12 |
139,210 | public void setMarkers ( QueryResult queryResult ) { mapWidget . clearMarkers ( ) ; RecordList recordList = queryResult . getRecordList ( ) ; List < RecordList . Record > records = recordList . getRecords ( ) ; List < GenericMarker > markers = new ArrayList < GenericMarker > ( ) ; final MarkerCoordinateSource markerCoordinateSource1 = getMarkerCoordinateSource ( ) ; final MarkerDisplayFilter markerFilter = getMarkerDisplayFilter ( ) ; markerFilter . init ( ) ; for ( final RecordList . Record record : records ) { MapMarkerBuilder markerBuilder = new MapMarkerBuilder ( ) ; final MarkerCoordinateSource . LatitudeLongitude latitudeLongitude = markerCoordinateSource1 . process ( record ) ; double lat = latitudeLongitude . getLatitude ( ) ; double lon = latitudeLongitude . getLongitude ( ) ; if ( markerFilter . filter ( record ) ) { GenericMarker < RecordList . Record > marker = markerBuilder . setMarkerLat ( lat ) . setMarkerLon ( lon ) . setMarkerIconPathBuilder ( getMarkerIconPathBuilder ( ) ) . createMarker ( record , mapWidget ) ; marker . setupMarkerHoverLabel ( getMarkerHoverLabelBuilder ( ) ) ; marker . setupMarkerClickInfoWindow ( getMarkerClickInfoWindow ( ) ) ; marker . addClickHandler ( new GenericMarker . MarkerCallBackEventHandler < GenericMarker > ( ) { @ Override public void run ( GenericMarker sourceElement ) { clientFactory . getEventBus ( ) . fireEvent ( new MarkerClickEvent ( record ) ) ; } } ) ; markers . add ( marker ) ; } } mapWidget . setMarkers ( markers ) ; } | Contain logic for getting records building marker from results Called on start and when filters are changed | 390 | 18 |
139,211 | public Uri getUri ( ) { if ( uri == null ) { try { uri = uriBuilder . build ( ) ; } catch ( Exception e ) { throw new IllegalStateException ( "Could not build the URI." , e ) ; } } return uri ; } | Get the URI identifying the resource . | 60 | 7 |
139,212 | private < T > void setupMarkerFixedNoRepeatHack ( GoogleV3Marker < T > genericMarker ) { final Marker marker1 = genericMarker . getMarker ( ) ; final LatLng [ ] initialPosition = new LatLng [ 1 ] ; marker1 . addDragStartHandler ( new DragStartMapHandler ( ) { @ Override public void onEvent ( DragStartMapEvent dragStartMapEvent ) { initialPosition [ 0 ] = marker1 . getPosition ( ) ; } } ) ; marker1 . addDragEndHandler ( new DragEndMapHandler ( ) { @ Override public void onEvent ( DragEndMapEvent dragEndMapEvent ) { marker1 . setPosition ( initialPosition [ 0 ] ) ; } } ) ; } | Prevent marker from repeating horizontally by setting marker drag and adjusting drag behaviour to reset | 163 | 16 |
139,213 | public void setComparator ( Column < T , ? > column , Comparator < T > comparator ) { columnSortHandler . setComparator ( column , comparator ) ; } | Sets a comparator to use when sorting the given column | 38 | 12 |
139,214 | String toUrl ( Auth . UrlCodex urlCodex ) { return new StringBuilder ( authUrl ) . append ( authUrl . contains ( "?" ) ? "&" : "?" ) . append ( "client_id" ) . append ( "=" ) . append ( urlCodex . encode ( clientId ) ) . append ( "&" ) . append ( "response_type" ) . append ( "=" ) . append ( "token" ) . append ( "&" ) . append ( "scope" ) . append ( "=" ) . append ( scopesToString ( urlCodex ) ) . toString ( ) ; } | Returns a URL representation of this request appending the client ID and scopes to the original authUrl . | 139 | 21 |
139,215 | public synchronized static < T > T get ( Class < T > cType ) { if ( map . get ( cType ) != null ) { return cType . cast ( map . get ( cType ) ) ; } try { Object obj = cType . newInstance ( ) ; log . debug ( "[CREATE INSTANCE] : " + cType . getSimpleName ( ) ) ; map . put ( cType , obj ) ; return cType . cast ( obj ) ; } catch ( InstantiationException | IllegalAccessException e ) { log . debug ( e . getMessage ( ) ) ; } return null ; } | Get t . | 131 | 3 |
139,216 | public WriteStreamOld openWrite ( ) { if ( _cb != null ) _cb . clear ( ) ; else _cb = CharBuffer . allocate ( ) ; if ( _ws == null ) _ws = new WriteStreamOld ( this ) ; else _ws . init ( this ) ; try { _ws . setEncoding ( "utf-8" ) ; } catch ( UnsupportedEncodingException e ) { } return _ws ; } | Opens a write stream using this StringWriter as the resulting string | 94 | 13 |
139,217 | @ Override public void write ( byte [ ] buf , int offset , int length , boolean isEnd ) throws IOException { int end = offset + length ; while ( offset < end ) { int ch1 = buf [ offset ++ ] & 0xff ; if ( ch1 < 0x80 ) _cb . append ( ( char ) ch1 ) ; else if ( ( ch1 & 0xe0 ) == 0xc0 ) { if ( offset >= end ) throw new EOFException ( "unexpected end of file in utf8 character" ) ; int ch2 = buf [ offset ++ ] & 0xff ; if ( ( ch2 & 0xc0 ) != 0x80 ) throw new CharConversionException ( "illegal utf8 encoding" ) ; _cb . append ( ( char ) ( ( ( ch1 & 0x1f ) << 6 ) + ( ch2 & 0x3f ) ) ) ; } else if ( ( ch1 & 0xf0 ) == 0xe0 ) { if ( offset + 1 >= end ) throw new EOFException ( "unexpected end of file in utf8 character" ) ; int ch2 = buf [ offset ++ ] & 0xff ; int ch3 = buf [ offset ++ ] & 0xff ; if ( ( ch2 & 0xc0 ) != 0x80 ) throw new CharConversionException ( "illegal utf8 encoding" ) ; if ( ( ch3 & 0xc0 ) != 0x80 ) throw new CharConversionException ( "illegal utf8 encoding" ) ; _cb . append ( ( char ) ( ( ( ch1 & 0x1f ) << 12 ) + ( ( ch2 & 0x3f ) << 6 ) + ( ch3 & 0x3f ) ) ) ; } else throw new CharConversionException ( "illegal utf8 encoding at (" + ( int ) ch1 + ")" ) ; } } | Writes a utf - 8 encoded buffer to the underlying string . | 409 | 14 |
139,218 | 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 | 141 | 9 |
139,219 | 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 ( "<" ) ; else if ( ch == ' ' ) cb . append ( "&" ) ; else if ( ch == ' ' || ch == ' ' ) { lineCharacter = 0 ; cb . append ( ch ) ; startsWithSpace = false ; } else if ( lineCharacter > 70 && ch == ' ' && ! startsWithSpace ) { lineCharacter = 0 ; cb . append ( ' ' ) ; for ( ; i + 1 < s . length ( ) && s . charAt ( i + 1 ) == ' ' ; i ++ ) { } } else if ( lineCharacter == 1 && ( ch == ' ' || ch == ' ' ) ) { cb . append ( ( char ) ch ) ; startsWithSpace = true ; } else cb . append ( ch ) ; } return cb . toString ( ) ; } | Escapes special symbols in a string . For example < becomes < ; | 273 | 15 |
139,220 | 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 . | 122 | 14 |
139,221 | @ Override 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 . | 83 | 13 |
139,222 | @ Override public String address ( Class < ? > api , String address ) { Objects . requireNonNull ( address ) ; if ( address . isEmpty ( ) ) { address = addressDefault ( api ) ; } int slash = address . indexOf ( "/" ) ; //int colon = 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 | 299 | 11 |
139,223 | @ Override 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 . | 101 | 11 |
139,224 | 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 . | 84 | 13 |
139,225 | 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 ) ; //System.out.println("Unknown cluster for heartbeat join: " + cluster + " " + clusterId); //throw new IllegalStateException("UNKNOWN_CLUSTER: " + cluster + " " + clusterId); } boolean isSSL = false ; ServerHeartbeat server = cluster . createDynamicServer ( address , port , isSSL ) ; //server.setDisplayName(displayName); ClusterTarget clusterTarget = null ; // boolean isJoinCluster = false; RackHeartbeat rack = server . getRack ( ) ; if ( rack == null ) { rack = getRack ( cluster , address ) ; server = rack . createServer ( address , port , isSSL ) ; //server.setDisplayName(displayName); 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 ) ) { // isJoinCluster = true; } } server . setPortBartender ( portBartender ) ; if ( extAddress != null ) { // && ! extAddress.startsWith("127")) { _serverSelf . setSeedIndex ( seedIndex ) ; _serverSelf . setLastSeedTime ( CurrentTime . currentTime ( ) ) ; _serverSelf . update ( ) ; } if ( server . isSelf ( ) ) { joinSelf ( server , extAddress , extPort , address , port , serverHash ) ; } // clear the fail time, since the server is now up server . clearConnectionFailTime ( ) ; server . update ( ) ; updateHeartbeats ( ) ; if ( server . isSelf ( ) ) { // join to self return null ; } else if ( clusterId . equals ( _serverSelf . getClusterId ( ) ) ) { // join to own cluster return server . getRack ( ) . getUpdate ( ) ; } else { // join to foreign cluster return _serverSelf . getRack ( ) . getUpdate ( ) ; } } | joinServer message to an external configured address from a new server including SelfServer . | 623 | 16 |
139,226 | 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 ( ) ; //_podService.updatePodsFromHeartbeat(); log . fine ( "join self " + server ) ; } | received a join from this server . Used to update external IPs . | 296 | 14 |
139,227 | 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 ) ; // XXX: _podService.onUpdateFromPeer(updatePod); // rack.update(); updateTargetServers ( ) ; PodHeartbeatService podHeartbeat = getPodHeartbeat ( ) ; if ( podHeartbeat != null && updatePod != null ) { podHeartbeat . updatePodSystem ( updatePod ) ; } _joinState = _joinState . onHubHeartbeat ( this ) ; // updateHubHeartbeat(); updateHeartbeats ( ) ; } | Heartbeat from a hub server includes the heartbeat status of its rack . | 191 | 14 |
139,228 | 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 . | 65 | 18 |
139,229 | 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 . | 144 | 10 |
139,230 | private void updateServerStart ( UpdateServerHeartbeat update ) { // internal communication is non-ssl boolean isSSL = false ; ServerHeartbeat server = _root . createServer ( update . getAddress ( ) , update . getPort ( ) , isSSL , 0 , getCluster ( ) ) ; server . setDisplayName ( update . getDisplayName ( ) ) ; //server.setMachineHash(serverUpdate.getMachineHash()); updateServer ( server , update ) ; if ( server . getRack ( ) != null ) { server . getRack ( ) . update ( ) ; } } | Update a server where the update is directly from the peer . | 127 | 12 |
139,231 | void updateServer ( ServerHeartbeat server , UpdateServerHeartbeat update ) { if ( server . isSelf ( ) ) { return ; } String externalId = update . getExternalId ( ) ; updateExternal ( server , externalId ) ; // XXX: validation server . setSeedIndex ( update . getSeedIndex ( ) ) ; if ( server . onHeartbeatUpdate ( update ) ) { if ( server . isUp ( ) ) { onServerStart ( server ) ; } else { onServerStop ( server ) ; } } } | Update a server with a heartbeat update . | 114 | 8 |
139,232 | private void updateExternal ( ServerHeartbeat server , String externalId ) { if ( externalId != null ) { ServerHeartbeat serverExternal = _root . getServer ( externalId ) ; server . setExternalServer ( serverExternal ) ; } else { server . setExternalServer ( null ) ; /* if (serverExternal != null) { serverExternal.setDelegate(data); _root.updateSequence(); } */ } // data.setExternalId(externalId); } | Update the external server delegation . | 100 | 6 |
139,233 | 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 . | 113 | 7 |
139,234 | 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 . | 98 | 12 |
139,235 | private void sendHubHeartbeats ( ) { RackHeartbeat rack = _rack ; UpdateRackHeartbeat updateRack = rack . getUpdate ( ) ; UpdatePodSystem updatePod = getUpdatePodSystem ( ) ; long now = CurrentTime . currentTime ( ) ; if ( ! isJoinComplete ( ) ) { updatePod = null ; } // send hub update to all servers in the rack 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 . | 161 | 29 |
139,236 | 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 . | 83 | 22 |
139,237 | 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 | 48 | 7 |
139,238 | 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 . | 51 | 30 |
139,239 | 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 . | 77 | 20 |
139,240 | 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 . | 70 | 20 |
139,241 | 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 . | 153 | 9 |
139,242 | @ Override public int owner ( int hash ) { NodePodAmp delegate = delegate ( ) ; if ( delegate != null ) { return delegate ( ) . owner ( hash ) ; } else { return 0 ; } } | The owner index for the node . | 46 | 7 |
139,243 | @ Override 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 | 225 | 6 |
139,244 | @ Override 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 | 81 | 7 |
139,245 | 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 | 143 | 7 |
139,246 | @ Override public String header ( String key ) { CharSegment buf = getHeaderBuffer ( key ) ; if ( buf != null ) return buf . toString ( ) ; else return null ; } | Returns the header . | 42 | 4 |
139,247 | 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 . | 207 | 5 |
139,248 | @ Override 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 . | 50 | 14 |
139,249 | @ Override 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 . | 63 | 13 |
139,250 | @ Override 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 . | 88 | 10 |
139,251 | 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 . | 193 | 11 |
139,252 | @ Override 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 ++ ; // XXX: size } | Adds a new header . Used only by the caching to simulate If - Modified - Since . | 224 | 18 |
139,253 | 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 . | 328 | 7 |
139,254 | @ Override protected void initRequest ( ) { super . initRequest ( ) ; _state = _state . toActive ( ) ; // HttpBufferStore httpBuffer = getHttpBufferStore(); HttpBufferStore bufferStore = getHttpBufferStore ( ) ; _method . clear ( ) ; _methodString = null ; _protocol . clear ( ) ; _uriLength = 0 ; if ( bufferStore == null ) { // server/05h8 _uri = getSmallUriBuffer ( ) ; // httpBuffer.getUriBuffer(); _headerBuffer = getSmallHeaderBuffer ( ) ; // httpBuffer.getHeaderBuffer(); _headerKeys = getSmallHeaderKeys ( ) ; // httpBuffer.getHeaderKeys(); _headerValues = getSmallHeaderValues ( ) ; // httpBuffer.getHeaderValues(); } _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 . | 233 | 11 |
139,255 | @ Override public void onTimeout ( ) { try { //request().sendError(WebRequest.INTERNAL_SERVER_ERROR); if ( true ) throw new UnsupportedOperationException ( ) ; } catch ( Exception e ) { log . log ( Level . FINEST , e . toString ( ) , e ) ; } closeResponse ( ) ; } | Handles a timeout . | 76 | 5 |
139,256 | @ GET @ 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 . | 114 | 12 |
139,257 | @ GET 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 . | 241 | 7 |
139,258 | public final ClientSocketFactory getLoadBalanceSocketPool ( ) { ClientSocketFactory factory = getLoadBalanceSocketFactory ( ) ; if ( factory == null ) return null ; if ( _serverBartender . getState ( ) . isDisableSoft ( ) ) { factory . enableSessionOnly ( ) ; } else if ( _serverBartender . getState ( ) . isDisabled ( ) ) { // server/269g factory . disable ( ) ; } else { factory . enable ( ) ; } return factory ; } | Returns the socket pool as a load - balancer . | 110 | 11 |
139,259 | boolean onHeartbeatStop ( ) { SocketPool clusterSocketPool ; if ( isExternal ( ) ) { clusterSocketPool = _clusterSocketPool . getAndSet ( null ) ; } else { clusterSocketPool = _clusterSocketPool . get ( ) ; } if ( clusterSocketPool != null ) { clusterSocketPool . getFactory ( ) . notifyHeartbeatStop ( ) ; } /* if (! _heartbeatState.notifyHeartbeatStop()) { return false; } */ log . fine ( "notify-heartbeat-stop " + this ) ; return true ; } | Notify that a stop event has been received . | 125 | 10 |
139,260 | 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 . | 78 | 4 |
139,261 | @ Override public void schema ( Class < ? > type ) { Objects . requireNonNull ( type ) ; _context . schema ( type ) ; } | Adds a predefined schema | 32 | 5 |
139,262 | public static long getRandomLong ( ) { Random random = getRandom ( ) ; long value = random . nextLong ( ) ; if ( ! _isTest ) { _freeRandomList . free ( random ) ; } return value ; } | Returns the next random long . | 50 | 6 |
139,263 | 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 . | 50 | 6 |
139,264 | 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 | 47 | 9 |
139,265 | public static Random getRandom ( ) { if ( _isTest ) { return _testRandom ; } Random random = _freeRandomList . allocate ( ) ; if ( random == null ) { random = new SecureRandom ( ) ; } return random ; } | Returns the random generator . | 53 | 5 |
139,266 | @ Override public void writeChunk ( long length , boolean isFinal ) { long chunk ; if ( isFinal ) { chunk = length << 1 ; } else { chunk = ( length << 1 ) + 1 ; } writeUnsigned ( chunk ) ; } | chunked header . LSB | 54 | 7 |
139,267 | @ Override 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 | 120 | 4 |
139,268 | @ Override 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 | 154 | 6 |
139,269 | 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 . | 39 | 9 |
139,270 | 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 . | 51 | 11 |
139,271 | @ Override public void writeRef ( int ref ) { require ( 1 ) ; _buffer [ _offset ++ ] = ( byte ) ConstH3 . REF ; writeUnsigned ( ref ) ; } | write graph reference | 43 | 3 |
139,272 | public final PathImpl lookup ( URL url ) { String name = URLDecoder . decode ( url . toString ( ) ) ; return lookup ( name , null ) ; } | Looks up a path by a URL . | 36 | 8 |
139,273 | 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 . | 124 | 33 |
139,274 | 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 . | 60 | 17 |
139,275 | public ArrayList < PathImpl > getResources ( ) { ArrayList < PathImpl > list = new ArrayList < PathImpl > ( ) ; //if (exists()) list . add ( this ) ; return list ; } | Looks up all the existing resources . ( Generally only useful with MergePath . | 47 | 15 |
139,276 | 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 >= ' ' && ch <= ' ' || ch >= ' ' && ch <= ' ' ) { for ( i = 1 ; i < length ; i ++ ) { ch = uri . charAt ( i ) ; if ( ch == ' ' ) return uri . substring ( 0 , i ) . toLowerCase ( Locale . ENGLISH ) ; if ( ! ( ch >= ' ' && ch <= ' ' || ch >= ' ' && ch <= ' ' || ch >= ' ' && ch <= ' ' || ch == ' ' || ch == ' ' || ch == ' ' ) ) break ; } } return null ; } | Returns the scheme portion of a uri . Since schemes are case - insensitive normalize them to lower case . | 194 | 22 |
139,277 | 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 . | 251 | 7 |
139,278 | public Iterator < String > iterator ( ) throws IOException { String list [ ] = list ( ) ; // Avoids NPE when subclasses override list() and // possibly return null, e.g. JarPath. if ( list == null ) list = new String [ 0 ] ; return new ArrayIterator ( list ) ; } | Returns a jdk1 . 2 Iterator for the contents of this directory . | 69 | 16 |
139,279 | 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 . | 79 | 11 |
139,280 | 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 . | 56 | 17 |
139,281 | 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 ; // Depend requires -1 } } catch ( IOException e ) { // XXX: log e . printStackTrace ( ) ; return - 1 ; } } | Returns the crc64 code . | 204 | 7 |
139,282 | 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 . | 96 | 8 |
139,283 | 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 . | 126 | 8 |
139,284 | 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 . | 122 | 23 |
139,285 | @ Override 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 . | 69 | 9 |
139,286 | 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 . | 84 | 6 |
139,287 | 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 . | 75 | 7 |
139,288 | 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 { // avoid duplicate wake _idleThreadRing . offer ( thread ) ; } } } | wake enough threads to process the tasks | 217 | 7 |
139,289 | 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 . | 73 | 8 |
139,290 | @ Override 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 . | 65 | 12 |
139,291 | private void init ( StubAmp stub ) { //BuildMessageAmp buildMessage = new BuildMessageAmp(this); OnInitMessage onInitMsg = new OnInitMessage ( this ) ; _queue . offer ( onInitMsg ) ; _queue . wake ( ) ; } | Init calls the | 59 | 3 |
139,292 | @ Override public void shutdown ( ShutdownModeAmp mode ) { if ( ! _lifecycle . toStopping ( ) ) { return ; } _lifecycle . toDestroy ( ) ; OnShutdownMessage shutdownMessage = new OnShutdownMessage ( this , mode , isSingle ( ) ) ; _queue . offer ( shutdownMessage ) ; // _queue.close(); /* for (Actor<?> actorProcessor : _queueActors) { actorProcessor.close(); } */ _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 ) ; } } // XXX: _worker.shutdown(ShutdownModeAmp.IMMEDIATE); } | Closes the inbox | 239 | 4 |
139,293 | public void setLocalTime ( long time ) { // If this is a local time zone date, just set the time if ( _timeZone != _gmtTimeZone ) { calculateSplit ( time ) ; } // If this is a GMT date, convert from local to GMT 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 . | 171 | 15 |
139,294 | public long getLocalTime ( ) { // If this is a local time zone date, just set the time if ( _timeZone != _gmtTimeZone ) { return _localTimeOfEpoch ; } // If this is a GMT date, convert from local to GMT 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 . | 127 | 9 |
139,295 | 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 . | 87 | 8 |
139,296 | 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 . | 196 | 7 |
139,297 | 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 . | 156 | 8 |
139,298 | 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 . | 147 | 8 |
139,299 | 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 . | 422 | 8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.