Package org.gcube.accounting.aggregator
Class RegexRulesAggregator
java.lang.Object
org.gcube.accounting.aggregator.RegexRulesAggregator
- All Implemented Interfaces:
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 Summary
FieldsModifier and TypeFieldDescriptionprotected AccountingPersistenceConfigurationprotected longprotected static final Stringprotected static final longThe interval between two attempts, until the first load succeeds.protected static RegexRulesAggregatorprotected booleanWhether a load has ever succeeded.protected static final Stringprotected List<MatcherReplace>The rules, never changed in place: every change replaces the list, so that a reader iterates a consistent snapshot without locking.static final ScheduledExecutorServiceprotected ScheduledFuture<?>protected booleanWhether the reload has been stopped; once stopped, it is no longer scheduled.protected static final Stringprotected TimeUnit -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddMatcherReplace(MatcherReplace matcherReplace) Adds a rule.static RegexRulesAggregatorReturns the instance, creating it on first use with empty rules and scheduling their load; no remote call is made on the calling thread.voidReads the rules and the reload delay from the IS; on failure, the last known ones are kept.voidrun()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.protected voidscheduleLoad(long loadDelay, TimeUnit loadTimeUnit) static voidshutdown()Stops the reload, if the instance exists, without creating it, and shuts the reload pool down.voidstart()Deprecated.voidstop()Stop rule reloader.voidRemoves every rule.
-
Field Details
-
REGEX_REDISCOVERY_POOL
-
DELAY
- See Also:
-
TIME_UNIT
- See Also:
-
MATCHER_REPLACE_RULES
- See Also:
-
FIRST_LOAD_RETRY_SECONDS
protected static final long FIRST_LOAD_RETRY_SECONDSThe interval between two attempts, until the first load succeeds.- See Also:
-
timeUnit
-
delay
protected long delay -
matcherReplaceList
The rules, never changed in place: every change replaces the list, so that a reader iterates a consistent snapshot without locking. -
accountingPersistenceConfiguration
-
instance
-
loaded
protected boolean loadedWhether a load has ever succeeded. -
stopped
protected boolean stoppedWhether the reload has been stopped; once stopped, it is no longer scheduled. -
reloadAggregatorRules
-
-
Constructor Details
-
RegexRulesAggregator
protected RegexRulesAggregator()
-
-
Method Details
-
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
- Returns:
- the current rules, an unmodifiable snapshot
-
addMatcherReplace
Adds a rule.- Parameters:
matcherReplace- the rule- Returns:
- the rule
-
vacumRules
public void vacumRules()Removes every rule. -
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. -
scheduleLoad
-
stop
public void stop()Stop rule reloader. Use only if you really know what you do. -
start
Deprecated. -
shutdown
public static void shutdown()Stops the reload, if the instance exists, without creating it, and shuts the reload pool down.
-