mirror of https://github.com/apache/jclouds.git
updated loadbalancer to backoff on unknownhost exception; made template match ubuntu 10.04 on rackspace, aws, and rimu
This commit is contained in:
parent
d45dfff1ec
commit
237afa4ddc
|
@ -43,8 +43,8 @@ public class EC2PropertiesBuilder extends PropertiesBuilder {
|
||||||
properties.setProperty(PROPERTY_ELB_ENDPOINT,
|
properties.setProperty(PROPERTY_ELB_ENDPOINT,
|
||||||
"https://elasticloadbalancing.us-east-1.amazonaws.com");
|
"https://elasticloadbalancing.us-east-1.amazonaws.com");
|
||||||
properties.setProperty(PROPERTY_AWS_EXPIREINTERVAL, "60");
|
properties.setProperty(PROPERTY_AWS_EXPIREINTERVAL, "60");
|
||||||
// alestic and canonical
|
// alestic, canonical, and rightscale
|
||||||
properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "063491364108,099720109477");
|
properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "063491364108,099720109477,411009282317");
|
||||||
// auth fail sometimes happens in EC2, as the rc.local script that injects the
|
// auth fail sometimes happens in EC2, as the rc.local script that injects the
|
||||||
// authorized key executes after ssh has started
|
// authorized key executes after ssh has started
|
||||||
properties.setProperty("jclouds.ssh.max_retries", "6");
|
properties.setProperty("jclouds.ssh.max_retries", "6");
|
||||||
|
|
|
@ -160,7 +160,7 @@ public class EC2ComputeServiceContextModule extends EC2ContextModule {
|
||||||
@Provides
|
@Provides
|
||||||
@Named("DEFAULT")
|
@Named("DEFAULT")
|
||||||
protected TemplateBuilder provideTemplate(TemplateBuilder template) {
|
protected TemplateBuilder provideTemplate(TemplateBuilder template) {
|
||||||
return template.architecture(Architecture.X86_32).osFamily(UBUNTU);
|
return template.architecture(Architecture.X86_32).osFamily(UBUNTU).imageNameMatches(".*10\\.?04.*");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO make this more efficient for listNodes(); currently RunningInstanceToNodeMetadata is slow
|
// TODO make this more efficient for listNodes(); currently RunningInstanceToNodeMetadata is slow
|
||||||
|
|
|
@ -1,3 +1,21 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||||
|
*
|
||||||
|
* ====================================================================
|
||||||
|
* Licensed 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.
|
||||||
|
* ====================================================================
|
||||||
|
*/
|
||||||
package org.jclouds.aws.ec2.xml;
|
package org.jclouds.aws.ec2.xml;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -19,6 +37,10 @@ import org.xml.sax.Attributes;
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Lili Nadar
|
||||||
|
*/
|
||||||
public class DescribeLoadBalancersResponseHandler extends
|
public class DescribeLoadBalancersResponseHandler extends
|
||||||
ParseSax.HandlerWithResult<Set<ElasticLoadBalancer>> {
|
ParseSax.HandlerWithResult<Set<ElasticLoadBalancer>> {
|
||||||
@Inject
|
@Inject
|
||||||
|
@ -43,13 +65,13 @@ public class DescribeLoadBalancersResponseHandler extends
|
||||||
private boolean inAppCookieStickinessPolicies = false;
|
private boolean inAppCookieStickinessPolicies = false;
|
||||||
private boolean inLBCookieStickinessPolicies = false;
|
private boolean inLBCookieStickinessPolicies = false;
|
||||||
private boolean inAvailabilityZones = false;
|
private boolean inAvailabilityZones = false;
|
||||||
//TODO unused?
|
// TODO unused?
|
||||||
private boolean inLoadBalancerDescriptions = false;
|
private boolean inLoadBalancerDescriptions = false;
|
||||||
|
|
||||||
private ElasticLoadBalancer elb;
|
private ElasticLoadBalancer elb;
|
||||||
//TODO unused?
|
// TODO unused?
|
||||||
private AppCookieStickinessPolicy appCookieStickinessPolicy;
|
private AppCookieStickinessPolicy appCookieStickinessPolicy;
|
||||||
//TODO unused?
|
// TODO unused?
|
||||||
private LBCookieStickinessPolicy lBCookieStickinessPolicy;
|
private LBCookieStickinessPolicy lBCookieStickinessPolicy;
|
||||||
|
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attributes) {
|
public void startElement(String uri, String localName, String qName, Attributes attributes) {
|
||||||
|
@ -77,8 +99,6 @@ public class DescribeLoadBalancersResponseHandler extends
|
||||||
}
|
}
|
||||||
|
|
||||||
public void endElement(String uri, String localName, String qName) {
|
public void endElement(String uri, String localName, String qName) {
|
||||||
logger.info(qName);
|
|
||||||
|
|
||||||
// if end tag is one of below then set inXYZ to false
|
// if end tag is one of below then set inXYZ to false
|
||||||
if (qName.equals("ListenerDescriptions")) {
|
if (qName.equals("ListenerDescriptions")) {
|
||||||
inListenerDescriptions = false;
|
inListenerDescriptions = false;
|
||||||
|
|
|
@ -32,7 +32,6 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
@ -44,14 +43,16 @@ import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
import org.jclouds.compute.strategy.DestroyLoadBalancerStrategy;
|
import org.jclouds.compute.strategy.DestroyLoadBalancerStrategy;
|
||||||
import org.jclouds.compute.strategy.LoadBalanceNodesStrategy;
|
import org.jclouds.compute.strategy.LoadBalanceNodesStrategy;
|
||||||
import org.jclouds.domain.Location;
|
import org.jclouds.domain.Location;
|
||||||
|
import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.base.Throwables;
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -61,6 +62,11 @@ import com.google.common.collect.Sets;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BaseLoadBalancerService implements LoadBalancerService {
|
public class BaseLoadBalancerService implements LoadBalancerService {
|
||||||
|
|
||||||
|
@Inject(optional = true)
|
||||||
|
@Named("jclouds.lb.max_retries")
|
||||||
|
@VisibleForTesting
|
||||||
|
int dnsRetries = 5;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
@ -68,16 +74,19 @@ public class BaseLoadBalancerService implements LoadBalancerService {
|
||||||
protected final ComputeServiceContext context;
|
protected final ComputeServiceContext context;
|
||||||
protected final LoadBalanceNodesStrategy loadBalancerStrategy;
|
protected final LoadBalanceNodesStrategy loadBalancerStrategy;
|
||||||
protected final DestroyLoadBalancerStrategy destroyLoadBalancerStrategy;
|
protected final DestroyLoadBalancerStrategy destroyLoadBalancerStrategy;
|
||||||
|
protected final BackoffLimitedRetryHandler backoffLimitedRetryHandler;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected BaseLoadBalancerService(ComputeServiceContext context,
|
protected BaseLoadBalancerService(ComputeServiceContext context,
|
||||||
LoadBalanceNodesStrategy loadBalancerStrategy,
|
LoadBalanceNodesStrategy loadBalancerStrategy,
|
||||||
DestroyLoadBalancerStrategy destroyLoadBalancerStrategy) {
|
DestroyLoadBalancerStrategy destroyLoadBalancerStrategy,
|
||||||
|
BackoffLimitedRetryHandler backoffLimitedRetryHandler) {
|
||||||
this.context = checkNotNull(context, "context");
|
this.context = checkNotNull(context, "context");
|
||||||
this.loadBalancerStrategy = checkNotNull(loadBalancerStrategy, "loadBalancerStrategy");
|
this.loadBalancerStrategy = checkNotNull(loadBalancerStrategy, "loadBalancerStrategy");
|
||||||
this.destroyLoadBalancerStrategy = checkNotNull(destroyLoadBalancerStrategy,
|
this.destroyLoadBalancerStrategy = checkNotNull(destroyLoadBalancerStrategy,
|
||||||
"destroyLoadBalancerStrategy");
|
"destroyLoadBalancerStrategy");
|
||||||
|
this.backoffLimitedRetryHandler = checkNotNull(backoffLimitedRetryHandler,
|
||||||
|
"backoffLimitedRetryHandler");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,15 +120,13 @@ public class BaseLoadBalancerService implements LoadBalancerService {
|
||||||
logger.debug(">> creating load balancer (%s)", loadBalancerName);
|
logger.debug(">> creating load balancer (%s)", loadBalancerName);
|
||||||
String dnsName = loadBalancerStrategy.execute(location, loadBalancerName, protocol,
|
String dnsName = loadBalancerStrategy.execute(location, loadBalancerName, protocol,
|
||||||
loadBalancerPort, instancePort, locationMap.get(location));
|
loadBalancerPort, instancePort, locationMap.get(location));
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < dnsRetries; i++) {
|
||||||
try {
|
try {
|
||||||
dnsNames.add(InetAddress.getByName(dnsName));
|
dnsNames.add(InetAddress.getByName(dnsName));
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException from) {
|
||||||
try {
|
backoffLimitedRetryHandler.imposeBackoffExponentialDelay(200L, 2, i + 1, dnsRetries,
|
||||||
Thread.sleep(1000);
|
String.format("%s/%s@%s:%d:%d connection error: %s", location,
|
||||||
} catch (InterruptedException e1) {
|
loadBalancerName, dnsName, loadBalancerPort, instancePort));
|
||||||
Throwables.propagate(e1);
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,6 +160,7 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private final Predicate<Image> osDescriptionPredicate = new Predicate<Image>() {
|
private final Predicate<Image> osDescriptionPredicate = new Predicate<Image>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Image input) {
|
public boolean apply(Image input) {
|
||||||
|
|
|
@ -126,7 +126,7 @@ public class CloudServersComputeServiceContextModule extends CloudServersContext
|
||||||
@Provides
|
@Provides
|
||||||
@Named("DEFAULT")
|
@Named("DEFAULT")
|
||||||
protected TemplateBuilder provideTemplate(TemplateBuilder template) {
|
protected TemplateBuilder provideTemplate(TemplateBuilder template) {
|
||||||
return template.osFamily(UBUNTU);
|
return template.osFamily(UBUNTU).imageNameMatches(".*10\\.?04.*");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
|
|
@ -128,7 +128,8 @@ public class RimuHostingComputeServiceContextModule extends RimuHostingContextMo
|
||||||
@Provides
|
@Provides
|
||||||
@Named("DEFAULT")
|
@Named("DEFAULT")
|
||||||
protected TemplateBuilder provideTemplate(TemplateBuilder template) {
|
protected TemplateBuilder provideTemplate(TemplateBuilder template) {
|
||||||
return template.sizeId("MIRO1B").osFamily(UBUNTU).architecture(Architecture.X86_32);
|
return template.sizeId("MIRO1B").osFamily(UBUNTU).architecture(Architecture.X86_32)
|
||||||
|
.imageNameMatches(".*10\\.?04.*");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
|
Loading…
Reference in New Issue