Class RegexRulesAggregator

java.lang.Object
org.gcube.accounting.aggregator.RegexRulesAggregator
All Implemented Interfaces:
Runnable

public class RegexRulesAggregator extends Object implements Runnable
Holds the rules which harmonize the service class, service name and called method of the service usage records. The rules are loaded from the IS in the background, with the library's credentials (LibraryCredentials), never on the thread which accounts a record: until the first load succeeds the rules are empty, the load is retried every 30L seconds, and afterwards it is repeated with the configured delay.
  • Field Details

    • REGEX_REDISCOVERY_POOL

      public static final ScheduledExecutorService REGEX_REDISCOVERY_POOL
    • DELAY

      protected static final String DELAY
      See Also:
    • TIME_UNIT

      protected static final String TIME_UNIT
      See Also:
    • MATCHER_REPLACE_RULES

      protected static final String MATCHER_REPLACE_RULES
      See Also:
    • FIRST_LOAD_RETRY_SECONDS

      protected static final long FIRST_LOAD_RETRY_SECONDS
      The interval between two attempts, until the first load succeeds.
      See Also:
    • timeUnit

      protected TimeUnit timeUnit
    • delay

      protected long delay
    • matcherReplaceList

      protected List<MatcherReplace> matcherReplaceList
    • accountingPersistenceConfiguration

      protected AccountingPersistenceConfiguration accountingPersistenceConfiguration
    • instance

      protected static RegexRulesAggregator instance
    • loaded

      protected boolean loaded
      Whether a load has ever succeeded.
    • stopped

      protected boolean stopped
      Whether the reload has been stopped; once stopped, it is no longer scheduled.
    • reloadAggregatorRules

      protected ScheduledFuture<?> reloadAggregatorRules
  • Constructor Details

    • RegexRulesAggregator

      protected RegexRulesAggregator()
  • Method Details

    • getInstance

      public static RegexRulesAggregator getInstance()
      Returns the instance, creating it on first use with empty rules and scheduling their load; no remote call is made on the calling thread.
      Returns:
      the instance
    • getMatcherReplaceList

      public List<MatcherReplace> getMatcherReplaceList()
    • addMatcherReplace

      public MatcherReplace addMatcherReplace(MatcherReplace matcherReplace)
    • vacumRules

      public void vacumRules()
    • readConfiguration

      public void readConfiguration()
      Reads the rules and the reload delay from the IS; on failure, the last known ones are kept.
    • run

      public void run()
      Loads the rules with the library's credentials, then schedules the next load: after 30L seconds until a load succeeds, then after the configured delay.
      Specified by:
      run in interface Runnable
    • scheduleLoad

      protected void scheduleLoad(long loadDelay, TimeUnit loadTimeUnit)
    • stop

      public void stop()
      Stop rule reloader. Use only if you really know what you do.
    • start

      @Deprecated public void start()
      Deprecated.
    • shutdown

      public static void shutdown()
      Stops the reload, if the instance exists, without creating it, and shuts the reload pool down.