mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
feat(timestream-influxdb): add Timestream for InfluxDB backed by InfluxDB 2.x containers (#3683)
* feat(timestream-influxdb): add Timestream for InfluxDB backed by InfluxDB 2.x containers Implements all 24 AmazonTimestreamInfluxDB operations; DB instances and read replica clusters run real influxdb:2.7 containers. * Fix #2566 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * fix(timestream-influxdb): reject unsupported RestoreFromDbBackup parameters Point-in-time restore needs a continuous backup, and REPLACE_EXISTING accepts no configuration overrides, so both are rejected instead of silently restoring on-demand data or dropping the overrides. * Fix #2566 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * style(timestream-influxdb): import the classes used instead of naming them inline Replaces the inline fully-qualified LinkedHashMap, Comparator, Predicate and TimestreamInfluxDbService references with imports. * Fix #2566 Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> --------- Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>
This commit is contained in:
1 parent
918a09f54a
commit
eb787672b8
27 files changed
+4202
-4
No files matched your search
@@ -741,6 +741,7 @@ public interface EmulatorConfig {
|
||||
BcmDataExportsServiceConfig bcmDataExports();
|
||||
OamServiceConfig oam();
|
||||
BcmPricingCalculatorServiceConfig bcmPricingCalculator();
|
||||
TimestreamInfluxDbServiceConfig timestreamInfluxdb();
|
||||
ConfigServiceConfig configservice();
|
||||
CloudTrailServiceConfig cloudtrail();
|
||||
CloudControlServiceConfig cloudcontrol();
|
||||
@@ -2075,6 +2076,34 @@ public interface EmulatorConfig {
|
||||
boolean enabled();
|
||||
}
|
||||
|
||||
interface TimestreamInfluxDbServiceConfig {
|
||||
@WithDefault("true")
|
||||
boolean enabled();
|
||||
|
||||
/** When true, DB instances and clusters reach AVAILABLE without a backing InfluxDB container. */
|
||||
@WithDefault("false")
|
||||
boolean mock();
|
||||
|
||||
/** InfluxDB 2.x image backing DB instances. Env: FLOCI_SERVICES_TIMESTREAM_INFLUXDB_DEFAULT_IMAGE */
|
||||
@WithDefault("influxdb:2.7")
|
||||
String defaultImage();
|
||||
|
||||
/** Lowest host port the InfluxDB HTTP listener (container port 8086) is published on. */
|
||||
@WithDefault("8086")
|
||||
int hostPortBase();
|
||||
|
||||
/** Highest host port the InfluxDB HTTP listener is published on. */
|
||||
@WithDefault("8185")
|
||||
int hostPortMax();
|
||||
|
||||
/** Seconds to wait for a started InfluxDB container to answer its health check. */
|
||||
@WithDefault("120")
|
||||
int readinessTimeoutSeconds();
|
||||
|
||||
/** Docker network to attach InfluxDB containers to. Empty uses the default network. */
|
||||
Optional<String> dockerNetwork();
|
||||
}
|
||||
|
||||
interface BcmDataExportsServiceConfig {
|
||||
@WithDefault("true")
|
||||
boolean enabled();
|
||||
|
||||
@@ -17,6 +17,7 @@ import io.github.hectorvent.floci.services.sns.SnsJsonHandler;
|
||||
import io.github.hectorvent.floci.services.sqs.SqsJsonHandler;
|
||||
import io.github.hectorvent.floci.services.stepfunctions.StepFunctionsJsonHandler;
|
||||
import io.github.hectorvent.floci.services.swf.SwfJsonHandler;
|
||||
import io.github.hectorvent.floci.services.timestreaminfluxdb.TimestreamInfluxDbJsonHandler;
|
||||
import io.github.hectorvent.floci.services.verifiedpermissions.VerifiedPermissionsJsonHandler;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.*;
|
||||
@@ -55,6 +56,7 @@ public class AwsJsonController {
|
||||
private final MarketplaceJsonHandler marketplaceJsonHandler;
|
||||
private final VerifiedPermissionsJsonHandler verifiedPermissionsJsonHandler;
|
||||
private final BcmPricingCalculatorJsonHandler bcmPricingCalculatorJsonHandler;
|
||||
private final TimestreamInfluxDbJsonHandler timestreamInfluxDbJsonHandler;
|
||||
|
||||
@Inject
|
||||
public AwsJsonController(ObjectMapper objectMapper, ResolvedServiceCatalog catalog,
|
||||
@@ -69,7 +71,8 @@ public class AwsJsonController {
|
||||
NetworkFirewallJsonHandler networkFirewallJsonHandler,
|
||||
MarketplaceJsonHandler marketplaceJsonHandler,
|
||||
VerifiedPermissionsJsonHandler verifiedPermissionsJsonHandler,
|
||||
BcmPricingCalculatorJsonHandler bcmPricingCalculatorJsonHandler) {
|
||||
BcmPricingCalculatorJsonHandler bcmPricingCalculatorJsonHandler,
|
||||
TimestreamInfluxDbJsonHandler timestreamInfluxDbJsonHandler) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.strictBodyReader = objectMapper.reader().with(DeserializationFeature.FAIL_ON_TRAILING_TOKENS);
|
||||
this.catalog = catalog;
|
||||
@@ -86,6 +89,7 @@ public class AwsJsonController {
|
||||
this.marketplaceJsonHandler = marketplaceJsonHandler;
|
||||
this.verifiedPermissionsJsonHandler = verifiedPermissionsJsonHandler;
|
||||
this.bcmPricingCalculatorJsonHandler = bcmPricingCalculatorJsonHandler;
|
||||
this.timestreamInfluxDbJsonHandler = timestreamInfluxDbJsonHandler;
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -147,6 +151,7 @@ public class AwsJsonController {
|
||||
case "marketplace" -> marketplaceJsonHandler.handle(action, request, region);
|
||||
case "verifiedpermissions" -> verifiedPermissionsJsonHandler.handle(action, request, region);
|
||||
case "bcm-pricing-calculator" -> bcmPricingCalculatorJsonHandler.handle(action, request, region);
|
||||
case "timestream-influxdb" -> timestreamInfluxDbJsonHandler.handle(action, request, region);
|
||||
default -> null;
|
||||
};
|
||||
// catalog.matchTarget is protocol-agnostic: a JSON 1.1 target
|
||||
|
||||
@@ -184,7 +184,7 @@ public class ResolvedServiceCatalog {
|
||||
protocols(ServiceProtocol.QUERY),
|
||||
Set.of(), Set.of("neptune"), Set.of(), Set.of()),
|
||||
descriptor("docdb", "docdb", config.services().docdb().enabled(), true,
|
||||
"docdb", config.storage().mode(),
|
||||
"docdb", config.storage().mode(),
|
||||
5000L, AwsNamespaces.RDS, ServiceProtocol.QUERY,
|
||||
protocols(ServiceProtocol.QUERY),
|
||||
Set.of(), Set.of("docdb"), Set.of(), Set.of()),
|
||||
@@ -583,6 +583,11 @@ public class ResolvedServiceCatalog {
|
||||
"bcmpricingcalculator", config.storage().mode(), 5000L, null, ServiceProtocol.JSON,
|
||||
protocols(ServiceProtocol.JSON),
|
||||
Set.of("AWSBCMPricingCalculator."), Set.of("bcm-pricing-calculator"), Set.of(), Set.of()),
|
||||
descriptor("timestream-influxdb", "timestreaminfluxdb",
|
||||
config.services().timestreamInfluxdb().enabled(), true,
|
||||
"timestreaminfluxdb", config.storage().mode(), 5000L, null, ServiceProtocol.JSON,
|
||||
protocols(ServiceProtocol.JSON),
|
||||
Set.of("AmazonTimestreamInfluxDB."), Set.of("timestream-influxdb"), Set.of(), Set.of()),
|
||||
descriptor("bcm-data-exports", "bcmdataexports", config.services().bcmDataExports().enabled(), true,
|
||||
"bcmdataexports", config.storage().mode(), 5000L, null, ServiceProtocol.JSON,
|
||||
protocols(ServiceProtocol.JSON),
|
||||
|
||||
@@ -34,6 +34,7 @@ import io.github.hectorvent.floci.services.memorydb.container.MemoryDbContainerM
|
||||
import io.github.hectorvent.floci.services.memorydb.proxy.MemoryDbProxyManager;
|
||||
import io.github.hectorvent.floci.services.rds.container.RdsContainerManager;
|
||||
import io.github.hectorvent.floci.services.rds.proxy.RdsProxyManager;
|
||||
import io.github.hectorvent.floci.services.timestreaminfluxdb.TimestreamInfluxDbService;
|
||||
import io.quarkus.runtime.Quarkus;
|
||||
import io.quarkus.runtime.ShutdownDelayInitiatedEvent;
|
||||
import io.quarkus.runtime.ShutdownEvent;
|
||||
@@ -84,6 +85,7 @@ public class EmulatorLifecycle {
|
||||
private final RabbitMqManager rabbitMqManager;
|
||||
private final FlinkContainerManager flinkContainerManager;
|
||||
private final RdsService rdsService;
|
||||
private final TimestreamInfluxDbService timestreamInfluxDbService;
|
||||
private final ElbV2Service elbV2Service;
|
||||
private final ElbClassicService elbClassicService;
|
||||
private final InitializationHooksRunner initializationHooksRunner;
|
||||
@@ -118,6 +120,7 @@ public class EmulatorLifecycle {
|
||||
RabbitMqManager rabbitMqManager,
|
||||
FlinkContainerManager flinkContainerManager,
|
||||
RdsService rdsService,
|
||||
TimestreamInfluxDbService timestreamInfluxDbService,
|
||||
ElbV2Service elbV2Service,
|
||||
ElbClassicService elbClassicService,
|
||||
InitializationHooksRunner initializationHooksRunner,
|
||||
@@ -151,6 +154,7 @@ public class EmulatorLifecycle {
|
||||
this.rabbitMqManager = rabbitMqManager;
|
||||
this.flinkContainerManager = flinkContainerManager;
|
||||
this.rdsService = rdsService;
|
||||
this.timestreamInfluxDbService = timestreamInfluxDbService;
|
||||
this.elbV2Service = elbV2Service;
|
||||
this.elbClassicService = elbClassicService;
|
||||
this.initializationHooksRunner = initializationHooksRunner;
|
||||
@@ -207,6 +211,9 @@ public class EmulatorLifecycle {
|
||||
dynamodbStreamsPoller.startPersistedPollers();
|
||||
pipesService.startPersistedPollers();
|
||||
rdsService.restorePersistedRuntime();
|
||||
if (config.services().timestreamInfluxdb().enabled()) {
|
||||
timestreamInfluxDbService.restorePersistedRuntime();
|
||||
}
|
||||
if (config.services().elasticache().enabled()) {
|
||||
elastiCacheService.restorePersistedRuntime().exceptionally(ex -> {
|
||||
LOG.warnv("ElastiCache cluster-mode restore failed: {0}", ex.getMessage());
|
||||
|
||||
+299
@@ -0,0 +1,299 @@
|
||||
package io.github.hectorvent.floci.services.timestreaminfluxdb;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.common.JsonErrorResponseUtils;
|
||||
import io.github.hectorvent.floci.core.common.PaginatedResult;
|
||||
import io.github.hectorvent.floci.services.timestreaminfluxdb.TimestreamInfluxDbService.Reported;
|
||||
import io.github.hectorvent.floci.services.timestreaminfluxdb.TimestreamInfluxDbService.RestoreResult;
|
||||
import io.github.hectorvent.floci.services.timestreaminfluxdb.model.DbBackup;
|
||||
import io.github.hectorvent.floci.services.timestreaminfluxdb.model.DbCluster;
|
||||
import io.github.hectorvent.floci.services.timestreaminfluxdb.model.DbInstance;
|
||||
import io.github.hectorvent.floci.services.timestreaminfluxdb.model.DbParameterGroup;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
@ApplicationScoped
|
||||
public class TimestreamInfluxDbJsonHandler {
|
||||
|
||||
private final TimestreamInfluxDbService service;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
@Inject
|
||||
public TimestreamInfluxDbJsonHandler(TimestreamInfluxDbService service, ObjectMapper objectMapper) {
|
||||
this.service = service;
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
public Response handle(String action, JsonNode request, String region) {
|
||||
return switch (action) {
|
||||
case "CreateDbInstance" -> ok(reportedInstance(service.createDbInstance(request, region)));
|
||||
case "GetDbInstance" -> ok(instanceNode(service.getDbInstance(request, region), null));
|
||||
case "ListDbInstances" -> ok(page(service.listDbInstances(request, region), this::instanceSummary));
|
||||
case "UpdateDbInstance" -> ok(reportedInstance(service.updateDbInstance(request, region)));
|
||||
case "RebootDbInstance" -> ok(reportedInstance(service.rebootDbInstance(request, region)));
|
||||
case "DeleteDbInstance" -> ok(reportedInstance(service.deleteDbInstance(request, region)));
|
||||
case "CreateDbCluster" -> ok(clusterStatus(service.createDbCluster(request, region)));
|
||||
case "GetDbCluster" -> ok(clusterNode(service.getDbCluster(request, region)));
|
||||
case "ListDbClusters" -> ok(page(service.listDbClusters(request, region), this::clusterSummary));
|
||||
case "ListDbInstancesForCluster" -> ok(page(service.listDbInstancesForCluster(request, region),
|
||||
this::clusterMemberSummary));
|
||||
case "UpdateDbCluster" -> ok(clusterStatusOnly(service.updateDbCluster(request, region)));
|
||||
case "RebootDbCluster" -> ok(clusterStatusOnly(service.rebootDbCluster(request, region)));
|
||||
case "DeleteDbCluster" -> ok(clusterStatusOnly(service.deleteDbCluster(request, region)));
|
||||
case "CreateDbParameterGroup" -> ok(parameterGroupNode(service.createDbParameterGroup(request, region)));
|
||||
case "GetDbParameterGroup" -> ok(parameterGroupNode(service.getDbParameterGroup(request, region)));
|
||||
case "ListDbParameterGroups" -> ok(page(service.listDbParameterGroups(request, region),
|
||||
this::parameterGroupSummary));
|
||||
case "CreateDbBackup" -> ok(reportedBackup(service.createDbBackup(request, region)));
|
||||
case "GetDbBackup" -> ok(backupNode(service.getDbBackup(request, region), null));
|
||||
case "ListDbBackups" -> ok(page(service.listDbBackups(request, region), this::backupSummary));
|
||||
case "DeleteDbBackup" -> ok(reportedBackup(service.deleteDbBackup(request, region)));
|
||||
case "RestoreFromDbBackup" -> ok(restoreNode(service.restoreFromDbBackup(request, region)));
|
||||
case "ListTagsForResource" -> ok(tagsNode(service.listTagsForResource(request)));
|
||||
case "TagResource" -> {
|
||||
service.tagResource(request);
|
||||
yield ok(objectMapper.createObjectNode());
|
||||
}
|
||||
case "UntagResource" -> {
|
||||
service.untagResource(request);
|
||||
yield ok(objectMapper.createObjectNode());
|
||||
}
|
||||
default -> JsonErrorResponseUtils.createUnknownOperationErrorResponse("AmazonTimestreamInfluxDB." + action);
|
||||
};
|
||||
}
|
||||
|
||||
private ObjectNode reportedInstance(Reported<DbInstance> reported) {
|
||||
return instanceNode(reported.resource(), reported.status());
|
||||
}
|
||||
|
||||
private ObjectNode reportedBackup(Reported<DbBackup> reported) {
|
||||
return backupNode(reported.resource(), reported.status());
|
||||
}
|
||||
|
||||
private ObjectNode instanceNode(DbInstance instance, String reportedStatus) {
|
||||
String status = reportedStatus != null ? reportedStatus : instance.getStatus();
|
||||
ObjectNode node = instanceSummary(instance);
|
||||
node.put("status", status);
|
||||
putStrings(node, "vpcSubnetIds", instance.getVpcSubnetIds());
|
||||
put(node, "publiclyAccessible", instance.getPubliclyAccessible());
|
||||
putStrings(node, "vpcSecurityGroupIds", instance.getVpcSecurityGroupIds());
|
||||
put(node, "dbParameterGroupIdentifier", instance.getDbParameterGroupIdentifier());
|
||||
put(node, "availabilityZone", instance.getAvailabilityZone());
|
||||
put(node, "secondaryAvailabilityZone", instance.getSecondaryAvailabilityZone());
|
||||
putJson(node, "logDeliveryConfiguration", instance.getLogDeliveryConfiguration());
|
||||
if (!"CREATING".equals(status)) {
|
||||
put(node, "influxAuthParametersSecretArn", instance.getInfluxAuthParametersSecretArn());
|
||||
}
|
||||
put(node, "dbClusterId", instance.getDbClusterId());
|
||||
put(node, "instanceMode", instance.getInstanceMode());
|
||||
if (instance.getDbClusterId() != null) {
|
||||
putStrings(node, "instanceModes", instance.getInstanceModes());
|
||||
}
|
||||
putJson(node, "maintenanceSchedule", instance.getMaintenanceSchedule());
|
||||
putJson(node, "dbBackupConfigurations", instance.getDbBackupConfigurations());
|
||||
put(node, "kmsKeyId", instance.getKmsKeyId());
|
||||
return node;
|
||||
}
|
||||
|
||||
private ObjectNode instanceSummary(DbInstance instance) {
|
||||
ObjectNode node = objectMapper.createObjectNode();
|
||||
node.put("id", instance.getId());
|
||||
node.put("name", instance.getName());
|
||||
node.put("arn", instance.getArn());
|
||||
put(node, "status", instance.getStatus());
|
||||
put(node, "endpoint", instance.getEndpoint());
|
||||
put(node, "port", instance.getPort());
|
||||
put(node, "networkType", instance.getNetworkType());
|
||||
put(node, "dbInstanceType", instance.getDbInstanceType());
|
||||
put(node, "dbStorageType", instance.getDbStorageType());
|
||||
put(node, "allocatedStorage", instance.getAllocatedStorage());
|
||||
put(node, "deploymentType", instance.getDeploymentType());
|
||||
return node;
|
||||
}
|
||||
|
||||
private ObjectNode clusterMemberSummary(DbInstance instance) {
|
||||
ObjectNode node = instanceSummary(instance);
|
||||
put(node, "instanceMode", instance.getInstanceMode());
|
||||
putStrings(node, "instanceModes", instance.getInstanceModes());
|
||||
return node;
|
||||
}
|
||||
|
||||
private ObjectNode clusterStatus(Reported<DbCluster> reported) {
|
||||
ObjectNode node = objectMapper.createObjectNode();
|
||||
node.put("dbClusterId", reported.resource().getId());
|
||||
node.put("dbClusterStatus", reported.status());
|
||||
return node;
|
||||
}
|
||||
|
||||
private ObjectNode clusterStatusOnly(Reported<DbCluster> reported) {
|
||||
ObjectNode node = objectMapper.createObjectNode();
|
||||
node.put("dbClusterStatus", reported.status());
|
||||
return node;
|
||||
}
|
||||
|
||||
private ObjectNode clusterNode(DbCluster cluster) {
|
||||
ObjectNode node = clusterSummary(cluster);
|
||||
put(node, "publiclyAccessible", cluster.getPubliclyAccessible());
|
||||
put(node, "dbParameterGroupIdentifier", cluster.getDbParameterGroupIdentifier());
|
||||
putJson(node, "logDeliveryConfiguration", cluster.getLogDeliveryConfiguration());
|
||||
putJson(node, "maintenanceSchedule", cluster.getMaintenanceSchedule());
|
||||
if (!"CREATING".equals(cluster.getStatus())) {
|
||||
put(node, "influxAuthParametersSecretArn", cluster.getInfluxAuthParametersSecretArn());
|
||||
}
|
||||
putStrings(node, "vpcSubnetIds", cluster.getVpcSubnetIds());
|
||||
putStrings(node, "vpcSecurityGroupIds", cluster.getVpcSecurityGroupIds());
|
||||
put(node, "failoverMode", cluster.getFailoverMode());
|
||||
putJson(node, "clusterConfiguration", cluster.getClusterConfiguration());
|
||||
putJson(node, "dbBackupConfigurations", cluster.getDbBackupConfigurations());
|
||||
put(node, "kmsKeyId", cluster.getKmsKeyId());
|
||||
return node;
|
||||
}
|
||||
|
||||
private ObjectNode clusterSummary(DbCluster cluster) {
|
||||
ObjectNode node = objectMapper.createObjectNode();
|
||||
node.put("id", cluster.getId());
|
||||
node.put("name", cluster.getName());
|
||||
node.put("arn", cluster.getArn());
|
||||
put(node, "status", cluster.getStatus());
|
||||
put(node, "endpoint", cluster.getEndpoint());
|
||||
put(node, "readerEndpoint", cluster.getReaderEndpoint());
|
||||
put(node, "port", cluster.getPort());
|
||||
put(node, "deploymentType", cluster.getDeploymentType());
|
||||
put(node, "dbInstanceType", cluster.getDbInstanceType());
|
||||
put(node, "networkType", cluster.getNetworkType());
|
||||
put(node, "dbStorageType", cluster.getDbStorageType());
|
||||
put(node, "allocatedStorage", cluster.getAllocatedStorage());
|
||||
put(node, "engineType", cluster.getEngineType());
|
||||
return node;
|
||||
}
|
||||
|
||||
private ObjectNode parameterGroupNode(DbParameterGroup group) {
|
||||
ObjectNode node = parameterGroupSummary(group);
|
||||
putJson(node, "parameters", group.getParameters());
|
||||
return node;
|
||||
}
|
||||
|
||||
private ObjectNode parameterGroupSummary(DbParameterGroup group) {
|
||||
ObjectNode node = objectMapper.createObjectNode();
|
||||
node.put("id", group.getId());
|
||||
node.put("name", group.getName());
|
||||
node.put("arn", group.getArn());
|
||||
put(node, "description", group.getDescription());
|
||||
return node;
|
||||
}
|
||||
|
||||
private ObjectNode backupNode(DbBackup backup, String reportedStatus) {
|
||||
ObjectNode node = backupSummary(backup);
|
||||
if (reportedStatus != null) {
|
||||
node.put("status", reportedStatus);
|
||||
}
|
||||
putJson(node, "clusterConfiguration", backup.getClusterConfiguration());
|
||||
put(node, "dbParameterGroupId", backup.getDbParameterGroupId());
|
||||
put(node, "dbInstanceType", backup.getDbInstanceType());
|
||||
putJson(node, "logDeliveryConfiguration", backup.getLogDeliveryConfiguration());
|
||||
put(node, "failoverMode", backup.getFailoverMode());
|
||||
put(node, "dbStorageType", backup.getDbStorageType());
|
||||
put(node, "allocatedStorage", backup.getAllocatedStorage());
|
||||
putStrings(node, "vpcSubnetIds", backup.getVpcSubnetIds());
|
||||
putStrings(node, "vpcSecurityGroupIds", backup.getVpcSecurityGroupIds());
|
||||
put(node, "publiclyAccessible", backup.getPubliclyAccessible());
|
||||
put(node, "port", backup.getPort());
|
||||
put(node, "networkType", backup.getNetworkType());
|
||||
put(node, "influxAuthParametersSecretArn", backup.getInfluxAuthParametersSecretArn());
|
||||
putJson(node, "maintenanceSchedule", backup.getMaintenanceSchedule());
|
||||
return node;
|
||||
}
|
||||
|
||||
private ObjectNode backupSummary(DbBackup backup) {
|
||||
ObjectNode node = objectMapper.createObjectNode();
|
||||
node.put("id", backup.getId());
|
||||
put(node, "name", backup.getName());
|
||||
node.put("arn", backup.getArn());
|
||||
put(node, "status", backup.getStatus());
|
||||
if (backup.getCreatedAt() != null) {
|
||||
node.put("createdAt", epochSeconds(backup.getCreatedAt()));
|
||||
}
|
||||
put(node, "expiresAfter", backup.getExpiresAfter());
|
||||
put(node, "dbResourceId", backup.getDbResourceId());
|
||||
put(node, "type", backup.getType());
|
||||
put(node, "engineType", backup.getEngineType());
|
||||
put(node, "deploymentType", backup.getDeploymentType());
|
||||
put(node, "kmsKeyId", backup.getKmsKeyId());
|
||||
return node;
|
||||
}
|
||||
|
||||
private ObjectNode restoreNode(RestoreResult result) {
|
||||
ObjectNode node = objectMapper.createObjectNode();
|
||||
node.put("restoredDbResourceId", result.restoredDbResourceId());
|
||||
node.put("restoreStatus", "RESTORING");
|
||||
node.put("resourceType", result.resourceType());
|
||||
put(node, "engineType", result.engineType());
|
||||
put(node, "deploymentType", result.deploymentType());
|
||||
return node;
|
||||
}
|
||||
|
||||
private ObjectNode tagsNode(Map<String, String> tags) {
|
||||
ObjectNode node = objectMapper.createObjectNode();
|
||||
ObjectNode tagNode = node.putObject("tags");
|
||||
tags.forEach(tagNode::put);
|
||||
return node;
|
||||
}
|
||||
|
||||
private <T> ObjectNode page(PaginatedResult<T> result, Function<T, ObjectNode> mapper) {
|
||||
ObjectNode node = objectMapper.createObjectNode();
|
||||
ArrayNode items = node.putArray("items");
|
||||
for (T item : result.items()) {
|
||||
items.add(mapper.apply(item));
|
||||
}
|
||||
put(node, "nextToken", result.nextToken());
|
||||
return node;
|
||||
}
|
||||
|
||||
private static Response ok(ObjectNode node) {
|
||||
return Response.ok(node).build();
|
||||
}
|
||||
|
||||
private static void put(ObjectNode node, String field, String value) {
|
||||
if (value != null) {
|
||||
node.put(field, value);
|
||||
}
|
||||
}
|
||||
|
||||
private static void put(ObjectNode node, String field, Integer value) {
|
||||
if (value != null) {
|
||||
node.put(field, value);
|
||||
}
|
||||
}
|
||||
|
||||
private static void put(ObjectNode node, String field, Boolean value) {
|
||||
if (value != null) {
|
||||
node.put(field, value);
|
||||
}
|
||||
}
|
||||
|
||||
private static void putJson(ObjectNode node, String field, JsonNode value) {
|
||||
if (value != null && !value.isNull()) {
|
||||
node.set(field, value);
|
||||
}
|
||||
}
|
||||
|
||||
private static void putStrings(ObjectNode node, String field, List<String> values) {
|
||||
if (values != null && !values.isEmpty()) {
|
||||
ArrayNode array = node.putArray(field);
|
||||
values.forEach(array::add);
|
||||
}
|
||||
}
|
||||
|
||||
private static double epochSeconds(Instant instant) {
|
||||
return instant.getEpochSecond() + instant.getNano() / 1_000_000_000.0;
|
||||
}
|
||||
}
|
||||
+1328
File diff suppressed because it is too large.
Load diff
+379
@@ -0,0 +1,379 @@
|
||||
package io.github.hectorvent.floci.services.timestreaminfluxdb;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
final class TimestreamInfluxDbValidation {
|
||||
|
||||
static final Pattern RESOURCE_NAME = Pattern.compile("[a-zA-Z][a-zA-Z0-9]*(-[a-zA-Z0-9]+)*");
|
||||
static final Pattern CLUSTER_NAME = Pattern.compile("[a-zA-z][a-zA-Z0-9]*(-[a-zA-Z0-9]+)*");
|
||||
static final Pattern IDENTIFIER = Pattern.compile("[a-zA-Z0-9]+");
|
||||
static final Pattern ARN = Pattern.compile(
|
||||
"arn:aws[a-z\\-]*:timestream\\-influxdb:([a-z0-9\\-]+):([0-9]{12}):(db\\-instance|db\\-cluster|db\\-parameter\\-group|db\\-backup)/([a-zA-Z0-9]{3,64})");
|
||||
|
||||
static final List<String> INSTANCE_TYPES = List.of("db.influx.medium", "db.influx.large", "db.influx.xlarge",
|
||||
"db.influx.2xlarge", "db.influx.4xlarge", "db.influx.8xlarge", "db.influx.12xlarge",
|
||||
"db.influx.16xlarge", "db.influx.24xlarge");
|
||||
static final List<String> STORAGE_TYPES = List.of("InfluxIOIncludedT1", "InfluxIOIncludedT2", "InfluxIOIncludedT3");
|
||||
static final List<String> INSTANCE_DEPLOYMENT_TYPES = List.of("SINGLE_AZ", "WITH_MULTIAZ_STANDBY");
|
||||
static final List<String> CLUSTER_DEPLOYMENT_TYPES = List.of("MULTI_NODE_READ_REPLICAS");
|
||||
static final List<String> RESOURCE_DEPLOYMENT_TYPES = List.of("SINGLE_AZ", "WITH_MULTIAZ_STANDBY", "MULTI_NODE_READ_REPLICAS");
|
||||
static final List<String> NETWORK_TYPES = List.of("IPV4", "DUAL");
|
||||
static final List<String> FAILOVER_MODES = List.of("AUTOMATIC", "NO_FAILOVER");
|
||||
static final List<String> RESTORE_MODES = List.of("NEW_RESOURCE", "REPLACE_EXISTING");
|
||||
|
||||
private static final List<String> AUTOMATED_BACKUP_TYPES = List.of("HOURLY", "DAILY", "WEEKLY", "MONTHLY",
|
||||
"CUSTOM_SCHEDULE", "CONTINUOUS");
|
||||
private static final List<String> DURATION_TYPES = List.of("hours", "minutes", "seconds", "milliseconds", "days");
|
||||
private static final Pattern SUBNET_ID = Pattern.compile("subnet-[a-z0-9]+");
|
||||
private static final Pattern SECURITY_GROUP_ID = Pattern.compile("sg-[a-z0-9]+");
|
||||
private static final Pattern PASSWORD = Pattern.compile("[a-zA-Z0-9]+");
|
||||
private static final Pattern BUCKET = Pattern.compile("[^_\"][^\"]*");
|
||||
private static final Pattern KMS_KEY_ID = Pattern.compile("[a-zA-Z0-9:/_\\-]+");
|
||||
private static final Pattern S3_BUCKET = Pattern.compile("[0-9a-z]+[0-9a-z\\.\\-]*[0-9a-z]+");
|
||||
private static final Pattern TIMEZONE = Pattern.compile("(UTC|[A-Za-z_]+/[A-Za-z0-9_]+(/[A-Za-z0-9_]+)?)");
|
||||
private static final Pattern MAINTENANCE_WINDOW = Pattern.compile(
|
||||
"|(Mon|Tue|Wed|Thu|Fri|Sat|Sun):([01]\\d|2[0-3]):[0-5]\\d-(Mon|Tue|Wed|Thu|Fri|Sat|Sun):([01]\\d|2[0-3]):[0-5]\\d");
|
||||
private static final Pattern CRON = Pattern.compile("cron\\(\\S+ \\S+ \\S+ \\S+ \\S+ \\S+\\)");
|
||||
private static final Set<String> ENGINE_PARAMETER_KEYS = Set.of("InfluxDBv2", "InfluxDBv3Core", "InfluxDBv3Enterprise");
|
||||
private static final Map<String, long[]> V2_NUMERIC_RANGES = Map.ofEntries(
|
||||
Map.entry("queryConcurrency", new long[]{0, 256}),
|
||||
Map.entry("queryQueueSize", new long[]{0, 256}),
|
||||
Map.entry("sessionLength", new long[]{1, 2880}),
|
||||
Map.entry("storageMaxConcurrentCompactions", new long[]{0, 64}),
|
||||
Map.entry("storageSeriesFileMaxConcurrentSnapshotCompactions", new long[]{0, 64}),
|
||||
Map.entry("storageWalMaxConcurrentWrites", new long[]{0, 256}),
|
||||
Map.entry("influxqlMaxSelectBuckets", new long[]{0, 1_000_000_000_000L}),
|
||||
Map.entry("influxqlMaxSelectPoint", new long[]{0, 1_000_000_000_000L}),
|
||||
Map.entry("influxqlMaxSelectSeries", new long[]{0, 1_000_000_000_000L}),
|
||||
Map.entry("queryInitialMemoryBytes", new long[]{0, 1_000_000_000_000L}),
|
||||
Map.entry("queryMaxMemoryBytes", new long[]{0, 1_000_000_000_000L}),
|
||||
Map.entry("queryMemoryBytes", new long[]{0, 1_000_000_000_000L}),
|
||||
Map.entry("storageCacheMaxMemorySize", new long[]{0, 1_000_000_000_000L}),
|
||||
Map.entry("storageCacheSnapshotMemorySize", new long[]{0, 1_000_000_000_000L}),
|
||||
Map.entry("storageCompactThroughputBurst", new long[]{0, 1_000_000_000_000L}),
|
||||
Map.entry("storageMaxIndexLogFileSize", new long[]{0, 1_000_000_000_000L}),
|
||||
Map.entry("storageSeriesIdSetCacheSize", new long[]{0, 1_000_000_000_000L}));
|
||||
private static final Map<String, List<String>> PARAMETER_ENUMS = Map.of(
|
||||
"logLevel", List.of("debug", "info", "error"),
|
||||
"tracingType", List.of("log", "jaeger", "disabled"),
|
||||
"logFormat", List.of("full"),
|
||||
"dataFusionRuntimeType", List.of("multi-thread", "multi-thread-alt"));
|
||||
private static final Set<Integer> RESERVED_PORTS = Set.of(2375, 2376, 7788, 7789, 7790, 7791, 7792, 7793, 7794,
|
||||
7795, 7796, 7797, 7798, 7799, 8090, 51678, 51679, 51680);
|
||||
|
||||
private TimestreamInfluxDbValidation() {
|
||||
}
|
||||
|
||||
static AwsException validation(String message) {
|
||||
return new AwsException("ValidationException", message, 400, Map.of("reason", "FIELD_VALIDATION_FAILED"));
|
||||
}
|
||||
|
||||
static AwsException notFound(String resourceType, String resourceId) {
|
||||
return new AwsException("ResourceNotFoundException",
|
||||
"The requested resource " + resourceId + " was not found or does not exist.", 400,
|
||||
Map.of("resourceId", resourceId, "resourceType", resourceType));
|
||||
}
|
||||
|
||||
static AwsException conflict(String resourceType, String resourceId, String message) {
|
||||
return new AwsException("ConflictException", message, 400,
|
||||
Map.of("resourceId", resourceId, "resourceType", resourceType));
|
||||
}
|
||||
|
||||
static String requiredString(JsonNode request, String field, int min, int max, Pattern pattern) {
|
||||
String value = optionalString(request, field, min, max, pattern);
|
||||
if (value == null) {
|
||||
throw validation(field + " is required.");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
static String optionalString(JsonNode request, String field, int min, int max, Pattern pattern) {
|
||||
JsonNode node = request.get(field);
|
||||
if (node == null || node.isNull()) {
|
||||
return null;
|
||||
}
|
||||
if (!node.isTextual()) {
|
||||
throw validation(field + " must be a string.");
|
||||
}
|
||||
String value = node.asText();
|
||||
if (value.length() < min || value.length() > max) {
|
||||
throw validation(field + " must have length between " + min + " and " + max + ".");
|
||||
}
|
||||
if (pattern != null && !pattern.matcher(value).matches()) {
|
||||
throw validation(field + " does not match the required pattern.");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
static String requiredEnum(JsonNode request, String field, List<String> allowed) {
|
||||
String value = optionalEnum(request, field, allowed);
|
||||
if (value == null) {
|
||||
throw validation(field + " is required.");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
static String optionalEnum(JsonNode request, String field, List<String> allowed) {
|
||||
String value = optionalString(request, field, 0, Integer.MAX_VALUE, null);
|
||||
if (value != null && !allowed.contains(value)) {
|
||||
throw validation(field + " must be one of " + allowed + ".");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
static Integer optionalInt(JsonNode request, String field, long min, long max) {
|
||||
JsonNode node = request.get(field);
|
||||
if (node == null || node.isNull()) {
|
||||
return null;
|
||||
}
|
||||
if (!node.isIntegralNumber() || node.asLong() < min || node.asLong() > max) {
|
||||
throw validation(field + " must be an integer between " + min + " and " + max + ".");
|
||||
}
|
||||
return node.asInt();
|
||||
}
|
||||
|
||||
static Integer requiredInt(JsonNode request, String field, long min, long max) {
|
||||
Integer value = optionalInt(request, field, min, max);
|
||||
if (value == null) {
|
||||
throw validation(field + " is required.");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
static Boolean optionalBoolean(JsonNode request, String field) {
|
||||
JsonNode node = request.get(field);
|
||||
if (node == null || node.isNull()) {
|
||||
return null;
|
||||
}
|
||||
if (!node.isBoolean()) {
|
||||
throw validation(field + " must be a boolean.");
|
||||
}
|
||||
return node.asBoolean();
|
||||
}
|
||||
|
||||
static Integer port(JsonNode request) {
|
||||
Integer port = optionalInt(request, "port", 1024, 65535);
|
||||
if (port != null && RESERVED_PORTS.contains(port)) {
|
||||
throw validation("port can't be 2375-2376, 7788-7799, 8090, or 51678-51680.");
|
||||
}
|
||||
return port;
|
||||
}
|
||||
|
||||
static String password(JsonNode request, boolean required) {
|
||||
return required
|
||||
? requiredString(request, "password", 8, 64, PASSWORD)
|
||||
: optionalString(request, "password", 8, 64, PASSWORD);
|
||||
}
|
||||
|
||||
static String bucket(JsonNode request) {
|
||||
return optionalString(request, "bucket", 2, 64, BUCKET);
|
||||
}
|
||||
|
||||
static String kmsKeyId(JsonNode request) {
|
||||
return optionalString(request, "kmsKeyId", 1, 2048, KMS_KEY_ID);
|
||||
}
|
||||
|
||||
static List<String> subnetIds(JsonNode request, boolean required) {
|
||||
return stringList(request, "vpcSubnetIds", required, 1, 6, SUBNET_ID);
|
||||
}
|
||||
|
||||
static List<String> securityGroupIds(JsonNode request, boolean required) {
|
||||
return stringList(request, "vpcSecurityGroupIds", required, 1, 5, SECURITY_GROUP_ID);
|
||||
}
|
||||
|
||||
static List<String> stringList(JsonNode request, String field, boolean required, int min, int max, Pattern member) {
|
||||
JsonNode node = request.get(field);
|
||||
if (node == null || node.isNull()) {
|
||||
if (required) {
|
||||
throw validation(field + " is required.");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (!node.isArray() || node.size() < min || node.size() > max) {
|
||||
throw validation(field + " must contain between " + min + " and " + max + " items.");
|
||||
}
|
||||
List<String> values = new ArrayList<>();
|
||||
for (JsonNode item : node) {
|
||||
if (!item.isTextual() || item.asText().length() > 64
|
||||
|| (member != null && !member.matcher(item.asText()).matches())) {
|
||||
throw validation(field + " contains an invalid value.");
|
||||
}
|
||||
values.add(item.asText());
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
static void storageForType(String storageType, Integer allocatedStorage) {
|
||||
if (allocatedStorage != null && !"InfluxIOIncludedT1".equals(storageType) && allocatedStorage < 400) {
|
||||
throw validation(storageType + " requires at least 400 GiB of allocatedStorage.");
|
||||
}
|
||||
}
|
||||
|
||||
static Map<String, String> tags(JsonNode request, String field, boolean required) {
|
||||
JsonNode node = request.get(field);
|
||||
if (node == null || node.isNull()) {
|
||||
if (required) {
|
||||
throw validation(field + " is required.");
|
||||
}
|
||||
return new LinkedHashMap<>();
|
||||
}
|
||||
if (!node.isObject() || node.size() < 1 || node.size() > 200) {
|
||||
throw validation(field + " must contain between 1 and 200 entries.");
|
||||
}
|
||||
Map<String, String> tags = new LinkedHashMap<>();
|
||||
Iterator<Map.Entry<String, JsonNode>> fields = node.fields();
|
||||
while (fields.hasNext()) {
|
||||
Map.Entry<String, JsonNode> entry = fields.next();
|
||||
String value = entry.getValue().isTextual() ? entry.getValue().asText() : null;
|
||||
if (entry.getKey().isEmpty() || entry.getKey().length() > 128 || value == null || value.length() > 256) {
|
||||
throw validation(field + " contains an invalid tag.");
|
||||
}
|
||||
tags.put(entry.getKey(), value);
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
|
||||
static List<String> tagKeys(JsonNode request) {
|
||||
List<String> keys = stringList(request, "tagKeys", true, 1, 200, null);
|
||||
for (String key : keys) {
|
||||
if (key.isEmpty() || key.length() > 128) {
|
||||
throw validation("tagKeys contains an invalid key.");
|
||||
}
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
static JsonNode logDeliveryConfiguration(JsonNode request) {
|
||||
JsonNode node = optionalObject(request, "logDeliveryConfiguration");
|
||||
if (node == null) {
|
||||
return null;
|
||||
}
|
||||
JsonNode s3 = node.get("s3Configuration");
|
||||
if (s3 == null || !s3.isObject()) {
|
||||
throw validation("logDeliveryConfiguration.s3Configuration is required.");
|
||||
}
|
||||
requiredString(s3, "bucketName", 3, 63, S3_BUCKET);
|
||||
if (optionalBoolean(s3, "enabled") == null) {
|
||||
throw validation("logDeliveryConfiguration.s3Configuration.enabled is required.");
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
static JsonNode maintenanceSchedule(JsonNode request) {
|
||||
JsonNode node = optionalObject(request, "maintenanceSchedule");
|
||||
if (node == null) {
|
||||
return null;
|
||||
}
|
||||
requiredString(node, "timezone", 1, 64, TIMEZONE);
|
||||
requiredString(node, "preferredMaintenanceWindow", 0, 19, MAINTENANCE_WINDOW);
|
||||
return node;
|
||||
}
|
||||
|
||||
static JsonNode dbBackupConfigurations(JsonNode request) {
|
||||
JsonNode node = request.get("dbBackupConfigurations");
|
||||
if (node == null || node.isNull()) {
|
||||
return null;
|
||||
}
|
||||
if (!node.isArray() || node.isEmpty() || node.size() > 4) {
|
||||
throw validation("dbBackupConfigurations must contain between 1 and 4 items.");
|
||||
}
|
||||
for (JsonNode configuration : node) {
|
||||
if (!configuration.isObject()) {
|
||||
throw validation("dbBackupConfigurations contains an invalid item.");
|
||||
}
|
||||
String type = requiredEnum(configuration, "type", AUTOMATED_BACKUP_TYPES);
|
||||
requiredInt(configuration, "retentionDays", 1, 365);
|
||||
if (optionalBoolean(configuration, "enabled") == null) {
|
||||
throw validation("dbBackupConfigurations.enabled is required.");
|
||||
}
|
||||
String schedule = optionalString(configuration, "customSchedule", 9, 256, CRON);
|
||||
if ("CUSTOM_SCHEDULE".equals(type) && schedule == null) {
|
||||
throw validation("customSchedule is required when type is CUSTOM_SCHEDULE.");
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
static String parameters(JsonNode parameters) {
|
||||
if (parameters == null || parameters.isNull()) {
|
||||
return TimestreamInfluxDbService.ENGINE_V2;
|
||||
}
|
||||
if (!parameters.isObject() || parameters.size() > 1) {
|
||||
throw validation("parameters must specify exactly one engine parameter set.");
|
||||
}
|
||||
Iterator<String> names = parameters.fieldNames();
|
||||
if (!names.hasNext()) {
|
||||
return TimestreamInfluxDbService.ENGINE_V2;
|
||||
}
|
||||
String engineKey = names.next();
|
||||
if (!ENGINE_PARAMETER_KEYS.contains(engineKey) || !parameters.get(engineKey).isObject()) {
|
||||
throw validation("parameters contains an unsupported engine parameter set: " + engineKey + ".");
|
||||
}
|
||||
JsonNode values = parameters.get(engineKey);
|
||||
validateParameterValues(values);
|
||||
return switch (engineKey) {
|
||||
case "InfluxDBv3Core" -> TimestreamInfluxDbService.ENGINE_V3_CORE;
|
||||
case "InfluxDBv3Enterprise" -> {
|
||||
requiredInt(values, "ingestQueryInstances", 1, 4);
|
||||
requiredInt(values, "queryOnlyInstances", 0, 10);
|
||||
if (optionalBoolean(values, "dedicatedCompactor") == null) {
|
||||
throw validation("dedicatedCompactor is required for InfluxDBv3Enterprise parameters.");
|
||||
}
|
||||
yield TimestreamInfluxDbService.ENGINE_V3_ENTERPRISE;
|
||||
}
|
||||
default -> {
|
||||
for (Map.Entry<String, long[]> range : V2_NUMERIC_RANGES.entrySet()) {
|
||||
optionalInt(values, range.getKey(), range.getValue()[0], range.getValue()[1]);
|
||||
}
|
||||
yield TimestreamInfluxDbService.ENGINE_V2;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static void validateParameterValues(JsonNode values) {
|
||||
Iterator<Map.Entry<String, JsonNode>> fields = values.fields();
|
||||
while (fields.hasNext()) {
|
||||
Map.Entry<String, JsonNode> entry = fields.next();
|
||||
List<String> allowed = PARAMETER_ENUMS.get(entry.getKey());
|
||||
if (allowed != null) {
|
||||
optionalEnum(values, entry.getKey(), allowed);
|
||||
}
|
||||
JsonNode value = entry.getValue();
|
||||
if (value.isObject() && value.has("durationType")) {
|
||||
requiredEnum(value, "durationType", DURATION_TYPES);
|
||||
JsonNode amount = value.get("value");
|
||||
if (amount == null || !amount.isIntegralNumber() || amount.asLong() < 0) {
|
||||
throw validation(entry.getKey() + ".value must be a non-negative integer.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static Integer maxResults(JsonNode request) {
|
||||
return optionalInt(request, "maxResults", 1, 100);
|
||||
}
|
||||
|
||||
static String nextToken(JsonNode request) {
|
||||
return optionalString(request, "nextToken", 1, Integer.MAX_VALUE, null);
|
||||
}
|
||||
|
||||
private static JsonNode optionalObject(JsonNode request, String field) {
|
||||
JsonNode node = request.get(field);
|
||||
if (node == null || node.isNull()) {
|
||||
return null;
|
||||
}
|
||||
if (!node.isObject()) {
|
||||
throw validation(field + " must be an object.");
|
||||
}
|
||||
return node;
|
||||
}
|
||||
}
|
||||
+420
@@ -0,0 +1,420 @@
|
||||
package io.github.hectorvent.floci.services.timestreaminfluxdb.container;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.github.dockerjava.api.DockerClient;
|
||||
import com.github.dockerjava.api.async.ResultCallback;
|
||||
import com.github.dockerjava.api.model.Frame;
|
||||
import com.github.dockerjava.api.model.StreamType;
|
||||
import io.github.hectorvent.floci.config.EmulatorConfig;
|
||||
import io.github.hectorvent.floci.core.common.ContainerTeardown;
|
||||
import io.github.hectorvent.floci.core.common.docker.ContainerBuilder;
|
||||
import io.github.hectorvent.floci.core.common.docker.ContainerDetector;
|
||||
import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager;
|
||||
import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager.ContainerInfo;
|
||||
import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager.EndpointInfo;
|
||||
import io.github.hectorvent.floci.core.common.docker.ContainerStorageHelper;
|
||||
import io.github.hectorvent.floci.core.common.docker.PortAllocator;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Runs the InfluxDB 2.x containers that back Timestream for InfluxDB resources. The HTTP
|
||||
* listener is published on a host port from the configured range in every topology, because no
|
||||
* Floci proxy fronts InfluxDB traffic. Data and the influx CLI configuration written by the
|
||||
* image's setup mode live on per-resource volumes, so restarts and parameter changes keep both.
|
||||
*/
|
||||
@ApplicationScoped
|
||||
public class TimestreamInfluxDbContainerManager implements ContainerTeardown {
|
||||
|
||||
static final String SERVICE = "timestream-influxdb";
|
||||
static final int INFLUX_PORT = 8086;
|
||||
private static final Logger LOG = Logger.getLogger(TimestreamInfluxDbContainerManager.class);
|
||||
private static final String DATA_PATH = "/var/lib/influxdb2";
|
||||
private static final String CONFIG_PATH = "/etc/influxdb2";
|
||||
private static final String CLI_CONFIG_FILE = CONFIG_PATH + "/influx-configs";
|
||||
private static final int READINESS_RETRY_MS = 500;
|
||||
private static final int EXEC_TIMEOUT_SECONDS = 300;
|
||||
|
||||
public record InfluxDbSetup(String username, String password, String organization, String bucket) {
|
||||
}
|
||||
|
||||
public record InfluxDbEndpoint(String containerId, String host, int port) {
|
||||
}
|
||||
|
||||
private record RunningContainer(String containerId, int hostPort) {
|
||||
}
|
||||
|
||||
private final ContainerBuilder containerBuilder;
|
||||
private final ContainerLifecycleManager lifecycleManager;
|
||||
private final ContainerDetector containerDetector;
|
||||
private final PortAllocator portAllocator;
|
||||
private final EmulatorConfig config;
|
||||
private final Map<String, RunningContainer> running = new ConcurrentHashMap<>();
|
||||
|
||||
@Inject
|
||||
public TimestreamInfluxDbContainerManager(ContainerBuilder containerBuilder,
|
||||
ContainerLifecycleManager lifecycleManager,
|
||||
ContainerDetector containerDetector,
|
||||
PortAllocator portAllocator,
|
||||
EmulatorConfig config) {
|
||||
this.containerBuilder = containerBuilder;
|
||||
this.lifecycleManager = lifecycleManager;
|
||||
this.containerDetector = containerDetector;
|
||||
this.portAllocator = portAllocator;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public boolean isDockerReachable() {
|
||||
try {
|
||||
lifecycleManager.getDockerClient().pingCmd().exec();
|
||||
return true;
|
||||
} catch (RuntimeException e) {
|
||||
LOG.debugv("Docker daemon is not reachable: {0}", e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public InfluxDbEndpoint start(String resourceId, String accountId, String region,
|
||||
InfluxDbSetup setup, Map<String, String> engineEnvironment) {
|
||||
EmulatorConfig.TimestreamInfluxDbServiceConfig serviceConfig = config.services().timestreamInfluxdb();
|
||||
String containerName = containerName(resourceId);
|
||||
LOG.infov("Starting InfluxDB container {0} for {1} using image {2}",
|
||||
containerName, resourceId, serviceConfig.defaultImage());
|
||||
|
||||
lifecycleManager.removeIfExists(containerName);
|
||||
releasePort(resourceId);
|
||||
|
||||
ContainerBuilder.Builder builder = containerBuilder.newContainer(serviceConfig.defaultImage())
|
||||
.withName(containerName)
|
||||
.withDockerNetwork(serviceConfig.dockerNetwork())
|
||||
.withLogRotation()
|
||||
.withLabels(ContainerStorageHelper.resourceIdentityLabels(SERVICE, resourceId, accountId, region));
|
||||
if (setup != null) {
|
||||
builder.withEnv("DOCKER_INFLUXDB_INIT_MODE", "setup")
|
||||
.withEnv("DOCKER_INFLUXDB_INIT_USERNAME", setup.username())
|
||||
.withEnv("DOCKER_INFLUXDB_INIT_PASSWORD", setup.password())
|
||||
.withEnv("DOCKER_INFLUXDB_INIT_ORG", setup.organization())
|
||||
.withEnv("DOCKER_INFLUXDB_INIT_BUCKET", setup.bucket());
|
||||
}
|
||||
for (Map.Entry<String, String> entry : engineEnvironment.entrySet()) {
|
||||
builder.withEnv(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
int hostPort = portAllocator.allocate(serviceConfig.hostPortBase(), serviceConfig.hostPortMax());
|
||||
builder.withPortBinding(INFLUX_PORT, hostPort);
|
||||
|
||||
ContainerInfo info;
|
||||
try {
|
||||
applyVolumes(builder, resourceId);
|
||||
info = lifecycleManager.createAndStart(builder.build());
|
||||
} catch (RuntimeException e) {
|
||||
lifecycleManager.removeIfExists(containerName);
|
||||
portAllocator.release(hostPort);
|
||||
throw e;
|
||||
}
|
||||
running.put(resourceId, new RunningContainer(info.containerId(), hostPort));
|
||||
EndpointInfo endpoint = info.getEndpoint(INFLUX_PORT);
|
||||
LOG.infov("InfluxDB container {0} for {1} listening on {2} (host port {3})",
|
||||
info.containerId(), resourceId, endpoint, String.valueOf(hostPort));
|
||||
return new InfluxDbEndpoint(info.containerId(), endpoint.host(), endpoint.port());
|
||||
}
|
||||
|
||||
public void waitUntilReady(InfluxDbEndpoint endpoint) {
|
||||
int timeoutSeconds = config.services().timestreamInfluxdb().readinessTimeoutSeconds();
|
||||
long deadline = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(timeoutSeconds);
|
||||
while (System.currentTimeMillis() < deadline) {
|
||||
if (isHealthy(endpoint)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(READINESS_RETRY_MS);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new IllegalStateException("Interrupted waiting for InfluxDB at " + endpoint.host(), e);
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("InfluxDB at " + endpoint.host() + ":" + endpoint.port()
|
||||
+ " did not become healthy within " + timeoutSeconds + "s");
|
||||
}
|
||||
|
||||
boolean isHealthy(InfluxDbEndpoint endpoint) {
|
||||
HttpURLConnection connection = null;
|
||||
try {
|
||||
connection = (HttpURLConnection) URI.create(
|
||||
"http://" + endpoint.host() + ":" + endpoint.port() + "/health").toURL().openConnection();
|
||||
connection.setConnectTimeout(1000);
|
||||
connection.setReadTimeout(1000);
|
||||
return connection.getResponseCode() == 200;
|
||||
} catch (IOException e) {
|
||||
LOG.debugv("InfluxDB health probe at {0}:{1} not ready: {2}",
|
||||
endpoint.host(), String.valueOf(endpoint.port()), e.getMessage());
|
||||
return false;
|
||||
} finally {
|
||||
if (connection != null) {
|
||||
connection.disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void restart(String containerId) {
|
||||
lifecycleManager.getDockerClient().restartContainerCmd(containerId).exec();
|
||||
}
|
||||
|
||||
public void stop(String resourceId, String containerId) {
|
||||
RunningContainer container = running.remove(resourceId);
|
||||
if (container != null) {
|
||||
portAllocator.release(container.hostPort());
|
||||
}
|
||||
String effectiveId = containerId != null ? containerId : container != null ? container.containerId() : null;
|
||||
if (effectiveId != null) {
|
||||
lifecycleManager.stopAndRemove(effectiveId, null);
|
||||
} else {
|
||||
lifecycleManager.removeIfExists(containerName(resourceId));
|
||||
}
|
||||
}
|
||||
|
||||
public void removeStorage(String resourceId) {
|
||||
if (ContainerStorageHelper.isNamedVolumeMode(config)) {
|
||||
ContainerStorageHelper.removeStorage(config, lifecycleManager, SERVICE, null, resourceId);
|
||||
ContainerStorageHelper.removeStorage(config, lifecycleManager, SERVICE, null, resourceId + "-config");
|
||||
}
|
||||
}
|
||||
|
||||
public void backup(String containerId, String backupId) {
|
||||
String workDir = "/tmp/floci-backup-" + backupId;
|
||||
execOrThrow(containerId, new String[]{"influx", "backup", workDir}, "influx backup");
|
||||
try {
|
||||
Path directory = backupDirectory();
|
||||
Files.createDirectories(directory);
|
||||
copyFromContainer(containerId, workDir, directory.resolve(backupId + ".tar"));
|
||||
copyFromContainer(containerId, CLI_CONFIG_FILE, directory.resolve(backupId + "-cli.tar"));
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException("Failed to store InfluxDB backup " + backupId, e);
|
||||
} finally {
|
||||
execQuietly(containerId, new String[]{"rm", "-rf", workDir});
|
||||
}
|
||||
}
|
||||
|
||||
public void restore(String containerId, String backupId) {
|
||||
Path directory = backupDirectory();
|
||||
String workDir = "/tmp/floci-backup-" + backupId;
|
||||
try {
|
||||
copyToContainer(containerId, directory.resolve(backupId + ".tar"), "/tmp");
|
||||
execOrThrow(containerId, new String[]{"influx", "restore", "--full", workDir}, "influx restore");
|
||||
copyToContainer(containerId, directory.resolve(backupId + "-cli.tar"), CONFIG_PATH);
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException("Failed to restore InfluxDB backup " + backupId, e);
|
||||
} finally {
|
||||
execQuietly(containerId, new String[]{"rm", "-rf", workDir});
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteBackupArtifacts(String backupId) {
|
||||
Path directory = backupDirectory();
|
||||
for (String suffix : List.of(".tar", "-cli.tar")) {
|
||||
try {
|
||||
Files.deleteIfExists(directory.resolve(backupId + suffix));
|
||||
} catch (IOException e) {
|
||||
LOG.warnv(e, "Failed to delete InfluxDB backup artifact {0}{1}", backupId, suffix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopManagedContainers() {
|
||||
List<String> resourceIds = new ArrayList<>(running.keySet());
|
||||
if (!resourceIds.isEmpty()) {
|
||||
LOG.infov("Stopping {0} Timestream for InfluxDB container(s) on shutdown", resourceIds.size());
|
||||
}
|
||||
for (String resourceId : resourceIds) {
|
||||
stop(resourceId, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps the InfluxDBv2 members of a DB parameter group onto the {@code INFLUXD_*} environment
|
||||
* variables of the same InfluxDB configuration options. Duration members become InfluxDB
|
||||
* duration strings; InfluxDB has no day unit, so days are expressed in hours.
|
||||
*/
|
||||
public static Map<String, String> engineEnvironment(JsonNode influxDbV2Parameters) {
|
||||
Map<String, String> environment = new LinkedHashMap<>();
|
||||
if (influxDbV2Parameters == null || !influxDbV2Parameters.isObject()) {
|
||||
return environment;
|
||||
}
|
||||
Iterator<Map.Entry<String, JsonNode>> fields = influxDbV2Parameters.fields();
|
||||
while (fields.hasNext()) {
|
||||
Map.Entry<String, JsonNode> field = fields.next();
|
||||
JsonNode value = field.getValue();
|
||||
String rendered = value.isObject() ? duration(value) : value.asText();
|
||||
environment.put("INFLUXD_" + upperSnake(field.getKey()), rendered);
|
||||
}
|
||||
return environment;
|
||||
}
|
||||
|
||||
private static String duration(JsonNode value) {
|
||||
long amount = value.path("value").asLong();
|
||||
return switch (value.path("durationType").asText()) {
|
||||
case "days" -> (amount * 24) + "h";
|
||||
case "hours" -> amount + "h";
|
||||
case "minutes" -> amount + "m";
|
||||
case "milliseconds" -> amount + "ms";
|
||||
default -> amount + "s";
|
||||
};
|
||||
}
|
||||
|
||||
private static String upperSnake(String camelCase) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (char c : camelCase.toCharArray()) {
|
||||
if (Character.isUpperCase(c) && !result.isEmpty()) {
|
||||
result.append('_');
|
||||
}
|
||||
result.append(Character.toUpperCase(c));
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private String containerName(String resourceId) {
|
||||
return ContainerStorageHelper.resourceName(config, SERVICE, null, resourceId);
|
||||
}
|
||||
|
||||
private void releasePort(String resourceId) {
|
||||
RunningContainer previous = running.remove(resourceId);
|
||||
if (previous != null) {
|
||||
portAllocator.release(previous.hostPort());
|
||||
}
|
||||
}
|
||||
|
||||
private void applyVolumes(ContainerBuilder.Builder builder, String resourceId) {
|
||||
if (ContainerStorageHelper.isNamedVolumeMode(config)) {
|
||||
ContainerStorageHelper.applyStorage(builder, lifecycleManager, config, SERVICE, null, resourceId, DATA_PATH);
|
||||
ContainerStorageHelper.applyStorage(builder, lifecycleManager, config, SERVICE, null,
|
||||
resourceId + "-config", CONFIG_PATH);
|
||||
return;
|
||||
}
|
||||
Path base = ContainerStorageHelper.hostResourcePath(config, SERVICE, resourceId);
|
||||
String dataDir = base.resolve("data").toAbsolutePath().toString();
|
||||
String configDir = base.resolve("config").toAbsolutePath().toString();
|
||||
if (!containerDetector.isRunningInContainer()) {
|
||||
ContainerStorageHelper.ensureHostDir(dataDir);
|
||||
ContainerStorageHelper.ensureHostDir(configDir);
|
||||
}
|
||||
builder.withBind(dataDir, DATA_PATH).withBind(configDir, CONFIG_PATH);
|
||||
}
|
||||
|
||||
private Path backupDirectory() {
|
||||
return Path.of(config.storage().persistentPath()).resolve(SERVICE).resolve("backups");
|
||||
}
|
||||
|
||||
private void copyFromContainer(String containerId, String containerPath, Path target) throws IOException {
|
||||
try (InputStream archive = lifecycleManager.getDockerClient()
|
||||
.copyArchiveFromContainerCmd(containerId, containerPath).exec()) {
|
||||
Files.copy(archive, target, StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
}
|
||||
|
||||
private void copyToContainer(String containerId, Path archive, String remotePath) throws IOException {
|
||||
try (InputStream stream = Files.newInputStream(archive)) {
|
||||
lifecycleManager.getDockerClient().copyArchiveToContainerCmd(containerId)
|
||||
.withRemotePath(remotePath)
|
||||
.withTarInputStream(stream)
|
||||
.exec();
|
||||
}
|
||||
}
|
||||
|
||||
private void execOrThrow(String containerId, String[] command, String description) {
|
||||
ExecResult result = exec(containerId, command);
|
||||
if (result.exitCode() != 0) {
|
||||
throw new IllegalStateException(description + " failed with exit code " + result.exitCode()
|
||||
+ ": " + result.stderr() + result.stdout());
|
||||
}
|
||||
}
|
||||
|
||||
private void execQuietly(String containerId, String[] command) {
|
||||
try {
|
||||
exec(containerId, command);
|
||||
} catch (RuntimeException e) {
|
||||
LOG.debugv("Cleanup command in container {0} failed: {1}", containerId, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private ExecResult exec(String containerId, String[] command) {
|
||||
DockerClient dockerClient = lifecycleManager.getDockerClient();
|
||||
String execId = dockerClient.execCreateCmd(containerId)
|
||||
.withCmd(command)
|
||||
.withAttachStdout(true)
|
||||
.withAttachStderr(true)
|
||||
.exec()
|
||||
.getId();
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
ByteArrayOutputStream stdout = new ByteArrayOutputStream();
|
||||
ByteArrayOutputStream stderr = new ByteArrayOutputStream();
|
||||
Closeable callback = dockerClient.execStartCmd(execId).exec(new ResultCallback.Adapter<Frame>() {
|
||||
@Override
|
||||
public void onNext(Frame frame) {
|
||||
if (frame.getPayload() == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (frame.getStreamType() == StreamType.STDERR) {
|
||||
stderr.write(frame.getPayload());
|
||||
} else {
|
||||
stdout.write(frame.getPayload());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LOG.warnv(e, "Failed to read output of container exec {0}", execId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable throwable) {
|
||||
LOG.warnv(throwable, "Container exec {0} failed", execId);
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
try {
|
||||
if (!latch.await(EXEC_TIMEOUT_SECONDS, TimeUnit.SECONDS)) {
|
||||
return new ExecResult(-1, stdout.toString(StandardCharsets.UTF_8), "timed out");
|
||||
}
|
||||
Long exitCode = dockerClient.inspectExecCmd(execId).exec().getExitCodeLong();
|
||||
return new ExecResult(exitCode != null ? exitCode : -1,
|
||||
stdout.toString(StandardCharsets.UTF_8), stderr.toString(StandardCharsets.UTF_8));
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new IllegalStateException("Interrupted running command in container " + containerId, e);
|
||||
} finally {
|
||||
try {
|
||||
callback.close();
|
||||
} catch (IOException e) {
|
||||
LOG.debugv("Failed to close exec callback {0}: {1}", execId, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private record ExecResult(long exitCode, String stdout, String stderr) {
|
||||
}
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
package io.github.hectorvent.floci.services.timestreaminfluxdb.model;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
public class DbBackup {
|
||||
private String id;
|
||||
private String name;
|
||||
private String arn;
|
||||
private String status;
|
||||
private Instant createdAt;
|
||||
private String expiresAfter;
|
||||
private String dbResourceId;
|
||||
private String resourceType;
|
||||
private String type;
|
||||
private String engineType;
|
||||
private String deploymentType;
|
||||
private String kmsKeyId;
|
||||
private JsonNode clusterConfiguration;
|
||||
private String dbParameterGroupId;
|
||||
private String dbInstanceType;
|
||||
private JsonNode logDeliveryConfiguration;
|
||||
private String failoverMode;
|
||||
private String dbStorageType;
|
||||
private Integer allocatedStorage;
|
||||
private List<String> vpcSubnetIds = new ArrayList<>();
|
||||
private List<String> vpcSecurityGroupIds = new ArrayList<>();
|
||||
private Boolean publiclyAccessible;
|
||||
private Integer port;
|
||||
private String networkType;
|
||||
private String influxAuthParametersSecretArn;
|
||||
private JsonNode maintenanceSchedule;
|
||||
private JsonNode dbBackupConfigurations;
|
||||
private Map<String, String> tags = new LinkedHashMap<>();
|
||||
private String accountId;
|
||||
private String region;
|
||||
private boolean dataCaptured;
|
||||
|
||||
public DbBackup() {
|
||||
}
|
||||
|
||||
public String getAccountId() { return accountId; }
|
||||
public void setAccountId(String accountId) { this.accountId = accountId; }
|
||||
public String getRegion() { return region; }
|
||||
public void setRegion(String region) { this.region = region; }
|
||||
public boolean isDataCaptured() { return dataCaptured; }
|
||||
public void setDataCaptured(boolean dataCaptured) { this.dataCaptured = dataCaptured; }
|
||||
|
||||
public String getId() { return id; }
|
||||
public void setId(String id) { this.id = id; }
|
||||
public String getName() { return name; }
|
||||
public void setName(String name) { this.name = name; }
|
||||
public String getArn() { return arn; }
|
||||
public void setArn(String arn) { this.arn = arn; }
|
||||
public String getStatus() { return status; }
|
||||
public void setStatus(String status) { this.status = status; }
|
||||
public Instant getCreatedAt() { return createdAt; }
|
||||
public void setCreatedAt(Instant createdAt) { this.createdAt = createdAt; }
|
||||
public String getExpiresAfter() { return expiresAfter; }
|
||||
public void setExpiresAfter(String expiresAfter) { this.expiresAfter = expiresAfter; }
|
||||
public String getDbResourceId() { return dbResourceId; }
|
||||
public void setDbResourceId(String dbResourceId) { this.dbResourceId = dbResourceId; }
|
||||
public String getResourceType() { return resourceType; }
|
||||
public void setResourceType(String resourceType) { this.resourceType = resourceType; }
|
||||
public String getType() { return type; }
|
||||
public void setType(String type) { this.type = type; }
|
||||
public String getEngineType() { return engineType; }
|
||||
public void setEngineType(String engineType) { this.engineType = engineType; }
|
||||
public String getDeploymentType() { return deploymentType; }
|
||||
public void setDeploymentType(String deploymentType) { this.deploymentType = deploymentType; }
|
||||
public String getKmsKeyId() { return kmsKeyId; }
|
||||
public void setKmsKeyId(String kmsKeyId) { this.kmsKeyId = kmsKeyId; }
|
||||
public JsonNode getClusterConfiguration() { return clusterConfiguration; }
|
||||
public void setClusterConfiguration(JsonNode clusterConfiguration) { this.clusterConfiguration = clusterConfiguration; }
|
||||
public String getDbParameterGroupId() { return dbParameterGroupId; }
|
||||
public void setDbParameterGroupId(String dbParameterGroupId) { this.dbParameterGroupId = dbParameterGroupId; }
|
||||
public String getDbInstanceType() { return dbInstanceType; }
|
||||
public void setDbInstanceType(String dbInstanceType) { this.dbInstanceType = dbInstanceType; }
|
||||
public JsonNode getLogDeliveryConfiguration() { return logDeliveryConfiguration; }
|
||||
public void setLogDeliveryConfiguration(JsonNode logDeliveryConfiguration) { this.logDeliveryConfiguration = logDeliveryConfiguration; }
|
||||
public String getFailoverMode() { return failoverMode; }
|
||||
public void setFailoverMode(String failoverMode) { this.failoverMode = failoverMode; }
|
||||
public String getDbStorageType() { return dbStorageType; }
|
||||
public void setDbStorageType(String dbStorageType) { this.dbStorageType = dbStorageType; }
|
||||
public Integer getAllocatedStorage() { return allocatedStorage; }
|
||||
public void setAllocatedStorage(Integer allocatedStorage) { this.allocatedStorage = allocatedStorage; }
|
||||
public List<String> getVpcSubnetIds() { return vpcSubnetIds; }
|
||||
public void setVpcSubnetIds(List<String> vpcSubnetIds) { this.vpcSubnetIds = copy(vpcSubnetIds); }
|
||||
public List<String> getVpcSecurityGroupIds() { return vpcSecurityGroupIds; }
|
||||
public void setVpcSecurityGroupIds(List<String> vpcSecurityGroupIds) { this.vpcSecurityGroupIds = copy(vpcSecurityGroupIds); }
|
||||
public Boolean getPubliclyAccessible() { return publiclyAccessible; }
|
||||
public void setPubliclyAccessible(Boolean publiclyAccessible) { this.publiclyAccessible = publiclyAccessible; }
|
||||
public Integer getPort() { return port; }
|
||||
public void setPort(Integer port) { this.port = port; }
|
||||
public String getNetworkType() { return networkType; }
|
||||
public void setNetworkType(String networkType) { this.networkType = networkType; }
|
||||
public String getInfluxAuthParametersSecretArn() { return influxAuthParametersSecretArn; }
|
||||
public void setInfluxAuthParametersSecretArn(String influxAuthParametersSecretArn) { this.influxAuthParametersSecretArn = influxAuthParametersSecretArn; }
|
||||
public JsonNode getMaintenanceSchedule() { return maintenanceSchedule; }
|
||||
public void setMaintenanceSchedule(JsonNode maintenanceSchedule) { this.maintenanceSchedule = maintenanceSchedule; }
|
||||
public JsonNode getDbBackupConfigurations() { return dbBackupConfigurations; }
|
||||
public void setDbBackupConfigurations(JsonNode dbBackupConfigurations) { this.dbBackupConfigurations = dbBackupConfigurations; }
|
||||
public Map<String, String> getTags() { return tags; }
|
||||
public void setTags(Map<String, String> tags) { this.tags = tags == null ? new LinkedHashMap<>() : new LinkedHashMap<>(tags); }
|
||||
|
||||
private static List<String> copy(List<String> values) {
|
||||
return values == null ? new ArrayList<>() : new ArrayList<>(values);
|
||||
}
|
||||
}
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
package io.github.hectorvent.floci.services.timestreaminfluxdb.model;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
public class DbCluster {
|
||||
private String id;
|
||||
private String name;
|
||||
private String arn;
|
||||
private String status;
|
||||
private String endpoint;
|
||||
private String readerEndpoint;
|
||||
private Integer port;
|
||||
private String deploymentType;
|
||||
private String dbInstanceType;
|
||||
private String networkType;
|
||||
private String dbStorageType;
|
||||
private Integer allocatedStorage;
|
||||
private String engineType;
|
||||
private Boolean publiclyAccessible;
|
||||
private String dbParameterGroupIdentifier;
|
||||
private JsonNode logDeliveryConfiguration;
|
||||
private JsonNode maintenanceSchedule;
|
||||
private String influxAuthParametersSecretArn;
|
||||
private List<String> vpcSubnetIds = new ArrayList<>();
|
||||
private List<String> vpcSecurityGroupIds = new ArrayList<>();
|
||||
private String failoverMode;
|
||||
private JsonNode clusterConfiguration;
|
||||
private JsonNode dbBackupConfigurations;
|
||||
private String kmsKeyId;
|
||||
private Instant createdAt;
|
||||
private Map<String, String> tags = new LinkedHashMap<>();
|
||||
private String accountId;
|
||||
private String region;
|
||||
private String containerId;
|
||||
|
||||
public DbCluster() {
|
||||
}
|
||||
|
||||
public String getAccountId() { return accountId; }
|
||||
public void setAccountId(String accountId) { this.accountId = accountId; }
|
||||
public String getRegion() { return region; }
|
||||
public void setRegion(String region) { this.region = region; }
|
||||
public String getContainerId() { return containerId; }
|
||||
public void setContainerId(String containerId) { this.containerId = containerId; }
|
||||
|
||||
public String getId() { return id; }
|
||||
public void setId(String id) { this.id = id; }
|
||||
public String getName() { return name; }
|
||||
public void setName(String name) { this.name = name; }
|
||||
public String getArn() { return arn; }
|
||||
public void setArn(String arn) { this.arn = arn; }
|
||||
public String getStatus() { return status; }
|
||||
public void setStatus(String status) { this.status = status; }
|
||||
public String getEndpoint() { return endpoint; }
|
||||
public void setEndpoint(String endpoint) { this.endpoint = endpoint; }
|
||||
public String getReaderEndpoint() { return readerEndpoint; }
|
||||
public void setReaderEndpoint(String readerEndpoint) { this.readerEndpoint = readerEndpoint; }
|
||||
public Integer getPort() { return port; }
|
||||
public void setPort(Integer port) { this.port = port; }
|
||||
public String getDeploymentType() { return deploymentType; }
|
||||
public void setDeploymentType(String deploymentType) { this.deploymentType = deploymentType; }
|
||||
public String getDbInstanceType() { return dbInstanceType; }
|
||||
public void setDbInstanceType(String dbInstanceType) { this.dbInstanceType = dbInstanceType; }
|
||||
public String getNetworkType() { return networkType; }
|
||||
public void setNetworkType(String networkType) { this.networkType = networkType; }
|
||||
public String getDbStorageType() { return dbStorageType; }
|
||||
public void setDbStorageType(String dbStorageType) { this.dbStorageType = dbStorageType; }
|
||||
public Integer getAllocatedStorage() { return allocatedStorage; }
|
||||
public void setAllocatedStorage(Integer allocatedStorage) { this.allocatedStorage = allocatedStorage; }
|
||||
public String getEngineType() { return engineType; }
|
||||
public void setEngineType(String engineType) { this.engineType = engineType; }
|
||||
public Boolean getPubliclyAccessible() { return publiclyAccessible; }
|
||||
public void setPubliclyAccessible(Boolean publiclyAccessible) { this.publiclyAccessible = publiclyAccessible; }
|
||||
public String getDbParameterGroupIdentifier() { return dbParameterGroupIdentifier; }
|
||||
public void setDbParameterGroupIdentifier(String dbParameterGroupIdentifier) { this.dbParameterGroupIdentifier = dbParameterGroupIdentifier; }
|
||||
public JsonNode getLogDeliveryConfiguration() { return logDeliveryConfiguration; }
|
||||
public void setLogDeliveryConfiguration(JsonNode logDeliveryConfiguration) { this.logDeliveryConfiguration = logDeliveryConfiguration; }
|
||||
public JsonNode getMaintenanceSchedule() { return maintenanceSchedule; }
|
||||
public void setMaintenanceSchedule(JsonNode maintenanceSchedule) { this.maintenanceSchedule = maintenanceSchedule; }
|
||||
public String getInfluxAuthParametersSecretArn() { return influxAuthParametersSecretArn; }
|
||||
public void setInfluxAuthParametersSecretArn(String influxAuthParametersSecretArn) { this.influxAuthParametersSecretArn = influxAuthParametersSecretArn; }
|
||||
public List<String> getVpcSubnetIds() { return vpcSubnetIds; }
|
||||
public void setVpcSubnetIds(List<String> vpcSubnetIds) { this.vpcSubnetIds = copy(vpcSubnetIds); }
|
||||
public List<String> getVpcSecurityGroupIds() { return vpcSecurityGroupIds; }
|
||||
public void setVpcSecurityGroupIds(List<String> vpcSecurityGroupIds) { this.vpcSecurityGroupIds = copy(vpcSecurityGroupIds); }
|
||||
public String getFailoverMode() { return failoverMode; }
|
||||
public void setFailoverMode(String failoverMode) { this.failoverMode = failoverMode; }
|
||||
public JsonNode getClusterConfiguration() { return clusterConfiguration; }
|
||||
public void setClusterConfiguration(JsonNode clusterConfiguration) { this.clusterConfiguration = clusterConfiguration; }
|
||||
public JsonNode getDbBackupConfigurations() { return dbBackupConfigurations; }
|
||||
public void setDbBackupConfigurations(JsonNode dbBackupConfigurations) { this.dbBackupConfigurations = dbBackupConfigurations; }
|
||||
public String getKmsKeyId() { return kmsKeyId; }
|
||||
public void setKmsKeyId(String kmsKeyId) { this.kmsKeyId = kmsKeyId; }
|
||||
public Instant getCreatedAt() { return createdAt; }
|
||||
public void setCreatedAt(Instant createdAt) { this.createdAt = createdAt; }
|
||||
public Map<String, String> getTags() { return tags; }
|
||||
public void setTags(Map<String, String> tags) { this.tags = tags == null ? new LinkedHashMap<>() : new LinkedHashMap<>(tags); }
|
||||
|
||||
private static List<String> copy(List<String> values) {
|
||||
return values == null ? new ArrayList<>() : new ArrayList<>(values);
|
||||
}
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
package io.github.hectorvent.floci.services.timestreaminfluxdb.model;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
public class DbInstance {
|
||||
private String id;
|
||||
private String name;
|
||||
private String arn;
|
||||
private String status;
|
||||
private String endpoint;
|
||||
private Integer port;
|
||||
private String networkType;
|
||||
private String dbInstanceType;
|
||||
private String dbStorageType;
|
||||
private Integer allocatedStorage;
|
||||
private String deploymentType;
|
||||
private List<String> vpcSubnetIds = new ArrayList<>();
|
||||
private List<String> vpcSecurityGroupIds = new ArrayList<>();
|
||||
private Boolean publiclyAccessible;
|
||||
private String dbParameterGroupIdentifier;
|
||||
private String availabilityZone;
|
||||
private String secondaryAvailabilityZone;
|
||||
private JsonNode logDeliveryConfiguration;
|
||||
private String influxAuthParametersSecretArn;
|
||||
private String dbClusterId;
|
||||
private String instanceMode;
|
||||
private List<String> instanceModes = new ArrayList<>();
|
||||
private JsonNode maintenanceSchedule;
|
||||
private JsonNode dbBackupConfigurations;
|
||||
private String kmsKeyId;
|
||||
private String engineType;
|
||||
private Instant createdAt;
|
||||
private Map<String, String> tags = new LinkedHashMap<>();
|
||||
private String accountId;
|
||||
private String region;
|
||||
private String containerId;
|
||||
|
||||
public DbInstance() {
|
||||
}
|
||||
|
||||
public String getAccountId() { return accountId; }
|
||||
public void setAccountId(String accountId) { this.accountId = accountId; }
|
||||
public String getRegion() { return region; }
|
||||
public void setRegion(String region) { this.region = region; }
|
||||
public String getContainerId() { return containerId; }
|
||||
public void setContainerId(String containerId) { this.containerId = containerId; }
|
||||
|
||||
public String getId() { return id; }
|
||||
public void setId(String id) { this.id = id; }
|
||||
public String getName() { return name; }
|
||||
public void setName(String name) { this.name = name; }
|
||||
public String getArn() { return arn; }
|
||||
public void setArn(String arn) { this.arn = arn; }
|
||||
public String getStatus() { return status; }
|
||||
public void setStatus(String status) { this.status = status; }
|
||||
public String getEndpoint() { return endpoint; }
|
||||
public void setEndpoint(String endpoint) { this.endpoint = endpoint; }
|
||||
public Integer getPort() { return port; }
|
||||
public void setPort(Integer port) { this.port = port; }
|
||||
public String getNetworkType() { return networkType; }
|
||||
public void setNetworkType(String networkType) { this.networkType = networkType; }
|
||||
public String getDbInstanceType() { return dbInstanceType; }
|
||||
public void setDbInstanceType(String dbInstanceType) { this.dbInstanceType = dbInstanceType; }
|
||||
public String getDbStorageType() { return dbStorageType; }
|
||||
public void setDbStorageType(String dbStorageType) { this.dbStorageType = dbStorageType; }
|
||||
public Integer getAllocatedStorage() { return allocatedStorage; }
|
||||
public void setAllocatedStorage(Integer allocatedStorage) { this.allocatedStorage = allocatedStorage; }
|
||||
public String getDeploymentType() { return deploymentType; }
|
||||
public void setDeploymentType(String deploymentType) { this.deploymentType = deploymentType; }
|
||||
public List<String> getVpcSubnetIds() { return vpcSubnetIds; }
|
||||
public void setVpcSubnetIds(List<String> vpcSubnetIds) { this.vpcSubnetIds = copy(vpcSubnetIds); }
|
||||
public List<String> getVpcSecurityGroupIds() { return vpcSecurityGroupIds; }
|
||||
public void setVpcSecurityGroupIds(List<String> vpcSecurityGroupIds) { this.vpcSecurityGroupIds = copy(vpcSecurityGroupIds); }
|
||||
public Boolean getPubliclyAccessible() { return publiclyAccessible; }
|
||||
public void setPubliclyAccessible(Boolean publiclyAccessible) { this.publiclyAccessible = publiclyAccessible; }
|
||||
public String getDbParameterGroupIdentifier() { return dbParameterGroupIdentifier; }
|
||||
public void setDbParameterGroupIdentifier(String dbParameterGroupIdentifier) { this.dbParameterGroupIdentifier = dbParameterGroupIdentifier; }
|
||||
public String getAvailabilityZone() { return availabilityZone; }
|
||||
public void setAvailabilityZone(String availabilityZone) { this.availabilityZone = availabilityZone; }
|
||||
public String getSecondaryAvailabilityZone() { return secondaryAvailabilityZone; }
|
||||
public void setSecondaryAvailabilityZone(String secondaryAvailabilityZone) { this.secondaryAvailabilityZone = secondaryAvailabilityZone; }
|
||||
public JsonNode getLogDeliveryConfiguration() { return logDeliveryConfiguration; }
|
||||
public void setLogDeliveryConfiguration(JsonNode logDeliveryConfiguration) { this.logDeliveryConfiguration = logDeliveryConfiguration; }
|
||||
public String getInfluxAuthParametersSecretArn() { return influxAuthParametersSecretArn; }
|
||||
public void setInfluxAuthParametersSecretArn(String influxAuthParametersSecretArn) { this.influxAuthParametersSecretArn = influxAuthParametersSecretArn; }
|
||||
public String getDbClusterId() { return dbClusterId; }
|
||||
public void setDbClusterId(String dbClusterId) { this.dbClusterId = dbClusterId; }
|
||||
public String getInstanceMode() { return instanceMode; }
|
||||
public void setInstanceMode(String instanceMode) { this.instanceMode = instanceMode; }
|
||||
public List<String> getInstanceModes() { return instanceModes; }
|
||||
public void setInstanceModes(List<String> instanceModes) { this.instanceModes = copy(instanceModes); }
|
||||
public JsonNode getMaintenanceSchedule() { return maintenanceSchedule; }
|
||||
public void setMaintenanceSchedule(JsonNode maintenanceSchedule) { this.maintenanceSchedule = maintenanceSchedule; }
|
||||
public JsonNode getDbBackupConfigurations() { return dbBackupConfigurations; }
|
||||
public void setDbBackupConfigurations(JsonNode dbBackupConfigurations) { this.dbBackupConfigurations = dbBackupConfigurations; }
|
||||
public String getKmsKeyId() { return kmsKeyId; }
|
||||
public void setKmsKeyId(String kmsKeyId) { this.kmsKeyId = kmsKeyId; }
|
||||
public String getEngineType() { return engineType; }
|
||||
public void setEngineType(String engineType) { this.engineType = engineType; }
|
||||
public Instant getCreatedAt() { return createdAt; }
|
||||
public void setCreatedAt(Instant createdAt) { this.createdAt = createdAt; }
|
||||
public Map<String, String> getTags() { return tags; }
|
||||
public void setTags(Map<String, String> tags) { this.tags = tags == null ? new LinkedHashMap<>() : new LinkedHashMap<>(tags); }
|
||||
|
||||
private static List<String> copy(List<String> values) {
|
||||
return values == null ? new ArrayList<>() : new ArrayList<>(values);
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package io.github.hectorvent.floci.services.timestreaminfluxdb.model;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
public class DbParameterGroup {
|
||||
private String id;
|
||||
private String name;
|
||||
private String arn;
|
||||
private String description;
|
||||
private JsonNode parameters;
|
||||
private String engineType;
|
||||
private Instant createdAt;
|
||||
private Map<String, String> tags = new LinkedHashMap<>();
|
||||
|
||||
public DbParameterGroup() {
|
||||
}
|
||||
|
||||
public String getId() { return id; }
|
||||
public void setId(String id) { this.id = id; }
|
||||
public String getName() { return name; }
|
||||
public void setName(String name) { this.name = name; }
|
||||
public String getArn() { return arn; }
|
||||
public void setArn(String arn) { this.arn = arn; }
|
||||
public String getDescription() { return description; }
|
||||
public void setDescription(String description) { this.description = description; }
|
||||
public JsonNode getParameters() { return parameters; }
|
||||
public void setParameters(JsonNode parameters) { this.parameters = parameters; }
|
||||
public String getEngineType() { return engineType; }
|
||||
public void setEngineType(String engineType) { this.engineType = engineType; }
|
||||
public Instant getCreatedAt() { return createdAt; }
|
||||
public void setCreatedAt(Instant createdAt) { this.createdAt = createdAt; }
|
||||
public Map<String, String> getTags() { return tags; }
|
||||
public void setTags(Map<String, String> tags) { this.tags = tags == null ? new LinkedHashMap<>() : new LinkedHashMap<>(tags); }
|
||||
}
|
||||
Reference in new issue
Block a user