|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.di.server.ReconnectRuleEngine
public class ReconnectRuleEngine
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 | |
---|---|
static int |
ERROR
the situation is a fatal error which no reconnect could fix |
static String |
ERROR_STRING
|
static int |
INVALID_RECONNECT_ACTION
|
static int |
RECONNECT
reconnect should be attempted to fix the error situation |
static char |
RECONNECT_RULE_PARTS_DELIMETER
the delimeter of the parts of a rule in the config file |
static String |
RECONNECT_STRING
|
Constructor Summary | |
---|---|
ReconnectRuleEngine(Log log)
Constructor, which loads the in-built rules and the user-defined rules. |
Method Summary | |
---|---|
int |
getReconnectChoice(Class connectorClass,
String connectorName,
Throwable error)
This method prescribes a response action for a given error situation. |
void |
loadRules(String userDefinedRulesFilePath,
MetamergeConfig sysConfig)
Loads the in-built and the user-defined rules. |
static String |
rulesToTextInUserDefinedRuleFormat(String connectorClassName,
Object rulesConfig)
Parses the in-built reconnect rules for a given connector and transforms them to a text in the format for user-defined rules (each rule resides on a single line). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int INVALID_RECONNECT_ACTION
public static final int ERROR
public static final int RECONNECT
public static final char RECONNECT_RULE_PARTS_DELIMETER
public static final String ERROR_STRING
public static final String RECONNECT_STRING
Constructor Detail |
---|
public ReconnectRuleEngine(Log log)
log
- a log object to be used during the lifetime of the engineMethod Detail |
---|
public void loadRules(String userDefinedRulesFilePath, MetamergeConfig sysConfig) throws Exception
userDefinedRulesFilePath
- the file with user-defined rulessysConfig
- system configuration object, which has the in-built rules of all connectors
Exception
- problem while parsing the confgured rules
ClassNotFoundException problem while loading an exception/connector class, specified in a rulepublic int getReconnectChoice(Class connectorClass, String connectorName, 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 in-built 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.
connectorClass
- the Java class of the connector, which raised the errorconnectorName
- the name of the connector as it is specified in the
configuration file of the solutionerror
- the error object
ERROR
or RECONNECT
public static String rulesToTextInUserDefinedRuleFormat(String connectorClassName, Object rulesConfig) throws Exception
connectorClassName
- the fully qualified name of the Java class of the connectorrulesConfig
- the configuration structure which holds the in-built reconnect rules of the connector
(it is supposed to be a list of maps)
problem
- with the reconnect rules
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |