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

Admin ui for live view of queries #2062

Merged
merged 22 commits into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
a81fdbd
Admin UI for live view of queries
Aug 31, 2021
526f8af
Update AutoDoc
github-actions[bot] Aug 31, 2021
574b15c
Update backend/src/main/java/com/bakdata/conquery/resources/admin/res…
Njimefo Sep 1, 2021
78cc524
Merge branch 'develop' into feature/admin-queries-monitor
Sep 2, 2021
7bf0fb5
Admin UI for live view of queries adapted
Sep 2, 2021
9102f93
Update AutoDoc
github-actions[bot] Sep 2, 2021
2da1d9c
languageTag in backend removed and added in fronted
Sep 3, 2021
28180c4
Merge remote-tracking branch 'origin/feature/admin-queries-monitor' i…
Sep 3, 2021
8eac327
Update AutoDoc
github-actions[bot] Sep 3, 2021
1ae82cb
path issues resolved
Sep 3, 2021
5140d50
Merge remote-tracking branch 'origin/feature/admin-queries-monitor' i…
Sep 3, 2021
72e577a
path issues resolved
Sep 3, 2021
4d60009
Merge remote-tracking branch 'origin/develop' into feature/admin-quer…
awildturtok Sep 3, 2021
a18e986
Merge branch 'feature/admin-queries-monitor' of https://github.com/ba…
awildturtok Sep 3, 2021
83fd6f6
parameterized request of queries and reformatted html code
Sep 6, 2021
76f561b
Merge remote-tracking branch 'origin/master' into feature/admin-queri…
Sep 7, 2021
81102a2
parameterized request of queries and reformatted html code
Sep 10, 2021
36906ef
Merge remote-tracking branch 'origin/develop' into develop
Sep 10, 2021
f446429
review changes
Sep 10, 2021
0e80020
Update AutoDoc
github-actions[bot] Sep 10, 2021
3418875
updated code after code review
Sep 10, 2021
2861dec
Merge remote-tracking branch 'origin/feature/admin-queries-monitor' i…
Sep 10, 2021
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
@@ -1,11 +1,13 @@
package com.bakdata.conquery.apiv1;

import java.net.URL;
import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.util.Collections;
import java.util.List;

import com.bakdata.conquery.models.execution.ExecutionState;
import com.bakdata.conquery.models.identifiable.ids.specific.DatasetId;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wird der Import gebraucht?

import com.bakdata.conquery.models.identifiable.ids.specific.ManagedExecutionId;
import com.bakdata.conquery.models.identifiable.ids.specific.SecondaryIdDescriptionId;
import com.bakdata.conquery.models.identifiable.ids.specific.UserId;
Expand Down Expand Up @@ -38,6 +40,9 @@ public abstract class ExecutionStatus {
private Long numberOfResults;
private Long requiredTime;

private LocalDateTime startTime;
private LocalDateTime finishTime;

private String queryType;
private SecondaryIdDescriptionId secondaryId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.FieldNameConstants;
import com.bakdata.conquery.models.i18n.I18n;

import static org.apache.shiro.util.StringUtils.hasText;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sieht so aus als ob die Imports auch weg können

/**
* This status holds extensive information about the query description and meta data that is computational heavy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@ public Stream<ExecutionStatus> getQueriesFiltered(Dataset datasetId, UriBuilder
.map(mq -> {
OverviewExecutionStatus status = mq.buildStatusOverview(
uriBuilder.clone(),
user,
datasetAbilities
user
);
if (mq.isReadyToDownload(datasetAbilities)) {
setDownloadUrls(status, config.getResultProviders(), mq, uriBuilder, allProviders);
Expand Down Expand Up @@ -361,7 +360,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, url, user, datasetRegistry, datasetAbilities);
final FullExecutionStatus status = query.buildStatusFull(storage, user, datasetRegistry);

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,15 +55,13 @@
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.Uninterruptibles;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.*;
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 @@ -238,7 +236,7 @@ public void awaitDone(int time, TimeUnit unit) {
Uninterruptibles.awaitUninterruptibly(execution, time, unit);
}

protected void setStatusBase(@NonNull User user, @NonNull ExecutionStatus status, UriBuilder url, Map<DatasetId, Set<Ability>> datasetAbilities) {
protected void setStatusBase(@NonNull User user, @NonNull ExecutionStatus status) {
status.setLabel(label == null ? queryId.toString() : getLabelWithoutAutoLabelSuffix());
status.setPristineLabel(label == null || queryId.toString().equals(label) || isAutoLabeled());
status.setId(getId());
Expand All @@ -247,6 +245,8 @@ protected void setStatusBase(@NonNull User user, @NonNull ExecutionStatus status
status.setOwn(user.isOwner(this));
status.setCreatedAt(getCreationTime().atZone(ZoneId.systemDefault()));
status.setRequiredTime((startTime != null && finishTime != null) ? ChronoUnit.MILLIS.between(startTime, finishTime) : null);
status.setStartTime(startTime);
status.setFinishTime(finishTime);
status.setStatus(getState());
if (owner != null) {
status.setOwner(owner.getId());
Expand All @@ -257,9 +257,9 @@ protected void setStatusBase(@NonNull User user, @NonNull ExecutionStatus status
/**
* Renders a lightweight status with meta information about this query. Computation an size should be small for this.
*/
public OverviewExecutionStatus buildStatusOverview(UriBuilder url, User user, Map<DatasetId, Set<Ability>> datasetAbilities) {
public OverviewExecutionStatus buildStatusOverview(UriBuilder url, User user) {
OverviewExecutionStatus status = new OverviewExecutionStatus();
setStatusBase(user, status, url, datasetAbilities);
setStatusBase(user, status);

return status;
}
Expand All @@ -268,12 +268,12 @@ 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<DatasetId, Set<Ability>> datasetAbilities) {
public FullExecutionStatus buildStatusFull(@NonNull MetaStorage storage, User user, DatasetRegistry datasetRegistry) {
Preconditions.checkArgument(isInitialized(), "The execution must have been initialized first");
FullExecutionStatus status = new FullExecutionStatus();
setStatusBase(user, status, url, datasetAbilities);
setStatusBase(user, status);

setAdditionalFieldsForStatusWithColumnDescription(storage, url, user, status, datasetRegistry);
setAdditionalFieldsForStatusWithColumnDescription(storage, user, status, datasetRegistry);
setAdditionalFieldsForStatusWithSource(user, status);
setAdditionalFieldsForStatusWithGroups(storage, status);
setAvailableSecondaryIds(status);
Expand Down Expand Up @@ -313,7 +313,7 @@ private void setAdditionalFieldsForStatusWithGroups(@NonNull MetaStorage storage
status.setGroups(permittedGroups);
}

protected void setAdditionalFieldsForStatusWithColumnDescription(@NonNull MetaStorage storage, UriBuilder url, User user, FullExecutionStatus status, DatasetRegistry datasetRegistry) {
protected void setAdditionalFieldsForStatusWithColumnDescription(@NonNull MetaStorage storage, User user, FullExecutionStatus status, DatasetRegistry datasetRegistry) {
// Implementation specific
}

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

import javax.ws.rs.core.UriBuilder;

import com.bakdata.conquery.apiv1.FullExecutionStatus;
import com.bakdata.conquery.apiv1.forms.Form;
import com.bakdata.conquery.apiv1.query.QueryDescription;
Expand Down Expand Up @@ -179,8 +177,8 @@ public QueryDescription getSubmitted() {


@Override
protected void setAdditionalFieldsForStatusWithColumnDescription(@NonNull MetaStorage storage, UriBuilder url, User user, FullExecutionStatus status, DatasetRegistry datasetRegistry) {
super.setAdditionalFieldsForStatusWithColumnDescription(storage, url, user, status, datasetRegistry);
protected void setAdditionalFieldsForStatusWithColumnDescription(@NonNull MetaStorage storage, User user, FullExecutionStatus status, DatasetRegistry datasetRegistry) {
super.setAdditionalFieldsForStatusWithColumnDescription(storage, user, status, datasetRegistry);
// Set the ColumnDescription if the Form only consits of a single subquery
if (subQueries == null) {
// If subqueries was not set the Execution was not initialized, do it manually
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import javax.ws.rs.core.UriBuilder;

import c10n.C10N;
import com.bakdata.conquery.apiv1.ExecutionStatus;
import com.bakdata.conquery.apiv1.FullExecutionStatus;
Expand All @@ -27,15 +25,13 @@
import com.bakdata.conquery.io.cps.CPSType;
import com.bakdata.conquery.io.storage.MetaStorage;
import com.bakdata.conquery.models.auth.entities.User;
import com.bakdata.conquery.models.auth.permissions.Ability;
import com.bakdata.conquery.models.config.ConqueryConfig;
import com.bakdata.conquery.models.datasets.Dataset;
import com.bakdata.conquery.models.execution.ExecutionState;
import com.bakdata.conquery.models.execution.ManagedExecution;
import com.bakdata.conquery.models.externalservice.ResultType;
import com.bakdata.conquery.models.i18n.I18n;
import com.bakdata.conquery.models.identifiable.ids.NamespacedIdentifiable;
import com.bakdata.conquery.models.identifiable.ids.specific.DatasetId;
import com.bakdata.conquery.models.messages.namespaces.WorkerMessage;
import com.bakdata.conquery.models.messages.namespaces.specific.ExecuteQuery;
import com.bakdata.conquery.models.query.resultinfo.ResultInfo;
Expand Down Expand Up @@ -136,8 +132,8 @@ public void start() {
}

@Override
protected void setStatusBase(@NonNull User user, @NonNull ExecutionStatus status, UriBuilder url, Map<DatasetId, Set<Ability>> datasetAbilities) {
super.setStatusBase(user, status, url, datasetAbilities);
protected void setStatusBase(@NonNull User user, @NonNull ExecutionStatus status) {
super.setStatusBase(user, status);
status.setNumberOfResults(lastResultCount);

status.setQueryType(query.getClass().getAnnotation(CPSType.class).id());
Expand All @@ -148,8 +144,8 @@ protected void setStatusBase(@NonNull User user, @NonNull ExecutionStatus status
}

@Override
protected void setAdditionalFieldsForStatusWithColumnDescription(@NonNull MetaStorage storage, UriBuilder url, User user, FullExecutionStatus status, DatasetRegistry datasetRegistry) {
super.setAdditionalFieldsForStatusWithColumnDescription(storage, url, user, status, datasetRegistry);
protected void setAdditionalFieldsForStatusWithColumnDescription(@NonNull MetaStorage storage, User user, FullExecutionStatus status, DatasetRegistry datasetRegistry) {
super.setAdditionalFieldsForStatusWithColumnDescription(storage, user, status, datasetRegistry);
if (columnDescriptions == null) {
columnDescriptions = generateColumnDescriptions(datasetRegistry);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class ResourceConstants {
public static final String TABLE = "table";
public static final String FILTER = "filter";
public static final String QUERY = "query";
public static final String QUERIES_MONITOR_PATH_ELEMENT = "queries";
public static final String FORM_CONFIG = "form-config";
public static final String FILENAME = "filename";
public static final String API = "api";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
package com.bakdata.conquery.resources.admin.rest;

import com.bakdata.conquery.io.jackson.Jackson;
import com.bakdata.conquery.apiv1.FullExecutionStatus;
import com.bakdata.conquery.apiv1.query.ConceptQuery;
import com.bakdata.conquery.apiv1.query.Query;
import com.bakdata.conquery.apiv1.query.concept.specific.CQAnd;
import com.bakdata.conquery.apiv1.query.concept.specific.CQConcept;
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.common.Range;
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.identifiable.ids.specific.DatasetId;
import com.bakdata.conquery.models.jobs.Job;
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;
import com.bakdata.conquery.models.worker.ShardNodeInformation;
import com.bakdata.conquery.resources.admin.ui.AdminUIResource;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.collect.ImmutableMap;
import com.google.common.util.concurrent.Uninterruptibles;
import io.dropwizard.auth.Auth;

import javax.inject.Inject;
Expand All @@ -21,12 +28,14 @@
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.List;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;

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)
Expand All @@ -52,7 +61,6 @@ public String executeScript(@Auth User user, String script) {
* Execute script and serialize return value as Json.
* Useful for configuration and verification scripts.
*/
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.TEXT_PLAIN)
@POST
@Path("/script")
Expand All @@ -79,6 +87,19 @@ public Response cancelJob(@PathParam(JOB_ID) UUID jobId) {
@GET
@Path("/jobs/")
public ImmutableMap<String, JobManagerStatus> getJobs() {
return processor.getJobs();
return processor.getJobs();
}


@GET
@Path("/queries/")
public FullExecutionStatus[] getQueries(@Auth User currentUser) {
thoniTUB marked this conversation as resolved.
Show resolved Hide resolved
final MetaStorage storage = processor.getStorage();
final DatasetRegistry datasetRegistry = processor.getDatasetRegistry();
return storage.getAllExecutions().stream()
.map(t -> t.buildStatusFull(storage, currentUser, datasetRegistry))
.filter(t -> t.getCreatedAt().toLocalDate().equals(LocalDate.now(t.getCreatedAt().getZone())))
thoniTUB marked this conversation as resolved.
Show resolved Hide resolved
.limit(100)
.toArray(FullExecutionStatus[]::new);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ public ImportStatistics getImportStatistics(Import imp) {
return new ImportStatistics(imp, cBlockSize);
}


public static long calculateCBlocksSizeBytes(Import imp, Collection<? extends Concept<?>> concepts) {

// CBlocks are created per (per Bucket) Import per Connector targeting this table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,10 @@ public View getJobs() {
return new UIView<>("jobs.html.ftl", uiProcessor.getUIContext(), uiProcessor.getAdminProcessor().getJobs());
}

@GET
@Path("queries")
public View getQueries() {
return new UIView<>("queries.html.ftl", uiProcessor.getUIContext());
}

}
Loading