mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
feat: implement local Data Lake stack (Athena, Glue, and Firehose) (#429)
* feat: implement local Data Lake stack (Athena, Glue, and Firehose) * fix: adding athena, firehose and glue documentation * fix: updating dataLateTest
This commit is contained in:
1 parent
3cdb9b0ded
commit
ea597c67d6
35 files changed
+1256
-8
No files matched your search
@@ -216,11 +216,14 @@ public interface EmulatorConfig {
|
||||
SecretsManagerServiceConfig secretsmanager();
|
||||
ApiGatewayV2ServiceConfig apigatewayv2();
|
||||
KinesisServiceConfig kinesis();
|
||||
FirehoseServiceConfig firehose();
|
||||
KmsServiceConfig kms();
|
||||
CognitoServiceConfig cognito();
|
||||
StepFunctionsServiceConfig stepfunctions();
|
||||
CloudFormationServiceConfig cloudformation();
|
||||
AcmServiceConfig acm();
|
||||
AthenaServiceConfig athena();
|
||||
GlueServiceConfig glue();
|
||||
SesServiceConfig ses();
|
||||
OpenSearchServiceConfig opensearch();
|
||||
Ec2ServiceConfig ec2();
|
||||
@@ -372,6 +375,11 @@ public interface EmulatorConfig {
|
||||
boolean enabled();
|
||||
}
|
||||
|
||||
interface FirehoseServiceConfig {
|
||||
@WithDefault("true")
|
||||
boolean enabled();
|
||||
}
|
||||
|
||||
interface KmsServiceConfig {
|
||||
@WithDefault("true")
|
||||
boolean enabled();
|
||||
@@ -401,6 +409,16 @@ public interface EmulatorConfig {
|
||||
int validationWaitSeconds();
|
||||
}
|
||||
|
||||
interface AthenaServiceConfig {
|
||||
@WithDefault("true")
|
||||
boolean enabled();
|
||||
}
|
||||
|
||||
interface GlueServiceConfig {
|
||||
@WithDefault("true")
|
||||
boolean enabled();
|
||||
}
|
||||
|
||||
interface SesServiceConfig {
|
||||
@WithDefault("true")
|
||||
boolean enabled();
|
||||
|
||||
@@ -3,8 +3,11 @@ package io.github.hectorvent.floci.core.common;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.github.hectorvent.floci.services.acm.AcmJsonHandler;
|
||||
import io.github.hectorvent.floci.services.athena.AthenaJsonHandler;
|
||||
import io.github.hectorvent.floci.services.ecr.EcrJsonHandler;
|
||||
import io.github.hectorvent.floci.services.ecs.EcsJsonHandler;
|
||||
import io.github.hectorvent.floci.services.firehose.FirehoseJsonHandler;
|
||||
import io.github.hectorvent.floci.services.glue.GlueJsonHandler;
|
||||
import io.github.hectorvent.floci.services.apigatewayv2.ApiGatewayV2JsonHandler;
|
||||
import io.github.hectorvent.floci.services.cloudwatch.logs.CloudWatchLogsHandler;
|
||||
import io.github.hectorvent.floci.services.cognito.CognitoJsonHandler;
|
||||
@@ -48,6 +51,9 @@ public class AwsJson11Controller {
|
||||
private final AcmJsonHandler acmJsonHandler;
|
||||
private final EcsJsonHandler ecsJsonHandler;
|
||||
private final EcrJsonHandler ecrJsonHandler;
|
||||
private final GlueJsonHandler glueJsonHandler;
|
||||
private final AthenaJsonHandler athenaJsonHandler;
|
||||
private final FirehoseJsonHandler firehoseJsonHandler;
|
||||
|
||||
@Inject
|
||||
public AwsJson11Controller(ObjectMapper objectMapper, ResolvedServiceCatalog catalog,
|
||||
@@ -59,7 +65,9 @@ public class AwsJson11Controller {
|
||||
ApiGatewayV2JsonHandler apigwV2JsonHandler,
|
||||
KmsJsonHandler kmsJsonHandler, CognitoJsonHandler cognitoJsonHandler,
|
||||
AcmJsonHandler acmJsonHandler, EcsJsonHandler ecsJsonHandler,
|
||||
EcrJsonHandler ecrJsonHandler) {
|
||||
EcrJsonHandler ecrJsonHandler, GlueJsonHandler glueJsonHandler,
|
||||
AthenaJsonHandler athenaJsonHandler,
|
||||
FirehoseJsonHandler firehoseJsonHandler) {
|
||||
this.objectMapper = objectMapper;
|
||||
this.catalog = catalog;
|
||||
this.regionResolver = regionResolver;
|
||||
@@ -74,6 +82,9 @@ public class AwsJson11Controller {
|
||||
this.acmJsonHandler = acmJsonHandler;
|
||||
this.ecsJsonHandler = ecsJsonHandler;
|
||||
this.ecrJsonHandler = ecrJsonHandler;
|
||||
this.glueJsonHandler = glueJsonHandler;
|
||||
this.athenaJsonHandler = athenaJsonHandler;
|
||||
this.firehoseJsonHandler = firehoseJsonHandler;
|
||||
}
|
||||
|
||||
@POST
|
||||
@@ -113,6 +124,9 @@ public class AwsJson11Controller {
|
||||
case "acm" -> acmJsonHandler.handle(action, request, region);
|
||||
case "ecs" -> ecsJsonHandler.handle(action, request, region);
|
||||
case "ecr" -> ecrJsonHandler.handle(action, request, region);
|
||||
case "glue" -> glueJsonHandler.handle(action, request, region);
|
||||
case "athena" -> athenaJsonHandler.handle(action, request, region);
|
||||
case "firehose" -> firehoseJsonHandler.handle(action, request, region);
|
||||
default -> null;
|
||||
};
|
||||
// catalog.matchTarget is protocol-agnostic: a JSON 1.0 target
|
||||
|
||||
@@ -135,6 +135,18 @@ public class ResolvedServiceCatalog {
|
||||
config.storage().services().acm().flushIntervalMs(), null, ServiceProtocol.JSON,
|
||||
protocols(ServiceProtocol.JSON),
|
||||
Set.of("CertificateManager."), Set.of("acm"), Set.of(), Set.of()),
|
||||
descriptor("athena", "athena", config.services().athena().enabled(), true,
|
||||
"athena", config.storage().mode(), 5000L, null, ServiceProtocol.JSON,
|
||||
protocols(ServiceProtocol.JSON),
|
||||
Set.of("AmazonAthena."), Set.of("athena"), Set.of(), Set.of()),
|
||||
descriptor("glue", "glue", config.services().glue().enabled(), true,
|
||||
"glue", config.storage().mode(), 5000L, null, ServiceProtocol.JSON,
|
||||
protocols(ServiceProtocol.JSON),
|
||||
Set.of("AWSGlue."), Set.of("glue"), Set.of(), Set.of()),
|
||||
descriptor("firehose", "firehose", config.services().firehose().enabled(), true,
|
||||
"firehose", config.storage().mode(), 5000L, null, ServiceProtocol.JSON,
|
||||
protocols(ServiceProtocol.JSON),
|
||||
Set.of("Firehose_20150804."), Set.of("firehose"), Set.of(), Set.of()),
|
||||
descriptor("email", "ses", config.services().ses().enabled(), true,
|
||||
"ses", config.storage().mode(), 5000L, AwsNamespaces.SES, ServiceProtocol.REST_JSON,
|
||||
protocols(ServiceProtocol.REST_JSON, ServiceProtocol.QUERY),
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package io.github.hectorvent.floci.services.athena;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.services.athena.model.QueryExecution;
|
||||
import io.github.hectorvent.floci.services.athena.model.ResultSet;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@ApplicationScoped
|
||||
public class AthenaJsonHandler {
|
||||
|
||||
private final AthenaService athenaService;
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
public AthenaJsonHandler(AthenaService athenaService, ObjectMapper mapper) {
|
||||
this.athenaService = athenaService;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
public Response handle(String action, JsonNode request, String region) throws Exception {
|
||||
return switch (action) {
|
||||
case "StartQueryExecution" -> {
|
||||
String query = request.get("QueryString").asText();
|
||||
String workGroup = request.has("WorkGroup") ? request.get("WorkGroup").asText() : "primary";
|
||||
String database = "default";
|
||||
if (request.has("QueryExecutionContext") && request.get("QueryExecutionContext").has("Database")) {
|
||||
database = request.get("QueryExecutionContext").get("Database").asText();
|
||||
}
|
||||
String id = athenaService.startQueryExecution(query, workGroup, database);
|
||||
yield Response.ok(Map.of("QueryExecutionId", id)).build();
|
||||
}
|
||||
case "GetQueryExecution" -> {
|
||||
String id = request.get("QueryExecutionId").asText();
|
||||
QueryExecution execution = athenaService.getQueryExecution(id);
|
||||
yield Response.ok(Map.of("QueryExecution", execution)).build();
|
||||
}
|
||||
case "GetQueryResults" -> {
|
||||
String id = request.get("QueryExecutionId").asText();
|
||||
ResultSet results = athenaService.getQueryResults(id);
|
||||
yield Response.ok(Map.of("ResultSet", results)).build();
|
||||
}
|
||||
case "ListQueryExecutions" -> {
|
||||
yield Response.ok(Map.of("QueryExecutionIds",
|
||||
athenaService.listQueryExecutions().stream().map(QueryExecution::getQueryExecutionId).toList())).build();
|
||||
}
|
||||
default -> throw new AwsException("InvalidAction", "Action " + action + " is not supported", 400);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package io.github.hectorvent.floci.services.athena;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.storage.StorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
import io.github.hectorvent.floci.services.athena.model.*;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
|
||||
@ApplicationScoped
|
||||
public class AthenaService {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(AthenaService.class);
|
||||
|
||||
private final StorageBackend<String, QueryExecution> queryStore;
|
||||
|
||||
@Inject
|
||||
public AthenaService(StorageFactory storageFactory) {
|
||||
this.queryStore = storageFactory.create("athena", "queries.json", new TypeReference<Map<String, QueryExecution>>() {});
|
||||
}
|
||||
|
||||
public String startQueryExecution(String query, String workGroup, String database) {
|
||||
String id = UUID.randomUUID().toString();
|
||||
QueryExecution execution = new QueryExecution(id, query, workGroup);
|
||||
queryStore.put(id, execution);
|
||||
|
||||
execution.getStatus().setState(QueryExecutionState.RUNNING);
|
||||
execution.getStatus().setState(QueryExecutionState.SUCCEEDED);
|
||||
execution.getStatus().setCompletionDateTime(Instant.now());
|
||||
queryStore.put(id, execution);
|
||||
|
||||
LOG.infov("Query {0} accepted (mock mode — no execution engine)", id);
|
||||
return id;
|
||||
}
|
||||
|
||||
public QueryExecution getQueryExecution(String id) {
|
||||
return queryStore.get(id)
|
||||
.orElseThrow(() -> new AwsException("InvalidRequestException", "Query execution not found: " + id, 400));
|
||||
}
|
||||
|
||||
public List<QueryExecution> listQueryExecutions() {
|
||||
return queryStore.scan(k -> true);
|
||||
}
|
||||
|
||||
public ResultSet getQueryResults(String id) {
|
||||
QueryExecution execution = getQueryExecution(id);
|
||||
if (execution.getStatus().getState() != QueryExecutionState.SUCCEEDED) {
|
||||
throw new AwsException("InvalidRequestException", "Query has not succeeded yet", 400);
|
||||
}
|
||||
return new ResultSet(List.of(), new ResultSet.ResultSetMetadata(List.of()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package io.github.hectorvent.floci.services.athena.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
public class QueryExecution {
|
||||
@JsonProperty("QueryExecutionId")
|
||||
private String queryExecutionId;
|
||||
@JsonProperty("Query")
|
||||
private String query;
|
||||
@JsonProperty("Status")
|
||||
private QueryExecutionStatus status;
|
||||
@JsonProperty("WorkGroup")
|
||||
private String workGroup;
|
||||
|
||||
public QueryExecution() {}
|
||||
public QueryExecution(String id, String query, String workGroup) {
|
||||
this.queryExecutionId = id;
|
||||
this.query = query;
|
||||
this.workGroup = workGroup;
|
||||
this.status = new QueryExecutionStatus(QueryExecutionState.QUEUED);
|
||||
}
|
||||
|
||||
public String getQueryExecutionId() { return queryExecutionId; }
|
||||
public void setQueryExecutionId(String queryExecutionId) { this.queryExecutionId = queryExecutionId; }
|
||||
public String getQuery() { return query; }
|
||||
public void setQuery(String query) { this.query = query; }
|
||||
public QueryExecutionStatus getStatus() { return status; }
|
||||
public void setStatus(QueryExecutionStatus status) { this.status = status; }
|
||||
public String getWorkGroup() { return workGroup; }
|
||||
public void setWorkGroup(String workGroup) { this.workGroup = workGroup; }
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package io.github.hectorvent.floci.services.athena.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
public enum QueryExecutionState {
|
||||
@JsonProperty("QUEUED")
|
||||
QUEUED,
|
||||
@JsonProperty("RUNNING")
|
||||
RUNNING,
|
||||
@JsonProperty("SUCCEEDED")
|
||||
SUCCEEDED,
|
||||
@JsonProperty("FAILED")
|
||||
FAILED,
|
||||
@JsonProperty("CANCELLED")
|
||||
CANCELLED
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package io.github.hectorvent.floci.services.athena.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import java.time.Instant;
|
||||
|
||||
@RegisterForReflection
|
||||
public class QueryExecutionStatus {
|
||||
@JsonProperty("State")
|
||||
private QueryExecutionState state;
|
||||
@JsonProperty("StateChangeReason")
|
||||
private String stateChangeReason;
|
||||
@JsonProperty("SubmissionDateTime")
|
||||
@JsonFormat(shape = JsonFormat.Shape.NUMBER)
|
||||
private Instant submissionDateTime;
|
||||
@JsonProperty("CompletionDateTime")
|
||||
@JsonFormat(shape = JsonFormat.Shape.NUMBER)
|
||||
private Instant completionDateTime;
|
||||
|
||||
public QueryExecutionStatus() {}
|
||||
public QueryExecutionStatus(QueryExecutionState state) {
|
||||
this.state = state;
|
||||
this.submissionDateTime = Instant.now();
|
||||
}
|
||||
|
||||
public QueryExecutionState getState() { return state; }
|
||||
public void setState(QueryExecutionState state) { this.state = state; }
|
||||
public String getStateChangeReason() { return stateChangeReason; }
|
||||
public void setStateChangeReason(String stateChangeReason) { this.stateChangeReason = stateChangeReason; }
|
||||
public Instant getSubmissionDateTime() { return submissionDateTime; }
|
||||
public void setSubmissionDateTime(Instant submissionDateTime) { this.submissionDateTime = submissionDateTime; }
|
||||
public Instant getCompletionDateTime() { return completionDateTime; }
|
||||
public void setCompletionDateTime(Instant completionDateTime) { this.completionDateTime = completionDateTime; }
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package io.github.hectorvent.floci.services.athena.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import java.util.List;
|
||||
|
||||
@RegisterForReflection
|
||||
public class ResultSet {
|
||||
@JsonProperty("Rows")
|
||||
private List<Row> rows;
|
||||
@JsonProperty("ResultSetMetadata")
|
||||
private ResultSetMetadata metadata;
|
||||
|
||||
public ResultSet() {}
|
||||
public ResultSet(List<Row> rows, ResultSetMetadata metadata) {
|
||||
this.rows = rows;
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
public List<Row> getRows() { return rows; }
|
||||
public void setRows(List<Row> rows) { this.rows = rows; }
|
||||
public ResultSetMetadata getMetadata() { return metadata; }
|
||||
public void setMetadata(ResultSetMetadata metadata) { this.metadata = metadata; }
|
||||
|
||||
@RegisterForReflection
|
||||
public static class Row {
|
||||
@JsonProperty("Data")
|
||||
private List<Datum> data;
|
||||
|
||||
public Row() {}
|
||||
public Row(List<Datum> data) { this.data = data; }
|
||||
public List<Datum> getData() { return data; }
|
||||
public void setData(List<Datum> data) { this.data = data; }
|
||||
}
|
||||
|
||||
@RegisterForReflection
|
||||
public static class Datum {
|
||||
@JsonProperty("VarCharValue")
|
||||
private String varCharValue;
|
||||
|
||||
public Datum() {}
|
||||
public Datum(String value) { this.varCharValue = value; }
|
||||
public String getVarCharValue() { return varCharValue; }
|
||||
public void setVarCharValue(String varCharValue) { this.varCharValue = varCharValue; }
|
||||
}
|
||||
|
||||
@RegisterForReflection
|
||||
public static class ResultSetMetadata {
|
||||
@JsonProperty("ColumnInfo")
|
||||
private List<ColumnInfo> columnInfo;
|
||||
|
||||
public ResultSetMetadata() {}
|
||||
public ResultSetMetadata(List<ColumnInfo> columnInfo) { this.columnInfo = columnInfo; }
|
||||
public List<ColumnInfo> getColumnInfo() { return columnInfo; }
|
||||
public void setColumnInfo(List<ColumnInfo> columnInfo) { this.columnInfo = columnInfo; }
|
||||
}
|
||||
|
||||
@RegisterForReflection
|
||||
public static class ColumnInfo {
|
||||
@JsonProperty("Name")
|
||||
private String name;
|
||||
@JsonProperty("Type")
|
||||
private String type;
|
||||
|
||||
public ColumnInfo() {}
|
||||
public ColumnInfo(String name, String type) { this.name = name; this.name = name; this.type = type; }
|
||||
public String getName() { return name; }
|
||||
public void setName(String name) { this.name = name; }
|
||||
public String getType() { return type; }
|
||||
public void setType(String type) { this.type = type; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package io.github.hectorvent.floci.services.firehose;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.services.firehose.model.Record;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@ApplicationScoped
|
||||
public class FirehoseJsonHandler {
|
||||
|
||||
private final FirehoseService firehoseService;
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
public FirehoseJsonHandler(FirehoseService firehoseService, ObjectMapper mapper) {
|
||||
this.firehoseService = firehoseService;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
public Response handle(String action, JsonNode request, String region) throws Exception {
|
||||
return switch (action) {
|
||||
case "CreateDeliveryStream" -> {
|
||||
String name = request.get("DeliveryStreamName").asText();
|
||||
String arn = firehoseService.createDeliveryStream(name);
|
||||
yield Response.ok(Map.of("DeliveryStreamARN", arn)).build();
|
||||
}
|
||||
case "DescribeDeliveryStream" -> {
|
||||
String name = request.get("DeliveryStreamName").asText();
|
||||
var desc = firehoseService.describeDeliveryStream(name);
|
||||
yield Response.ok(Map.of("DeliveryStreamDescription", desc)).build();
|
||||
}
|
||||
case "ListDeliveryStreams" -> {
|
||||
yield Response.ok(Map.of("DeliveryStreamNames", firehoseService.listDeliveryStreams(), "HasMoreDeliveryStreams", false)).build();
|
||||
}
|
||||
case "DeleteDeliveryStream" -> {
|
||||
// TODO: delete implementation
|
||||
yield Response.ok().build();
|
||||
}
|
||||
case "PutRecord" -> {
|
||||
String name = request.get("DeliveryStreamName").asText();
|
||||
Record record = mapper.treeToValue(request.get("Record"), Record.class);
|
||||
firehoseService.putRecord(name, record);
|
||||
yield Response.ok(Map.of("RecordId", UUID.randomUUID().toString())).build();
|
||||
}
|
||||
case "PutRecordBatch" -> {
|
||||
String name = request.get("DeliveryStreamName").asText();
|
||||
List<Map<String, String>> responseEntries = new ArrayList<>();
|
||||
for (JsonNode recordNode : request.get("Records")) {
|
||||
Record record = mapper.treeToValue(recordNode, Record.class);
|
||||
firehoseService.putRecord(name, record);
|
||||
responseEntries.add(Map.of("RecordId", UUID.randomUUID().toString()));
|
||||
}
|
||||
yield Response.ok(Map.of("FailedPutCount", 0, "RequestResponses", responseEntries)).build();
|
||||
}
|
||||
default -> throw new AwsException("InvalidAction", "Action " + action + " is not supported", 400);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package io.github.hectorvent.floci.services.firehose;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.storage.StorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
import io.github.hectorvent.floci.services.firehose.model.DeliveryStreamDescription;
|
||||
import io.github.hectorvent.floci.services.firehose.model.Record;
|
||||
import io.github.hectorvent.floci.services.s3.S3Service;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@ApplicationScoped
|
||||
public class FirehoseService {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(FirehoseService.class);
|
||||
|
||||
private final StorageBackend<String, DeliveryStreamDescription> streamStore;
|
||||
private final Map<String, List<byte[]>> buffers = new ConcurrentHashMap<>();
|
||||
private final S3Service s3Service;
|
||||
|
||||
@Inject
|
||||
public FirehoseService(StorageFactory storageFactory, S3Service s3Service) {
|
||||
this.streamStore = storageFactory.create("firehose", "streams.json", new TypeReference<Map<String, DeliveryStreamDescription>>() {});
|
||||
this.s3Service = s3Service;
|
||||
}
|
||||
|
||||
public String createDeliveryStream(String name) {
|
||||
String arn = "arn:aws:firehose:us-east-1:000000000000:deliverystream/" + name;
|
||||
DeliveryStreamDescription description = new DeliveryStreamDescription(name, arn);
|
||||
streamStore.put(name, description);
|
||||
buffers.put(name, Collections.synchronizedList(new ArrayList<>()));
|
||||
LOG.infov("Created Firehose Delivery Stream: {0}", name);
|
||||
return arn;
|
||||
}
|
||||
|
||||
public DeliveryStreamDescription describeDeliveryStream(String name) {
|
||||
return streamStore.get(name)
|
||||
.orElseThrow(() -> new AwsException("ResourceNotFoundException", "Stream not found: " + name, 400));
|
||||
}
|
||||
|
||||
public List<String> listDeliveryStreams() {
|
||||
return streamStore.scan(k -> true).stream().map(DeliveryStreamDescription::getDeliveryStreamName).toList();
|
||||
}
|
||||
|
||||
public void putRecord(String streamName, Record record) {
|
||||
describeDeliveryStream(streamName); // Check exists
|
||||
buffers.get(streamName).add(record.getData());
|
||||
|
||||
// Flush every 5 records for observable local feedback
|
||||
if (buffers.get(streamName).size() >= 5) {
|
||||
flush(streamName);
|
||||
}
|
||||
}
|
||||
|
||||
public void flush(String streamName) {
|
||||
List<byte[]> buffer = buffers.get(streamName);
|
||||
if (buffer.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<byte[]> toFlush;
|
||||
synchronized (buffer) {
|
||||
toFlush = new ArrayList<>(buffer);
|
||||
buffer.clear();
|
||||
}
|
||||
|
||||
try {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte[] data : toFlush) {
|
||||
sb.append(new String(data, StandardCharsets.UTF_8)).append("\n");
|
||||
}
|
||||
|
||||
String bucket = "floci-firehose-results";
|
||||
String key = streamName + "/" + UUID.randomUUID() + ".json";
|
||||
|
||||
try {
|
||||
s3Service.createBucket(bucket, "us-east-1");
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
byte[] jsonBytes = sb.toString().getBytes(StandardCharsets.UTF_8);
|
||||
s3Service.putObject(bucket, key, jsonBytes, "application/x-ndjson", Map.of());
|
||||
LOG.infov("Flushed {0} records from stream {1} to s3://{2}/{3}", toFlush.size(), streamName, bucket, key);
|
||||
} catch (Exception e) {
|
||||
LOG.errorv("Failed to flush Firehose stream {0}: {1}", streamName, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package io.github.hectorvent.floci.services.firehose.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import java.time.Instant;
|
||||
|
||||
@RegisterForReflection
|
||||
public class DeliveryStreamDescription {
|
||||
@JsonProperty("DeliveryStreamName")
|
||||
private String deliveryStreamName;
|
||||
@JsonProperty("DeliveryStreamARN")
|
||||
private String deliveryStreamARN;
|
||||
@JsonProperty("DeliveryStreamStatus")
|
||||
private DeliveryStreamStatus deliveryStreamStatus;
|
||||
@JsonProperty("CreateTimestamp")
|
||||
@JsonFormat(shape = JsonFormat.Shape.NUMBER)
|
||||
private Instant createTimestamp;
|
||||
|
||||
public DeliveryStreamDescription() {}
|
||||
public DeliveryStreamDescription(String name, String arn) {
|
||||
this.deliveryStreamName = name;
|
||||
this.deliveryStreamARN = arn;
|
||||
this.deliveryStreamStatus = DeliveryStreamStatus.ACTIVE;
|
||||
this.createTimestamp = Instant.now();
|
||||
}
|
||||
|
||||
public String getDeliveryStreamName() { return deliveryStreamName; }
|
||||
public void setDeliveryStreamName(String deliveryStreamName) { this.deliveryStreamName = deliveryStreamName; }
|
||||
public String getDeliveryStreamARN() { return deliveryStreamARN; }
|
||||
public void setDeliveryStreamARN(String deliveryStreamARN) { this.deliveryStreamARN = deliveryStreamARN; }
|
||||
public DeliveryStreamStatus getDeliveryStreamStatus() { return deliveryStreamStatus; }
|
||||
public void setDeliveryStreamStatus(DeliveryStreamStatus deliveryStreamStatus) { this.deliveryStreamStatus = deliveryStreamStatus; }
|
||||
public Instant getCreateTimestamp() { return createTimestamp; }
|
||||
public void setCreateTimestamp(Instant createTimestamp) { this.createTimestamp = createTimestamp; }
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package io.github.hectorvent.floci.services.firehose.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
public enum DeliveryStreamStatus {
|
||||
@JsonProperty("CREATING")
|
||||
CREATING,
|
||||
@JsonProperty("DELETING")
|
||||
DELETING,
|
||||
@JsonProperty("ACTIVE")
|
||||
ACTIVE
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package io.github.hectorvent.floci.services.firehose.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
public class Record {
|
||||
@JsonProperty("Data")
|
||||
private byte[] data;
|
||||
|
||||
public Record() {}
|
||||
public Record(byte[] data) { this.data = data; }
|
||||
public byte[] getData() { return data; }
|
||||
public void setData(byte[] data) { this.data = data; }
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package io.github.hectorvent.floci.services.glue;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.services.glue.model.Database;
|
||||
import io.github.hectorvent.floci.services.glue.model.Partition;
|
||||
import io.github.hectorvent.floci.services.glue.model.Table;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@ApplicationScoped
|
||||
public class GlueJsonHandler {
|
||||
|
||||
private final GlueService glueService;
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
public GlueJsonHandler(GlueService glueService, ObjectMapper mapper) {
|
||||
this.glueService = glueService;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
public Response handle(String action, JsonNode request, String region) throws Exception {
|
||||
return switch (action) {
|
||||
case "CreateDatabase" -> {
|
||||
Database db = mapper.treeToValue(request.get("DatabaseInput"), Database.class);
|
||||
glueService.createDatabase(db);
|
||||
yield Response.ok().build();
|
||||
}
|
||||
case "GetDatabase" -> {
|
||||
String name = request.get("Name").asText();
|
||||
Database db = glueService.getDatabase(name);
|
||||
yield Response.ok(Map.of("Database", db)).build();
|
||||
}
|
||||
case "GetDatabases" -> {
|
||||
yield Response.ok(Map.of("DatabaseList", glueService.getDatabases())).build();
|
||||
}
|
||||
case "CreateTable" -> {
|
||||
String dbName = request.get("DatabaseName").asText();
|
||||
Table table = mapper.treeToValue(request.get("TableInput"), Table.class);
|
||||
glueService.createTable(dbName, table);
|
||||
yield Response.ok().build();
|
||||
}
|
||||
case "GetTable" -> {
|
||||
String dbName = request.get("DatabaseName").asText();
|
||||
String tableName = request.get("Name").asText();
|
||||
Table table = glueService.getTable(dbName, tableName);
|
||||
yield Response.ok(Map.of("Table", table)).build();
|
||||
}
|
||||
case "GetTables" -> {
|
||||
String dbName = request.get("DatabaseName").asText();
|
||||
yield Response.ok(Map.of("TableList", glueService.getTables(dbName))).build();
|
||||
}
|
||||
case "DeleteTable" -> {
|
||||
String dbName = request.get("DatabaseName").asText();
|
||||
String tableName = request.get("Name").asText();
|
||||
glueService.deleteTable(dbName, tableName);
|
||||
yield Response.ok().build();
|
||||
}
|
||||
case "CreatePartition" -> {
|
||||
String dbName = request.get("DatabaseName").asText();
|
||||
String tableName = request.get("TableName").asText();
|
||||
Partition partition = mapper.treeToValue(request.get("PartitionInput"), Partition.class);
|
||||
glueService.createPartition(dbName, tableName, partition);
|
||||
yield Response.ok().build();
|
||||
}
|
||||
case "GetPartitions" -> {
|
||||
String dbName = request.get("DatabaseName").asText();
|
||||
String tableName = request.get("TableName").asText();
|
||||
yield Response.ok(Map.of("Partitions", glueService.getPartitions(dbName, tableName))).build();
|
||||
}
|
||||
default -> throw new AwsException("InvalidAction", "Action " + action + " is not supported", 400);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package io.github.hectorvent.floci.services.glue;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.storage.StorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
import io.github.hectorvent.floci.services.glue.model.Database;
|
||||
import io.github.hectorvent.floci.services.glue.model.Partition;
|
||||
import io.github.hectorvent.floci.services.glue.model.Table;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@ApplicationScoped
|
||||
public class GlueService {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(GlueService.class);
|
||||
|
||||
private final StorageBackend<String, Database> databaseStore;
|
||||
private final StorageBackend<String, Table> tableStore;
|
||||
private final StorageBackend<String, Partition> partitionStore;
|
||||
|
||||
@Inject
|
||||
public GlueService(StorageFactory storageFactory) {
|
||||
this.databaseStore = storageFactory.create("glue", "databases.json", new TypeReference<Map<String, Database>>() {});
|
||||
this.tableStore = storageFactory.create("glue", "tables.json", new TypeReference<Map<String, Table>>() {});
|
||||
this.partitionStore = storageFactory.create("glue", "partitions.json", new TypeReference<Map<String, Partition>>() {});
|
||||
}
|
||||
|
||||
public void createDatabase(Database database) {
|
||||
if (databaseStore.get(database.getName()).isPresent()) {
|
||||
throw new AwsException("AlreadyExistsException", "Database already exists: " + database.getName(), 400);
|
||||
}
|
||||
databaseStore.put(database.getName(), database);
|
||||
LOG.infov("Created Glue Database: {0}", database.getName());
|
||||
}
|
||||
|
||||
public Database getDatabase(String name) {
|
||||
return databaseStore.get(name)
|
||||
.orElseThrow(() -> new AwsException("EntityNotFoundException", "Database not found: " + name, 400));
|
||||
}
|
||||
|
||||
public List<Database> getDatabases() {
|
||||
return databaseStore.scan(k -> true);
|
||||
}
|
||||
|
||||
public void createTable(String databaseName, Table table) {
|
||||
getDatabase(databaseName); // Check if db exists
|
||||
String key = databaseName + ":" + table.getName();
|
||||
if (tableStore.get(key).isPresent()) {
|
||||
throw new AwsException("AlreadyExistsException", "Table already exists: " + table.getName(), 400);
|
||||
}
|
||||
table.setDatabaseName(databaseName);
|
||||
tableStore.put(key, table);
|
||||
LOG.infov("Created Glue Table: {0}.{1}", databaseName, table.getName());
|
||||
}
|
||||
|
||||
public Table getTable(String databaseName, String tableName) {
|
||||
String key = databaseName + ":" + tableName;
|
||||
return tableStore.get(key)
|
||||
.orElseThrow(() -> new AwsException("EntityNotFoundException", "Table not found: " + databaseName + "." + tableName, 400));
|
||||
}
|
||||
|
||||
public List<Table> getTables(String databaseName) {
|
||||
return tableStore.scan(k -> k.startsWith(databaseName + ":"));
|
||||
}
|
||||
|
||||
public void deleteTable(String databaseName, String tableName) {
|
||||
String key = databaseName + ":" + tableName;
|
||||
tableStore.delete(key);
|
||||
// Also delete partitions
|
||||
partitionStore.scan(k -> k.startsWith(key + ":")).forEach(p -> {
|
||||
partitionStore.delete(databaseName + ":" + tableName + ":" + String.join(",", p.getValues()));
|
||||
});
|
||||
LOG.infov("Deleted Glue Table: {0}.{1}", databaseName, tableName);
|
||||
}
|
||||
|
||||
public void createPartition(String databaseName, String tableName, Partition partition) {
|
||||
getTable(databaseName, tableName); // Check if table exists
|
||||
String key = databaseName + ":" + tableName + ":" + String.join(",", partition.getValues());
|
||||
partition.setDatabaseName(databaseName);
|
||||
partition.setTableName(tableName);
|
||||
partitionStore.put(key, partition);
|
||||
}
|
||||
|
||||
public List<Partition> getPartitions(String databaseName, String tableName) {
|
||||
String prefix = databaseName + ":" + tableName + ":";
|
||||
return partitionStore.scan(k -> k.startsWith(prefix));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package io.github.hectorvent.floci.services.glue.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
public class Column {
|
||||
@JsonProperty("Name")
|
||||
private String name;
|
||||
@JsonProperty("Type")
|
||||
private String type;
|
||||
@JsonProperty("Comment")
|
||||
private String comment;
|
||||
|
||||
public Column() {}
|
||||
public Column(String name, String type) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getName() { return name; }
|
||||
public void setName(String name) { this.name = name; }
|
||||
public String getType() { return type; }
|
||||
public void setType(String type) { this.type = type; }
|
||||
public String getComment() { return comment; }
|
||||
public void setComment(String comment) { this.comment = comment; }
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package io.github.hectorvent.floci.services.glue.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
public class Database {
|
||||
@JsonProperty("Name")
|
||||
private String name;
|
||||
@JsonProperty("Description")
|
||||
private String description;
|
||||
@JsonProperty("LocationUri")
|
||||
private String locationUri;
|
||||
@JsonProperty("Parameters")
|
||||
private Map<String, String> parameters;
|
||||
@JsonProperty("CreateTime")
|
||||
@JsonFormat(shape = JsonFormat.Shape.NUMBER)
|
||||
private Instant createTime;
|
||||
|
||||
public Database() {}
|
||||
public Database(String name) {
|
||||
this.name = name;
|
||||
this.createTime = Instant.now();
|
||||
}
|
||||
|
||||
public String getName() { return name; }
|
||||
public void setName(String name) { this.name = name; }
|
||||
public String getDescription() { return description; }
|
||||
public void setDescription(String description) { this.description = description; }
|
||||
public String getLocationUri() { return locationUri; }
|
||||
public void setLocationUri(String locationUri) { this.locationUri = locationUri; }
|
||||
public Map<String, String> getParameters() { return parameters; }
|
||||
public void setParameters(Map<String, String> parameters) { this.parameters = parameters; }
|
||||
public Instant getCreateTime() { return createTime; }
|
||||
public void setCreateTime(Instant createTime) { this.createTime = createTime; }
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package io.github.hectorvent.floci.services.glue.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
public class Partition {
|
||||
@JsonProperty("Values")
|
||||
private List<String> values;
|
||||
@JsonProperty("DatabaseName")
|
||||
private String databaseName;
|
||||
@JsonProperty("TableName")
|
||||
private String tableName;
|
||||
@JsonProperty("CreationTime")
|
||||
@JsonFormat(shape = JsonFormat.Shape.NUMBER)
|
||||
private Instant creationTime;
|
||||
@JsonProperty("LastAccessTime")
|
||||
@JsonFormat(shape = JsonFormat.Shape.NUMBER)
|
||||
private Instant lastAccessTime;
|
||||
@JsonProperty("StorageDescriptor")
|
||||
private StorageDescriptor storageDescriptor;
|
||||
@JsonProperty("Parameters")
|
||||
private Map<String, String> parameters;
|
||||
|
||||
public Partition() {}
|
||||
|
||||
public List<String> getValues() { return values; }
|
||||
public void setValues(List<String> values) { this.values = values; }
|
||||
public String getDatabaseName() { return databaseName; }
|
||||
public void setDatabaseName(String databaseName) { this.databaseName = databaseName; }
|
||||
public String getTableName() { return tableName; }
|
||||
public void setTableName(String tableName) { this.tableName = tableName; }
|
||||
public Instant getCreationTime() { return creationTime; }
|
||||
public void setCreationTime(Instant creationTime) { this.creationTime = creationTime; }
|
||||
public Instant getLastAccessTime() { return lastAccessTime; }
|
||||
public void setLastAccessTime(Instant lastAccessTime) { this.lastAccessTime = lastAccessTime; }
|
||||
public StorageDescriptor getStorageDescriptor() { return storageDescriptor; }
|
||||
public void setStorageDescriptor(StorageDescriptor storageDescriptor) { this.storageDescriptor = storageDescriptor; }
|
||||
public Map<String, String> getParameters() { return parameters; }
|
||||
public void setParameters(Map<String, String> parameters) { this.parameters = parameters; }
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package io.github.hectorvent.floci.services.glue.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
public class StorageDescriptor {
|
||||
@JsonProperty("Columns")
|
||||
private List<Column> columns;
|
||||
@JsonProperty("Location")
|
||||
private String location;
|
||||
@JsonProperty("InputFormat")
|
||||
private String inputFormat;
|
||||
@JsonProperty("OutputFormat")
|
||||
private String outputFormat;
|
||||
@JsonProperty("Compressed")
|
||||
private Boolean compressed;
|
||||
@JsonProperty("NumberOfBuckets")
|
||||
private Integer numberOfBuckets;
|
||||
@JsonProperty("SerdeInfo")
|
||||
private SerDeInfo serdeInfo;
|
||||
@JsonProperty("Parameters")
|
||||
private Map<String, String> parameters;
|
||||
|
||||
public StorageDescriptor() {}
|
||||
|
||||
public List<Column> getColumns() { return columns; }
|
||||
public void setColumns(List<Column> columns) { this.columns = columns; }
|
||||
public String getLocation() { return location; }
|
||||
public void setLocation(String location) { this.location = location; }
|
||||
public String getInputFormat() { return inputFormat; }
|
||||
public void setInputFormat(String inputFormat) { this.inputFormat = inputFormat; }
|
||||
public String getOutputFormat() { return outputFormat; }
|
||||
public void setOutputFormat(String outputFormat) { this.outputFormat = outputFormat; }
|
||||
public Boolean getCompressed() { return compressed; }
|
||||
public void setCompressed(Boolean compressed) { this.compressed = compressed; }
|
||||
public Integer getNumberOfBuckets() { return numberOfBuckets; }
|
||||
public void setNumberOfBuckets(Integer numberOfBuckets) { this.numberOfBuckets = numberOfBuckets; }
|
||||
public SerDeInfo getSerdeInfo() { return serdeInfo; }
|
||||
public void setSerdeInfo(SerDeInfo serdeInfo) { this.serdeInfo = serdeInfo; }
|
||||
public Map<String, String> getParameters() { return parameters; }
|
||||
public void setParameters(Map<String, String> parameters) { this.parameters = parameters; }
|
||||
|
||||
@RegisterForReflection
|
||||
public static class SerDeInfo {
|
||||
@JsonProperty("Name")
|
||||
private String name;
|
||||
@JsonProperty("SerializationLibrary")
|
||||
private String serializationLibrary;
|
||||
@JsonProperty("Parameters")
|
||||
private Map<String, String> parameters;
|
||||
|
||||
public String getName() { return name; }
|
||||
public void setName(String name) { this.name = name; }
|
||||
public String getSerializationLibrary() { return serializationLibrary; }
|
||||
public void setSerializationLibrary(String serializationLibrary) { this.serializationLibrary = serializationLibrary; }
|
||||
public Map<String, String> getParameters() { return parameters; }
|
||||
public void setParameters(Map<String, String> parameters) { this.parameters = parameters; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package io.github.hectorvent.floci.services.glue.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
public class Table {
|
||||
@JsonProperty("Name")
|
||||
private String name;
|
||||
@JsonProperty("DatabaseName")
|
||||
private String databaseName;
|
||||
@JsonProperty("Description")
|
||||
private String description;
|
||||
@JsonProperty("CreateTime")
|
||||
@JsonFormat(shape = JsonFormat.Shape.NUMBER)
|
||||
private Instant createTime;
|
||||
@JsonProperty("UpdateTime")
|
||||
@JsonFormat(shape = JsonFormat.Shape.NUMBER)
|
||||
private Instant updateTime;
|
||||
@JsonProperty("LastAccessTime")
|
||||
@JsonFormat(shape = JsonFormat.Shape.NUMBER)
|
||||
private Instant lastAccessTime;
|
||||
@JsonProperty("PartitionKeys")
|
||||
private List<Column> partitionKeys;
|
||||
@JsonProperty("StorageDescriptor")
|
||||
private StorageDescriptor storageDescriptor;
|
||||
@JsonProperty("TableType")
|
||||
private String tableType;
|
||||
@JsonProperty("Parameters")
|
||||
private Map<String, String> parameters;
|
||||
|
||||
public Table() {}
|
||||
|
||||
public String getName() { return name; }
|
||||
public void setName(String name) { this.name = name; }
|
||||
public String getDatabaseName() { return databaseName; }
|
||||
public void setDatabaseName(String databaseName) { this.databaseName = databaseName; }
|
||||
public String getDescription() { return description; }
|
||||
public void setDescription(String description) { this.description = description; }
|
||||
public Instant getCreateTime() { return createTime; }
|
||||
public void setCreateTime(Instant createTime) { this.createTime = createTime; }
|
||||
public Instant getUpdateTime() { return updateTime; }
|
||||
public void setUpdateTime(Instant updateTime) { this.updateTime = updateTime; }
|
||||
public Instant getLastAccessTime() { return lastAccessTime; }
|
||||
public void setLastAccessTime(Instant lastAccessTime) { this.lastAccessTime = lastAccessTime; }
|
||||
public List<Column> getPartitionKeys() { return partitionKeys; }
|
||||
public void setPartitionKeys(List<Column> partitionKeys) { this.partitionKeys = partitionKeys; }
|
||||
public StorageDescriptor getStorageDescriptor() { return storageDescriptor; }
|
||||
public void setStorageDescriptor(StorageDescriptor storageDescriptor) { this.storageDescriptor = storageDescriptor; }
|
||||
public String getTableType() { return tableType; }
|
||||
public void setTableType(String tableType) { this.tableType = tableType; }
|
||||
public Map<String, String> getParameters() { return parameters; }
|
||||
public void setParameters(Map<String, String> parameters) { this.parameters = parameters; }
|
||||
}
|
||||
Reference in new issue
Block a user