This is an automated email from the ASF dual-hosted git repository. lahirujayathilake pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/airavata-custos.git
commit b3640e86f20bab7db71eccf90791155d2a6de9e6 Author: lahiruj <[email protected]> AuthorDate: Mon Sep 22 23:08:30 2025 -0400 model classes for AMIE service --- amie-decoder/pom.xml | 69 ++++++++- .../main/assembly/amie-decoder-bin-assembly.xml | 1 - .../apache/custos/amie/AmieDecoderApplication.java | 2 + .../apache/custos/amie/config/AmieProperties.java | 121 ++++++++++++++++ .../org/apache/custos/amie/config/AppConfig.java | 38 +++++ .../org/apache/custos/amie/model/PacketEntity.java | 152 ++++++++++++++++++++ .../PacketStatus.java} | 35 +++-- .../custos/amie/model/ProcessingErrorEntity.java | 107 ++++++++++++++ .../custos/amie/model/ProcessingEventEntity.java | 157 +++++++++++++++++++++ .../ProcessingEventType.java} | 21 +-- .../ProcessingStatus.java} | 35 +++-- .../PacketRepository.java} | 31 ++-- .../ProcessingErrorRepository.java} | 23 ++- .../ProcessingEventRepository.java} | 28 ++-- amie-decoder/src/main/proto/amie_packets.proto | 1 + amie-decoder/src/main/proto/internal_events.proto | 1 + amie-decoder/src/main/resources/application.yml | 16 +++ .../resources/distribution/conf/application.yml | 16 +++ pom.xml | 2 +- 19 files changed, 762 insertions(+), 94 deletions(-) diff --git a/amie-decoder/pom.xml b/amie-decoder/pom.xml index 5e8eb2ed6..42446c6d7 100644 --- a/amie-decoder/pom.xml +++ b/amie-decoder/pom.xml @@ -1,6 +1,24 @@ <?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> @@ -26,6 +44,16 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-data-jpa</artifactId> + <exclusions> + <exclusion> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-to-slf4j</artifactId> + </exclusion> + </exclusions> + </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>jul-to-slf4j</artifactId> @@ -35,17 +63,24 @@ <artifactId>mysql-connector-java</artifactId> </dependency> <dependency> - <groupId>org.apache.custos</groupId> - <artifactId>custos-core</artifactId> - <version>${project.version}</version> + <groupId>org.flywaydb</groupId> + <artifactId>flyway-core</artifactId> </dependency> <dependency> - <groupId>org.springframework.vault</groupId> - <artifactId>spring-vault-core</artifactId> + <groupId>com.google.protobuf</groupId> + <artifactId>protobuf-java</artifactId> </dependency> </dependencies> <build> + <extensions> + <extension> + <groupId>kr.motd.maven</groupId> + <artifactId>os-maven-plugin</artifactId> + <version>1.7.0</version> + </extension> + </extensions> + <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> @@ -69,6 +104,26 @@ </execution> </executions> </plugin> + <plugin> + <groupId>org.xolstice.maven.plugins</groupId> + <artifactId>protobuf-maven-plugin</artifactId> + <version>${protobuf.maven.plugin}</version> + <configuration> + <protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier} + </protocArtifact> + <pluginId>grpc-java</pluginId> + <pluginArtifact>io.grpc:protoc-gen-grpc-java:${io.grpc.version}:exe:${os.detected.classifier} + </pluginArtifact> + </configuration> + <executions> + <execution> + <goals> + <goal>compile</goal> + <goal>compile-custom</goal> + </goals> + </execution> + </executions> + </plugin> </plugins> </build> diff --git a/amie-decoder/src/main/assembly/amie-decoder-bin-assembly.xml b/amie-decoder/src/main/assembly/amie-decoder-bin-assembly.xml index 43edf6f98..0ff1667d9 100644 --- a/amie-decoder/src/main/assembly/amie-decoder-bin-assembly.xml +++ b/amie-decoder/src/main/assembly/amie-decoder-bin-assembly.xml @@ -1,4 +1,3 @@ - <!-- Licensed to the Apache Software Foundation (ASF) under one diff --git a/amie-decoder/src/main/java/org/apache/custos/amie/AmieDecoderApplication.java b/amie-decoder/src/main/java/org/apache/custos/amie/AmieDecoderApplication.java index c3d6813ab..6dffe2d0f 100644 --- a/amie-decoder/src/main/java/org/apache/custos/amie/AmieDecoderApplication.java +++ b/amie-decoder/src/main/java/org/apache/custos/amie/AmieDecoderApplication.java @@ -22,9 +22,11 @@ package org.apache.custos.amie; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.data.jpa.repository.config.EnableJpaAuditing; +import org.springframework.scheduling.annotation.EnableScheduling; @SpringBootApplication @EnableJpaAuditing +@EnableScheduling public class AmieDecoderApplication { public static void main(String[] args) { SpringApplication.run(AmieDecoderApplication.class, args); diff --git a/amie-decoder/src/main/java/org/apache/custos/amie/config/AmieProperties.java b/amie-decoder/src/main/java/org/apache/custos/amie/config/AmieProperties.java new file mode 100644 index 000000000..a4daac8ae --- /dev/null +++ b/amie-decoder/src/main/java/org/apache/custos/amie/config/AmieProperties.java @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.custos.amie.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +import java.time.Duration; + +@ConfigurationProperties(prefix = "app.amie") +public class AmieProperties { + + /** + * The base URL for the AMIE Client API. + */ + private String baseUrl; + + /** + * ACCESS CI provided site code (e.g., "NEXUS") for the XA-SITE header + */ + private String siteCode; + + /** + * ACCESS CI provided API key for the XA-API-KEY header + */ + private String apiKey; + + + private final Scheduler scheduler = new Scheduler(); + + private final Client client = new Client(); + + public static class Scheduler { + private Duration pollDelay = Duration.ofSeconds(30); + private Duration workerDelay = Duration.ofSeconds(5); + + public Duration getPollDelay() { + return pollDelay; + } + + public void setPollDelay(Duration pollDelay) { + this.pollDelay = pollDelay; + } + + public Duration getWorkerDelay() { + return workerDelay; + } + + public void setWorkerDelay(Duration workerDelay) { + this.workerDelay = workerDelay; + } + } + + public static class Client { + private Duration connectTimeout = Duration.ofSeconds(5); + private Duration readTimeout = Duration.ofSeconds(20); + + public Duration getConnectTimeout() { + return connectTimeout; + } + + public void setConnectTimeout(Duration connectTimeout) { + this.connectTimeout = connectTimeout; + } + + public Duration getReadTimeout() { + return readTimeout; + } + + public void setReadTimeout(Duration readTimeout) { + this.readTimeout = readTimeout; + } + } + + public String getBaseUrl() { + return baseUrl; + } + + public void setBaseUrl(String baseUrl) { + this.baseUrl = baseUrl; + } + + public String getSiteCode() { + return siteCode; + } + + public void setSiteCode(String siteCode) { + this.siteCode = siteCode; + } + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + public Scheduler getScheduler() { + return scheduler; + } + + public Client getClient() { + return client; + } +} diff --git a/amie-decoder/src/main/java/org/apache/custos/amie/config/AppConfig.java b/amie-decoder/src/main/java/org/apache/custos/amie/config/AppConfig.java new file mode 100644 index 000000000..a56fb6b01 --- /dev/null +++ b/amie-decoder/src/main/java/org/apache/custos/amie/config/AppConfig.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.custos.amie.config; + +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.client.RestTemplate; + +@Configuration +@EnableConfigurationProperties(AmieProperties.class) +public class AppConfig { + + @Bean("amieRestTemplate") + public RestTemplate amieRestTemplate(AmieProperties properties) { + return new RestTemplateBuilder() + .setConnectTimeout(properties.getClient().getConnectTimeout()) + .setReadTimeout(properties.getClient().getReadTimeout()) + .build(); + } +} \ No newline at end of file diff --git a/amie-decoder/src/main/java/org/apache/custos/amie/model/PacketEntity.java b/amie-decoder/src/main/java/org/apache/custos/amie/model/PacketEntity.java new file mode 100644 index 000000000..17ede689f --- /dev/null +++ b/amie-decoder/src/main/java/org/apache/custos/amie/model/PacketEntity.java @@ -0,0 +1,152 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.custos.amie.model; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.Lob; +import jakarta.persistence.Table; + +import java.time.Instant; + +@Entity +@Table(name = "packets") +public class PacketEntity { + + @Id + @GeneratedValue(generator = "uuid") + private String id; + + @Column(name = "amie_id", nullable = false, unique = true) + private Long amieId; + + @Column(name = "type", nullable = false, length = 64) + private String type; + + @Enumerated(EnumType.STRING) + @Column(name = "status", nullable = false, length = 32) + private PacketStatus status = PacketStatus.NEW; + + @Lob + @Column(name = "raw_json", columnDefinition = "JSON", nullable = false) + private String rawJson; + + @Column(name = "received_at", nullable = false) + private Instant receivedAt = Instant.now(); + + @Column(name = "decoded_at") + private Instant decodedAt; + + @Column(name = "processed_at") + private Instant processedAt; + + @Column(name = "retries", nullable = false) + private int retries = 0; + + @Lob + @Column(name = "last_error") + private String lastError; + + public PacketEntity() { + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Long getAmieId() { + return amieId; + } + + public void setAmieId(Long amieId) { + this.amieId = amieId; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public PacketStatus getStatus() { + return status; + } + + public void setStatus(PacketStatus status) { + this.status = status; + } + + public String getRawJson() { + return rawJson; + } + + public void setRawJson(String rawJson) { + this.rawJson = rawJson; + } + + public Instant getReceivedAt() { + return receivedAt; + } + + public void setReceivedAt(Instant receivedAt) { + this.receivedAt = receivedAt; + } + + public Instant getDecodedAt() { + return decodedAt; + } + + public void setDecodedAt(Instant decodedAt) { + this.decodedAt = decodedAt; + } + + public Instant getProcessedAt() { + return processedAt; + } + + public void setProcessedAt(Instant processedAt) { + this.processedAt = processedAt; + } + + public int getRetries() { + return retries; + } + + public void setRetries(int retries) { + this.retries = retries; + } + + public String getLastError() { + return lastError; + } + + public void setLastError(String lastError) { + this.lastError = lastError; + } +} diff --git a/amie-decoder/src/main/java/org/apache/custos/amie/AmieDecoderApplication.java b/amie-decoder/src/main/java/org/apache/custos/amie/model/PacketStatus.java similarity index 50% copy from amie-decoder/src/main/java/org/apache/custos/amie/AmieDecoderApplication.java copy to amie-decoder/src/main/java/org/apache/custos/amie/model/PacketStatus.java index c3d6813ab..a35680243 100644 --- a/amie-decoder/src/main/java/org/apache/custos/amie/AmieDecoderApplication.java +++ b/amie-decoder/src/main/java/org/apache/custos/amie/model/PacketStatus.java @@ -7,26 +7,33 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * + * specific language governing permissions and limitations + * under the License. */ -package org.apache.custos.amie; +package org.apache.custos.amie.model; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.data.jpa.repository.config.EnableJpaAuditing; +public enum PacketStatus { -@SpringBootApplication -@EnableJpaAuditing -public class AmieDecoderApplication { - public static void main(String[] args) { - SpringApplication.run(AmieDecoderApplication.class, args); - } + /** + * Packet has been received from the AMIE API and persisted but has not yet been processed. + */ + NEW, + /** + * The packet's raw JSON content has been successfully parsed, and the initial processing event has been created. + */ + DECODED, + /** + * All required processing events have been completed successfully. + */ + PROCESSED, + /** + * The processing of this packet failed and will not be automatically retried. + */ + FAILED } diff --git a/amie-decoder/src/main/java/org/apache/custos/amie/model/ProcessingErrorEntity.java b/amie-decoder/src/main/java/org/apache/custos/amie/model/ProcessingErrorEntity.java new file mode 100644 index 000000000..ae9ef13bb --- /dev/null +++ b/amie-decoder/src/main/java/org/apache/custos/amie/model/ProcessingErrorEntity.java @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.custos.amie.model; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.Lob; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; + +import java.time.Instant; + +@Entity +@Table(name = "processing_errors") +public class ProcessingErrorEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "packet_id") + private PacketEntity packet; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "event_id") + private ProcessingEventEntity event; + + @Column(name = "occurred_at", nullable = false) + private Instant occurredAt = Instant.now(); + + @Column(name = "summary", nullable = false) + private String summary; + + @Lob + @Column(name = "detail") + private String detail; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public PacketEntity getPacket() { + return packet; + } + + public void setPacket(PacketEntity packet) { + this.packet = packet; + } + + public ProcessingEventEntity getEvent() { + return event; + } + + public void setEvent(ProcessingEventEntity event) { + this.event = event; + } + + public Instant getOccurredAt() { + return occurredAt; + } + + public void setOccurredAt(Instant occurredAt) { + this.occurredAt = occurredAt; + } + + public String getSummary() { + return summary; + } + + public void setSummary(String summary) { + this.summary = summary; + } + + public String getDetail() { + return detail; + } + + public void setDetail(String detail) { + this.detail = detail; + } +} diff --git a/amie-decoder/src/main/java/org/apache/custos/amie/model/ProcessingEventEntity.java b/amie-decoder/src/main/java/org/apache/custos/amie/model/ProcessingEventEntity.java new file mode 100644 index 000000000..87673d7ee --- /dev/null +++ b/amie-decoder/src/main/java/org/apache/custos/amie/model/ProcessingEventEntity.java @@ -0,0 +1,157 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.custos.amie.model; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.Lob; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; + +import java.time.Instant; + +@Entity +@Table(name = "processing_events") +public class ProcessingEventEntity { + + @Id + @GeneratedValue(generator = "uuid") + private String id; + + @ManyToOne(fetch = FetchType.LAZY, optional = false) + @JoinColumn(name = "packet_id", nullable = false) + private PacketEntity packet; + + @Enumerated(EnumType.STRING) + @Column(name = "type", nullable = false, length = 64) + private ProcessingEventType type; + + @Enumerated(EnumType.STRING) + @Column(name = "status", nullable = false, length = 32) + private ProcessingStatus status = ProcessingStatus.NEW; + + @Column(name = "attempts", nullable = false) + private int attempts = 0; + + @Lob + @Column(name = "payload", nullable = false) + private byte[] payload; + + @Column(name = "created_at", nullable = false) + private Instant createdAt = Instant.now(); + + @Column(name = "started_at") + private Instant startedAt; + + @Column(name = "finished_at") + private Instant finishedAt; + + @Lob + @Column(name = "last_error") + private String lastError; + + public ProcessingEventEntity() { + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public PacketEntity getPacket() { + return packet; + } + + public void setPacket(PacketEntity packet) { + this.packet = packet; + } + + public ProcessingEventType getType() { + return type; + } + + public void setType(ProcessingEventType type) { + this.type = type; + } + + public ProcessingStatus getStatus() { + return status; + } + + public void setStatus(ProcessingStatus status) { + this.status = status; + } + + public int getAttempts() { + return attempts; + } + + public void setAttempts(int attempts) { + this.attempts = attempts; + } + + public byte[] getPayload() { + return payload; + } + + public void setPayload(byte[] payload) { + this.payload = payload; + } + + public Instant getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Instant createdAt) { + this.createdAt = createdAt; + } + + public Instant getStartedAt() { + return startedAt; + } + + public void setStartedAt(Instant startedAt) { + this.startedAt = startedAt; + } + + public Instant getFinishedAt() { + return finishedAt; + } + + public void setFinishedAt(Instant finishedAt) { + this.finishedAt = finishedAt; + } + + public String getLastError() { + return lastError; + } + + public void setLastError(String lastError) { + this.lastError = lastError; + } +} diff --git a/amie-decoder/src/main/java/org/apache/custos/amie/AmieDecoderApplication.java b/amie-decoder/src/main/java/org/apache/custos/amie/model/ProcessingEventType.java similarity index 54% copy from amie-decoder/src/main/java/org/apache/custos/amie/AmieDecoderApplication.java copy to amie-decoder/src/main/java/org/apache/custos/amie/model/ProcessingEventType.java index c3d6813ab..e798d5b34 100644 --- a/amie-decoder/src/main/java/org/apache/custos/amie/AmieDecoderApplication.java +++ b/amie-decoder/src/main/java/org/apache/custos/amie/model/ProcessingEventType.java @@ -7,26 +7,17 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * + * specific language governing permissions and limitations + * under the License. */ -package org.apache.custos.amie; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.data.jpa.repository.config.EnableJpaAuditing; +package org.apache.custos.amie.model; -@SpringBootApplication -@EnableJpaAuditing -public class AmieDecoderApplication { - public static void main(String[] args) { - SpringApplication.run(AmieDecoderApplication.class, args); - } +public enum ProcessingEventType { + DECODE_PACKET } diff --git a/amie-decoder/src/main/java/org/apache/custos/amie/AmieDecoderApplication.java b/amie-decoder/src/main/java/org/apache/custos/amie/model/ProcessingStatus.java similarity index 54% copy from amie-decoder/src/main/java/org/apache/custos/amie/AmieDecoderApplication.java copy to amie-decoder/src/main/java/org/apache/custos/amie/model/ProcessingStatus.java index c3d6813ab..5d4cf3865 100644 --- a/amie-decoder/src/main/java/org/apache/custos/amie/AmieDecoderApplication.java +++ b/amie-decoder/src/main/java/org/apache/custos/amie/model/ProcessingStatus.java @@ -7,26 +7,33 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * + * specific language governing permissions and limitations + * under the License. */ -package org.apache.custos.amie; +package org.apache.custos.amie.model; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.data.jpa.repository.config.EnableJpaAuditing; +public enum ProcessingStatus { -@SpringBootApplication -@EnableJpaAuditing -public class AmieDecoderApplication { - public static void main(String[] args) { - SpringApplication.run(AmieDecoderApplication.class, args); - } + /** + * The event has been created and is waiting to be processed by a worker. + */ + NEW, + /** + * A worker has picked up the event and is actively processing it. + */ + RUNNING, + /** + * The event was processed successfully. + */ + SUCCEEDED, + /** + * The event failed processing and will not be automatically retried. + */ + FAILED } diff --git a/amie-decoder/src/main/java/org/apache/custos/amie/AmieDecoderApplication.java b/amie-decoder/src/main/java/org/apache/custos/amie/repo/PacketRepository.java similarity index 50% copy from amie-decoder/src/main/java/org/apache/custos/amie/AmieDecoderApplication.java copy to amie-decoder/src/main/java/org/apache/custos/amie/repo/PacketRepository.java index c3d6813ab..5929f0543 100644 --- a/amie-decoder/src/main/java/org/apache/custos/amie/AmieDecoderApplication.java +++ b/amie-decoder/src/main/java/org/apache/custos/amie/repo/PacketRepository.java @@ -7,26 +7,29 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * + * specific language governing permissions and limitations + * under the License. */ -package org.apache.custos.amie; +package org.apache.custos.amie.repo; + +import org.apache.custos.amie.model.PacketEntity; +import org.apache.custos.amie.model.PacketStatus; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.Optional; +import java.util.stream.Stream; + +@Repository +public interface PacketRepository extends JpaRepository<PacketEntity, String> { -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.data.jpa.repository.config.EnableJpaAuditing; + Optional<PacketEntity> findByAmieId(Long amieId); -@SpringBootApplication -@EnableJpaAuditing -public class AmieDecoderApplication { - public static void main(String[] args) { - SpringApplication.run(AmieDecoderApplication.class, args); - } + Stream<PacketEntity> findTop50ByStatusOrderByReceivedAtAsc(PacketStatus status); } diff --git a/amie-decoder/src/main/java/org/apache/custos/amie/AmieDecoderApplication.java b/amie-decoder/src/main/java/org/apache/custos/amie/repo/ProcessingErrorRepository.java similarity index 55% copy from amie-decoder/src/main/java/org/apache/custos/amie/AmieDecoderApplication.java copy to amie-decoder/src/main/java/org/apache/custos/amie/repo/ProcessingErrorRepository.java index c3d6813ab..a5e76e870 100644 --- a/amie-decoder/src/main/java/org/apache/custos/amie/AmieDecoderApplication.java +++ b/amie-decoder/src/main/java/org/apache/custos/amie/repo/ProcessingErrorRepository.java @@ -7,26 +7,21 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * + * specific language governing permissions and limitations + * under the License. */ -package org.apache.custos.amie; +package org.apache.custos.amie.repo; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.data.jpa.repository.config.EnableJpaAuditing; +import org.apache.custos.amie.model.ProcessingErrorEntity; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; -@SpringBootApplication -@EnableJpaAuditing -public class AmieDecoderApplication { - public static void main(String[] args) { - SpringApplication.run(AmieDecoderApplication.class, args); - } +@Repository +public interface ProcessingErrorRepository extends JpaRepository<ProcessingErrorEntity, Long> { } diff --git a/amie-decoder/src/main/java/org/apache/custos/amie/AmieDecoderApplication.java b/amie-decoder/src/main/java/org/apache/custos/amie/repo/ProcessingEventRepository.java similarity index 51% copy from amie-decoder/src/main/java/org/apache/custos/amie/AmieDecoderApplication.java copy to amie-decoder/src/main/java/org/apache/custos/amie/repo/ProcessingEventRepository.java index c3d6813ab..24c1fd854 100644 --- a/amie-decoder/src/main/java/org/apache/custos/amie/AmieDecoderApplication.java +++ b/amie-decoder/src/main/java/org/apache/custos/amie/repo/ProcessingEventRepository.java @@ -7,26 +7,26 @@ * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * + * specific language governing permissions and limitations + * under the License. */ -package org.apache.custos.amie; +package org.apache.custos.amie.repo; + +import org.apache.custos.amie.model.ProcessingEventEntity; +import org.apache.custos.amie.model.ProcessingStatus; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.stream.Stream; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.data.jpa.repository.config.EnableJpaAuditing; +@Repository +public interface ProcessingEventRepository extends JpaRepository<ProcessingEventEntity, String> { -@SpringBootApplication -@EnableJpaAuditing -public class AmieDecoderApplication { - public static void main(String[] args) { - SpringApplication.run(AmieDecoderApplication.class, args); - } + Stream<ProcessingEventEntity> findTop50ByStatusOrderByCreatedAtAsc(ProcessingStatus status); } diff --git a/amie-decoder/src/main/proto/amie_packets.proto b/amie-decoder/src/main/proto/amie_packets.proto index 23c51d3ab..804c39e96 100644 --- a/amie-decoder/src/main/proto/amie_packets.proto +++ b/amie-decoder/src/main/proto/amie_packets.proto @@ -1,5 +1,6 @@ syntax = "proto3"; +option java_multiple_files = true; package org.apache.custos.amie.v1; import "google/protobuf/struct.proto"; diff --git a/amie-decoder/src/main/proto/internal_events.proto b/amie-decoder/src/main/proto/internal_events.proto index 8c68ee929..5959ffceb 100644 --- a/amie-decoder/src/main/proto/internal_events.proto +++ b/amie-decoder/src/main/proto/internal_events.proto @@ -1,5 +1,6 @@ syntax = "proto3"; +option java_multiple_files = true; package org.apache.custos.amie.internal.events.v1; import "google/protobuf/timestamp.proto"; diff --git a/amie-decoder/src/main/resources/application.yml b/amie-decoder/src/main/resources/application.yml index 163c6c485..3add2af62 100644 --- a/amie-decoder/src/main/resources/application.yml +++ b/amie-decoder/src/main/resources/application.yml @@ -28,8 +28,24 @@ spring: jpa: hibernate: ddl-auto: update + properties: + hibernate.jdbc.time_zone: UTC show-sql: false database-platform: org.hibernate.dialect.MySQL8Dialect + flyway: + locations: classpath:db/migration + +app: + amie: + base-url: https://a3mdev.xsede.org/amie-api-test + site-code: ${AMIE_SITE_CODE} + api-key: ${AMIE_API_KEY} + scheduler: + poll-delay: 30s + worker-delay: 5s + client: + connect-timeout: 5s + read-timeout: 20s logging: pattern: diff --git a/amie-decoder/src/main/resources/distribution/conf/application.yml b/amie-decoder/src/main/resources/distribution/conf/application.yml index 163c6c485..3add2af62 100644 --- a/amie-decoder/src/main/resources/distribution/conf/application.yml +++ b/amie-decoder/src/main/resources/distribution/conf/application.yml @@ -28,8 +28,24 @@ spring: jpa: hibernate: ddl-auto: update + properties: + hibernate.jdbc.time_zone: UTC show-sql: false database-platform: org.hibernate.dialect.MySQL8Dialect + flyway: + locations: classpath:db/migration + +app: + amie: + base-url: https://a3mdev.xsede.org/amie-api-test + site-code: ${AMIE_SITE_CODE} + api-key: ${AMIE_API_KEY} + scheduler: + poll-delay: 30s + worker-delay: 5s + client: + connect-timeout: 5s + read-timeout: 20s logging: pattern: diff --git a/pom.xml b/pom.xml index 6f6852512..a46cb3790 100644 --- a/pom.xml +++ b/pom.xml @@ -191,7 +191,7 @@ <springdoc.version>2.5.0</springdoc.version> <protobuf.maven.plugin>0.6.1</protobuf.maven.plugin> - <protobuf.version>3.24.0</protobuf.version> + <protobuf.version>4.32.1</protobuf.version> <protobuf.json.version>0.9.15</protobuf.json.version> <io.grpc.version>1.58.0</io.grpc.version> <com.google.protobuf.util>3.21.11</com.google.protobuf.util>
