Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #701 #702 #703 #729 refactored out postgres callbacks and message bus usage #705

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,39 @@ public LabelsUpdatedEvent(int testId, int datasetId, boolean isRecalculation) {
}

public static class EventNew {
public DataSet dataset;

public int datasetId;
public int testId;
public int runId;
public int labelId = -1;
public boolean isRecalculation;

public EventNew() {
}

public EventNew(DataSet dataset, boolean isRecalculation) {
this.dataset = dataset;
public EventNew(DataSet dataSet, boolean isRecalculation) {
this.datasetId = dataSet.id;
this.testId = dataSet.testid;
this.runId = dataSet.runId;
this.isRecalculation = isRecalculation;
}
public EventNew(int datasetId, int testId, int runId, int labelId, boolean isRecalculation) {
this.datasetId = datasetId;
this.testId = testId;
this.runId = runId;
this.labelId = labelId;
this.isRecalculation = isRecalculation;
}

@Override
public String toString() {
return "DataSetDTO.EventNew{dataset=" + this.dataset.id + " (" + this.dataset.runId + "/" + this.dataset.ordinal + "), isRecalculation=" + this.isRecalculation + '}';
return "EventNew{" +
"datasetId=" + datasetId +
", testId=" + testId +
", runId=" + runId +
", labelId=" + labelId +
", isRecalculation=" + isRecalculation +
'}';
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,7 @@ class ComparisonResult {
public String result;

public ComparisonResult() {
this.overall = null;
this.experimentValue = 0.0;
this.baselineValue = 0.0;
this.result = null;
}

public ComparisonResult(BetterOrWorse overall, double experimentValue, double baselineValue, String result) {
this.overall = overall;
this.experimentValue = experimentValue;
Expand Down
4 changes: 4 additions & 0 deletions horreum-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-reactive-messaging-amqp</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-postgresql</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

public enum MessageBusChannels {
DATAPOINT_NEW,
DATAPOINT_DELETED,
DATAPOINT_PROCESSED,
DATASET_NEW,
DATASET_UPDATED_LABELS,
DATASET_MISSING_VALUES,
DATASET_DELETED,
DATASET_VALIDATED,
DATASET_CHANGES_NEW,
TEST_NEW,
Expand All @@ -18,7 +16,4 @@ public enum MessageBusChannels {
CHANGE_NEW,
EXPERIMENT_RESULT_NEW,
FOOBAR



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package io.hyperfoil.tools.horreum.converter;

import io.smallrye.reactive.messaging.MessageConverter;
import io.smallrye.reactive.messaging.amqp.IncomingAmqpMetadata;
import io.vertx.core.json.JsonObject;
import jakarta.enterprise.context.ApplicationScoped;
import org.eclipse.microprofile.reactive.messaging.Message;

import java.lang.reflect.Type;
@ApplicationScoped
public class JsonToEventConverter implements MessageConverter {
@Override
public boolean canConvert(Message<?> in, Type target) {
return in.getMetadata(IncomingAmqpMetadata.class)
.map(meta -> meta.getContentType().equals("application/json") && target instanceof Class)
.orElse(false);
}

@Override
public Message<?> convert(Message<?> in, Type target) {
return in.withPayload(((JsonObject) in.getPayload()).mapTo((Class<?>) target));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
import org.hibernate.annotations.Type;

@Entity(name = "Fingerprint")
@Immutable
public class FingerprintDAO extends PanacheEntityBase {
@Id
@Column(name = "dataset_id")
public int datasetId;
public Integer datasetId;

@OneToOne(fetch = FetchType.LAZY)
@MapsId
Expand All @@ -33,4 +32,11 @@ public class FingerprintDAO extends PanacheEntityBase {
@Column(columnDefinition = "jsonb")
public JsonNode fingerprint;

@Override
public String toString() {
return "FP{" +
"datasetId=" + datasetId +
", fingerprint=" + fingerprint +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import jakarta.validation.constraints.NotNull;
import org.hibernate.annotations.Type;

import java.util.Objects;

@Embeddable
public class ValidationErrorDAO {
@ManyToOne(fetch = FetchType.LAZY, optional = false)
Expand All @@ -27,4 +29,25 @@ public void setSchema(int id) {
public Integer getSchemaId() {
return schema == null ? null : schema.id;
}

@Override
public String toString() {
return "ValidationErrorDAO{" +
"schema=" + schema.id +
", error=" + error +
'}';
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ValidationErrorDAO that = (ValidationErrorDAO) o;
return Objects.equals(schema.id, that.schema.id) && Objects.equals(error, that.error);
}

@Override
public int hashCode() {
return Objects.hash(schema.id, error);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ public static void deleteForDataset(int id) {
MissingDataRuleResultDAO.delete("pk.datasetId", id);
}

public static void deleteForDataRule(int id) {
MissingDataRuleResultDAO.delete("pk.ruleId", id);
}

public static void deleteOlder(int ruleId, Instant timestamp) {
MissingDataRuleResultDAO.delete("pk.ruleId = ?1 AND timestamp < ?2", ruleId, timestamp);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,13 @@ public ExtractorDAO(String name, String jsonpath, boolean array) {
this.jsonpath = jsonpath;
this.array = array;
}

@Override
public String toString() {
return "ExtractorDAO{" +
"name='" + name + '\'' +
", jsonpath='" + jsonpath + '\'' +
", array=" + array +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@

import io.quarkus.hibernate.orm.panache.PanacheEntityBase;

/* When we make changes to label we need to ensure that we remove label_values where label_id = id
* After delete on extractors we need to execute:
* https://github.com/Hyperfoil/Horreum/blob/master/horreum-backend/src/main/resources/db/changeLog.xml#L2566
* */
@Entity(name="label")
public class LabelDAO extends OwnedEntityBase {
@Id
Expand Down Expand Up @@ -69,6 +73,19 @@ public void setSchema(int schemaId) {
schema = getEntityManager().getReference(SchemaDAO.class, schemaId);
}

@Override
public String toString() {
return "LabelDAO{" +
"id=" + id +
", name='" + name + '\'' +
", schemaId=" + schema.id +
", extractors=" + extractors +
", function='" + function + '\'' +
", filtering=" + filtering +
", metrics=" + metrics +
'}';
}

@Entity
@Table(name = "label_values")
public static class Value extends PanacheEntityBase implements Serializable {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ public class ActionServiceImpl implements ActionService {
@Inject
Vertx vertx;

@Inject
MessageBus messageBus;

@Inject
EncryptionManager encryptionManager;

Expand All @@ -78,11 +75,6 @@ public class ActionServiceImpl implements ActionService {
@PostConstruct()
public void postConstruct(){
plugins = actionPlugins.stream().collect(Collectors.toMap(ActionPlugin::type, Function.identity()));
messageBus.subscribe(MessageBusChannels.TEST_NEW, "ActionService", Test.class, this::onNewTest);
messageBus.subscribe(MessageBusChannels.TEST_DELETED, "ActionService", Test.class, this::onTestDelete);
messageBus.subscribe(MessageBusChannels.RUN_NEW, "ActionService", Run.class, this::onNewRun);
messageBus.subscribe(MessageBusChannels.CHANGE_NEW, "ActionService", Change.Event.class, this::onNewChange);
messageBus.subscribe(MessageBusChannels.EXPERIMENT_RESULT_NEW, "ActionService", ExperimentService.ExperimentResult.class, this::onNewExperimentResult);
}

private void executeActions(MessageBusChannels event, int testId, Object payload, boolean notify){
Expand Down Expand Up @@ -142,8 +134,8 @@ public void onNewTest(Test test) {

@WithRoles(extras = Roles.HORREUM_SYSTEM)
@Transactional
public void onTestDelete(Test test) {
ActionDAO.delete("testId", test.id);
public void onTestDelete(int testId) {
ActionDAO.delete("testId", testId);
}

@WithRoles(extras = Roles.HORREUM_SYSTEM)
Expand Down
Loading
Loading