Unknown macro: {style}

.ia-secondary-container

Unknown macro: { margin}
Unknown macro: {div}
Kaa releases
Unknown macro: {div}
Shortcuts

Page tree
Skip to end of metadata
Go to start of metadata

Failover strategies allow users to provide their own ways of resolving endpoint failures. The failover strategy is notified whenever an endpoint failure occurs or an endpoint SDK is recovered after the failure, thus allowing the developer to implement practically any failure mitigation scenario. In addition, the failover strategy API enables switching strategies at runtime, which may be useful for more sophisticated scenarios.

Implementing custom failover strategy

This section illustrates how to implement and use a custom failover strategy.

// Overriding default failover strategy
kaaClient.setFailoverStrategy(new DefaultFailoverStrategy() {

    @Override
    public void onRecover(TransportConnectionInfo connectionInfo) {
        super.onRecover(connectionInfo);
        //make call to external service, add extra logging or do anything else
    }

    @Override
    public FailoverDecision onFailover(FailoverStatus failoverStatus) {
        if (failoverStatus == FailoverStatus.OPERATION_SERVERS_NA) {
            return new FailoverDecision(FailoverAction.USE_NEXT_BOOTSTRAP);
        } else {
            return super.onFailover(failoverStatus);
        }
    }
});
// Overriding default failover strategy
@interface CustomFailoverStrategy : DefaultFailoverStrategy
@end

@implementation CustomFailoverStrategy

- (void)onRecoverWithConnectionInfo:(id<TransportConnectionInfo>)connectionInfo {
    [super onRecoverWithConnectionInfo:connectionInfo];
    //make call to external service, add extra logging or do anything else
}

- (FailoverDecision *)decisionOnFailoverStatus:(FailoverStatus)status {
	if (status == FailoverStatusOperationsServersNotAvailable) {
		return [[FailoverDecision alloc] initWithFailoverAction:FailoverActionUseNextBootstrap];
    } else {
       return [super decisionOnFailoverStatus:status];
    }
}

@end
 
 
// Create and set custom failover strategy to Kaa client
[kaaClient setFailoverStrategy:[[CustomFailoverStrategy alloc] init]];

 


Copyright © 2014-2016, CyberVision, Inc.

  • No labels