From 38df22cd8133d75524f224977949507cb8b69f55 Mon Sep 17 00:00:00 2001 From: Elena Lopez-Castro Date: Wed, 20 Sep 2023 04:19:51 -0400 Subject: [PATCH] decompose metrics services --- legend-depot-artifacts-services/pom.xml | 12 ++- .../purge/ArtifactsPurgeServiceImpl.java | 12 +-- .../generations/TestGenerationsProvider.java | 4 +- .../purge/TestArtifactsPurgeService.java | 13 ++-- .../refresh/TestArtifactsRefreshService.java | 4 +- ...actsRefreshServiceExceptionEscenarios.java | 4 +- .../TestArtifactsRefreshServiceWithMocks.java | 4 +- .../TestProjectVersionRefreshHandler.java | 4 +- .../artifacts/ArtifactsFilesMongo.java | 2 +- .../guice/ArtifactsStoreMongoModule.java | 4 +- .../artifacts/TestArtifactMongo.java | 3 +- .../artifacts/TestMongoAdminStore.java | 3 +- legend-depot-core-data-services/pom.xml | 2 +- .../projects/ManageProjectsServiceImpl.java | 2 +- .../projects/ProjectsServiceImpl.java | 2 +- .../resources/TestProjectsResource.java | 2 +- .../TestProjectsVersionsResource.java | 2 +- .../TestManageDependenciesService.java | 2 +- .../projects/TestProjectsService.java | 2 +- .../ManageSchedulesStoreMongoModule.java | 6 +- .../guice/SchedulesStoreMongoModule.java | 6 +- .../schedules/ScheduleInstancesMongo.java | 2 +- .../{admin => }/schedules/SchedulesMongo.java | 2 +- legend-depot-entities-services/pom.xml | 10 +++ .../resources/TestEntitiesResource.java | 17 +++-- .../entities/TestEntitiesService.java | 2 +- .../TestFileGenerationsService.java | 2 +- legend-depot-metrics-query-api/pom.xml | 53 +++++++++++++ .../metrics/query}/QueryMetricsRegistry.java | 5 +- .../metrics/query/QueryMetricsService.java | 40 ++++++++++ .../query}/VoidQueryMetricsRegistry.java | 5 +- .../api/metrics/query}/QueryMetrics.java | 4 +- .../metrics/query}/VersionQueryMetric.java | 2 +- legend-depot-metrics-query-services/pom.xml | 74 +++++++++++++++++++ .../ManageQueryMetricsSchedulesModule.java | 25 ++----- .../services/guice/QueryMetricsModule.java | 20 ++--- .../guice/QueryMetricsSchedulesModule.java | 48 ++++++++++++ .../query}/InMemoryQueryMetricsRegistry.java | 6 +- .../query/QueryMetricsServiceImpl.java | 28 ++++--- .../metrics/query}/TestMetricsServices.java | 17 ++--- .../pom.xml | 8 +- .../ManageQueryMetricsMongoStoreModule.java | 11 +-- .../guice/QueryMetricsMongoStoreModule.java | 34 +++++++++ .../metrics/query}/QueryMetricsMongo.java | 8 +- legend-depot-pure-model-context/pom.xml | 10 +++ .../TestPureModelContextDataResource.java | 4 +- .../context/TestPureModelContextService.java | 16 ++-- legend-depot-server/pom.xml | 7 +- .../depot/server/LegendDepotServer.java | 12 +-- .../ManageMetricsResourceResource.java | 65 ---------------- legend-depot-store-server/pom.xml | 8 ++ .../store/server/LegendDepotStoreServer.java | 13 ++-- legend-depot-test-reports/pom.xml | 12 ++- pom.xml | 17 ++++- 54 files changed, 460 insertions(+), 222 deletions(-) rename legend-depot-artifacts-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/{admin => }/artifacts/ArtifactsFilesMongo.java (97%) rename legend-depot-artifacts-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/{admin => }/guice/ArtifactsStoreMongoModule.java (91%) rename legend-depot-artifacts-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/{admin => }/artifacts/TestArtifactMongo.java (95%) rename legend-depot-artifacts-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/{admin => }/artifacts/TestMongoAdminStore.java (93%) rename legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/{admin => }/guice/ManageSchedulesStoreMongoModule.java (85%) rename legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/{admin => }/guice/SchedulesStoreMongoModule.java (84%) rename legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/{admin => }/schedules/ScheduleInstancesMongo.java (97%) rename legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/{admin => }/schedules/SchedulesMongo.java (97%) create mode 100644 legend-depot-metrics-query-api/pom.xml rename {legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/api => legend-depot-metrics-query-api/src/main/java/org/finos/legend/depot/services/api/metrics/query}/QueryMetricsRegistry.java (87%) create mode 100644 legend-depot-metrics-query-api/src/main/java/org/finos/legend/depot/services/api/metrics/query/QueryMetricsService.java rename {legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/services => legend-depot-metrics-query-api/src/main/java/org/finos/legend/depot/services/api/metrics/query}/VoidQueryMetricsRegistry.java (83%) rename {legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/store/api => legend-depot-metrics-query-api/src/main/java/org/finos/legend/depot/store/api/metrics/query}/QueryMetrics.java (89%) rename {legend-depot-store-metrics/src/main/java/org/finos/legend/depot/domain/metrics => legend-depot-metrics-query-api/src/main/java/org/finos/legend/depot/store/model/metrics/query}/VersionQueryMetric.java (97%) create mode 100644 legend-depot-metrics-query-services/pom.xml rename legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/MetricsSchedulesModule.java => legend-depot-metrics-query-services/src/main/java/org/finos/legend/depot/services/guice/ManageQueryMetricsSchedulesModule.java (61%) rename legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/MetricsModule.java => legend-depot-metrics-query-services/src/main/java/org/finos/legend/depot/services/guice/QueryMetricsModule.java (64%) create mode 100644 legend-depot-metrics-query-services/src/main/java/org/finos/legend/depot/services/guice/QueryMetricsSchedulesModule.java rename {legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/services => legend-depot-metrics-query-services/src/main/java/org/finos/legend/depot/services/metrics/query}/InMemoryQueryMetricsRegistry.java (87%) rename legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/services/QueryMetricsHandler.java => legend-depot-metrics-query-services/src/main/java/org/finos/legend/depot/services/metrics/query/QueryMetricsServiceImpl.java (83%) rename {legend-depot-store-metrics/src/test/java/org/finos/legend/depot/store/metrics => legend-depot-metrics-query-services/src/test/java/org/finos/legend/depot/services/metrics/query}/TestMetricsServices.java (92%) rename {legend-depot-store-metrics => legend-depot-metrics-query-store-mongo}/pom.xml (87%) rename legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/AdminMetricsModule.java => legend-depot-metrics-query-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/guice/ManageQueryMetricsMongoStoreModule.java (76%) create mode 100644 legend-depot-metrics-query-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/guice/QueryMetricsMongoStoreModule.java rename {legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/store/mongo => legend-depot-metrics-query-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/metrics/query}/QueryMetricsMongo.java (94%) delete mode 100644 legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/resources/metrics/ManageMetricsResourceResource.java diff --git a/legend-depot-artifacts-services/pom.xml b/legend-depot-artifacts-services/pom.xml index 95ffe79b8..fdd7f6069 100644 --- a/legend-depot-artifacts-services/pom.xml +++ b/legend-depot-artifacts-services/pom.xml @@ -39,7 +39,7 @@ org.finos.legend.depot - legend-depot-store-metrics + legend-depot-metrics-query-api org.finos.legend.depot @@ -163,6 +163,16 @@ test-jar test + + org.finos.legend.depot + legend-depot-metrics-query-services + test + + + org.finos.legend.depot + legend-depot-metrics-query-store-mongo + test + de.bwaldvogel mongo-java-server diff --git a/legend-depot-artifacts-services/src/main/java/org/finos/legend/depot/services/artifacts/purge/ArtifactsPurgeServiceImpl.java b/legend-depot-artifacts-services/src/main/java/org/finos/legend/depot/services/artifacts/purge/ArtifactsPurgeServiceImpl.java index 53a495f3b..132083ff1 100644 --- a/legend-depot-artifacts-services/src/main/java/org/finos/legend/depot/services/artifacts/purge/ArtifactsPurgeServiceImpl.java +++ b/legend-depot-artifacts-services/src/main/java/org/finos/legend/depot/services/artifacts/purge/ArtifactsPurgeServiceImpl.java @@ -17,16 +17,16 @@ import org.finos.legend.depot.domain.VersionedData; import org.finos.legend.depot.domain.api.MetadataEventResponse; +import org.finos.legend.depot.domain.artifacts.repository.ArtifactType; import org.finos.legend.depot.domain.project.ProjectVersion; +import org.finos.legend.depot.services.api.artifacts.handlers.ProjectArtifactHandlerFactory; +import org.finos.legend.depot.services.api.artifacts.handlers.ProjectArtifactsHandler; import org.finos.legend.depot.services.api.artifacts.purge.ArtifactsPurgeService; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsService; import org.finos.legend.depot.services.api.projects.ManageProjectsService; -import org.finos.legend.depot.domain.artifacts.repository.ArtifactType; import org.finos.legend.depot.services.api.projects.ProjectsVersionsReconciliationService; -import org.finos.legend.depot.store.metrics.services.QueryMetricsHandler; import org.finos.legend.depot.store.model.projects.StoreProjectData; import org.finos.legend.depot.store.model.projects.StoreProjectVersionData; -import org.finos.legend.depot.services.api.artifacts.handlers.ProjectArtifactHandlerFactory; -import org.finos.legend.depot.services.api.artifacts.handlers.ProjectArtifactsHandler; import org.finos.legend.depot.tracing.services.TracerFactory; import org.finos.legend.depot.tracing.services.prometheus.PrometheusMetricsFactory; import org.slf4j.Logger; @@ -61,10 +61,10 @@ public class ArtifactsPurgeServiceImpl implements ArtifactsPurgeService private final ManageProjectsService projects; private final ProjectsVersionsReconciliationService versionsMismatchService; - private final QueryMetricsHandler metrics; + private final QueryMetricsService metrics; @Inject - public ArtifactsPurgeServiceImpl(ManageProjectsService projects, ProjectsVersionsReconciliationService versionsMismatchService, QueryMetricsHandler metrics) + public ArtifactsPurgeServiceImpl(ManageProjectsService projects, ProjectsVersionsReconciliationService versionsMismatchService, QueryMetricsService metrics) { this.projects = projects; this.metrics = metrics; diff --git a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/handlers/generations/TestGenerationsProvider.java b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/handlers/generations/TestGenerationsProvider.java index 43845665d..6724cde48 100644 --- a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/handlers/generations/TestGenerationsProvider.java +++ b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/handlers/generations/TestGenerationsProvider.java @@ -17,8 +17,6 @@ import org.finos.legend.depot.services.api.artifacts.repository.ArtifactRepository; import org.finos.legend.depot.domain.artifacts.repository.ArtifactType; -import org.finos.legend.depot.services.artifacts.handlers.generations.FileGenerationHandlerImpl; -import org.finos.legend.depot.services.artifacts.handlers.generations.FileGenerationsProvider; import org.finos.legend.depot.services.artifacts.repository.maven.TestMavenArtifactsRepository; import org.finos.legend.depot.domain.api.MetadataEventResponse; import org.finos.legend.depot.domain.generation.DepotGeneration; @@ -33,7 +31,7 @@ import org.finos.legend.depot.store.api.projects.UpdateProjects; import org.finos.legend.depot.store.api.projects.UpdateProjectsVersions; import org.finos.legend.depot.services.api.artifacts.handlers.generations.FileGenerationsArtifactsProvider; -import org.finos.legend.depot.store.metrics.api.QueryMetricsRegistry; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsRegistry; import org.finos.legend.depot.store.mongo.TestStoreMongo; import org.finos.legend.depot.store.mongo.generations.FileGenerationsMongo; import org.finos.legend.depot.store.notifications.queue.api.Queue; diff --git a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/purge/TestArtifactsPurgeService.java b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/purge/TestArtifactsPurgeService.java index 1d331fd74..04963a950 100644 --- a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/purge/TestArtifactsPurgeService.java +++ b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/purge/TestArtifactsPurgeService.java @@ -16,7 +16,8 @@ package org.finos.legend.depot.services.artifacts.purge; import org.finos.legend.depot.services.TestBaseServices; -import org.finos.legend.depot.domain.metrics.VersionQueryMetric; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsService; +import org.finos.legend.depot.store.model.metrics.query.VersionQueryMetric; import org.finos.legend.depot.services.api.artifacts.repository.ArtifactRepository; import org.finos.legend.depot.domain.artifacts.repository.ArtifactType; import org.finos.legend.depot.domain.version.VersionMismatch; @@ -41,10 +42,10 @@ import org.finos.legend.depot.services.artifacts.handlers.entities.EntityProvider; import org.finos.legend.depot.services.artifacts.handlers.generations.FileGenerationHandlerImpl; import org.finos.legend.depot.services.artifacts.handlers.generations.FileGenerationsProvider; -import org.finos.legend.depot.store.metrics.api.QueryMetricsRegistry; -import org.finos.legend.depot.store.metrics.services.InMemoryQueryMetricsRegistry; -import org.finos.legend.depot.store.metrics.services.QueryMetricsHandler; -import org.finos.legend.depot.store.metrics.store.mongo.QueryMetricsMongo; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsRegistry; +import org.finos.legend.depot.services.metrics.query.InMemoryQueryMetricsRegistry; +import org.finos.legend.depot.services.metrics.query.QueryMetricsServiceImpl; +import org.finos.legend.depot.store.mongo.metrics.query.QueryMetricsMongo; import org.finos.legend.depot.store.mongo.entities.EntitiesMongo; import org.finos.legend.depot.store.mongo.entities.test.EntitiesMongoTestUtils; import org.finos.legend.depot.store.mongo.generations.FileGenerationsMongo; @@ -78,7 +79,7 @@ public class TestArtifactsPurgeService extends TestBaseServices protected UpdateProjectsVersions projectsVersionsStore = new ProjectsVersionsMongo(mongoProvider); private final QueryMetricsMongo metrics = new QueryMetricsMongo(mongoProvider); private final QueryMetricsRegistry metricsRegistry = new InMemoryQueryMetricsRegistry(); - private final QueryMetricsHandler metricHandler = new QueryMetricsHandler(metrics, metricsRegistry); + private final QueryMetricsService metricHandler = new QueryMetricsServiceImpl(metrics); private final Queue queue = mock(Queue.class); protected ManageProjectsService projectsService = new ManageProjectsServiceImpl(projectsVersionsStore, projectsStore, metricsRegistry, queue, new ProjectsConfiguration("master")); protected UpdateEntities entitiesStore = new EntitiesMongo(mongoProvider); diff --git a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestArtifactsRefreshService.java b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestArtifactsRefreshService.java index e5277d6fd..7cea58344 100644 --- a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestArtifactsRefreshService.java +++ b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestArtifactsRefreshService.java @@ -43,11 +43,11 @@ import org.finos.legend.depot.services.artifacts.handlers.entities.EntityProvider; import org.finos.legend.depot.services.artifacts.handlers.generations.FileGenerationHandlerImpl; import org.finos.legend.depot.services.artifacts.handlers.generations.FileGenerationsProvider; -import org.finos.legend.depot.store.metrics.api.QueryMetricsRegistry; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsRegistry; import org.finos.legend.depot.store.model.projects.StoreProjectData; import org.finos.legend.depot.store.model.projects.StoreProjectVersionData; import org.finos.legend.depot.store.mongo.TestStoreMongo; -import org.finos.legend.depot.store.mongo.admin.artifacts.ArtifactsFilesMongo; +import org.finos.legend.depot.store.mongo.artifacts.ArtifactsFilesMongo; import org.finos.legend.depot.store.mongo.entities.EntitiesMongo; import org.finos.legend.depot.store.mongo.generations.FileGenerationsMongo; import org.finos.legend.depot.store.mongo.projects.ProjectsMongo; diff --git a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestArtifactsRefreshServiceExceptionEscenarios.java b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestArtifactsRefreshServiceExceptionEscenarios.java index 9fdc4403f..fe1df45e1 100644 --- a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestArtifactsRefreshServiceExceptionEscenarios.java +++ b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestArtifactsRefreshServiceExceptionEscenarios.java @@ -36,10 +36,10 @@ import org.finos.legend.depot.services.artifacts.handlers.entities.EntityProvider; import org.finos.legend.depot.services.artifacts.handlers.generations.FileGenerationHandlerImpl; import org.finos.legend.depot.services.artifacts.handlers.generations.FileGenerationsProvider; -import org.finos.legend.depot.store.metrics.api.QueryMetricsRegistry; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsRegistry; import org.finos.legend.depot.store.model.projects.StoreProjectData; import org.finos.legend.depot.store.mongo.TestStoreMongo; -import org.finos.legend.depot.store.mongo.admin.artifacts.ArtifactsFilesMongo; +import org.finos.legend.depot.store.mongo.artifacts.ArtifactsFilesMongo; import org.finos.legend.depot.store.notifications.queue.api.Queue; import org.finos.legend.depot.store.notifications.queue.store.mongo.NotificationsQueueMongo; import org.finos.legend.depot.services.api.artifacts.handlers.ProjectArtifactHandlerFactory; diff --git a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestArtifactsRefreshServiceWithMocks.java b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestArtifactsRefreshServiceWithMocks.java index b93749aa9..6f3c4c2ad 100644 --- a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestArtifactsRefreshServiceWithMocks.java +++ b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestArtifactsRefreshServiceWithMocks.java @@ -33,11 +33,11 @@ import org.finos.legend.depot.services.artifacts.handlers.entities.EntityProvider; import org.finos.legend.depot.services.artifacts.handlers.generations.FileGenerationHandlerImpl; import org.finos.legend.depot.services.artifacts.handlers.generations.FileGenerationsProvider; -import org.finos.legend.depot.store.metrics.api.QueryMetricsRegistry; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsRegistry; import org.finos.legend.depot.store.model.projects.StoreProjectData; import org.finos.legend.depot.store.model.projects.StoreProjectVersionData; import org.finos.legend.depot.store.mongo.TestStoreMongo; -import org.finos.legend.depot.store.mongo.admin.artifacts.ArtifactsFilesMongo; +import org.finos.legend.depot.store.mongo.artifacts.ArtifactsFilesMongo; import org.finos.legend.depot.store.notifications.queue.api.Queue; import org.finos.legend.depot.store.notifications.queue.store.mongo.NotificationsQueueMongo; import org.finos.legend.depot.services.api.artifacts.handlers.ProjectArtifactHandlerFactory; diff --git a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestProjectVersionRefreshHandler.java b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestProjectVersionRefreshHandler.java index 801b35c78..a062d3fd1 100644 --- a/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestProjectVersionRefreshHandler.java +++ b/legend-depot-artifacts-services/src/test/java/org/finos/legend/depot/services/artifacts/refresh/TestProjectVersionRefreshHandler.java @@ -36,11 +36,11 @@ import org.finos.legend.depot.domain.artifacts.repository.ArtifactType; import org.finos.legend.depot.services.artifacts.handlers.entities.EntitiesHandlerImpl; import org.finos.legend.depot.services.artifacts.handlers.entities.EntityProvider; -import org.finos.legend.depot.store.metrics.api.QueryMetricsRegistry; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsRegistry; import org.finos.legend.depot.store.model.projects.StoreProjectData; import org.finos.legend.depot.store.model.projects.StoreProjectVersionData; import org.finos.legend.depot.store.mongo.TestStoreMongo; -import org.finos.legend.depot.store.mongo.admin.artifacts.ArtifactsFilesMongo; +import org.finos.legend.depot.store.mongo.artifacts.ArtifactsFilesMongo; import org.finos.legend.depot.store.mongo.entities.EntitiesMongo; import org.finos.legend.depot.store.mongo.projects.ProjectsVersionsMongo; import org.finos.legend.depot.store.notifications.queue.api.Queue; diff --git a/legend-depot-artifacts-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/admin/artifacts/ArtifactsFilesMongo.java b/legend-depot-artifacts-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/artifacts/ArtifactsFilesMongo.java similarity index 97% rename from legend-depot-artifacts-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/admin/artifacts/ArtifactsFilesMongo.java rename to legend-depot-artifacts-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/artifacts/ArtifactsFilesMongo.java index dc0c93fec..b3827965c 100644 --- a/legend-depot-artifacts-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/admin/artifacts/ArtifactsFilesMongo.java +++ b/legend-depot-artifacts-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/artifacts/ArtifactsFilesMongo.java @@ -13,7 +13,7 @@ // limitations under the License. // -package org.finos.legend.depot.store.mongo.admin.artifacts; +package org.finos.legend.depot.store.mongo.artifacts; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/legend-depot-artifacts-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/admin/guice/ArtifactsStoreMongoModule.java b/legend-depot-artifacts-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/guice/ArtifactsStoreMongoModule.java similarity index 91% rename from legend-depot-artifacts-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/admin/guice/ArtifactsStoreMongoModule.java rename to legend-depot-artifacts-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/guice/ArtifactsStoreMongoModule.java index 3f596925a..4edd03ed2 100644 --- a/legend-depot-artifacts-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/admin/guice/ArtifactsStoreMongoModule.java +++ b/legend-depot-artifacts-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/guice/ArtifactsStoreMongoModule.java @@ -13,14 +13,14 @@ // limitations under the License. // -package org.finos.legend.depot.store.mongo.admin.guice; +package org.finos.legend.depot.store.mongo.guice; import com.google.inject.PrivateModule; import com.google.inject.Provides; import com.google.inject.Singleton; import org.finos.legend.depot.store.api.admin.artifacts.ArtifactsFilesStore; import org.finos.legend.depot.store.mongo.admin.MongoAdminStore; -import org.finos.legend.depot.store.mongo.admin.artifacts.ArtifactsFilesMongo; +import org.finos.legend.depot.store.mongo.artifacts.ArtifactsFilesMongo; import javax.inject.Named; diff --git a/legend-depot-artifacts-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/admin/artifacts/TestArtifactMongo.java b/legend-depot-artifacts-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/artifacts/TestArtifactMongo.java similarity index 95% rename from legend-depot-artifacts-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/admin/artifacts/TestArtifactMongo.java rename to legend-depot-artifacts-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/artifacts/TestArtifactMongo.java index 8fedc5f32..be4a73ba1 100644 --- a/legend-depot-artifacts-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/admin/artifacts/TestArtifactMongo.java +++ b/legend-depot-artifacts-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/artifacts/TestArtifactMongo.java @@ -13,11 +13,12 @@ // limitations under the License. // -package org.finos.legend.depot.store.mongo.admin.artifacts; +package org.finos.legend.depot.store.mongo.artifacts; import org.finos.legend.depot.store.api.admin.artifacts.ArtifactsFilesStore; import org.finos.legend.depot.store.model.admin.artifacts.ArtifactFile; import org.finos.legend.depot.store.mongo.TestStoreMongo; +import org.finos.legend.depot.store.mongo.artifacts.ArtifactsFilesMongo; import org.junit.Assert; import org.junit.Test; diff --git a/legend-depot-artifacts-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/admin/artifacts/TestMongoAdminStore.java b/legend-depot-artifacts-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/artifacts/TestMongoAdminStore.java similarity index 93% rename from legend-depot-artifacts-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/admin/artifacts/TestMongoAdminStore.java rename to legend-depot-artifacts-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/artifacts/TestMongoAdminStore.java index e9c503b3b..31261e41b 100644 --- a/legend-depot-artifacts-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/admin/artifacts/TestMongoAdminStore.java +++ b/legend-depot-artifacts-store-mongo/src/test/java/org/finos/legend/depot/store/mongo/artifacts/TestMongoAdminStore.java @@ -13,11 +13,12 @@ // limitations under the License. // -package org.finos.legend.depot.store.mongo.admin.artifacts; +package org.finos.legend.depot.store.mongo.artifacts; import org.bson.Document; import org.finos.legend.depot.store.mongo.TestStoreMongo; import org.finos.legend.depot.store.mongo.admin.MongoAdminStore; +import org.finos.legend.depot.store.mongo.artifacts.ArtifactsFilesMongo; import org.finos.legend.depot.store.mongo.core.BaseMongo; import org.junit.Assert; import org.junit.Test; diff --git a/legend-depot-core-data-services/pom.xml b/legend-depot-core-data-services/pom.xml index 07f1acba4..96b568eca 100644 --- a/legend-depot-core-data-services/pom.xml +++ b/legend-depot-core-data-services/pom.xml @@ -37,7 +37,7 @@ org.finos.legend.depot - legend-depot-store-metrics + legend-depot-metrics-query-api org.finos.legend.depot diff --git a/legend-depot-core-data-services/src/main/java/org/finos/legend/depot/services/projects/ManageProjectsServiceImpl.java b/legend-depot-core-data-services/src/main/java/org/finos/legend/depot/services/projects/ManageProjectsServiceImpl.java index b38e1de20..6c5584a5d 100644 --- a/legend-depot-core-data-services/src/main/java/org/finos/legend/depot/services/projects/ManageProjectsServiceImpl.java +++ b/legend-depot-core-data-services/src/main/java/org/finos/legend/depot/services/projects/ManageProjectsServiceImpl.java @@ -23,7 +23,7 @@ import org.finos.legend.depot.services.projects.configuration.ProjectsConfiguration; import org.finos.legend.depot.store.api.projects.UpdateProjects; import org.finos.legend.depot.store.api.projects.UpdateProjectsVersions; -import org.finos.legend.depot.store.metrics.api.QueryMetricsRegistry; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsRegistry; import org.finos.legend.depot.store.notifications.queue.api.Queue; import javax.inject.Inject; diff --git a/legend-depot-core-data-services/src/main/java/org/finos/legend/depot/services/projects/ProjectsServiceImpl.java b/legend-depot-core-data-services/src/main/java/org/finos/legend/depot/services/projects/ProjectsServiceImpl.java index 438d20f6b..50208c0a9 100644 --- a/legend-depot-core-data-services/src/main/java/org/finos/legend/depot/services/projects/ProjectsServiceImpl.java +++ b/legend-depot-core-data-services/src/main/java/org/finos/legend/depot/services/projects/ProjectsServiceImpl.java @@ -36,7 +36,7 @@ import org.finos.legend.depot.store.api.projects.ProjectsVersions; import org.finos.legend.depot.store.api.projects.UpdateProjectsVersions; import org.finos.legend.depot.store.api.projects.UpdateProjects; -import org.finos.legend.depot.store.metrics.api.QueryMetricsRegistry; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsRegistry; import org.finos.legend.depot.store.notifications.queue.api.Queue; import org.finos.legend.sdlc.domain.model.version.VersionId; diff --git a/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/server/resources/TestProjectsResource.java b/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/server/resources/TestProjectsResource.java index b2aeabea9..5287f4974 100644 --- a/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/server/resources/TestProjectsResource.java +++ b/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/server/resources/TestProjectsResource.java @@ -18,7 +18,7 @@ import org.finos.legend.depot.server.resources.projects.ProjectsResource; import org.finos.legend.depot.services.TestBaseServices; import org.finos.legend.depot.services.projects.ProjectsServiceImpl; -import org.finos.legend.depot.store.metrics.api.QueryMetricsRegistry; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsRegistry; import org.finos.legend.depot.services.projects.configuration.ProjectsConfiguration; import org.finos.legend.depot.store.notifications.queue.api.Queue; import org.junit.Assert; diff --git a/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/server/resources/TestProjectsVersionsResource.java b/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/server/resources/TestProjectsVersionsResource.java index 36d35c830..0b5178cea 100644 --- a/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/server/resources/TestProjectsVersionsResource.java +++ b/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/server/resources/TestProjectsVersionsResource.java @@ -20,7 +20,7 @@ import org.finos.legend.depot.services.TestBaseServices; import org.finos.legend.depot.services.projects.ProjectsServiceImpl; import org.finos.legend.depot.services.projects.configuration.ProjectsConfiguration; -import org.finos.legend.depot.store.metrics.api.QueryMetricsRegistry; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsRegistry; import org.finos.legend.depot.store.notifications.queue.api.Queue; import org.junit.Assert; import org.junit.Test; diff --git a/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/services/dependencies/TestManageDependenciesService.java b/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/services/dependencies/TestManageDependenciesService.java index 1543c4fe9..91cf446f7 100644 --- a/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/services/dependencies/TestManageDependenciesService.java +++ b/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/services/dependencies/TestManageDependenciesService.java @@ -22,7 +22,7 @@ import org.finos.legend.depot.store.api.projects.UpdateProjects; import org.finos.legend.depot.store.api.projects.UpdateProjectsVersions; import org.finos.legend.depot.services.api.artifacts.repository.ArtifactRepository; -import org.finos.legend.depot.store.metrics.api.QueryMetricsRegistry; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsRegistry; import org.finos.legend.depot.store.model.projects.StoreProjectData; import org.finos.legend.depot.store.model.projects.StoreProjectVersionData; import org.finos.legend.depot.store.mongo.CoreDataMongoStoreTests; diff --git a/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/services/projects/TestProjectsService.java b/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/services/projects/TestProjectsService.java index 85070909c..5892cf42c 100644 --- a/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/services/projects/TestProjectsService.java +++ b/legend-depot-core-data-services/src/test/java/org/finos/legend/depot/services/projects/TestProjectsService.java @@ -28,7 +28,7 @@ import org.finos.legend.depot.domain.project.dependencies.VersionDependencyReport; import org.finos.legend.depot.services.TestBaseServices; import org.finos.legend.depot.services.api.projects.ManageProjectsService; -import org.finos.legend.depot.store.metrics.api.QueryMetricsRegistry; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsRegistry; import org.finos.legend.depot.services.projects.configuration.ProjectsConfiguration; import org.finos.legend.depot.store.notifications.queue.api.Queue; import org.finos.legend.depot.store.notifications.queue.store.mongo.NotificationsQueueMongo; diff --git a/legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/admin/guice/ManageSchedulesStoreMongoModule.java b/legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/guice/ManageSchedulesStoreMongoModule.java similarity index 85% rename from legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/admin/guice/ManageSchedulesStoreMongoModule.java rename to legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/guice/ManageSchedulesStoreMongoModule.java index 2a6306669..a0be49041 100644 --- a/legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/admin/guice/ManageSchedulesStoreMongoModule.java +++ b/legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/guice/ManageSchedulesStoreMongoModule.java @@ -13,13 +13,13 @@ // limitations under the License. // -package org.finos.legend.depot.store.mongo.admin.guice; +package org.finos.legend.depot.store.mongo.guice; import com.google.inject.Provides; import com.google.inject.Singleton; import org.finos.legend.depot.store.mongo.admin.MongoAdminStore; -import org.finos.legend.depot.store.mongo.admin.schedules.ScheduleInstancesMongo; -import org.finos.legend.depot.store.mongo.admin.schedules.SchedulesMongo; +import org.finos.legend.depot.store.mongo.schedules.ScheduleInstancesMongo; +import org.finos.legend.depot.store.mongo.schedules.SchedulesMongo; import javax.inject.Named; diff --git a/legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/admin/guice/SchedulesStoreMongoModule.java b/legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/guice/SchedulesStoreMongoModule.java similarity index 84% rename from legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/admin/guice/SchedulesStoreMongoModule.java rename to legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/guice/SchedulesStoreMongoModule.java index 2dfcb4c19..566195bef 100644 --- a/legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/admin/guice/SchedulesStoreMongoModule.java +++ b/legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/guice/SchedulesStoreMongoModule.java @@ -13,13 +13,13 @@ // limitations under the License. // -package org.finos.legend.depot.store.mongo.admin.guice; +package org.finos.legend.depot.store.mongo.guice; import com.google.inject.PrivateModule; import org.finos.legend.depot.store.api.admin.schedules.ScheduleInstancesStore; import org.finos.legend.depot.store.api.admin.schedules.SchedulesStore; -import org.finos.legend.depot.store.mongo.admin.schedules.ScheduleInstancesMongo; -import org.finos.legend.depot.store.mongo.admin.schedules.SchedulesMongo; +import org.finos.legend.depot.store.mongo.schedules.ScheduleInstancesMongo; +import org.finos.legend.depot.store.mongo.schedules.SchedulesMongo; public class SchedulesStoreMongoModule extends PrivateModule { diff --git a/legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/admin/schedules/ScheduleInstancesMongo.java b/legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/schedules/ScheduleInstancesMongo.java similarity index 97% rename from legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/admin/schedules/ScheduleInstancesMongo.java rename to legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/schedules/ScheduleInstancesMongo.java index 099d47e79..75417284b 100644 --- a/legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/admin/schedules/ScheduleInstancesMongo.java +++ b/legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/schedules/ScheduleInstancesMongo.java @@ -13,7 +13,7 @@ // limitations under the License. // -package org.finos.legend.depot.store.mongo.admin.schedules; +package org.finos.legend.depot.store.mongo.schedules; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/admin/schedules/SchedulesMongo.java b/legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/schedules/SchedulesMongo.java similarity index 97% rename from legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/admin/schedules/SchedulesMongo.java rename to legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/schedules/SchedulesMongo.java index 01e79e2a3..c2642ee1b 100644 --- a/legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/admin/schedules/SchedulesMongo.java +++ b/legend-depot-core-schedules-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/schedules/SchedulesMongo.java @@ -13,7 +13,7 @@ // limitations under the License. // -package org.finos.legend.depot.store.mongo.admin.schedules; +package org.finos.legend.depot.store.mongo.schedules; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/legend-depot-entities-services/pom.xml b/legend-depot-entities-services/pom.xml index 487af397d..c6d9b9490 100644 --- a/legend-depot-entities-services/pom.xml +++ b/legend-depot-entities-services/pom.xml @@ -119,6 +119,16 @@ test-jar test + + org.finos.legend.depot + legend-depot-metrics-query-store-mongo + test + + + org.finos.legend.depot + legend-depot-metrics-query-services + test + diff --git a/legend-depot-entities-services/src/test/java/org/finos/legend/depot/server/resources/TestEntitiesResource.java b/legend-depot-entities-services/src/test/java/org/finos/legend/depot/server/resources/TestEntitiesResource.java index 999337b51..9e10286f0 100644 --- a/legend-depot-entities-services/src/test/java/org/finos/legend/depot/server/resources/TestEntitiesResource.java +++ b/legend-depot-entities-services/src/test/java/org/finos/legend/depot/server/resources/TestEntitiesResource.java @@ -17,6 +17,9 @@ import com.squarespace.jersey2.guice.JerseyGuiceUtils; import org.finos.legend.depot.domain.project.ProjectVersion; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsService; +import org.finos.legend.depot.services.metrics.query.InMemoryQueryMetricsRegistry; +import org.finos.legend.depot.services.metrics.query.QueryMetricsServiceImpl; import org.finos.legend.depot.store.model.projects.StoreProjectData; import org.finos.legend.depot.store.model.projects.StoreProjectVersionData; import org.finos.legend.depot.server.resources.entities.EntitiesResource; @@ -28,12 +31,10 @@ import org.finos.legend.depot.store.api.entities.UpdateEntities; import org.finos.legend.depot.store.api.projects.UpdateProjectsVersions; import org.finos.legend.depot.store.api.projects.UpdateProjects; -import org.finos.legend.depot.store.metrics.api.QueryMetricsRegistry; -import org.finos.legend.depot.store.metrics.services.QueryMetricsHandler; -import org.finos.legend.depot.store.metrics.services.InMemoryQueryMetricsRegistry; -import org.finos.legend.depot.store.metrics.store.mongo.QueryMetricsMongo; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsRegistry; import org.finos.legend.depot.store.mongo.entities.EntitiesMongo; import org.finos.legend.depot.store.mongo.entities.test.EntitiesMongoTestUtils; +import org.finos.legend.depot.store.mongo.metrics.query.QueryMetricsMongo; import org.finos.legend.depot.store.notifications.queue.api.Queue; import org.finos.legend.sdlc.domain.model.entity.Entity; import org.junit.After; @@ -63,7 +64,7 @@ public class TestEntitiesResource extends TestBaseServices private final EntitiesService entitiesService = new EntitiesServiceImpl(entitiesStore,new ProjectsServiceImpl(projectsVersions, projects, metricsRegistry, queue, new ProjectsConfiguration("master"))); private EntitiesResource entitiesResource = new EntitiesResource(entitiesService); private QueryMetricsMongo metricsStore = new QueryMetricsMongo(mongoProvider); - private QueryMetricsHandler metricsHandler = new QueryMetricsHandler(metricsStore, metricsRegistry); + private QueryMetricsService metricsHandler = new QueryMetricsServiceImpl(metricsStore); static { @@ -128,7 +129,7 @@ public void canGetMetrics() throws InterruptedException when(projects.find("examples.metadata","test")).thenReturn(Optional.of(new StoreProjectData("mock","examples.metadata","test"))); Response responseOne = entitiesResource.getEntities("examples.metadata", "test", "2.3.0", "examples::metadata::test", null, true, null); Assert.assertEquals(Response.Status.OK.getStatusCode(), responseOne.getStatus()); - metricsHandler.persistMetrics(); + metricsHandler.persist(metricsRegistry); Assert.assertEquals(1, metricsStore.get("examples.metadata", "test", "2.3.0").size()); Assert.assertNotNull(metricsStore.get("examples.metadata", "test", "2.3.0").get(0).getLastQueryTime()); @@ -136,7 +137,7 @@ public void canGetMetrics() throws InterruptedException Response responseTwo = entitiesResource.getEntities("example.services.test", "test", "1.0.1", null); Assert.assertEquals(Response.Status.OK.getStatusCode(), responseTwo.getStatus()); - metricsHandler.persistMetrics(); + metricsHandler.persist(metricsRegistry); Assert.assertNotNull(metricsStore.get("examples.metadata", "test", "2.3.0").get(0).getLastQueryTime()); Assert.assertEquals(2, metricsStore.getAllStoredEntities().size()); @@ -154,7 +155,7 @@ public void canGetMetricsForTransitiveDependencies() throws InterruptedException when(projectsVersions.find("examples.metadata","test-master", "2.3.0")).thenReturn(Optional.of(versionData)); entitiesService.getDependenciesEntities("examples.metadata", "test-master", "2.3.0", true, false); - metricsHandler.persistMetrics(); + metricsHandler.persist(metricsRegistry); Assert.assertEquals(2, metricsStore.getAll().size()); Assert.assertNotNull(metricsStore.get("examples.metadata", "test", "2.3.0").get(0).getLastQueryTime()); diff --git a/legend-depot-entities-services/src/test/java/org/finos/legend/depot/services/entities/TestEntitiesService.java b/legend-depot-entities-services/src/test/java/org/finos/legend/depot/services/entities/TestEntitiesService.java index 83e40a1cf..cbbd25d37 100644 --- a/legend-depot-entities-services/src/test/java/org/finos/legend/depot/services/entities/TestEntitiesService.java +++ b/legend-depot-entities-services/src/test/java/org/finos/legend/depot/services/entities/TestEntitiesService.java @@ -28,7 +28,7 @@ import org.finos.legend.depot.services.TestBaseServices; import org.finos.legend.depot.services.api.entities.ManageEntitiesService; import org.finos.legend.depot.services.projects.ProjectsServiceImpl; -import org.finos.legend.depot.store.metrics.api.QueryMetricsRegistry; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsRegistry; import org.finos.legend.depot.services.projects.configuration.ProjectsConfiguration; import org.finos.legend.depot.store.mongo.entities.EntitiesMongo; import org.finos.legend.depot.store.mongo.entities.test.EntitiesMongoTestUtils; diff --git a/legend-depot-generations-services/src/test/java/org/finos/legend/depot/services/generations/TestFileGenerationsService.java b/legend-depot-generations-services/src/test/java/org/finos/legend/depot/services/generations/TestFileGenerationsService.java index cd2cd9654..7fd50fa6d 100644 --- a/legend-depot-generations-services/src/test/java/org/finos/legend/depot/services/generations/TestFileGenerationsService.java +++ b/legend-depot-generations-services/src/test/java/org/finos/legend/depot/services/generations/TestFileGenerationsService.java @@ -28,7 +28,7 @@ import org.finos.legend.depot.store.api.generations.UpdateFileGenerations; import org.finos.legend.depot.store.api.projects.UpdateProjects; import org.finos.legend.depot.store.api.projects.UpdateProjectsVersions; -import org.finos.legend.depot.store.metrics.api.QueryMetricsRegistry; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsRegistry; import org.finos.legend.depot.store.model.generations.StoredFileGeneration; import org.finos.legend.depot.store.mongo.TestStoreMongo; import org.finos.legend.depot.store.mongo.generations.FileGenerationsMongo; diff --git a/legend-depot-metrics-query-api/pom.xml b/legend-depot-metrics-query-api/pom.xml new file mode 100644 index 000000000..af2ecce27 --- /dev/null +++ b/legend-depot-metrics-query-api/pom.xml @@ -0,0 +1,53 @@ + + + + + + legend-depot + org.finos.legend.depot + 2.5.1-SNAPSHOT + + 4.0.0 + + Legend Depot - Metrics - Query - API + legend-depot-metrics-query-api + + + + org.finos.legend.depot + legend-depot-core-data-api + + + org.finos.legend.depot + legend-depot-core-store-api + + + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.core + jackson-databind + + + javax.validation + validation-api + + + diff --git a/legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/api/QueryMetricsRegistry.java b/legend-depot-metrics-query-api/src/main/java/org/finos/legend/depot/services/api/metrics/query/QueryMetricsRegistry.java similarity index 87% rename from legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/api/QueryMetricsRegistry.java rename to legend-depot-metrics-query-api/src/main/java/org/finos/legend/depot/services/api/metrics/query/QueryMetricsRegistry.java index 44ae0aa51..7546f3e53 100644 --- a/legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/api/QueryMetricsRegistry.java +++ b/legend-depot-metrics-query-api/src/main/java/org/finos/legend/depot/services/api/metrics/query/QueryMetricsRegistry.java @@ -13,9 +13,9 @@ // limitations under the License. // -package org.finos.legend.depot.store.metrics.api; +package org.finos.legend.depot.services.api.metrics.query; -import org.finos.legend.depot.domain.metrics.VersionQueryMetric; +import org.finos.legend.depot.store.model.metrics.query.VersionQueryMetric; import java.util.Date; import java.util.Optional; @@ -30,4 +30,5 @@ default void record(String groupId, String artifactId, String versionId) void record(String groupId, String artifactId, String versionId, Date date); Optional findFirst(); + } diff --git a/legend-depot-metrics-query-api/src/main/java/org/finos/legend/depot/services/api/metrics/query/QueryMetricsService.java b/legend-depot-metrics-query-api/src/main/java/org/finos/legend/depot/services/api/metrics/query/QueryMetricsService.java new file mode 100644 index 000000000..d1a66f9cb --- /dev/null +++ b/legend-depot-metrics-query-api/src/main/java/org/finos/legend/depot/services/api/metrics/query/QueryMetricsService.java @@ -0,0 +1,40 @@ +// Copyright 2021 Goldman Sachs +// +// Licensed 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.finos.legend.depot.services.api.metrics.query; + +import org.finos.legend.depot.store.model.metrics.query.VersionQueryMetric; + +import java.util.Date; +import java.util.List; +import java.util.Optional; + +public interface QueryMetricsService +{ + Optional getSummary(String groupId, String artifactId, String versionId); + + List getSummaryByProjectVersion(); + + List findMetricsForProjectCoordinates(String groupId, String artifactId); + + List findReleasedVersionMetricsBefore(Date date); + + List findSnapshotVersionMetricsBefore(Date date); + + void consolidateMetrics(); + + void persist(QueryMetricsRegistry registry); + +} diff --git a/legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/services/VoidQueryMetricsRegistry.java b/legend-depot-metrics-query-api/src/main/java/org/finos/legend/depot/services/api/metrics/query/VoidQueryMetricsRegistry.java similarity index 83% rename from legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/services/VoidQueryMetricsRegistry.java rename to legend-depot-metrics-query-api/src/main/java/org/finos/legend/depot/services/api/metrics/query/VoidQueryMetricsRegistry.java index 1e008ffbb..308e613ae 100644 --- a/legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/services/VoidQueryMetricsRegistry.java +++ b/legend-depot-metrics-query-api/src/main/java/org/finos/legend/depot/services/api/metrics/query/VoidQueryMetricsRegistry.java @@ -13,10 +13,9 @@ // limitations under the License. // -package org.finos.legend.depot.store.metrics.services; +package org.finos.legend.depot.services.api.metrics.query; -import org.finos.legend.depot.domain.metrics.VersionQueryMetric; -import org.finos.legend.depot.store.metrics.api.QueryMetricsRegistry; +import org.finos.legend.depot.store.model.metrics.query.VersionQueryMetric; import java.util.Date; import java.util.Optional; diff --git a/legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/store/api/QueryMetrics.java b/legend-depot-metrics-query-api/src/main/java/org/finos/legend/depot/store/api/metrics/query/QueryMetrics.java similarity index 89% rename from legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/store/api/QueryMetrics.java rename to legend-depot-metrics-query-api/src/main/java/org/finos/legend/depot/store/api/metrics/query/QueryMetrics.java index 36648ffbd..e4be738c3 100644 --- a/legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/store/api/QueryMetrics.java +++ b/legend-depot-metrics-query-api/src/main/java/org/finos/legend/depot/store/api/metrics/query/QueryMetrics.java @@ -13,10 +13,10 @@ // limitations under the License. // -package org.finos.legend.depot.store.metrics.store.api; +package org.finos.legend.depot.store.api.metrics.query; import org.finos.legend.depot.domain.project.ProjectVersion; -import org.finos.legend.depot.domain.metrics.VersionQueryMetric; +import org.finos.legend.depot.store.model.metrics.query.VersionQueryMetric; import java.util.Date; import java.util.List; diff --git a/legend-depot-store-metrics/src/main/java/org/finos/legend/depot/domain/metrics/VersionQueryMetric.java b/legend-depot-metrics-query-api/src/main/java/org/finos/legend/depot/store/model/metrics/query/VersionQueryMetric.java similarity index 97% rename from legend-depot-store-metrics/src/main/java/org/finos/legend/depot/domain/metrics/VersionQueryMetric.java rename to legend-depot-metrics-query-api/src/main/java/org/finos/legend/depot/store/model/metrics/query/VersionQueryMetric.java index 7b41002c0..14f6dec74 100644 --- a/legend-depot-store-metrics/src/main/java/org/finos/legend/depot/domain/metrics/VersionQueryMetric.java +++ b/legend-depot-metrics-query-api/src/main/java/org/finos/legend/depot/store/model/metrics/query/VersionQueryMetric.java @@ -13,7 +13,7 @@ // limitations under the License. // -package org.finos.legend.depot.domain.metrics; +package org.finos.legend.depot.store.model.metrics.query; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; diff --git a/legend-depot-metrics-query-services/pom.xml b/legend-depot-metrics-query-services/pom.xml new file mode 100644 index 000000000..1730d557a --- /dev/null +++ b/legend-depot-metrics-query-services/pom.xml @@ -0,0 +1,74 @@ + + + + + + legend-depot + org.finos.legend.depot + 2.5.1-SNAPSHOT + + 4.0.0 + + Legend Depot - Metrics - Query - Services + legend-depot-metrics-query-services + + + + + org.finos.legend.depot + legend-depot-metrics-query-api + + + org.finos.legend.depot + legend-depot-core-schedules-api + + + com.google.inject + guice + + + org.slf4j + slf4j-api + + + org.finos.legend.depot + legend-depot-metrics-query-store-mongo + test + + + org.finos.legend.depot + legend-depot-store-mongo + tests + test-jar + test + + + + + ${junit.groupId} + ${junit.artifactId} + test + + + de.bwaldvogel + mongo-java-server + test + + + + diff --git a/legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/MetricsSchedulesModule.java b/legend-depot-metrics-query-services/src/main/java/org/finos/legend/depot/services/guice/ManageQueryMetricsSchedulesModule.java similarity index 61% rename from legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/MetricsSchedulesModule.java rename to legend-depot-metrics-query-services/src/main/java/org/finos/legend/depot/services/guice/ManageQueryMetricsSchedulesModule.java index 5363300b1..623ddbbc8 100644 --- a/legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/MetricsSchedulesModule.java +++ b/legend-depot-metrics-query-services/src/main/java/org/finos/legend/depot/services/guice/ManageQueryMetricsSchedulesModule.java @@ -13,18 +13,17 @@ // limitations under the License. // -package org.finos.legend.depot.store.metrics; +package org.finos.legend.depot.services.guice; import com.google.inject.PrivateModule; import com.google.inject.Provides; import com.google.inject.Singleton; import com.google.inject.name.Named; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsService; import org.finos.legend.depot.services.api.schedules.SchedulesFactory; -import org.finos.legend.depot.store.metrics.api.QueryMetricsRegistry; -import org.finos.legend.depot.store.metrics.services.InMemoryQueryMetricsRegistry; -import org.finos.legend.depot.store.metrics.services.QueryMetricsHandler; -public class MetricsSchedulesModule extends PrivateModule + +public class ManageQueryMetricsSchedulesModule extends PrivateModule { @Override protected void configure() @@ -34,7 +33,7 @@ protected void configure() @Provides @Singleton @Named("consolidate-query-metrics") - boolean scheduleMetricsConsolidation(SchedulesFactory schedulesFactory, QueryMetricsHandler queryMetrics) + boolean scheduleMetricsConsolidation(SchedulesFactory schedulesFactory, QueryMetricsService queryMetrics) { schedulesFactory.registerSingleInstance("consolidate-query-metrics", SchedulesFactory.MINUTE, 6 * SchedulesFactory.HOUR, () -> { @@ -43,18 +42,4 @@ boolean scheduleMetricsConsolidation(SchedulesFactory schedulesFactory, QueryMet }); return true; } - - @Provides - @Singleton - @Named("persist-query-metrics") - boolean scheduleMetricsPersistence(SchedulesFactory schedulesFactory, QueryMetricsHandler queryMetrics) - { - schedulesFactory.register("persist-query-metrics", SchedulesFactory.MINUTE, 5 * SchedulesFactory.MINUTE, () -> - { - queryMetrics.persistMetrics(); - return true; - }); - return true; - } - } diff --git a/legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/MetricsModule.java b/legend-depot-metrics-query-services/src/main/java/org/finos/legend/depot/services/guice/QueryMetricsModule.java similarity index 64% rename from legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/MetricsModule.java rename to legend-depot-metrics-query-services/src/main/java/org/finos/legend/depot/services/guice/QueryMetricsModule.java index 6c9c345e4..62498fe7e 100644 --- a/legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/MetricsModule.java +++ b/legend-depot-metrics-query-services/src/main/java/org/finos/legend/depot/services/guice/QueryMetricsModule.java @@ -13,30 +13,26 @@ // limitations under the License. // -package org.finos.legend.depot.store.metrics; +package org.finos.legend.depot.services.guice; import com.google.inject.PrivateModule; import com.google.inject.Provides; import com.google.inject.Singleton; import com.google.inject.name.Named; import com.google.inject.name.Names; -import org.finos.legend.depot.store.metrics.api.QueryMetricsRegistry; -import org.finos.legend.depot.store.metrics.services.InMemoryQueryMetricsRegistry; -import org.finos.legend.depot.store.metrics.services.QueryMetricsHandler; -import org.finos.legend.depot.store.metrics.store.api.QueryMetrics; -import org.finos.legend.depot.store.metrics.store.mongo.QueryMetricsMongo; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsRegistry; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsService; +import org.finos.legend.depot.services.metrics.query.InMemoryQueryMetricsRegistry; +import org.finos.legend.depot.services.metrics.query.QueryMetricsServiceImpl; -public class MetricsModule extends PrivateModule +public class QueryMetricsModule extends PrivateModule { @Override protected void configure() { - bind(QueryMetricsHandler.class); - bind(QueryMetrics.class).to(QueryMetricsMongo.class); - - expose(QueryMetrics.class); + bind(QueryMetricsService.class).to(QueryMetricsServiceImpl.class); + expose(QueryMetricsService.class); expose(QueryMetricsRegistry.class).annotatedWith(Names.named("queryMetricsRegistry")); - expose(QueryMetricsHandler.class); } @Provides diff --git a/legend-depot-metrics-query-services/src/main/java/org/finos/legend/depot/services/guice/QueryMetricsSchedulesModule.java b/legend-depot-metrics-query-services/src/main/java/org/finos/legend/depot/services/guice/QueryMetricsSchedulesModule.java new file mode 100644 index 000000000..14c835579 --- /dev/null +++ b/legend-depot-metrics-query-services/src/main/java/org/finos/legend/depot/services/guice/QueryMetricsSchedulesModule.java @@ -0,0 +1,48 @@ +// Copyright 2021 Goldman Sachs +// +// Licensed 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.finos.legend.depot.services.guice; + +import com.google.inject.PrivateModule; +import com.google.inject.Provides; +import com.google.inject.Singleton; +import com.google.inject.name.Named; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsRegistry; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsService; +import org.finos.legend.depot.services.api.schedules.SchedulesFactory; + + +public class QueryMetricsSchedulesModule extends PrivateModule +{ + @Override + protected void configure() + { + } + + + @Provides + @Singleton + @Named("persist-query-metrics-schedule") + boolean scheduleMetricsPersistence(SchedulesFactory schedulesFactory, @Named("queryMetricsRegistry") QueryMetricsRegistry metricsRegistry, QueryMetricsService metricsService) + { + schedulesFactory.register("persist-query-metrics", SchedulesFactory.MINUTE, 5 * SchedulesFactory.MINUTE, () -> + { + metricsService.persist(metricsRegistry); + return true; + }); + return true; + } + +} diff --git a/legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/services/InMemoryQueryMetricsRegistry.java b/legend-depot-metrics-query-services/src/main/java/org/finos/legend/depot/services/metrics/query/InMemoryQueryMetricsRegistry.java similarity index 87% rename from legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/services/InMemoryQueryMetricsRegistry.java rename to legend-depot-metrics-query-services/src/main/java/org/finos/legend/depot/services/metrics/query/InMemoryQueryMetricsRegistry.java index 9c674e4b4..c633b4405 100644 --- a/legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/services/InMemoryQueryMetricsRegistry.java +++ b/legend-depot-metrics-query-services/src/main/java/org/finos/legend/depot/services/metrics/query/InMemoryQueryMetricsRegistry.java @@ -13,10 +13,10 @@ // limitations under the License. // -package org.finos.legend.depot.store.metrics.services; +package org.finos.legend.depot.services.metrics.query; -import org.finos.legend.depot.domain.metrics.VersionQueryMetric; -import org.finos.legend.depot.store.metrics.api.QueryMetricsRegistry; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsRegistry; +import org.finos.legend.depot.store.model.metrics.query.VersionQueryMetric; import javax.inject.Inject; import java.util.Date; diff --git a/legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/services/QueryMetricsHandler.java b/legend-depot-metrics-query-services/src/main/java/org/finos/legend/depot/services/metrics/query/QueryMetricsServiceImpl.java similarity index 83% rename from legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/services/QueryMetricsHandler.java rename to legend-depot-metrics-query-services/src/main/java/org/finos/legend/depot/services/metrics/query/QueryMetricsServiceImpl.java index c94c09736..17900b820 100644 --- a/legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/services/QueryMetricsHandler.java +++ b/legend-depot-metrics-query-services/src/main/java/org/finos/legend/depot/services/metrics/query/QueryMetricsServiceImpl.java @@ -13,13 +13,14 @@ // limitations under the License. // -package org.finos.legend.depot.store.metrics.services; +package org.finos.legend.depot.services.metrics.query; import com.google.inject.name.Named; import org.finos.legend.depot.domain.version.VersionValidator; -import org.finos.legend.depot.store.metrics.store.api.QueryMetrics; -import org.finos.legend.depot.domain.metrics.VersionQueryMetric; -import org.finos.legend.depot.store.metrics.api.QueryMetricsRegistry; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsRegistry; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsService; +import org.finos.legend.depot.store.api.metrics.query.QueryMetrics; +import org.finos.legend.depot.store.model.metrics.query.VersionQueryMetric; import org.slf4j.Logger; import javax.inject.Inject; @@ -29,19 +30,19 @@ import java.util.Optional; import java.util.stream.Collectors; -public class QueryMetricsHandler +public class QueryMetricsServiceImpl implements QueryMetricsService { - private static final Logger LOGGER = org.slf4j.LoggerFactory.getLogger(QueryMetricsHandler.class); + private static final Logger LOGGER = org.slf4j.LoggerFactory.getLogger(QueryMetricsServiceImpl.class); private final QueryMetrics metricsStore; - private final QueryMetricsRegistry queryMetricsRegistry; + //TODO: will require different implementation for recording and consolidating query metrics for different stores @Inject - public QueryMetricsHandler(QueryMetrics metricsStore, @Named("queryMetricsRegistry") QueryMetricsRegistry queryMetricsRegistry) + public QueryMetricsServiceImpl(QueryMetrics metricsStore) { this.metricsStore = metricsStore; - this.queryMetricsRegistry = queryMetricsRegistry; + } public Optional getSummary(String groupId, String artifactId, String versionId) @@ -79,14 +80,17 @@ public List findSnapshotVersionMetricsBefore(Date date) return metricsStore.findMetricsBefore(date).parallelStream().filter(metric -> VersionValidator.isSnapshotVersion(metric.getVersionId())).collect(Collectors.toList()); } - public void persistMetrics() + + @Override + public void persist(QueryMetricsRegistry registry) { - Optional versionQueryMetric = queryMetricsRegistry.findFirst(); + Optional versionQueryMetric = registry.findFirst(); while (versionQueryMetric.isPresent()) { metricsStore.insert(versionQueryMetric.get()); - versionQueryMetric = queryMetricsRegistry.findFirst(); + versionQueryMetric = registry.findFirst(); } + } public void consolidateMetrics() diff --git a/legend-depot-store-metrics/src/test/java/org/finos/legend/depot/store/metrics/TestMetricsServices.java b/legend-depot-metrics-query-services/src/test/java/org/finos/legend/depot/services/metrics/query/TestMetricsServices.java similarity index 92% rename from legend-depot-store-metrics/src/test/java/org/finos/legend/depot/store/metrics/TestMetricsServices.java rename to legend-depot-metrics-query-services/src/test/java/org/finos/legend/depot/services/metrics/query/TestMetricsServices.java index 7575f2351..3de95183e 100644 --- a/legend-depot-store-metrics/src/test/java/org/finos/legend/depot/store/metrics/TestMetricsServices.java +++ b/legend-depot-metrics-query-services/src/test/java/org/finos/legend/depot/services/metrics/query/TestMetricsServices.java @@ -13,14 +13,13 @@ // limitations under the License. // -package org.finos.legend.depot.store.metrics; +package org.finos.legend.depot.services.metrics.query; import org.finos.legend.depot.domain.project.ProjectVersion; -import org.finos.legend.depot.domain.metrics.VersionQueryMetric; -import org.finos.legend.depot.store.metrics.api.QueryMetricsRegistry; -import org.finos.legend.depot.store.metrics.services.QueryMetricsHandler; -import org.finos.legend.depot.store.metrics.services.InMemoryQueryMetricsRegistry; -import org.finos.legend.depot.store.metrics.store.mongo.QueryMetricsMongo; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsRegistry; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsService; +import org.finos.legend.depot.store.model.metrics.query.VersionQueryMetric; +import org.finos.legend.depot.store.mongo.metrics.query.QueryMetricsMongo; import org.finos.legend.depot.store.mongo.TestStoreMongo; import org.junit.After; import org.junit.Assert; @@ -48,7 +47,7 @@ public class TestMetricsServices extends TestStoreMongo private QueryMetricsMongo metricsStore = new QueryMetricsMongo(mongoProvider); private QueryMetricsRegistry metricsRegistry = new InMemoryQueryMetricsRegistry(); - private QueryMetricsHandler metricsHandler = new QueryMetricsHandler(metricsStore, metricsRegistry); + private QueryMetricsService metricsHandler = new QueryMetricsServiceImpl(metricsStore); @Before @@ -117,7 +116,7 @@ public void canConsolidateQueryMetrics() throws InterruptedException metricsRegistry.record("group1", "art1", "3.0.0"); Thread.sleep(10); metricsRegistry.record("group1", "art1", "3.0.0"); - metricsHandler.persistMetrics(); + metricsHandler.persist(metricsRegistry); Assert.assertEquals(6, metricsStore.getAllStoredEntities().size()); List summary = metricsHandler.getSummaryByProjectVersion(); metricsHandler.consolidateMetrics(); @@ -156,7 +155,7 @@ public void canPersistMetrics() throws InterruptedException Thread.sleep(10); metricsRegistry.record("group1", "art1", "3.0.0"); metricsRegistry.record("group1", "art1", "2.0.0"); - metricsHandler.persistMetrics(); + metricsHandler.persist(metricsRegistry); Assert.assertEquals(7, metricsStore.getAllStoredEntities().size()); } diff --git a/legend-depot-store-metrics/pom.xml b/legend-depot-metrics-query-store-mongo/pom.xml similarity index 87% rename from legend-depot-store-metrics/pom.xml rename to legend-depot-metrics-query-store-mongo/pom.xml index 1d0b08073..e1bb90265 100644 --- a/legend-depot-store-metrics/pom.xml +++ b/legend-depot-metrics-query-store-mongo/pom.xml @@ -24,11 +24,15 @@ 4.0.0 - Legend Depot - Store - Metrics - legend-depot-store-metrics + Legend Depot - Metrics - Query - Store -Mongo + legend-depot-metrics-query-store-mongo + + org.finos.legend.depot + legend-depot-metrics-query-api + org.finos.legend.depot legend-depot-store-mongo diff --git a/legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/AdminMetricsModule.java b/legend-depot-metrics-query-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/guice/ManageQueryMetricsMongoStoreModule.java similarity index 76% rename from legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/AdminMetricsModule.java rename to legend-depot-metrics-query-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/guice/ManageQueryMetricsMongoStoreModule.java index f1da3ae4f..5dd40c355 100644 --- a/legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/AdminMetricsModule.java +++ b/legend-depot-metrics-query-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/guice/ManageQueryMetricsMongoStoreModule.java @@ -13,24 +13,21 @@ // limitations under the License. // -package org.finos.legend.depot.store.metrics; +package org.finos.legend.depot.store.mongo.guice; +import com.google.inject.PrivateModule; import com.google.inject.Provides; import com.google.inject.Singleton; import com.google.inject.name.Named; -import org.finos.legend.depot.store.metrics.store.mongo.QueryMetricsMongo; import org.finos.legend.depot.store.mongo.admin.MongoAdminStore; -import org.finos.legend.depot.store.resources.metrics.ManageMetricsResourceResource; +import org.finos.legend.depot.store.mongo.metrics.query.QueryMetricsMongo; -public class AdminMetricsModule extends MetricsModule +public class ManageQueryMetricsMongoStoreModule extends QueryMetricsMongoStoreModule { @Override protected void configure() { super.configure(); - - bind(ManageMetricsResourceResource.class); - expose(ManageMetricsResourceResource.class); } @Singleton diff --git a/legend-depot-metrics-query-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/guice/QueryMetricsMongoStoreModule.java b/legend-depot-metrics-query-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/guice/QueryMetricsMongoStoreModule.java new file mode 100644 index 000000000..ff39fbb12 --- /dev/null +++ b/legend-depot-metrics-query-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/guice/QueryMetricsMongoStoreModule.java @@ -0,0 +1,34 @@ +// Copyright 2021 Goldman Sachs +// +// Licensed 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.finos.legend.depot.store.mongo.guice; + +import com.google.inject.PrivateModule; + +import org.finos.legend.depot.store.api.metrics.query.QueryMetrics; +import org.finos.legend.depot.store.mongo.metrics.query.QueryMetricsMongo; + +public class QueryMetricsMongoStoreModule extends PrivateModule +{ + @Override + protected void configure() + { + bind(QueryMetrics.class).to(QueryMetricsMongo.class); + + expose(QueryMetrics.class); + } + + +} diff --git a/legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/store/mongo/QueryMetricsMongo.java b/legend-depot-metrics-query-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/metrics/query/QueryMetricsMongo.java similarity index 94% rename from legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/store/mongo/QueryMetricsMongo.java rename to legend-depot-metrics-query-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/metrics/query/QueryMetricsMongo.java index 0762cc864..a2c6580af 100644 --- a/legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/metrics/store/mongo/QueryMetricsMongo.java +++ b/legend-depot-metrics-query-store-mongo/src/main/java/org/finos/legend/depot/store/mongo/metrics/query/QueryMetricsMongo.java @@ -14,7 +14,7 @@ // -package org.finos.legend.depot.store.metrics.store.mongo; +package org.finos.legend.depot.store.mongo.metrics.query; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.ObjectMapper; @@ -27,8 +27,8 @@ import org.bson.Document; import org.bson.conversions.Bson; import org.finos.legend.depot.domain.project.ProjectVersion; -import org.finos.legend.depot.domain.metrics.VersionQueryMetric; -import org.finos.legend.depot.store.metrics.store.api.QueryMetrics; +import org.finos.legend.depot.store.api.metrics.query.QueryMetrics; +import org.finos.legend.depot.store.model.metrics.query.VersionQueryMetric; import org.finos.legend.depot.store.mongo.core.BaseMongo; import com.mongodb.client.model.IndexModel; @@ -52,13 +52,11 @@ public class QueryMetricsMongo extends BaseMongo implements public static final String COLLECTION = "query-metrics"; - private final MongoDatabase mongoDatabase; @Inject public QueryMetricsMongo(@Named("mongoDatabase") MongoDatabase databaseProvider) { super(databaseProvider, VersionQueryMetric.class, new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_EMPTY)); - this.mongoDatabase = databaseProvider; } public MongoCollection getCollection() diff --git a/legend-depot-pure-model-context/pom.xml b/legend-depot-pure-model-context/pom.xml index 319379076..6fe7d4e93 100644 --- a/legend-depot-pure-model-context/pom.xml +++ b/legend-depot-pure-model-context/pom.xml @@ -119,6 +119,16 @@ test-jar test + + org.finos.legend.depot + legend-depot-metrics-query-services + test + + + org.finos.legend.depot + legend-depot-metrics-query-store-mongo + test + diff --git a/legend-depot-pure-model-context/src/test/java/org/finos/legend/depot/server/resources/TestPureModelContextDataResource.java b/legend-depot-pure-model-context/src/test/java/org/finos/legend/depot/server/resources/TestPureModelContextDataResource.java index bf6229a58..1a0922400 100644 --- a/legend-depot-pure-model-context/src/test/java/org/finos/legend/depot/server/resources/TestPureModelContextDataResource.java +++ b/legend-depot-pure-model-context/src/test/java/org/finos/legend/depot/server/resources/TestPureModelContextDataResource.java @@ -25,8 +25,8 @@ import org.finos.legend.depot.services.pure.model.context.PureModelContextServiceImpl; import org.finos.legend.depot.services.pure.model.context.TestPureModelContextService; import org.finos.legend.depot.store.api.entities.Entities; -import org.finos.legend.depot.store.metrics.api.QueryMetricsRegistry; -import org.finos.legend.depot.store.metrics.services.InMemoryQueryMetricsRegistry; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsRegistry; +import org.finos.legend.depot.services.metrics.query.InMemoryQueryMetricsRegistry; import org.finos.legend.depot.store.mongo.entities.EntitiesMongo; import org.finos.legend.depot.store.mongo.entities.test.EntitiesMongoTestUtils; import org.finos.legend.depot.store.notifications.queue.api.Queue; diff --git a/legend-depot-pure-model-context/src/test/java/org/finos/legend/depot/services/pure/model/context/TestPureModelContextService.java b/legend-depot-pure-model-context/src/test/java/org/finos/legend/depot/services/pure/model/context/TestPureModelContextService.java index 3ce3de466..2c27aee75 100644 --- a/legend-depot-pure-model-context/src/test/java/org/finos/legend/depot/services/pure/model/context/TestPureModelContextService.java +++ b/legend-depot-pure-model-context/src/test/java/org/finos/legend/depot/services/pure/model/context/TestPureModelContextService.java @@ -18,6 +18,9 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsService; +import org.finos.legend.depot.services.metrics.query.InMemoryQueryMetricsRegistry; +import org.finos.legend.depot.services.metrics.query.QueryMetricsServiceImpl; import org.finos.legend.depot.store.model.projects.StoreProjectData; import org.finos.legend.depot.store.model.projects.StoreProjectVersionData; import org.finos.legend.depot.services.api.pure.model.context.PureModelContextService; @@ -27,14 +30,13 @@ import org.finos.legend.depot.services.entities.EntitiesServiceImpl; import org.finos.legend.depot.services.projects.ProjectsServiceImpl; import org.finos.legend.depot.store.api.entities.UpdateEntities; -import org.finos.legend.depot.store.metrics.services.InMemoryQueryMetricsRegistry; -import org.finos.legend.depot.store.metrics.store.api.QueryMetrics; -import org.finos.legend.depot.store.metrics.api.QueryMetricsRegistry; -import org.finos.legend.depot.store.metrics.services.QueryMetricsHandler; -import org.finos.legend.depot.store.metrics.store.mongo.QueryMetricsMongo; +import org.finos.legend.depot.store.api.metrics.query.QueryMetrics; +import org.finos.legend.depot.services.api.metrics.query.QueryMetricsRegistry; + import org.finos.legend.depot.store.mongo.entities.test.EntitiesMongoTestUtils; import org.finos.legend.depot.services.projects.configuration.ProjectsConfiguration; import org.finos.legend.depot.store.mongo.entities.EntitiesMongo; +import org.finos.legend.depot.store.mongo.metrics.query.QueryMetricsMongo; import org.finos.legend.depot.store.notifications.queue.api.Queue; import org.finos.legend.engine.protocol.pure.v1.model.context.AlloySDLC; import org.finos.legend.engine.protocol.pure.v1.model.context.PureModelContextData; @@ -63,7 +65,7 @@ public class TestPureModelContextService extends TestBaseServices public static final String CLIENT_VERSION = "vX_X_X"; private final QueryMetrics metrics = new QueryMetricsMongo(mongoProvider); private final QueryMetricsRegistry metricsRegistry = new InMemoryQueryMetricsRegistry(); - private final QueryMetricsHandler metricsHandler = new QueryMetricsHandler(metrics, metricsRegistry); + private final QueryMetricsService metricsHandler = new QueryMetricsServiceImpl(metrics); private final Queue queue = mock(Queue.class); ProjectsService projectsService = new ProjectsServiceImpl(projectsVersionsStore, projectsStore, metricsRegistry, queue, new ProjectsConfiguration("master")); protected UpdateEntities entitiesStore = new EntitiesMongo(mongoProvider); @@ -193,7 +195,7 @@ public void canGetEntitiesForProjectAsPureModelContextDataWithLatestAsVersion() public void canGetEntitiesForProjectAsPureModelContextDataWithMetricsStored() { getPureModelContextDataAsString("examples.metadata", "test", "2.3.1", CLIENT_VERSION, true); - metricsHandler.persistMetrics(); + metricsHandler.persist(metricsRegistry); Assert.assertEquals(metrics.getAll().size(), 5); Assert.assertNotNull(metrics.get("examples.metadata", "test-dependencies", "1.0.0").get(0).getLastQueryTime()); Assert.assertNotNull(metrics.get("examples.metadata", "test", "2.3.1").get(0).getLastQueryTime()); diff --git a/legend-depot-server/pom.xml b/legend-depot-server/pom.xml index fd02c958a..80192b70e 100644 --- a/legend-depot-server/pom.xml +++ b/legend-depot-server/pom.xml @@ -45,8 +45,11 @@ org.finos.legend.depot - legend-depot-store-metrics - compile + legend-depot-metrics-query-services + + + org.finos.legend.depot + legend-depot-metrics-query-store-mongo org.finos.legend.depot diff --git a/legend-depot-server/src/main/java/org/finos/legend/depot/server/LegendDepotServer.java b/legend-depot-server/src/main/java/org/finos/legend/depot/server/LegendDepotServer.java index 3ec1f634c..4d3ef05d0 100644 --- a/legend-depot-server/src/main/java/org/finos/legend/depot/server/LegendDepotServer.java +++ b/legend-depot-server/src/main/java/org/finos/legend/depot/server/LegendDepotServer.java @@ -30,9 +30,10 @@ import org.finos.legend.depot.services.guice.CoreDataServicesModule; import org.finos.legend.depot.services.guice.SchedulesModule; import org.finos.legend.depot.services.guice.GenerationsServicesModule; -import org.finos.legend.depot.store.metrics.MetricsModule; -import org.finos.legend.depot.store.metrics.MetricsSchedulesModule; -import org.finos.legend.depot.store.mongo.admin.guice.SchedulesStoreMongoModule; +import org.finos.legend.depot.services.guice.QueryMetricsModule; +import org.finos.legend.depot.services.guice.QueryMetricsSchedulesModule; +import org.finos.legend.depot.store.mongo.guice.QueryMetricsMongoStoreModule; +import org.finos.legend.depot.store.mongo.guice.SchedulesStoreMongoModule; import org.finos.legend.depot.store.mongo.core.MongoClientModule; import org.finos.legend.depot.store.mongo.guice.CoreDataStoreMongoModule; import org.finos.legend.depot.store.mongo.guice.EntitiesStoreMongoModule; @@ -83,8 +84,9 @@ protected List getServerModules() new SchedulesModule(), new SchedulesStoreMongoModule(), - new MetricsModule(), - new MetricsSchedulesModule(), + new QueryMetricsModule(), + new QueryMetricsMongoStoreModule(), + new QueryMetricsSchedulesModule(), new TracingModule() ); } diff --git a/legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/resources/metrics/ManageMetricsResourceResource.java b/legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/resources/metrics/ManageMetricsResourceResource.java deleted file mode 100644 index bc69e576b..000000000 --- a/legend-depot-store-metrics/src/main/java/org/finos/legend/depot/store/resources/metrics/ManageMetricsResourceResource.java +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2021 Goldman Sachs -// -// Licensed 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.finos.legend.depot.store.resources.metrics; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.finos.legend.depot.core.authorisation.api.AuthorisationProvider; -import org.finos.legend.depot.core.authorisation.resources.BaseAuthorisedResource; -import org.finos.legend.depot.domain.metrics.VersionQueryMetric; -import org.finos.legend.depot.store.metrics.services.QueryMetricsHandler; -import org.finos.legend.depot.tracing.resources.ResourceLoggingAndTracing; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Provider; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; -import java.security.Principal; -import java.util.List; - -@Path("") -@Api("Metrics") -public class ManageMetricsResourceResource extends BaseAuthorisedResource -{ - private final QueryMetricsHandler queryMetrics; - - @Inject - protected ManageMetricsResourceResource(AuthorisationProvider authorisationProvider, - @Named("requestPrincipal") Provider principalProvider, QueryMetricsHandler queryMetrics) - { - super(authorisationProvider, principalProvider); - this.queryMetrics = queryMetrics; - } - - @Override - protected String getResourceName() - { - return "Metrics"; - } - - @GET - @Path("/metrics/lastQuery") - @ApiOperation(ResourceLoggingAndTracing.GET_VERSIONS_BY_LAST_USED) - @Produces(MediaType.APPLICATION_JSON) - public List getVersionsByLastUsed() - { - return handle(ResourceLoggingAndTracing.GET_VERSIONS_BY_LAST_USED, () -> this.queryMetrics.getSummaryByProjectVersion()); - } - -} diff --git a/legend-depot-store-server/pom.xml b/legend-depot-store-server/pom.xml index f54238d11..0bf2a4bd6 100644 --- a/legend-depot-store-server/pom.xml +++ b/legend-depot-store-server/pom.xml @@ -115,6 +115,14 @@ ${junit.artifactId} test + + org.finos.legend.depot + legend-depot-metrics-query-store-mongo + + + org.finos.legend.depot + legend-depot-metrics-query-services + diff --git a/legend-depot-store-server/src/main/java/org/finos/legend/depot/store/server/LegendDepotStoreServer.java b/legend-depot-store-server/src/main/java/org/finos/legend/depot/store/server/LegendDepotStoreServer.java index b584700a1..c348d7ca2 100644 --- a/legend-depot-store-server/src/main/java/org/finos/legend/depot/store/server/LegendDepotStoreServer.java +++ b/legend-depot-store-server/src/main/java/org/finos/legend/depot/store/server/LegendDepotStoreServer.java @@ -29,13 +29,14 @@ import org.finos.legend.depot.services.guice.ManageGenerationsServicesModule; import org.finos.legend.depot.services.guice.ManageSchedulesModule; import org.finos.legend.depot.services.api.artifacts.repository.ArtifactRepositoryProviderConfiguration; + +import org.finos.legend.depot.services.guice.QueryMetricsModule; import org.finos.legend.depot.services.guice.RepositoryModule; -import org.finos.legend.depot.store.metrics.AdminMetricsModule; -import org.finos.legend.depot.store.metrics.MetricsSchedulesModule; import org.finos.legend.depot.store.mongo.guice.ManageMongoStoreSchedulesModule; -import org.finos.legend.depot.store.mongo.admin.guice.ManageSchedulesStoreMongoModule; +import org.finos.legend.depot.store.mongo.guice.ManageQueryMetricsMongoStoreModule; +import org.finos.legend.depot.store.mongo.guice.ManageSchedulesStoreMongoModule; import org.finos.legend.depot.store.mongo.guice.ManageMongoStoreModule; -import org.finos.legend.depot.store.mongo.admin.guice.ArtifactsStoreMongoModule; +import org.finos.legend.depot.store.mongo.guice.ArtifactsStoreMongoModule; import org.finos.legend.depot.store.mongo.core.MongoClientModule; import org.finos.legend.depot.store.mongo.guice.CoreDataMigrationsStoreMongoModule; import org.finos.legend.depot.store.mongo.guice.EntitiesMigrationsStoreMongoModule; @@ -119,8 +120,8 @@ protected List getServerModules() new NotificationsSchedulesModule(), new ManageNotificationsQueueModule(), - new AdminMetricsModule(), - new MetricsSchedulesModule(), + new QueryMetricsModule(), + new ManageQueryMetricsMongoStoreModule(), new AuthorisationModule(), diff --git a/legend-depot-test-reports/pom.xml b/legend-depot-test-reports/pom.xml index e472bef0e..a5d9528cd 100644 --- a/legend-depot-test-reports/pom.xml +++ b/legend-depot-test-reports/pom.xml @@ -211,7 +211,17 @@ org.finos.legend.depot - legend-depot-store-metrics + legend-depot-metrics-query-services + + + * + * + + + + + org.finos.legend.depot + legend-depot-metrics-query-store-mongo * diff --git a/pom.xml b/pom.xml index 126601aa6..ac704a1a2 100644 --- a/pom.xml +++ b/pom.xml @@ -46,7 +46,10 @@ legend-depot-core-schedules legend-depot-core-schedules-store-mongo - legend-depot-store-metrics + legend-depot-metrics-query-api + legend-depot-metrics-query-services + legend-depot-metrics-query-store-mongo + legend-depot-store-notifications legend-depot-store-notifications-queue @@ -529,7 +532,17 @@ org.finos.legend.depot - legend-depot-store-metrics + legend-depot-metrics-query-api + ${project.version} + + + org.finos.legend.depot + legend-depot-metrics-query-services + ${project.version} + + + org.finos.legend.depot + legend-depot-metrics-query-store-mongo ${project.version}