Skip to content

Conversation

@ivgag
Copy link
Contributor

@ivgag ivgag commented Aug 1, 2023

@ivgag ivgag changed the title IGNITE-19009 WIP IGNITE-19009 Introduce file transfer support in messaging Aug 1, 2023
@ivgag ivgag force-pushed the IGNITE-19009 branch 13 times, most recently from a5bb82f to 187fe66 Compare August 2, 2023 06:15
return raf.length();
int nextChunkNumber() {
if (!hasNextChunk()) {
throw new IllegalStateException("No more chunks to read");
Copy link
Contributor

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?

Copy link
Contributor Author

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().

FileConsumer<M> consumer
) {
metadataToHandler.compute(
metadataToConsumer.compute(
Copy link
Contributor

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"));
Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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

Comment on lines 95 to 97
if (read != toRead) {
throw new IOException("Failed to read chunk data from file: expected " + toRead + ", actual " + read + "]");
}
Copy link
Contributor

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) -> {
Copy link
Contributor

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) {
Copy link
Contributor

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

@PakhomovAlexander PakhomovAlexander merged commit 77d9823 into apache:main Aug 21, 2023
@ivgag ivgag deleted the IGNITE-19009 branch August 21, 2023 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants