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