mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-22 13:45:42 +00:00
bug4811: added Landscape.getMachineImageTypes
This commit is contained in:
+8
-2
@@ -83,8 +83,14 @@ public class TestProcedures {
|
||||
}
|
||||
|
||||
@Test
|
||||
public
|
||||
void testStartupEmptyMultiServerAndDeployAnotherProcess() throws Exception {
|
||||
public void testGetImageTypes() {
|
||||
final Iterable<String> imageTypes = landscape.getMachineImageTypes(region);
|
||||
assertTrue(Util.contains(imageTypes, "sailing-analytics-server"));
|
||||
assertTrue(Util.contains(imageTypes, "mongodb-server"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStartupEmptyMultiServerAndDeployAnotherProcess() throws Exception {
|
||||
final String keyName = "MyKey-"+UUID.randomUUID();
|
||||
landscape.createKeyPair(region, keyName);
|
||||
final StartMultiServer.Builder<?, String> builder = StartMultiServer.builder();
|
||||
|
||||
+2
-1
@@ -15,6 +15,7 @@ import com.sap.sailing.landscape.SailingAnalyticsProcess;
|
||||
import com.sap.sailing.landscape.impl.SailingAnalyticsProcessImpl;
|
||||
import com.sap.sse.common.Duration;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.landscape.Landscape;
|
||||
import com.sap.sse.landscape.application.ApplicationProcess;
|
||||
import com.sap.sse.landscape.aws.AmazonMachineImage;
|
||||
import com.sap.sse.landscape.aws.ApplicationProcessHost;
|
||||
@@ -270,7 +271,7 @@ implements Procedure<ShardingKey, SailingAnalyticsMetrics, SailingAnalyticsProce
|
||||
instance = getLandscape().getInstance(getHost().getInstanceId(), getHost().getRegion());
|
||||
}
|
||||
}
|
||||
upgradedAmi = getLandscape().createImage(getHost(), upgradedImageName, Optional.of(Tags.with(IMAGE_TYPE_TAG_NAME, imageType)));
|
||||
upgradedAmi = getLandscape().createImage(getHost(), upgradedImageName, Optional.of(Tags.with(Landscape.IMAGE_TYPE_TAG_NAME, imageType)));
|
||||
final TimePoint startedWaiting = TimePoint.now();
|
||||
while ((upgradedAmi=getLandscape().getImage(upgradedAmi.getRegion(), upgradedAmi.getId())).getState() != ImageState.AVAILABLE && (timeout == null || startedWaiting.until(TimePoint.now()).compareTo(timeout) < 0)) {
|
||||
logger.info("Image " + upgradedAmi.getId() + " still in state " + upgradedAmi.getState()
|
||||
|
||||
@@ -160,6 +160,12 @@ extends Landscape<ShardingKey, MetricsT, ProcessT> {
|
||||
|
||||
AmazonMachineImage<ShardingKey, MetricsT> getLatestImageWithTag(Region region, String tagName, String tagValue);
|
||||
|
||||
default AmazonMachineImage<ShardingKey, MetricsT> getLatestImageWithType(Region region, String imageType) {
|
||||
return getLatestImageWithTag(region, IMAGE_TYPE_TAG_NAME, imageType);
|
||||
}
|
||||
|
||||
Iterable<String> getMachineImageTypes(Region region);
|
||||
|
||||
void setSnapshotName(Region region, String snapshotId, String snapshotName);
|
||||
|
||||
void deleteSnapshot(Region region, String snapshotId);
|
||||
|
||||
+8
@@ -483,6 +483,14 @@ implements AwsLandscape<ShardingKey, MetricsT, ProcessT> {
|
||||
return new AmazonMachineImageImpl<>(response.images().stream().max(getMachineImageCreationDateComparator()).get(), region, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> getMachineImageTypes(com.sap.sse.landscape.Region region) {
|
||||
final DescribeImagesResponse response = getEc2Client(getRegion(region))
|
||||
.describeImages(DescribeImagesRequest.builder().filters(
|
||||
Filter.builder().name("tag-key").values(IMAGE_TYPE_TAG_NAME).build()).build());
|
||||
return Util.map(response.images(), image->image.tags().stream().filter(t->t.key().equals(IMAGE_TYPE_TAG_NAME)).findAny().get().value());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSnapshotName(com.sap.sse.landscape.Region region, String snapshotId, String snapshotName) {
|
||||
getEc2Client(getRegion(region)).createTags(b->b
|
||||
|
||||
+1
-1
@@ -253,7 +253,7 @@ extends StartHost<ShardingKey, MetricsT, ProcessT, HostT> {
|
||||
MetricsT extends ApplicationProcessMetrics,
|
||||
ProcessT extends ApplicationProcess<ShardingKey, MetricsT, ProcessT>>
|
||||
AmazonMachineImage<ShardingKey, MetricsT> getLatestImageOfType(String imageType, AwsLandscape<ShardingKey, MetricsT, ProcessT> landscape, Region region) {
|
||||
return landscape.getLatestImageWithTag(region, IMAGE_TYPE_TAG_NAME, imageType);
|
||||
return landscape.getLatestImageWithType(region, imageType);
|
||||
}
|
||||
|
||||
protected static <ShardingKey,
|
||||
|
||||
@@ -10,6 +10,14 @@ import com.sap.sse.landscape.rabbitmq.RabbitMQEndpoint;
|
||||
|
||||
public interface Landscape<ShardingKey, MetricsT extends ApplicationProcessMetrics,
|
||||
ProcessT extends ApplicationProcess<ShardingKey, MetricsT, ProcessT>> {
|
||||
/**
|
||||
* The {@link Landscape#getLatestImageWithTag(Region, String, String)} method is
|
||||
* used to obtain default images for specific host starting procedures that subclass this class. The
|
||||
* Machine Images for this are then expected to be tagged with a tag named as specified by this
|
||||
* constant ("image-type"). The tag value then must match what the subclass wants.
|
||||
*/
|
||||
String IMAGE_TYPE_TAG_NAME = "image-type";
|
||||
|
||||
/**
|
||||
* Tells which scope currently lives where
|
||||
*/
|
||||
@@ -46,4 +54,6 @@ ProcessT extends ApplicationProcess<ShardingKey, MetricsT, ProcessT>> {
|
||||
Iterable<Region> getRegions();
|
||||
|
||||
MachineImage getLatestImageWithTag(Region region, String tagName, String tagValue);
|
||||
|
||||
MachineImage getLatestImageWithType(Region region, String imageType);
|
||||
}
|
||||
|
||||
@@ -12,16 +12,6 @@ public abstract class StartHost<ShardingKey,
|
||||
HostT extends Host>
|
||||
extends AbstractProcedureImpl<ShardingKey, MetricsT, ProcessT>
|
||||
implements Procedure<ShardingKey, MetricsT, ProcessT> {
|
||||
/**
|
||||
* The {@link AwsLandscape#getLatestImageWithTag(com.sap.sse.landscape.Region, String, String)} method is
|
||||
* used to obtain default images for specific AWS host starting procedures that subclass this class. The
|
||||
* Amazon Machine Images (AMIs) for this are then expected to be tagged with a tag named as specified by this
|
||||
* constant ("image-type"). The tag value then must match what the subclass wants.
|
||||
*
|
||||
* @see #getLatestImageOfType(String)
|
||||
*/
|
||||
protected final static String IMAGE_TYPE_TAG_NAME = "image-type";
|
||||
|
||||
private final MachineImage machineImage;
|
||||
|
||||
/**
|
||||
@@ -51,7 +41,7 @@ implements Procedure<ShardingKey, MetricsT, ProcessT> {
|
||||
private String imageType;
|
||||
|
||||
protected MachineImage getMachineImage() {
|
||||
return machineImage == null ? getLandscape().getLatestImageWithTag(getRegion(), IMAGE_TYPE_TAG_NAME, getImageType()) : machineImage;
|
||||
return machineImage == null ? getLandscape().getLatestImageWithType(getRegion(), getImageType()) : machineImage;
|
||||
}
|
||||
|
||||
protected Region getRegion() {
|
||||
|
||||
Reference in New Issue
Block a user