/** * TODO: メソッドコメント * * @param client * @return */ public AmazonElasticLoadBalancing wrap(final AmazonElasticLoadBalancing client) { InvocationHandler handler = new InvocationHandler() { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (!AmazonWebServiceResult.class.isAssignableFrom(method.getReturnType())) { return method.invoke(client, args); } return doInvoke(client, proxy, method, args); } }; return (AmazonElasticLoadBalancing) Proxy.newProxyInstance(LoggingAwsClientWrapper.class.getClassLoader(), new Class[] { AmazonElasticLoadBalancing.class }, handler); }
/** * {@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; }
@Before public void beforeEachTestRuns() { AWSCredentialsProvider credentialsProvider = new DefaultAWSCredentialsProviderChain(); AmazonEC2 ec2Client = EnvironmentSetupForTests.createEC2Client(); AmazonElasticLoadBalancing awsElbClient = EnvironmentSetupForTests.createELBClient(); AmazonCloudFormation cfnClient = EnvironmentSetupForTests.createCFNClient(); AmazonRDS awsRdsClient = EnvironmentSetupForTests.createRDSClient(); CloudClient cloudClient = new CloudClient(ec2Client, new DefaultAwsRegionProviderChain()); LoadBalancerClient elbClient = new LoadBalancerClient(awsElbClient); VpcRepository vpcRepository = new VpcRepository(cloudClient); CloudFormationClient cloudFormationClient = new CloudFormationClient(cfnClient); cloudRepository = new CloudRepository(cloudClient); ResourceRepository cfnRepository = new CfnRepository(cloudFormationClient, cloudRepository, "CfnAssist"); elbRepository = new ELBRepository(elbClient, vpcRepository, cfnRepository); rdsClient = new RDSClient(awsRdsClient); }
@Bean public AmazonElasticLoadBalancing amazonElbClient(final AWSCredentialsProvider awsCredentialsProvider, final ClientConfiguration awsClientConfig, final Region awsRegion) { return AmazonElasticLoadBalancingClientBuilder.standard() .withCredentials(awsCredentialsProvider) .withClientConfiguration(awsClientConfig) .withRegion(awsRegion.getName()) .build(); }
/** * Fetches and filters a Region's ELBs * @param amazonElasticLoadBalancing * @param filter * @return */ public static List<LoadBalancerDescription> findLoadBalancers(AmazonElasticLoadBalancing amazonElasticLoadBalancing, ELBFilter filter) { List<LoadBalancerDescription> loadBalancers = amazonElasticLoadBalancing.describeLoadBalancers().getLoadBalancerDescriptions(); List<LoadBalancerDescription> result = new ArrayList<>(loadBalancers.size()); for(LoadBalancerDescription loadBalancer:loadBalancers){ if(filter.accept(loadBalancer)){ result.add(loadBalancer); } } return result; }
public ServerInstanceContext(Ec2MetadataClient ec2MetadataClient, AmazonEC2 amazonEC2, AmazonElasticLoadBalancing amazonElasticLoadBalancing){ this.ec2MetadataClient = ec2MetadataClient; this.amazonEC2 = amazonEC2; this.amazonElasticLoadBalancing = amazonElasticLoadBalancing; init(); }
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; }
@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); }
/** * {@inheritDoc} */ @Override public AmazonElasticLoadBalancing createElbClient(String awsAccessId, String awsSecretKey) { return elbClient; }
protected AwsProcessClient createAwsClient(Platform platform, PlatformAws platformAws, AwsCertificate awsCertificate) { AwsClientFactory factory; if (BooleanUtils.isTrue(platformAws.getEuca())) { factory = new EucaAwsClientFactory(); } else { factory = new AmazonAwsClientFactory(); } factory.setHost(platformAws.getHost()); factory.setPort(platformAws.getPort()); factory.setSecure(platformAws.getSecure()); if (BooleanUtils.isTrue(platform.getProxy())) { Proxy proxy = proxyDao.read(); factory.setProxyHost(proxy.getHost()); factory.setProxyPort(proxy.getPort()); factory.setProxyUser(proxy.getUser()); factory.setProxyPassword(proxy.getPassword()); } // Clientの作成 AmazonEC2 ec2Client = factory .createEc2Client(awsCertificate.getAwsAccessId(), awsCertificate.getAwsSecretKey()); AmazonElasticLoadBalancing elbClient = factory.createElbClient(awsCertificate.getAwsAccessId(), awsCertificate.getAwsSecretKey()); // ログ出力用Clientでラップ String logging = StringUtils.defaultIfEmpty(Config.getProperty("aws.logging"), "false"); if (BooleanUtils.toBoolean(logging)) { LoggingAwsClientWrapper loggingAwsClientWrapper = new LoggingAwsClientWrapper(); ec2Client = loggingAwsClientWrapper.wrap(ec2Client); elbClient = loggingAwsClientWrapper.wrap(elbClient); } // 同期実行用Clientでラップ String sync = StringUtils.defaultIfEmpty(Config.getProperty("aws.synchronized"), "true"); if (BooleanUtils.toBoolean(sync)) { SynchronizedAwsClientWrapper synchronizedAwsClientWrapper = new SynchronizedAwsClientWrapper(); ec2Client = synchronizedAwsClientWrapper.wrap(ec2Client); elbClient = synchronizedAwsClientWrapper.wrap(elbClient); } AwsProcessClient client = new AwsProcessClient(awsCertificate.getUserNo(), platform, platformAws, ec2Client, elbClient); String describeInterval = Config.getProperty("aws.describeInterval"); client.setDescribeInterval(NumberUtils.toInt(describeInterval, 15)); return client; }
public AmazonElasticLoadBalancing getElbClient() { return elbClient; }
public LoadBalancerClient(AmazonElasticLoadBalancing elbClient) { this.elbClient = elbClient; }
/** * TODO: コンストラクタコメント * * @param userNo * @param platform * @param platformAws * @param ec2Client * @param elbClient */ public AwsProcessClient(Long userNo, Platform platform, PlatformAws platformAws, AmazonEC2 ec2Client, AmazonElasticLoadBalancing elbClient) { this.userNo = userNo; this.platform = platform; this.platformAws = platformAws; this.ec2Client = ec2Client; this.elbClient = elbClient; }
public static AmazonElasticLoadBalancing createELBClient() { return AmazonElasticLoadBalancingClientBuilder.defaultClient(); }
public abstract AmazonElasticLoadBalancing createElbClient(String awsAccessId, String awsSecretKey);