Example #1
0
 public PausedMode(TorrentManager manager, DiskManager diskManager, ConnectionManager connectionManager, EngineSettings settings)
     : base(manager, diskManager, connectionManager, settings)
 {
     // When in the Paused mode, a special RateLimiter will
     // activate and disable transfers. PauseMode itself
     // does not need to do anything special.
 }
Example #2
0
        /// <summary>
        /// Uninitializes the torrent engine.
        /// </summary>
        public static void Uninitialize()
        {
            if (!isInitialized)
            {
                return;
            }

            Log.LogInfo("[Engine] Shutting down TorrentEngine.");

            isInitialized = false;
            isStopping    = true;
            workQueueResetEvent.Set();

            TorrentRegistry.StopAllActiveTorrents();
            PeerListener.StopListening();
            LocalPeerListener.StopListening();
            LocalPeerDiscovery.Uninitialize();
            DiskManager.Uninitialize();

            if (engineThread != null)
            {
                engineThread.Join();
                engineThread = null;
            }
        }
Example #3
0
        public DownloadMode(TorrentManager manager, DiskManager diskManager, ConnectionManager connectionManager, EngineSettings settings)
            : base(manager, diskManager, connectionManager, settings)
        {
            manager.HashFails = 0;

            // Ensure the state is correct. We should either be downloading or seeding based on
            // the files whose priority is not set to 'DoNotDownload'.
            if (manager.Complete)
            {
                state = TorrentState.Seeding;
            }
            else
            {
                state = TorrentState.Downloading;

                UpdatePartialProgress();
                if (Manager.PartialProgressSelector.TrueCount > 0)
                {
                    // If some files are marked as DoNotDownload and we have downloaded all downloadable files, mark the torrent as 'seeding'.
                    // Otherwise if we have not downloaded all downloadable files, set the state to Downloading.
                    if (Manager.Bitfield.CountTrue(Manager.PartialProgressSelector) == Manager.PartialProgressSelector.TrueCount && state == TorrentState.Downloading)
                    {
                        state = TorrentState.Seeding;
                    }
                }
            }
        }
Example #4
0
        public void Setup()
        {
            conn              = new ConnectionPair().WithTimeout();
            Settings          = new EngineSettings();
            PieceWriter       = new TestWriter();
            DiskManager       = new DiskManager(Settings, PieceWriter);
            ConnectionManager = new ConnectionManager("LocalPeerId", Settings, DiskManager);
            TrackerManager    = new ManualTrackerManager();

            int[] fileSizes =
            {
                Piece.BlockSize / 2,
                Piece.BlockSize * 32,
                Piece.BlockSize * 2,
                Piece.BlockSize * 13,
            };
            Manager = TestRig.CreateMultiFileManager(fileSizes, Piece.BlockSize * 2);
            Manager.SetTrackerManager(TrackerManager);
            Peer = new PeerId(new Peer("", new Uri("ipv4://123.123.123.123:12345"), EncryptionTypes.All), conn.Outgoing, Manager.Bitfield?.Clone().SetAll(true))
            {
                ProcessingQueue = true,
                IsChoking       = false,
                AmInterested    = true,
            };
        }
Example #5
0
        internal async Task UpdateSeedingDownloadingState()
        {
            UpdatePartialProgress();

            //If download is fully complete, set state to 'Seeding' and send an announce to the tracker.
            if (Manager.Complete && state == TorrentState.Downloading)
            {
                state = TorrentState.Seeding;
                await Task.WhenAll(
                    Manager.TrackerManager.AnnounceAsync (TorrentEvent.Completed, CancellationToken.None).AsTask(),
                    DiskManager.FlushAsync(Manager)
                    );

                Manager.RaiseTorrentStateChanged(new TorrentStateChangedEventArgs(Manager, TorrentState.Downloading, TorrentState.Seeding));
            }
            else if (Manager.PartialProgressSelector.TrueCount > 0)
            {
                // If some files are marked as DoNotDownload and we have downloaded all downloadable files, mark the torrent as 'seeding'.
                // Otherwise if we have not downloaded all downloadable files, set the state to Downloading.
                if (Manager.Bitfield.CountTrue(Manager.PartialProgressSelector) == Manager.PartialProgressSelector.TrueCount && state == TorrentState.Downloading)
                {
                    state = TorrentState.Seeding;
                    await DiskManager.FlushAsync(Manager);

                    Manager.RaiseTorrentStateChanged(new TorrentStateChangedEventArgs(Manager, TorrentState.Downloading, TorrentState.Seeding));
                }
                else if (Manager.Bitfield.CountTrue(Manager.PartialProgressSelector) < Manager.PartialProgressSelector.TrueCount && state == TorrentState.Seeding)
                {
                    state = TorrentState.Downloading;
                    await DiskManager.FlushAsync(Manager);

                    Manager.RaiseTorrentStateChanged(new TorrentStateChangedEventArgs(Manager, TorrentState.Seeding, TorrentState.Downloading));
                }
            }
        }
Example #6
0
 public HashingMode(TorrentManager manager, DiskManager diskManager, ConnectionManager connectionManager, EngineSettings settings)
     : base(manager, diskManager, connectionManager, settings)
 {
     // Mark it as completed so we are *not* paused by default;
     PausedCompletionSource = new TaskCompletionSource <object> ();
     PausedCompletionSource.TrySetResult(null);
 }
 public InitialSeedingMode(TorrentManager manager, DiskManager diskManager, ConnectionManager connectionManager, EngineSettings settings)
     : base(manager, diskManager, connectionManager, settings)
 {
     unchoker = new InitialSeedUnchoker(manager);
     manager.chokeUnchoker = unchoker;
     zero = new BitField(manager.Bitfield.Length);
 }
Example #8
0
        internal async ReusableTask TryHashPendingFilesAsync ()
        {
            // If we cannot handle peer messages then we should not try to async hash.
            // This adds a little bit of a double meaning to the property (for now).
            // Any mode which doesn't allow processing peer messages also does not allow
            // partial hashing.
            if (hashingPendingFiles || !Manager.HasMetadata || !CanHandleMessages)
                return;

            // FIXME: Handle errors from DiskManager and also handle cancellation if the Mode is replaced.
            hashingPendingFiles = true;
            try {
                foreach (TorrentFile file in Manager.Torrent.Files) {
                    // If the start piece *and* end piece have been hashed, then every piece in between must've been hashed!
                    if (file.Priority != Priority.DoNotDownload && (Manager.UnhashedPieces[file.StartPieceIndex] || Manager.UnhashedPieces[file.EndPieceIndex])) {
                        for (int index = file.StartPieceIndex; index <= file.EndPieceIndex; index++) {
                            if (Manager.UnhashedPieces[index]) {
                                byte[] hash = await DiskManager.GetHashAsync (Manager.Torrent, index);
                                Cancellation.Token.ThrowIfCancellationRequested ();

                                bool hashPassed = hash != null && Manager.Torrent.Pieces.IsValid (hash, index);
                                Manager.OnPieceHashed (index, hashPassed, 1, 1);

                                if (hashPassed)
                                    Manager.finishedPieces.Enqueue (new HaveMessage (index));
                            }
                        }
                    }
                }
            } finally {
                hashingPendingFiles = false;
            }
        }
Example #9
0
        /// <summary>
        /// Initializes the torrent engine.
        /// </summary>
        public static void Initialize()
        {
            if (isInitialized)
            {
                return;
            }

            isInitialized = true;

            Log.LogInfo("[Engine] Starting up TorrentEngine.");

            if (engineThread != null)
            {
                engineThread.Join();
                engineThread = null;
            }

            isStopping = false;
            workQueueResetEvent.Set();

            DiskManager.Initialize();
            PeerListener.StartListening();
            LocalPeerListener.StartListening();
            LocalPeerDiscovery.Initialize();

            engineThread          = new Thread(EngineLoop);
            engineThread.Priority = ThreadPriority.Normal;
            engineThread.Name     = "TorrentEngineThread";
            engineThread.Start();
        }
 // Use this for initialization
 void Awake()
 {
     Debug.Log("Start");
     SSDirector.getInstance().currentSceneController = this;
     DM = Singleton <DiskManager> .Instance;
     SR = Singleton <ScoreRecorder> .Instance;
     RD = Singleton <RoundData> .Instance;
 }
Example #11
0
        public async Task WaitForHashingToComplete()
        {
            if (!Manager.HasMetadata)
            {
                throw new TorrentException("A hash check cannot be performed if TorrentManager.HasMetadata is false.");
            }

            // Ensure the partial progress selector is up to date before we start hashing
            UpdatePartialProgress();

            int piecesHashed = 0;

            Manager.HashFails = 0;

            // Delete any existing fast resume data. We will need to recreate it after hashing completes.
            await Manager.MaybeDeleteFastResumeAsync();

            if (await DiskManager.CheckAnyFilesExistAsync(Manager))
            {
                Cancellation.Token.ThrowIfCancellationRequested();
                for (int index = 0; index < Manager.Torrent.Pieces.Count; index++)
                {
                    if (!Manager.Files.Any(f => index >= f.StartPieceIndex && index <= f.EndPieceIndex && f.Priority != Priority.DoNotDownload))
                    {
                        // If a file is marked 'do not download' ensure we update the TorrentFiles
                        // so they also report that the piece is not available/downloaded.
                        Manager.OnPieceHashed(index, false, piecesHashed, Manager.PartialProgressSelector.TrueCount);
                        // Then mark this piece as being unhashed so we don't try to download it.
                        Manager.UnhashedPieces[index] = true;
                        continue;
                    }

                    await PausedCompletionSource.Task;
                    Cancellation.Token.ThrowIfCancellationRequested();

                    byte[] hash = await DiskManager.GetHashAsync(Manager, index);

                    if (Cancellation.Token.IsCancellationRequested)
                    {
                        await DiskManager.CloseFilesAsync(Manager);

                        Cancellation.Token.ThrowIfCancellationRequested();
                    }

                    bool hashPassed = hash != null && Manager.Torrent.Pieces.IsValid(hash, index);
                    Manager.OnPieceHashed(index, hashPassed, ++piecesHashed, Manager.PartialProgressSelector.TrueCount);
                }
            }
            else
            {
                await PausedCompletionSource.Task;

                for (int i = 0; i < Manager.Torrent.Pieces.Count; i++)
                {
                    Manager.OnPieceHashed(i, false, ++piecesHashed, Manager.Torrent.Pieces.Count);
                }
            }
        }
        public async Task WaitForHashingToComplete()
        {
            if (!Manager.HasMetadata)
            {
                throw new TorrentException("A hash check cannot be performed if TorrentManager.HasMetadata is false.");
            }

            Manager.HashFails = 0;

            // Delete any existing fast resume data. We will need to recreate it after hashing completes.
            await Manager.MaybeDeleteFastResumeAsync();

            bool atLeastOneDoNotDownload = Manager.Files.Any(t => t.Priority == Priority.DoNotDownload);

            if (await DiskManager.CheckAnyFilesExistAsync(Manager))
            {
                int piecesHashed = 0;
                Cancellation.Token.ThrowIfCancellationRequested();
                // bep52: Properly support this
                using var hashBuffer = MemoryPool.Default.Rent(Manager.InfoHashes.GetMaxByteCount(), out Memory <byte> hashMemory);
                var hashes = new PieceHash(hashMemory);
                for (int index = 0; index < Manager.Torrent !.PieceCount; index++)
                {
                    if (atLeastOneDoNotDownload && !Manager.Files.Any(f => index >= f.StartPieceIndex && index <= f.EndPieceIndex && f.Priority != Priority.DoNotDownload))
                    {
                        // If a file is marked 'do not download' ensure we update the TorrentFiles
                        // so they also report that the piece is not available/downloaded.
                        Manager.OnPieceHashed(index, false, piecesHashed, Manager.PartialProgressSelector.TrueCount);
                        // Then mark this piece as being unhashed so we don't try to download it.
                        Manager.UnhashedPieces[index] = true;
                        continue;
                    }

                    await PausedCompletionSource.Task;
                    Cancellation.Token.ThrowIfCancellationRequested();

                    var successful = await DiskManager.GetHashAsync(Manager, index, hashes);

                    if (Cancellation.Token.IsCancellationRequested)
                    {
                        await DiskManager.CloseFilesAsync(Manager);

                        Cancellation.Token.ThrowIfCancellationRequested();
                    }

                    bool hashPassed = successful && Manager.PieceHashes.IsValid(hashes, index);
                    Manager.OnPieceHashed(index, hashPassed, ++piecesHashed, Manager.PartialProgressSelector.TrueCount);
                }
            }
            else
            {
                await PausedCompletionSource.Task;
                for (int i = 0; i < Manager.Torrent !.PieceCount; i++)
                {
                    Manager.OnPieceHashed(i, false, i + 1, Manager.Torrent.PieceCount);
                }
            }
        }
Example #13
0
        protected Mode(TorrentManager manager, DiskManager diskManager, ConnectionManager connectionManager, EngineSettings settings)
        {
            Cancellation      = new CancellationTokenSource();
            ConnectionManager = connectionManager;
            DiskManager       = diskManager;
            Manager           = manager;
            Settings          = settings;

            manager.chokeUnchoker = new ChokeUnchokeManager(manager, manager.Settings.MinimumTimeBetweenReviews, manager.Settings.PercentOfMaxRateToSkipReview);
        }
Example #14
0
        protected Mode(TorrentManager manager, DiskManager diskManager, ConnectionManager connectionManager, EngineSettings settings)
        {
            Cancellation      = new CancellationTokenSource();
            ConnectionManager = connectionManager;
            DiskManager       = diskManager;
            Manager           = manager;
            Settings          = settings;

            manager.chokeUnchoker = new ChokeUnchokeManager(new TorrentManagerUnchokeable(manager));
        }
Example #15
0
        public DownloadMode(TorrentManager manager, DiskManager diskManager, ConnectionManager connectionManager, EngineSettings settings)
            : base(manager, diskManager, connectionManager, settings)
        {
            manager.HashFails = 0;

            // Ensure the state is correct. We should either be downloading or seeding based on
            // the files whose priority is not set to 'DoNotDownload'.
            state = manager.Complete ? TorrentState.Seeding : TorrentState.Downloading;
            UpdateSeedingDownloadingState();
        }
Example #16
0
        public static void CheckCommand(string command)
        {
            try
            {
                if (command == "crash")
                {
                    SystemManager.FatalError("TEST_CRASH", "Test crash");
                }
                else if (command == "diskpart")
                {
                    currentApp = new Diskpart();
                }
                else if (command.StartsWith("create"))
                {
                    string name    = workingDir + command.Substring(7);
                    string content = command.Substring(7 + name.Length + 1);

                    DiskManager.CreateFile(name, content);
                }
                else if (command.StartsWith("cd"))
                {
                    string dir = command.Substring(3);

                    if (dir == "..")
                    {
                        workingDir = @"\" + workingDir.Substring(0, workingDir.Length - workingDir.Substring(workingDir.IndexOf(@"\")).Length);
                    }
                    else
                    {
                        workingDir += dir + @"\";
                    }
                }
                else if (command == "clear")
                {
                    Console.Clear();
                }
                else if (command.StartsWith("read"))
                {
                    Console.WriteLine(DiskManager.ReadFile(workingDir + command.Substring(5)));
                }
                else if (command == "dir")
                {
                    DiskManager.ListFiles("0", workingDir);
                }
                else
                {
                    Console.WriteLine("Invalid command.");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: ", e.ToString());
            }
        }
Example #17
0
        public Nativefier(int maxCount, string appName)
        {
            if (maxCount < 1)
            {
                throw new ArgumentException("Nativefier max count must be greater than 1");
            }
            appName.CheckForNullAndThrow("appName cannot be null");
            appName.CheckIsEmptyAndThrow("appName cannot be empty");

            MemoryManager = new MemoryManager <T>((maxCount / 2) > 0 ? (maxCount / 2) : 1);
            DiskManager   = new DiskManager <T>(maxCount, appName);
        }
Example #18
0
        async void WritePieceAsync (PieceMessage message, Piece piece)
        {
            long offset = (long) message.PieceIndex * Manager.Torrent.PieceLength + message.StartOffset;

            try {
                await DiskManager.WriteAsync (Manager.Torrent, offset, message.Data, message.RequestLength);
                if (Cancellation.IsCancellationRequested)
                    return;
            } catch (Exception ex) {
                Manager.TrySetError (Reason.WriteFailure, ex);
                return;
            } finally {
                ClientEngine.BufferPool.Return (message.Data);
            }

            piece.TotalWritten++;

            // If we haven't received all the pieces to disk, there's no point in hash checking
            if (!piece.AllBlocksWritten)
                return;

            // Hashcheck the piece as we now have all the blocks.
            byte[] hash;
            try {
                hash = await DiskManager.GetHashAsync (Manager.Torrent, piece.Index);
                if (Cancellation.IsCancellationRequested)
                    return;
            } catch (Exception ex) {
                Manager.TrySetError (Reason.ReadFailure, ex);
                return;
            }

            bool result = hash != null && Manager.Torrent.Pieces.IsValid (hash, piece.Index);
            Manager.OnPieceHashed (piece.Index, result, 1, 1);
            Manager.PieceManager.PendingHashCheckPieces[piece.Index] = false;
            if (!result)
                Manager.HashFails++;

            for (int i = 0; i < piece.Blocks.Length; i++)
                if (piece.Blocks[i].RequestedOff != null)
                    peers.Add ((PeerId) piece.Blocks[i].RequestedOff);

            foreach (PeerId peer in peers) {
                peer.Peer.HashedPiece (result);
                if (peer.Peer.TotalHashFails == 5)
                    ConnectionManager.CleanupSocket (Manager, peer);
            }
            peers.Clear ();

            // If the piece was successfully hashed, enqueue a new "have" message to be sent out
            if (result)
                Manager.finishedPieces.Enqueue (new HaveMessage (piece.Index));
        }
Example #19
0
 protected override void BeforeRun()
 {
     Console.ForegroundColor = ConsoleColor.Blue;
     Console.WriteLine("Starting mayaOS");
     Console.WriteLine("Starting FileSystem");
     DiskManager.RegisterFileSystem();
     Console.WriteLine("Done");
     Console.ForegroundColor = ConsoleColor.White;
     Console.Clear();
     UserManager.UserManager.InitUserManager();
     UserManager.UserManager.Login();
     Console.WriteLine("Welcome {0}", user);
 }
Example #20
0
        public async Task WaitForHashingToComplete()
        {
            if (!Manager.HasMetadata)
            {
                throw new TorrentException("A hash check cannot be performed if TorrentManager.HasMetadata is false.");
            }

            Manager.HashFails = 0;
            if (await DiskManager.CheckAnyFilesExistAsync(Manager.Torrent))
            {
                Cancellation.Token.ThrowIfCancellationRequested();
                for (int index = 0; index < Manager.Torrent.Pieces.Count; index++)
                {
                    if (!Manager.Torrent.Files.Any(f => index >= f.StartPieceIndex && index <= f.EndPieceIndex && f.Priority != Priority.DoNotDownload))
                    {
                        // If a file is marked 'do not download' ensure we update the TorrentFiles
                        // so they also report that the piece is not available/downloaded.
                        Manager.OnPieceHashed(index, false);
                        // Then mark this piece as being unhashed so we don't try to download it.
                        Manager.UnhashedPieces[index] = true;
                        continue;
                    }

                    await PausedCompletionSource.Task;
                    Cancellation.Token.ThrowIfCancellationRequested();

                    var hash = await DiskManager.GetHashAsync(Manager.Torrent, index);

                    if (Cancellation.Token.IsCancellationRequested)
                    {
                        await DiskManager.CloseFilesAsync(Manager.Torrent);

                        Cancellation.Token.ThrowIfCancellationRequested();
                    }

                    var hashPassed = hash != null && Manager.Torrent.Pieces.IsValid(hash, index);
                    Manager.OnPieceHashed(index, hashPassed);
                }
            }
            else
            {
                await PausedCompletionSource.Task;

                for (int i = 0; i < Manager.Torrent.Pieces.Count; i++)
                {
                    Manager.OnPieceHashed(i, false);
                }
            }
        }
Example #21
0
        public void MoveDisksTest(int count)
        {
            var diskManager = new DiskManager(count);

            diskManager.MoveDisks();

            var tower = diskManager.Destination;

            // Verify Destination tower has all the disks
            int disk = 1;
            while(disk == count)
            {
                Assert.Equal(disk++, tower.Pop());
            }
        }
Example #22
0
        private void ProcExport(object obj)
        {
            try
            {
                RecordDisk recordDisk = DiskManager.GetInstance().GetDisk(driveName);// new RecordDisk(drive);

                FileStream fs = (FileStream)obj;

                recordDisk.Export(fs);
                fs.Close();
            }
            catch (Exception)
            {
            }
        }
Example #23
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            driveName = comboBox1.Text;
            if (string.IsNullOrEmpty(driveName))
            {
                gridControl1.DataSource = null;
                return;
            }
            RecordDisk recordDisk = DiskManager.GetInstance().GetDisk(driveName);// new RecordDisk(drive);



            gridControl1.DataSource = recordDisk.RecordList;

            JudgeSelect();
        }
Example #24
0
 async Task VerifyHashState()
 {
     // FIXME: I should really just ensure that zero length files always exist on disk. If the first file is
     // a zero length file and someone deletes it after the first piece has been written to disk, it will
     // never be recreated. If the downloaded data requires this file to exist, we have an issue.
     if (Manager.HasMetadata)
     {
         foreach (var file in Manager.Torrent.Files)
         {
             if (!file.BitField.AllFalse && Manager.HashChecked && file.Length > 0)
             {
                 Manager.HashChecked &= await DiskManager.CheckFileExistsAsync(file);
             }
         }
     }
 }
Example #25
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string drive = comboBox1.Text;

            if (string.IsNullOrEmpty(drive))
            {
                gridControl1.DataSource = null;
                return;
            }
            RecordDisk recordDisk = DiskManager.GetInstance().GetDisk(drive);// new RecordDisk(drive);


            DiskChannel diskChannel = new DiskChannel(recordDisk);

            gridControl1.DataSource = diskChannel.Channels;
        }
Example #26
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            RecordDisk recordDisk = DiskManager.GetInstance().GetDisk(driveName);

            if (recordDisk.ExportOK)
            {
                wizardPage2.AllowNext = true;
                progressBar1.Value    = progressBar1.Maximum;
                progressBar2.Value    = progressBar2.Maximum;
                timer1.Enabled        = false;
            }
            else
            {
                progressBar1.Value = (int)(progressBar1.Maximum * recordDisk.CurrentFileRate);
                progressBar2.Value = (int)(progressBar2.Maximum * recordDisk.ExportRate);
            }
        }
Example #27
0
        public async Task WaitForHashingToComplete()
        {
            if (!Manager.HasMetadata)
            {
                throw new TorrentException("A hash check cannot be performed if TorrentManager.HasMetadata is false.");
            }

            Manager.HashFails = 0;
            if (await DiskManager.CheckAnyFilesExistAsync(Manager.Torrent))
            {
                Cancellation.Token.ThrowIfCancellationRequested();
                for (int index = 0; index < Manager.Torrent.Pieces.Count; index++)
                {
                    if (!Manager.Torrent.Files.Any(f => index >= f.StartPieceIndex && index <= f.EndPieceIndex && f.Priority != Priority.DoNotDownload))
                    {
                        Manager.Bitfield [index] = false;
                        continue;
                    }

                    await PausedCompletionSource.Task;
                    Cancellation.Token.ThrowIfCancellationRequested();

                    var hash = await DiskManager.GetHashAsync(Manager.Torrent, index);

                    if (Cancellation.Token.IsCancellationRequested)
                    {
                        await DiskManager.CloseFilesAsync(Manager.Torrent);

                        Cancellation.Token.ThrowIfCancellationRequested();
                    }

                    var hashPassed = hash != null && Manager.Torrent.Pieces.IsValid(hash, index);
                    Manager.OnPieceHashed(index, hashPassed);
                }
            }
            else
            {
                await PausedCompletionSource.Task;

                for (int i = 0; i < Manager.Torrent.Pieces.Count; i++)
                {
                    Manager.OnPieceHashed(i, false);
                }
            }
        }
Example #28
0
        public Nativefier(int diskMaxCount, int memoryMaxCount, string appName, string containerName)
        {
            if (diskMaxCount < 1)
            {
                throw new ArgumentException("Nativefier disk max count must be greater than 1");
            }
            if (memoryMaxCount < 1)
            {
                throw new ArgumentException("Nativefier memory max count must be greater than 1");
            }
            appName.CheckForNullAndThrow("appName cannot be null");
            appName.CheckIsEmptyAndThrow("appName cannot be empty");
            containerName.CheckForNullAndThrow("containerName cannot be null");
            containerName.CheckIsEmptyAndThrow("containerName cannot be empty");

            MemoryManager = new MemoryManager <T>(memoryMaxCount);
            DiskManager   = new DiskManager <T>(diskMaxCount, appName, containerName);
        }
        public void Setup ()
        {
            conn = new ConnectionPair ().WithTimeout ();
            Settings = new EngineSettings ();
            PieceWriter = new TestWriter ();
            DiskManager = new DiskManager (Settings, PieceWriter);
            ConnectionManager = new ConnectionManager ("LocalPeerId", Settings, DiskManager);
            TrackerManager = new ManualTrackerManager ();

            long[] fileSizes = {
                Piece.BlockSize / 2,
                Piece.BlockSize * 32,
                Piece.BlockSize * 2,
                Piece.BlockSize * 13,
            };
            Manager = TestRig.CreateMultiFileManager (fileSizes, Piece.BlockSize * 2);
            Manager.SetTrackerManager (TrackerManager);
        }
Example #30
0
        private void FormSignalSelect_Load(object sender, EventArgs e)
        {
            DiskManager.GetInstance().Reset();
            DriveInfo[] allDrives = DriveInfo.GetDrives();

            foreach (DriveInfo info in allDrives)
            {
                if (info.DriveType == DriveType.Removable)
                {
                    comboBox1.Items.Add(info.Name.TrimEnd(new char[] { '\\' }));
                }
            }

            if (comboBox1.Items.Count > 0)
            {
                comboBox1.SelectedIndex = 0;
            }
        }
 public DiskWriterLimiter(DiskManager manager)
 {
     this.manager = manager;
 }
 public DiskWriterLimiter(DiskManager manager)
 {
     _manager = manager;
 }