diff --git a/performance-test/python-test/main.py b/performance-test/python-test/main.py index 5828067e..ee087c97 100644 --- a/performance-test/python-test/main.py +++ b/performance-test/python-test/main.py @@ -3,13 +3,13 @@ import methods -NUMBER_OF_PAYMENTS = 5000 +NUMBER_OF_PAYMENTS = 30000 MAX_PAYMENTS_PER_ADD_OPERATION = 1000 def main(URL, subkey): logging.basicConfig(level=logging.INFO) - flow_date = "2024-10-15" + flow_date = "2024-10-30" tmstmp = timestamp = int(time.time()) flow_name = f"{flow_date}88888888888-{tmstmp}" diff --git a/performance-test/python-test/methods.py b/performance-test/python-test/methods.py index 4211c062..3045161e 100644 --- a/performance-test/python-test/methods.py +++ b/performance-test/python-test/methods.py @@ -1,5 +1,5 @@ +import random import json, logging, requests, time -import utility def create_empty_flow(url, flow_name, flow_date, total_payments, key): @@ -85,13 +85,13 @@ def generate_payments(number_of_payments, total_amount, date): payments = [] iuvs = set() for idx in range(number_of_payments): - iuv = utility.get_random_numeric_string(15) + iuv = get_random_numeric_string(15) if iuv not in iuvs: iuvs.add(iuv) payments.append({ "index": idx + 1, "iuv": iuv, - "iur": utility.get_random_numeric_string(11), + "iur": get_random_numeric_string(11), "pay": total_amount / number_of_payments, "idTransfer": 1, "payStatus": "EXECUTED", diff --git a/src/main/java/it/gov/pagopa/fdr/repository/fdr/FdrPaymentInsertEntity.java b/src/main/java/it/gov/pagopa/fdr/repository/fdr/FdrPaymentInsertEntity.java index f9fdbecf..fffc5c97 100644 --- a/src/main/java/it/gov/pagopa/fdr/repository/fdr/FdrPaymentInsertEntity.java +++ b/src/main/java/it/gov/pagopa/fdr/repository/fdr/FdrPaymentInsertEntity.java @@ -67,6 +67,12 @@ public static PanacheQuery findByFdrAndPspId(String fdr, Parameters.with("fdr", fdr).and("pspId", pspId).map()); } + public static void deleteByFdrAndIds(String fdr, List objectIds) { + delete( + "ref_fdr = :fdr and _id in :objectIds", + Parameters.with("fdr", fdr).and("ids", objectIds).map()); + } + public static long deleteByFdrAndIndexes(String fdr, List indexList) { return delete( "ref_fdr = :fdr and index in :indexes", diff --git a/src/main/java/it/gov/pagopa/fdr/repository/fdr/FdrPaymentPublishEntityReactive.java b/src/main/java/it/gov/pagopa/fdr/repository/fdr/FdrPaymentPublishEntityReactive.java deleted file mode 100644 index ddf17536..00000000 --- a/src/main/java/it/gov/pagopa/fdr/repository/fdr/FdrPaymentPublishEntityReactive.java +++ /dev/null @@ -1,19 +0,0 @@ -package it.gov.pagopa.fdr.repository.fdr; - -import io.quarkus.mongodb.panache.common.MongoEntity; -import io.quarkus.mongodb.panache.reactive.ReactivePanacheMongoEntity; -import io.smallrye.mutiny.Uni; -import java.util.List; -import lombok.Data; -import lombok.EqualsAndHashCode; - -@Data -@EqualsAndHashCode(callSuper = true) -@MongoEntity(collection = "fdr_payment_publish") -public class FdrPaymentPublishEntityReactive extends ReactivePanacheMongoEntity { - - // Reactive persistence method for FdrPaymentPublishEntity objects - public static Uni persistFdrPaymentPublishEntities(List entities) { - return persist(entities); - } -} diff --git a/src/main/java/it/gov/pagopa/fdr/service/psps/PspsService.java b/src/main/java/it/gov/pagopa/fdr/service/psps/PspsService.java index 6e61f75d..26ab1cee 100644 --- a/src/main/java/it/gov/pagopa/fdr/service/psps/PspsService.java +++ b/src/main/java/it/gov/pagopa/fdr/service/psps/PspsService.java @@ -35,6 +35,7 @@ import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; import java.util.stream.IntStream; +import org.bson.types.ObjectId; import org.jboss.logging.Logger; import org.jboss.logging.MDC; @@ -362,8 +363,8 @@ private void batchDelete(String fdr, List paymentInsertE .toList(); // sequential stream batches.forEach(batch -> { - List indexes = paymentInsertEntities.stream().map(FdrPaymentInsertEntity::getIndex).toList(); - FdrPaymentInsertEntity.deleteByFdrAndIndexes(fdr, indexes); + List objectIds = paymentInsertEntities.stream().map(entity -> entity.id).toList(); + FdrPaymentInsertEntity.deleteByFdrAndIds(fdr, objectIds); }); } @@ -374,15 +375,15 @@ private void parallelPersist(String fdr, List fdrPaymen .mapToObj(i -> fdrPaymentPublishEntities.subList(i * batchSize, Math.min((i + 1) * batchSize, fdrPaymentPublishEntities.size()))) .toList(); batchesPublish.parallelStream().forEach(FdrPaymentPublishEntity::persistFdrPaymentPublishEntities); - log.infof("Published fdrPaymentPublishEntities of fdr[%s]", fdr); + log.debugf("Published fdrPaymentPublishEntities of fdr[%s]", fdr); } private void addToConversionQueue(boolean internalPublish, FdrInsertEntity fdrEntity) { // add to conversion queue if (internalPublish) { - log.info("NOT Add FdrInsertEntity in queue fdr message"); + log.debugf("NOT Add FdrInsertEntity in queue fdr message"); } else { - log.info("Starting add FdrInsertEntity in queue fdr message"); + log.debugf("Starting add FdrInsertEntity in queue fdr message"); conversionQueue.addQueueFlowMessage( FdrMessage.builder() .fdr(fdrEntity.getFdr()) @@ -391,12 +392,11 @@ private void addToConversionQueue(boolean internalPublish, FdrInsertEntity fdrEn .retry(0L) .revision(fdrEntity.getRevision()) .build()); - log.info("End add FdrInsertEntity in queue fdr message"); + log.debugf("End add FdrInsertEntity in queue fdr message"); } } private void rePublish(String fdr, String pspId, FdrPublishEntity fdrPublishEntity) { - log.info("Starting write to re"); String sessionId = (String) MDC.get(TRX_ID); MDC.put(EVENT_CATEGORY, EventTypeEnum.INTERNAL.name()); reService.sendEvent( @@ -413,7 +413,6 @@ private void rePublish(String fdr, String pspId, FdrPublishEntity fdrPublishEnti .revision(fdrPublishEntity.getRevision()) .fdrAction(FdrActionEnum.PUBLISH) .build()); - log.info("End write to re"); } @WithSpan(kind = SERVER) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index da9a9a02..83107936 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -69,11 +69,6 @@ quarkus.mongodb.connection-string=${MONGODB_CONNECTION_STRING:${mockserver.mongo %dev.quarkus.mongodb.connection-string=mongodb://root:example@localhost:27017/ quarkus.mongodb.database=fdr -################### -## Vert.x -################### -# quarkus.vertx.max-event-loop-execute-time=2s - ################### ## ADAPTER API CONFIG CACHE ###################