Exemplo n.º 1
0
 internal void EndRecording(bool closingDueToCancellation)
 {
     _recordQueue.Add(null);
     _writeThread.Join();
     if (!closingDueToCancellation)
     {
         File.Delete(_transferLogFile);
     }
 }
 /// <summary>
 /// Starts each thread worker. Waits for each thread worker to finish. If there was an exception throws it.
 /// Else returns a contentsummary
 /// </summary>
 /// <returns>Content summary-Total file count, directory count, total size</returns>
 private ContentSummary GetContentSummary()
 {
     _queue.Add(new DirectoryEntry(RootPath));
     for (int i = 0; i < NumThreads; i++)
     {
         _threadWorker[i].Start();
     }
     for (int i = 0; i < NumThreads; i++)
     {
         _threadWorker[i].Join();
     }
     if (_clientException != null)//No need to lock here
     {
         throw _clientException;
     }
     return(new ContentSummary(_directoryCount, _fileCount, _totalBytes, _totalBytes));
 }
        /// <summary>
        /// Starts the Acl Processor threads. Returns the results or throws any exceptions.
        /// </summary>
        /// <returns>Acl Processor: Number of files and directories processed or ACl Verification: Number of files and directories processed and number of files and directories correctly processed by Acl Processor</returns>
        private AclProcessorStats ProcessAcl()
        {
            if (_cancelToken.IsCancellationRequested)
            {
                return(_isVerify
                ? new AclProcessorStats(_filesEnumerated, _directoryEnumerated, _incorrectFileCount, _incorrectDirectoryCount, _linkPaths)
                : new AclProcessorStats(_filesEnumerated, _directoryEnumerated, 0, 0, _linkPaths));
            }

            //Create the threads
            for (int i = 0; i < NumThreads; i++)
            {
                _threadWorker[i] = new Thread(Run)
                {
                    Name = "Thread: " + i
                };
            }

            if (_aclStatusTracker != null)
            {
                _threadStats = new Thread(StatsRun)
                {
                    Name = "StatsThread"
                };
            }
            if (!string.IsNullOrEmpty(_incorrectVerifyFile))
            {
                _threadDumpIncorrectFiles = new Thread(VerifyFileDumpRun)
                {
                    Name = "Verify Dump Thread"
                };
            }

            // Put the first entry to queue
            DirectoryEntry dir = Client.GetDirectoryEntry(_inputPath);

            ProcessDirectoryEntry(dir);

            // Start the threads
            for (int i = 0; i < NumThreads; i++)
            {
                _threadWorker[i].Start();
            }

            if (_aclStatusTracker != null)
            {
                _threadStats.Start();
            }

            if (!string.IsNullOrEmpty(_incorrectVerifyFile))
            {
                _threadDumpIncorrectFiles.Start();
            }

            //Join the threads
            for (int i = 0; i < NumThreads; i++)
            {
                _threadWorker[i].Join();
            }

            if (_aclStatusTracker != null)
            {
                Interlocked.Increment(ref _consumerDone);
                _threadStats.Join();
            }

            if (!string.IsNullOrEmpty(_incorrectVerifyFile))
            {
                // Signify the end of the queue
                _incorrectFileList.Add(null);
                _threadDumpIncorrectFiles.Join();
            }

            if (GetException() != null)
            {
                throw GetException();
            }

            return(_isVerify
                ? new AclProcessorStats(_filesEnumerated, _directoryEnumerated, _incorrectFileCount, _incorrectDirectoryCount, _linkPaths)
                : new AclProcessorStats(_filesEnumerated, _directoryEnumerated, 0, 0, _linkPaths));
        }
Exemplo n.º 4
0
 internal void AddToQueue(T a)
 {
     _queue.Add(a);
 }