|
Platform SDK Java 8.5 API Reference | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface WarmStandbyConnectionFailureHandler
An interface to be implemented for the custom handling of connection failure events.
Users can create their own algorithm to restore connection functionality by creating a custom implementation of theWarmStandbyConnectionFailureHandler
interface and then configuring the WarmStandbyService
instance to use it. The
WarmStandbyService
will call the custom implementation and provide failure
context, so the user can specify whether to schedule the next reconnect task,
switchover, or stop the service.
Here are some samples of the handler implementation:
class MyDummyFailureHandler
implements WarmStandbyConnectionFailureHandler {
public boolean handleRegistrationFailure(
WarmStandbyConnectionFailureContext context) {
System.out.println(RegistrationFailure);
return false;
}
public boolean handleConnectionFailure(
WarmStandbyConnectionFailureContext context) {
System.out.println(ConnectionFailure);
return false;
}
}
class MyDefaultFailureHandler
implements WarmStandbyConnectionFailureHandler {
public boolean handleRegistrationFailure(
WarmStandbyConnectionFailureContext context) {
context.doStandbyOff();
return true;
}
public boolean handleConnectionFailure(
WarmStandbyConnectionFailureContext context) {
WarmStandbyService service = context.getService();
WarmStandbyConfiguration config =
service.getConfiguration();
if (service.getAttempt() > config.getAttempts()) {
Short cfgSwitchovers = config.getSwitchovers();
if (cfgSwitchovers == null
|| service.getSwitchover() < cfgSwitchovers) {
context.doSwitchover();
} else {
if (log.isDebug()) {
log.debug("Switchover "
+ service.getSwitchover()
+ " of " + cfgSwitchovers
+ ", WarmStandbyService is stopped");
}
context.doStandbyOff();
return true;
}
}
context.scheduleReconnect(config.getTimeout());
return true;
}
}
WarmStandbyConfiguration
object for Genesys Configuration
Server with an unavailable active server and with the wrong initial value
for user password.
In this scenario, we can create custom handler which performs fast switchover
on connection failure, corrects the password on registration failure, and
initiates a reconnect with the new password:
final ConfServerProtocol cfgProtocol =
new ConfServerProtocol(confEPBad1);
cfgProtocol.setClientName("default");
cfgProtocol.setClientApplicationType(CfgAppType.CFGSCE.ordinal());
cfgProtocol.setUserName("default");
cfgProtocol.setUserPassword("<wrong-pass>");
cfgProtocol.setTimeout(2000);
WarmStandbyConnectionFailureHandler handler =
new WarmStandbyConnectionFailureHandler() {
public boolean handleRegistrationFailure(
WarmStandbyConnectionFailureContext context) {
System.out.println("handleRegistrationFailure");
((ConfServerProtocol) context.getService().getChannel())
.setUserPassword("<good-password>");
context.scheduleReconnect(100);
return true;
}
public boolean handleConnectionFailure(
WarmStandbyConnectionFailureContext context) {
System.out.println("handleConnectionFailure");
context.doSwitchover();
context.scheduleReconnect(100);
return true;
}
};
WarmStandbyService service = new WarmStandbyService(cfgProtocol);
WarmStandbyConfiguration config = new WarmStandbyConfiguration(
confEPBad1, confEPGood1,
1000, (short) 2, (short) 3);
service.applyConfiguration(config);
service.setConnectionFailureHandler(handler);
service.start();
cfgProtocol.beginOpen();
Method Summary | |
---|---|
boolean |
handleConnectionFailure(WarmStandbyConnectionFailureContext context)
This call-back method is called in case of connection failure (except RegistrationException). |
boolean |
handleRegistrationFailure(WarmStandbyConnectionFailureContext context)
This call-back method is called in case of RegistrationException. |
Method Detail |
---|
boolean handleRegistrationFailure(WarmStandbyConnectionFailureContext context)
context
- failure context
RegistrationException
boolean handleConnectionFailure(WarmStandbyConnectionFailureContext context)
context
- failure context
|
Platform SDK Java 8.5 API Reference | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |