本文整理了Java中com.enioka.jqm.api.Query
类的一些代码示例,展示了Query
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query
类的具体详情如下:
包路径:com.enioka.jqm.api.Query
类名称:Query
[英]Parameters for querying JobInstances. A null parameter (the default for most query parameters) is ignored in the query. To query a null String, specify "" (empty String). To query a null Integer, specify -1. It is not possible to query for null Calendar values, since it is far more efficient to query by status (the different Calendar fields are only null at certain statuses).
See individual setters for the signification of query parameters.
By default, i.e. by simply using Query.create().run()
, the API retrieves the first 50 instances that have ended, ordered by launch ID (i.e. by time). See Query#setQueryLiveInstances(boolean) for details and how to retrieve living instances in addition to ended ones.
Also please note that queries get more expensive with the result count, so it is strongly recommended to use pagination ( #setFirstRow(Integer) and #setPageSize(Integer)).
[中]用于查询作业实例的参数。在查询中忽略空参数(大多数查询参数的默认值)。要查询空字符串,请指定“”(空字符串)。要查询空整数,请指定-1。不可能查询空的日历值,因为按状态查询要高效得多(不同的日历字段仅在某些状态下为空)。
有关查询参数的含义,请参见单个设置器。
默认情况下,即通过简单地使用Query.create().run()
,API检索已结束的前50个实例,按启动ID(即按时间)排序。有关详细信息,以及如何检索活动实例和结束实例,请参见查询#setQueryLiveInstances(布尔值)。
另外请注意,查询的结果计数会增加开销,因此强烈建议使用分页(#setFirstRow(整数)和#setPageSize(整数))。
代码示例来源:origin: enioka/jqm
@Override
public List<com.enioka.jqm.api.JobInstance> getActiveJobs()
{
return Query.create().setQueryHistoryInstances(false).setQueryLiveInstances(true).addSortAsc(Sort.ID).run();
}
代码示例来源: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
@Override
public List<JobInstance> getJobs(Query query)
{
try
{
Query res = target.path("ji/query").request().post(Entity.entity(query, MediaType.APPLICATION_XML), Query.class);
query.setResultSize(res.getResultSize());
query.setResults(res.getResults());
return query.getResults();
}
catch (BadRequestException e)
{
throw new JqmInvalidRequestException(e.getResponse().readEntity(String.class), e);
}
catch (Exception e)
{
throw new JqmClientException(e);
}
}
代码示例来源: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
if ((query.getFirstRow() != null || query.getPageSize() != null) && query.isQueryLiveInstances() && query.isQueryHistoryInstances())
if (query.isQueryLiveInstances() && query.isQueryHistoryInstances() && query.getSorts().size() > 0)
if (!query.isQueryHistoryInstances() && !query.isQueryLiveInstances())
if (query.isQueryLiveInstances())
wh += getIntPredicate("ji.ID", query.getJobInstanceId(), prms);
wh += getIntPredicate("ji.PARENT", query.getParentId(), prms);
wh += getStringPredicate("ji.APPLICATION", query.getInstanceApplication(), prms);
wh += getStringPredicate("ji.MODULE", query.getInstanceModule(), prms);
wh += getStringPredicate("ji.KEYWORD1", query.getInstanceKeyword1(), prms);
wh += getStringPredicate("ji.KEYWORD2", query.getInstanceKeyword2(), prms);
wh += getStringPredicate("ji.KEYWORD3", query.getInstanceKeyword3(), prms);
wh += getStringPredicate("ji.USERNAME", query.getUser(), prms);
wh += getStringPredicate("ji.SESSION_KEY", query.getSessionId(), prms);
wh += getStatusPredicate("ji.STATUS", query.getStatus(), prms);
wh += getStringPredicate("jd.JD_KEY", query.getApplicationName(), prms);
wh += getStringPredicate("jd.APPLICATION", query.getJobDefApplication(), prms);
wh += getStringPredicate("jd.MODULE", query.getJobDefModule(), prms);
wh += getStringPredicate("jd.KEYWORD1", query.getJobDefKeyword1(), prms);
wh += getStringPredicate("jd.KEYWORD2", query.getJobDefKeyword2(), prms);
wh += getStringPredicate("jd.KEYWORD3", query.getJobDefKeyword3(), prms);
wh += getStringPredicate("n.NAME", query.getNodeName(), prms);
wh += getStringPredicate("q.NAME", query.getQueueName(), prms);
代码示例来源:origin: com.enioka.jqm/jqm-tst
/**
* Version of {@link JqmClient#getDeliverableContent(Deliverable)} which does not require the web service APIs to be enabled to work.
* Also, returned files do not self-destruct on stream close.<br>
* See the javadoc of the original method for details.
*
* @throws FileNotFoundException
*/
public InputStream getDeliverableContent(Deliverable file) throws FileNotFoundException
{
List<com.enioka.jqm.model.Deliverable> dd = com.enioka.jqm.model.Deliverable.select(cnx, "deliverable_select_by_id", file.getId());
if (dd.isEmpty())
{
throw new JqmInvalidRequestException("no deliverable with this ID");
}
com.enioka.jqm.model.Deliverable d = dd.get(0);
JobInstance ji = Query.create().setJobInstanceId(d.getJobId()).run().get(0);
String nodeName = ji.getNodeName();
Node n = nodes.get(nodeName);
return new FileInputStream(FilenameUtils.concat(n.getDlRepo(), file.getFilePath()));
}
}
代码示例来源: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: com.enioka.jqm/jqm-engine
@Override
public void waitChildren()
{
JqmClient c = getJqmClient();
Query q = Query.create().setQueryHistoryInstances(false).setQueryLiveInstances(true).setParentId(ji.getId());
while (!c.getJobs(q).isEmpty())
{
try
{
Thread.sleep(1000);
handleInstructions();
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
break;
}
}
}
代码示例来源:origin: enioka/jqm
@Test // Commented - waiting for one minute is long.
public void testDelayedJob()
{
CreationTools.createJobDef(null, true, "pyl.EngineApiSendMsg", null, "jqm-tests/jqm-test-pyl/target/test.jar", TestHelpers.qVip, 42,
"MarsuApplication", null, "Franquin", "ModuleMachin", "other", "other", true, cnx);
Calendar runAt = Calendar.getInstance();
runAt.set(Calendar.MILLISECOND, 0); // Not needed in normal operations, but we will compare at the end.
runAt.set(Calendar.SECOND, 0);
runAt.add(Calendar.MINUTE, 1);
JobRequest.create("MarsuApplication", "testuser").setRunAfter(runAt).submit();
Assert.assertEquals(1, TestHelpers.getQueueAllCount(cnx));
Assert.assertEquals(State.SCHEDULED, Query.create().setQueryLiveInstances(true).run().get(0).getState());
Assert.assertTrue(Query.create().setQueryLiveInstances(true).run().get(0).isFromSchedule());
Assert.assertEquals(runAt, Query.create().setQueryLiveInstances(true).run().get(0).getRunAfter());
addAndStartEngine();
TestHelpers.waitFor(1, 150000, cnx);
Assert.assertEquals(1, TestHelpers.getOkCount(cnx));
Assert.assertTrue(Query.create().run().get(0).isFromSchedule());
Assert.assertTrue(Query.create().run().get(0).getBeganRunningDate().after(runAt));
}
代码示例来源:origin: enioka/jqm
Assert.assertTrue(Query.create().setNodeName("localhost48").run().size() == 0L);
Assert.assertTrue(Query.create().setNodeName("localhost").run().size() > 0L);
Assert.assertTrue(Query.create().setNodeName("localhost4").run().size() > 0L);
Assert.assertTrue(Query.create().setNodeName("localhost5").run().size() > 0L);
代码示例来源: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
Assert.assertEquals(0, TestHelpers.getNonOkCount(cnx));
List<JobInstance> jis = Query.create().setParentId(i).run();
Assert.assertEquals(1, jis.size());
代码示例来源:origin: enioka/jqm
@Test
public void testHistoryFields() throws Exception
{
CreationTools.createJobDef(null, true, "App", null, "jqm-tests/jqm-test-datetimemaven/target/test.jar", TestHelpers.qVip, 42,
"MarsuApplication", null, "Franquin", "ModuleMachin", "other", "other2", true, cnx);
int i = JobRequest.create("MarsuApplication", "TestUser").setSessionID("session42").setKeyword1("k1").setKeyword2("k2").submit();
addAndStartEngine();
TestHelpers.waitFor(1, 10000, cnx);
Assert.assertEquals(1, TestHelpers.getOkCount(cnx));
JobInstance h = JqmClientFactory.getClient().getJob(i);
SimpleDateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm");
jqmlogger.debug("enqueueDate: " + df.format(h.getEnqueueDate().getTime()));
jqmlogger.debug("ExecutionDate: " + df.format(h.getBeganRunningDate().getTime()));
jqmlogger.debug("EndDate: " + df.format(h.getEndDate().getTime()));
Assert.assertTrue(h.getEnqueueDate() != null);
Assert.assertTrue(h.getUser() != null);
Assert.assertTrue(h.getEndDate() != null);
Assert.assertTrue(h.getBeganRunningDate() != null);
Assert.assertTrue(h.getSessionID() != null);
Assert.assertEquals("session42", h.getSessionID());
JobInstance ji = Query.create().setApplicationName("MarsuApplication").run().get(0);
Assert.assertEquals("ModuleMachin", ji.getDefinitionKeyword1());
Assert.assertEquals("other", ji.getDefinitionKeyword2());
Assert.assertEquals("other2", ji.getDefinitionKeyword3());
Assert.assertEquals("k1", ji.getKeyword1());
Assert.assertEquals("k2", ji.getKeyword2());
Assert.assertEquals(null, ji.getKeyword3());
}
代码示例来源:origin: enioka/jqm
for (JobInstance ji : Query.create().setPageSize(1000).run())
代码示例来源:origin: enioka/jqm
public Query(String applicationName, String instanceKeyword1)
{
this.setApplicationName(applicationName);
this.instanceKeyword1 = instanceKeyword1;
}
代码示例来源:origin: enioka/jqm
/**
* Version of {@link JqmClient#getDeliverableContent(Deliverable)} which does not require the web service APIs to be enabled to work.
* Also, returned files do not self-destruct on stream close.<br>
* See the javadoc of the original method for details.
*
* @throws FileNotFoundException
*/
public InputStream getDeliverableContent(Deliverable file) throws FileNotFoundException
{
List<com.enioka.jqm.model.Deliverable> dd = com.enioka.jqm.model.Deliverable.select(cnx, "deliverable_select_by_id", file.getId());
if (dd.isEmpty())
{
throw new JqmInvalidRequestException("no deliverable with this ID");
}
com.enioka.jqm.model.Deliverable d = dd.get(0);
JobInstance ji = Query.create().setJobInstanceId(d.getJobId()).run().get(0);
String nodeName = ji.getNodeName();
Node n = nodes.get(nodeName);
return new FileInputStream(FilenameUtils.concat(n.getDlRepo(), file.getFilePath()));
}
}
代码示例来源: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: 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
@Override
public void waitChildren()
{
JqmClient c = getJqmClient();
Query q = Query.create().setQueryHistoryInstances(false).setQueryLiveInstances(true).setParentId(ji.getId());
while (!c.getJobs(q).isEmpty())
{
try
{
Thread.sleep(1000);
handleInstructions();
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
break;
}
}
}
代码示例来源:origin: enioka/jqm
@Test
public void testStartHeld()
{
CreationTools.createJobDef(null, true, "pyl.EngineApiSendMsg", null, "jqm-tests/jqm-test-pyl/target/test.jar", TestHelpers.qVip, 42,
"MarsuApplication", null, "Franquin", "ModuleMachin", "other", "other", true, cnx);
int i = JobRequest.create("MarsuApplication", "testuser").startHeld().submit();
addAndStartEngine();
// Should not run.
sleepms(1000);
Assert.assertEquals(1, TestHelpers.getQueueAllCount(cnx));
Assert.assertEquals(State.HOLDED, Query.create().setQueryLiveInstances(true).run().get(0).getState());
// Resume at will.
JqmClientFactory.getClient().resumeQueuedJob(i);
TestHelpers.waitFor(1, 10000, cnx);
Assert.assertEquals(1, TestHelpers.getOkCount(cnx));
}
}
内容来源于网络,如有侵权,请联系作者删除!