SWDownloadCandidate.java

Index Score
phex.download.swarming
Phex

View: Reasons, Metrics, Source Code

These are the metrics that contribute to the Enerjy Score for this file, ranked by impact. So the metrics listed at the top influence the score to a greater extent that the metrics listed at the bottom.

MetricDescription
LINE_COMMENTNumber of line comments
DECL_COMMENTSComments in declarations
EXEC_COMMENTSComments in executable code
SIZESize of the file in bytes
LINESNumber of lines in the source file
COMMENTSComment lines
LOCLines of code
CYCLOMATICCyclomatic complexity
JAVA0117JAVA0117 Missing javadoc: method 'method'
DOC_COMMENTNumber of javadoc comment lines
FUNCTIONSNumber of function declarations
ELOCEffective lines of code
EXITSProcedure exits
LOGICAL_LINESNumber of statements
RETURNSNumber of return points from functions
BLOCKSNumber of blocks
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
COMPARISONSNumber of comparison operators
UNIQUE_OPERANDSNumber of unique operands
INTERFACE_COMPLEXITYInterface complexity
PROGRAM_VOCABHalstead program vocabulary
OPERATORSNumber of operators
PROGRAM_LENGTHHalstead program length
OPERANDSNumber of operands
JAVA0031JAVA0031 Case statement not properly closed
PARAMSNumber of formal parameter declarations
JAVA0034JAVA0034 Missing braces in if statement
JAVA0177JAVA0177 Variable declaration missing initializer
UNIQUE_OPERATORSNumber of unique operators
WHITESPACENumber of whitespace lines
PROGRAM_VOLUMEHalstead program volume
JAVA0259JAVA0259 Return of collection/array field
JAVA0136JAVA0136 N methods defined in class (maximum: M)
JAVA0032JAVA0032 Switch statement missing default
JAVA0126JAVA0126 Method declares unchecked exception in throws
JAVA0264JAVA0264 Integer math in long context - check for overflow
JAVA0100JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0254JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0145JAVA0145 Tab character used in source file
/* * PHEX - The pure-java Gnutella-servent. * Copyright (C) 2001 - 2008 Phex Development Group * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * --- SVN Information --- * $Id: SWDownloadCandidate.java 4231 2008-07-15 16:01:10Z gregork $ */ package phex.download.swarming; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import org.apache.commons.httpclient.URI; import org.apache.commons.httpclient.URIException; import phex.common.AlternateLocation; import phex.common.URN; import phex.common.address.DefaultDestAddress; import phex.common.address.DestAddress; import phex.common.address.MalformedDestAddressException; import phex.common.log.LogBuffer; import phex.common.log.LogRecord; import phex.common.log.NLogger; import phex.download.DownloadScope; import phex.download.DownloadScopeList; import phex.download.RemoteFile; import phex.event.ChangeEvent; import phex.event.PhexEventTopics; import phex.http.HTTPRangeSet; import phex.http.Range; import phex.http.XQueueParameters; import phex.msg.GUID; import phex.net.repres.PresentationManager; import phex.prefs.core.DownloadPrefs; import phex.query.QueryHitHost; import phex.servent.Servent; import phex.utils.URLCodecUtils; import phex.utils.URLUtil; import phex.xml.XMLUtils; import phex.xml.sax.downloads.DDownloadCandidate; /** * A representation of a download candidate. A download candidate contains all * information required for a given endpoint that can offer us data for download. * <p> * */ public class SWDownloadCandidate implements SWDownloadConstants { /** * The value of the candidate status constants are used for sorting * therefore status values should be kept in a reasonable order. */ public enum CandidateStatus { // Indicating the candidate is ignored from further processing IGNORED, // Indicating the candidate is ignored from further processing BAD, // Indicating the candidate is waiting to be processed. WAITING, // Indicating the last connecting try to the candidate failed. CONNECTION_FAILED, // Indicating the candidate is busy. BUSY, // Indicating the last requested range of the candidate was unavailable. RANGE_UNAVAILABLE, // Indicating the candidate is connecting CONNECTING, // Indicating the candidate is connecting with a push request. PUSH_REQUEST, // Indicating the candidate is remotely queued. REMOTLY_QUEUED, // Indicating the candidate is requesting a segment REQUESTING, // Indicating the candidate is downloading DOWNLOADING } public enum ThexStatus { // Indicating the candidate has not yet succeeded or failed to perform // a thex request. OPEN, // Indicating the candidate has succeeded to perform a thex request. SUCCEDED, // Indicating the candidate failed to perform a thex request. FAILED } /** * The download file that this candidate belongs to. */ private final SWDownloadFile downloadFile; /** * A {@link LogBuffer} to add candidate log messages. * This can be null and also a shared instance across multiple * candidate. */ private final LogBuffer candidateLogBuffer; /** * The time this download candidate was first added to the list of download * candidates of the corresponding download file. This is the first creation * time of the SWDownloadCandidate object. */ //private Date firstSeenDate; /** * The time a connection to this download candidate could be established * successful. */ private long lastConnectionTime; /** * The number of failed connection tries to this download candidate, since * the last successful connection. */ private int failedConnectionTries; /** * The GUID of the client used for push requests. */ private GUID guid; /** * The file index of the file at the download candidate. * This is the old style identifier for candidates without * urn. */ private long fileIndex; /** * The resource URN of the file. If known this will be used * for download requests. */ private URN resourceURN; /** * A complete download URI to use. This is necessary for standard * uri downloads like in http urls. */ private URI downloadURI; /** * The thex request status for this candidate. */ private ThexStatus thexStatus; /** * The thex uri string, expected without host (it's supposed to be intended * for this candidate). The value is initialized during the download * handshake. */ private String thexUri; /** * The thex root string. Initialized during the download handshake. */ private String thexRoot; /** * The name of the file at the download candidate. */ private String fileName; /** * Rate at which the last segment was transferred */ private int lastTransferRateBPS; /** * The host address of the download candidate. */ private DestAddress hostAddress; /** * The status of the candidate. */ private CandidateStatus status; /** * A possible status reason. */ private String statusReason; /** * The last error status of the download to track status changes. */ private CandidateStatus errorStatus; /** * The time after which the current status times out and things continue. */ private long statusTimeout; /** * Counts the number of times the status keeps repeating. */ private int errorStatusRepetition; /** * The vendor of the client running at the candidate. */ private String vendor; private boolean isG2FeatureAdded; /** * Defines if a push is needed for this candidate. */ private boolean isPushNeeded; /** * The addresses of push proxies of this host or null * if not available. */ private DestAddress[] pushProxyAddresses; /** * Defines if the candidate supports chat connections. */ private boolean isChatSupported; /** * The available range set of the candidate file. */ private DownloadScopeList availableScopeList; /** * The time the available range was last updated. */ private long availableRangeSetTime = 0; /** * The download segment that is currently associated by this download * candidate or null if no association exists. */ private SWDownloadSegment downloadSegment; /** * The parameters that are available in case the candidate is remotely queuing * our download request. This is referenced for information purpose only. */ private XQueueParameters xQueueParameters; /** * This is a Map holding all AltLocs already send to this candidate during * this session. It is used to make sure the same AltLocs are not send twice * to the same candidate. The list is lazy initialized on first access. */ private Set<AlternateLocation> sendAltLocSet; /** * The total amount of data downloaded from this candidate. */ private long totalDownloadSize; private SWDownloadCandidate( SWDownloadFile downloadFile, LogBuffer candidateLogBuffer ) { if ( downloadFile == null ) { throw new NullPointerException( "downloadFile is null." ); } this.downloadFile = downloadFile; // can be null this.candidateLogBuffer = candidateLogBuffer; availableScopeList = null; lastTransferRateBPS = 0; totalDownloadSize = 0; lastConnectionTime = 0; } public SWDownloadCandidate( RemoteFile remoteFile, SWDownloadFile downloadFile, LogBuffer candidateLogBuffer ) { this( downloadFile, candidateLogBuffer ); fileIndex = remoteFile.getFileIndex(); fileName = remoteFile.getFilename(); resourceURN = remoteFile.getURN(); guid = remoteFile.getRemoteClientID(); QueryHitHost qhHost = remoteFile.getQueryHitHost(); vendor = qhHost.getVendor(); isPushNeeded = qhHost.isPushNeeded(); hostAddress = remoteFile.getHostAddress(); isChatSupported = qhHost.isChatSupported(); pushProxyAddresses = qhHost.getPushProxyAddresses(); status = CandidateStatus.WAITING; thexStatus = ThexStatus.OPEN; } public SWDownloadCandidate( DestAddress aHostAddress, long aFileIndex, String aFileName, URN aResourceURN, SWDownloadFile downloadFile, LogBuffer candidateLogBuffer ) { this( downloadFile, candidateLogBuffer ); fileIndex = aFileIndex; fileName = aFileName; resourceURN = aResourceURN; guid = null; vendor = null; isPushNeeded = false; // assume chat is supported but we dont know... isChatSupported = true; hostAddress = aHostAddress; status = CandidateStatus.WAITING; thexStatus = ThexStatus.OPEN; /*setAvailableRangeSet(new HTTPRangeSet(0, downloadFile.getTotalDataSize())); */ } public SWDownloadCandidate(DestAddress address, URI downloadUri, SWDownloadFile downloadFile, LogBuffer candidateLogBuffer ) throws URIException { this( downloadFile, candidateLogBuffer ); fileName = URLUtil.getPathQueryFromUri( downloadUri ); this.downloadURI = downloadUri; resourceURN = URLUtil.getQueryURN( downloadUri ); guid = null; vendor = null; isPushNeeded = false; // assume chat is supported but we dont know... isChatSupported = true; hostAddress = address; status = CandidateStatus.WAITING; thexStatus = ThexStatus.OPEN; } public SWDownloadCandidate( DDownloadCandidate dCandidate, SWDownloadFile downloadFile, LogBuffer candidateLogBuffer ) throws MalformedDestAddressException { this( downloadFile, candidateLogBuffer ); fileIndex = dCandidate.getFileIndex(); fileName = dCandidate.getFileName(); /* setAvailableRangeSet(new HTTPRangeSet(0, downloadFile.getTotalDataSize())); */ String guidHexStr = dCandidate.getGuid(); if ( guidHexStr != null ) { guid = new GUID( guidHexStr ); } String downloadUriStr = dCandidate.getDownloadUri(); if ( downloadUriStr != null ) { try { downloadURI = new URI( downloadUriStr, true ); } catch ( URIException exp ) { NLogger.warn( SWDownloadCandidate.class, "Malformed URI in: " + downloadFile.toString() + " - " + downloadUriStr + " - " + this.toString(), exp ); // continue anyway.. download candidate might still be useful } } String resourceUrnStr = dCandidate.getResourceUrn(); if ( resourceUrnStr != null ) { resourceURN = new URN( resourceUrnStr ); } else { // No resource urn was found there could be two reasons, the // candidate uses a download uri or the download file is from // release 3.0.2 or earlier. If no download uri is available // we use the resource urn of the download file to work around // this shortcoming and support pre 3.0.2 download lists as // good as possible. Basically this means we don't support // file index downloads anymore.. but do we really need them // nowadays.. if ( downloadURI == null ) { resourceURN = downloadFile.getFileURN(); } } vendor = dCandidate.getVendor(); isPushNeeded = dCandidate.isPushNeeded(); isChatSupported = dCandidate.isChatSupported(); if ( dCandidate.isSetLastConnectionTime() ) { lastConnectionTime = dCandidate.getLastConnectionTime(); } else { lastConnectionTime = 0; } try { hostAddress = PresentationManager.getInstance().createHostAddress( dCandidate.getRemoteHost(), DefaultDestAddress.DEFAULT_PORT ); } catch ( MalformedDestAddressException exp ) { NLogger.warn( SWDownloadCandidate.class, "Malformed host address in: " + downloadFile.toString() + " - " + dCandidate.getRemoteHost() + " - " + this.toString(), exp ); throw exp; } if ( dCandidate.getConnectionFailedRepetition() > 0 ) { errorStatus = CandidateStatus.CONNECTION_FAILED; status = CandidateStatus.CONNECTION_FAILED; errorStatusRepetition = dCandidate.getConnectionFailedRepetition(); failedConnectionTries = errorStatusRepetition; } else { status = CandidateStatus.WAITING; } // thex status is reset on startup. thexStatus = ThexStatus.OPEN; } /** * Returns the url necessary for the download request. * @return the download url. */ public String getDownloadRequestUrl() { String requestUrl; if ( downloadURI != null ) { try { // Don't use whole uri.. only file and query part..!? requestUrl = URLUtil.getPathQueryFromUri( downloadURI ); return requestUrl; } catch (URIException e) {// failed to use uri.. try other request urls.. NLogger.warn( SWDownloadCandidate.class, e, e ); } } if ( resourceURN != null ) { requestUrl = URLUtil.buildName2ResourceURL( resourceURN ); } else { // build standard old style gnutella request. String fileIndexStr = String.valueOf( fileIndex ); StringBuffer urlBuffer = new StringBuffer( 6 + fileIndexStr.length() + fileName.length() ); urlBuffer.append( "/get/" ); urlBuffer.append( fileIndexStr ); urlBuffer.append( '/' ); urlBuffer.append( URLCodecUtils.encodeURL( fileName ) ); requestUrl = urlBuffer.toString(); } return requestUrl; } public SWDownloadFile getDownloadFile() { return downloadFile; } /** * Returns the average transfer speed of the last transfer, * or 0 if no transfer has finished yet. * @return the average transfer speed of the last transfer, * or 0 if no transfer has finished yet */ public long getSpeed() { return lastTransferRateBPS; } /** * Returns the HostAddress of the download candidate */ public DestAddress getHostAddress() { return hostAddress; } /** * Returns the name of the file at the download candidate. */ public String getFileName() { return fileName; } /** * Returns the resource URN of the file at the download candidate. */ public URN getResourceURN() { return resourceURN; } /** * Returns the GUID of the candidate for push requests. */ public GUID getGUID() { return guid; } /** * Returns the file index of the file at the download candidate. */ public long getFileIndex() { return fileIndex; } public long getTotalDownloadSize() { return totalDownloadSize; } public void incTotalDownloadSize( int val ) { totalDownloadSize += val; } /** * Returns the time in millis until the the status timesout. */ public long getStatusTimeLeft() { long timeLeft = statusTimeout - System.currentTimeMillis(); if ( timeLeft < 0 ) { timeLeft = 0; } return timeLeft; } /** * Returns the current status of the candidate. */ public CandidateStatus getStatus() { return status; } public String getStatusReason() { return statusReason; } /** * Indicates how often the last error status repeated. The last error status * must must not be the current status, but is the current status in case the * current status is a error status. * @return how often the last error status repeated */ /*public int getErrorStatusRepetition() { return errorStatusRepetition; }*/ /** * Returns the number of failed connection tries since the last successful * connection. * @return the number of failed connection tries since the last successful * connection. */ public int getFailedConnectionTries() { return failedConnectionTries; } /** * The download candidate vendor. * @return the vendor name */ public String getVendor() { return vendor; } public void setVendor( String aVendor ) { if ( vendor == null || !vendor.equals( aVendor ) ) { // verify characters - this is used to remove invalid xml characters for ( int i = 0; i < aVendor.length(); i++ ) { if ( !XMLUtils.isXmlChar( aVendor.charAt( i ) ) ) { return; } } vendor = aVendor; addToCandidateLog( "Set vendor to: " + vendor ); } } public boolean isG2FeatureAdded() { return isG2FeatureAdded; } public void setG2FeatureAdded( boolean state ) { isG2FeatureAdded = state; } public void updateXQueueParameters( XQueueParameters newXQueueParameters ) { if ( xQueueParameters == null ) { xQueueParameters = newXQueueParameters; } else { xQueueParameters.update( newXQueueParameters ); } } public XQueueParameters getXQueueParameters() { return xQueueParameters; } public boolean isPushNeeded() { return isPushNeeded; } /** * Returns the array of push proxies of this connection * or null if there are no available. * @return an array of push proxies or null */ public DestAddress[] getPushProxyAddresses() { return pushProxyAddresses; } public void setPushProxyAddresses( DestAddress[] addresses ) { pushProxyAddresses = addresses; } public long getLastConnectionTime() { return lastConnectionTime; } public void setLastConnectionTime( long lastConnectionTime ) { this.lastConnectionTime = lastConnectionTime; } public boolean isChatSupported() { return isChatSupported; } public void setChatSupported( boolean state ) { isChatSupported = state; } /** * Returns true if the candidate is remotly queued, false otherwise. * @return true is the candidate is remotly queued, false otherwise. */ public boolean isRemotlyQueued() { return status == CandidateStatus.REMOTLY_QUEUED; } /** * Returns true if the candidate is busy or remotly queued, false otherwise. * @return true is the candidate is busy or remotly queued, false otherwise. */ public boolean isBusyOrQueued() { return status == CandidateStatus.BUSY || status == CandidateStatus.REMOTLY_QUEUED; } /** * Returns true if the candidate range is unavailable, false otherwise. * @return true is the candidate range is unavailable, false otherwise. */ public boolean isRangeUnavailable() { return status == CandidateStatus.RANGE_UNAVAILABLE; } /** * Returns true if the candidate is downloading, false otherwise. * @return true is the candidate is downloading, false otherwise. */ public boolean isDownloading() { return status == CandidateStatus.DOWNLOADING; } public boolean isThexSupported() { return thexUri != null && thexRoot != null && thexStatus == ThexStatus.OPEN; } public String getThexUri() { return thexUri; } public String getThexRoot() { return thexRoot; } public void setThexUriRoot( String thexUri, String thexRoot ) { this.thexUri = thexUri; this.thexRoot = thexRoot; } public void setThexStatus( ThexStatus thexStatus ) { this.thexStatus = thexStatus; } /** * Returns the list of alt locs already send to this connection. * @return the list of alt locs already send to this connection. */ public Set<AlternateLocation> getSendAltLocsSet() { if ( sendAltLocSet == null ) {// TODO2 use something like a LRUMap. But current LRUMap uses maxSize // as initial hash size. This would be much to big in most cases! // Currently this HashSet has no size boundry. We would need our own // LRUMap implementation with a low initial size and a different max size. sendAltLocSet = new HashSet<AlternateLocation>(); } return sendAltLocSet; } /** * Sets the available range set. * @param newRangeSet the available range set. */ public void setAvailableRangeSet(HTTPRangeSet newRangeSet) { // dont do anything if we have no range set and the scope list is // uninitialized if ( (newRangeSet == null || newRangeSet.size() == 0) && availableScopeList == null ) { return; } long fileSize = downloadFile.getTotalDataSize(); if ( fileSize == SWDownloadConstants.UNKNOWN_FILE_SIZE ) {// we cant handle available range set without knowing // file size... return; } if ( newRangeSet == null ) { // not only clear existing scope list but set it to NULL availableScopeList = null; return; } // we always initialize a new available scope list here instead of // clearing and reusing the existing scope list to prevent concurrent // modification exceptions during the many access operations to the list // after calls to getAvailableScopeList() // Also we lock the write operation to prevent giving out a incomplete // availableScopeList synchronized( this ) { availableScopeList = new DownloadScopeList(); // add.. Iterator<Range> iterator = newRangeSet.getIterator(); while ( iterator.hasNext() ) { Range range = iterator.next(); long start = range.getStartOffset( fileSize ); long end = range.getEndOffset( fileSize ); if ( end < start ) {// this is an invalid range... skip it NLogger.warn( SWDownloadCandidate.class, "Invalid range: " +range.buildHTTPRangeString() + " - " + start + " - " + end + " - " + fileSize + " - " + vendor ); continue; } DownloadScope scope = new DownloadScope( start, end ); availableScopeList.add( scope ); } availableRangeSetTime = System.currentTimeMillis(); } NLogger.debug( SWDownloadCandidate.class, "Added new rangeset for " + downloadFile.getFileName() + ": " + newRangeSet); } /** * Returns the available range set or null if not set. * @return the available range set or null if not set. */ public DownloadScopeList getAvailableScopeList( ) { if ( System.currentTimeMillis() > availableRangeSetTime + AVAILABLE_RANGE_SET_TIMEOUT ) { setAvailableRangeSet( null ); } // We lock the access to prevent giving out a currently written to // availableScopeList synchronized( this ) { return availableScopeList; } } /** * @see java.lang.Object#hashCode() */ @Override public int hashCode() { final int PRIME = 31; int result = 17; result = PRIME * result + ((hostAddress == null) ? 0 : hostAddress.hashCode()); return result; } /** * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals( Object obj ) { if ( this == obj ) return true; if ( obj == null ) return false; if ( getClass() != obj.getClass() ) return false; final SWDownloadCandidate other = (SWDownloadCandidate) obj; if ( hostAddress == null ) { if ( other.hostAddress != null ) return false; } else if ( !hostAddress.equals( other.hostAddress ) ) return false; return true; } /** * Sets the status of the candidate and fulfills the required actions * necessary for that status. E.g. setting the statusTime. * @param newStatus the status to set from * SWDownloadConstants.STATUS_CANDIDATE_* */ public void setStatus( CandidateStatus newStatus ) { setStatus( newStatus, -1, null ); } /** * Sets the status of the candidate and fulfills the required actions * necessary for that status. E.g. setting the statusTime. * @param newStatus the status to set from * SWDownloadConstants.STATUS_CANDIDATE_* * @param statusSeconds the time in seconds the status should last. */ public void setStatus( CandidateStatus newStatus, int statusSeconds ) { setStatus( newStatus, statusSeconds, null ); } /** * Sets the status of the candidate and fulfills the required actions * necessary for that status. E.g. setting the statusTime. * @param newStatus the status to set from * SWDownloadConstants.STATUS_CANDIDATE_* * @param statusSeconds the time in seconds the status should last only * used for REMOTLY_QUEUED. * @param aStatusReason a status reason to be displayed to the user. */ public void setStatus( CandidateStatus newStatus, int statusSeconds, String aStatusReason ) { // Don't care for same status if ( status == newStatus ) { return; } CandidateStatus oldStatus = status; status = newStatus; if ( System.currentTimeMillis() < statusTimeout && NLogger.isWarnEnabled( SWDownloadCandidate.class ) ) { NLogger.warn( SWDownloadCandidate.class, "Status timeout has not passed yet." ); } long newStatusTimeout; statusTimeout = newStatusTimeout = System.currentTimeMillis(); switch( status ) { case BAD: newStatusTimeout += BAD_CANDIDATE_STATUS_TIMEOUT; break; case IGNORED: newStatusTimeout = Long.MAX_VALUE; break; case CONNECTING: //connectionTries ++; break; case CONNECTION_FAILED: failedConnectionTries ++; if ( failedConnectionTries >= IGNORE_CANDIDATE_CONNECTION_TRIES ) {// we have tried long enough to connect to this candidate, ignore // it for the future (causes delete after session). downloadFile.markCandidateIgnored( this, "CandidateStatusReason_ConnectionFailed" ); // markCandidateIgnored updates the statusTimeout // and statusReason, this value is reset here to not // overwrite it... newStatusTimeout = statusTimeout; aStatusReason = statusReason; break; } else if ( failedConnectionTries >= BAD_CANDIDATE_CONNECTION_TRIES ) { // we dont remove candidates but put them into a bad list. // once we see a new X-Alt the candidate is valid again. // candidates might go into the bad list quickly. // when no "good" candidates are avaiable we might also try additional // bad list connects, every 3 hours or so... downloadFile.markCandidateBad( this ); // markCandidateBad updates the statusTimeout, this value is // reset here to not overwrite it... newStatusTimeout = statusTimeout; break; } else { downloadFile.markCandidateMedium( this ); newStatusTimeout += calculateConnectionFailedTimeout(); break; } // watch... no break here... case REQUESTING: failedConnectionTries = 0; break; case BUSY: case RANGE_UNAVAILABLE: case REMOTLY_QUEUED: failedConnectionTries = 0; if ( statusSeconds > 0 ) { newStatusTimeout += statusSeconds * 1000L; } else { newStatusTimeout += determineErrorStatusTimeout( status ); } break; case PUSH_REQUEST: newStatusTimeout += DownloadPrefs.PushRequestTimeout.get().intValue(); break; case DOWNLOADING: // clear the current error status... use the waiting status for this errorStatus = CandidateStatus.WAITING; failedConnectionTries = 0; break; } this.statusReason = aStatusReason; NLogger.debug( SWDownloadCandidate.class, "Setting status from " + oldStatus + " to " + newStatus + " and raise timeout from " + statusTimeout + " to " + newStatusTimeout + "(" + (newStatusTimeout-statusTimeout) + ") Reason:" + aStatusReason + "."); addToCandidateLog( "Setting status to " + SWDownloadInfo.getDownloadCandidateStatusString(this) + " and raise timeout from " + statusTimeout + " to " + newStatusTimeout + "(" + (newStatusTimeout-statusTimeout) + ") Reason:" + aStatusReason + ". OldStatus: " + oldStatus); statusTimeout = newStatusTimeout; fireCandidateStatusChange( oldStatus, newStatus ); } /** * Calculates the timeout between the last failed connection and the next * connection try. * @return the number of millies to wait till the status expires. */ private long calculateConnectionFailedTimeout() { // Once we are over BAD_CANDIDATE_CONNECTION_TRIES we dont call this // method anymore and use BAD_CANDIDATE_STATUS_TIMEOUT instead. // When CONNECTION_FAILED_STEP_TIME time is 2 it gives a sequence of // tries: 1, 2, 3,| 4, 5, 6, 7, 8, 9, 10 // to: 2, 4, 8,| 16, 32, 64, 128, 128, 128, 128 // to2: 2, 6, 12,| 22, 40, 74, 140, 142, 144, 146 // // to1 - would cause the values to double on each repetition. // CONNECTION_FAILED_STEP_TIME * (long)Math.pow( 2, // Math.min( failedConnectionTries - 1, 7 ) ); // to2 - would add a raising penalty to to1 on each repetition // CONNECTION_FAILED_STEP_TIME * (long)Math.pow( 2, // Math.min( failedConnectionTries - 1, 7 ) ) // + (failedConnectionTries - 1) * 2; // // We use to2 currently: return CONNECTION_FAILED_STEP_TIME * (long)Math.pow( 2, Math.min( failedConnectionTries - 1, 7 ) ) + (failedConnectionTries - 1) * 2; } /** * Maintains error status tracking. This is needed to track repeting errors * that will be handled by flexible status timeouts. * @returns the livetime of the status. */ private long determineErrorStatusTimeout( CandidateStatus aErrorStatus ) { if ( errorStatus == aErrorStatus ) { errorStatusRepetition ++; } else { errorStatus = aErrorStatus; errorStatusRepetition = 0; } switch( errorStatus ) { case BUSY: // we can add here a step thing for each retry with a top limit // and a shorter start sleep time but currently we keep it like this. return HOST_BUSY_SLEEP_TIME; /*( statusRepetition + 1 ) * */ case RANGE_UNAVAILABLE: // when step time is 1 it gives a sequence of // 1, 2, 4, 8, 16, 32... // this would cause the values to double on each repetition. return RANGE_UNAVAILABLE_STEP_TIME * (long)Math.pow( 2, errorStatusRepetition ); case REMOTLY_QUEUED: if ( xQueueParameters == null ) { return 0; } else { return xQueueParameters.getRequestSleepTime(); } default: NLogger.warn( SWDownloadCandidate.class, "Unknown error status: " + errorStatus ); return 0; } } /** * Manually forces a connection retry, when the candidate is in a * valid state. * The method should only be called from user triggered GUI action. */ public void manualConnectionRetry() { if ( status != CandidateStatus.BUSY && status != CandidateStatus.CONNECTION_FAILED && status != CandidateStatus.RANGE_UNAVAILABLE && status != CandidateStatus.BAD && status != CandidateStatus.IGNORED ) { return; } setStatus( CandidateStatus.WAITING ); } /** * Returns if the candidate is able to be allocated. To be allocated a * candidate must not have a worker assigned and the nextRetryTime must be * passed. */ public boolean isAbleToBeAllocated( ) { // Do not allow allocation if it's too slow! if (lastTransferRateBPS < DownloadPrefs.CandidateMinAllowedTransferRate.get().intValue() && lastTransferRateBPS > 0) { addToCandidateLog( "Refusing candidate allocation as last transfer rate was only " + lastTransferRateBPS + " bps"); NLogger.debug( SWDownloadCandidate.class, "Refusing candidate allocation as last transfer rate was only " + lastTransferRateBPS + " bps"); return false; } long currentTime = System.currentTimeMillis(); return statusTimeout <= currentTime; } public void associateDownloadSegment( SWDownloadSegment aSegment ) { downloadSegment = aSegment; } /** * Returns the preferred (ie: largest) segment size to use for this candidate. * This will be DEFAULT_SEGMENT_SIZE initially, but will then be calculated so that if * the transfer rate for the previous segment were maintained, the next segment * would take DEFAULT_SEGMENT_TIME seconds. * The value MAXIMUM_ALLOWED_SEGMENT_SIZE is respected. */ public long getPreferredSegmentSize() { long result; // No previous segment has been transferred if (lastTransferRateBPS == 0) { result = DownloadPrefs.SegmentInitialSize.get().intValue(); } else { // default is rate * seconds, but not lower then a segmentMultiple. result = Math.max( lastTransferRateBPS * DownloadPrefs.SegmentTransferTargetTime.get().intValue(), DownloadPrefs.SegmentMultiple.get().intValue() ); // round the result up to the next multiple of segmentMultiple long remainder = (-result) % DownloadPrefs.SegmentMultiple.get().intValue(); result += remainder; // Too fast (ie: segment would be bigger than allowed if (result > DownloadPrefs.SegmentMaximumSize.get().intValue() ) { result = DownloadPrefs.SegmentMaximumSize.get().intValue(); } } if ( result < 1 ) { NLogger.warn( SWDownloadCandidate.class, "Preferred size looks strange. bps=" + lastTransferRateBPS + " and stt=" + DownloadPrefs.SegmentTransferTargetTime.get().intValue() + " res " + result + " res1 " + (lastTransferRateBPS * DownloadPrefs.SegmentTransferTargetTime.get().intValue()) + " res2 " + ((-result) % DownloadPrefs.SegmentMultiple.get().intValue() ) ); result = DownloadPrefs.SegmentInitialSize.get().intValue(); } NLogger.debug( SWDownloadCandidate.class, "Preferred segment size is " + result); return result; } public void releaseDownloadSegment() { if ( downloadSegment != null ) { lastTransferRateBPS = downloadSegment.getLongTermTransferRate(); downloadSegment = null; } } /** * Provides the caller with the currently associated segment or null if no * association is available. * @return the associated segment or null. */ public SWDownloadSegment getDownloadSegment() { return downloadSegment; } /** * Creates the DElement representation of this object to serialize it * into XML. * @return the DElement representation of this object */ public DDownloadCandidate createDDownloadCandidate() { DDownloadCandidate dCandidate = new DDownloadCandidate(); dCandidate.setFileIndex( fileIndex ); dCandidate.setFileName( fileName ); if ( guid != null ) { dCandidate.setGuid( guid.toHexString() ); } if ( downloadURI != null ) { dCandidate.setDownloadUri( downloadURI.getEscapedURI() ); } // we need to store the resource urn since not all candidates // have one, and we need to identify them. if ( resourceURN != null ) { dCandidate.setResourceUrn( resourceURN.getAsString() ); } dCandidate.setPushNeeded( isPushNeeded ); dCandidate.setChatSupported( isChatSupported ); dCandidate.setRemoteHost( hostAddress.getFullHostName() ); dCandidate.setVendor( vendor ); if ( lastConnectionTime > 0 ) { dCandidate.setLastConnectionTime( lastConnectionTime ); } // also maintain count how often a connection was failed in a row... //if ( failedConnectionTries >= BAD_CANDIDATE_CONNECTION_TRIES ) if ( failedConnectionTries > 0 ) { dCandidate.setConnectionFailedRepetition( failedConnectionTries ); } return dCandidate; } @Override public String toString() { StringBuffer buffer = new StringBuffer( "[Candidate: "); if ( vendor != null ) { buffer.append( vendor ); buffer.append( ',' ); } buffer.append( "Adr:" ); buffer.append( hostAddress ); buffer.append( " ->" ); buffer.append( super.toString() ); buffer.append( "]" ); return buffer.toString(); } public void addToCandidateLog( String message ) { if ( candidateLogBuffer != null ) { LogRecord record = new LogRecord( this, message ); candidateLogBuffer.addLogRecord( record ); } } public void addToCandidateLog( Throwable th ) { if ( candidateLogBuffer != null ) { StackTraceElement[] stackTrace = th.getStackTrace(); if ( stackTrace == null ) { return; } for ( int i = 0; i < 2 && i < stackTrace.length; i++ ) { LogRecord record = new LogRecord( this, stackTrace[i].toString() ); candidateLogBuffer.addLogRecord( record ); } } } ///////////////////// START event handling methods //////////////////////// private void fireCandidateStatusChange( CandidateStatus oldStatus, CandidateStatus newStatus ) { Servent.getInstance().getEventService().publish( PhexEventTopics.Download_Candidate_Status, new ChangeEvent( this, oldStatus, newStatus ) ); } ///////////////////// END event handling methods //////////////////////// }

The table below shows all metrics for SWDownloadCandidate.java.

MetricValueDescription
BLOCKS125.00Number of blocks
BLOCK_COMMENT28.00Number of block comment lines
COMMENTS385.00Comment lines
COMMENT_DENSITY 0.73Comment density
COMPARISONS87.00Number of comparison operators
CYCLOMATIC143.00Cyclomatic complexity
DECL_COMMENTS83.00Comments in declarations
DOC_COMMENT262.00Number of javadoc comment lines
ELOC531.00Effective lines of code
EXEC_COMMENTS38.00Comments in executable code
EXITS99.00Procedure exits
FUNCTIONS62.00Number of function declarations
HALSTEAD_DIFFICULTY90.37Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY125.00Interface complexity
JAVA0001 0.00JAVA0001 Package name does not contain only lower case letters
JAVA0002 1.00JAVA0002 Package name does not begin with a top level domain name or country code
JAVA0003 0.00JAVA0003 Minimize use of on-demand (.*) imports
JAVA0004 0.00JAVA0004 Unnecessary import from java.lang
JAVA0005 0.00JAVA0005 Imports not in specified order
JAVA0006 0.00JAVA0006 Empty finally block
JAVA0007 0.00JAVA0007 Should not declare public field
JAVA0008 0.00JAVA0008 Empty catch block
JAVA0009 0.00JAVA0009 Protected member in final class
JAVA0010 0.00JAVA0010 Non-instantiable class does not contain a non-private static member
JAVA0011 0.00JAVA0011 Abstract class does not contain an abstract method
JAVA0012 0.00JAVA0012 Non-constructor method with same name as declaring class
JAVA0013 0.00JAVA0013 Non-blank final field is not static
JAVA0014 0.00JAVA0014 Class with only static members has non-private constructor
JAVA0015 0.00JAVA0015 Package class contains public nested type
JAVA0016 0.00JAVA0016 Abstract class contains public constructor
JAVA0017 0.00JAVA0017 Class name does not have required form
JAVA0018 0.00JAVA0018 Method name does not have required form
JAVA0019 0.00JAVA0019 Interface name does not have required form
JAVA0020 0.00JAVA0020 Field name does not have required form
JAVA0021 0.00JAVA0021 Interface method name does not have required form
JAVA0022 0.00JAVA0022 Static final field name does not have required form
JAVA0023 0.00JAVA0023 Empty finalize method
JAVA0024 0.00JAVA0024 Empty class
JAVA0025 0.00JAVA0025 Method override is empty
JAVA0026 0.00JAVA0026 Finalize method with parameters
JAVA0029 0.00JAVA0029 Private method not used
JAVA0030 0.00JAVA0030 Private field not used
JAVA0031 2.00JAVA0031 Case statement not properly closed
JAVA0032 1.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA0034 5.00JAVA0034 Missing braces in if statement
JAVA0035 0.00JAVA0035 Missing braces in for statement
JAVA0036 0.00JAVA0036 Missing braces in while statement
JAVA0038 0.00JAVA0038 Non-case label in switch statement
JAVA0039 0.00JAVA0039 Break statement with label
JAVA0040 0.00JAVA0040 Switch statement contains N cases (maximum: M)
JAVA0041 0.00JAVA0041 Nested synchronized block
JAVA0042 0.00JAVA0042 Empty synchronized statement
JAVA0043 0.00JAVA0043 Inner class does not use outer class
JAVA0044 0.00JAVA0044 Serializable class with no instance variables
JAVA0045 0.00JAVA0045 Serializable class with only transient fields
JAVA0046 0.00JAVA0046 Name of class not derived from Exception ends with 'Exception'
JAVA0047 0.00JAVA0047 Serializable class derives from invalid base class
JAVA0048 0.00JAVA0048 Name of class derived from Exception does not end with 'Exception'
JAVA0049 0.00JAVA0049 Nested block at depth N (maximum: M)
JAVA0050 0.00JAVA0050 Class derives from java.lang.Error
JAVA0051 0.00JAVA0051 Class derives from java.lang.RuntimeException
JAVA0052 0.00JAVA0052 Class derives from java.lang.Throwable
JAVA0053 0.00JAVA0053 Unused label
JAVA0054 0.00JAVA0054 Inheritance depth N exceeds maximum M
JAVA0055 0.00JAVA0055 Class should be interface
JAVA0056 0.00JAVA0056 Unnecessary abstract modifier for interface or annotation
JAVA0057 0.00JAVA0057 Unnecessary default constructor
JAVA0058 0.00JAVA0058 Constructor calls super()
JAVA0059 0.00JAVA0059 Method override only calls super()
JAVA0061 0.00JAVA0061 Inaccessible member in anonymous class
JAVA0062 0.00JAVA0062 Public class missing public member or protected constructor
JAVA0063 0.00JAVA0063 Identifier name should not contain '$'
JAVA0064 1.00JAVA0064 N variations of identifier name (maximum: M)
JAVA0065 0.00JAVA0065 Unnecessary final modifier for method in final class
JAVA0066 0.00JAVA0066 Unnecessary modifier for interface nested type
JAVA0067 0.00JAVA0067 Array descriptor on identifier name
JAVA0068 0.00JAVA0068 Modifiers not declared in recommended order
JAVA0071 0.00JAVA0071 Strings compared with ==
JAVA0073 0.00JAVA0073 Integer division in floating-point context
JAVA0074 0.00JAVA0074 Use of Object.notify()
JAVA0075 0.00JAVA0075 Method parameter hides field
JAVA0076 0.00JAVA0076 Use of magic number
JAVA0077 0.00JAVA0077 Private field not used in declaring class
JAVA0078 0.00JAVA0078 Floating point values compared with ==
JAVA0079 0.00JAVA0079 Use of instance to reference static member
JAVA0080 0.00JAVA0080 Import declaration not used
JAVA0081 0.00JAVA0081 Boolean literal in comparison
JAVA0082 0.00JAVA0082 Unnecessary widening cast
JAVA0083 0.00JAVA0083 Unnecessary instanceof test
JAVA0084 0.00JAVA0084 Should use compound assignment operator
JAVA0085 0.00JAVA0085 Use of sun.* class
JAVA0087 0.00JAVA0087 Use of Thread.sleep()
JAVA0089 0.00JAVA0089 Use of restricted package
JAVA0092 0.00JAVA0092 Use of restricted type
JAVA0093 0.00JAVA0093 Redundant assignment
JAVA0094 0.00JAVA0094 Field hides a superclass field
JAVA0095 0.00JAVA0095 Uninitialized private field
JAVA0096 0.00JAVA0096 Field in nested class hides outer field
JAVA0098 0.00JAVA0098 Minimize use of implicit field initializers
JAVA0100 1.00JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0101 0.00JAVA0101 Unnecessary modifier for field in interface
JAVA0102 0.00JAVA0102 Last statement in finalize() not super.finalize()
JAVA0103 0.00JAVA0103 Explicit call to finalize()
JAVA0104 0.00JAVA0104 finalize() only calls super.finalize()
JAVA0105 0.00JAVA0105 Duplicate import declaration
JAVA0106 0.00JAVA0106 Unnecessary import from current package
JAVA0108 1.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 0.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA011012.00JAVA0110 Incorrect javadoc: no @return tag
JAVA0111 0.00JAVA0111 Incorrect javadoc: @return tag for void method
JAVA0112 0.00JAVA0112 Incorrect javadoc: no exception 'exception' in throws
JAVA0113 1.00JAVA0113 Incorrect javadoc: no @author tag
JAVA0114 1.00JAVA0114 Incorrect javadoc: no @version tag
JAVA0115 0.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 0.00JAVA0116 Missing javadoc: field 'field'
JAVA011728.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 0.00JAVA0118 Missing javadoc: type 'type'
JAVA0119 0.00JAVA0119 Control variable changed within body of for loop
JAVA0123 0.00JAVA0123 Use all three components of for loop
JAVA0125 0.00JAVA0125 Continue statement with label
JAVA0126 0.00JAVA0126 Method declares unchecked exception in throws
JAVA0128 0.00JAVA0128 Public constructor in non-public class
JAVA0130 0.00JAVA0130 Non-static method does not use instance fields
JAVA0131 0.00JAVA0131 Compatible method does not override base
JAVA0132 0.00JAVA0132 Method overload with compatible signature
JAVA0133 0.00JAVA0133 Non-synchronized method overrides synchronized method
JAVA0135 0.00JAVA0135 Only one of Object.equals and Object.hashCode defined: missing 'method'
JAVA0136 1.00JAVA0136 N methods defined in class (maximum: M)
JAVA0137 0.00JAVA0137 Non-abstract class missing constructor
JAVA0138 1.00JAVA0138 N parameters defined for method (maximum: M)
JAVA0139 0.00JAVA0139 Definition of main other than public static void main(java.lang.String[])
JAVA0141 0.00JAVA0141 Unnecessary modifier for method in interface
JAVA0143 0.00JAVA0143 Synchronized method
JAVA0144 0.00JAVA0144 Line exceeds maximum M characters
JAVA0145 0.00JAVA0145 Tab character used in source file
JAVA0150 0.00JAVA0150 java.lang.Error (or subclass) thrown
JAVA0153 0.00JAVA0153 Inefficient conversion of integer to string
JAVA0159 0.00JAVA0159 Inefficient conversion of string to integer
JAVA0160 0.00JAVA0160 Method does not throw specified exception
JAVA0161 0.00JAVA0161 Conditional wait() not in loop
JAVA0163 0.00JAVA0163 Empty statement
JAVA0165 0.00JAVA0165 Conflicting return statement in finally block
JAVA0166 0.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 0.00JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0171 0.00JAVA0171 Unused local variable
JAVA0173 0.00JAVA0173 Unused method parameter
JAVA0174 0.00JAVA0174 Assigned local variable never used
JAVA0175 0.00JAVA0175 Successive assignment to variable
JAVA0176 0.00JAVA0176 Local variable name does not have required form
JAVA0177 3.00JAVA0177 Variable declaration missing initializer
JAVA0179 0.00JAVA0179 Local variable hides visible field
JAVA0233 0.00JAVA0233 Definition of serialVersionUID other than 'private static final long serialVersionUID'
JAVA0234 0.00JAVA0234 Class is Serializable but does not define serialVersionUID
JAVA0235 0.00JAVA0235 Class defines serialVersionUID but does not implement Serializable
JAVA0236 0.00JAVA0236 Attempt to clone an object which does not implement Cloneable
JAVA0237 0.00JAVA0237 Class implements Cloneable but does not have public clone method
JAVA0238 0.00JAVA0238 Clone method does not call super.clone()
JAVA0239 0.00JAVA0239 Class declares 'readObject' or 'writeObject' but does not implement Serializable
JAVA0240 0.00JAVA0240 Serializable class which declares readObject or writeObject but not both
JAVA0241 0.00JAVA0241 'readObject' or 'writeObject' should be declared private in Serializable class
JAVA0242 0.00JAVA0242 Transient field in non-Serializable class
JAVA0243 0.00JAVA0243 'readResolve' or 'writeReplace' should be declared private or protected
JAVA0244 0.00JAVA0244 Field or method name in subclass differs only by case from inherited field or method
JAVA0245 0.00JAVA0245 JUnit TestCase with non-trivial constructor
JAVA0246 0.00JAVA0246 JUnit assertXXX statement missing message parameter
JAVA0247 0.00JAVA0247 JUnit 'setUp()' and 'tearDown()' should call super method
JAVA0248 0.00JAVA0248 JUnit method 'setUp' or 'tearDown' with incorrect signature
JAVA0249 0.00JAVA0249 JUnit TestCase 'suite()' should be declared static
JAVA0250 0.00JAVA0250 JUnit TestCase declares testXXX method with incorrect signature
JAVA0251 0.00JAVA0251 Use '%n' for line breaks in printf/format for platform independence
JAVA0252 0.00JAVA0252 'enum' is a Java 1.5 reserved word
JAVA0253 1.00JAVA0253 Not all enum constants consumed in switch statement
JAVA0254 1.00JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0255 0.00JAVA0255 Result of method invocation not used
JAVA0256 1.00JAVA0256 Assignment of external collection/array to field
JAVA0257 1.00JAVA0257 Use of 'Constant Interface' anti-pattern
JAVA0258 0.00JAVA0258 Implement Iterable for foreach compatibility
JAVA0259 2.00JAVA0259 Return of collection/array field
JAVA0260 0.00JAVA0260 Use 'enum' instead of Enumerated Type pattern
JAVA0261 0.00JAVA0261 Use specialized Enum collection types
JAVA0262 1.00JAVA0262 Use of char in integer context
JAVA0263 0.00JAVA0263 Long literal ends with 'l' instead of 'L'
JAVA0264 1.00JAVA0264 Integer math in long context - check for overflow
JAVA0265 0.00JAVA0265 Use of Throwable.printStackTrace()
JAVA0266 0.00JAVA0266 Use of System.out
JAVA0267 0.00JAVA0267 Use of System.err
JAVA0269 0.00JAVA0269 Contents of StringBuffer never used
JAVA0270 0.00JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0271 0.00JAVA0271 Minimize use of on-demand (.*) static imports
JAVA0272 0.00JAVA0272 Thread.run() called
JAVA0273 0.00JAVA0273 Non-final derivative of Thread calls start() in constructor
JAVA0274 0.00JAVA0274 Serializable class has a synchronized readObject()
JAVA0275 0.00JAVA0275 Serializable class has a synchronized writeObject() and no other synchronized methods
JAVA0276 0.00JAVA0276 Unnecessary use of String constructor
JAVA0277 0.00JAVA0277 Iterator.next() implementation does not throw NoSuchElementException
JAVA0278 0.00JAVA0278 Unnecessary use of Boolean constructor
JAVA0279 0.00JAVA0279 Serialization method readObject or readObjectNoData calls an overridable method
JAVA0280 0.00JAVA0280 IllegalMonitorStateException caught
JAVA0281 0.00JAVA0281 Iterator.next() not called in loop
JAVA0282 0.00JAVA0282 Call to Iterator.next() in loop which does not test Iterator.hasNext()
JAVA0283 0.00JAVA0283 Control variable not updated in loop body
JAVA0284 0.00JAVA0284 Explicit garbage collection
JAVA0285 0.00JAVA0285 Dereference of potentially null variable
JAVA0286 0.00JAVA0286 Dereference of null variable
JAVA0287 0.00JAVA0287 Unnecessary null check
JAVA0288 0.00JAVA0288 Inconsistent null check
LINES1307.00Number of lines in the source file
LINE_COMMENT95.00Number of line comments
LOC785.00Lines of code
LOGICAL_LINES317.00Number of statements
LOOPS 3.00Number of loops
NEST_DEPTH 4.00Maximum nesting depth
OPERANDS1197.00Number of operands
OPERATORS2331.00Number of operators
PARAMS42.00Number of formal parameter declarations
PROGRAM_LENGTH3528.00Halstead program length
PROGRAM_VOCAB465.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS83.00Number of return points from functions
SIZE42643.00Size of the file in bytes
UNIQUE_OPERANDS404.00Number of unique operands
UNIQUE_OPERATORS61.00Number of unique operators
WHITESPACE137.00Number of whitespace lines