Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

ensure initialization of ManagedExecution instead of crashing #2068

Merged
merged 3 commits into from
Sep 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -360,7 +364,7 @@ public FullExecutionStatus getQueryFullStatus(ManagedExecution<?> query, User us
query.initExecutable(datasetRegistry, config);

Map<DatasetId, Set<Ability>> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -268,8 +270,9 @@ 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) {
Preconditions.checkArgument(isInitialized(), "The execution must have been initialized first");
public FullExecutionStatus buildStatusFull(@NonNull MetaStorage storage, User user, DatasetRegistry datasetRegistry, ConqueryConfig config) {

initExecutable(datasetRegistry, config);
FullExecutionStatus status = new FullExecutionStatus();
setStatusBase(user, status);

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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("/")
Expand Down Expand Up @@ -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);
Expand Down