#  Licensed to the Apache Software Foundation (ASF) under one
#  or more contributor license agreements.  See the NOTICE file
#  distributed with this work for additional information
#  regarding copyright ownership.  The ASF licenses this file
#  to you under the Apache License, Version 2.0 (the
#  "License"); you may not use this file except in compliance
#  with the License.  You may obtain a copy of the License at
#  
#  http://www.apache.org/licenses/LICENSE-2.0
#  
#  Unless required by applicable law or agreed to in writing,
#  software distributed under the License is distributed on an
#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
#  KIND, either express or implied.  See the License for the
#  specific language governing permissions and limitations
#  under the License.

loadbalancer {

    # Default load balancing algorithm
    # Refer algorithm name from algorithms section.
    algorithm: round-robin;

    # Enable/disable failover handling
    # If failover handling is enabled load balancer will retry requests on all members in a
    # given cluster if the selected member fails to respond.
    failover: true;

    # Enable/disable session affinity
    # If session affinity is enabled load balancer will track all outgoing sessions and delegate
    # incoming requests to members with same sessions.
    session-affinity: true;

    # Endpoint timeout in milli-seconds
    endpoint-timeout: 60000;

    # Session timeout in milli-seconds
    session-timeout: 90000;

    # Enable/disable topology event listener
    # If this property is set to true, load balancer will listen to topology events and build
    # the topology configuration accordingly. If not static configuration given in the services
    # section will be used.
    topology-event-listener: false;

    # Topology member ip address type
    # Provide this configuration if topology-event-listener is set to true. If this property is set to 'private'
    # load balancer will delegate requests to member's private IP address. If it is set to 'public' requests will
    # be delegated to member's public IP address.
    topology-member-ip-type: private;

    # Topology service filter
    # Provide service names in a comma separated list to filter incoming topology events if
    # topology_event_listener_enabled is set to true. This functionality could be used for hosting
    # dedicated load balancers for services.
    # topology-service-filter: service-name=service-name1,service-name2;

    # Topology cluster filter
    # Provide cluster ids in a comma separated list to filter incoming topology events if
    # topology_event_listener_enabled is set to true. This functionality could be used for hosting
    # dedicated load balancers for subscriptions.
    # topology-cluster-filter: cluster-id=cluster-id1,cluster-id2;

    # Topology member filter
    # Provide load balancer cluster ids in a comma separated list to filter incoming topology events if
    # topology_event_listener_enabled is set to true. This functionality could be used for allowing members
    # to join a given load balancer cluster.
    # topology-member-filter: lb-cluster-id=lb-cluster-id1;

    # Enable/disable cep statistics publisher
    cep-stats-publisher: false;

    # Complex event processor endpoint
    # Provide CEP ip address and port if cep-stats-publisher is set to true.
    cep-ip: localhost;
    cep-port: 7615;

    # Network partition id
    # Provide the network partition id if cep-stats-publisher is set to true.
    network-partition-id: network-partition-1;

    # Multi-tenancy
    # If this property is set to true, all incoming request URLs will be scanned using the given tenant-identifier-regex
    # and matching tenant identifier value will be used to delegate the requests to the relevant cluster.
    multi-tenancy: false;
    tenant-identifier: tenant-domain; # Tenant identifier could either be tenant-id or tenant-domain.
    tenant-identifier-regex: t/([^/]*)/; # Regular expression for extracting the tenant identifier value from the URL.

    # Load balancing algorithm class names
    algorithms {
        round-robin {  # algorithm name
            class-name: org.apache.stratos.load.balancer.algorithm.RoundRobin;
        }
    }

    # Rewrite location header
    # If this property is set to true, load balancer will rewrite HTTP Location header values found in response
    # messages if the host is set to an ip address of a known member. The resulting Location header host will be
    # set to corresponding cluster hostname and the port will be set to corresponding transport proxy port.
    rewrite-location-header: true;

    # Static topology configuration
    # Define a static topology configuration if topology-event-listener is set to false.
    # A sample configuration has been given below:
    #
    # services {
    #     app-server {  # service name, a unique identifier to identify a service
    #         multi-tenant: true; # Set to true if the service is multi-tenant
    #         clusters {
    #             app-server-cluster1 {  # cluster id, a unique identifier to identify a cluster
    #                 hosts: cluster1.appserver.foo.org, cluster1.org;  # comma separated hostname list
    #                 tenant-range: 1-100; # Tenant range of the cluster
    #                 algorithm: round-robin;  # algorithm name
    #                 members {
    #                     m1 {  # member id, a unique identifier to identify a member
    #                         ip: 10.0.0.10; # member ip address
    #                         ports {
    #                             http {
    #                                 value: 8080; # application port
    #                                 proxy: 80;   # proxy port exposed by load balancer transport, set this value in axis2.xml
    #                             }
    #                             https {
    #                                 value: 8090;
    #                                 proxy: 443;
    #                             }
    #                         }
    #                     }
    #                     m2 {
    #                         ip: 10.0.0.11;
    #                         ports {
    #                             http {
    #                                 value: 8080;
    #                                 proxy: 80;
    #                             }
    #                             https {
    #                                 value: 8090;
    #                                 proxy: 443;
    #                             }
    #                         }
    #                     }
    #                 }
    #             }
    #         }
    #     }
    # }
	services {
		appserver {
			multi-tenant: true;
			clusters {
				app-server-mgt-cluster {
					hosts: mgt.as.cloud-test.wso2.com;
					tenant-range: *;
					algorithm: round-robin;
						members {
                    		m1 {  # member id, a unique identifier to identify a member
                        		ip: 192.168.10.100; # member ip address
								#ip: mgt.as.cloud-test.wso2.com;
                         		ports {
                            		http {
                                		value: 9764; # application port
                                		proxy: 80;   # proxy port exposed by load balancer transport, set this value in axis2.xml
                             		}
                             		https {
                                		value: 9444;
                                		proxy: 443;
                             		}
                         		}
                     		}
                 		}	
					}
				}
	    	}
		}
	}
}