[java-opensaml COMMIT] /trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynam...
noreply at shibboleth.net
noreply at shibboleth.net
Thu Oct 27 16:47:50 EDT 2016
Author: putmanb
Date: Thu Oct 27 16:47:49 2016
New Revision: 4560
URL: http://svn.shibboleth.net/view/java-opensaml?rev=4560&view=rev
Log:
OSJ-182: Add Metrics instrumentation to dynamic metadata resolvers
Refactor to just have 2 Timers, since 1) we do really want to time the resolve() method in general, and
2) Timers seemto give you everything that a Meter could (which in turn is better than the Counters that
we had originally).
Also refactor to use local Metrics variables populated during init. This cleans up the code, and will be necessary
anyway if we inject these into other composite Metrics objects, like a RatioGauge or a shared map of
component ID-specific data.
Modified:
trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java
Modified: trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java?rev=4560&r1=4559&r2=4560&view=diff
==============================================================================
--- trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java (original)
+++ trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/metadata/resolver/impl/AbstractDynamicMetadataResolver.java Thu Oct 27 16:47:49 2016
@@ -77,20 +77,23 @@
public abstract class AbstractDynamicMetadataResolver extends AbstractMetadataResolver
implements DynamicMetadataResolver {
- /** Metric name for timer on fetch from origin source. */
- public static final String METRIC_TIMER_FETCH_FROM_ORIGIN_SOURCE = "fetchFromOriginSourceTimer";
-
- /** Metric name for counter on number of fetches from origin source. */
- public static final String METRIC_COUNTER_FETCHES_FROM_ORIGIN_SOURCE = "fetchesFromOriginSource";
-
- /** Metric name for counter on number of fetches from origin source. */
- public static final String METRIC_COUNTER_RESOLVE_REQUESTS = "resolveRequests";
+ /** Metric name for the timer for {@link #fetchFromOriginSource(CriteriaSet)}. */
+ public static final String METRIC_TIMER_FETCH_FROM_ORIGIN_SOURCE = "timer.fetchFromOriginSource";
+
+ /** Metric name for the timer for {@link #resolve(CriteriaSet)}. */
+ public static final String METRIC_TIMER_RESOLVE = "timer.resolve";
/** Class logger. */
private final Logger log = LoggerFactory.getLogger(AbstractDynamicMetadataResolver.class);
/** Base name for Metrics instrumentation names. */
@NonnullAfterInit private String metricsBaseName;
+
+ /** Metrics Timer for {@link #resolve(CriteriaSet)}. */
+ @NonnullAfterInit private com.codahale.metrics.Timer timerResolve;
+
+ /** Metrics Timer for {@link #fetchFromOriginSource(CriteriaSet)}. */
+ @NonnullAfterInit private com.codahale.metrics.Timer timerFetchFromOriginSource;
/** Timer used to schedule background metadata update tasks. */
private Timer taskTimer;
@@ -470,44 +473,48 @@
ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this);
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
- final EntityIdCriterion entityIdCriterion = criteria.get(EntityIdCriterion.class);
- if (entityIdCriterion == null || Strings.isNullOrEmpty(entityIdCriterion.getEntityId())) {
- log.info("Entity Id was not supplied in criteria set, skipping resolution");
- return Collections.emptySet();
- }
-
- final String entityID = StringSupport.trimOrNull(criteria.get(EntityIdCriterion.class).getEntityId());
- log.debug("Attempting to resolve metadata for entityID: {}", entityID);
-
- MetricsSupport.getMetricRegistry().counter(MetricRegistry.name(getMetricsBaseName(),
- METRIC_COUNTER_RESOLVE_REQUESTS)).inc();
-
- final EntityManagementData mgmtData = getBackingStore().getManagementData(entityID);
- final Lock readLock = mgmtData.getReadWriteLock().readLock();
- Iterable<EntityDescriptor> candidates = null;
+ com.codahale.metrics.Timer.Context contextResolve = timerResolve.time();
try {
- readLock.lock();
-
- final List<EntityDescriptor> descriptors = lookupEntityID(entityID);
- if (descriptors.isEmpty()) {
- log.debug("Did not find requested metadata in backing store, will attempt to resolve dynamically");
- } else {
- if (shouldAttemptRefresh(mgmtData)) {
- log.debug("Metadata was indicated to be refreshed based on refresh trigger time");
+ final EntityIdCriterion entityIdCriterion = criteria.get(EntityIdCriterion.class);
+ if (entityIdCriterion == null || Strings.isNullOrEmpty(entityIdCriterion.getEntityId())) {
[... 88 lines stripped ...]
More information about the commits
mailing list