Class MultiTransferHandler<T>

    • Field Detail

      • willTransfer

        protected boolean willTransfer
      • waitForDiscWriteProgressive

        public static long waitForDiscWriteProgressive
      • statusMessage

        protected java.lang.String statusMessage
      • countTransferred

        protected int countTransferred
      • lastBytesSoFar

        protected long lastBytesSoFar
      • isParentPooled

        protected boolean isParentPooled
    • Constructor Detail

      • MultiTransferHandler

        public MultiTransferHandler​(FCClientEngine fcClient)
    • Method Detail

      • willTransfer

        public boolean willTransfer()
      • runHandler

        public abstract void runHandler()
      • setCancelled

        protected void setCancelled​(boolean isCancelled)
      • setStatusCode

        protected void setStatusCode​(int code)
      • getLastTry

        public long getLastTry()
      • setLastTry

        protected void setLastTry()
      • isFatal

        public boolean isFatal()
        Return true if a fatal error occurred
        Overrides:
        isFatal in class TransferHook
        Returns:
        true if fatal error occurred
      • setFatal

        public void setFatal​(boolean fatal)
        Marks transfer as having failed in a fatal way, no retry at this point
        Parameters:
        fatal -
      • addObserver

        public void addObserver​(java.util.Observer o)
        Description copied from class: TransferHook
        Java has Deprecated Observable due to it being an anti-pattern.
        Overrides:
        addObserver in class TransferHook
      • notifyObservers

        public void notifyObservers()
        Overrides:
        notifyObservers in class java.util.Observable
      • notifyObservers

        public void notifyObservers​(java.lang.Object arg)
        Overrides:
        notifyObservers in class java.util.Observable
      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
      • close

        public void close()
                   throws java.lang.Exception
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.lang.Exception
      • isValidFileCache

        public boolean isValidFileCache()
      • setLocalFileTransferIndex

        protected void setLocalFileTransferIndex​(CachedFileIndexInterface localFileTransferIndex)
      • shouldCompressFile

        public boolean shouldCompressFile​(java.nio.file.Path f)
      • getAverageSetupTeardown

        public long getAverageSetupTeardown()
      • isDeleteAfterTransfer

        public boolean isDeleteAfterTransfer()
      • setDeleteAfterTransfer

        public void setDeleteAfterTransfer​(boolean deleteAfterTransfer)
      • getFilesTransferredRemote

        public java.util.List<java.lang.String> getFilesTransferredRemote()
        Description copied from interface: TransferState
        Returns a List containing the full remote paths (Strings) of all files that were transferred. Calling this method through JavaScript to the applet will return a String delimited by the default delimiter, or whatever delimiter was specified via the applet "delimiter" param
        Specified by:
        getFilesTransferredRemote in interface TransferState
        Overrides:
        getFilesTransferredRemote in class TransferHook
        Returns:
        List containing the full remote paths (Strings) of all files that were transferred.
      • getFilesTransferredLocal

        public java.util.List<java.lang.String> getFilesTransferredLocal()
        Description copied from interface: TransferState
        Returns a List containing the full local paths (Strings) of all files that were transferred. Calling this method through JavaScript to the applet will return a String delimited by the default delimiter, or whatever delimiter was specified via the applet "delimiter" param
        Specified by:
        getFilesTransferredLocal in interface TransferState
        Overrides:
        getFilesTransferredLocal in class TransferHook
        Returns:
        List containing the full local paths (Strings) of all files that were transferred.
      • getStatus

        public java.lang.Integer getStatus​(int index)
      • getAllFileAndSize

        public java.util.Map<java.lang.String,​java.lang.Long> getAllFileAndSize()
      • setCancelled

        public void setCancelled()
        Description copied from interface: TransferState
        Calling this method will cancel the current transfer. This method will block until the transfer is actually cancelled.
        Specified by:
        setCancelled in interface TransferState
        Overrides:
        setCancelled in class TransferHook
      • incrementTotalFiles

        protected final void incrementTotalFiles()
      • getFilesSoFar

        public int getFilesSoFar()
        Description copied from interface: TransferState
        Returns the number of files transferred so far. This includes files that were skipped because incremental is enabled and the file has not been changed.
        Specified by:
        getFilesSoFar in interface TransferState
        Overrides:
        getFilesSoFar in class TransferHook
        Returns:
        the number of files transferred so far.
      • setFilesSoFar

        public void setFilesSoFar​(int num)
      • updateSofarAllFiles

        protected final void updateSofarAllFiles()
      • getStatusMessage

        public java.lang.String getStatusMessage()
        Description copied from interface: TransferState
        Returns a String representation of the current status of this transfer handler.
        Specified by:
        getStatusMessage in interface TransferState
        Overrides:
        getStatusMessage in class TransferHook
        Returns:
        A String representation of the current status of this transfer handler.
      • getSizeAllFiles

        public long getSizeAllFiles()
        Description copied from interface: TransferState
        Returns the total size in bytes of all files that will be transferred
        Specified by:
        getSizeAllFiles in interface TransferState
        Overrides:
        getSizeAllFiles in class TransferHook
        Returns:
        the total size in bytes of all files that will be transferred
      • getBytesSoFarAllFilesFull

        public long getBytesSoFarAllFilesFull()
        Return the full size of the files which were transferred. Do not include delta/signature/compression size. Include partial transfer size if cancel/pause/error has stopped the transfer. BugZilla #442
        Returns:
      • getPercent

        public int getPercent()
        Description copied from interface: TransferState
        Returns the percentage complete of all files to be transferred
        Specified by:
        getPercent in interface TransferState
        Overrides:
        getPercent in class TransferHook
        Returns:
        the percentage complete of all files to be transferred
      • getRateAverage

        public int getRateAverage()
        Description copied from interface: TransferState
        Returns the network rate for the current file in Kbps as an average over last 30 seconds.
        Specified by:
        getRateAverage in interface TransferState
        Overrides:
        getRateAverage in class TransferHook
        Returns:
        the rate for the current file in Kbps
      • getCurrentRate

        public int getCurrentRate()
        Description copied from interface: TransferState
        Returns the rate in the last second for the current file in Kbps.
        Specified by:
        getCurrentRate in interface TransferState
        Overrides:
        getCurrentRate in class TransferHook
        Returns:
        the rate for the current file in Kbps over the past second.
      • getEffectiveRateAverageInKBperSecond

        public int getEffectiveRateAverageInKBperSecond()
      • getTimeRemaining

        public java.lang.String getTimeRemaining()
        Description copied from interface: TransferState
        Return the time remaining for the current file formatted to a String i.e 5 mins 21 secs
        Specified by:
        getTimeRemaining in interface TransferState
        Overrides:
        getTimeRemaining in class TransferHook
        Returns:
        the time remaining for the current file formatted to a String
      • getTransferMetrics

        public unlimited.core.transfers.UDPTransferMetricsContainer getTransferMetrics()
        Returns transfer metric container specific to UDP transfers. Statistics gathered by UDPTransmitter and UDPReceiver, and passed down the food chain by the ClientEngine -> TransferHook (Receive/Transmit Handler) -> Upload/Download Transfer classes If nothing is transferring, an empty container is passed through with stats values set to zero.
        Specified by:
        getTransferMetrics in interface unlimited.core.transfers.UDPTransferMetrics
        Overrides:
        getTransferMetrics in class TransferHook
        Returns:
        UDPTransferMetricsContainer
      • updateObservers

        public void updateObservers()
      • getFormattedTransferTime

        public java.lang.String getFormattedTransferTime()
        Description copied from interface: TransferState
        Returns the time taken to transfer the current file formatted to a String i.e 5 mins 21 secs
        Specified by:
        getFormattedTransferTime in interface TransferState
        Overrides:
        getFormattedTransferTime in class TransferHook
        Returns:
        the time taken to transfer the current file formatted to a String i.e 5 mins 21 secs
      • isCancelled

        public boolean isCancelled()
        Specified by:
        isCancelled in interface unlimited.core.util.common.CancelHandler
      • isCancelledDueToError

        public boolean isCancelledDueToError()
        Specified by:
        isCancelledDueToError in interface unlimited.core.util.common.CancelHandler
      • getStatusCode

        public int getStatusCode()
        Description copied from interface: TransferState
        Returns the current status code, indicates what is currently happening with the transfer
        Specified by:
        getStatusCode in interface TransferState
        Overrides:
        getStatusCode in class TransferHook
        Returns:
        the current status code
      • getTransferTime

        public long getTransferTime()
        Description copied from interface: TransferState
        Returns the transfer time for the total transfer in milliseconds
        Specified by:
        getTransferTime in interface TransferState
        Overrides:
        getTransferTime in class TransferHook
        Returns:
        the transfer time for the total transfer in milliseconds
      • getLogFiles

        public unlimited.core.util.common.logs.LogUtils getLogFiles()
      • setLogFiles

        public void setLogFiles​(unlimited.core.util.common.logs.LogUtils logFiles)
      • setAutoZip

        public void setAutoZip​(boolean b)
      • isAutoZip

        public boolean isAutoZip()
      • isOptimizeBlocksize

        public boolean isOptimizeBlocksize()
      • setOptimizeBlocksize

        public void setOptimizeBlocksize​(boolean optimizeBlocksize)
      • downgradeFileTransferMode

        protected void downgradeFileTransferMode()
      • renameExtension

        protected void renameExtension​(java.nio.file.Path file,
                                       java.lang.String rFile)
                                throws unlimited.core.util.common.exception.FCException,
                                       java.io.IOException
        OTIS feature, rename the extensions on the local and remote files from RDY to PKD
        Parameters:
        file -
        rFile -
        Throws:
        unlimited.core.util.common.exception.FCException
        java.io.IOException
      • filesMatchBackground

        protected void filesMatchBackground​(java.nio.file.Path file,
                                            java.lang.String rFile)
                                     throws unlimited.core.util.common.exception.FCException,
                                            java.io.IOException
        Throws:
        unlimited.core.util.common.exception.FCException
        java.io.IOException
      • filesMatch

        protected MD5Result filesMatch​(java.nio.file.Path file,
                                       java.lang.String rFile)
                                throws unlimited.core.util.common.exception.FCException,
                                       java.io.IOException
        Throws:
        unlimited.core.util.common.exception.FCException
        java.io.IOException
      • filesMatch

        public static MD5Result filesMatch​(java.nio.file.Path file,
                                           java.lang.String rFile,
                                           boolean invalidateRemoteMD5CacheEntry,
                                           FilesMatchHandler filesMatchHandler)
                                    throws java.io.IOException,
                                           unlimited.core.util.common.exception.FCException
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • filesMatchPartial

        public static MD5Result filesMatchPartial​(java.nio.file.Path file,
                                                  java.lang.String rFile,
                                                  long checkInterval,
                                                  long checkLength,
                                                  boolean invalidateRemoteMD5CacheEntry,
                                                  FilesMatchHandler filesMatchHandler)
                                           throws java.io.IOException,
                                                  unlimited.core.util.common.exception.FCException
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • filesMatch

        protected MD5Result filesMatch​(java.nio.file.Path file,
                                       java.lang.String rFile,
                                       boolean invalidateRemoteMD5CacheEntry)
                                throws unlimited.core.util.common.exception.FCException,
                                       java.io.IOException
        Throws:
        unlimited.core.util.common.exception.FCException
        java.io.IOException
      • filesMatchPartial

        protected MD5Result filesMatchPartial​(java.nio.file.Path file,
                                              java.lang.String rFile,
                                              long checkInterval,
                                              long checkLength)
                                       throws unlimited.core.util.common.exception.FCException,
                                              java.io.IOException
        Throws:
        unlimited.core.util.common.exception.FCException
        java.io.IOException
      • permissionsAllowForDeltasTransfer

        protected boolean permissionsAllowForDeltasTransfer()
        Check to see if the permissions on teh server are OK for doing Deltas
        Returns:
      • fileRegionMatch

        protected boolean fileRegionMatch​(java.nio.file.Path file,
                                          java.lang.String rFile,
                                          long offset,
                                          long length)
      • initializeProgressiveDelay

        protected void initializeProgressiveDelay()
      • initializeTransferHeadersEachAppend

        protected void initializeTransferHeadersEachAppend()
      • setBandwidth

        public void setBandwidth​(int bandwidth)
      • isIncremental

        public boolean isIncremental()
      • setIncremental

        public void setIncremental​(boolean incremental)
      • isIncrementalSizeCheckOnly

        public boolean isIncrementalSizeCheckOnly()
      • setIncrementalSizeCheckOnly

        public void setIncrementalSizeCheckOnly​(boolean incrementalSizeCheckOnly)
      • getIncTransferOption

        public int getIncTransferOption()
      • isTransferUsingDeltas

        protected boolean isTransferUsingDeltas()
      • setCompressionMethod

        public void setCompressionMethod​(int compMethod)
      • getCompressionMethod

        public int getCompressionMethod()
      • setCompressionLevel

        public void setCompressionLevel​(int compLevel)
      • getCompressionLevel

        public int getCompressionLevel()
      • setCompressionStrategy

        public void setCompressionStrategy​(int cs)
      • getCompressionStrategy

        public int getCompressionStrategy()
      • setIncTransferOption

        public void setIncTransferOption​(int incTransferOption)
      • isAutoResume

        public boolean isAutoResume()
      • setAutoResume

        public void setAutoResume​(boolean autoResume)
      • setTransferMode

        public void setTransferMode​(int transferMode)
      • getCountTransferred

        public int getCountTransferred()
        Description copied from interface: TransferState
        Returns the number of files that were actually transferred. This differs from getFilesSofar() in that it only includes files that actually got transferred. Some may be skipped because incremental is set to true and had not changed on the server.
        Specified by:
        getCountTransferred in interface TransferState
        Overrides:
        getCountTransferred in class TransferHook
        Returns:
        number of files actually transferred
      • isProgressiveTransfers

        public boolean isProgressiveTransfers()
      • setProgressiveTransfers

        public void setProgressiveTransfers​(boolean progressiveTransfers)
      • setProgressiveTimeout

        public void setProgressiveTimeout​(int i)
      • getProgressiveTimeout

        public int getProgressiveTimeout()
      • setProgressiveTimeoutFilter

        public void setProgressiveTimeoutFilter​(java.lang.String i)
      • getProgressiveTimeoutFilter

        public java.lang.String getProgressiveTimeoutFilter()
      • isStorTmp

        public boolean isStorTmp()
      • setStorTmp

        public void setStorTmp​(boolean storTmp)
      • isPreservePathStructure

        public boolean isPreservePathStructure()
      • isUseCompression

        public boolean isUseCompression()
      • getTmpMode

        public int getTmpMode()
      • getCompFileFilter

        public java.lang.String getCompFileFilter()
      • getUniqueID

        public java.lang.String getUniqueID()
      • getActiveIndex

        public int getActiveIndex()
      • removeIndex

        public void removeIndex​(int index)
      • getMinimumDeltaSize

        public static long getMinimumDeltaSize​(long sourceFileSize,
                                               long destFileSize)
      • getMaximumDeltaSize

        public static long getMaximumDeltaSize​(long sourceFileSize,
                                               long destFileSize)
      • shouldPerformIncremental

        public static boolean shouldPerformIncremental​(long sourceFileSize,
                                                       long destFileSize)
      • main

        public static void main​(java.lang.String[] args)
      • getLocalWorkingDirectory

        public java.nio.file.Path getLocalWorkingDirectory()
      • setPreservePathStructure

        public void setPreservePathStructure​(boolean preservePathStructure)
      • setUseCompression

        public void setUseCompression​(boolean useCompression)
      • setTmpMode

        public void setTmpMode​(int tmpMode)
      • setCompFileFilter

        public void setCompFileFilter​(java.lang.String compFileFilter)
      • setUniqueID

        public void setUniqueID​(java.lang.String uniqueID)
      • setAvgRTT

        public void setAvgRTT​(long avgRTT)
      • setLocalWorkingDirectory

        @Deprecated
        public void setLocalWorkingDirectory​(java.lang.String localWorkingDirectory)
        Deprecated.
      • setLocalWorkingDirectory

        public void setLocalWorkingDirectory​(java.nio.file.Path localWorkingDirectory)
      • deleteLocalFiles

        protected void deleteLocalFiles​(java.util.LinkedList<java.nio.file.Path> tmpFileList)
        Attempts to delete all files marked in temp file list locally. This allows the TransmitHandlers and RecieveHandlers to build up a list of files during deltas and have them deleted automatically in a try-finally block after the procedure exits.
        Parameters:
        tmpFileList - LinkedList LinkedList of Files that must be deleted.
      • deleteRemoteFileNames

        protected void deleteRemoteFileNames​(java.util.LinkedList<java.lang.String> tmpFileList)
        Attempts to delete all remote files marked in temp file list. This allows the TransmitHandlers and RecieveHandlers to build up a list of files during deltas and have them deleted automatically in a try-finally block after the procedure exits.
        Parameters:
        tmpFileList - LinkedList LinkedList of filenames that must be deleted.
      • getSignatureFilename

        public static java.lang.String getSignatureFilename​(java.lang.String originalFilename,
                                                            java.lang.String uniqueID)
        Returns the delta filename used when caculating signatures during a transfer. Unique name allows multiple signatures to be generated by multiple clients on the same file concurrently.
        Parameters:
        originalFilename - String
        uniqueID - String
        Returns:
        String
      • getDeltaFilename

        public static java.lang.String getDeltaFilename​(java.lang.String originalFilename,
                                                        java.lang.String uniqueID)
        Returns the delta filename used when caculating deltas during a transfer. Unique name allows multiple deltas to be generated by multiple clients on the same file concurrently.
        Parameters:
        originalFilename - String
        uniqueID - String
        Returns:
        String
      • getMD5Key

        public static java.lang.String getMD5Key​(java.nio.file.Path file)
      • isAddSkippedFilesToTransferVector

        public boolean isAddSkippedFilesToTransferVector()
      • getRemoteWorkingDirectory

        public java.lang.String getRemoteWorkingDirectory()
      • getMaxTries

        public int getMaxTries()
      • getWaitRetry

        public long getWaitRetry()
      • isTransferEmptyDirectories

        public boolean isTransferEmptyDirectories()
      • getRegex

        public java.lang.String getRegex()
      • getPostURL

        public java.lang.String getPostURL()
      • isDeletePartial

        public boolean isDeletePartial()
      • setAddSkippedFilesToTransferVector

        public void setAddSkippedFilesToTransferVector​(boolean addSkippedFilesToTransferVector)
      • setSizeCurrentFile

        public void setSizeCurrentFile​(long sizeCurrentFile)
      • setRemoteWorkingDirectory

        public void setRemoteWorkingDirectory​(java.lang.String remoteWorkingDirectory)
      • setMaxTries

        public void setMaxTries​(int maxTries)
      • setWaitRetry

        public void setWaitRetry​(long waitRetry)
      • setTransferEmptyDirectories

        public void setTransferEmptyDirectories​(boolean transferEmptyDirectories)
      • setRegex

        public void setRegex​(java.lang.String regex)
      • checkRegex

        public boolean checkRegex​(java.lang.String filename)
      • setPostURL

        public void setPostURL​(java.lang.String postURL)
      • setDeletePartial

        public void setDeletePartial​(boolean deletePartial)
      • setAppletTransferCache

        public void setAppletTransferCache​(java.util.HashMap<java.lang.String,​java.lang.Long> transferCache)
      • getVerifyMode

        public int getVerifyMode()
        Returns:
        the verifyMode
      • setVerifyMode

        public void setVerifyMode​(int verifyMode)
        Parameters:
        verifyMode - the verifyMode to set
      • validateVerifyMode

        public int validateVerifyMode​(int verifyMode)
      • enableVerifySizeIfNeeded

        protected void enableVerifySizeIfNeeded()
      • verifierRunning

        public boolean verifierRunning()
      • setMd5RateLimit

        public void setMd5RateLimit​(int md5RateLimit)
        Parameters:
        md5RateLimit - the md5RateLimit to set
      • isRenameExtensions

        public boolean isRenameExtensions()
        Returns:
        the renameExtensions
      • setRenameExtensions

        public void setRenameExtensions​(boolean renameExtensions)
        Parameters:
        renameExtensions - the renameExtensions to set
      • getZipFileSizeLimit

        public long getZipFileSizeLimit()
        Returns:
        the zipFileSizeLimit
      • setZipFileSizeLimit

        public void setZipFileSizeLimit​(long zipFileSizeLimit)
        Parameters:
        zipFileSizeLimit - the zipFileSizeLimit to set
      • isDowngradeModeOnReConnect

        public boolean isDowngradeModeOnReConnect()
        Returns:
        the downgradeModeOnReConnect
      • setDowngradeModeOnReConnect

        public void setDowngradeModeOnReConnect​(boolean downgradeModeOnReConnect)
        Parameters:
        downgradeModeOnReConnect - the downgradeModeOnReConnect to set
      • getCurrentFileTime

        public long getCurrentFileTime()
        Returns:
        the currentFileTime
      • calculateAverageKbpsRate

        protected int calculateAverageKbpsRate​(long bytesTotal,
                                               long msTotal)
        Calculate a transfer rate in kilo bits per second Kilo here means a 1000, because this is a rate. We're not counting power of 2 sized blocks stored on disk
        Parameters:
        bytesTotal - - total bytes
        msTotal - - total time span in milliseconds
        Returns:
        rate in kilo bits per second
      • logFinalTransferStats

        public void logFinalTransferStats​(java.nio.file.Path file)
        Parameters:
        file -
      • passesProgressiveTimeoutFilter

        protected boolean passesProgressiveTimeoutFilter​(java.lang.String sourceFile)
      • calculateEffectiveRateOfZipTransfer

        public int calculateEffectiveRateOfZipTransfer​(long sizeOfAllFilesZipped,
                                                       long timeForEffectiveRate)
      • verifySize

        protected void verifySize​(java.nio.file.Path file,
                                  java.lang.String rFile)
      • verifyFileContents

        protected void verifyFileContents​(java.nio.file.Path file,
                                          java.lang.String rfile,
                                          boolean invalidateRemoteCache)
                                   throws unlimited.core.util.common.exception.FCException,
                                          java.io.IOException
        Throws:
        unlimited.core.util.common.exception.FCException
        java.io.IOException
      • incrementSofarAllFiles

        protected void incrementSofarAllFiles​(boolean isADeltaTransfer,
                                              long dataSize)
      • doesDirectoryContainContents

        protected abstract boolean doesDirectoryContainContents​(T t)
      • filterEmptyDirectoriesIfNeeded

        protected void filterEmptyDirectoriesIfNeeded()
      • setParentPooled

        public void setParentPooled​(boolean pooled)
      • getPreservePathStructureFileName

        public static java.lang.String getPreservePathStructureFileName​(java.lang.String lFile)
      • setAutoUnzip

        public void setAutoUnzip​(boolean b)
      • isAutoUnzip

        public boolean isAutoUnzip()
      • addTransferredRemoteFile

        public void addTransferredRemoteFile​(java.lang.String filename)
      • addTransferredLocalFile

        public void addTransferredLocalFile​(java.lang.String filename)
      • waitForDiscWriteProgressives

        public static void waitForDiscWriteProgressives​(MultiTransferHandler<?> handler)
      • handleProgressiveDelayBeforeAppend

        public void handleProgressiveDelayBeforeAppend()
      • updateStatusTransferring

        protected final void updateStatusTransferring()
      • getRetransferHeaderSize

        public long getRetransferHeaderSize()
        Returns:
        the retransferHeaderSize
      • setRetransferHeaderSize

        public void setRetransferHeaderSize​(long retransferHeaderSize)
        Parameters:
        retransferHeaderSize - the retransferHeaderSize to set
      • getClientAPI

        public FCClient getClientAPI()
        Returns:
        the clientAPI
      • setClientAPI

        public void setClientAPI​(FCClient clientAPI)
        Parameters:
        clientAPI - the clientAPI to set