コード例 #1
0
 @Test(priority = 3)
 public void testSearchStoreJob() throws Exception {
   // Store more jobs with the one user and search
   XJob job = getTestJob();
   long currentTime = System.currentTimeMillis();
   SchedulerJobInfo info =
       new SchedulerJobInfo(
           SchedulerJobHandle.fromString(UUID.randomUUID().toString()),
           job,
           "lens",
           SchedulerJobState.NEW,
           currentTime,
           currentTime);
   // Store the job
   schedulerDAO.storeJob(info);
   info =
       new SchedulerJobInfo(
           SchedulerJobHandle.fromString(UUID.randomUUID().toString()),
           job,
           "lens",
           SchedulerJobState.NEW,
           currentTime,
           currentTime);
   schedulerDAO.storeJob(info);
   // There should be 3 jobs till now.
   Assert.assertEquals(schedulerDAO.getJobs("lens", null, null, null).size(), 3);
   Assert.assertEquals(
       schedulerDAO.getJobs("lens", SchedulerJobState.NEW, 1L, System.currentTimeMillis()).size(),
       2);
   Assert.assertEquals(schedulerDAO.getJobs("Alice", SchedulerJobState.NEW, null, null).size(), 0);
 }
コード例 #2
0
  @Test(priority = 2)
  public void testStoreInstance() throws Exception {
    long currentTime = System.currentTimeMillis();
    SchedulerJobInstanceHandle instanceHandle = new SchedulerJobInstanceHandle(UUID.randomUUID());
    SchedulerJobInstanceInfo firstInstance =
        new SchedulerJobInstanceInfo(
            instanceHandle, jobHandle, currentTime, new ArrayList<SchedulerJobInstanceRun>());
    SchedulerJobInstanceRun run1 =
        new SchedulerJobInstanceRun(
            instanceHandle,
            1,
            new LensSessionHandle(UUID.randomUUID(), UUID.randomUUID()),
            currentTime,
            currentTime,
            "/tmp/",
            QueryHandle.fromString(UUID.randomUUID().toString()),
            SchedulerJobInstanceState.WAITING);
    instances.put(firstInstance.getId(), firstInstance);
    schedulerDAO.storeJobInstance(firstInstance);
    schedulerDAO.storeJobInstanceRun(run1);
    // Put run in the instance
    firstInstance.getInstanceRunList().add(run1);

    currentTime = System.currentTimeMillis();
    instanceHandle = new SchedulerJobInstanceHandle(UUID.randomUUID());
    SchedulerJobInstanceInfo secondInstance =
        new SchedulerJobInstanceInfo(
            instanceHandle, jobHandle, currentTime, new ArrayList<SchedulerJobInstanceRun>());
    SchedulerJobInstanceRun run2 =
        new SchedulerJobInstanceRun(
            instanceHandle,
            1,
            new LensSessionHandle(UUID.randomUUID(), UUID.randomUUID()),
            currentTime,
            currentTime,
            "/tmp/",
            QueryHandle.fromString(UUID.randomUUID().toString()),
            SchedulerJobInstanceState.WAITING);
    instances.put(secondInstance.getId(), secondInstance);
    schedulerDAO.storeJobInstance(secondInstance);
    schedulerDAO.storeJobInstanceRun(run2);
    secondInstance.getInstanceRunList().add(run2);

    List<SchedulerJobInstanceInfo> handleList = schedulerDAO.getJobInstances(jobHandle);
    // Size should be 2
    Assert.assertEquals(handleList.size(), 2);
    // Get the definition of instance from the store.
    SchedulerJobInstanceInfo instance1 = handleList.get(0);
    Assert.assertEquals(instances.get(handleList.get(0).getId()), instance1);

    SchedulerJobInstanceInfo instance2 = handleList.get(1);
    Assert.assertEquals(instances.get(handleList.get(1).getId()), instance2);
  }
コード例 #3
0
 @Test(priority = 1)
 public void testStoreJob() throws Exception {
   XJob job = getTestJob();
   long currentTime = System.currentTimeMillis();
   jobHandle = new SchedulerJobHandle(UUID.randomUUID());
   SchedulerJobInfo info =
       new SchedulerJobInfo(
           jobHandle, job, "lens", SchedulerJobState.NEW, currentTime, currentTime);
   // Store the job
   schedulerDAO.storeJob(info);
   // Retrive the stored job
   XJob outJob = schedulerDAO.getJob(info.getId());
   Assert.assertEquals(job, outJob);
 }