mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-03 01:29:33 +00:00
bug4811: updated AWS API
This commit is contained in:
1 parent
b0d00c3dd8
commit
06d4e9ec2d
18 files changed
+94
-64
No files matched your search
@@ -6,3 +6,6 @@ and established manifest, classpath and build.properties file so the project
|
||||
can be built both, in Eclipse and with Maven.
|
||||
|
||||
See /java/com.amazon.aws.aws-java-api/README for further instructions.
|
||||
|
||||
See also /java/com.sap.sailing.targetplatform/scripts/uploadAwsApiRepositoryToServer.sh
|
||||
for uploading the update site to the p2 repository at p2.sapsailing.com.
|
||||
@@ -2,21 +2,21 @@
|
||||
<feature
|
||||
id="com.amazon.aws.aws-java-api"
|
||||
label="AWS API"
|
||||
version="2.13.61"
|
||||
version="2.14.24"
|
||||
provider-name="Amazon">
|
||||
|
||||
<plugin
|
||||
id="com.amazon.aws.aws-java-api"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="2.13.61"
|
||||
version="2.14.24"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.amazon.aws.aws-java-api.source"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="2.13.61"
|
||||
version="2.14.24"
|
||||
unpack="false"/>
|
||||
|
||||
</feature>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<site>
|
||||
<feature url="features/aws-sdk/com.amazon.aws.aws-java-api_2.13.61.jar" id="com.amazon.aws.aws-java-api" version="2.13.61">
|
||||
<feature url="features/aws-sdk/com.amazon.aws.aws-java-api_2.14.24.jar" id="com.amazon.aws.aws-java-api" version="2.14.24">
|
||||
<category name="aws-java-api"/>
|
||||
</feature>
|
||||
<category-def name="com.amazon.aws.aws-java-api" label="aws-java-api"/>
|
||||
|
||||
@@ -57,3 +57,6 @@ updates .classpath, pom.xml, build.properties and META-INF/MANIFEST.MF according
|
||||
runs a Maven build to produce the wrapper bundle's JAR file. This JAR is then copied to the
|
||||
update site project's plugins/aws-sdk folder, the feature.xml file for the update site is updated
|
||||
to reflect the correct version number, and then the update site is built using Maven.
|
||||
|
||||
If you like what you've got, update the p2.sapsailing.com version of the aws-sdk update site by invoking
|
||||
/java/com.sap.sailing.targetplatform/scripts/uploadAwsApiRepositoryToServer.sh
|
||||
@@ -5,7 +5,7 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation platform('software.amazon.awssdk:bom:2.13.61')
|
||||
implementation platform('software.amazon.awssdk:bom:2.14.24')
|
||||
implementation 'software.amazon.awssdk:s3'
|
||||
implementation 'software.amazon.awssdk:ec2'
|
||||
implementation 'software.amazon.awssdk:route53'
|
||||
|
||||
@@ -8,6 +8,6 @@
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>com.amazon.aws.aws-java-api</artifactId>
|
||||
<version>2.13.61</version>
|
||||
<version>2.14.24</version>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
</project>
|
||||
@@ -120,7 +120,7 @@
|
||||
<repository location="https://p2.sapsailing.com/p2/sailing/"/>
|
||||
</location>
|
||||
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="slicer" includeSource="true" type="InstallableUnit">
|
||||
<unit id="com.amazon.aws.aws-java-api.feature.group" version="2.13.61"/>
|
||||
<unit id="com.amazon.aws.aws-java-api.feature.group" version="2.14.24"/>
|
||||
<repository location="https://p2.sapsailing.com/p2/aws-sdk/"/>
|
||||
</location>
|
||||
</locations>
|
||||
|
||||
+5
-5
@@ -60,7 +60,7 @@ public class ConnectivityTest {
|
||||
|
||||
@Test
|
||||
public void testConnectivity() {
|
||||
final AwsInstance host = landscape.launchHost(landscape.getImage(region, "ami-01b4b27a5699e33e6"),
|
||||
final AwsInstance<String, ApplicationProcessMetrics> host = landscape.launchHost(landscape.getImage(region, "ami-01b4b27a5699e33e6"),
|
||||
InstanceType.T3_SMALL, landscape.getAvailabilityZoneByName(region, "eu-west-2b"), "Axel", Collections.singleton(()->"sg-0b2afd48960251280"));
|
||||
try {
|
||||
assertNotNull(host);
|
||||
@@ -130,7 +130,7 @@ public class ConnectivityTest {
|
||||
}
|
||||
|
||||
private void testSshConnectWithKey(final String keyName) throws InterruptedException, JSchException, IOException {
|
||||
final AwsInstance host = landscape.launchHost(landscape.getImage(region, "ami-01b4b27a5699e33e6"),
|
||||
final AwsInstance<String, ApplicationProcessMetrics> host = landscape.launchHost(landscape.getImage(region, "ami-01b4b27a5699e33e6"),
|
||||
InstanceType.T3_SMALL, landscape.getAvailabilityZoneByName(region, "eu-west-2b"), keyName, Collections.singleton(()->"sg-0b2afd48960251280"));
|
||||
try {
|
||||
assertNotNull(host);
|
||||
@@ -174,7 +174,7 @@ public class ConnectivityTest {
|
||||
|
||||
@Test
|
||||
public void testImageDate() throws ParseException {
|
||||
final AmazonMachineImage image = landscape.getImage(region, "ami-01b4b27a5699e33e6");
|
||||
final AmazonMachineImage<String, ApplicationProcessMetrics> image = landscape.getImage(region, "ami-01b4b27a5699e33e6");
|
||||
assertEquals(TimePoint.of(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz").parse("2020-07-08T12:41:06+0200")),
|
||||
image.getCreatedAt());
|
||||
}
|
||||
@@ -212,9 +212,9 @@ public class ConnectivityTest {
|
||||
@Test
|
||||
public void createAndDeleteTargetGroupTest() {
|
||||
final String targetGroupName = "TestTargetGroup-"+new Random().nextInt();
|
||||
final TargetGroup targetGroup = landscape.createTargetGroup(region, targetGroupName, 80, "/gwt/status", 80);
|
||||
final TargetGroup<String, ApplicationProcessMetrics> targetGroup = landscape.createTargetGroup(region, targetGroupName, 80, "/gwt/status", 80);
|
||||
try {
|
||||
final TargetGroup fetchedTargetGroup = landscape.getTargetGroup(region, targetGroupName, targetGroup.getTargetGroupArn());
|
||||
final TargetGroup<String, ApplicationProcessMetrics> fetchedTargetGroup = landscape.getTargetGroup(region, targetGroupName, targetGroup.getTargetGroupArn());
|
||||
assertEquals(targetGroupName, fetchedTargetGroup.getName());
|
||||
} finally {
|
||||
landscape.deleteTargetGroup(targetGroup);
|
||||
|
||||
@@ -9,8 +9,17 @@ import com.jcraft.jsch.Channel;
|
||||
import com.jcraft.jsch.ChannelSftp;
|
||||
import com.jcraft.jsch.JSchException;
|
||||
import com.sap.sse.landscape.Host;
|
||||
import com.sap.sse.landscape.MachineImage;
|
||||
import com.sap.sse.landscape.application.ApplicationProcessMetrics;
|
||||
|
||||
public interface AwsInstance extends Host {
|
||||
/**
|
||||
* An AWS EC2 host that has been created from a {@link MachineImage} that supports deploying an application,
|
||||
* has a {@link ReverseProxy} on it
|
||||
*
|
||||
* @author Axel Uhl (D043530)
|
||||
*
|
||||
*/
|
||||
public interface AwsInstance<ShardingKey, MetricsT extends ApplicationProcessMetrics> extends Host {
|
||||
/**
|
||||
* Connects to an SSH session for the username specified, using the SSH key pair used to launch the instance, and
|
||||
* opens a "shell" channel. Use the {@link Channel} returned by {@link Channel#setInputStream(java.io.InputStream)
|
||||
@@ -32,6 +41,8 @@ public interface AwsInstance extends Host {
|
||||
ChannelSftp createSftpChannel(String sshUserName) throws JSchException, IOException;
|
||||
|
||||
ChannelSftp createRootSftpChannel() throws JSchException, IOException;
|
||||
|
||||
|
||||
ReverseProxy<ShardingKey, MetricsT> getReverseProxy();
|
||||
|
||||
String getInstanceId();
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public interface AwsLandscape<ShardingKey, MetricsT extends ApplicationProcessMe
|
||||
* the SSH key pair name to use when launching; this will grant root access with the corresponding
|
||||
* private key; see also {@link #getKeyPairInfo(Region, String)}
|
||||
*/
|
||||
default AwsInstance launchHost(MachineImage<AwsInstance> fromImage, InstanceType instanceType,
|
||||
default AwsInstance<ShardingKey, MetricsT> launchHost(MachineImage<AwsInstance<ShardingKey, MetricsT>> fromImage, InstanceType instanceType,
|
||||
AwsAvailabilityZone az, String keyName, Iterable<SecurityGroup> securityGroups) {
|
||||
return launchHosts(1, fromImage, instanceType, az, keyName, securityGroups).iterator().next();
|
||||
}
|
||||
@@ -71,10 +71,10 @@ public interface AwsLandscape<ShardingKey, MetricsT extends ApplicationProcessMe
|
||||
* the SSH key pair name to use when launching; this will grant root access with the corresponding
|
||||
* private key; see also {@link #getKeyPairInfo(Region, String)}
|
||||
*/
|
||||
Iterable<AwsInstance> launchHosts(int numberOfHostsToLaunch, MachineImage<AwsInstance> fromImage, InstanceType instanceType,
|
||||
Iterable<AwsInstance<ShardingKey, MetricsT>> launchHosts(int numberOfHostsToLaunch, MachineImage<AwsInstance<ShardingKey, MetricsT>> fromImage, InstanceType instanceType,
|
||||
AwsAvailabilityZone az, String keyName, Iterable<SecurityGroup> securityGroups);
|
||||
|
||||
AmazonMachineImage getImage(Region region, String imageId);
|
||||
AmazonMachineImage<ShardingKey, MetricsT> getImage(Region region, String imageId);
|
||||
|
||||
KeyPairInfo getKeyPairInfo(Region region, String keyName);
|
||||
|
||||
@@ -85,7 +85,7 @@ public interface AwsLandscape<ShardingKey, MetricsT extends ApplicationProcessMe
|
||||
*/
|
||||
String importKeyPair(Region region, byte[] publicKey, byte[] unencryptedPrivateKey, String keyName) throws JSchException;
|
||||
|
||||
void terminate(AwsInstance host);
|
||||
void terminate(AwsInstance<ShardingKey, MetricsT> host);
|
||||
|
||||
SSHKeyPair getSSHKeyPair(Region region, String keyName);
|
||||
|
||||
@@ -157,15 +157,15 @@ public interface AwsLandscape<ShardingKey, MetricsT extends ApplicationProcessMe
|
||||
* Creates a target group with a default configuration that includes a health check URL. Stickiness is enabled with
|
||||
* the default duration of one day. The load balancing algorithm is set to {@code least_outstanding_requests}.
|
||||
*/
|
||||
TargetGroup createTargetGroup(AwsRegion region, String targetGroupName, int port, String healthCheckPath, int healthCheckPort);
|
||||
TargetGroup<ShardingKey, MetricsT> createTargetGroup(AwsRegion region, String targetGroupName, int port, String healthCheckPath, int healthCheckPort);
|
||||
|
||||
default TargetGroup getTargetGroup(AwsRegion region, String targetGroupName, String targetGroupArn) {
|
||||
return new AwsTargetGroupImpl(this, region, targetGroupName, targetGroupArn);
|
||||
default TargetGroup<ShardingKey, MetricsT> getTargetGroup(AwsRegion region, String targetGroupName, String targetGroupArn) {
|
||||
return new AwsTargetGroupImpl<>(this, region, targetGroupName, targetGroupArn);
|
||||
}
|
||||
|
||||
software.amazon.awssdk.services.elasticloadbalancingv2.model.TargetGroup getAwsTargetGroup(AwsRegion region, String targetGroupName);
|
||||
|
||||
Map<AwsInstance, TargetHealth> getTargetHealthDescriptions(TargetGroup targetGroup);
|
||||
Map<AwsInstance<ShardingKey, MetricsT>, TargetHealth> getTargetHealthDescriptions(TargetGroup<ShardingKey, MetricsT> targetGroup);
|
||||
|
||||
void deleteTargetGroup(TargetGroup targetGroup);
|
||||
void deleteTargetGroup(TargetGroup<ShardingKey, MetricsT> targetGroup);
|
||||
}
|
||||
+4
-2
@@ -1,5 +1,7 @@
|
||||
package com.sap.sse.landscape.aws;
|
||||
|
||||
public interface ForwardToTargetGroup extends LoadBalancerRuleAction {
|
||||
TargetGroup getTargetGroupToForwardTo();
|
||||
import com.sap.sse.landscape.application.ApplicationProcessMetrics;
|
||||
|
||||
public interface ForwardToTargetGroup<ShardingKey, MetricsT extends ApplicationProcessMetrics> extends LoadBalancerRuleAction {
|
||||
TargetGroup<ShardingKey, MetricsT> getTargetGroupToForwardTo();
|
||||
}
|
||||
@@ -42,7 +42,7 @@ public interface ReverseProxy<ShardingKey, MetricsT extends ApplicationProcessMe
|
||||
*
|
||||
* @return at least one host
|
||||
*/
|
||||
Iterable<AwsInstance> getHosts();
|
||||
Iterable<AwsInstance<ShardingKey, MetricsT>> getHosts();
|
||||
|
||||
/**
|
||||
* The target group that will be managed by this object when hosts are added and removed. This instance asserts that
|
||||
@@ -50,7 +50,7 @@ public interface ReverseProxy<ShardingKey, MetricsT extends ApplicationProcessMe
|
||||
* {@link #removeHost(AwsInstance)} the {@link TargetGroup#getRegisteredTargets()} will match the response of
|
||||
* {@link #getHosts()}.
|
||||
*/
|
||||
TargetGroup getTargetGroup();
|
||||
TargetGroup<ShardingKey, MetricsT> getTargetGroup();
|
||||
|
||||
/**
|
||||
* Adds a single host to this reverse proxy in availability zone {@code az}, using a default instance type
|
||||
@@ -59,7 +59,7 @@ public interface ReverseProxy<ShardingKey, MetricsT extends ApplicationProcessMe
|
||||
*
|
||||
* @return the host that was added by this request; it will also be part of the response of {@link #getHosts()} now
|
||||
*/
|
||||
default AwsInstance addHost(AwsAvailabilityZone az) {
|
||||
default AwsInstance<ShardingKey, MetricsT> addHost(AwsAvailabilityZone az) {
|
||||
return addHosts(getDefaultInstanceType(), az, /* numberOfHostsToAdd */ 1).iterator().next();
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public interface ReverseProxy<ShardingKey, MetricsT extends ApplicationProcessMe
|
||||
* @return the hosts that were added by this request; they will also be part of the response of {@link #getHosts()}
|
||||
* now
|
||||
*/
|
||||
Iterable<AwsInstance> addHosts(InstanceType instanceType, AwsAvailabilityZone az, int numberOfHostsToAdd);
|
||||
Iterable<AwsInstance<ShardingKey, MetricsT>> addHosts(InstanceType instanceType, AwsAvailabilityZone az, int numberOfHostsToAdd);
|
||||
|
||||
/**
|
||||
* Configures a redirect in this reverse proxy such that requests for it will go to the
|
||||
@@ -123,7 +123,7 @@ public interface ReverseProxy<ShardingKey, MetricsT extends ApplicationProcessMe
|
||||
* an {@link IllegalStateException} will be thrown and the method will not complete the request. Consider
|
||||
* using {@link #terminate()} to terminate all hosts forming this reverse proxy.
|
||||
*/
|
||||
void removeHost(AwsInstance host);
|
||||
void removeHost(AwsInstance<ShardingKey, MetricsT> host);
|
||||
|
||||
/**
|
||||
* {@link AwsLandscape#terminate(AwsInstance) Terminates} all {@link #getHosts() hosts} that form this reverse
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sap.sse.common.Named;
|
||||
import com.sap.sse.landscape.application.ApplicationProcessMetrics;
|
||||
import com.sap.sse.landscape.aws.impl.AwsRegion;
|
||||
|
||||
import software.amazon.awssdk.services.elasticloadbalancingv2.model.TargetHealth;
|
||||
@@ -14,22 +15,22 @@ import software.amazon.awssdk.services.elasticloadbalancingv2.model.TargetHealth
|
||||
* @author Axel Uhl (D043530)
|
||||
*
|
||||
*/
|
||||
public interface TargetGroup extends Named {
|
||||
public interface TargetGroup<ShardingKey, MetricsT extends ApplicationProcessMetrics> extends Named {
|
||||
AwsRegion getRegion();
|
||||
|
||||
Map<AwsInstance, TargetHealth> getRegisteredTargets();
|
||||
Map<AwsInstance<ShardingKey, MetricsT>, TargetHealth> getRegisteredTargets();
|
||||
|
||||
default void addTarget(AwsInstance target) {
|
||||
default void addTarget(AwsInstance<ShardingKey, MetricsT> target) {
|
||||
addTargets(Collections.singleton(target));
|
||||
}
|
||||
|
||||
void addTargets(Iterable<AwsInstance> targets);
|
||||
void addTargets(Iterable<AwsInstance<ShardingKey, MetricsT>> targets);
|
||||
|
||||
default void removeTarget(AwsInstance target) {
|
||||
default void removeTarget(AwsInstance<ShardingKey, MetricsT> target) {
|
||||
removeTargets(Collections.singleton(target));
|
||||
}
|
||||
|
||||
void removeTargets(Iterable<AwsInstance> targets);
|
||||
void removeTargets(Iterable<AwsInstance<ShardingKey, MetricsT>> targets);
|
||||
|
||||
String getTargetGroupArn();
|
||||
}
|
||||
+3
-2
@@ -9,11 +9,12 @@ import java.util.TimeZone;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.landscape.MachineImage;
|
||||
import com.sap.sse.landscape.Region;
|
||||
import com.sap.sse.landscape.application.ApplicationProcessMetrics;
|
||||
import com.sap.sse.landscape.aws.AwsInstance;
|
||||
|
||||
import software.amazon.awssdk.services.ec2.model.Image;
|
||||
|
||||
public class AmazonMachineImage implements MachineImage<AwsInstance> {
|
||||
public class AmazonMachineImage<ShardingKey, MetricsT extends ApplicationProcessMetrics> implements MachineImage<AwsInstance<ShardingKey, MetricsT>> {
|
||||
private final Image image;
|
||||
private final Region region;
|
||||
|
||||
@@ -46,7 +47,7 @@ public class AmazonMachineImage implements MachineImage<AwsInstance> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AmazonMachineImage updateAllPackages() {
|
||||
public AmazonMachineImage<ShardingKey, MetricsT> updateAllPackages() {
|
||||
// TODO Implement MachineImage<AwsInstance>.updateAllPackages(...)
|
||||
return null;
|
||||
}
|
||||
|
||||
+7
-7
@@ -39,7 +39,7 @@ public class ApacheReverseProxy<ShardingKey, MetricsT extends ApplicationProcess
|
||||
super(name);
|
||||
this.landscape = landscape;
|
||||
this.region = region;
|
||||
final TargetGroup targetGroup = landscape.createTargetGroup(region, getTargetGroupName(), /* port */ 80,
|
||||
final TargetGroup<ShardingKey, MetricsT> targetGroup = landscape.createTargetGroup(region, getTargetGroupName(), /* port */ 80,
|
||||
getHealthCheckUrl(), /* health check port */ 80);
|
||||
targetGroupArn = targetGroup.getTargetGroupArn();
|
||||
for (final Entry<AwsAvailabilityZone, Integer> e : numberOfInstancesPerAz.entrySet()) {
|
||||
@@ -98,19 +98,19 @@ public class ApacheReverseProxy<ShardingKey, MetricsT extends ApplicationProcess
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AwsInstance> getHosts() {
|
||||
public Iterable<AwsInstance<ShardingKey, MetricsT>> getHosts() {
|
||||
// TODO Implement ReverseProxy.getHosts(...)
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AwsInstance> addHosts(InstanceType instanceType, AwsAvailabilityZone az, int numberOfHostsToAdd) {
|
||||
public Iterable<AwsInstance<ShardingKey, MetricsT>> addHosts(InstanceType instanceType, AwsAvailabilityZone az, int numberOfHostsToAdd) {
|
||||
// TODO Implement ReverseProxy.addHost(...)
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeHost(AwsInstance host) {
|
||||
public void removeHost(AwsInstance<ShardingKey, MetricsT> host) {
|
||||
assert Util.contains(getHosts(), host);
|
||||
if (Util.size(getHosts()) == 1) {
|
||||
throw new IllegalStateException("Trying to remove the last hosts of reverse proxy "+this+". Use terminate() instead");
|
||||
@@ -120,16 +120,16 @@ public class ApacheReverseProxy<ShardingKey, MetricsT extends ApplicationProcess
|
||||
|
||||
@Override
|
||||
public void terminate() {
|
||||
Set<AwsInstance> hosts = new HashSet<>();
|
||||
Set<AwsInstance<ShardingKey, MetricsT>> hosts = new HashSet<>();
|
||||
Util.addAll(getHosts(), hosts);
|
||||
for (final AwsInstance host : hosts) {
|
||||
for (final AwsInstance<ShardingKey, MetricsT> host : hosts) {
|
||||
landscape.terminate(host);
|
||||
}
|
||||
landscape.deleteTargetGroup(getTargetGroup());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetGroup getTargetGroup() {
|
||||
public TargetGroup<ShardingKey, MetricsT> getTargetGroup() {
|
||||
return landscape.getTargetGroup(region, getTargetGroupName(), targetGroupArn);
|
||||
}
|
||||
}
|
||||
+9
-1
@@ -21,9 +21,11 @@ import com.sap.sse.landscape.Log;
|
||||
import com.sap.sse.landscape.Metrics;
|
||||
import com.sap.sse.landscape.Process;
|
||||
import com.sap.sse.landscape.SecurityGroup;
|
||||
import com.sap.sse.landscape.application.ApplicationProcessMetrics;
|
||||
import com.sap.sse.landscape.aws.AwsAvailabilityZone;
|
||||
import com.sap.sse.landscape.aws.AwsInstance;
|
||||
import com.sap.sse.landscape.aws.AwsLandscape;
|
||||
import com.sap.sse.landscape.aws.ReverseProxy;
|
||||
import com.sap.sse.landscape.aws.SshCommandChannel;
|
||||
import com.sap.sse.landscape.ssh.JCraftLogAdapter;
|
||||
import com.sap.sse.landscape.ssh.SSHKeyPair;
|
||||
@@ -31,7 +33,7 @@ import com.sap.sse.landscape.ssh.YesUserInfo;
|
||||
|
||||
import software.amazon.awssdk.services.ec2.model.Instance;
|
||||
|
||||
public class AwsInstanceImpl implements AwsInstance {
|
||||
public class AwsInstanceImpl<ShardingKey, MetricsT extends ApplicationProcessMetrics> implements AwsInstance<ShardingKey, MetricsT> {
|
||||
private final static Logger logger = Logger.getLogger(AwsInstanceImpl.class.getName());
|
||||
private static final String ROOT_USER_NAME = "root";
|
||||
private final String instanceId;
|
||||
@@ -185,6 +187,12 @@ public class AwsInstanceImpl implements AwsInstance {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReverseProxy<ShardingKey, MetricsT> getReverseProxy() {
|
||||
// TODO Implement AwsInstanceImpl.getReverseProxy(...)
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInstanceId() {
|
||||
return instanceId;
|
||||
|
||||
+12
-12
@@ -275,10 +275,10 @@ public class AwsLandscapeImpl<ShardingKey, MetricsT extends ApplicationProcessMe
|
||||
}
|
||||
|
||||
@Override
|
||||
public AmazonMachineImage getImage(com.sap.sse.landscape.Region region, String imageId) {
|
||||
public AmazonMachineImage<ShardingKey, MetricsT> getImage(com.sap.sse.landscape.Region region, String imageId) {
|
||||
final DescribeImagesResponse response = getEc2Client(getRegion(region))
|
||||
.describeImages(DescribeImagesRequest.builder().imageIds(imageId).build());
|
||||
return new AmazonMachineImage(response.images().iterator().next(), region);
|
||||
return new AmazonMachineImage<>(response.images().iterator().next(), region);
|
||||
}
|
||||
|
||||
private AwsCredentials getCredentials() {
|
||||
@@ -334,7 +334,7 @@ public class AwsLandscapeImpl<ShardingKey, MetricsT extends ApplicationProcessMe
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AwsInstance> launchHosts(int numberOfHostsToLaunch, MachineImage<AwsInstance> fromImage,
|
||||
public Iterable<AwsInstance<ShardingKey, MetricsT>> launchHosts(int numberOfHostsToLaunch, MachineImage<AwsInstance<ShardingKey, MetricsT>> fromImage,
|
||||
InstanceType instanceType, AwsAvailabilityZone az, String keyName, Iterable<SecurityGroup> securityGroups) {
|
||||
if (!fromImage.getRegion().equals(az.getRegion())) {
|
||||
throw new IllegalArgumentException("Trying to launch an instance in region "+az.getRegion()+
|
||||
@@ -351,15 +351,15 @@ public class AwsLandscapeImpl<ShardingKey, MetricsT extends ApplicationProcessMe
|
||||
.securityGroupIds(Util.mapToArrayList(securityGroups, sg->sg.getId())).build();
|
||||
logger.info("Launching instance(s): "+launchRequest);
|
||||
final RunInstancesResponse response = getEc2Client(getRegion(az.getRegion())).runInstances(launchRequest);
|
||||
final List<AwsInstance> result = new ArrayList<>();
|
||||
final List<AwsInstance<ShardingKey, MetricsT>> result = new ArrayList<>();
|
||||
for (final Instance instance : response.instances()) {
|
||||
result.add(new AwsInstanceImpl(instance.instanceId(), az, this));
|
||||
result.add(new AwsInstanceImpl<>(instance.instanceId(), az, this));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void terminate(AwsInstance host) {
|
||||
public void terminate(AwsInstance<ShardingKey, MetricsT> host) {
|
||||
logger.info("Terminating instance "+host);
|
||||
getEc2Client(getRegion(host.getAvailabilityZone().getRegion())).terminateInstances(
|
||||
TerminateInstancesRequest.builder().instanceIds(host.getInstanceId()).build());
|
||||
@@ -376,7 +376,7 @@ public class AwsLandscapeImpl<ShardingKey, MetricsT extends ApplicationProcessMe
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetGroup createTargetGroup(AwsRegion region, String targetGroupName, int port, String healthCheckPath, int healthCheckPort) {
|
||||
public TargetGroup<ShardingKey, MetricsT> createTargetGroup(AwsRegion region, String targetGroupName, int port, String healthCheckPath, int healthCheckPort) {
|
||||
final ElasticLoadBalancingV2Client loadBalancingClient = getLoadBalancingClient(getRegion(region));
|
||||
final software.amazon.awssdk.services.elasticloadbalancingv2.model.TargetGroup targetGroup =
|
||||
loadBalancingClient.createTargetGroup(CreateTargetGroupRequest.builder()
|
||||
@@ -399,7 +399,7 @@ public class AwsLandscapeImpl<ShardingKey, MetricsT extends ApplicationProcessMe
|
||||
.attributes(TargetGroupAttribute.builder().key("stickiness.enabled").value("true").build(),
|
||||
TargetGroupAttribute.builder().key("load_balancing.algorithm.type").value("least_outstanding_requests")
|
||||
.build()).build());
|
||||
return new AwsTargetGroupImpl(this, region, targetGroupName, targetGroupArn);
|
||||
return new AwsTargetGroupImpl<>(this, region, targetGroupName, targetGroupArn);
|
||||
}
|
||||
|
||||
private String getVpcId(AwsRegion region) {
|
||||
@@ -415,19 +415,19 @@ public class AwsLandscapeImpl<ShardingKey, MetricsT extends ApplicationProcessMe
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteTargetGroup(TargetGroup targetGroup) {
|
||||
public void deleteTargetGroup(TargetGroup<ShardingKey, MetricsT> targetGroup) {
|
||||
getLoadBalancingClient(getRegion(targetGroup.getRegion())).deleteTargetGroup(DeleteTargetGroupRequest.builder().targetGroupArn(
|
||||
targetGroup.getTargetGroupArn()).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<AwsInstance, TargetHealth> getTargetHealthDescriptions(TargetGroup targetGroup) {
|
||||
final Map<AwsInstance, TargetHealth> result = new HashMap<>();
|
||||
public Map<AwsInstance<ShardingKey, MetricsT>, TargetHealth> getTargetHealthDescriptions(TargetGroup<ShardingKey, MetricsT> targetGroup) {
|
||||
final Map<AwsInstance<ShardingKey, MetricsT>, TargetHealth> result = new HashMap<>();
|
||||
final Region region = getRegion(targetGroup.getRegion());
|
||||
getLoadBalancingClient(region)
|
||||
.describeTargetHealth(DescribeTargetHealthRequest.builder().build()).targetHealthDescriptions().forEach(
|
||||
targetHealthDescription->result.put(
|
||||
new AwsInstanceImpl(targetHealthDescription.target().id(),
|
||||
new AwsInstanceImpl<>(targetHealthDescription.target().id(),
|
||||
getAvailabilityZoneByName(targetGroup.getRegion(), targetHealthDescription.target().availabilityZone()), this),
|
||||
targetHealthDescription.targetHealth()));
|
||||
return result;
|
||||
|
||||
+7
-6
@@ -3,19 +3,20 @@ package com.sap.sse.landscape.aws.impl;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sap.sse.common.impl.NamedImpl;
|
||||
import com.sap.sse.landscape.application.ApplicationProcessMetrics;
|
||||
import com.sap.sse.landscape.aws.AwsInstance;
|
||||
import com.sap.sse.landscape.aws.AwsLandscape;
|
||||
import com.sap.sse.landscape.aws.TargetGroup;
|
||||
|
||||
import software.amazon.awssdk.services.elasticloadbalancingv2.model.TargetHealth;
|
||||
|
||||
public class AwsTargetGroupImpl extends NamedImpl implements TargetGroup {
|
||||
public class AwsTargetGroupImpl<ShardingKey, MetricsT extends ApplicationProcessMetrics> extends NamedImpl implements TargetGroup<ShardingKey, MetricsT> {
|
||||
private static final long serialVersionUID = -5442598262397393201L;
|
||||
private final String arn;
|
||||
private final AwsLandscape<?, ?> landscape;
|
||||
private final AwsLandscape<ShardingKey, MetricsT> landscape;
|
||||
private final AwsRegion region;
|
||||
|
||||
public AwsTargetGroupImpl(AwsLandscape<?, ?> landscape, AwsRegion region, String targetGroupName, String arn) {
|
||||
public AwsTargetGroupImpl(AwsLandscape<ShardingKey, MetricsT> landscape, AwsRegion region, String targetGroupName, String arn) {
|
||||
super(targetGroupName);
|
||||
this.arn = arn;
|
||||
this.landscape = landscape;
|
||||
@@ -27,17 +28,17 @@ public class AwsTargetGroupImpl extends NamedImpl implements TargetGroup {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<AwsInstance, TargetHealth> getRegisteredTargets() {
|
||||
public Map<AwsInstance<ShardingKey, MetricsT>, TargetHealth> getRegisteredTargets() {
|
||||
return landscape.getTargetHealthDescriptions(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTargets(Iterable<AwsInstance> targets) {
|
||||
public void addTargets(Iterable<AwsInstance<ShardingKey, MetricsT>> targets) {
|
||||
// TODO Implement AwsTargetGroupImpl.addTargets(...)
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTargets(Iterable<AwsInstance> targets) {
|
||||
public void removeTargets(Iterable<AwsInstance<ShardingKey, MetricsT>> targets) {
|
||||
// TODO Implement AwsTargetGroupImpl.removeTargets(...)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user