Package org.apache.hadoop.fs.impl
Class AbstractFSBuilderImpl<S,B extends FSBuilder<S,B>>
java.lang.Object
org.apache.hadoop.fs.impl.AbstractFSBuilderImpl<S,B>
- Type Parameters:
S- Return type on theFSBuilder.build()call.B- type of builder itself.
- All Implemented Interfaces:
FSBuilder<S,B>
- Direct Known Subclasses:
FSDataOutputStreamBuilder,FutureDataInputStreamBuilderImpl,MultipartUploaderBuilderImpl
@Public
@Unstable
public abstract class AbstractFSBuilderImpl<S,B extends FSBuilder<S,B>>
extends Object
implements FSBuilder<S,B>
Builder for filesystem/filecontext operations of various kinds,
with option support.
.opt("fs.s3a.open.option.caching", true)
.opt("fs.option.openfile.read.policy", "random, adaptive")
.opt("fs.s3a.open.option.etag", "9fe4c37c25b")
.optLong("fs.option.openfile.length", 1_500_000_000_000)
.must("fs.option.openfile.buffer.size", 256_000)
.mustLong("fs.option.openfile.split.start", 256_000_000)
.mustLong("fs.option.openfile.split.end", 512_000_000)
.build();
Configuration keys declared in an opt() may be ignored by
a builder which does not recognise them.
Configuration keys declared in a must() function set must
be understood by the implementation or a
IllegalArgumentException will be thrown.-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractFSBuilderImpl(Optional<Path> optionalPath, Optional<PathHandle> optionalPathHandle) Constructor with both optional path and path handle.protectedAbstractFSBuilderImpl(Path path) protectedAbstractFSBuilderImpl(PathHandle pathHandle) -
Method Summary
Modifier and TypeMethodDescriptionGet all the keys that are set as mandatory keys.Get all the keys that are set as optional keys.Get the optional path; may be empty.Get the optional path handle; may be empty.Get the mutable option configuration.getPath()Get the path: only valid if constructed with a path.Get the PathHandle: only valid if constructed with a PathHandle.Get the cast builder.Set mandatory boolean option.Set mandatory long option, despite passing in a floating point value.This parameter is converted to a long and passed toFSBuilder.mustLong(String, long)-all decimal precision is lost.Set mandatory int option.Set mandatory long option.Set mandatory option to the Builder.Set a string array as mandatory option.mustDouble(String key, double value) Set optional double parameter for the Builder.Set mandatory long parameter for the Builder.Set optional boolean parameter for the Builder.Set optional double parameter for the Builder.Set optional float parameter for the Builder.Set optional int parameter for the Builder.Set optional long parameter for the Builder.Set optional Builder parameter.Set an array of string values as optional parameter for the Builder.Set optional double parameter for the Builder.Set optional long parameter for the Builder.protected voidrejectUnknownMandatoryKeys(Collection<String> knownKeys, String extraErrorText) Reject a configuration if one or more mandatory keys are not in the set of mandatory keys.static voidrejectUnknownMandatoryKeys(Set<String> mandatory, Collection<String> knownKeys, String extraErrorText) Reject a configuration if one or more mandatory keys are not in the set of mandatory keys.
-
Field Details
-
UNKNOWN_MANDATORY_KEY
- See Also:
-
-
Constructor Details
-
AbstractFSBuilderImpl
protected AbstractFSBuilderImpl(@Nonnull Optional<Path> optionalPath, @Nonnull Optional<PathHandle> optionalPathHandle) Constructor with both optional path and path handle. Either or both argument may be empty, but it is an error for both to be defined.- Parameters:
optionalPath- a path or emptyoptionalPathHandle- a path handle/empty- Throws:
IllegalArgumentException- if both parameters are set.
-
AbstractFSBuilderImpl
-
AbstractFSBuilderImpl
-
-
Method Details
-
getThisBuilder
Get the cast builder.- Returns:
- this object, typecast
-
getOptionalPath
Get the optional path; may be empty.- Returns:
- the optional path field.
-
getPath
Get the path: only valid if constructed with a path.- Returns:
- the path
- Throws:
NoSuchElementException- if the field is empty.
-
getOptionalPathHandle
Get the optional path handle; may be empty.- Returns:
- the optional path handle field.
-
getPathHandle
Get the PathHandle: only valid if constructed with a PathHandle.- Returns:
- the PathHandle
- Throws:
NoSuchElementException- if the field is empty.
-
opt
Set optional Builder parameter. -
opt
Set optional boolean parameter for the Builder. -
opt
Set optional int parameter for the Builder. -
opt
Description copied from interface:FSBuilderSet optional long parameter for the Builder. -
optLong
Description copied from interface:FSBuilderSet optional long parameter for the Builder. -
opt
Set optional float parameter for the Builder. -
opt
Set optional double parameter for the Builder. -
optDouble
Set optional double parameter for the Builder. -
opt
Set an array of string values as optional parameter for the Builder. -
must
Set mandatory option to the Builder. If the option is not supported or unavailable on theFileSystem, the client should expectFSBuilder.build()throws IllegalArgumentException. -
must
Set mandatory boolean option. -
mustLong
Description copied from interface:FSBuilderSet mandatory long parameter for the Builder. -
mustDouble
Set optional double parameter for the Builder. -
must
Set mandatory int option. -
must
Description copied from interface:FSBuilderSet mandatory long option. -
must
Description copied from interface:FSBuilderThis parameter is converted to a long and passed toFSBuilder.mustLong(String, long)-all decimal precision is lost. -
must
Description copied from interface:FSBuilderSet mandatory long option, despite passing in a floating point value. -
must
Set a string array as mandatory option. -
getOptions
Get the mutable option configuration.- Returns:
- the option configuration.
-
getMandatoryKeys
Get all the keys that are set as mandatory keys.- Returns:
- mandatory keys.
-
getOptionalKeys
Get all the keys that are set as optional keys.- Returns:
- optional keys.
-
rejectUnknownMandatoryKeys
protected void rejectUnknownMandatoryKeys(Collection<String> knownKeys, String extraErrorText) throws IllegalArgumentException Reject a configuration if one or more mandatory keys are not in the set of mandatory keys. The first invalid key raises the exception; the order of the scan and hence the specific key raising the exception is undefined.- Parameters:
knownKeys- a possibly empty collection of known keysextraErrorText- extra error text to include.- Throws:
IllegalArgumentException- if any key is unknown.
-
rejectUnknownMandatoryKeys
public static void rejectUnknownMandatoryKeys(Set<String> mandatory, Collection<String> knownKeys, String extraErrorText) throws IllegalArgumentException Reject a configuration if one or more mandatory keys are not in the set of mandatory keys. The first invalid key raises the exception; the order of the scan and hence the specific key raising the exception is undefined.- Parameters:
mandatory- the set of mandatory keysknownKeys- a possibly empty collection of known keysextraErrorText- extra error text to include.- Throws:
IllegalArgumentException- if any key is unknown.
-