[java-identity-provider COMMIT] in /trunk: idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/reso...

noreply at shibboleth.net noreply at shibboleth.net
Wed May 6 06:38:08 EDT 2015


Author: rdw
Date: Wed May  6 06:38:08 2015
New Revision: 7497

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=7497&view=rev
Log:
IDP700 Add code to leave a data connector dead for a specified timeout

Modified:
    trunk/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/AbstractDataConnector.java
    trunk/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/DataConnector.java
    trunk/idp-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/AttributeResolverImpl.java
    trunk/idp-attribute-resolver-impl/src/test/java/net/shibboleth/idp/attribute/resolver/impl/AttributeResolverImplTest.java

Modified: trunk/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/AbstractDataConnector.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/AbstractDataConnector.java?rev=7497&r1=7496&r2=7497&view=diff
==============================================================================
--- trunk/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/AbstractDataConnector.java	(original)
+++ trunk/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/AbstractDataConnector.java	Wed May  6 06:38:08 2015
@@ -26,6 +26,7 @@
 import net.shibboleth.idp.attribute.IdPAttribute;
 import net.shibboleth.idp.attribute.resolver.context.AttributeResolutionContext;
 import net.shibboleth.idp.attribute.resolver.context.AttributeResolverWorkContext;
+import net.shibboleth.utilities.java.support.annotation.Duration;
 import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
 import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
 import net.shibboleth.utilities.java.support.component.ComponentSupport;
@@ -48,10 +49,16 @@
     /** cache for the log prefix - to save multiple recalculations. */
     @Nullable private String logPrefix;
 
+    /** When did this connector last fail. */
+    private long lastFail;
+
+    /** How long to wait until we declare the connector live again. */
+    @Duration private long noRetryDelay;
+
     /**
      * Gets the ID of the {@link AbstractDataConnector} whose values will be used in the event that this data connector
      * experiences an error.
-     * 
+     *
      * @return ID of the {@link AbstractDataConnector} whose values will be used in the event that this data connector
      *         experiences an error
      */
@@ -62,7 +69,7 @@
     /**
      * Set the ID of the {@link AbstractDataConnector} whose values will be used in the event that this data connector
      * experiences an error.
-     * 
+     *
      * @param id ID of the {@link AbstractDataConnector} whose values will be used in the event that this data connector
      *            experiences an error
      */
@@ -71,6 +78,36 @@
         ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
 
         failoverDataConnectorId = StringSupport.trimOrNull(id);
+    }
+
+    /**
+     * Set the time when this connector last failed.
+     *
+     * @param time what to set
+     */
+    public void setLastFail(long time) {
+        lastFail = time;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override public long getLastFail() {
+        return lastFail;
+    }
+
+    /**
+     * Set how long to wait until we declare the connector live again.
+     *
+     * @param delay what to set
+     */
+    public void setNoRetryDelay(@Duration long delay) {
+        noRetryDelay = delay;
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getNoRetryDelay() {
+        return noRetryDelay;
     }
 
     /**
@@ -83,7 +120,14 @@
     @Override @Nullable public final Map<String, IdPAttribute> doResolve(
             @Nonnull final AttributeResolutionContext resolutionContext,
             @Nonnull final AttributeResolverWorkContext workContext) throws ResolutionException {
-        Map<String, IdPAttribute> result = doDataConnectorResolve(resolutionContext, workContext);
+
+        final Map<String, IdPAttribute> result;
+        try {
+            result = doDataConnectorResolve(resolutionContext, workContext);
+        } catch (Exception e) {
+            setLastFail(System.currentTimeMillis());
+            throw e;
+        }
 
         if (null == result) {
             log.debug("{} no attributes were produced during resolution", getId());

Modified: trunk/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/DataConnector.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/DataConnector.java?rev=7497&r1=7496&r2=7497&view=diff
==============================================================================
--- trunk/idp-attribute-resolver-api/src/main/java/net/shibboleth/idp/attribute/resolver/DataConnector.java	(original)

[... 89 lines stripped ...]


More information about the commits mailing list