Table of contents Index

class FailoverChainer - Connects to a group of remote servers trying them sequentially.

Declared in module Chainer

Inheritance hierarchy:

Chainer.FailoverChainer
  Chainer.Chainer

Synopsis

class FailoverChainer(Chainer):
    def Chainer.FailoverChainer.__init__(self, hosts, local=None, forge_addr=0) # Initializes an instance of FailoverChainer
    def Chainer.FailoverChainer.connectServer(self, session, host, port) # Called by the proxy to connect to the remote server.
    def Chainer.FailoverChainer.getHostAddress(self) # Returns the actual host to try
    def Chainer.FailoverChainer.nextHost(self) # Finds the next host to try

    # Inherited from Chainer.Chainer
    def Chainer.Chainer.connectServer(self, session, host, port) # Connect to the targeted server.
    def Chainer.Chainer.establishConnection(self, session, local, remote) # Function to actually establish the connection.

Description

Failover chainer tries to connect several hosts until one of them succeeds.

Attributes:

hosts
The list of addresses to try
local
the address of the local end of the connection
forge_addr
forge client address
current_host
The index of the actual host in the list

Notes:

FIXME: support priorities, shorter than system default timeouts

Chainer.FailoverChainer.__init__(self, hosts, local=None, forge_addr=0)

Initializes an instance of FailoverChainer

hosts
The list of addresses to try
local=None
address to bind to (Optional)
forge_addr=0
forge client address (Optional)
Sets attributes based on parameters.

Chainer.FailoverChainer.connectServer(self, session, host, port)

Called by the proxy to connect to the remote server.

Tries to connect to each host round-robin until one of them succeeds.

Arguments:

self
this instance
session
The data of the current session
host
not used
port
not used

Returns:

The fd given by establishConnection

Chainer.FailoverChainer.getHostAddress(self)

Returns the actual host to try

self
this instance
Returns the actual (current_host) elem of the list (hosts)

Chainer.FailoverChainer.nextHost(self)

Finds the next host to try

Increments the index (current_host), zeroes it if overflowed

Arguments:

self
this instance

Copyright © 2000 BalaBit IT Ltd.
Written by: Balázs Scheidler