Hi Imesh,

One question,

This is one way of identifying tenant (from URL using t/([^/]*)/).
What if someone want to plug-in a different way for that? Is that
possible?

On Sun, Dec 8, 2013 at 3:37 PM, Imesh Gunaratne <[email protected]> wrote:
> Hi All,
>
> Multi-tenancy support in Stratos Load Balancer is now ready. Changes have
> been committed with commit revision:
> 57cccfbf83c3c3b7a322cd6b3124a74eae08ce29.
>
> How it works:
> - According to the discussions had on Multi-Tenancy support, Stratos Manager
> publishes tenant information to the message broker via a topic.
> - A sample complete tenant event message:
> {"tenants":[{"tenantId":1,"tenantDomain":"foo.org","serviceNameMap":{"app-server":true}},{"tenantId":2,"tenantDomain":"abc.org","serviceNameMap":{"app-server":true}}]}
> - Events: CompleteTenantEvent, TenantCreatedEvent, TenantUpdatedEvent,
> TenantRemovedEvent, TenantSubscribedEvent, TenantUnSubscribedEvent.
> - These event messages are received by load balancer and a corresponding
> tenant data model is maintained.
> - Multi-tenancy is enabled in load balancer and tenant identifier is
> specified either as tenant-id or tenant-domain.
> - Then tenant identifier regular expression is defined: default: t/([^/]*)/.
> This is used to scan the request URL and find the tenant identifier value.
> - Load balancer maintains two hash maps:
>   - Map<HostName, Cluster>: map hostname to cluster
>   - Map<HostName, Map<TenantId, Cluster>>: map hostname, tenant id to
> cluster
> - When a request is received if multi-tenancy is disabled it will use
> Map<Hostname, Cluster> map to identify the service cluster and forward the
> request to the next available member.
> - If multi-tenancy is enabled: it will scan the request URL using the
> regular expression given and find the tenant identifier value.
> - Then the matching cluster will be identified using Map<HostName,
> Map<TenantId, Cluster>>.
>
> Test Case
> The above functionality was tested with two Application Server clusters:
>
>     services {
>          app-server {  # service name, a unique identifier to identify a
> service
>              multi-tenant: true;
>              clusters {
>                  app-server-cluster1 {  # cluster id, a unique identifier to
> identify a cluster
>                      hosts: foo.org, cluster1.org;  # comma separated
> hostname list
>                      tenant-range: 0-1;
>                      algorithm: round-robin;  # algorithm name
>                      members {
>                          m1 {  # member id, a unique identifier to identify
> a member
>                              ip: 192.168.1.110; # member ip address
>                              ports {
>                                  http {
>                                      value: 9773; # application port
>                                      proxy: 80;   # proxy port exposed by
> load balancer transport, set this value in axis2.xml
>                                  }
>                                  https {
>                                      value: 9453;
>                                      proxy: 443;
>                                  }
>                              }
>                          }
>                      }
>                  }
>                  app-server-cluster2 {  # cluster id, a unique identifier to
> identify a cluster
>                      hosts: foo.org, cluster1.org;  # comma separated
> hostname list
>                      tenant-range: 2-*;
>                      algorithm: round-robin;  # algorithm name
>                      members {
>                          m2 {
>                              ip: 192.168.1.110;
>                              ports {
>                                  http {
>                                      value: 9774;
>                                      proxy: 80;
>                                  }
>                                  https {
>                                      value: 9454;
>                                      proxy: 443;
>                                  }
>                              }
>                          }
>                      }
>                  }
>              }
>                  }
>              }
>          }
>
> Tenant Definitions:
>
> Tenant 1:
> Tenant ID: 1, Tenant Domain: foo.org, Subscriptions: app-server
>
> Tenant 2:
> Tenant ID: 2, Tenant Domain: abc.org, Subscriptions: app-server
>
>
> Super Tenant Request Log:
>
> [...] DEBUG - TenantAwareLoadBalanceEndpoint Multi-tenancy enabled, scanning
> URL for tenant...
> [...] DEBUG - TenantAwareLoadBalanceEndpoint Request URL: /
> [...] DEBUG - TenantAwareLoadBalanceEndpoint Tenant identifier regex:
> t/([^/]*)/
> [...] DEBUG - TenantAwareLoadBalanceEndpoint Tenant identifier not found in
> URL
> [...] DEBUG - RoundRobin Searching for next member: [service] app-server
> [cluster]: app-server-cluster1 [member-count]: 1 [current-index] 0
> [...] DEBUG - RequestDelegator Next member identified in 1ms: [service]
> app-server [cluster] app-server-cluster1 [member] m1
> [...] DEBUG - TenantAwareLoadBalanceEndpoint Sending request to endpoint:
> https://192.168.1.110:9453/
>
> Tenant 1 Request Log:
>
> [...] DEBUG - TenantAwareLoadBalanceEndpoint Multi-tenancy enabled, scanning
> URL for tenant...
> [...] DEBUG - TenantAwareLoadBalanceEndpoint Request URL:
> /t/foo.org/carbon/admin/index.jsp
> [...] DEBUG - TenantAwareLoadBalanceEndpoint Tenant identifier regex:
> t/([^/]*)/
> [...] DEBUG - TenantAwareLoadBalanceEndpoint Identifying tenant using tenant
> domain...
> [...] DEBUG - TenantAwareLoadBalanceEndpoint Tenant identifier found:
> [tenant-domain] foo.org [tenant-id] 1
> [...] DEBUG - RoundRobin Searching for next member: [service] app-server
> [cluster]: app-server-cluster1 [member-count]: 1 [current-index] 0
> [...] DEBUG - RequestDelegator Next member identified in 4ms: [service]
> app-server [cluster] app-server-cluster1 [tenant-id] 1 [member] m1
> [...]  INFO - LoadBalancerInFlightRequestCountCollector Load balancing
> statistics notifier thread started
> [...] DEBUG - TenantAwareLoadBalanceEndpoint Sending request to endpoint:
> https://192.168.1.110:9453/t/foo.org/carbon/admin/index.jsp
>
> Tenant 2 Request Log:
>
> [...] DEBUG - TenantAwareLoadBalanceEndpoint Multi-tenancy enabled, scanning
> URL for tenant...
> [...] DEBUG - TenantAwareLoadBalanceEndpoint Request URL:
> /t/abc.org/carbon/admin/login.jsp
> [...] DEBUG - TenantAwareLoadBalanceEndpoint Tenant identifier regex:
> t/([^/]*)/
> [...] DEBUG - TenantAwareLoadBalanceEndpoint Identifying tenant using tenant
> domain...
> [...] DEBUG - TenantAwareLoadBalanceEndpoint Tenant identifier found:
> [tenant-domain] abc.org [tenant-id] 2
> [...] DEBUG - RoundRobin Searching for next member: [service] app-server
> [cluster]: app-server-cluster2 [member-count]: 1 [current-index] 0
> [...] DEBUG - RequestDelegator Next member identified in 1ms: [service]
> app-server [cluster] app-server-cluster2 [tenant-id] 2 [member] m2
> [...] DEBUG - TenantAwareLoadBalanceEndpoint Sending request to endpoint:
> https://192.168.1.110:9454/t/abc.org/carbon/admin/login.jsp
> [...] DEBUG - TenantAwareLoadBalanceEndpoint Existing session found:
> JSESSIONID=585B7333AD1C2920FE0CDDE1BCC610B2
> [...] DEBUG - TenantAwareLoadBalanceEndpoint Sending request to endpoint:
> https://192.168.1.110:9454/carbon/admin/login.jsp
>
>
> Please feel free to add your thoughts on this.
>
> Many Thanks
> Imesh

Reply via email to