-
Notifications
You must be signed in to change notification settings - Fork 133
IGNITE-19009 Introduce file transfer support in messaging #2390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
a5bb82f to
187fe66
Compare
.../testFixtures/java/org/apache/ignite/internal/testframework/matchers/FileContentMatcher.java
Outdated
Show resolved
Hide resolved
.../testFixtures/java/org/apache/ignite/internal/testframework/matchers/FileContentMatcher.java
Outdated
Show resolved
Hide resolved
...ansferring/src/testFixtures/java/org/apache/ignite/internal/network/file/FileAssertions.java
Outdated
Show resolved
Hide resolved
...src/integrationTest/java/org/apache/ignite/internal/network/file/ItFileTransferringTest.java
Outdated
Show resolved
Hide resolved
...es/file-transferring/src/main/java/org/apache/ignite/internal/network/file/FileReceiver.java
Outdated
Show resolved
Hide resolved
...es/file-transferring/src/main/java/org/apache/ignite/internal/network/file/FileReceiver.java
Outdated
Show resolved
Hide resolved
...transferring/src/main/java/org/apache/ignite/internal/network/file/messages/ChunkedFile.java
Outdated
Show resolved
Hide resolved
modules/network-api/src/main/java/org/apache/ignite/network/MessagingService.java
Show resolved
Hide resolved
modules/network-api/src/main/java/org/apache/ignite/network/MessagingService.java
Show resolved
Hide resolved
...fer/src/integrationTest/java/org/apache/ignite/internal/network/file/ItFileTransferTest.java
Outdated
Show resolved
Hide resolved
...s/file-transfer/src/main/java/org/apache/ignite/internal/network/file/ChunkedFileReader.java
Outdated
Show resolved
Hide resolved
...s/file-transfer/src/main/java/org/apache/ignite/internal/network/file/ChunkedFileReader.java
Outdated
Show resolved
Hide resolved
| return raf.length(); | ||
| int nextChunkNumber() { | ||
| if (!hasNextChunk()) { | ||
| throw new IllegalStateException("No more chunks to read"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, this is one of the most widely misused exceptions out there.
Why do we even need the exception in this method in the first place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect that there is a next chunk if it has a number. So we have to return a special value (e.g., -1) or throw an exception to indicate that there are no more chunks to read. Actually, I don't see a difference between those approaches because it is expected that a user has checked the absence of the next chunk by calling hasNextChunk().
...s/file-transfer/src/main/java/org/apache/ignite/internal/network/file/ChunkedFileWriter.java
Outdated
Show resolved
Hide resolved
...-transfer/src/main/java/org/apache/ignite/internal/network/file/FileTransferServiceImpl.java
Outdated
Show resolved
Hide resolved
| FileConsumer<M> consumer | ||
| ) { | ||
| metadataToHandler.compute( | ||
| metadataToConsumer.compute( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you renamed "handler" to "consumer"? Consumer is too broad of a term
| List<Path> paths | ||
| ) { | ||
| if (paths.isEmpty()) { | ||
| return failedFuture(new FileTransferException("No files to upload")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this a problem? What happens if user tries to do this, will he have an error in his log? It's not what he would expect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it puzzling when someone uploads or downloads an empty list of files. What could this mean? That the files weren't found, or something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to keep empty lists restricted to avoid confusion until we really need support for this. Right now we are going to transfer only deployment units. It's impossible to have a deployment unit without any files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What error will a user see in this case? If it's an error message in a server log, then it's a problem. If it's an exception message in his application, then I'm fine with it
modules/file-transfer/src/test/java/org/apache/ignite/internal/network/file/FileSenderTest.java
Outdated
Show resolved
Hide resolved
modules/file-transfer/src/test/java/org/apache/ignite/internal/network/file/FileSenderTest.java
Outdated
Show resolved
Hide resolved
| if (read != toRead) { | ||
| throw new IOException("Failed to read chunk data from file: expected " + toRead + ", actual " + read + "]"); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not what I meant, you should read in a loop.
-1 would mean an unexpected end of file, but you don't check for it exclusively. Please use the API properly
| )); | ||
|
|
||
| // Check that directory was created successfully and send response to the sender. | ||
| directoryFuture.handle((directory, e) -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you're tired of me at this point, but does it really have to be one huge statement in the code?
Why not split it into several statements, by extracting temporary results into variables?
Why not extract some parts into methods?
Are you comfortable yourself with the code of such complexity?
| hasNextChunk = stream.available() > 0; | ||
|
|
||
| if (offset == length) { | ||
| if (stream.available() == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why it's not a !hasNextChunk, but whatever.
I've been looking at this code for too long. If there are more problems, I probably won't notice them at this point
…st.transferIsRegisteredBeforeResponseIsSent
https://issues.apache.org/jira/browse/IGNITE-19009