Conversation
…es between restarts
sproshev
approved these changes
Jan 22, 2019
|
|
||
| import java.util.List; | ||
|
|
||
| interface TorrentClient { |
| import java.nio.file.Path; | ||
| import java.util.*; | ||
|
|
||
| public class TorrentClientImpl implements TorrentClient { |
There was a problem hiding this comment.
и от этого класса тоже мало толку, т.к. непонятно, что нового он приносит относительно TorrentClientFileSystemManager
| return; | ||
| } | ||
| } | ||
|
|
| return filePartSize; | ||
| } | ||
|
|
||
| File createNewFilePart(int id, int partNumber, InputStream inputStream) throws IOException { |
There was a problem hiding this comment.
по факту сюда всегда передается массив байт, а не поток
| try (FileInputStream reader = new FileInputStream(fileToReadFrom)) { | ||
| byte[] buffer = new byte[filePartSize]; | ||
| for (int partNumber = 0; partNumber < totalPartsCount; partNumber++) { | ||
| int count = reader.read(buffer); |
There was a problem hiding this comment.
count не обязательно равен filePartSize, т.ч. копирование может быть некорректным
|
|
||
| File partContentInFile = part.getPartFileContentInFile(); | ||
| try (FileInputStream partContentReader = new FileInputStream(partContentInFile)) { | ||
| i = partContentReader.read(bytes); |
| } | ||
|
|
||
| if (!availableParts.equals(allPartsNumber)) { | ||
| return false; |
| executor.execute(() -> { | ||
| try (ServerSocket trackerSocket = new ServerSocket(TRACKER_PORT)) { | ||
| while (true) { | ||
| try (Tracker2ClientConnection client = new Tracker2ClientConnection(trackerSocket.accept())) { |
There was a problem hiding this comment.
работа с одним клиентом в единицу времени :(
|
|
||
| // list & update | ||
| ClientSendsRequest(String command, short port) throws FileNotFoundException { | ||
| this.client = new TorrentClientImpl(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Преподаватель : @sproshev
Добавлено решение для третьей домашней работы по реализации Torrent-a:
Для запуска приложения необходимо:
./gradlew installDisttorrent/build/install/torrent/bin/torrenttorrent/client/build/install/client/bin/client