You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by la...@apache.org on 2015/04/13 05:22:17 UTC
[04/16] stratos git commit: Formatting Load balancer module
Formatting Load balancer module
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/7d6d933b
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/7d6d933b
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/7d6d933b
Branch: refs/heads/master
Commit: 7d6d933b952678f5894ab43e6797e16465c6cc60
Parents: 13e979e
Author: Lahiru Sandaruwan <la...@apache.org>
Authored: Sun Apr 12 20:45:27 2015 +0530
Committer: Lahiru Sandaruwan <la...@apache.org>
Committed: Sun Apr 12 20:45:27 2015 +0530
----------------------------------------------------------------------
.../org.apache.stratos.load.balancer/pom.xml | 3 +-
.../conf/LoadBalancerConfiguration.java | 8 ++-
.../conf/configurator/CEPConfigurator.java | 2 +-
.../load/balancer/conf/domain/MemberIpType.java | 2 +-
.../load/balancer/conf/structure/Node.java | 32 ++++++------
.../balancer/conf/structure/NodeBuilder.java | 32 ++++++------
.../load/balancer/conf/util/Constants.java | 32 ++++++------
.../load/balancer/context/AlgorithmContext.java | 6 +--
.../balancer/context/LoadBalancerContext.java | 2 +-
.../balancer/endpoint/RequestDelegator.java | 26 +++++-----
.../TenantAwareLoadBalanceEndpoint.java | 50 ++++++++++---------
.../internal/LoadBalancerServiceComponent.java | 52 ++++++++++----------
.../balancer/mediators/LocationReWriter.java | 38 +++++++-------
.../balancer/mediators/ResponseInterceptor.java | 40 +++++++--------
.../LoadBalancerStatisticsCollector.java | 4 +-
.../test/LoadBalancerConfigurationTest.java | 32 ++++++------
.../LoadBalancerStatisticsCollectorTest.java | 34 ++++++-------
17 files changed, 199 insertions(+), 196 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/7d6d933b/components/org.apache.stratos.load.balancer/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/pom.xml b/components/org.apache.stratos.load.balancer/pom.xml
index 981bad4..b723858 100644
--- a/components/org.apache.stratos.load.balancer/pom.xml
+++ b/components/org.apache.stratos.load.balancer/pom.xml
@@ -17,7 +17,8 @@
~ specific language governing permissions and limitations
~ under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.apache.stratos</groupId>
http://git-wip-us.apache.org/repos/asf/stratos/blob/7d6d933b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/LoadBalancerConfiguration.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/LoadBalancerConfiguration.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/LoadBalancerConfiguration.java
index 9ea21e9..87a9cb3 100644
--- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/LoadBalancerConfiguration.java
+++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/LoadBalancerConfiguration.java
@@ -538,13 +538,11 @@ public class LoadBalancerConfiguration {
}
private MemberIpType transformMemberIpType(String topologyMemberIpType) {
- if("private".equals(topologyMemberIpType)) {
+ if ("private".equals(topologyMemberIpType)) {
return MemberIpType.Private;
- }
- else if("public".equals(topologyMemberIpType)) {
+ } else if ("public".equals(topologyMemberIpType)) {
return MemberIpType.Public;
- }
- else {
+ } else {
throw new InvalidConfigurationException(String.format("Topology member ip address type is not valid: %s", topologyMemberIpType));
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/7d6d933b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/configurator/CEPConfigurator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/configurator/CEPConfigurator.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/configurator/CEPConfigurator.java
index 952ce52..fca1722 100644
--- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/configurator/CEPConfigurator.java
+++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/configurator/CEPConfigurator.java
@@ -29,7 +29,7 @@ public class CEPConfigurator {
public static void configure(LoadBalancerConfiguration configuration) {
// Set system properties
System.setProperty("cep.stats.publisher.enabled", String.valueOf(configuration.isCepStatsPublisherEnabled()));
- if(configuration.isCepStatsPublisherEnabled()) {
+ if (configuration.isCepStatsPublisherEnabled()) {
System.setProperty("thrift.receiver.ip", configuration.getCepIp());
System.setProperty("thrift.receiver.port", String.valueOf(configuration.getCepPort()));
System.setProperty("network.partition.id", configuration.getNetworkPartitionId());
http://git-wip-us.apache.org/repos/asf/stratos/blob/7d6d933b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/domain/MemberIpType.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/domain/MemberIpType.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/domain/MemberIpType.java
index f5132d6..00e36a8 100644
--- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/domain/MemberIpType.java
+++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/domain/MemberIpType.java
@@ -26,6 +26,6 @@ package org.apache.stratos.load.balancer.conf.domain;
* Time: 11:18 AM
* To change this template use File | Settings | File Templates.
*/
-public enum MemberIpType {
+public enum MemberIpType {
Private, Public
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/7d6d933b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/structure/Node.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/structure/Node.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/structure/Node.java
index a7b3808..2b33725 100755
--- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/structure/Node.java
+++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/structure/Node.java
@@ -1,20 +1,20 @@
/**
- * 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.
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
*/
package org.apache.stratos.load.balancer.conf.structure;
http://git-wip-us.apache.org/repos/asf/stratos/blob/7d6d933b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/structure/NodeBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/structure/NodeBuilder.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/structure/NodeBuilder.java
index bbdbe9b..297f5a5 100755
--- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/structure/NodeBuilder.java
+++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/structure/NodeBuilder.java
@@ -1,20 +1,20 @@
/**
- * 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.
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
*/
package org.apache.stratos.load.balancer.conf.structure;
http://git-wip-us.apache.org/repos/asf/stratos/blob/7d6d933b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/util/Constants.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/util/Constants.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/util/Constants.java
index ba59d8e..79b5bcd 100755
--- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/util/Constants.java
+++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/util/Constants.java
@@ -1,20 +1,20 @@
/**
- * 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.
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
*/
package org.apache.stratos.load.balancer.conf.util;
http://git-wip-us.apache.org/repos/asf/stratos/blob/7d6d933b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/AlgorithmContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/AlgorithmContext.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/AlgorithmContext.java
index d261791..fc1f4a5 100755
--- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/AlgorithmContext.java
+++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/AlgorithmContext.java
@@ -52,7 +52,7 @@ public class AlgorithmContext {
lock = acquireCurrentMemberIndexLock();
putCurrentMemberIndex(serviceName, clusterId, 0);
} finally {
- if(lock != null) {
+ if (lock != null) {
releaseCurrentMemberIndexLock(lock);
}
}
@@ -76,7 +76,7 @@ public class AlgorithmContext {
lock = acquireCurrentMemberIndexLock();
putCurrentMemberIndex(getServiceName(), getClusterId(), currentMemberIndex);
} finally {
- if(lock != null) {
+ if (lock != null) {
releaseCurrentMemberIndexLock(lock);
}
}
@@ -91,7 +91,7 @@ public class AlgorithmContext {
}
private void releaseCurrentMemberIndexLock(Lock lock) {
- if(lock != null) {
+ if (lock != null) {
distributedObjectProvider.releaseLock(lock);
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/7d6d933b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/LoadBalancerContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/LoadBalancerContext.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/LoadBalancerContext.java
index 2ba0cfd..2ebc466 100644
--- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/LoadBalancerContext.java
+++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/context/LoadBalancerContext.java
@@ -90,7 +90,7 @@ public class LoadBalancerContext {
}
public void removeDomainMappingContextPath(String hostName) {
- if(containsDomainMappingContextPath(hostName)) {
+ if (containsDomainMappingContextPath(hostName)) {
hostNameToDomainMappingContextPathMap.remove(hostName);
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/7d6d933b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/endpoint/RequestDelegator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/endpoint/RequestDelegator.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/endpoint/RequestDelegator.java
index 636955d..5047fc6 100644
--- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/endpoint/RequestDelegator.java
+++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/endpoint/RequestDelegator.java
@@ -48,7 +48,8 @@ public class RequestDelegator {
/**
* Find the next member in a cluster by applying a load balancing algorithm by the given host name.
- * @param hostName host name of the cluster
+ *
+ * @param hostName host name of the cluster
* @param messageId synapse message id to be included in debugging logs
* @return
*/
@@ -73,9 +74,8 @@ public class RequestDelegator {
}
}
return member;
- }
- else {
- if(log.isWarnEnabled()) {
+ } else {
+ if (log.isWarnEnabled()) {
log.warn(String.format("Could not find a cluster for hostname %s", hostName));
}
}
@@ -84,6 +84,7 @@ public class RequestDelegator {
/**
* Find the next member in a cluster by applying a load balancing algorithm by the given host name and tenant id.
+ *
* @param hostName host name of the cluster
* @param tenantId tenant id of the incoming request
* @return
@@ -104,22 +105,21 @@ public class RequestDelegator {
}
}
return member;
- }
- else {
- if(log.isWarnEnabled()) {
+ } else {
+ if (log.isWarnEnabled()) {
log.warn(String.format("Could not find a cluster for hostname %s and tenant-id %d", hostName, tenantId));
}
}
return null;
}
- /**
+ /**
* Find next member in the cluster by applying a load balancing algorithm.
- *
- * This operation should be synchronized in order to find a member
- * correctly. This has no performance impact as per the load tests
- * carried out.
- */
+ * <p/>
+ * This operation should be synchronized in order to find a member
+ * correctly. This has no performance impact as per the load tests
+ * carried out.
+ */
private synchronized Member findNextMemberInCluster(Cluster cluster) {
// Find algorithm context of the cluster
ClusterContext clusterContext = LoadBalancerContext.getInstance().getClusterContext(cluster.getClusterId());
http://git-wip-us.apache.org/repos/asf/stratos/blob/7d6d933b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/endpoint/TenantAwareLoadBalanceEndpoint.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/endpoint/TenantAwareLoadBalanceEndpoint.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/endpoint/TenantAwareLoadBalanceEndpoint.java
index a71c7a8..b483bb2 100644
--- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/endpoint/TenantAwareLoadBalanceEndpoint.java
+++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/endpoint/TenantAwareLoadBalanceEndpoint.java
@@ -76,7 +76,7 @@ public class TenantAwareLoadBalanceEndpoint extends org.apache.synapse.endpoints
/* Sessions time out interval */
private long sessionTimeout = -1;
-
+
private final static Pattern LAST_INT_PATTERN = Pattern.compile("[^0-9]+([0-9]+)$");
@Override
@@ -156,15 +156,15 @@ public class TenantAwareLoadBalanceEndpoint extends org.apache.synapse.endpoints
private void setupLoadBalancerContextProperties(MessageContext synCtx, org.apache.axis2.clustering.Member currentMember) {
String targetHostname = extractTargetHost(synCtx);
org.apache.axis2.context.MessageContext axis2MsgCtx = ((Axis2MessageContext) synCtx).getAxis2MessageContext();
-
+
String httpTransportName = "http", httpsTransportName = "https";
String transportId = getTransportId(extractIncomingTransport(synCtx));
-
- if (transportId != null) {
- httpsTransportName = httpsTransportName.concat(transportId);
- httpTransportName = httpTransportName.concat(transportId);
- }
-
+
+ if (transportId != null) {
+ httpsTransportName = httpsTransportName.concat(transportId);
+ httpTransportName = httpTransportName.concat(transportId);
+ }
+
TransportInDescription httpTransportIn = axis2MsgCtx.getConfigurationContext().getAxisConfiguration().getTransportIn(httpTransportName);
TransportInDescription httpsTransportIn = axis2MsgCtx.getConfigurationContext().getAxisConfiguration().getTransportIn(httpsTransportName);
String lbHttpPort = (String) httpTransportIn.getParameter("port").getValue();
@@ -176,16 +176,16 @@ public class TenantAwareLoadBalanceEndpoint extends org.apache.synapse.endpoints
synCtx.setProperty(LoadBalancerConstants.LB_HTTPS_PORT, lbHttpsPort);
synCtx.setProperty(LoadBalancerConstants.CLUSTER_ID, clusterId);
}
-
- protected String getTransportId(String incomingTransportName) {
- // pattern match and find the transport id.
- Matcher matcher = LAST_INT_PATTERN.matcher(incomingTransportName);
- if (matcher.find()) {
- return matcher.group(1);
- }
- return null;
- }
+ protected String getTransportId(String incomingTransportName) {
+ // pattern match and find the transport id.
+ Matcher matcher = LAST_INT_PATTERN.matcher(incomingTransportName);
+ if (matcher.find()) {
+ return matcher.group(1);
+ }
+
+ return null;
+ }
/**
@@ -241,8 +241,8 @@ public class TenantAwareLoadBalanceEndpoint extends org.apache.synapse.endpoints
String url = extractUrl(synCtx);
int tenantId = scanUrlForTenantId(url);
- if(tenantId == -1) {
- // If there is no tenant involves in the URL, Find next member from host name
+ if (tenantId == -1) {
+ // If there is no tenant involves in the URL, Find next member from host name
member = requestDelegator.findNextMemberFromHostName(targetHost, synCtx.getMessageID());
} else if (tenantExists(tenantId)) {
// Tenant found, find member from hostname and tenant id
@@ -264,6 +264,7 @@ public class TenantAwareLoadBalanceEndpoint extends org.apache.synapse.endpoints
/**
* Create axis2 member from load balancer member object.
+ *
* @param synCtx
* @param member
* @return
@@ -290,7 +291,7 @@ public class TenantAwareLoadBalanceEndpoint extends org.apache.synapse.endpoints
* @param axis2Member
*/
private void updateAxis2MemberPorts(MessageContext synCtx, org.apache.axis2.clustering.Member axis2Member) {
- if(log.isDebugEnabled()) {
+ if (log.isDebugEnabled()) {
log.debug("Updating axis2 member port");
}
@@ -437,7 +438,7 @@ public class TenantAwareLoadBalanceEndpoint extends org.apache.synapse.endpoints
private int scanUrlForTenantId(String url) {
int tenantId = -1;
List<String> regexList = LoadBalancerConfiguration.getInstance().getTenantIdentifierRegexList();
- for(String regex : regexList) {
+ for (String regex : regexList) {
if (log.isDebugEnabled()) {
log.debug(String.format("Request URL: %s ", url));
log.debug(String.format("Tenant identifier regex: %s ", regex));
@@ -475,6 +476,7 @@ public class TenantAwareLoadBalanceEndpoint extends org.apache.synapse.endpoints
/**
* Check tenant exists.
+ *
* @param tenantId
* @return
*/
@@ -489,6 +491,7 @@ public class TenantAwareLoadBalanceEndpoint extends org.apache.synapse.endpoints
/**
* Find tenant id from tenant domain.
+ *
* @param tenantDomain
* @return
*/
@@ -507,6 +510,7 @@ public class TenantAwareLoadBalanceEndpoint extends org.apache.synapse.endpoints
/**
* Extract target host from incoming request.
+ *
* @param synCtx
* @return
*/
@@ -528,7 +532,7 @@ public class TenantAwareLoadBalanceEndpoint extends org.apache.synapse.endpoints
org.apache.axis2.context.MessageContext axis2MessageContext = ((Axis2MessageContext) synCtx).getAxis2MessageContext();
return axis2MessageContext.getTransportIn().getName();
}
-
+
private String extractIncomingTransport(MessageContext synCtx) {
org.apache.axis2.context.MessageContext axis2MessageContext = ((Axis2MessageContext) synCtx).getAxis2MessageContext();
return axis2MessageContext.getIncomingTransportName();
@@ -591,7 +595,7 @@ public class TenantAwareLoadBalanceEndpoint extends org.apache.synapse.endpoints
String hostName = extractTargetHost(synCtx);
if (LoadBalancerContext.getInstance().containsDomainMappingContextPath(hostName)) {
String appContext = LoadBalancerContext.getInstance().getDomainMappingContextPath(hostName);
- if(StringUtils.isNotBlank(appContext)) {
+ if (StringUtils.isNotBlank(appContext)) {
if (log.isDebugEnabled()) {
log.debug(String.format("Domain mapping found with application context: [domain-name] %s " +
"[app-context] %s", hostName, appContext));
http://git-wip-us.apache.org/repos/asf/stratos/blob/7d6d933b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/internal/LoadBalancerServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/internal/LoadBalancerServiceComponent.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/internal/LoadBalancerServiceComponent.java
index ca055de..4577735 100644
--- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/internal/LoadBalancerServiceComponent.java
+++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/internal/LoadBalancerServiceComponent.java
@@ -68,21 +68,21 @@ import java.util.concurrent.ExecutorService;
/**
* @scr.component name="org.apache.stratos.load.balancer.internal.LoadBalancerServiceComponent" immediate="true"
* @scr.reference name="distributedObjectProvider" interface="org.apache.stratos.common.services.DistributedObjectProvider"
- * cardinality="1..1" policy="dynamic" bind="setDistributedObjectProvider" unbind="unsetDistributedObjectProvider"
+ * cardinality="1..1" policy="dynamic" bind="setDistributedObjectProvider" unbind="unsetDistributedObjectProvider"
* @scr.reference name="configuration.context.service" interface="org.wso2.carbon.utils.ConfigurationContextService"
- * cardinality="1..1" policy="dynamic" bind="setConfigurationContextService" unbind="unsetConfigurationContextService"
+ * cardinality="1..1" policy="dynamic" bind="setConfigurationContextService" unbind="unsetConfigurationContextService"
* @scr.reference name="synapse.config.service" interface="org.wso2.carbon.mediation.initializer.services.SynapseConfigurationService"
- * cardinality="1..1" policy="dynamic" bind="setSynapseConfigurationService" unbind="unsetSynapseConfigurationService"
+ * cardinality="1..1" policy="dynamic" bind="setSynapseConfigurationService" unbind="unsetSynapseConfigurationService"
* @scr.reference name="synapse.env.service" interface="org.wso2.carbon.mediation.initializer.services.SynapseEnvironmentService"
- * cardinality="1..n" policy="dynamic" bind="setSynapseEnvironmentService" unbind="unsetSynapseEnvironmentService"
+ * cardinality="1..n" policy="dynamic" bind="setSynapseEnvironmentService" unbind="unsetSynapseEnvironmentService"
* @scr.reference name="registry.service" interface="org.wso2.carbon.registry.core.service.RegistryService"
- * cardinality="1..1" policy="dynamic" bind="setRegistryService" unbind="unsetRegistryService"
+ * cardinality="1..1" policy="dynamic" bind="setRegistryService" unbind="unsetRegistryService"
* @scr.reference name="dependency.mgt.service" interface="org.wso2.carbon.mediation.dependency.mgt.services.DependencyManagementService"
- * cardinality="0..1" policy="dynamic" bind="setDependencyManager" unbind="unsetDependencyManager"
+ * cardinality="0..1" policy="dynamic" bind="setDependencyManager" unbind="unsetDependencyManager"
* @scr.reference name="synapse.registrations.service" interface="org.wso2.carbon.mediation.initializer.services.SynapseRegistrationsService"
- * cardinality="1..n" policy="dynamic" bind="setSynapseRegistrationsService" unbind="unsetSynapseRegistrationsService"
+ * cardinality="1..n" policy="dynamic" bind="setSynapseRegistrationsService" unbind="unsetSynapseRegistrationsService"
* @scr.reference name="user.realmservice.default" interface="org.wso2.carbon.user.core.service.RealmService"
- * cardinality="1..1" policy="dynamic" bind="setRealmService" unbind="unsetRealmService"
+ * cardinality="1..1" policy="dynamic" bind="setRealmService" unbind="unsetRealmService"
*/
@SuppressWarnings({"UnusedDeclaration", "JavaDoc"})
public class LoadBalancerServiceComponent {
@@ -101,7 +101,7 @@ public class LoadBalancerServiceComponent {
try {
ClusteringAgent clusteringAgent = ServiceReferenceHolder.getInstance().getAxisConfiguration().getClusteringAgent();
boolean clusteringEnabled = (clusteringAgent != null);
- if(log.isInfoEnabled()) {
+ if (log.isInfoEnabled()) {
log.info(String.format("Load balancer clustering is %s", (clusteringEnabled ? "enabled" : "disabled")));
}
@@ -127,7 +127,7 @@ public class LoadBalancerServiceComponent {
threadPoolSize);
TopologyProvider topologyProvider = LoadBalancerConfiguration.getInstance().getTopologyProvider();
- if(topologyProvider == null) {
+ if (topologyProvider == null) {
topologyProvider = new TopologyProvider();
LoadBalancerConfiguration.getInstance().setTopologyProvider(topologyProvider);
}
@@ -138,7 +138,7 @@ public class LoadBalancerServiceComponent {
startApplicationSignUpEventReceiver(executorService, topologyProvider);
}
- if(configuration.isDomainMappingEnabled()) {
+ if (configuration.isDomainMappingEnabled()) {
// Start domain mapping event receiver
startDomainMappingEventReceiver(executorService, topologyProvider);
}
@@ -148,7 +148,7 @@ public class LoadBalancerServiceComponent {
startTopologyEventReceiver(executorService, topologyProvider);
}
- if(configuration.isCepStatsPublisherEnabled()) {
+ if (configuration.isCepStatsPublisherEnabled()) {
// Start statistics notifier
startStatisticsNotifier(topologyProvider);
}
@@ -165,7 +165,7 @@ public class LoadBalancerServiceComponent {
}
private void startDomainMappingEventReceiver(ExecutorService executorService, TopologyProvider topologyProvider) {
- if(domainMappingEventReceiver != null) {
+ if (domainMappingEventReceiver != null) {
return;
}
@@ -178,7 +178,7 @@ public class LoadBalancerServiceComponent {
}
private void startApplicationSignUpEventReceiver(ExecutorService executorService, TopologyProvider topologyProvider) {
- if(applicationSignUpEventReceiver != null) {
+ if (applicationSignUpEventReceiver != null) {
return;
}
@@ -191,29 +191,29 @@ public class LoadBalancerServiceComponent {
}
private void startTopologyEventReceiver(ExecutorService executorService, TopologyProvider topologyProvider) {
- if(topologyEventReceiver != null) {
+ if (topologyEventReceiver != null) {
return;
}
topologyEventReceiver = new LoadBalancerTopologyEventReceiver(topologyProvider);
- topologyEventReceiver.setExecutorService(executorService);
- topologyEventReceiver.execute();
+ topologyEventReceiver.setExecutorService(executorService);
+ topologyEventReceiver.execute();
if (log.isInfoEnabled()) {
log.info("Topology receiver thread started");
}
if (log.isInfoEnabled()) {
- if(TopologyServiceFilter.getInstance().isActive()) {
+ if (TopologyServiceFilter.getInstance().isActive()) {
log.info(String.format("Service filter activated: [filter] %s",
TopologyServiceFilter.getInstance().toString()));
}
- if(TopologyClusterFilter.getInstance().isActive()) {
+ if (TopologyClusterFilter.getInstance().isActive()) {
log.info(String.format("Cluster filter activated: [filter] %s",
TopologyClusterFilter.getInstance().toString()));
}
- if(TopologyMemberFilter.getInstance().isActive()) {
+ if (TopologyMemberFilter.getInstance().isActive()) {
log.info(String.format("Member filter activated: [filter] %s",
TopologyMemberFilter.getInstance().toString()));
}
@@ -254,7 +254,7 @@ public class LoadBalancerServiceComponent {
}
// Terminate topology receiver
- if(topologyEventReceiver != null) {
+ if (topologyEventReceiver != null) {
try {
topologyEventReceiver.terminate();
} catch (Exception e) {
@@ -263,7 +263,7 @@ public class LoadBalancerServiceComponent {
}
// Terminate application signup event receiver
- if(applicationSignUpEventReceiver != null) {
+ if (applicationSignUpEventReceiver != null) {
try {
applicationSignUpEventReceiver.terminate();
} catch (Exception e) {
@@ -272,7 +272,7 @@ public class LoadBalancerServiceComponent {
}
// Terminate domain mapping event receiver
- if(domainMappingEventReceiver != null) {
+ if (domainMappingEventReceiver != null) {
try {
domainMappingEventReceiver.terminate();
} catch (Exception e) {
@@ -281,7 +281,7 @@ public class LoadBalancerServiceComponent {
}
// Terminate statistics notifier
- if(statisticsNotifier != null) {
+ if (statisticsNotifier != null) {
try {
statisticsNotifier.terminate();
} catch (Exception e) {
@@ -290,7 +290,7 @@ public class LoadBalancerServiceComponent {
}
// Shutdown executor service
- if(executorService != null) {
+ if (executorService != null) {
try {
executorService.shutdownNow();
} catch (Exception e) {
@@ -390,7 +390,7 @@ public class LoadBalancerServiceComponent {
if (!alreadyCreated) {
try {
registerDeployer(synapseEnvironmentService
- .getConfigurationContext().getAxisConfiguration(),
+ .getConfigurationContext().getAxisConfiguration(),
synapseEnvironmentService.getSynapseEnvironment());
if (log.isDebugEnabled()) {
log.debug("Endpoint admin bundle is activated ");
http://git-wip-us.apache.org/repos/asf/stratos/blob/7d6d933b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/mediators/LocationReWriter.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/mediators/LocationReWriter.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/mediators/LocationReWriter.java
index 312ff46..24720d5 100644
--- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/mediators/LocationReWriter.java
+++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/mediators/LocationReWriter.java
@@ -1,20 +1,20 @@
/**
- * 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.
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
*/
package org.apache.stratos.load.balancer.mediators;
@@ -68,13 +68,13 @@ public class LocationReWriter extends AbstractMediator {
String clusterHostname = topologyProvider.getClusterHostname(inLocationUrl.getHost());
if (StringUtils.isEmpty(clusterHostname)) {
if (topologyProvider.getClusterByHostName(inLocationUrl.getHost()) == null) {
- if (log.isDebugEnabled()) {
+ if (log.isDebugEnabled()) {
log.debug(String.format("A cluster hostname not found for ip: [ip-address] %s",
inLocationUrl.getHost()));
}
- return;
+ return;
} else {
- clusterHostname = inLocationUrl.getHost();
+ clusterHostname = inLocationUrl.getHost();
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/7d6d933b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/mediators/ResponseInterceptor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/mediators/ResponseInterceptor.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/mediators/ResponseInterceptor.java
index 91cea19..8e9cec2 100644
--- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/mediators/ResponseInterceptor.java
+++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/mediators/ResponseInterceptor.java
@@ -1,20 +1,20 @@
/**
- * 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.
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
*/
package org.apache.stratos.load.balancer.mediators;
@@ -50,14 +50,14 @@ public class ResponseInterceptor extends AbstractMediator implements ManagedLife
if (StringUtils.isNotBlank(clusterId)) {
FutureTask<Object> task = new FutureTask<Object>(new InFlightRequestDecrementCallable(clusterId));
LoadBalancerStatisticsExecutor.getInstance().getService().submit(task);
- } else{
- if (log.isDebugEnabled()) {
+ } else {
+ if (log.isDebugEnabled()) {
log.debug("Could not decrement in-flight request count : cluster id not found in message context");
}
}
-
+
} catch (Exception e) {
- if(log.isErrorEnabled()) {
+ if (log.isErrorEnabled()) {
log.error("Could not decrement in-flight request count", e);
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/7d6d933b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/statistics/LoadBalancerStatisticsCollector.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/statistics/LoadBalancerStatisticsCollector.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/statistics/LoadBalancerStatisticsCollector.java
index 2e5723f..b195407 100644
--- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/statistics/LoadBalancerStatisticsCollector.java
+++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/statistics/LoadBalancerStatisticsCollector.java
@@ -70,7 +70,7 @@ public class LoadBalancerStatisticsCollector implements LoadBalancerStatisticsRe
synchronized (LoadBalancerStatisticsCollector.class) {
if (clusterIdRequestCountMap.containsKey(clusterId)) {
Integer count = clusterIdRequestCountMap.get(clusterId);
- if(count != null) {
+ if (count != null) {
return count;
}
}
@@ -81,7 +81,7 @@ public class LoadBalancerStatisticsCollector implements LoadBalancerStatisticsRe
/**
* Returns the number of requests served since the last time this function was called.
*/
- public int getServedRequestCount(String clusterId){
+ public int getServedRequestCount(String clusterId) {
synchronized (LoadBalancerStatisticsCollector.class) {
if (clusterIdServedRequestCountMap.containsKey(clusterId)) {
Integer servedCount = clusterIdServedRequestCountMap.get(clusterId);
http://git-wip-us.apache.org/repos/asf/stratos/blob/7d6d933b/components/org.apache.stratos.load.balancer/src/test/java/org/apache/stratos/load/balancer/test/LoadBalancerConfigurationTest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/test/java/org/apache/stratos/load/balancer/test/LoadBalancerConfigurationTest.java b/components/org.apache.stratos.load.balancer/src/test/java/org/apache/stratos/load/balancer/test/LoadBalancerConfigurationTest.java
index d8ee1fd..7e867dd 100755
--- a/components/org.apache.stratos.load.balancer/src/test/java/org/apache/stratos/load/balancer/test/LoadBalancerConfigurationTest.java
+++ b/components/org.apache.stratos.load.balancer/src/test/java/org/apache/stratos/load/balancer/test/LoadBalancerConfigurationTest.java
@@ -1,20 +1,20 @@
/**
- * 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.
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
*/
package org.apache.stratos.load.balancer.test;
http://git-wip-us.apache.org/repos/asf/stratos/blob/7d6d933b/components/org.apache.stratos.load.balancer/src/test/java/org/apache/stratos/load/balancer/test/LoadBalancerStatisticsCollectorTest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.load.balancer/src/test/java/org/apache/stratos/load/balancer/test/LoadBalancerStatisticsCollectorTest.java b/components/org.apache.stratos.load.balancer/src/test/java/org/apache/stratos/load/balancer/test/LoadBalancerStatisticsCollectorTest.java
index 26b5f34..594b9a4 100644
--- a/components/org.apache.stratos.load.balancer/src/test/java/org/apache/stratos/load/balancer/test/LoadBalancerStatisticsCollectorTest.java
+++ b/components/org.apache.stratos.load.balancer/src/test/java/org/apache/stratos/load/balancer/test/LoadBalancerStatisticsCollectorTest.java
@@ -1,20 +1,20 @@
/**
- * 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.
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
*/
package org.apache.stratos.load.balancer.test;
@@ -75,7 +75,7 @@ public class LoadBalancerStatisticsCollectorTest {
private void executeTask(FutureTask<Object> task) {
Future future = LoadBalancerStatisticsExecutor.getInstance().getService().submit(task);
- while(!future.isDone()) {
+ while (!future.isDone()) {
// Wait until task get executed
try {
Thread.sleep(100);