You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ma...@apache.org on 2014/09/24 09:22:24 UTC
git commit: Support HAProxy for default and static load balancer
Repository: stratos
Updated Branches:
refs/heads/master aecbdf758 -> 7e146d29e
Support HAProxy for default and static load balancer
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/7e146d29
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/7e146d29
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/7e146d29
Branch: refs/heads/master
Commit: 7e146d29e79fb82528f8c6adb1aed683cc0472ec
Parents: aecbdf7
Author: Manula Thantriwatte <ma...@apache.org>
Authored: Wed Sep 24 07:21:22 2014 +0000
Committer: Manula Thantriwatte <ma...@apache.org>
Committed: Wed Sep 24 07:21:22 2014 +0000
----------------------------------------------------------------------
.../src/main/bin/haproxy-extension.sh | 1 +
.../apache/stratos/haproxy/extension/Constants.java | 1 +
.../haproxy/extension/HAProxyConfigWriter.java | 7 ++++---
.../stratos/haproxy/extension/HAProxyContext.java | 14 ++++++++++++--
.../haproxy-extension/src/main/license/LICENSE | 1 -
5 files changed, 18 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/7e146d29/extensions/load-balancer/haproxy-extension/src/main/bin/haproxy-extension.sh
----------------------------------------------------------------------
diff --git a/extensions/load-balancer/haproxy-extension/src/main/bin/haproxy-extension.sh b/extensions/load-balancer/haproxy-extension/src/main/bin/haproxy-extension.sh
index 3f6bc73..f8ed9b3 100755
--- a/extensions/load-balancer/haproxy-extension/src/main/bin/haproxy-extension.sh
+++ b/extensions/load-balancer/haproxy-extension/src/main/bin/haproxy-extension.sh
@@ -40,6 +40,7 @@ properties="-Dhaproxy.private.ip=127.0.0.1
-Dthrift.receiver.port=7615
-Dnetwork.partition.id=network-partition-1
-Dcluster.id=cluster
+ -Dservice.name=service
-Dcep.stats.publisher.enabled=true"
http://git-wip-us.apache.org/repos/asf/stratos/blob/7e146d29/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/Constants.java
----------------------------------------------------------------------
diff --git a/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/Constants.java b/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/Constants.java
index eb88c16..d0abeb8 100644
--- a/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/Constants.java
+++ b/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/Constants.java
@@ -35,6 +35,7 @@ public class Constants {
public static final String THRIFT_RECEIVER_PORT = "thrift.receiver.port";
public static final String NETWORK_PARTITION_ID = "network.partition.id";
public static final String CLUSTER_ID = "cluster.id";
+ public static final String SERVICE_NAME = "service.name";
public static final String LOAD_BALANCER = "load.balancer";
public static final String LOAD_BALANCER_REF = "load.balancer.ref";
http://git-wip-us.apache.org/repos/asf/stratos/blob/7e146d29/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/HAProxyConfigWriter.java
----------------------------------------------------------------------
diff --git a/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/HAProxyConfigWriter.java b/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/HAProxyConfigWriter.java
index 10a4c97..f7349d9 100644
--- a/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/HAProxyConfigWriter.java
+++ b/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/HAProxyConfigWriter.java
@@ -79,7 +79,7 @@ public class HAProxyConfigWriter {
frontEndHttpsAdded = false;
for (Service service : topology.getServices()) {
- if (service.getServiceName().equals("haproxy")) {
+ if (service.getServiceName().equals(HAProxyContext.getInstance().getServiceName())) {
for (Cluster cluster : service.getClusters()) {
if (cluster.getClusterId().equals(HAProxyContext.getInstance().getClusterId())) {
if ((cluster.getProperties().getProperty(Constants.LOAD_BALANCER) != null) && (cluster.getProperties().getProperty(Constants.LOAD_BALANCER_REF) != null)) {
@@ -88,7 +88,8 @@ public class HAProxyConfigWriter {
loadBalancedServiceType = cluster.getProperties().getProperty(Constants.LB_SERVICE_TYPE);
break;
} else {
- loadBalancerType = cluster.getProperties().getProperty(Constants.STATIC_LOAD_BALANCER);
+ loadBalancerType = Constants.STATIC_LOAD_BALANCER;
+ log.debug("Static load balancer");
break;
}
}
@@ -101,7 +102,7 @@ public class HAProxyConfigWriter {
if (cluster.getProperties().getProperty(Constants.LOAD_BALANCER) == null) {
if ((cluster.getProperties().getProperty(Constants.LOAD_BALANCER_REF) != null)) {
if ((cluster.getProperties().getProperty(Constants.LOAD_BALANCER_REF).equals(Constants.NO_LOAD_BALANCER)) &&
- Constants.STATIC_LOAD_BALANCER.equals(loadBalancerType)) {
+ Constants.STATIC_LOAD_BALANCER.equals(loadBalancerType) && cluster.getServiceName().equals(HAProxyContext.getInstance().getLbserviceType())) {
createConfig(service, cluster);
} else if ((cluster.getProperties().getProperty(Constants.LOAD_BALANCER_REF).equals(Constants.DEFAULT_LOAD_BALANCER)) &&
Constants.DEFAULT_LOAD_BALANCER.equals(loadBalancerType)) {
http://git-wip-us.apache.org/repos/asf/stratos/blob/7e146d29/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/HAProxyContext.java
----------------------------------------------------------------------
diff --git a/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/HAProxyContext.java b/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/HAProxyContext.java
index f73498a..1228b53 100644
--- a/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/HAProxyContext.java
+++ b/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/HAProxyContext.java
@@ -42,6 +42,8 @@ public class HAProxyContext {
private String thriftReceiverPort;
private String networkPartitionId;
private String clusterId;
+ private String serviceName;
+ private String lbserviceType;
private HAProxyContext() {
this.haProxyPrivateIp = System.getProperty(Constants.HAPROXY_PRIVATE_IP);
@@ -56,6 +58,8 @@ public class HAProxyContext {
this.thriftReceiverPort = System.getProperty(Constants.THRIFT_RECEIVER_PORT);
this.networkPartitionId = System.getProperty(Constants.NETWORK_PARTITION_ID);
this.clusterId = System.getProperty(Constants.CLUSTER_ID);
+ this.serviceName = System.getProperty(Constants.SERVICE_NAME);
+ this.lbserviceType = System.getProperty(Constants.LB_SERVICE_TYPE);
if (log.isDebugEnabled()) {
log.debug(Constants.HAPROXY_PRIVATE_IP + " = " + haProxyPrivateIp);
@@ -95,7 +99,7 @@ public class HAProxyContext {
validateSystemProperty(Constants.CEP_STATS_PUBLISHER_ENABLED);
validateSystemProperty(Constants.CLUSTER_ID);
- if(cepStatsPublisherEnabled) {
+ if (cepStatsPublisherEnabled) {
validateSystemProperty(Constants.THRIFT_RECEIVER_IP);
validateSystemProperty(Constants.THRIFT_RECEIVER_PORT);
validateSystemProperty(Constants.NETWORK_PARTITION_ID);
@@ -104,7 +108,7 @@ public class HAProxyContext {
private void validateSystemProperty(String propertyName) {
String value = System.getProperty(propertyName);
- if(StringUtils.isEmpty(value)) {
+ if (StringUtils.isEmpty(value)) {
throw new RuntimeException("System property was not found: " + propertyName);
}
}
@@ -148,4 +152,10 @@ public class HAProxyContext {
public String getClusterId() {
return clusterId;
}
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public String getLbserviceType() { return lbserviceType;}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/7e146d29/extensions/load-balancer/haproxy-extension/src/main/license/LICENSE
----------------------------------------------------------------------
diff --git a/extensions/load-balancer/haproxy-extension/src/main/license/LICENSE b/extensions/load-balancer/haproxy-extension/src/main/license/LICENSE
index 5a78fc9..d9da95e 100644
--- a/extensions/load-balancer/haproxy-extension/src/main/license/LICENSE
+++ b/extensions/load-balancer/haproxy-extension/src/main/license/LICENSE
@@ -457,7 +457,6 @@ slf4j-log4j12-1.7.5.jar
The MIT License (MIT)
-Copyright (c) 2004-2013 QOS.ch
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal