当前位置: 首页>>代码示例>>Java>>正文


Java LoadBalancerDescription类代码示例

本文整理汇总了Java中com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription的典型用法代码示例。如果您正苦于以下问题:Java LoadBalancerDescription类的具体用法?Java LoadBalancerDescription怎么用?Java LoadBalancerDescription使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LoadBalancerDescription类属于com.amazonaws.services.elasticloadbalancing.model包,在下文中一共展示了LoadBalancerDescription类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGetElbDnsName

import com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription; //导入依赖的package包/类
@Test
public void testGetElbDnsName() {
    final LoadBalancerDescription description = new LoadBalancerDescription();
    description.setDNSName("testDnsName");

    final List<LoadBalancerDescription> descriptions = new ArrayList<>();
    descriptions.add(description);

    final DescribeLoadBalancersResult result = mock(DescribeLoadBalancersResult.class);
    when(result.getLoadBalancerDescriptions()).thenReturn(descriptions);

    when(amazonElbClient.describeLoadBalancers(any(DescribeLoadBalancersRequest.class))).thenReturn(result);

    final String elbName = "testElbName";
    assertThat(awsHelperService.getElbDnsName(elbName), equalTo(description.getDNSName()));

    final ArgumentCaptor<DescribeLoadBalancersRequest> argumentCaptor = ArgumentCaptor.forClass(DescribeLoadBalancersRequest.class);
    verify(amazonElbClient).describeLoadBalancers(argumentCaptor.capture());
    assertThat(argumentCaptor.getValue().getLoadBalancerNames().get(0), equalTo(elbName));
}
 
开发者ID:shinesolutions,项目名称:aem-orchestrator,代码行数:21,代码来源:AwsHelperServiceTest.java

示例2: checkInstanceRemoval

import com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription; //导入依赖的package包/类
/**
 * Sanity checks the LB description, and checks for done-ness.
 */
private void checkInstanceRemoval(LoadBalancerDescription loadBalancerDescription)
{
  if (!StringUtils.equals(elbName, loadBalancerDescription.getLoadBalancerName()))
  {
    throw new IllegalStateException(logContext + "We requested description of ELB '" + elbName
        + "' but response is for '" + loadBalancerDescription.getLoadBalancerName() + "'");
  }
  if (CollectionUtils.isEmpty(loadBalancerDescription.getInstances()))
  {
    throw new IllegalStateException("ELB '" + elbName + "' has zero instances");
  }
  if (instanceIsGoneFromList(loadBalancerDescription.getInstances()))
  {
    LOGGER.info("ELB '" + elbName + "' list of instances shows '" + ec2InstanceId + "' is gone");
    done = true;
    result = true;
  }
}
 
开发者ID:Nike-Inc,项目名称:bluegreen-manager,代码行数:22,代码来源:ElbInstanceGoneProgressChecker.java

示例3: makeLoadBalancerDescription

import com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription; //导入依赖的package包/类
/**
 * Test helper - makes a fake LB description.
 */
private LoadBalancerDescription makeLoadBalancerDescription(String elbName, String... instanceIds)
{
  LoadBalancerDescription loadBalancerDescription = new LoadBalancerDescription();
  loadBalancerDescription.setLoadBalancerName(elbName);
  List<Instance> instances = new ArrayList<Instance>();
  if (instanceIds != null)
  {
    for (String instanceId : instanceIds)
    {
      Instance instance = new Instance();
      instance.setInstanceId(instanceId);
      instances.add(instance);
    }
  }
  loadBalancerDescription.setInstances(instances);
  return loadBalancerDescription;
}
 
开发者ID:Nike-Inc,项目名称:bluegreen-manager,代码行数:21,代码来源:ElbInstanceGoneProgressCheckerTest.java

示例4: makeDescribeLoadBalancersResult

import com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription; //导入依赖的package包/类
/**
 * Test helper - makes describe result with one or more named LBs.
 */
private DescribeLoadBalancersResult makeDescribeLoadBalancersResult(String... loadBalancerNames)
{
  DescribeLoadBalancersResult result = new DescribeLoadBalancersResult();
  if (ArrayUtils.isNotEmpty(loadBalancerNames))
  {
    List<LoadBalancerDescription> list = new ArrayList<LoadBalancerDescription>();
    for (String loadBalancerName : loadBalancerNames)
    {
      LoadBalancerDescription loadBalancerDescription = new LoadBalancerDescription();
      loadBalancerDescription.setLoadBalancerName(loadBalancerName);
      list.add(loadBalancerDescription);
    }
    result.setLoadBalancerDescriptions(list);
  }
  return result;
}
 
开发者ID:Nike-Inc,项目名称:bluegreen-manager,代码行数:20,代码来源:ElbClientTest.java

示例5: getAwsLoadBalancer

import com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription; //导入依赖的package包/类
private LoadBalancerDescription getAwsLoadBalancer(String name) {
    DescribeLoadBalancersRequest describeRequest = new DescribeLoadBalancersRequest()
            .withLoadBalancerNames(name);

    DescribeLoadBalancersResult describeResult = null;

    try {
        describeResult = this.client.describeLoadBalancers(describeRequest);
    } catch (Exception e) {
        this.host.log("Exception describing load balancers with name '%s': %s", name,
                e.toString());
    }

    Collection<LoadBalancerDescription> lbs =
            describeResult != null ? describeResult.getLoadBalancerDescriptions() : null;
    if (lbs == null || lbs.isEmpty()) {
        return null;
    }
    if (lbs.size() > 1) {
        throw new IllegalStateException(
                "More than one load balancers found with name '" + name + "'.");
    }
    return lbs.iterator().next();
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:25,代码来源:AWSLoadBalancerServiceTest.java

示例6: getLoadBalancerDNS

import com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription; //导入依赖的package包/类
public static String getLoadBalancerDNS(String name) {
	if (name == null || name.trim().length() == 0)
		throw new RuntimeException(
				"The name of the load balancer cannot be empty!");

	connect();

	ArrayList<String> names = new ArrayList<String>();
	names.add(name);

	DescribeLoadBalancersRequest req = new DescribeLoadBalancersRequest(
			names);
	DescribeLoadBalancersResult res = client.describeLoadBalancers(req);
	List<LoadBalancerDescription> descs = res.getLoadBalancerDescriptions();
	if (descs.size() == 0 || descs.get(0) == null)
		return null;

	return descs.get(0).getDNSName();
}
 
开发者ID:rickdesantis,项目名称:cloud-runner,代码行数:20,代码来源:ElasticLoadBalancing.java

示例7: describeLoadBalancer

import com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription; //导入依赖的package包/类
public LoadBalancerDescription describeLoadBalancer(AwsProcessClient awsProcessClient, String loadBalancerName) {
    // 単一ロードバランサの参照
    DescribeLoadBalancersRequest request = new DescribeLoadBalancersRequest();
    request.withLoadBalancerNames(loadBalancerName);
    DescribeLoadBalancersResult result = awsProcessClient.getElbClient().describeLoadBalancers(request);
    List<LoadBalancerDescription> descriptions = result.getLoadBalancerDescriptions();

    // API実行結果チェック
    if (descriptions.size() == 0) {
        // アドレスが存在しない場合
        throw new AutoException("EPROCESS-000131", loadBalancerName);

    } else if (descriptions.size() > 1) {
        // アドレスを複数参照できた場合
        AutoException exception = new AutoException("EPROCESS-000132", loadBalancerName);
        exception.addDetailInfo("result=" + descriptions);
        throw exception;
    }

    return descriptions.get(0);
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:22,代码来源:AwsCommonProcess.java

示例8: accept

import com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription; //导入依赖的package包/类
@Override
public boolean accept(LoadBalancerDescription loadBalancer) {

    String[] pieces = loadBalancer.getLoadBalancerName().split("-");

    if (pieces.length < 2) {
        return false;
    }
    // match ENV-Zoo* (Cloud Formation naming scheme)
    if (pieces[0].equalsIgnoreCase(environment) && pieces[1].startsWith("Zoo")) {
        return true;
    }
    // match exhibitor-ENV-internal (Original naming scheme)
    if (pieces.length == 3 && pieces[0].equalsIgnoreCase("exhibitor") && pieces[1].equalsIgnoreCase(environment) && pieces[2].equalsIgnoreCase("internal")) {
        return true;
    }

    return false;

}
 
开发者ID:Kixeye,项目名称:chassis,代码行数:21,代码来源:ZookeeperElbFilter.java

示例9: initExhibitor

import com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription; //导入依赖的package包/类
private void initExhibitor() {
    LOGGER.info("Initializing exhibitor info...");

    List<LoadBalancerDescription> loadBalancers = AwsUtils.findLoadBalancers(amazonElasticLoadBalancing, new ZookeeperElbFilter(environment));

    if(loadBalancers.size() == 0) {
        LOGGER.info("No Zookeeper ELBs for environment " + environment);
        return;
    } else if(loadBalancers.size() != 1){
        throw new BootstrapException("Found multiple Zookeeper ELBs for environment " + environment);
    }

    LoadBalancerDescription loadBalancer = loadBalancers.get(0);

    ListenerDescription exhibitorListenerDescription = getExhibitorListenerDescription(loadBalancer);

    this.exhibitorHost = loadBalancer.getDNSName();
    this.exhibitorPort = exhibitorListenerDescription.getListener().getLoadBalancerPort();

    LOGGER.info("Initialized exhibitor info with: exhibitorHost: {}, exhibitorPort: {}", exhibitorHost, exhibitorPort);
}
 
开发者ID:Kixeye,项目名称:chassis,代码行数:22,代码来源:ServerInstanceContext.java

示例10: checkForMatchingTag

import com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription; //导入依赖的package包/类
private LoadBalancerDescription checkForMatchingTag(
		List<LoadBalancerDescription> descriptions, String vpcID, String type) throws TooManyELBException {
	List<LoadBalancerDescription> found = new LinkedList<LoadBalancerDescription>();
	
	for(LoadBalancerDescription desc : descriptions) {
		String loadBalancerName = desc.getLoadBalancerName();
		logger.info(String.format("Checking LB for tag %s:%s, ELB name is %s", AwsFacade.TYPE_TAG, type, loadBalancerName));
		List<Tag> tags = elbClient.getTagsFor(loadBalancerName);
		if (containsCorrectTag(tags, type)) {
			logger.info("LB matched " + loadBalancerName);
			found.add(desc);
		}
	}
	if (found.size()==1) {
		return found.get(0);
	}

	throw new TooManyELBException(found.size(), String.format("Found too many elbs for vpc (%s) that matched tag %s",
			vpcID,
			AwsFacade.TYPE_TAG));
}
 
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:22,代码来源:ELBRepository.java

示例11: addInstancesThatMatchBuildAndType

import com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription; //导入依赖的package包/类
private List<Instance> addInstancesThatMatchBuildAndType(ProjectAndEnv projAndEnv, String typeTag) throws CfnAssistException {
	if (!projAndEnv.hasBuildNumber()) {
		throw new MustHaveBuildNumber();
	}
	LoadBalancerDescription elb = findELBFor(projAndEnv, typeTag);	
	List<Instance> currentInstances = elb.getInstances();
	String lbName = elb.getLoadBalancerName();
	
	SearchCriteria criteria = new SearchCriteria(projAndEnv);
	List<Instance> allMatchingInstances = cfnRepository.getAllInstancesMatchingType(criteria, typeTag);
	List<Instance> instancesToAdd = filterBy(currentInstances, allMatchingInstances);
	if (allMatchingInstances.size()==0) {
		logger.warn(String.format("No instances matched %s and type tag %s (%s)", projAndEnv, typeTag, AwsFacade.TYPE_TAG));
	} else {	
		logger.info(String.format("Regsister matching %s instances with the LB %s ", instancesToAdd.size(),lbName));
		elbClient.registerInstances(instancesToAdd, lbName);	
	}
	return instancesToAdd;
}
 
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:20,代码来源:ELBRepository.java

示例12: removeInstancesNotMatching

import com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription; //导入依赖的package包/类
private List<Instance> removeInstancesNotMatching(ProjectAndEnv projAndEnv, List<Instance> matchingInstances, String typeTag) throws MustHaveBuildNumber, TooManyELBException {	
	LoadBalancerDescription elb = findELBFor(projAndEnv, typeTag);
	logger.info("Checking if instances should be removed from ELB " + elb.getLoadBalancerName());
	List<Instance> currentInstances = elb.getInstances();	
			
	List<Instance> toRemove = new LinkedList<Instance>();
	for(Instance current : currentInstances) {
		String instanceId = current.getInstanceId();
		if (matchingInstances.contains(current)) {
			logger.info("Instance matched project/env/build/type, will not be removed " + instanceId);
		} else {
			logger.info("Instance did not match, will be removed from ELB " +instanceId);
			toRemove.add(new Instance(instanceId));
		}
	}
	
	if (toRemove.isEmpty()) {
		logger.info("No instances to remove from ELB " + elb.getLoadBalancerName());
		return new LinkedList<Instance>();
	}
	return removeInstances(elb,toRemove);	
}
 
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:23,代码来源:ELBRepository.java

示例13: ShouldUseTagIfMoreThanOneELB

import com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription; //导入依赖的package包/类
@Test
public void ShouldUseTagIfMoreThanOneELB() throws TooManyELBException {
	String typeTag = "expectedType";
	
	List<Tag> lb1Tags = new LinkedList<>();
	lb1Tags.add(new Tag().withKey(AwsFacade.TYPE_TAG).withValue("someNonMatchingTag"));

	List<Tag> lb2Tags = new LinkedList<>();
	lb2Tags.add(new Tag().withKey(AwsFacade.TYPE_TAG).withValue(typeTag));
	
	List<LoadBalancerDescription> lbs = new LinkedList<>();
	lbs.add(new LoadBalancerDescription().withLoadBalancerName("lb1Name").withVPCId("vpcId"));
	lbs.add(new LoadBalancerDescription().withLoadBalancerName("lb2Name").withVPCId("vpcId"));
	
	Vpc vpc = new Vpc().withVpcId("vpcId");
	EasyMock.expect(vpcRepository.getCopyOfVpc(projAndEnv)).andReturn(vpc);
	EasyMock.expect(elbClient.describeLoadBalancers()).andReturn(lbs);
	EasyMock.expect(elbClient.getTagsFor("lb1Name")).andReturn(lb1Tags);
	EasyMock.expect(elbClient.getTagsFor("lb2Name")).andReturn(lb2Tags);
	
	replayAll();
	LoadBalancerDescription result = elbRepository.findELBFor(projAndEnv, typeTag);
	verifyAll();
	
	assertEquals("lb2Name", result.getLoadBalancerName());
}
 
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:27,代码来源:TestELBRepository.java

示例14: ShouldThrowIfMoreThanOneELBAndNoMatchingTags

import com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription; //导入依赖的package包/类
@Test
public void ShouldThrowIfMoreThanOneELBAndNoMatchingTags() {
	List<Tag> tags = new LinkedList<>();
	tags.add(new Tag().withKey("someOtherTag").withValue("someOtherValue"));
	
	List<LoadBalancerDescription> lbs = new LinkedList<>();
	lbs.add(new LoadBalancerDescription().withLoadBalancerName("lb1Name").withVPCId("vpcId"));
	lbs.add(new LoadBalancerDescription().withLoadBalancerName("lb2Name").withVPCId("vpcId"));
	
	Vpc vpc = new Vpc().withVpcId("vpcId");
	EasyMock.expect(vpcRepository.getCopyOfVpc(projAndEnv)).andReturn(vpc);
	EasyMock.expect(elbClient.describeLoadBalancers()).andReturn(lbs);
	EasyMock.expect(elbClient.getTagsFor("lb1Name")).andReturn(new LinkedList<>());
	EasyMock.expect(elbClient.getTagsFor("lb2Name")).andReturn(tags);
	
	replayAll();
	try {
		elbRepository.findELBFor(projAndEnv,"notMatchingAnLB");
		fail("should have thrown");
	}
	catch(TooManyELBException expectedException) {
		// no op
	}
	verifyAll();
}
 
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:26,代码来源:TestELBRepository.java

示例15: shouldGetInstancesForTheLB

import com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription; //导入依赖的package包/类
@Test
public void shouldGetInstancesForTheLB() throws TooManyELBException {
	String vpcId = "myVPC";
	Instance insA = new Instance().withInstanceId("instanceA"); // associated
	
	List<LoadBalancerDescription> theLB = new LinkedList<>();
	theLB.add(new LoadBalancerDescription().withVPCId(vpcId).
			withInstances(insA).
			withLoadBalancerName("lbName").withDNSName("dnsName"));

	EasyMock.expect(vpcRepository.getCopyOfVpc(projAndEnv)).andStubReturn(new Vpc().withVpcId(vpcId));
	EasyMock.expect(elbClient.describeLoadBalancers()).andReturn(theLB);
	
	replayAll();
	List<Instance> result = elbRepository.findInstancesAssociatedWithLB(projAndEnv,"typeNotUsedWhenOneMatchingLB");
	verifyAll();
	
	assertEquals(1,  result.size());
	assertEquals("instanceA", result.get(0).getInstanceId());
}
 
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:21,代码来源:TestELBRepository.java


注:本文中的com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。