From c31586d01947c0e3b2c5da587528801341f46013 Mon Sep 17 00:00:00 2001 From: Fabian Kovacs <1553491+awildturtok@users.noreply.github.com> Date: Fri, 3 Sep 2021 15:06:08 +0200 Subject: [PATCH 1/2] ensure initialization instead of crashing --- .../java/com/bakdata/conquery/apiv1/QueryProcessor.java | 8 ++++++-- .../conquery/models/execution/ManagedExecution.java | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/com/bakdata/conquery/apiv1/QueryProcessor.java b/backend/src/main/java/com/bakdata/conquery/apiv1/QueryProcessor.java index 42266a5558..9037b201f3 100644 --- a/backend/src/main/java/com/bakdata/conquery/apiv1/QueryProcessor.java +++ b/backend/src/main/java/com/bakdata/conquery/apiv1/QueryProcessor.java @@ -3,7 +3,11 @@ import static com.bakdata.conquery.models.auth.AuthorizationHelper.buildDatasetAbilityMap; import java.net.URL; -import java.util.*; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; import java.util.function.Consumer; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -361,7 +365,7 @@ public FullExecutionStatus getQueryFullStatus(ManagedExecution query, User us query.initExecutable(datasetRegistry, config); Map> datasetAbilities = buildDatasetAbilityMap(user, datasetRegistry); - final FullExecutionStatus status = query.buildStatusFull(storage, url, user, datasetRegistry, datasetAbilities); + final FullExecutionStatus status = query.buildStatusFull(storage, url, user, datasetRegistry, datasetAbilities, config); if (query.isReadyToDownload(datasetAbilities)) { setDownloadUrls(status, config.getResultProviders(), query, url, allProviders); diff --git a/backend/src/main/java/com/bakdata/conquery/models/execution/ManagedExecution.java b/backend/src/main/java/com/bakdata/conquery/models/execution/ManagedExecution.java index 5780e68751..e3e9e02cd7 100644 --- a/backend/src/main/java/com/bakdata/conquery/models/execution/ManagedExecution.java +++ b/backend/src/main/java/com/bakdata/conquery/models/execution/ManagedExecution.java @@ -268,8 +268,10 @@ public OverviewExecutionStatus buildStatusOverview(UriBuilder url, User user, Ma * Renders an extensive status of this query (see {@link FullExecutionStatus}. The rendering can be computation intensive and can produce a large * object. The use of the full status is only intended if a client requested specific information about this execution. */ - public FullExecutionStatus buildStatusFull(@NonNull MetaStorage storage, UriBuilder url, User user, DatasetRegistry datasetRegistry, Map> datasetAbilities) { - Preconditions.checkArgument(isInitialized(), "The execution must have been initialized first"); + public FullExecutionStatus buildStatusFull(@NonNull MetaStorage storage, UriBuilder url, User user, DatasetRegistry datasetRegistry, Map> datasetAbilities, ConqueryConfig config) { + + initExecutable(datasetRegistry, config); + FullExecutionStatus status = new FullExecutionStatus(); setStatusBase(user, status, url, datasetAbilities); From 09fedbc94cf8b9a14793ee7e4b69b6858f5579f1 Mon Sep 17 00:00:00 2001 From: Fabian Kovacs <1553491+awildturtok@users.noreply.github.com> Date: Mon, 20 Sep 2021 11:49:25 +0200 Subject: [PATCH 2/2] put back config that was dropped earlier --- .../conquery/apiv1/QueryProcessor.java | 2 +- .../models/execution/ManagedExecution.java | 10 +++-- .../resources/admin/rest/AdminResource.java | 44 +++++++++---------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/backend/src/main/java/com/bakdata/conquery/apiv1/QueryProcessor.java b/backend/src/main/java/com/bakdata/conquery/apiv1/QueryProcessor.java index fcf688d16d..5e43bc644a 100644 --- a/backend/src/main/java/com/bakdata/conquery/apiv1/QueryProcessor.java +++ b/backend/src/main/java/com/bakdata/conquery/apiv1/QueryProcessor.java @@ -364,7 +364,7 @@ public FullExecutionStatus getQueryFullStatus(ManagedExecution query, User us query.initExecutable(datasetRegistry, config); Map> datasetAbilities = buildDatasetAbilityMap(user, datasetRegistry); - final FullExecutionStatus status = query.buildStatusFull(storage, user, datasetRegistry); + final FullExecutionStatus status = query.buildStatusFull(storage, user, datasetRegistry, config); if (query.isReadyToDownload(datasetAbilities)) { setDownloadUrls(status, config.getResultProviders(), query, url, allProviders); diff --git a/backend/src/main/java/com/bakdata/conquery/models/execution/ManagedExecution.java b/backend/src/main/java/com/bakdata/conquery/models/execution/ManagedExecution.java index 370538da43..90327a0577 100644 --- a/backend/src/main/java/com/bakdata/conquery/models/execution/ManagedExecution.java +++ b/backend/src/main/java/com/bakdata/conquery/models/execution/ManagedExecution.java @@ -55,13 +55,15 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.google.common.base.Preconditions; import com.google.common.util.concurrent.Uninterruptibles; -import lombok.*; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.Setter; +import lombok.ToString; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ArrayUtils; import org.apache.shiro.authz.Permission; -import static org.apache.shiro.util.StringUtils.hasText; - @Getter @Setter @ToString @@ -268,7 +270,7 @@ public OverviewExecutionStatus buildStatusOverview(UriBuilder url, User user) { * Renders an extensive status of this query (see {@link FullExecutionStatus}. The rendering can be computation intensive and can produce a large * object. The use of the full status is only intended if a client requested specific information about this execution. */ - public FullExecutionStatus buildStatusFull(@NonNull MetaStorage storage, User user, DatasetRegistry datasetRegistry) { + public FullExecutionStatus buildStatusFull(@NonNull MetaStorage storage, User user, DatasetRegistry datasetRegistry, ConqueryConfig config) { initExecutable(datasetRegistry, config); FullExecutionStatus status = new FullExecutionStatus(); diff --git a/backend/src/main/java/com/bakdata/conquery/resources/admin/rest/AdminResource.java b/backend/src/main/java/com/bakdata/conquery/resources/admin/rest/AdminResource.java index 20ac72e5cd..e0af8d4679 100644 --- a/backend/src/main/java/com/bakdata/conquery/resources/admin/rest/AdminResource.java +++ b/backend/src/main/java/com/bakdata/conquery/resources/admin/rest/AdminResource.java @@ -1,18 +1,30 @@ package com.bakdata.conquery.resources.admin.rest; +import static com.bakdata.conquery.resources.ResourceConstants.JOB_ID; + +import java.time.LocalDate; +import java.util.Objects; +import java.util.Optional; +import java.util.OptionalLong; +import java.util.UUID; + +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriBuilder; + import com.bakdata.conquery.apiv1.FullExecutionStatus; -import com.bakdata.conquery.io.jackson.Jackson; import com.bakdata.conquery.io.jersey.ExtraMimeTypes; import com.bakdata.conquery.io.storage.MetaStorage; import com.bakdata.conquery.models.auth.entities.User; -import com.bakdata.conquery.models.error.ConqueryError; -import com.bakdata.conquery.models.execution.ExecutionState; -import com.bakdata.conquery.models.execution.ManagedExecution; -import com.bakdata.conquery.models.i18n.I18n; -import com.bakdata.conquery.models.common.Range; import com.bakdata.conquery.models.config.auth.AuthenticationConfig; -import com.bakdata.conquery.models.identifiable.ids.specific.DatasetId; -import com.bakdata.conquery.models.identifiable.ids.specific.ManagedExecutionId; import com.bakdata.conquery.models.jobs.JobManagerStatus; import com.bakdata.conquery.models.messages.network.specific.CancelJobMessage; import com.bakdata.conquery.models.worker.DatasetRegistry; @@ -21,20 +33,6 @@ import com.google.common.collect.ImmutableMap; import io.dropwizard.auth.Auth; -import javax.inject.Inject; -import javax.ws.rs.*; -import javax.ws.rs.core.Cookie; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriBuilder; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.ZonedDateTime; -import java.util.*; - -import static com.bakdata.conquery.resources.ResourceConstants.JOB_ID; -import static org.apache.shiro.util.StringUtils.hasText; - @Consumes({ExtraMimeTypes.JSON_STRING, ExtraMimeTypes.SMILE_STRING}) @Produces(ExtraMimeTypes.JSON_STRING) @Path("/") @@ -101,7 +99,7 @@ public FullExecutionStatus[] getQueries(@Auth User currentUser, @QueryParam("lim final MetaStorage storage = processor.getStorage(); final DatasetRegistry datasetRegistry = processor.getDatasetRegistry(); return storage.getAllExecutions().stream() - .map(t -> t.buildStatusFull(storage, currentUser, datasetRegistry)) + .map(t -> t.buildStatusFull(storage, currentUser, datasetRegistry, processor.getConfig())) .filter(t -> t.getCreatedAt().toLocalDate().isEqual(since.map(LocalDate::parse).orElse(LocalDate.now()))) .limit(limit.orElse(100)) .toArray(FullExecutionStatus[]::new);