Class DefaultFileChunkPacketSender
java.lang.Object
eu.cloudnetservice.driver.network.chunk.defaults.DefaultChunkedPacketProvider
eu.cloudnetservice.driver.network.chunk.defaults.DefaultFileChunkPacketSender
- All Implemented Interfaces:
ChunkedPacketProvider,ChunkedPacketSender
public class DefaultFileChunkPacketSender
extends DefaultChunkedPacketProvider
implements ChunkedPacketSender
Represents a default implementation of a chunked packet sender specifically created for chunked transferring of a
huge file, e.g. a zip archive.
This class shouldn't get instantiated directly, use ChunkedPacketSender.forFileTransfer() instead.
- Since:
- 4.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface eu.cloudnetservice.driver.network.chunk.ChunkedPacketSender
ChunkedPacketSender.Builder -
Field Summary
FieldsFields inherited from class eu.cloudnetservice.driver.network.chunk.defaults.DefaultChunkedPacketProvider
chunkSessionInformation, transferStatus -
Constructor Summary
ConstructorsConstructorDescriptionDefaultFileChunkPacketSender(@NonNull ChunkSessionInformation sessionInformation, @NonNull InputStream source, @NonNull Consumer<Packet> packetSplitter) Constructs a new chunked packet sender for file transfer. -
Method Summary
Modifier and TypeMethodDescriptionTransfers the data from the data source to all targets of this sender.Methods inherited from class eu.cloudnetservice.driver.network.chunk.defaults.DefaultChunkedPacketProvider
sessionInformation, transferStatusMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface eu.cloudnetservice.driver.network.chunk.ChunkedPacketProvider
sessionInformation, transferStatus
-
Field Details
-
source
-
packetSplitter
-
-
Constructor Details
-
DefaultFileChunkPacketSender
public DefaultFileChunkPacketSender(@NonNull @NonNull ChunkSessionInformation sessionInformation, @NonNull @NonNull InputStream source, @NonNull @NonNull Consumer<Packet> packetSplitter) Constructs a new chunked packet sender for file transfer.- Parameters:
sessionInformation- the information about the chunked session.source- the source stream of the file, will be closed automatically.packetSplitter- the splitter for each chunk part to transfer.- Throws:
NullPointerException- if either the information, source or splitter is null.
-
-
Method Details
-
transferChunkedData
Transfers the data from the data source to all targets of this sender. The returned future is completed when:- The transfer completed successfully.
- The transfer failed for any reason. The returned task will be completed holding the reason exception.
- Specified by:
transferChunkedDatain interfaceChunkedPacketSender- Returns:
- a future completed when the transfer finishes.
-