com.enioka.jqm.api.Query.run()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(113)

本文整理了Java中com.enioka.jqm.api.Query.run方法的一些代码示例,展示了Query.run的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.run方法的具体详情如下:
包路径:com.enioka.jqm.api.Query
类名称:Query
方法名:run

Query.run介绍

[英]The end of the fluent Query API. It simply executes the query and returns the results.
[中]fluent查询API的结尾。它只是执行查询并返回结果。

代码示例

代码示例来源:origin: com.enioka.jqm/jqm-tst

/**
 * Helper query (directly uses {@link Query}). Gives the count of all ended (KO and OK) job instances.
 */
public int getHistoryAllCount()
{
  return Query.create().run().size();
}

代码示例来源:origin: enioka/jqm

/**
 * Helper query (directly uses {@link Query}). Gives the count of all ended (KO and OK) job instances.
 */
public int getHistoryAllCount()
{
  return Query.create().run().size();
}

代码示例来源:origin: com.enioka.jqm/jqm-tst

/**
 * Helper query (directly uses {@link Query}). Gives the count of all OK-ended job instances.
 */
public int getOkCount()
{
  return Query.create().addStatusFilter(State.ENDED).run().size();
}

代码示例来源:origin: enioka/jqm

/**
 * Helper query (directly uses {@link Query}). Gives the count of all OK-ended job instances.
 */
public int getOkCount()
{
  return Query.create().addStatusFilter(State.ENDED).run().size();
}

代码示例来源:origin: com.enioka.jqm/jqm-tst

/**
 * Helper query (directly uses {@link Query}). Gives the count of all non-ended (waiting in queue, running...) job instances.
 */
public int getQueueAllCount()
{
  return Query.create().setQueryHistoryInstances(false).setQueryLiveInstances(true).run().size();
}

代码示例来源:origin: com.enioka.jqm/jqm-tst

/**
 * Helper query (directly uses {@link Query}). Gives the count of all non-OK-ended job instances.
 */
public int getNonOkCount()
{
  return Query.create().addStatusFilter(State.CRASHED).addStatusFilter(State.KILLED).run().size();
}

代码示例来源:origin: enioka/jqm

/**
 * Helper query (directly uses {@link Query}). Gives the count of all non-ended (waiting in queue, running...) job instances.
 */
public int getQueueAllCount()
{
  return Query.create().setQueryHistoryInstances(false).setQueryLiveInstances(true).run().size();
}

代码示例来源:origin: enioka/jqm

/**
 * Helper query (directly uses {@link Query}). Gives the count of all non-OK-ended job instances.
 */
public int getNonOkCount()
{
  return Query.create().addStatusFilter(State.CRASHED).addStatusFilter(State.KILLED).run().size();
}

代码示例来源:origin: enioka/jqm

@Override
public List<com.enioka.jqm.api.JobInstance> getJobs()
{
  return Query.create().setQueryHistoryInstances(true).setQueryLiveInstances(true).run();
}

代码示例来源:origin: enioka/jqm

@Override
public List<com.enioka.jqm.api.JobInstance> getActiveJobs()
{
  return Query.create().setQueryHistoryInstances(false).setQueryLiveInstances(true).addSortAsc(Sort.ID).run();
}

代码示例来源:origin: enioka/jqm

@Override
public List<com.enioka.jqm.api.JobInstance> getUserActiveJobs(String user)
{
  if (user == null || user.isEmpty())
  {
    throw new JqmInvalidRequestException("user cannot be null or empty");
  }
  return Query.create().setUser(user).setQueryHistoryInstances(false).setQueryLiveInstances(true).addSortAsc(Sort.ID).run();
}

代码示例来源:origin: enioka/jqm

protected void displayAllHistoryTable()
  {
    java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("HH:mm:ss.SSS");
    jqmlogger.debug("==========================================================================================");
    for (JobInstance h : Query.create().run())
    {
      jqmlogger.debug("JobInstance Id: " + h.getId() + " | " + h.getState() + " | JD: " + h.getApplicationName() + " | "
          + h.getQueueName() + " | enqueue: " + format.format(h.getEnqueueDate().getTime()) + " | exec: "
          + (h.getBeganRunningDate() != null ? format.format(h.getBeganRunningDate().getTime()) : null) + " | end: "
          + (h.getEndDate() != null ? format.format(h.getEndDate().getTime()) : null));
    }
    jqmlogger.debug("==========================================================================================");
  }
}

代码示例来源:origin: enioka/jqm

@Test
public void testSendProgress() throws Exception
{
  JqmSimpleTest.create(cnx, "pyl.EngineApiProgress").addWaitMargin(10000).run(this);
  List<JobInstance> res = Query.create().run();
  Assert.assertEquals((Integer) 50, res.get(0).getProgress());
}

代码示例来源:origin: enioka/jqm

/**
 * A parent job can wait for all its children - then its end date should be after the end date of the children.
 */
@Test
public void testWaitChildren() throws Exception
{
  JqmSimpleTest.create(cnx, "pyl.EngineApiWaitAll").expectOk(6).run(this);
  List<JobInstance> jj = Query.create().addSortAsc(Sort.ID).addStatusFilter(State.ENDED).run();
  Calendar parentEnd = jj.get(0).getEndDate();
  for (int i = 1; i < 6; i++)
  {
    Assert.assertTrue(parentEnd.after(jj.get(i).getEndDate()));
  }
}

代码示例来源:origin: enioka/jqm

@Test
public void testKillJob() throws Exception
{
  int i = JqmSimpleTest.create(cnx, "pyl.KillMe").expectOk(0).addWaitTime(3000).run(this);
  JqmClientFactory.getClient().killJob(i);
  TestHelpers.waitFor(1, 3000, cnx);
  List<JobInstance> res = Query.create().run();
  Assert.assertEquals(1, res.size());
  Assert.assertEquals(State.CRASHED, res.get(0).getState());
}

代码示例来源:origin: enioka/jqm

@Test
public void testMainTypeInject() throws Exception
{
  JqmSimpleTest.create(cnx, "pyl.EngineApiInject").setSessionId("123X").expectOk(3).run(this);
  Assert.assertEquals(3, (int) cnx.runSelectSingle("message_select_count_all", Integer.class));
  Assert.assertEquals(100, (int) Query.create().run().get(0).getProgress());
}

代码示例来源:origin: enioka/jqm

@Test
public void testRunnableInject() throws Exception
{
  JqmSimpleTest.create(cnx, "pyl.EngineApiInjectThread").expectOk(3).run(this);
  Assert.assertEquals(3, (int) cnx.runSelectSingle("message_select_count_all", Integer.class));
  Assert.assertEquals(100, (int) Query.create().addSortAsc(Sort.ID).run().get(0).getProgress());
}

代码示例来源:origin: enioka/jqm

@Test
public void testChangeQueue() throws Exception
{
  CreationTools.createJobDef(null, true, "App", null, "jqm-tests/jqm-test-datetimemaven/target/test.jar", TestHelpers.qVip, 42,
      "MarsuApplication", null, "Franquin", "ModuleMachin", "other", "other", false, cnx);
  int i = JobRequest.create("MarsuApplication", "TestUser").submit();
  JqmClientFactory.getClient().setJobQueue(i, TestHelpers.qSlow);
  addAndStartEngine();
  TestHelpers.waitFor(1, 10000, cnx);
  List<JobInstance> res = Query.create().addSortAsc(Sort.DATEENQUEUE).run();
  Assert.assertEquals(1, res.size());
  Assert.assertEquals(State.ENDED, res.get(0).getState());
  Assert.assertEquals("SlowQueue", res.get(0).getQueue().getName());
}

代码示例来源:origin: enioka/jqm

@Test
public void testCancelJob() throws Exception
{
  CreationTools.createJobDef(null, true, "App", null, "jqm-tests/jqm-test-datetimemaven/target/test.jar", TestHelpers.qVip, 42,
      "MarsuApplication", null, "Franquin", "ModuleMachin", "other", "other", false, cnx);
  int i = JobRequest.create("MarsuApplication", "TestUser").submit();
  JqmClientFactory.getClient().cancelJob(i);
  JobRequest.create("MarsuApplication", "TestUser").submit();
  addAndStartEngine();
  TestHelpers.waitFor(2, 5000, cnx);
  List<JobInstance> res = Query.create().addSortAsc(Sort.DATEENQUEUE).run();
  Assert.assertEquals(2, res.size());
  Assert.assertEquals(State.CANCELLED, res.get(0).getState());
  Assert.assertEquals(State.ENDED, res.get(1).getState());
}

代码示例来源:origin: enioka/jqm

@Test
public void testDisabledPayload() throws Exception
{
  int jd = CreationTools.createJobDef(null, true, "App", null, "jqm-tests/jqm-test-datetimemaven/target/test.jar", TestHelpers.qVip,
      42, "MarsuApplication", null, "Franquin", "ModuleMachin", "other", "other", true, cnx);
  cnx.runUpdate("jd_update_set_enabled_by_id", false, jd);
  cnx.commit();
  JobRequest.create("MarsuApplication", "TestUser").submit();
  addAndStartEngine();
  TestHelpers.waitFor(1, 10000, cnx);
  Assert.assertEquals(1, TestHelpers.getOkCount(cnx));
  Assert.assertEquals(0, TestHelpers.getNonOkCount(cnx));
  Assert.assertEquals(-1, (int) Query.create().run().get(0).getProgress());
}

相关文章