Hi,

The initial version of the Load Balancer Extension API - Statistics
Reporting Interface and its Reference Implementation for HAProxy are now
ready with their initial versions.

The idea of this module is to provide an interface to read statistics from
a given load balancer and periodically report them to the Complex Event
Processing (CEP) Engine.


*Statistics Reader Interface:*
package org.apache.stratos.load.balancer.extension.api;

/**
 * Load balancer statistics reader interface.
 */
public interface LoadBalancerStatsReader {

    /**
     * Get in-flight request count of a given cluster.
     * @param clusterId
     */
    int getInFlightRequestCount(String clusterId);
}

*Reference Implementation:*
The above interface could be implemented for a given load balancer:

package org.apache.stratos.haproxy.extension;

/**
 * HAProxy statistics reader.
 */
public class HAProxyStatsReader implements LoadBalancerStatsReader {
    ...

    @Override
    public int getInFlightRequestCount(String clusterId) {
    ...
    }
}

*Load Balancer Extension:*
The statistics reader implementation could be passed to the
LoadBalancerExtension instance:

HAProxyContext.getInstance().validate();
LoadBalancerExtension extension = new LoadBalancerExtension(new HAProxy(),
new HAProxyStatsReader());
Thread thread = new Thread(extension);
thread.start();


*How to Install HAProxy Extension:*
1. Download and extract HAProxy binary distribution to a desired location:
<HAPROXY-HOME>.

2. Extract apache-stratos-haproxy-extension-4.0.0-SNAPSHOT-bin.zip to a
desired location: <HAPROXY-EXTENSION-HOME>.

3. Open <HAPROXY-EXTENSION-HOME>/bin/haproxy-extension.sh file in a text
editor and update following system properties:
   -Dexecutable.file.path=<HAPROXY-HOME>/haproxy     # HAProxy executable
file path
   -Dconf.file.path=/tmp/haproxy.cfg                                   #
HAProxy configuration file path
   -Dstats.socket.file.path=/tmp/haproxy-stats.socket         # HAProxy
statistics socket file path
   -Dthrift.receiver.ip=localhost
# CEP IP Address
   -Dthrift.receiver.port=7615
 # CEP Port

4. Open <HAPROXY-EXTENSION-HOME>/conf/jndi.properties file in a text editor
and update message broker information:
    connectionfactory.topicConnectionfactory=amqp://admin:admin@carbon
/carbon?brokerlist='tcp://<message-broker-ip>:<message-broker-port>'

5. Run <HAPROXY-EXTENSION-HOME>/bin/haproxy-extension.sh


Many Thanks
Imesh

Reply via email to