Class ReconnectRuleEngine
- java.lang.Object
-
- com.ibm.di.server.ReconnectRuleEngine
-
public class ReconnectRuleEngine extends java.lang.Object
This class decides what to do when a connector raises an error. Possible actions are to attempt a reconnect or leave the error unhandled and let further mechanisms process it.
The class makes decisions based on configured rules. Each rule describes what should be done when an error occurs. Each rule applies to certain connectors and certain errors. In a rule the connectors are described by their base Java class and their name in the current configuration. (there are match-all options for both the class and the name of the connector). A rule describes applicable errors by their base Java class and a regular expression that matches their messages (the regular expression is optional).
The reconnect engine holds two collections of rules: in-built rules and user-defined rules.
The in-built rules are defined in an '.inf' file in the jar file of the corresponding connector. They are specific to that connector class. In order to preserver the reconnect behaviour, which existed before the introduction of ReconnectRuleEngine, when the engine is created, it implicitly adds to the in-built rules rules, which prescribe to attempt reconnect on all IOException-s and all CommunicationException-s.
The user defined rules reside in an external text file.
-
-
Field Summary
Fields Modifier and Type Field Description static int
ERROR
the situation is a fatal error which no reconnect could fixstatic java.lang.String
ERROR_STRING
error action - no reconnect will be attemptedstatic int
INVALID_RECONNECT_ACTION
invalid reconnect actionstatic int
RECONNECT
reconnect should be attempted to fix the error situationstatic char
RECONNECT_RULE_PARTS_DELIMETER
the delimiter of the parts of a rule in the config filestatic java.lang.String
RECONNECT_STRING
reconnect action - if an error occurs reconnect will be attempted
-
Constructor Summary
Constructors Constructor Description ReconnectRuleEngine(Log log)
Constructor, which loads the in-built rules and the user-defined rules.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getReconnectChoice(ConnectorInterface connector, java.lang.Throwable error)
This method prescribes a response action for a given error situation.void
loadRules(java.lang.String userDefinedRulesFilePath, MetamergeConfig sysConfig)
Loads the in-built and the user-defined rules.
-
-
-
Field Detail
-
INVALID_RECONNECT_ACTION
public static final int INVALID_RECONNECT_ACTION
invalid reconnect action- See Also:
- Constant Field Values
-
ERROR
public static final int ERROR
the situation is a fatal error which no reconnect could fix- See Also:
- Constant Field Values
-
RECONNECT
public static final int RECONNECT
reconnect should be attempted to fix the error situation- See Also:
- Constant Field Values
-
RECONNECT_RULE_PARTS_DELIMETER
public static final char RECONNECT_RULE_PARTS_DELIMETER
the delimiter of the parts of a rule in the config file- See Also:
- Constant Field Values
-
ERROR_STRING
public static final java.lang.String ERROR_STRING
error action - no reconnect will be attempted- See Also:
- Constant Field Values
-
RECONNECT_STRING
public static final java.lang.String RECONNECT_STRING
reconnect action - if an error occurs reconnect will be attempted- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ReconnectRuleEngine
public ReconnectRuleEngine(Log log)
Constructor, which loads the in-built rules and the user-defined rules.- Parameters:
log
- a log object to be used during the lifetime of the engine
-
-
Method Detail
-
loadRules
public void loadRules(java.lang.String userDefinedRulesFilePath, MetamergeConfig sysConfig) throws java.lang.Exception
Loads the in-built and the user-defined rules.- Parameters:
userDefinedRulesFilePath
- the file with user-defined rulessysConfig
- system configuration object, which has the in-built rules of all connectors- Throws:
java.lang.Exception
- problem while parsing the configured rules ClassNotFoundException problem while loading an exception/connector class, specified in a rule
-
getReconnectChoice
public int getReconnectChoice(ConnectorInterface connector, java.lang.Throwable error)
This method prescribes a response action for a given error situation.
First searches the user-defined rules and if no matching rule is found, the method searches the Connector own rules. If a rule cannot be found in either collection, the default action (
ERROR
) is prescribed.When a collection (in-built or user-defined) is searched for a matching rule, first is sought a match for the error itself. If no match is found for the error and the error has a specified cause (
getCause()
returns non-null) then a match for the cause is searched. Only when both searched fail, another collection of rules is considered.- Parameters:
connector
- the connector, which raised the errorerror
- the error object- Returns:
- the prescribed action - it is one of the following:
ERROR
orRECONNECT
-
-