Package org.apache.aurora.gen

Examples of org.apache.aurora.gen.TaskQuery


   * @param query Query to extract the keys from.
   * @return A present if keys can be extracted, absent otherwise.
   */
  public static Optional<Set<IJobKey>> from(Query.Builder query) {
    if (Query.isJobScoped(query)) {
      TaskQuery taskQuery = query.get();
      ImmutableSet.Builder<IJobKey> builder = ImmutableSet.builder();

      if (taskQuery.isSetJobName()) {
        builder.add(from(
            taskQuery.getOwner().getRole(),
            taskQuery.getEnvironment(),
            taskQuery.getJobName()));
      }

      if (taskQuery.isSetJobKeys()) {
        builder.addAll(IJobKey.setFromBuilders(taskQuery.getJobKeys()));
      }
      return Optional.of(assertValid(builder.build()));
    } else {
      return Optional.absent();
    }
View Full Code Here


   */
  public static final class Builder implements Supplier<TaskQuery> {
    private final TaskQuery query;

    Builder() {
      this.query = new TaskQuery();
    }
View Full Code Here

   * @param query Query to extract the keys from.
   * @return A present if keys can be extracted, absent otherwise.
   */
  public static Optional<Set<IJobKey>> from(Query.Builder query) {
    if (Query.isJobScoped(query)) {
      TaskQuery taskQuery = query.get();
      ImmutableSet.Builder<IJobKey> builder = ImmutableSet.builder();

      if (taskQuery.isSetJobName()) {
        builder.add(from(
            taskQuery.getRole(),
            taskQuery.getEnvironment(),
            taskQuery.getJobName()));
      }

      if (taskQuery.isSetJobKeys()) {
        builder.addAll(IJobKey.setFromBuilders(taskQuery.getJobKeys()));
      }
      return Optional.of(assertValid(builder.build()));
    } else {
      return Optional.absent();
    }
View Full Code Here

   *
   * @param taskQuery Query to test.
   * @return {@code true} if the query specifies at least one job key, otherwise {@code false}.
   */
  public static boolean isJobScoped(Builder taskQuery) {
    TaskQuery q = taskQuery.get();
    return q.isSetRole() && q.isSetEnvironment() && q.isSetJobName() || q.isSetJobKeys();
  }
View Full Code Here

    assertResponse(AUTH_FAILED, thrift.killTasks(query.get(), DEFAULT_LOCK, SESSION));
  }

  @Test
  public void testKillTasksInvalidJobName() throws Exception {
    TaskQuery query = new TaskQuery()
        .setOwner(ROLE_IDENTITY)
        .setJobName("");

    control.replay();
View Full Code Here

  @Test
  public void testKillCronAuthenticatesQueryJobKeyRole() throws Exception {
    expectAuth(ROOT, false);
    IJobKey key = JobKeys.from("role", "env", "job");

    Query.Builder query = Query.arbitrary(new TaskQuery().setJobKeys(
        ImmutableSet.of(key.newBuilder())));

    storageUtil.expectTaskFetch(query.active());
    expectAuth(ImmutableSet.of("role"), true);
    expect(cronJobManager.deleteJob(key)).andReturn(true);
View Full Code Here

        ImmutableSet.<JobConfiguration>builder().addAll(crons).add(immediateJob).build();
    assertEquals(allJobs, thrift.getJobs(null).getResult().getGetJobsResult().getConfigs());
  }

  private TaskQuery setupPaginatedQuery(Iterable<IScheduledTask> tasks, int offset, int limit) {
    TaskQuery query = new TaskQuery().setOffset(offset).setLimit(limit);
    Builder builder = Query.arbitrary(query);
    storageUtil.expectTaskFetch(builder, ImmutableSet.copyOf(tasks));
    return query;
  }
View Full Code Here

  @Test
  public void testGetTasksStatusPagination() throws Exception {
    Iterable<IScheduledTask> tasks = makeDefaultScheduledTasks(10);

    TaskQuery page1Query = setupPaginatedQuery(tasks, 0, 4);
    TaskQuery page2Query = setupPaginatedQuery(tasks, 4, 4);
    TaskQuery page3Query = setupPaginatedQuery(tasks, 8, 4);

    control.replay();

    Response page1Response = assertOkResponse(thrift.getTasksStatus(page1Query));
    Response page2Response = assertOkResponse(thrift.getTasksStatus(page2Query));
View Full Code Here

    storageUtil.expectTaskFetch(query, ImmutableSet.copyOf(tasks));

    control.replay();

    ImmutableList<ScheduledTask> expected = IScheduledTask.toBuildersList(tasks);
    Response response = assertOkResponse(thrift.getTasksStatus(new TaskQuery()));
    assertEquals(expected, response.getResult().getScheduleStatusResult().getTasks());
  }
View Full Code Here

    ImmutableList<ScheduledTask> expected = IScheduledTask.toBuildersList(makeDefaultScheduledTasks(
        10,
        defaultTask(true).setExecutorConfig(null)));

    Response response = assertOkResponse(thrift.getTasksWithoutConfigs(new TaskQuery()));
    assertEquals(expected, response.getResult().getScheduleStatusResult().getTasks());
  }
View Full Code Here

TOP

Related Classes of org.apache.aurora.gen.TaskQuery

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.