Search in sources :

Example 1 with ConqueryError

use of com.bakdata.conquery.models.error.ConqueryError in project conquery by bakdata.

the class ExecuteForm method react.

@Override
public void react(Worker worker) throws Exception {
    log.info("Started Form {}", formId);
    // Execution might have been cancelled before so we uncancel it here.
    final QueryExecutor queryExecutor = worker.getQueryExecutor();
    queryExecutor.unsetQueryCancelled(formId);
    // Execute all plans.
    for (Entry<ManagedExecutionId, Query> entry : queries.entrySet()) {
        final Query query = entry.getValue();
        ShardResult result = createResult(worker, entry.getKey());
        // Before we start the query, we create it once to test if it will succeed before creating it multiple times for evaluation per core.
        try {
            query.createQueryPlan(new QueryPlanContext(worker));
        } catch (Exception e) {
            ConqueryError err = asConqueryError(e);
            log.warn("Failed to create query plans for {}.", formId, err);
            queryExecutor.sendFailureToManagerNode(result, err);
            return;
        }
        final QueryExecutionContext subQueryContext = new QueryExecutionContext(formId, queryExecutor, worker.getStorage(), worker.getBucketManager());
        if (!queryExecutor.execute(query, subQueryContext, result)) {
            return;
        }
    }
}
Also used : ConqueryError.asConqueryError(com.bakdata.conquery.models.error.ConqueryError.asConqueryError) ConqueryError(com.bakdata.conquery.models.error.ConqueryError) Query(com.bakdata.conquery.apiv1.query.Query) QueryExecutionContext(com.bakdata.conquery.models.query.QueryExecutionContext) QueryExecutor(com.bakdata.conquery.models.query.QueryExecutor) ManagedExecutionId(com.bakdata.conquery.models.identifiable.ids.specific.ManagedExecutionId) FormShardResult(com.bakdata.conquery.models.query.results.FormShardResult) ShardResult(com.bakdata.conquery.models.query.results.ShardResult) QueryPlanContext(com.bakdata.conquery.models.query.QueryPlanContext)

Example 2 with ConqueryError

use of com.bakdata.conquery.models.error.ConqueryError in project conquery by bakdata.

the class ExecuteQuery method react.

@Override
public void react(Worker worker) throws Exception {
    final ManagedExecutionId executionId = id;
    log.info("Started {} {}", query.getClass().getSimpleName(), executionId);
    // Execution might have been cancelled before so we uncancel it here.
    final QueryExecutor queryExecutor = worker.getQueryExecutor();
    queryExecutor.unsetQueryCancelled(executionId);
    final ShardResult result = createShardResult(worker);
    // Before we start the query, we create it once to test if it will succeed before creating it multiple times for evaluation per core.
    try {
        query.createQueryPlan(new QueryPlanContext(worker));
    } catch (Exception e) {
        ConqueryError err = asConqueryError(e);
        log.warn("Failed to create query plans for {}.", executionId, err);
        queryExecutor.sendFailureToManagerNode(result, err);
        return;
    }
    final QueryExecutionContext executionContext = new QueryExecutionContext(executionId, queryExecutor, worker.getStorage(), worker.getBucketManager());
    queryExecutor.execute(query, executionContext, result);
}
Also used : ConqueryError.asConqueryError(com.bakdata.conquery.models.error.ConqueryError.asConqueryError) ConqueryError(com.bakdata.conquery.models.error.ConqueryError) QueryExecutionContext(com.bakdata.conquery.models.query.QueryExecutionContext) QueryExecutor(com.bakdata.conquery.models.query.QueryExecutor) ManagedExecutionId(com.bakdata.conquery.models.identifiable.ids.specific.ManagedExecutionId) ShardResult(com.bakdata.conquery.models.query.results.ShardResult) QueryPlanContext(com.bakdata.conquery.models.query.QueryPlanContext)

Example 3 with ConqueryError

use of com.bakdata.conquery.models.error.ConqueryError in project conquery by bakdata.

the class SerializationTests method executionQueryJobError.

@Test
public void executionQueryJobError() throws JSONException, IOException {
    log.info("Beware, this test will print an ERROR message.");
    ConqueryError error = new ConqueryError.ExecutionJobErrorWrapper(new Entity(5), new ConqueryError.UnknownError(null));
    SerializationTestUtil.forType(ConqueryError.class).test(error);
}
Also used : Entity(com.bakdata.conquery.models.query.entity.Entity) ConqueryError(com.bakdata.conquery.models.error.ConqueryError) Test(org.junit.jupiter.api.Test) IdMapSerialisationTest(com.bakdata.conquery.models.identifiable.IdMapSerialisationTest)

Example 4 with ConqueryError

use of com.bakdata.conquery.models.error.ConqueryError in project conquery by bakdata.

the class QueryJob method get.

@Override
public Optional<EntityResult> get() {
    if (ctx.isQueryCancelled()) {
        return Optional.empty();
    }
    try {
        QueryPlan queryPlan = plan.get();
        queryPlan.init(ctx, entity);
        return queryPlan.execute(ctx, entity);
    } catch (ConqueryError e) {
        // Catch errors, propagate them with their id.
        throw new ConqueryError.ExecutionJobErrorWrapper(entity, e);
    } catch (Exception e) {
        throw new ConqueryError.ExecutionJobErrorWrapper(entity, new ConqueryError.UnknownError(e));
    }
}
Also used : ConqueryError(com.bakdata.conquery.models.error.ConqueryError) QueryPlan(com.bakdata.conquery.models.query.queryplan.QueryPlan)

Example 5 with ConqueryError

use of com.bakdata.conquery.models.error.ConqueryError in project conquery by bakdata.

the class AdminResource method getQueries.

@GET
@Path("/queries")
public FullExecutionStatus[] getQueries(@Auth Subject currentUser, @QueryParam("limit") OptionalLong limit, @QueryParam("since") Optional<String> since) {
    final MetaStorage storage = processor.getStorage();
    final DatasetRegistry datasetRegistry = processor.getDatasetRegistry();
    return storage.getAllExecutions().stream().map(t -> {
        try {
            return t.buildStatusFull(storage, currentUser, datasetRegistry, processor.getConfig());
        } catch (ConqueryError e) {
            // Initialization of execution probably failed, so we construct a status based on the overview status
            final FullExecutionStatus fullExecutionStatus = new FullExecutionStatus();
            t.setStatusBase(currentUser, fullExecutionStatus);
            fullExecutionStatus.setStatus(ExecutionState.FAILED);
            fullExecutionStatus.setError(e);
            return fullExecutionStatus;
        }
    }).filter(t -> t.getCreatedAt().toLocalDate().isEqual(since.map(LocalDate::parse).orElse(LocalDate.now()))).limit(limit.orElse(100)).toArray(FullExecutionStatus[]::new);
}
Also used : PathParam(javax.ws.rs.PathParam) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ExecutionState(com.bakdata.conquery.models.execution.ExecutionState) JobManagerStatus(com.bakdata.conquery.models.jobs.JobManagerStatus) Path(javax.ws.rs.Path) Subject(com.bakdata.conquery.models.auth.entities.Subject) JOB_ID(com.bakdata.conquery.resources.ResourceConstants.JOB_ID) Auth(io.dropwizard.auth.Auth) NewCookie(javax.ws.rs.core.NewCookie) ContainerRequestContext(javax.ws.rs.container.ContainerRequestContext) Inject(javax.inject.Inject) OptionalLong(java.util.OptionalLong) MediaType(javax.ws.rs.core.MediaType) QueryParam(javax.ws.rs.QueryParam) Consumes(javax.ws.rs.Consumes) UriBuilder(javax.ws.rs.core.UriBuilder) AdminUIResource(com.bakdata.conquery.resources.admin.ui.AdminUIResource) POST(javax.ws.rs.POST) Context(javax.ws.rs.core.Context) ImmutableMap(com.google.common.collect.ImmutableMap) AuthenticationConfig(com.bakdata.conquery.models.config.auth.AuthenticationConfig) UUID(java.util.UUID) ConqueryError(com.bakdata.conquery.models.error.ConqueryError) ExtraMimeTypes(com.bakdata.conquery.io.jersey.ExtraMimeTypes) Objects(java.util.Objects) CancelJobMessage(com.bakdata.conquery.models.messages.network.specific.CancelJobMessage) Response(javax.ws.rs.core.Response) LocalDate(java.time.LocalDate) FullExecutionStatus(com.bakdata.conquery.apiv1.FullExecutionStatus) ShardNodeInformation(com.bakdata.conquery.models.worker.ShardNodeInformation) Optional(java.util.Optional) DatasetRegistry(com.bakdata.conquery.models.worker.DatasetRegistry) MetaStorage(com.bakdata.conquery.io.storage.MetaStorage) ConqueryError(com.bakdata.conquery.models.error.ConqueryError) MetaStorage(com.bakdata.conquery.io.storage.MetaStorage) DatasetRegistry(com.bakdata.conquery.models.worker.DatasetRegistry) FullExecutionStatus(com.bakdata.conquery.apiv1.FullExecutionStatus) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

ConqueryError (com.bakdata.conquery.models.error.ConqueryError)7 IdMapSerialisationTest (com.bakdata.conquery.models.identifiable.IdMapSerialisationTest)3 Test (org.junit.jupiter.api.Test)3 ConqueryError.asConqueryError (com.bakdata.conquery.models.error.ConqueryError.asConqueryError)2 ManagedExecutionId (com.bakdata.conquery.models.identifiable.ids.specific.ManagedExecutionId)2 QueryExecutionContext (com.bakdata.conquery.models.query.QueryExecutionContext)2 QueryExecutor (com.bakdata.conquery.models.query.QueryExecutor)2 QueryPlanContext (com.bakdata.conquery.models.query.QueryPlanContext)2 ShardResult (com.bakdata.conquery.models.query.results.ShardResult)2 FullExecutionStatus (com.bakdata.conquery.apiv1.FullExecutionStatus)1 Query (com.bakdata.conquery.apiv1.query.Query)1 ExtraMimeTypes (com.bakdata.conquery.io.jersey.ExtraMimeTypes)1 MetaStorage (com.bakdata.conquery.io.storage.MetaStorage)1 Subject (com.bakdata.conquery.models.auth.entities.Subject)1 AuthenticationConfig (com.bakdata.conquery.models.config.auth.AuthenticationConfig)1 ExecutionState (com.bakdata.conquery.models.execution.ExecutionState)1 DatasetId (com.bakdata.conquery.models.identifiable.ids.specific.DatasetId)1 JobManagerStatus (com.bakdata.conquery.models.jobs.JobManagerStatus)1 CancelJobMessage (com.bakdata.conquery.models.messages.network.specific.CancelJobMessage)1 Entity (com.bakdata.conquery.models.query.entity.Entity)1