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


Java DescribeLoadBalancersRequest类代码示例

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


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

示例1: testGetElbDnsName

import com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest; //导入依赖的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: getAwsLoadBalancer

import com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest; //导入依赖的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

示例3: getLoadBalancerDNS

import com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest; //导入依赖的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

示例4: describeLoadBalancer

import com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest; //导入依赖的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

示例5: getElb

import com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest; //导入依赖的package包/类
@GET
@NoAuth
@Path("/{elbName}")
public LoadBalancerDescription getElb(@PathParam("elbName") String elbName) {
  if (config.isPresent()) {
    try {
      DescribeLoadBalancersRequest request = new DescribeLoadBalancersRequest(Arrays.asList(elbName));
      DescribeLoadBalancersResult result = elbClient.describeLoadBalancers(request);
      for (LoadBalancerDescription elb : result.getLoadBalancerDescriptions()) {
        if (elb.getLoadBalancerName().equals(elbName)) {
          return elb;
        }
      }
    } catch (AmazonClientException e) {
      throw new BaragonWebException(String.format("AWS Client Error: %s", e));
    }
    throw new BaragonNotFoundException(String.format("ELB with name %s not found", elbName));
  } else {
    throw new BaragonWebException("ElbSync and related actions are not currently enabled");
  }
}
 
开发者ID:HubSpot,项目名称:Baragon,代码行数:22,代码来源:ElbResource.java

示例6: describeLoadBalancer

import com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest; //导入依赖的package包/类
/**
 * Returns a description of the named ELB.
 */
public LoadBalancerDescription describeLoadBalancer(String elbName)
{
  LOGGER.debug("describeLoadBalancers(elbName: " + elbName + ")");
  if (StringUtils.isBlank(elbName))
  {
    throw new IllegalArgumentException("Blank elbName");
  }
  StopWatch stopWatch = new StopWatch();
  try
  {
    stopWatch.start();
    DescribeLoadBalancersRequest request = new DescribeLoadBalancersRequest();
    request.setLoadBalancerNames(Arrays.asList(elbName));
    DescribeLoadBalancersResult result = awsElbClient.describeLoadBalancers(request);
    if (result == null || CollectionUtils.isEmpty(result.getLoadBalancerDescriptions()))
    {
      throw new RuntimeException("ELB '" + elbName + "' was not found");
    }
    else if (result.getLoadBalancerDescriptions().size() > 1)
    {
      LOGGER.warn("Expected 1 ELB description for elb name '" + elbName + "', found "
          + result.getLoadBalancerDescriptions().size());
    }
    return result.getLoadBalancerDescriptions().get(0);
  }
  finally
  {
    stopWatch.stop();
    LOGGER.debug("describeLoadBalancers time elapsed " + stopWatch);
  }
}
 
开发者ID:Nike-Inc,项目名称:bluegreen-manager,代码行数:35,代码来源:ElbClient.java

示例7: getAWSLoadBalancer

import com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest; //导入依赖的package包/类
private DeferredResult<AWSLoadBalancerContext> getAWSLoadBalancer(
        AWSLoadBalancerContext context) {
    DescribeLoadBalancersRequest describeRequest = new DescribeLoadBalancersRequest()
            .withLoadBalancerNames(context.loadBalancerStateExpanded.name);

    String message =
            "Describing AWS load balancer [" + context.loadBalancerStateExpanded.name + "].";
    AWSDeferredResultAsyncHandler<DescribeLoadBalancersRequest, DescribeLoadBalancersResult> handler =
            new AWSDeferredResultAsyncHandler<>(this, message);

    context.client.describeLoadBalancersAsync(describeRequest, handler);

    return handler.toDeferredResult().thenCompose(result -> {

        List<com.amazonaws.services.elasticloadbalancing.model.LoadBalancerDescription> lbs = result
                .getLoadBalancerDescriptions();

        if (lbs != null && !lbs.isEmpty() && lbs.size() == 1) {
            context.registeredInstances = lbs.iterator().next().getInstances();
            return DeferredResult.completed(context);
        }

        return DeferredResult.failed(new IllegalStateException(
                "Unable to describe load balancer with name '"
                        + context.loadBalancerStateExpanded.name + "' for update"));
    });
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:28,代码来源:AWSLoadBalancerService.java

示例8: getExternalResources

import com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest; //导入依赖的package包/类
@Override
protected DeferredResult<RemoteResourcesPage> getExternalResources(String nextPageLink) {
    DescribeLoadBalancersRequest describeRequest = new DescribeLoadBalancersRequest()
            .withPageSize(getQueryPageSize());

    if (nextPageLink != null) {
        describeRequest.setMarker(nextPageLink);
    }

    String msg =
            "Getting AWS Load Balancers [" + this.request.original.resourceReference + "]";

    AWSDeferredResultAsyncHandler<DescribeLoadBalancersRequest, DescribeLoadBalancersResult> asyncHandler =
            new AWSDeferredResultAsyncHandler<>(this.service, msg);

    this.amazonLoadBalancerClient.describeLoadBalancersAsync(describeRequest, asyncHandler);

    return asyncHandler.toDeferredResult().thenApply(describeLoadBalancersResult -> {
        RemoteResourcesPage page = new RemoteResourcesPage();
        page.nextPageLink = describeLoadBalancersResult.getNextMarker();

        describeLoadBalancersResult.getLoadBalancerDescriptions().forEach(
                lbDescription -> page.resourcesPage
                        .put(lbDescription.getLoadBalancerName(), lbDescription));

        return page;
    });
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:29,代码来源:AWSLoadBalancerEnumerationAdapterService.java

示例9: describeMatchingElbListeners

import com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest; //导入依赖的package包/类
private List<ListenerDescription> describeMatchingElbListeners(String loadbalancerName, List<Integer> ports) {
    DescribeLoadBalancersResult loadbalancer = awsElbClient.describeLoadBalancers(new DescribeLoadBalancersRequest().withLoadBalancerNames(loadbalancerName));
    LoadBalancerDescription description = loadbalancer.getLoadBalancerDescriptions().get(0);
    return description.getListenerDescriptions().stream()
            .filter(d -> ports.contains(d.getListener().getLoadBalancerPort()))
            .filter(d -> d.getListener().getProtocol().startsWith("HTTP"))
            .collect(Collectors.toList());
}
 
开发者ID:msoute,项目名称:vertx-deploy-tools,代码行数:9,代码来源:AwsAutoScalingDeployUtils.java

示例10: describeLoadBalancers

import com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest; //导入依赖的package包/类
@Override
public List<AbstractResource<?>> describeLoadBalancers(Account account, Region region, DateTime dt) {
    AmazonElasticLoadBalancing elb = findClient(account, region);

    DescribeLoadBalancersRequest req = new DescribeLoadBalancersRequest();

    log.debug("start describing elb for account:{} in region:{} via api", account.getId() + "=>" + account.getName(), region);
    DescribeLoadBalancersResult res = elb.describeLoadBalancers(req);
    return converter.toLoadBalancers(res.getLoadBalancerDescriptions(), account.getId(), region, dt);
}
 
开发者ID:veyronfei,项目名称:clouck,代码行数:11,代码来源:ElbWrapperImpl.java

示例11: describeLoadBalancers

import com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest; //导入依赖的package包/类
public List<LoadBalancerDescription> describeLoadBalancers() {
	DescribeLoadBalancersRequest request = new DescribeLoadBalancersRequest();
	DescribeLoadBalancersResult result = elbClient.describeLoadBalancers(request);
	List<LoadBalancerDescription> descriptions = result.getLoadBalancerDescriptions();
	logger.info(String.format("Found %s load balancers %s", descriptions.size(), descriptions));
	return descriptions;
}
 
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:8,代码来源:LoadBalancerClient.java

示例12: getElb

import com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest; //导入依赖的package包/类
private Optional<LoadBalancerDescription> getElb(String elbName) {
  DescribeLoadBalancersRequest request = new DescribeLoadBalancersRequest(Arrays.asList(elbName));
  DescribeLoadBalancersResult result = elbClient.describeLoadBalancers(request);
  if (!result.getLoadBalancerDescriptions().isEmpty()) {
    return Optional.of(result.getLoadBalancerDescriptions().get(0));
  } else {
    return Optional.absent();
  }
}
 
开发者ID:HubSpot,项目名称:Baragon,代码行数:10,代码来源:ClassicLoadBalancer.java

示例13: getElbDnsName

import com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest; //导入依赖的package包/类
/**
 * Return the DNS name for a given AWS ELB group name
 * @param elbName the ELB group name
 * @return String DNS name
 */
public String getElbDnsName(String elbName) {
    DescribeLoadBalancersResult result = amazonElbClient.describeLoadBalancers(new DescribeLoadBalancersRequest()
        .withLoadBalancerNames(elbName));
    return result.getLoadBalancerDescriptions().get(0).getDNSName();
}
 
开发者ID:shinesolutions,项目名称:aem-orchestrator,代码行数:11,代码来源:AwsHelperService.java

示例14: setupMock

import com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest; //导入依赖的package包/类
private void setupMock(DescribeLoadBalancersResult fakeResult)
{
  when(mockELBClient.describeLoadBalancers(any(DescribeLoadBalancersRequest.class))).thenReturn(fakeResult);
}
 
开发者ID:Nike-Inc,项目名称:bluegreen-manager,代码行数:5,代码来源:ElbClientTest.java

示例15: testCheck

import com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest; //导入依赖的package包/类
@Test
public void testCheck() throws Exception {
    when(accountIdSupplierMock.get()).thenReturn(newHashSet(ACCOUNT_ID));
    when(jobsPropertiesMock.getWhitelistedRegions()).thenReturn(regions);
    when(portsChecker.check(any(LoadBalancerDescription.class))).thenReturn(Collections.<Integer>emptyList());
    when(securityGroupsChecker.check(any(), any(), any())).thenReturn(emptyMap());
    when(mockAwsELBClient.describeLoadBalancers(any(DescribeLoadBalancersRequest.class))).thenReturn(mockDescribeELBResult);
    when(mockAwsELBClient.describeTags(any(DescribeTagsRequest.class))).thenReturn(mockDescribeTagsResult);
    when(mockAwsApplications.isPubliclyAccessible(anyString(), anyString(), anyListOf(String.class)))
            .thenReturn(Optional.of(false));

    final FetchElasticLoadBalancersJob fetchELBJob = new FetchElasticLoadBalancersJob(
            violationSinkMock,
            clientProviderMock,
            accountIdSupplierMock,
            jobsPropertiesMock,
            securityGroupsChecker,
            portsChecker,
            mockAwsApplications,
            mockViolationService,
            fetchTaupageYamlMock,
            mockAmiDetailsProvider,
            mockEC2InstanceProvider,
            mock(CloseableHttpClient.class),
            mock(JobExceptionHandler.class));

    fetchELBJob.run();

    verify(accountIdSupplierMock).get();
    verify(jobsPropertiesMock, atLeast(1)).getWhitelistedRegions();
    verify(jobsPropertiesMock).getElbAllowedPorts();
    verify(securityGroupsChecker, atLeast(1)).check(any(), any(), any());
    verify(portsChecker, atLeast(1)).check(any());
    verify(mockAwsELBClient).describeLoadBalancers(any(DescribeLoadBalancersRequest.class));
    // maximum 20 ELB names can be requested at once. So this needs to be split into two calls.
    verify(mockAwsELBClient, times(2)).describeTags(any(DescribeTagsRequest.class));
    verify(clientProviderMock).getClient(any(), any(String.class), any(Region.class));
    verify(mockAwsApplications).isPubliclyAccessible(eq(ACCOUNT_ID), eq(REGION1), eq(asList("i1", "i2")));
    verify(mockEC2InstanceProvider).getById(eq(ACCOUNT_ID), eq(getRegion(fromName(REGION1))), eq("i1"));
    verify(mockAmiDetailsProvider).getAmiDetails(eq(ACCOUNT_ID), eq(getRegion(fromName(REGION1))), eq("bar"));
}
 
开发者ID:zalando-stups,项目名称:fullstop,代码行数:42,代码来源:FetchElasticLoadBalancersJobTest.java


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