public abstract class AbstractDynamicMetadataResolver extends AbstractMetadataResolver implements DynamicMetadataResolver
Modifier and Type | Class and Description |
---|---|
protected class |
AbstractDynamicMetadataResolver.BackingStoreCleanupSweeper
Background maintenance task which cleans expired and idle metadata from the backing store, and removes
orphaned entity management data.
|
static class |
AbstractDynamicMetadataResolver.DefaultCacheKeyGenerator
Default function for generating a cache key for loading and saving an
EntityDescriptor
using a XMLObjectLoadSaveManager . |
protected class |
AbstractDynamicMetadataResolver.DynamicEntityBackingStore
Specialized entity backing store implementation for dynamic metadata resolvers.
|
protected class |
AbstractDynamicMetadataResolver.EntityManagementData
Class holding per-entity management data.
|
static class |
AbstractDynamicMetadataResolver.PersistentCacheInitializationMetrics
Class used to track metrics related to the initialization from the persistent cache.
|
AbstractMetadataResolver.EntityBackingStore
Modifier and Type | Field and Description |
---|---|
private Long |
backgroundInitializationFromCacheDelay
The delay in milliseconds after which to schedule the background initialization from the persistent cache.
|
private AbstractDynamicMetadataResolver.BackingStoreCleanupSweeper |
cleanupTask
The backing store cleanup sweeper background task.
|
private Long |
cleanupTaskInterval
The interval in milliseconds at which the cleanup task should run.
|
private boolean |
createdOwnTaskTimer
Whether we created our own task timer during object construction.
|
private com.codahale.metrics.Gauge<Integer> |
gaugeNumLiveEntityIDs
Metrics Gauge for the number of live entityIDs.
|
private com.codahale.metrics.Gauge<AbstractDynamicMetadataResolver.PersistentCacheInitializationMetrics> |
gaugePersistentCacheInit
Metrics Gauge for the persistent cache initialization.
|
private com.google.common.base.Predicate<EntityDescriptor> |
initializationFromCachePredicate
Predicate which determines whether a given entity should be loaded from the persistent cache
at resolver initialization time.
|
private boolean |
initializeFromPersistentCacheInBackground
Flag indicating whether should initialize from the persistent cache in the background.
|
private boolean |
initializing
Flag used to track state of whether currently initializing or not.
|
private org.slf4j.Logger |
log
Class logger.
|
private Long |
maxCacheDuration
Maximum cache duration.
|
private Long |
maxIdleEntityData
The maximum idle time in milliseconds for which the resolver will keep data for a given entityID,
before it is removed.
|
static String |
METRIC_GAUGE_NUM_LIVE_ENTITYIDS
Metric name for the gauge of the number of live entityIDs.
|
static String |
METRIC_GAUGE_PERSISTENT_CACHE_INIT
Metric name for the gauge of the persistent cache initialization metrics.
|
static String |
METRIC_RATIOGAUGE_FETCH_TO_RESOLVE
Metric name for the ratio gauge of fetches to resolve requests.
|
static String |
METRIC_TIMER_FETCH_FROM_ORIGIN_SOURCE
Metric name for the timer for
fetchFromOriginSource(CriteriaSet) . |
static String |
METRIC_TIMER_RESOLVE
Metric name for the timer for
resolve(CriteriaSet) . |
private String |
metricsBaseName
Base name for Metrics instrumentation names.
|
private Long |
minCacheDuration
Minimum cache duration.
|
private AbstractDynamicMetadataResolver.PersistentCacheInitializationMetrics |
persistentCacheInitMetrics
Object tracking metrics related to the persistent cache initialization.
|
private com.google.common.base.Function<EntityDescriptor,String> |
persistentCacheKeyGenerator
Function for generating the String key used with the cache manager.
|
private org.opensaml.core.xml.persist.XMLObjectLoadSaveManager<EntityDescriptor> |
persistentCacheManager
The manager for the persistent cache store for resolved metadata.
|
private com.codahale.metrics.RatioGauge |
ratioGaugeFetchToResolve
Metrics RatioGauge for count of origin fetches to resolves.
|
private Float |
refreshDelayFactor
Factor used to compute when the next refresh interval will occur.
|
private boolean |
removeIdleEntityData
Flag indicating whether idle entity data should be removed.
|
private Timer |
taskTimer
Timer used to schedule background metadata update tasks.
|
private com.codahale.metrics.Timer |
timerFetchFromOriginSource
Metrics Timer for
fetchFromOriginSource(CriteriaSet) . |
private com.codahale.metrics.Timer |
timerResolve
Metrics Timer for
resolve(CriteriaSet) . |
Constructor and Description |
---|
AbstractDynamicMetadataResolver(Timer backgroundTaskTimer)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected org.joda.time.DateTime |
computeExpirationTime(EntityDescriptor entityDescriptor,
org.joda.time.DateTime now)
Compute the effective expiration time for the specified metadata.
|
protected org.joda.time.DateTime |
computeRefreshTriggerTime(org.joda.time.DateTime expirationTime,
org.joda.time.DateTime nowDateTime)
Compute the refresh trigger time.
|
protected AbstractDynamicMetadataResolver.DynamicEntityBackingStore |
createNewBackingStore()
Create a new backing store instance for EntityDescriptor data.
|
protected void |
doDestroy() |
protected abstract org.opensaml.core.xml.XMLObject |
fetchFromOriginSource(net.shibboleth.utilities.java.support.resolver.CriteriaSet criteria)
Fetch the metadata from the origin source.
|
Long |
getBackgroundInitializationFromCacheDelay()
Get the delay in milliseconds after which to schedule the background initialization from the persistent cache.
|
protected AbstractDynamicMetadataResolver.DynamicEntityBackingStore |
getBackingStore()
Get the EntityDescriptor backing store currently in use by the metadata resolver.
|
Long |
getCleanupTaskInterval()
Get the interval in milliseconds at which the cleanup task should run.
|
com.google.common.base.Predicate<EntityDescriptor> |
getInitializationFromCachePredicate()
Get the predicate which determines whether a given entity should be loaded from the persistent cache
at resolver initialization time.
|
Long |
getMaxCacheDuration()
Get the maximum cache duration for metadata.
|
Long |
getMaxIdleEntityData()
Get the maximum idle time in milliseconds for which the resolver will keep data for a given entityID,
before it is removed.
|
String |
getMetricsBaseName()
Get the base name for Metrics instrumentation.
|
Long |
getMinCacheDuration()
Get the minimum cache duration for metadata.
|
com.google.common.base.Function<EntityDescriptor,String> |
getPersistentCacheKeyGenerator()
Get the function for generating the String key used with the persistent cache manager.
|
org.opensaml.core.xml.persist.XMLObjectLoadSaveManager<EntityDescriptor> |
getPersistentCacheManager()
Get the manager for the persistent cache store for resolved metadata.
|
Float |
getRefreshDelayFactor()
Gets the delay factor used to compute the next refresh time.
|
protected void |
initializeFromPersistentCache()
Initialize the resolver with data from the persistent cache manager, if enabled.
|
private void |
initializeMetricsInstrumentation()
Initialize the Metrics-based instrumentation.
|
protected void |
initMetadataResolver()
Subclasses should override this method to perform any initialization logic necessary.
|
boolean |
isInitializeFromPersistentCacheInBackground()
Get the flag indicating whether should initialize from the persistent cache in the background.
|
boolean |
isPersistentCachingEnabled()
Get the flag indicating whether persistent caching of the resolved metadata is enabled.
|
boolean |
isRemoveIdleEntityData()
Get the flag indicating whether idle entity data should be removed.
|
protected List<EntityDescriptor> |
lookupEntityID(String entityID)
Get list of descriptors matching an entityID.
|
protected org.opensaml.core.xml.XMLObject |
prepareForFiltering(org.opensaml.core.xml.XMLObject input)
Prepare the object for filtering: If persistent caching is enabled, return a clone of the object
in case the configured filter mutates the object.
|
protected void |
preProcessEntityDescriptor(EntityDescriptor entityDescriptor,
AbstractMetadataResolver.EntityBackingStore backingStore)
Pre-process the specified entity descriptor, updating the specified entity backing store instance as necessary.
|
protected void |
processNewMetadata(org.opensaml.core.xml.XMLObject root,
String expectedEntityID)
Process the specified new metadata document, including metadata filtering, and store the
processed metadata in the backing store.
|
protected void |
processNewMetadata(org.opensaml.core.xml.XMLObject root,
String expectedEntityID,
boolean fromPersistentCache)
Process the specified new metadata document, including metadata filtering, and store the
processed metadata in the backing store.
|
protected void |
processPersistentCacheEntry(String currentKey,
EntityDescriptor descriptor)
Process an entry loaded from the persistent cache.
|
protected void |
removeByEntityID(String entityID,
AbstractMetadataResolver.EntityBackingStore backingStore)
Remove from the backing store all metadata for the entity with the given entity ID.
|
Iterable<EntityDescriptor> |
resolve(net.shibboleth.utilities.java.support.resolver.CriteriaSet criteria) |
protected Iterable<EntityDescriptor> |
resolveFromOriginSource(net.shibboleth.utilities.java.support.resolver.CriteriaSet criteria)
Fetch metadata from an origin source based on the input criteria, store it in the backing store
and then return it.
|
void |
setBackgroundInitializationFromCacheDelay(Long delay)
Set the delay in milliseconds after which to schedule the background initialization from the persistent cache.
|
void |
setCleanupTaskInterval(Long interval)
Set the interval in milliseconds at which the cleanup task should run.
|
void |
setInitializationFromCachePredicate(com.google.common.base.Predicate<EntityDescriptor> predicate)
Set the predicate which determines whether a given entity should be loaded from the persistent cache
at resolver initialization time.
|
void |
setInitializeFromPersistentCacheInBackground(boolean flag)
Set the flag indicating whether should initialize from the persistent cache in the background.
|
void |
setMaxCacheDuration(Long duration)
Set the maximum cache duration for metadata.
|
void |
setMaxIdleEntityData(Long max)
Set the maximum idle time in milliseconds for which the resolver will keep data for a given entityID,
before it is removed.
|
void |
setMetricsBaseName(String baseName)
Set the base name for Metrics instrumentation.
|
void |
setMinCacheDuration(Long duration)
Set the minimum cache duration for metadata.
|
void |
setPersistentCacheKeyGenerator(com.google.common.base.Function<EntityDescriptor,String> generator)
Set the function for generating the String key used with the persistent cache manager.
|
void |
setPersistentCacheManager(org.opensaml.core.xml.persist.XMLObjectLoadSaveManager<EntityDescriptor> manager)
Set the manager for the persistent cache store for resolved metadata.
|
void |
setRefreshDelayFactor(Float factor)
Sets the delay factor used to compute the next refresh time.
|
void |
setRemoveIdleEntityData(boolean flag)
Set the flag indicating whether idle entity data should be removed.
|
protected boolean |
shouldAttemptRefresh(AbstractDynamicMetadataResolver.EntityManagementData mgmtData)
Determine whether should attempt to refresh the metadata, based on stored refresh trigger time.
|
doInitialize, filterMetadata, getCriterionPredicateRegistry, getLogPrefix, getMetadataFilter, getParserPool, getUnmarshallerFactory, indexEntityDescriptor, isFailFastInitialization, isRequireValidMetadata, isSatisfyAnyPredicates, isUseDefaultPredicateRegistry, isValid, lookupIndexedEntityID, predicateFilterCandidates, preProcessEntitiesDescriptor, releaseMetadataDOM, resolveSingle, setBackingStore, setCriterionPredicateRegistry, setFailFastInitialization, setMetadataFilter, setParserPool, setRequireValidMetadata, setSatisfyAnyPredicates, setUseDefaultPredicateRegistry, unmarshallMetadata
setId
getId
destroy, initialize, isDestroyed, isInitialized
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getMetadataFilter, isRequireValidMetadata, setMetadataFilter, setRequireValidMetadata
public static final String METRIC_TIMER_FETCH_FROM_ORIGIN_SOURCE
fetchFromOriginSource(CriteriaSet)
.public static final String METRIC_TIMER_RESOLVE
resolve(CriteriaSet)
.public static final String METRIC_RATIOGAUGE_FETCH_TO_RESOLVE
public static final String METRIC_GAUGE_NUM_LIVE_ENTITYIDS
public static final String METRIC_GAUGE_PERSISTENT_CACHE_INIT
private final org.slf4j.Logger log
@NonnullAfterInit private String metricsBaseName
@Nullable private com.codahale.metrics.Timer timerResolve
resolve(CriteriaSet)
.@Nullable private com.codahale.metrics.Timer timerFetchFromOriginSource
fetchFromOriginSource(CriteriaSet)
.@Nullable private com.codahale.metrics.RatioGauge ratioGaugeFetchToResolve
@Nullable private com.codahale.metrics.Gauge<Integer> gaugeNumLiveEntityIDs
@Nullable private com.codahale.metrics.Gauge<AbstractDynamicMetadataResolver.PersistentCacheInitializationMetrics> gaugePersistentCacheInit
private Timer taskTimer
private boolean createdOwnTaskTimer
@Duration @Positive private Long minCacheDuration
@Duration @Positive private Long maxCacheDuration
@Positive private Float refreshDelayFactor
@Duration @Positive private Long maxIdleEntityData
private boolean removeIdleEntityData
@Duration @Positive private Long cleanupTaskInterval
private AbstractDynamicMetadataResolver.BackingStoreCleanupSweeper cleanupTask
private org.opensaml.core.xml.persist.XMLObjectLoadSaveManager<EntityDescriptor> persistentCacheManager
private com.google.common.base.Function<EntityDescriptor,String> persistentCacheKeyGenerator
private boolean initializeFromPersistentCacheInBackground
@Duration @Positive private Long backgroundInitializationFromCacheDelay
private com.google.common.base.Predicate<EntityDescriptor> initializationFromCachePredicate
@NonnullAfterInit private AbstractDynamicMetadataResolver.PersistentCacheInitializationMetrics persistentCacheInitMetrics
private boolean initializing
public boolean isInitializeFromPersistentCacheInBackground()
Defaults to: true.
public void setInitializeFromPersistentCacheInBackground(boolean flag)
Defaults to: true.
flag
- true if should init from the cache in the background, false otherwise@Nonnull public Long getBackgroundInitializationFromCacheDelay()
Defaults to: 2 seconds.
public void setBackgroundInitializationFromCacheDelay(@Nonnull Long delay)
Defaults to: 2 seconds.
delay
- the delay in milliseconds@Nullable public org.opensaml.core.xml.persist.XMLObjectLoadSaveManager<EntityDescriptor> getPersistentCacheManager()
public void setPersistentCacheManager(@Nullable org.opensaml.core.xml.persist.XMLObjectLoadSaveManager<EntityDescriptor> manager)
manager
- the cache manager, may be nullpublic boolean isPersistentCachingEnabled()
@NonnullAfterInit public com.google.common.base.Function<EntityDescriptor,String> getPersistentCacheKeyGenerator()
public void setPersistentCacheKeyGenerator(@Nullable com.google.common.base.Function<EntityDescriptor,String> generator)
generator
- the new generator to set, may be null@NonnullAfterInit public com.google.common.base.Predicate<EntityDescriptor> getInitializationFromCachePredicate()
public void setInitializationFromCachePredicate(@Nullable com.google.common.base.Predicate<EntityDescriptor> predicate)
predicate
- the cache initialization predicate@Nonnull public Long getMinCacheDuration()
Defaults to: 10 minutes.
public void setMinCacheDuration(@Nonnull Long duration)
Defaults to: 10 minutes.
duration
- the minimum cache duration, in milliseconds@Nonnull public Long getMaxCacheDuration()
Defaults to: 8 hours.
public void setMaxCacheDuration(@Nonnull Long duration)
Defaults to: 8 hours.
duration
- the maximum cache duration, in millisecondspublic Float getRefreshDelayFactor()
Defaults to: 0.75.
public void setRefreshDelayFactor(Float factor)
Defaults to: 0.75.
factor
- delay factor used to compute the next refresh timepublic boolean isRemoveIdleEntityData()
public void setRemoveIdleEntityData(boolean flag)
flag
- true if idle entity data should be removed, false otherwise@Nonnull public Long getMaxIdleEntityData()
Defaults to: 8 hours.
public void setMaxIdleEntityData(@Nonnull Long max)
Defaults to: 8 hours.
max
- the maximum entity data idle time, in milliseconds@Nonnull public Long getCleanupTaskInterval()
Defaults to: 30 minutes.
public void setCleanupTaskInterval(@Nonnull Long interval)
Defaults to: 30 minutes.
interval
- the interval to set, in milliseconds@NonnullAfterInit public String getMetricsBaseName()
public void setMetricsBaseName(@Nullable String baseName)
baseName
- the Metrics base name@Nonnull public Iterable<EntityDescriptor> resolve(@Nonnull net.shibboleth.utilities.java.support.resolver.CriteriaSet criteria) throws net.shibboleth.utilities.java.support.resolver.ResolverException
resolve
in interface net.shibboleth.utilities.java.support.resolver.Resolver<EntityDescriptor,net.shibboleth.utilities.java.support.resolver.CriteriaSet>
net.shibboleth.utilities.java.support.resolver.ResolverException
@Nonnull @NonnullElements protected Iterable<EntityDescriptor> resolveFromOriginSource(@Nonnull net.shibboleth.utilities.java.support.resolver.CriteriaSet criteria) throws net.shibboleth.utilities.java.support.resolver.ResolverException
criteria
- the input criteria setnet.shibboleth.utilities.java.support.resolver.ResolverException
- if there is a fatal error attempting to resolve the metadata@Nullable protected abstract org.opensaml.core.xml.XMLObject fetchFromOriginSource(@Nonnull net.shibboleth.utilities.java.support.resolver.CriteriaSet criteria) throws IOException
criteria
- the input criteria setIOException
- if there is a fatal error fetching metadata from the origin source@Nonnull @NonnullElements protected List<EntityDescriptor> lookupEntityID(@Nonnull String entityID) throws net.shibboleth.utilities.java.support.resolver.ResolverException
lookupEntityID
in class AbstractMetadataResolver
entityID
- entityID to lookupnet.shibboleth.utilities.java.support.resolver.ResolverException
- if an error occurs@Nonnull protected void processNewMetadata(@Nonnull org.opensaml.core.xml.XMLObject root, @Nonnull String expectedEntityID) throws FilterException
Equivalent to #processNewMetadata(XMLObject, String, false)
.
root
- the root of the new metadata document being processedexpectedEntityID
- the expected entityID of the resolved metadataFilterException
- if there is a problem filtering the metadata@Nonnull protected void processNewMetadata(@Nonnull org.opensaml.core.xml.XMLObject root, @Nonnull String expectedEntityID, boolean fromPersistentCache) throws FilterException, net.shibboleth.utilities.java.support.resolver.ResolverException
In order to be processed successfully, the metadata (after filtering) must be an instance of
EntityDescriptor
and its entityID
value must match the value supplied
as the required expectedEntityID
argument.
root
- the root of the new metadata document being processedexpectedEntityID
- the expected entityID of the resolved metadatafromPersistentCache
- whether the entity data was loaded from the persistent cacheFilterException
- if there is a problem filtering the metadatanet.shibboleth.utilities.java.support.resolver.ResolverException
- if there is a problem processing the metadata@Nonnull protected org.opensaml.core.xml.XMLObject prepareForFiltering(@Nonnull org.opensaml.core.xml.XMLObject input)
input
- the XMLObject on which to operateprotected void preProcessEntityDescriptor(@Nonnull EntityDescriptor entityDescriptor, @Nonnull AbstractMetadataResolver.EntityBackingStore backingStore)
preProcessEntityDescriptor
in class AbstractMetadataResolver
entityDescriptor
- the target entity descriptor to processbackingStore
- the backing store instance to update@Nonnull protected org.joda.time.DateTime computeExpirationTime(@Nonnull EntityDescriptor entityDescriptor, @Nonnull org.joda.time.DateTime now)
entityDescriptor
- the EntityDescriptor instance to evaluatenow
- the current date time instant@Nonnull protected org.joda.time.DateTime computeRefreshTriggerTime(@Nullable org.joda.time.DateTime expirationTime, @Nonnull org.joda.time.DateTime nowDateTime)
expirationTime
- the time at which the metadata effectively expiresnowDateTime
- the current date time instantprotected boolean shouldAttemptRefresh(@Nonnull AbstractDynamicMetadataResolver.EntityManagementData mgmtData)
mgmtData
- the entity'd management data@Nonnull protected AbstractDynamicMetadataResolver.DynamicEntityBackingStore createNewBackingStore()
AbstractMetadataResolver.setBackingStore(EntityBackingStore)
to make it the effective
instance in use.createNewBackingStore
in class AbstractMetadataResolver
@NonnullAfterInit protected AbstractDynamicMetadataResolver.DynamicEntityBackingStore getBackingStore()
getBackingStore
in class AbstractMetadataResolver
protected void initMetadataResolver() throws net.shibboleth.utilities.java.support.component.ComponentInitializationException
initMetadataResolver
in class AbstractMetadataResolver
net.shibboleth.utilities.java.support.component.ComponentInitializationException
- thrown if there is a problem initializing the providerprivate void initializeMetricsInstrumentation()
protected void initializeFromPersistentCache()
protected void processPersistentCacheEntry(@Nonnull String currentKey, @Nonnull EntityDescriptor descriptor)
currentKey
- the current persistent cache keydescriptor
- the entity descriptor to processprotected void removeByEntityID(String entityID, AbstractMetadataResolver.EntityBackingStore backingStore)
removeByEntityID
in class AbstractMetadataResolver
entityID
- the entity ID of the metadata to removebackingStore
- the backing store instance to updateprotected void doDestroy()
doDestroy
in class AbstractMetadataResolver
Copyright © 1999–2020 Shibboleth Consortium. All rights reserved.