Search in sources :

Example 6 with ManagedExecutionId

use of com.bakdata.conquery.models.identifiable.ids.specific.ManagedExecutionId 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 7 with ManagedExecutionId

use of com.bakdata.conquery.models.identifiable.ids.specific.ManagedExecutionId 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 8 with ManagedExecutionId

use of com.bakdata.conquery.models.identifiable.ids.specific.ManagedExecutionId in project conquery by bakdata.

the class SerializationTests method user.

/*
	 * Only way to add permission without a storage.
	 */
@Test
public void user() throws IOException, JSONException {
    User user = new User("user", "user", STORAGE);
    user.addPermission(DatasetPermission.onInstance(Ability.READ, new DatasetId("test")));
    user.addPermission(ExecutionPermission.onInstance(Ability.READ, new ManagedExecutionId(new DatasetId("dataset"), UUID.randomUUID())));
    Role role = new Role("company", "company", STORAGE);
    user.addRole(role);
    CentralRegistry registry = new CentralRegistry();
    registry.register(role);
    SerializationTestUtil.forType(User.class).registry(registry).injectables(STORAGE).test(user);
}
Also used : Role(com.bakdata.conquery.models.auth.entities.Role) User(com.bakdata.conquery.models.auth.entities.User) ManagedExecutionId(com.bakdata.conquery.models.identifiable.ids.specific.ManagedExecutionId) CentralRegistry(com.bakdata.conquery.models.identifiable.CentralRegistry) DatasetId(com.bakdata.conquery.models.identifiable.ids.specific.DatasetId) Test(org.junit.jupiter.api.Test) IdMapSerialisationTest(com.bakdata.conquery.models.identifiable.IdMapSerialisationTest)

Example 9 with ManagedExecutionId

use of com.bakdata.conquery.models.identifiable.ids.specific.ManagedExecutionId in project conquery by bakdata.

the class InstancePermissionImplificationTest method permissionTypesFail.

@Test
public void permissionTypesFail() {
    Permission dPerm = DatasetPermission.onInstance(Ability.READ.asSet(), new DatasetId(DATASET1));
    Permission qPerm = ExecutionPermission.onInstance(Ability.READ.asSet(), new ManagedExecutionId(new DatasetId(DATASET1), UUID.randomUUID()));
    Permission sPerm = SuperPermission.onDomain();
    Permission aPerm = AdminPermission.onDomain();
    assertThat(dPerm.implies(qPerm)).isFalse();
    assertThat(dPerm.implies(sPerm)).isFalse();
    assertThat(aPerm.implies(sPerm)).isFalse();
}
Also used : SuperPermission(com.bakdata.conquery.models.auth.permissions.SuperPermission) DatasetPermission(com.bakdata.conquery.models.auth.permissions.DatasetPermission) ExecutionPermission(com.bakdata.conquery.models.auth.permissions.ExecutionPermission) Permission(org.apache.shiro.authz.Permission) AdminPermission(com.bakdata.conquery.models.auth.permissions.AdminPermission) ManagedExecutionId(com.bakdata.conquery.models.identifiable.ids.specific.ManagedExecutionId) DatasetId(com.bakdata.conquery.models.identifiable.ids.specific.DatasetId) Test(org.junit.jupiter.api.Test)

Example 10 with ManagedExecutionId

use of com.bakdata.conquery.models.identifiable.ids.specific.ManagedExecutionId in project conquery by bakdata.

the class SerializationTests method group.

@Test
public void group() throws IOException, JSONException {
    Group group = new Group("group", "group", STORAGE);
    group.addPermission(DatasetPermission.onInstance(Ability.READ, new DatasetId("test")));
    group.addPermission(ExecutionPermission.onInstance(Ability.READ, new ManagedExecutionId(new DatasetId("dataset"), UUID.randomUUID())));
    group.addRole(new Role("company", "company", STORAGE));
    Role role = new Role("company", "company", STORAGE);
    group.addRole(role);
    User user = new User("userName", "userLabel", STORAGE);
    group.addMember(user);
    CentralRegistry registry = new CentralRegistry();
    registry.register(role);
    registry.register(user);
    SerializationTestUtil.forType(Group.class).injectables(STORAGE).registry(registry).test(group);
}
Also used : Role(com.bakdata.conquery.models.auth.entities.Role) Group(com.bakdata.conquery.models.auth.entities.Group) User(com.bakdata.conquery.models.auth.entities.User) ManagedExecutionId(com.bakdata.conquery.models.identifiable.ids.specific.ManagedExecutionId) CentralRegistry(com.bakdata.conquery.models.identifiable.CentralRegistry) DatasetId(com.bakdata.conquery.models.identifiable.ids.specific.DatasetId) Test(org.junit.jupiter.api.Test) IdMapSerialisationTest(com.bakdata.conquery.models.identifiable.IdMapSerialisationTest)

Aggregations

ManagedExecutionId (com.bakdata.conquery.models.identifiable.ids.specific.ManagedExecutionId)13 User (com.bakdata.conquery.models.auth.entities.User)6 Dataset (com.bakdata.conquery.models.datasets.Dataset)4 DatasetId (com.bakdata.conquery.models.identifiable.ids.specific.DatasetId)4 ManagedQuery (com.bakdata.conquery.models.query.ManagedQuery)4 Query (com.bakdata.conquery.apiv1.query.Query)3 MetaStorage (com.bakdata.conquery.io.storage.MetaStorage)3 Group (com.bakdata.conquery.models.auth.entities.Group)3 Role (com.bakdata.conquery.models.auth.entities.Role)3 Test (org.junit.jupiter.api.Test)3 ConceptQuery (com.bakdata.conquery.apiv1.query.ConceptQuery)2 SecondaryIdQuery (com.bakdata.conquery.apiv1.query.SecondaryIdQuery)2 CQAnd (com.bakdata.conquery.apiv1.query.concept.specific.CQAnd)2 ExecutionPermission (com.bakdata.conquery.models.auth.permissions.ExecutionPermission)2 ConqueryError (com.bakdata.conquery.models.error.ConqueryError)2 ConqueryError.asConqueryError (com.bakdata.conquery.models.error.ConqueryError.asConqueryError)2 CentralRegistry (com.bakdata.conquery.models.identifiable.CentralRegistry)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