本文整理了Java中com.enioka.jqm.api.Query.setQueryLiveInstances
方法的一些代码示例,展示了Query.setQueryLiveInstances
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setQueryLiveInstances
方法的具体详情如下:
包路径:com.enioka.jqm.api.Query
类名称:Query
方法名:setQueryLiveInstances
[英]By default, querying only occurs on ended (OK or not) job instances. If this parameter is set to true, it will also include living (waiting, running, ...) job instances.
If you also query on live instances at the same time, this will reset pagination as it is impossible to use pagination with both.
Setting this to true has a noticeable performance impact and should be used as little as possible (or should be used when #setQueryHistoryInstances(boolean) is false, which is not the default)
[中]默认情况下,查询仅在结束(确定或否)作业实例上发生。如果此参数设置为true,它还将包括生存(等待、运行等)工作实例。
如果同时查询活动实例,这将重置分页,因为不可能同时对这两个实例使用分页。
将其设置为true会对性能产生显著影响,应尽可能少地使用(或者在#setQueryHistoryInstances(布尔值)为false时使用,这不是默认值)
代码示例来源: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: 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
@Override
public List<com.enioka.jqm.api.JobInstance> getJobs()
{
return Query.create().setQueryHistoryInstances(true).setQueryLiveInstances(true).run();
}
代码示例来源:origin: enioka/jqm
@Override
public void waitChild(int id)
{
JqmClient c = getJqmClient();
Query q = Query.create().setQueryHistoryInstances(false).setQueryLiveInstances(true).setJobInstanceId(id);
while (!c.getJobs(q).isEmpty())
{
try
{
Thread.sleep(1000);
handleInstructions();
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
break;
}
}
}
代码示例来源:origin: com.enioka.jqm/jqm-engine
@Override
public void waitChild(int id)
{
JqmClient c = getJqmClient();
Query q = Query.create().setQueryHistoryInstances(false).setQueryLiveInstances(true).setJobInstanceId(id);
while (!c.getJobs(q).isEmpty())
{
try
{
Thread.sleep(1000);
handleInstructions();
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
break;
}
}
}
代码示例来源: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-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
@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
@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
return Query.create().setJobInstanceId(idJob).setQueryHistoryInstances(true).setQueryLiveInstances(true).run().get(0);
代码示例来源: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
@Test
public void testQuery() throws Exception
{
CreationTools.createJobDef(null, true, "pyl.KillMe", null, "jqm-tests/jqm-test-pyl/target/test.jar", TestHelpers.qNormal, 42,
"jqm-test-kill", null, "Franquin", "ModuleMachin", "other", "other", false, cnx);
cnx.commit();
JqmClientFactory.getClient().enqueue("jqm-test-kill", "test");
JqmClientFactory.getClient().enqueue("jqm-test-kill", "test");
JqmClientFactory.getClient().enqueue("jqm-test-kill", "test");
JqmClientFactory.getClient().enqueue("jqm-test-kill", "test");
JqmClientFactory.getClient().enqueue("jqm-test-kill", "test");
jqmlogger.debug("COUNT RUNNING " + cnx.runSelectSingle("ji_select_count_running", Integer.class));
jqmlogger.debug("COUNT ALL " + cnx.runSelectSingle("ji_select_count_all", Integer.class));
Assert.assertEquals(0, Query.create().setQueryLiveInstances(true).setQueryHistoryInstances(false)
.addStatusFilter(com.enioka.jqm.api.State.RUNNING).addStatusFilter(com.enioka.jqm.api.State.ENDED).run().size());
Assert.assertEquals(5, Query.create().setQueryLiveInstances(true).setQueryHistoryInstances(false)
.addStatusFilter(com.enioka.jqm.api.State.SUBMITTED).run().size());
}
代码示例来源:origin: enioka/jqm
@Test
public void testPauseInQueue() 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().pauseQueuedJob(i);
JobRequest.create("MarsuApplication", "TestUser").submit();
addAndStartEngine();
TestHelpers.waitFor(1, 5000, cnx);
List<JobInstance> res1 = Query.create().addSortAsc(Sort.DATEENQUEUE).run();
List<JobInstance> res2 = Query.create().addSortAsc(Sort.DATEENQUEUE).setQueryHistoryInstances(false).setQueryLiveInstances(true)
.run();
Assert.assertEquals(1, res1.size());
Assert.assertEquals(1, res2.size());
Assert.assertEquals(State.HOLDED, res2.get(0).getState());
Assert.assertEquals(State.ENDED, res1.get(0).getState());
}
代码示例来源:origin: enioka/jqm
Assert.assertEquals(3, Query.create().setQueryLiveInstances(true).setQueryHistoryInstances(false)
.addStatusFilter(com.enioka.jqm.api.State.RUNNING).run().size());
Assert.assertEquals(1, Query.create().setQueryLiveInstances(true).setQueryHistoryInstances(false)
.addStatusFilter(com.enioka.jqm.api.State.SUBMITTED).run().size());
List<JobInstance> running = Query.create().setQueryLiveInstances(true).setQueryHistoryInstances(false)
.addStatusFilter(com.enioka.jqm.api.State.RUNNING).run();
JqmClientFactory.getClient().killJob(running.get(0).getId());
Assert.assertEquals(3, Query.create().setQueryLiveInstances(true).setQueryHistoryInstances(false)
.addStatusFilter(com.enioka.jqm.api.State.RUNNING).run().size());
Assert.assertEquals(0, Query.create().setQueryLiveInstances(true).setQueryHistoryInstances(false)
.addStatusFilter(com.enioka.jqm.api.State.SUBMITTED).run().size());
running = Query.create().setQueryLiveInstances(true).setQueryHistoryInstances(false)
.addStatusFilter(com.enioka.jqm.api.State.RUNNING).run();
JqmClientFactory.getClient().killJob(running.get(0).getId());
代码示例来源:origin: enioka/jqm
Assert.assertEquals(3, Query.create().setQueryLiveInstances(true).setQueryHistoryInstances(false)
.addStatusFilter(com.enioka.jqm.api.State.RUNNING).run().size());
Assert.assertEquals(2, Query.create().setQueryLiveInstances(true).setQueryHistoryInstances(false)
.addStatusFilter(com.enioka.jqm.api.State.SUBMITTED).run().size());
Assert.assertEquals(3, Query.create().setQueryLiveInstances(true).setQueryHistoryInstances(false)
.addStatusFilter(com.enioka.jqm.api.State.RUNNING).run().size());
Assert.assertEquals(0, Query.create().setQueryLiveInstances(true).setQueryHistoryInstances(false)
.addStatusFilter(com.enioka.jqm.api.State.SUBMITTED).run().size());
代码示例来源: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));
}
}
代码示例来源: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));
}
}
代码示例来源:origin: enioka/jqm
sleep(1); // Additional - check no more than two running!
List<com.enioka.jqm.api.JobInstance> res = Query.create().setQueryLiveInstances(true).setQueryHistoryInstances(false)
.addSortAsc(Sort.ID).run();
代码示例来源:origin: enioka/jqm
int toKill = Query.create().setQueryHistoryInstances(false).setQueryLiveInstances(true).addStatusFilter(State.RUNNING).run().get(0)
.getId();
JqmClientFactory.getClient().killJob(toKill);
for (JobInstance ji : Query.create().setQueryHistoryInstances(false).setQueryLiveInstances(true).addStatusFilter(State.RUNNING)
.run())
内容来源于网络,如有侵权,请联系作者删除!