Package org.dataloader
Class DataLoaderOptions
- java.lang.Object
-
- org.dataloader.DataLoaderOptions
-
@PublicApi public class DataLoaderOptions extends java.lang.Object
Configuration options forDataLoader
instances. This is an immutable class so each time you change a value it returns a new object.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DataLoaderOptions.Builder
-
Constructor Summary
Constructors Constructor Description DataLoaderOptions()
Creates a new data loader options with default settings.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
batchingEnabled()
Option that determines whether to use batching (the default), or not.java.util.Optional<CacheKey>
cacheKeyFunction()
Gets an (optional) function to invoke for creation of the cache key, if caching is enabled.java.util.Optional<CacheMap<?,?>>
cacheMap()
Gets the (optional) cache map implementation that is used for caching, if caching is enabled.boolean
cachingEnabled()
Option that determines whether to use caching of futures (the default), or not.boolean
cachingExceptionsEnabled()
Option that determines whether to cache exceptional values (the default), or not.boolean
equals(java.lang.Object o)
BatchLoaderContextProvider
getBatchLoaderContextProvider()
BatchLoaderScheduler
getBatchLoaderScheduler()
DataLoaderInstrumentation
getInstrumentation()
StatisticsCollector
getStatisticsCollector()
ValueCacheOptions
getValueCacheOptions()
int
maxBatchSize()
Gets the maximum number of keys that will be presented to theBatchLoader
function before they are split into multiple classstatic DataLoaderOptions
newDefaultOptions()
static DataLoaderOptions.Builder
newOptions()
static DataLoaderOptions.Builder
newOptions(DataLoaderOptions otherOptions)
Copies the options into a new builderDataLoaderOptions
transform(java.util.function.Consumer<DataLoaderOptions.Builder> builderConsumer)
Will transform the current options in to a builder ands allow you to build a new set of optionsjava.util.Optional<ValueCache<?,?>>
valueCache()
Gets the (optional) cache store implementation that is used for value caching, if caching is enabled.
-
-
-
Method Detail
-
newDefaultOptions
public static DataLoaderOptions newDefaultOptions()
- Returns:
- a new default data loader options that you can then customize
-
newOptions
public static DataLoaderOptions.Builder newOptions()
- Returns:
- a new default data loader options builder that you can then customize
-
newOptions
public static DataLoaderOptions.Builder newOptions(DataLoaderOptions otherOptions)
Copies the options into a new builder- Returns:
- a new default data loader options builder that you can then customize
-
transform
public DataLoaderOptions transform(java.util.function.Consumer<DataLoaderOptions.Builder> builderConsumer)
Will transform the current options in to a builder ands allow you to build a new set of options- Parameters:
builderConsumer
- the consumer of a builder that has this objects starting values- Returns:
- a new
DataLoaderOptions
object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
batchingEnabled
public boolean batchingEnabled()
Option that determines whether to use batching (the default), or not.- Returns:
true
when batching is enabled,false
otherwise
-
cachingEnabled
public boolean cachingEnabled()
Option that determines whether to use caching of futures (the default), or not.- Returns:
true
when caching is enabled,false
otherwise
-
cachingExceptionsEnabled
public boolean cachingExceptionsEnabled()
Option that determines whether to cache exceptional values (the default), or not.For short-lived caches (that is request caches) it makes sense to cache exceptions since it's likely the key is still poisoned. However, if you have long-lived caches, then it may make sense to set this to false since the downstream system may have recovered from its failure mode.
- Returns:
true
when exceptional values are cached is enabled,false
otherwise
-
cacheKeyFunction
public java.util.Optional<CacheKey> cacheKeyFunction()
Gets an (optional) function to invoke for creation of the cache key, if caching is enabled.If missing the cache key defaults to the
key
type parameter of the data loader of typeK
.- Returns:
- an optional with the function, or empty optional
-
cacheMap
public java.util.Optional<CacheMap<?,?>> cacheMap()
Gets the (optional) cache map implementation that is used for caching, if caching is enabled.If missing a standard
LinkedHashMap
will be used as the cache implementation.- Returns:
- an optional with the cache map instance, or empty
-
maxBatchSize
public int maxBatchSize()
Gets the maximum number of keys that will be presented to theBatchLoader
function before they are split into multiple class- Returns:
- the maximum batch size or -1 if there is no limit
-
getStatisticsCollector
public StatisticsCollector getStatisticsCollector()
- Returns:
- the statistics collector to use with these options
-
getBatchLoaderContextProvider
public BatchLoaderContextProvider getBatchLoaderContextProvider()
- Returns:
- the batch environment provider that will be used to give context to batch load functions
-
valueCache
public java.util.Optional<ValueCache<?,?>> valueCache()
Gets the (optional) cache store implementation that is used for value caching, if caching is enabled.If missing, a no-op implementation will be used.
- Returns:
- an optional with the cache store instance, or empty
-
getValueCacheOptions
public ValueCacheOptions getValueCacheOptions()
- Returns:
- the
ValueCacheOptions
that control how theValueCache
will be used
-
getBatchLoaderScheduler
public BatchLoaderScheduler getBatchLoaderScheduler()
- Returns:
- the
BatchLoaderScheduler
to use, which can be null
-
getInstrumentation
public DataLoaderInstrumentation getInstrumentation()
- Returns:
- the
DataLoaderInstrumentation
to use
-
-