本文整理汇总了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));
}
示例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();
}
示例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();
}
示例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);
}
示例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");
}
}
示例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);
}
}
示例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"));
});
}
示例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;
});
}
示例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());
}
示例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);
}
示例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;
}
示例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();
}
}
示例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();
}
示例14: setupMock
import com.amazonaws.services.elasticloadbalancing.model.DescribeLoadBalancersRequest; //导入依赖的package包/类
private void setupMock(DescribeLoadBalancersResult fakeResult)
{
when(mockELBClient.describeLoadBalancers(any(DescribeLoadBalancersRequest.class))).thenReturn(fakeResult);
}
示例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"));
}