Problems |
|
A problem is defined as the state of the component in which the functioning of the component does not happen in the expected manner. The management sub system allows the applications to perform the following tasks:
- Define a problem with the cause and clear alert messages.
- Raise a defined problem when the problem occurs
- Resolve the problem through a problem-resolve-handler
Defining a problem
The method defineproblem
is used to define a problem for a Managed Component in an application. This method returns an IProblemDefinition instance that the application must retain for raising the problem.
// defining a problem IProblemDefinition m_problemDef = defineProblem( Messages.CONNECTION_LOSS_RAISE_ALERT_MESSAGE, Messages.CONNECTION_LOSS_RAISE_ALERT_DESCRIPTION, Messages.CONNECTION_LOSS_CLEAR_ALERT_MESSAGE, Messages.CONNECTION_LOSS_CLEAR_ALERT_DESCRIPTION);
Raise a problem
Raiseproblem
is the method that should be called to raise a problem. While calling the method, the component must pass a problem resolver that implements IProblemResolver. The problem resolver thread periodically invokes the method and checks whether the problem can be resolved.
// raising a problem long recheckInterval = 120*1000; m_problemDef.raiseProblem(new MyProblemResolver(), recheckInterval, null);
A problem can also be raised with arguments.
// raising a problem with arguments long recheckInterval = 120*1000; m_problemDef.raiseProblem(new MyProblemResolver(), recheckInterval, new Date());
Problem resolver
The problem resolver periodically calls the resolve method and checks whether the problem can be solved. After calling the method, IProblemStatusEventListener is passed. Then the resolver invokes methods on this interface and informs the management subsystem about the status of the problem.
class MyProblemResolver implements IProblemResolver { public void resolveProblem(IProblemStatusEventListener problemStatusEventListener) { try { reconnect(); problemStatusEventListener.notifyResolved(); } catch (ConnectionFailureException ex) { problemStatusEventListener. notifyNotResolved(recheckInterval); } } }