public class SegmentFetcher extends Object implements OnData, OnDataValidationFailed, OnTimeout, OnNetworkNack
| Modifier and Type | Class and Description |
|---|---|
static class |
SegmentFetcher.ErrorCode |
static interface |
SegmentFetcher.OnComplete |
static interface |
SegmentFetcher.OnError |
static class |
SegmentFetcher.Options |
static interface |
SegmentFetcher.VerifySegment |
| Modifier and Type | Field and Description |
|---|---|
static SegmentFetcher.VerifySegment |
DontVerifySegment
DontVerifySegment may be used in fetch to skip validation of Data packets.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
fetch(Face face,
Interest baseInterest,
KeyChain validatorKeyChain,
SegmentFetcher.OnComplete onComplete,
SegmentFetcher.OnError onError) |
static void |
fetch(Face face,
Interest baseInterest,
SegmentFetcher.Options options,
KeyChain validatorKeyChain,
SegmentFetcher.OnComplete onComplete,
SegmentFetcher.OnError onError)
Initiate segment fetching.
|
static void |
fetch(Face face,
Interest baseInterest,
SegmentFetcher.Options options,
SegmentFetcher.VerifySegment verifySegment,
SegmentFetcher.OnComplete onComplete,
SegmentFetcher.OnError onError)
Initiate segment fetching.
|
static void |
fetch(Face face,
Interest baseInterest,
SegmentFetcher.Options options,
Validator validator,
SegmentFetcher.OnComplete onComplete,
SegmentFetcher.OnError onError)
Initiate segment fetching.
|
static void |
fetch(Face face,
Interest baseInterest,
SegmentFetcher.VerifySegment verifySegment,
SegmentFetcher.OnComplete onComplete,
SegmentFetcher.OnError onError) |
static void |
fetch(Face face,
Interest baseInterest,
Validator validator,
SegmentFetcher.OnComplete onComplete,
SegmentFetcher.OnError onError) |
boolean |
isStopped() |
void |
onData(Interest originalInterest,
Data data)
When a matching data packet is received, onData is called.
|
void |
onDataValidationFailed(Data data,
String reason)
When verifyData fails, onDataValidationFailed is called.
|
void |
onNetworkNack(Interest interest,
NetworkNack networkNack)
When a network Nack packet is received, onNetworkNack is called.
|
void |
onTimeout(Interest interest)
If the interest times out according to the interest lifetime, onTimeout is
called.
|
void |
stop()
Stop fetching packets and clear the received data.
|
public static final SegmentFetcher.VerifySegment DontVerifySegment
public static void fetch(Face face, Interest baseInterest, SegmentFetcher.Options options, SegmentFetcher.VerifySegment verifySegment, SegmentFetcher.OnComplete onComplete, SegmentFetcher.OnError onError)
face - This calls face.expressInterest to fetch more segments.baseInterest - Interest for the initial segment of requested data.
This interest may include a custom InterestLifetime and parameters that
will propagate to all subsequent Interests. The only exception is that the
initial Interest will be forced to include the "CanBePrefix=true" and
"MustBeFresh=true" parameters, which will not be included in subsequent
interests.options - A set of options to control the sending and receiving of packets
in the AIMD pipelining.verifySegment - When a Data packet is received this calls
verifySegment.verifySegment(data). If it returns false then abort fetching
and call onError.onError with ErrorCode.SEGMENT_VERIFICATION_FAILED. If
data validation is not required, use DontVerifySegment.
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.onComplete - When all segments are received, call
onComplete.onComplete(content) where content is the concatenation of the
content of all the segments.
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.onError - Call onError.onError(errorCode, message) for timeout or an
error processing segments.
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.public static void fetch(Face face, Interest baseInterest, SegmentFetcher.VerifySegment verifySegment, SegmentFetcher.OnComplete onComplete, SegmentFetcher.OnError onError)
public static void fetch(Face face, Interest baseInterest, SegmentFetcher.Options options, KeyChain validatorKeyChain, SegmentFetcher.OnComplete onComplete, SegmentFetcher.OnError onError)
face - This calls face.expressInterest to fetch more segments.baseInterest - Interest for the initial segment of requested data.
This interest may include a custom InterestLifetime and parameters that
will propagate to all subsequent Interests. The only exception is that the
initial Interest will be forced to include the "CanBePrefix=true" and
"MustBeFresh=true" parameters, which will not be included in subsequent
interests.options - A set of options to control the sending and receiving of packets
in the AIMD pipelining.validatorKeyChain - When a Data packet is received this calls
validatorKeyChain.verifyData(data). If validation fails then abort
fetching and call onError with SEGMENT_VERIFICATION_FAILED. This does not
make a copy of the KeyChain; the object must remain valid while fetching.
If validatorKeyChain is null, this does not validate the data packet.onComplete - When all segments are received, call
onComplete.onComplete(content) where content is the concatenation of the
content of all the segments.
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.onError - Call onError.onError(errorCode, message) for timeout or an
error processing segments.
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.public static void fetch(Face face, Interest baseInterest, KeyChain validatorKeyChain, SegmentFetcher.OnComplete onComplete, SegmentFetcher.OnError onError)
public static void fetch(Face face, Interest baseInterest, SegmentFetcher.Options options, Validator validator, SegmentFetcher.OnComplete onComplete, SegmentFetcher.OnError onError)
face - This calls face.expressInterest to fetch more segments.baseInterest - Interest for the initial segment of requested data.
This interest may include a custom InterestLifetime and parameters that
will propagate to all subsequent Interests. The only exception is that the
initial Interest will be forced to include the "CanBePrefix=true" and
"MustBeFresh=true" parameters, which will not be included in subsequent
interests.options - A set of options to control the sending and receiving of packets
in the AIMD pipelining.validator - The Validator, the fetcher will use to validate data.
The caller must ensure the validator remains valid until either #onComplete
or #onError has been signaled.onComplete - When all segments are received, call
onComplete.onComplete(content) where content is the concatenation of the
content of all the segments.
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.onError - Call onError.onError(errorCode, message) for timeout or an
error processing segments.
NOTE: The library will log any exceptions thrown by this callback, but for
better error handling the callback should catch and properly handle any
exceptions.public static void fetch(Face face, Interest baseInterest, Validator validator, SegmentFetcher.OnComplete onComplete, SegmentFetcher.OnError onError)
public void onData(Interest originalInterest, Data data)
OnDatapublic void onDataValidationFailed(Data data, String reason)
OnDataValidationFailedonDataValidationFailed in interface OnDataValidationFaileddata - The data object being verified.reason - The reason for the failed validation.public void onNetworkNack(Interest interest, NetworkNack networkNack)
OnNetworkNackonNetworkNack in interface OnNetworkNackinterest - The interest given to Face.expressInterest. NOTE: You must
not change the interest object - if you need to change it then make a copy.networkNack - The received NetworkNack object.public void onTimeout(Interest interest)
OnTimeoutpublic boolean isStopped()
public void stop()
Copyright © 2019. All rights reserved.