core/src/main/java/org/commonjava/indy/core/change/StoreEnablementManager.java
@Measure( timers = @MetricNamed( DEFAULT ) )
    public void onStoreError( @Observes IndyStoreErrorEvent evt )
    {
        Logger logger = LoggerFactory.getLogger( getClass() );
        StoreKey key = evt.getStoreKey();
        Throwable error = evt.getError();
        try
        {
            ArtifactStore store = storeDataManager.getArtifactStore( key );
            if ( store == null )
            {
                logger.warn( "Attempt to disable missing repo! Skipping." );
                return;
            }

            store = store.copyOf();

            int disableTimeout = store.getDisableTimeout();
            if ( disableTimeout <= TIMEOUT_NEVER_DISABLE )
            {
                logger.debug( "Disable-timeout set to {}, will never disable the repo", disableTimeout );
                store.setDisabled( false );
            }
            else
            {
                store.setDisabled( true );
                final ChangeSummary changeSummary = new ChangeSummary( ChangeSummary.SYSTEM_USER, String.format(
                        "Disabling %s due to error: %s\n\nStack Trace:\n  %s", key, error,
                        StringUtils.join( error.getStackTrace(), "\n  " ) ) );

                storeDataManager.storeArtifactStore( store, changeSummary, false, true, new EventMetadata() );

                logger.warn( "{} has been disabled due to store-level error: {}\n Will re-enable in {} seconds.", key,
                             error, disableTimeout == TIMEOUT_USE_DEFAULT ? config.getStoreDisableTimeoutSeconds() : disableTimeout );

                // TODO: How is it this doesn't duplicate the event handler method onStoreUpdate()...we're updating the store just above here.
                setReEnablementTimeout( key );
            }
        }
        catch ( IndyDataException e )
        {
            logger.error( String.format( "Failed to disable %s on error: %s", key, error ), e);
        }
        catch ( IndySchedulerException e )
        {
            logger.error( String.format( "Failed to schedule re-enablement of %s for retry.", key ), e );
        }
    }
@Measure( timers = @MetricNamed( DEFAULT ) )
    public void onStoreError( @Observes IndyStoreErrorEvent evt )
    {
        Logger logger = LoggerFactory.getLogger( getClass() );
        StoreKey key = evt.getStoreKey();
        Throwable error = evt.getError();
        try
        {
            ArtifactStore store = storeDataManager.getArtifactStore( key );
            if ( store == null )
            {
                logger.warn( "Attempt to disable missing repo! Skipping." );
                return;
            }

            store = store.copyOf();

            int disableTimeout = store.getDisableTimeout();
            if ( disableTimeout <= TIMEOUT_NEVER_DISABLE )
            {
                logger.debug( "Disable-timeout set to {}, will never disable the repo", disableTimeout );
                store.setDisabled( false );
            }
            else
            {
                store.setDisabled( true );
                final ChangeSummary changeSummary = new ChangeSummary( ChangeSummary.SYSTEM_USER, String.format(
                        "Disabling %s due to error: %s\n\nStack Trace:\n  %s", key, error,
                        StringUtils.join( error.getStackTrace(), "\n  " ) ) );

                storeDataManager.storeArtifactStore( store, changeSummary, false, true, new EventMetadata() );

                logger.warn( "{} has been disabled due to store-level error: {}\n Will re-enable in {} seconds.", key,
                             error, disableTimeout == TIMEOUT_USE_DEFAULT ? config.getStoreDisableTimeoutSeconds() : disableTimeout );

                // TODO: How is it this doesn't duplicate the event handler method onStoreUpdate()...we're updating the store just above here.
                setReEnablementTimeout( key );
            }
        }
        catch ( IndyDataException e )
        {
            logger.error( String.format( "Failed to disable %s on error: %s", key, error ), e);
        }
        catch ( IndySchedulerException e )
        {
            logger.error( String.format( "Failed to schedule re-enablement of %s for retry.", key ), e );
        }
    }
@ Measure ( timers = @ MetricNamed ( DEFAULT ) ) public void onStoreError ( @ Observes IndyStoreErrorEvent evt ) { Logger logger = LoggerFactory . getLogger ( getClass ( ) ) ; StoreKey key = evt . getStoreKey ( ) ; Throwable error = evt . getError ( ) ; try { ArtifactStore store = storeDataManager . getArtifactStore ( key ) ; if ( store == null ) { logger . warn ( "Attempt to disable missing repo! Skipping." ) ; return ; } store = store . copyOf ( ) ; int disableTimeout = store . getDisableTimeout ( ) ; if ( disableTimeout <= TIMEOUT_NEVER_DISABLE ) { logger . debug ( "Disable-timeout set to {}, will never disable the repo" , disableTimeout ) ; store . setDisabled ( false ) ; } else { store . setDisabled ( true ) ; final ChangeSummary changeSummary = new ChangeSummary ( ChangeSummary . SYSTEM_USER , String . format ( "Disabling %s due to error: %s\n\nStack Trace:\n  %s" , key , error , StringUtils . join ( error . getStackTrace ( ) , "\n  " ) ) ) ; storeDataManager . storeArtifactStore ( store , changeSummary , false , true , new EventMetadata ( ) ) ; logger . warn ( "{} has been disabled due to store-level error: {}\n Will re-enable in {} seconds." , key , error , disableTimeout == TIMEOUT_USE_DEFAULT ? config . getStoreDisableTimeoutSeconds ( ) : disableTimeout ) ; // TODO: How is it this doesn't duplicate the event handler method onStoreUpdate()...we're updating the store just above here. setReEnablementTimeout ( key ) ; } } catch ( IndyDataException e ) { logger . error ( String . format ( "Failed to disable %s on error: %s" , key , error ) , e ) ; } catch ( IndySchedulerException e ) { logger . error ( String . format ( "Failed to schedule re-enablement of %s for retry." , key ) , e ) ; } }
}
}