public class ClientImplOptions extends Object
ClientImpl on construction.| Constructor and Description |
|---|
ClientImplOptions()
Create a new set of options, initialized with default values.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
getAutoRefreshing()
Deprecated.
As of release 1.2.0, replaced by
isAutoRefreshing(). |
CatalogueFetcher |
getCatalogueFetcher() |
long |
getMaxAcceptableStaleness() |
long |
getMinTimeBetweenQueries() |
Map<String,byte[]> |
getPersistentCacheMap() |
Map<String,byte[]> |
getPersistentCacheProvider()
Deprecated.
As of release 1.4.0, replaced by
getPersistentCacheMap(). |
long |
getStalenessWarningThreshold()
Return the minimum staleness of the catalogue, above which
ClientImpl will begin to
report warning-level messages in its logs. |
long |
getTimeBetweenRetries() |
boolean |
isAutoRefreshing() |
ClientImplOptions |
setAutoRefreshing(boolean autoRefreshing)
Set auto-refreshing on or off.
|
ClientImplOptions |
setCatalogueFetcher(CatalogueFetcher catalogueFetcher)
Tell
ClientImpl to use a custom CatalogueFetcher. |
ClientImplOptions |
setMaxAcceptableStaleness(long milliseconds)
Set a limit on maximum allowed staleness of the used catalogue.
|
ClientImplOptions |
setMinTimeBetweenQueries(long milliseconds)
Set a minimum time between subsequent auto-refresh queries.
|
ClientImplOptions |
setPersistentCacheMap(Map<String,byte[]> persistentCacheMap)
Tell
ClientImpl to use a given map as persistent cache between its subsequent
instantiations. |
ClientImplOptions |
setTimeBetweenRetries(long milliseconds)
Set a time between query retries, when no valid response was received.
|
String |
toString() |
public ClientImplOptions()
Use set* methods to change the defaults. Default values are mentioned in the
documentation of each method. Note, that each of the set* methods returns
this, to enable setter chaining.
@Deprecated public boolean getAutoRefreshing()
isAutoRefreshing().isAutoRefreshing().public CatalogueFetcher getCatalogueFetcher()
CatalogueFetcher instance which will be used by the client. See
setCatalogueFetcher(CatalogueFetcher).public long getMaxAcceptableStaleness()
setMaxAcceptableStaleness(long).public long getMinTimeBetweenQueries()
setMinTimeBetweenQueries(long).public Map<String,byte[]> getPersistentCacheMap()
setPersistentCacheMap(Map).@Deprecated public Map<String,byte[]> getPersistentCacheProvider()
getPersistentCacheMap().setPersistentCacheMap(Map).public long getStalenessWarningThreshold()
ClientImpl will begin to
report warning-level messages in its logs.public long getTimeBetweenRetries()
setTimeBetweenRetries(long).public boolean isAutoRefreshing()
setAutoRefreshing(boolean).public ClientImplOptions setAutoRefreshing(boolean autoRefreshing)
Once this option is turned on, ClientImpl will automatically call its
ClientImpl.refresh() method whenever the currently held version of the catalogue
document expires. This will usually be done in a separate background thread, but
ClientImpl might also try to do this during the construction time, if it thinks it's
needed.
autoRefreshing - true to turn auto-refreshing on, false to turn it off.public ClientImplOptions setCatalogueFetcher(CatalogueFetcher catalogueFetcher)
ClientImpl to use a custom CatalogueFetcher.
By default, it will use a DefaultCatalogueFetcher instance for fetching the catalogue
files from the Registry Service. You might want to tweak this is some situations (for example
when running unit-tests).
catalogueFetcher - CatalogueFetcher to use.public ClientImplOptions setMaxAcceptableStaleness(long milliseconds)
In general, if auto-refreshing is turned on, ClientImpl will always keep the internal
copy of the catalogue up-to-date. However, if ClientImpl will not be able to fetch a
fresh copy, then it will reuse the older (stale) copy of the catalogue. The amount of time
which has passed since the internal copy has expired is defined as "catalogue staleness".
It is reasonable to to use a copy of a catalogue which is one or two hours stale, if - for some
reason - we cannot retrieve the fresh copy. However, as the staleness grows, it becomes more
dangerous to use such stale copy. Once the staleness reaches a certain limit,
ClientImpl will start to throw RegistryClient.UnacceptableStalenessException exceptions. These
are not checked exceptions, and they are not usually caught, so, most likely, they will cause
your application to break. Note, that ClientImpl will attempt to warn you before
this happens (see getStalenessWarningThreshold()).
milliseconds - the new value of acceptable staleness, in milliseconds.public ClientImplOptions setMinTimeBetweenQueries(long milliseconds)
In auto-refreshing mode ClientImpl attempts to query the Registry Service as often as
the Registry Service wishes. For example: If the Registry tells us to refresh in 15
minutes, then we will refresh in 15 minutes. However, if the Registry tells us to refresh in 1
second (which might be due to invalid CatalogueFetcher implementation), then
ClientImpl will not listen to such suggestion, and use the value supplied here
instead.
This option is relevant only in auto-refreshing mode. Manual calls to
ClientImpl.refresh() will never be limited.
milliseconds - the minimum time between auto-refresh queries, in milliseconds.public ClientImplOptions setPersistentCacheMap(Map<String,byte[]> persistentCacheMap)
ClientImpl to use a given map as persistent cache between its subsequent
instantiations. Default is null.
If given, ClientImpl will use this map to keep a persistent copy of the catalogue. It
will load the catalogue from this cache during construction. If the loaded copy is fresh
enough, then it may speed up the construction time and help you avoid
RegistryClient.UnacceptableStalenessException exceptions. It is okay for this cache to be purged
without notice, it is also okay for some elements to be removed once other stay. You should
however take care that all of its keys are modifiable by ClientImpl only.
In most cases, supplying this object makes sense only if its data is persisted to a hard drive,
or a similar "more persistent than usual" medium (otherwise you can simply keep
ClientImpl in memory instead of destroying it between runs).
persistentCacheMap - a new map to use as cache.public ClientImplOptions setTimeBetweenRetries(long milliseconds)
This option is relevant only in auto-refreshing mode. If the catalogue cannot be retrieved for some reason, this is the time we will wait before we retry.
milliseconds - time, in milliseconds.Copyright © 2017. All rights reserved.