Skip to content

Commit

Permalink
Merge branch 'finos:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
AFine-gs authored Oct 7, 2024
2 parents df6d619 + 97c43ff commit e51ad34
Show file tree
Hide file tree
Showing 47 changed files with 148 additions and 69 deletions.
2 changes: 1 addition & 1 deletion legend-depot-artifacts-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.finos.legend.depot</groupId>
<artifactId>legend-depot</artifactId>
<version>2.42.1-SNAPSHOT</version>
<version>2.43.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-artifacts-repository-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>legend-depot</artifactId>
<groupId>org.finos.legend.depot</groupId>
<version>2.42.1-SNAPSHOT</version>
<version>2.43.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-artifacts-repository-maven-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>legend-depot</artifactId>
<groupId>org.finos.legend.depot</groupId>
<version>2.42.1-SNAPSHOT</version>
<version>2.43.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-artifacts-services/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>legend-depot</artifactId>
<groupId>org.finos.legend.depot</groupId>
<version>2.42.1-SNAPSHOT</version>
<version>2.43.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-artifacts-store-mongo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.finos.legend.depot</groupId>
<artifactId>legend-depot</artifactId>
<version>2.42.1-SNAPSHOT</version>
<version>2.43.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-core-authorisation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>legend-depot</artifactId>
<groupId>org.finos.legend.depot</groupId>
<version>2.42.1-SNAPSHOT</version>
<version>2.43.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-core-data-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.finos.legend.depot</groupId>
<artifactId>legend-depot</artifactId>
<version>2.42.1-SNAPSHOT</version>
<version>2.43.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-core-data-services/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>legend-depot</artifactId>
<groupId>org.finos.legend.depot</groupId>
<version>2.42.1-SNAPSHOT</version>
<version>2.43.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-core-data-store-mongo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.finos.legend.depot</groupId>
<artifactId>legend-depot</artifactId>
<version>2.42.1-SNAPSHOT</version>
<version>2.43.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-core-schedules-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.finos.legend.depot</groupId>
<artifactId>legend-depot</artifactId>
<version>2.42.1-SNAPSHOT</version>
<version>2.43.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ public interface ScheduleInstancesStore

void insert(ScheduleInstance instance);

void delete(String instanceId);
long delete(long l);

}
2 changes: 1 addition & 1 deletion legend-depot-core-schedules-store-mongo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.finos.legend.depot</groupId>
<artifactId>legend-depot</artifactId>
<version>2.42.1-SNAPSHOT</version>
<version>2.43.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.model.IndexModel;
import org.bson.conversions.Bson;
import org.bson.types.ObjectId;
import org.finos.legend.depot.store.api.admin.schedules.ScheduleInstancesStore;
import org.finos.legend.depot.store.model.admin.schedules.ScheduleInstance;
import org.finos.legend.depot.store.mongo.core.BaseMongo;
Expand All @@ -32,11 +31,13 @@
import java.util.List;

import static com.mongodb.client.model.Filters.eq;
import static com.mongodb.client.model.Filters.lt;

public class ScheduleInstancesMongo extends BaseMongo<ScheduleInstance> implements ScheduleInstancesStore
{
public static final String COLLECTION = "schedule-instances";
public static final String SCHEDULE = "schedule";
private static final String EXPIRES = "expires";


@Inject
Expand Down Expand Up @@ -75,9 +76,9 @@ public List<ScheduleInstance> getAll()
}

@Override
public void delete(String instanceId)
public long delete(long expiry)
{
super.delete(eq(ID_FIELD, new ObjectId(instanceId)));
return super.delete(lt(EXPIRES, expiry));
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion legend-depot-core-schedules/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>legend-depot</artifactId>
<groupId>org.finos.legend.depot</groupId>
<version>2.42.1-SNAPSHOT</version>
<version>2.43.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.util.stream.Collectors;

import static org.finos.legend.depot.domain.DatesHandler.toDate;
import static org.finos.legend.depot.domain.DatesHandler.toTime;


@Singleton
Expand Down Expand Up @@ -144,10 +145,9 @@ boolean canExecute(String name)

long deleteExpired()
{
List<ScheduleInstance> expired = instancesStore.getAll().stream().filter(instance -> instance.isExpired()).collect(Collectors.toList());
expired.forEach(instance -> this.instancesStore.delete(instance.getId()));
LOGGER.info("Deleted {} expired schedule runs", expired.size());
return expired.size();
long deletedInstancesCount = this.instancesStore.delete(toTime(LocalDateTime.now()));
LOGGER.info("Deleted {} expired schedule runs", deletedInstancesCount);
return deletedInstancesCount;
}

public void deRegister(String name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

class MockInstancesStore implements ScheduleInstancesStore
{
Expand All @@ -36,9 +37,11 @@ public void insert(ScheduleInstance instance)
}

@Override
public void delete(String instanceId)
public long delete(long l)
{
instances.removeIf(i -> instanceId.equals(i.getId()));
List<ScheduleInstance> toDeletedInstances = instances.stream().filter(i -> i.isExpired()).collect(Collectors.toList());
instances.removeAll(toDeletedInstances);
return toDeletedInstances.size();
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion legend-depot-core-store-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>legend-depot</artifactId>
<groupId>org.finos.legend.depot</groupId>
<version>2.42.1-SNAPSHOT</version>
<version>2.43.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-core-tracing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.finos.legend.depot</groupId>
<artifactId>legend-depot</artifactId>
<version>2.42.1-SNAPSHOT</version>
<version>2.43.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-entities-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.finos.legend.depot</groupId>
<artifactId>legend-depot</artifactId>
<version>2.42.1-SNAPSHOT</version>
<version>2.43.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-entities-services/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>legend-depot</artifactId>
<groupId>org.finos.legend.depot</groupId>
<version>2.42.1-SNAPSHOT</version>
<version>2.43.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.finos.legend.depot.services.api.entities.EntitiesService;
import org.finos.legend.depot.core.services.tracing.resources.TracingResource;
import org.finos.legend.depot.services.api.EtagBuilder;
import org.finos.legend.depot.services.api.projects.ProjectsService;

import javax.inject.Inject;
import javax.ws.rs.DefaultValue;
Expand All @@ -45,11 +46,13 @@
public class EntitiesResource extends TracingResource
{
private final EntitiesService entitiesService;
private final ProjectsService projectsService;

@Inject
public EntitiesResource(EntitiesService entitiesService)
public EntitiesResource(EntitiesService entitiesService, ProjectsService projectsService)
{
this.entitiesService = entitiesService;
this.projectsService = projectsService;
}

@GET
Expand All @@ -61,7 +64,8 @@ public Response getEntities(@PathParam("groupId") String groupId,
@PathParam("versionId") @ApiParam(value = VersionValidator.VALID_VERSION_ID_TXT) String versionId,
@Context Request request)
{
return handle(GET_VERSION_ENTITIES, () -> this.entitiesService.getEntities(groupId, artifactId, versionId), request, () -> EtagBuilder.create().withGAV(groupId, artifactId, versionId).build());
String resolvedVersionId = this.projectsService.resolveAliasesAndCheckVersionExists(groupId, artifactId, versionId);
return handle(GET_VERSION_ENTITIES, () -> this.entitiesService.getEntities(groupId, artifactId, resolvedVersionId), request, () -> EtagBuilder.create().withGAV(groupId, artifactId, resolvedVersionId).build());
}

@GET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import org.finos.legend.depot.domain.project.ProjectVersion;
import org.finos.legend.depot.services.api.metrics.query.QueryMetricsService;
import org.finos.legend.depot.services.api.projects.ProjectsService;
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;
Expand Down Expand Up @@ -60,8 +61,9 @@ public class TestEntitiesResource extends TestBaseServices
private final Queue queue = mock(Queue.class);
private UpdateEntities entitiesStore = new EntitiesMongo(mongoProvider);
private EntitiesMongoTestUtils entityUtils = new EntitiesMongoTestUtils(mongoProvider);
private final EntitiesService entitiesService = new EntitiesServiceImpl(entitiesStore,new ProjectsServiceImpl(projectsVersions, projects, metricsRegistry, queue, new ProjectsConfiguration("master")));
private EntitiesResource entitiesResource = new EntitiesResource(entitiesService);
private ProjectsService projectsService = new ProjectsServiceImpl(projectsVersions, projects, metricsRegistry, queue, new ProjectsConfiguration("master"));
private final EntitiesService entitiesService = new EntitiesServiceImpl(entitiesStore,projectsService);
private EntitiesResource entitiesResource = new EntitiesResource(entitiesService, projectsService);
private QueryMetricsMongo metricsStore = new QueryMetricsMongo(mongoProvider);
private QueryMetricsService metricsHandler = new QueryMetricsServiceImpl(metricsStore);

Expand Down Expand Up @@ -135,7 +137,7 @@ public void canGetMetrics() throws InterruptedException
metricsHandler.persist(metricsRegistry);

Assert.assertNotNull(metricsStore.get("examples.metadata", "test", "2.3.0").get(0).getLastQueryTime());
Assert.assertEquals(2, metricsStore.getAllStoredEntities().size());
Assert.assertEquals(3, metricsStore.getAllStoredEntities().size());
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion legend-depot-entities-store-mongo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.finos.legend.depot</groupId>
<artifactId>legend-depot</artifactId>
<version>2.42.1-SNAPSHOT</version>
<version>2.43.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-generations-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>legend-depot</artifactId>
<groupId>org.finos.legend.depot</groupId>
<version>2.42.1-SNAPSHOT</version>
<version>2.43.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-generations-services/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>legend-depot</artifactId>
<groupId>org.finos.legend.depot</groupId>
<version>2.42.1-SNAPSHOT</version>
<version>2.43.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-generations-store-mongo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.finos.legend.depot</groupId>
<artifactId>legend-depot</artifactId>
<version>2.42.1-SNAPSHOT</version>
<version>2.43.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-metrics-query-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>legend-depot</artifactId>
<groupId>org.finos.legend.depot</groupId>
<version>2.42.1-SNAPSHOT</version>
<version>2.43.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-metrics-query-services/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>legend-depot</artifactId>
<groupId>org.finos.legend.depot</groupId>
<version>2.42.1-SNAPSHOT</version>
<version>2.43.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-metrics-query-store-mongo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>legend-depot</artifactId>
<groupId>org.finos.legend.depot</groupId>
<version>2.42.1-SNAPSHOT</version>
<version>2.43.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.finos.legend.depot</groupId>
<artifactId>legend-depot</artifactId>
<version>2.42.1-SNAPSHOT</version>
<version>2.43.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-notifications-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>legend-depot</artifactId>
<groupId>org.finos.legend.depot</groupId>
<version>2.42.1-SNAPSHOT</version>
<version>2.43.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-notifications-queue-mongo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>legend-depot</artifactId>
<groupId>org.finos.legend.depot</groupId>
<version>2.42.1-SNAPSHOT</version>
<version>2.43.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-notifications-services/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>legend-depot</artifactId>
<groupId>org.finos.legend.depot</groupId>
<version>2.42.1-SNAPSHOT</version>
<version>2.43.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion legend-depot-notifications-store-mongo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>legend-depot</artifactId>
<groupId>org.finos.legend.depot</groupId>
<version>2.42.1-SNAPSHOT</version>
<version>2.43.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Loading

0 comments on commit e51ad34

Please sign in to comment.