Instances implements Iterable<Instance> { public Iterator<Instance.InstanceQueueingInfo> iteratorQueueing() { return iteratorQueueing(getDefaultProjectName()); } Instances(Odps odps); String getDefaultRunningCluster(); void setDefaultRunningCluster(String defaultRunningCluster); Instance create(Job job); Instance create(Task task); Instance create(Task task, int priority); Instance create(Task task, int priority, String runningCluster); Instance get(String id); Instance get(String projectName, String id); boolean exists(String id); boolean exists(String projectName, String id); Instance create(String projectName, Task task); Instance create(String projectName, Task task, int priority); Instance create(String projectName, Task task, int priority, String runningCluster); Instance create(String projectName, Task task, Integer priority, String runningCluster); Instance create(String projectName, Task task, Integer priority, String runningCluster,
                         String jobName); Iterator<Instance> iterator(); Iterator<Instance> iterator(final String project); Iterator<Instance> iterator(final InstanceFilter filter); Iterator<Instance> iterator(final String project,
                                     final InstanceFilter filter); Iterable<Instance> iterable(); Iterable<Instance> iterable(final String project); Iterable<Instance> iterable(final InstanceFilter filter); Iterable<Instance> iterable(final String project,
                                     final InstanceFilter filter); Iterator<Instance.InstanceQueueingInfo> iteratorQueueing(); Iterator<Instance.InstanceQueueingInfo> iteratorQueueing(String project); Iterator<Instance.InstanceQueueingInfo> iteratorQueueing(InstanceFilter filter); Iterator<Instance.InstanceQueueingInfo> iteratorQueueing(String project, InstanceFilter filter); Iterator<Instance.InstanceQueueingInfo> iteratorQueueing(
      String project, InstanceFilter filter, Integer maxItemsPerRequest);  }
@Test public void testIteratorQueueing() throws Exception { SQLTask task = new SQLTask(); task.setQuery("select (t2.c1 + 2) from " + TABLE_NAME + " t1 join " + TABLE_NAME_1 + " t2 on t1.c1 == t2.c1;"); task.setName("testsqlcase"); for (int counter = 0; counter < 10; counter++) { i = odps.instances().create(task); } System.out.println("Now create Instance: " + i.getId()); Iterator<Instance.InstanceQueueingInfo> iterator = odps.instances().iteratorQueueing(); Assert.assertTrue(iterator.hasNext()); while (iterator.hasNext()) { Instance.InstanceQueueingInfo info = iterator.next(); System.out.println(info.getId()); System.out.println(info.getStatus()); System.out.println(info.getStartTime()); System.out.println(info.getProgress()); if (i.getId().equals(info.getId())) { Assert.assertNotNull(info.getPriority()); Assert.assertNotNull(info.getProgress()); Assert.assertNotNull(info.getTaskName()); Assert.assertNotNull(info.getTaskType()); Assert.assertNotNull(info.getStartTime()); Assert.assertNotNull(info.getStatus()); Assert.assertNotNull(info.getProject()); Assert.assertNotNull(info.getSkyNetId()); Assert.assertNotNull(info.getUserAccount()); Assert.assertNotNull(info.getId()); } } }