Platform SDK Java 8.5 API Reference

com.genesyslab.platform.applicationblocks.warmstandby
Interface WarmStandbyConnectionFailureHandler


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 the WarmStandbyConnectionFailureHandler 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:

Empty Handler Passing to Default Behavior

   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;
       }
   }
 

Duplicate Default Behavior

   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;
       }
   }
 

Some synthetic handler with trick

Scenario: A 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

handleRegistrationFailure

boolean handleRegistrationFailure(WarmStandbyConnectionFailureContext context)
This call-back method is called in case of RegistrationException. It means that target server is available, but for some reason it does not allow the client connection. It may be caused by wrong login credentials, or some other exception while client registration procedure on opened connection. Usually it means that there is no need to try reconnect.

Custom code may use provided context to access WarmStandbyService instance, to get WarmStandbyConfiguration, and the client protocol connection. Also the context allows user to schedule next reconnect task, switchover, or stop service.

Parameters:
context - failure context
Returns:
true if the failure event is handled, or false if user wants to let the service to perform default operation for the event (stop the WarmStandby service)
See Also:
RegistrationException

handleConnectionFailure

boolean handleConnectionFailure(WarmStandbyConnectionFailureContext context)
This call-back method is called in case of connection failure (except RegistrationException).

Custom code may use provided context to access WarmStandbyService instance, to get WarmStandbyConfiguration, and the client protocol connection. Also the context allows user to schedule next reconnect task, switchover, or stop service.

Parameters:
context - failure context
Returns:
true if the failure event is handled, or false if user wants to let the service to perform default operation for the event

Platform SDK Java 8.5 API Reference

Send comments on this topicTechpubs.webadmin@genesys.com.
Document version: 8.5.302.00
Copyright © 2006–2017 Genesys Telecommunications Laboratories, Inc. All rights reserved.