本文整理汇总了Java中com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancingClient类的典型用法代码示例。如果您正苦于以下问题:Java AmazonElasticLoadBalancingClient类的具体用法?Java AmazonElasticLoadBalancingClient怎么用?Java AmazonElasticLoadBalancingClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AmazonElasticLoadBalancingClient类属于com.amazonaws.services.elasticloadbalancing包,在下文中一共展示了AmazonElasticLoadBalancingClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createElbClient
import com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancingClient; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public AmazonElasticLoadBalancing createElbClient(String awsAccessId, String awsSecretKey) {
AWSCredentials credentials = new BasicAWSCredentials(awsAccessId, awsSecretKey);
ClientConfiguration configuration = createConfiguration();
AmazonElasticLoadBalancing client = new AmazonElasticLoadBalancingClient(credentials, configuration);
if (host != null) {
client.setEndpoint(AmazonElasticLoadBalancing.ENDPOINT_PREFIX + "." + host);
}
client = new ExceptionHandleAwsClientWrapper().wrap(client);
return client;
}
示例2: registerInstancesToLoadBalancer
import com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancingClient; //导入依赖的package包/类
private RegisterInstancesWithLoadBalancerResult registerInstancesToLoadBalancer(AmazonElasticLoadBalancingClient client, AmazonEC2Client simpleClient,
String lbName) {
List<Instance> instances = new ArrayList<>();
for (Reservation reservation : simpleClient.describeInstances().getReservations()) {
instances.addAll(reservation.getInstances());
}
List<com.amazonaws.services.elasticloadbalancing.model.Instance> instanceId = new ArrayList<>();
List<String> instanceIdString = new ArrayList<>();
for (Instance instance : instances) {
instanceId.add(new com.amazonaws.services.elasticloadbalancing.model.Instance(instance.getInstanceId()));
instanceIdString.add(instance.getInstanceId());
}
RegisterInstancesWithLoadBalancerRequest register = new RegisterInstancesWithLoadBalancerRequest();
register.setLoadBalancerName(lbName);
register.setInstances(instanceId);
return client.registerInstancesWithLoadBalancer(register);
}
示例3: AwsAutoScalingDeployUtils
import com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancingClient; //导入依赖的package包/类
public AwsAutoScalingDeployUtils(String region, DeployConfiguration activeConfiguration, Log log) {
this.activeConfiguration = activeConfiguration;
this.log = log;
Region awsRegion = Region.getRegion(Regions.fromName(region));
awsAsClient = new AmazonAutoScalingClient();
awsAsClient.setRegion(awsRegion);
awsElbClient = new AmazonElasticLoadBalancingClient();
awsElbClient.setRegion(awsRegion);
awsEc2Client = new AmazonEC2Client();
awsEc2Client.setRegion(awsRegion);
activeConfiguration.withAutoScalingGroup(matchAutoScalingGroupName(activeConfiguration.getAutoScalingGroupId()));
}
示例4: providesAwsElbClientV2
import com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancingClient; //导入依赖的package包/类
@Provides
@Named(BARAGON_AWS_ELB_CLIENT_V2)
public com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancingClient providesAwsElbClientV2(Optional<ElbConfiguration> configuration) {
com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancingClient elbClient;
if (configuration.isPresent() && configuration.get().getAwsAccessKeyId() != null && configuration.get().getAwsAccessKeySecret() != null) {
elbClient = new com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancingClient(new BasicAWSCredentials(configuration.get().getAwsAccessKeyId(), configuration.get().getAwsAccessKeySecret()));
} else {
elbClient = new com.amazonaws.services.elasticloadbalancingv2.AmazonElasticLoadBalancingClient();
}
if (configuration.isPresent() && configuration.get().getAwsEndpoint().isPresent()) {
elbClient.setEndpoint(configuration.get().getAwsEndpoint().get());
}
if (configuration.isPresent() && configuration.get().getAwsRegion().isPresent()) {
elbClient.configureRegion(Regions.fromName(configuration.get().getAwsRegion().get()));
}
return elbClient;
}
示例5: makeRegionalElbClient
import com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancingClient; //导入依赖的package包/类
/**
* Constructs an AmazonElasticLoadBalancingClient and sets the region.
*/
public AmazonElasticLoadBalancingClient makeRegionalElbClient()
{
AWSCredentials credentials = new BasicAWSCredentials(awsAccessKeyId, awsSecretAccessKey);
AmazonElasticLoadBalancingClient elb = new AmazonElasticLoadBalancingClient(credentials);
elb.setRegion(awsRegion);
return elb;
}
示例6: testMakeRegionalELBClient
import com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancingClient; //导入依赖的package包/类
/**
* Tests that we can make an elb client.
*/
@Test
public void testMakeRegionalELBClient()
{
AmazonElasticLoadBalancingClient elb = awsClientFactory.makeRegionalElbClient();
assertEquals(ServiceAbbreviations.ElasticLoadbalancing, elb.getServiceName());
}
示例7: getElbTags
import com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancingClient; //导入依赖的package包/类
private Map<String, List<Tag>> getElbTags(AmazonElasticLoadBalancingClient elbClient, List<String> elbNames) {
if (isEmpty(elbNames)) {
return emptyMap();
} else {
final Map<String, List<Tag>> result = newHashMapWithExpectedSize(elbNames.size());
// http://docs.aws.amazon.com/elasticloadbalancing/2012-06-01/APIReference/API_DescribeTags.html
// describeTags expects a maximum of 20 load balancer names per call
for (List<String> elbNamePartition : partition(elbNames, ELB_NAMES_MAX_SIZE)) {
elbClient.describeTags(new DescribeTagsRequest().withLoadBalancerNames(elbNamePartition))
.getTagDescriptions()
.forEach(tagDescription -> result.put(tagDescription.getLoadBalancerName(), tagDescription.getTags()));
}
return result;
}
}
示例8: ServerInstanceContext
import com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancingClient; //导入依赖的package包/类
private ServerInstanceContext(){
amazonElasticLoadBalancing = new AmazonElasticLoadBalancingClient();
amazonEC2 = new AmazonEC2Client();
ec2MetadataClient = new Ec2MetadataClient() {
@Override
public String getAvailabilityZone() {
return EC2MetadataUtils.getAvailabilityZone();
}
@Override
public String getInstanceId() {
return EC2MetadataUtils.getInstanceId();
}
@Override
public String getUserData() {
return EC2MetadataUtils.getUserData();
}
@Override
public String getPrivateIpAddress() {
return EC2MetadataUtils.getPrivateIpAddress();
}
@Override
public String getPublicIpAddress() {
for (EC2MetadataUtils.NetworkInterface net : EC2MetadataUtils.getNetworkInterfaces()) {
List<String> ips = net.getPublicIPv4s();
if (ips != null && ips.size() > 0) {
return ips.get(0);
}
}
return null;
}
};
init();
}
示例9: createLoadBalancer
import com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancingClient; //导入依赖的package包/类
private CreateLoadBalancerResult createLoadBalancer(AmazonElasticLoadBalancingClient client, String name, String... zones) {
CreateLoadBalancerRequest lbRequest = new CreateLoadBalancerRequest();
lbRequest.setLoadBalancerName(name);
lbRequest.withAvailabilityZones(zones);
lbRequest.setListeners(Arrays.asList(new Listener("HTTP", 80, 80)));
return client.createLoadBalancer(lbRequest);
}
示例10: findClient
import com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancingClient; //导入依赖的package包/类
private AmazonElasticLoadBalancing findClient(Account account, Region region) {
// TODO: need to config client config parameter. ignore it for now.
// TODO: need a cached version based on account and region as key
AWSCredentials credential = new BasicAWSCredentials(account.getAccessKeyId(), account.getSecretAccessKey());
AmazonElasticLoadBalancing elb = new AmazonElasticLoadBalancingClient(credential);
elb.setRegion(com.amazonaws.regions.Region.getRegion(region.getRegions()));
return elb;
}
示例11: ClassicLoadBalancer
import com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancingClient; //导入依赖的package包/类
@Inject
public ClassicLoadBalancer(Optional<ElbConfiguration> configuration,
BaragonExceptionNotifier exceptionNotifier,
BaragonLoadBalancerDatastore loadBalancerDatastore,
BaragonKnownAgentsDatastore knownAgentsDatastore,
@Named(BaragonServiceModule.BARAGON_AWS_ELB_CLIENT_V1) AmazonElasticLoadBalancingClient elbClient) {
super(configuration, exceptionNotifier, loadBalancerDatastore, knownAgentsDatastore);
this.elbClient = elbClient;
}
示例12: ElbClient
import com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancingClient; //导入依赖的package包/类
public ElbClient(AmazonElasticLoadBalancingClient awsElbClient)
{
this.awsElbClient = awsElbClient;
}
示例13: EC2UtilsImpl
import com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancingClient; //导入依赖的package包/类
/**
* Default constructor.
*/
public EC2UtilsImpl() {
this.amazonEc2 = new AmazonEC2Client();
this.amazonElasticLoadBalancing = new AmazonElasticLoadBalancingClient();
}
示例14: setUp
import com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancingClient; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
this.violationSinkMock = mock(ViolationSink.class);
this.clientProviderMock = mock(ClientProvider.class);
this.accountIdSupplierMock = mock(AccountIdSupplier.class);
this.jobsPropertiesMock = mock(JobsProperties.class);
this.portsChecker = mock(PortsChecker.class);
this.securityGroupsChecker = mock(SecurityGroupsChecker.class);
this.mockAwsELBClient = mock(AmazonElasticLoadBalancingClient.class);
this.mockAwsApplications = mock(AwsApplications.class);
this.mockViolationService = mock(ViolationService.class);
this.fetchTaupageYamlMock = mock(FetchTaupageYaml.class);
this.mockAmiDetailsProvider = mock(AmiDetailsProvider.class);
this.mockEC2InstanceProvider = mock(EC2InstanceProvider.class);
final Listener listener = new Listener("HTTPS", 80, 80);
final ListenerDescription listenerDescription = new ListenerDescription();
listenerDescription.setListener(listener);
final ArrayList<LoadBalancerDescription> elbs = newArrayList();
final ArrayList<TagDescription> tagDescriptions = newArrayList();
final LoadBalancerDescription publicELB = new LoadBalancerDescription();
publicELB.setScheme("internet-facing");
publicELB.setListenerDescriptions(newArrayList(listenerDescription));
publicELB.setCanonicalHostedZoneName("test.com");
publicELB.setInstances(asList(new Instance("i1"), new Instance("i2")));
publicELB.setLoadBalancerName("publicELB");
elbs.add(publicELB);
tagDescriptions.add(
new TagDescription()
.withLoadBalancerName("publicELB")
.withTags(newArrayList(
new Tag().withKey("someTag").withValue("someValue"))));
final LoadBalancerDescription privateELB = new LoadBalancerDescription();
privateELB.setScheme("internal");
privateELB.setCanonicalHostedZoneName("internal.org");
privateELB.setLoadBalancerName("privateELB");
elbs.add(privateELB);
for (int i = 1; i <= 20; i++) {
final String loadBalancerName = "kubeELB" + i;
final LoadBalancerDescription kubeELB = new LoadBalancerDescription();
kubeELB.setScheme("internet-facing");
kubeELB.setCanonicalHostedZoneName("test" + i + ".com");
kubeELB.setLoadBalancerName(loadBalancerName);
elbs.add(kubeELB);
tagDescriptions.add(
new TagDescription()
.withLoadBalancerName(loadBalancerName)
.withTags(newArrayList(
new Tag().withKey("someTag").withValue("someValue"),
new Tag().withKey("kubernetes.io/cluster/").withValue("owned"))));
}
mockDescribeELBResult = new DescribeLoadBalancersResult();
mockDescribeELBResult.setLoadBalancerDescriptions(elbs);
mockDescribeTagsResult = new DescribeTagsResult();
mockDescribeTagsResult.setTagDescriptions(tagDescriptions);
regions.add(REGION1);
when(clientProviderMock.getClient(any(), any(String.class), any(Region.class))).thenReturn(mockAwsELBClient);
when(mockEC2InstanceProvider.getById(anyString(), any(Region.class), anyString()))
.thenReturn(Optional.of(new com.amazonaws.services.ec2.model.Instance().withInstanceId("foo").withImageId("bar")));
when(mockAmiDetailsProvider.getAmiDetails(anyString(), any(Region.class), anyString()))
.thenReturn(ImmutableMap.of("ami_id", "bar"));
}
示例15: getLoadBalanceClient
import com.amazonaws.services.elasticloadbalancing.AmazonElasticLoadBalancingClient; //导入依赖的package包/类
public AmazonElasticLoadBalancingClient getLoadBalanceClient() {
return loadBalanceClient;
}