Search in sources :

Example 1 with BulkResponseInfo

use of org.apache.oozie.BulkResponseInfo in project oozie by apache.

the class ZKUUIDServiceWithException method testBulkJobForZKUUIDService.

public void testBulkJobForZKUUIDService() throws Exception {
    Services service = Services.get();
    ZKUUIDService uuid = new ZKUUIDService();
    try {
        setSystemProperty(UUIDService.CONF_GENERATOR, "counter");
        uuid.init(service);
        String bundleId = uuid.generateId(ApplicationType.BUNDLE);
        BundleJobBean bundle = createBundleJob(bundleId, Job.Status.SUCCEEDED, false);
        JPAService jpaService = Services.get().get(JPAService.class);
        BundleJobInsertJPAExecutor bundleInsertjpa = new BundleJobInsertJPAExecutor(bundle);
        jpaService.execute(bundleInsertjpa);
        addCoordForBulkMonitor(bundleId);
        String request = "bundle=" + bundleId;
        BulkJPAExecutor bulkjpa = new BulkJPAExecutor(BundleEngine.parseBulkFilter(request), 1, 1);
        try {
            BulkResponseInfo response = jpaService.execute(bulkjpa);
            assertEquals(response.getResponses().get(0).getBundle().getId(), bundleId);
        } catch (JPAExecutorException jex) {
            // should not throw exception as this case is now supported
            fail();
        }
    } finally {
        uuid.destroy();
    }
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) BundleJobBean(org.apache.oozie.BundleJobBean) BulkResponseInfo(org.apache.oozie.BulkResponseInfo) BulkJPAExecutor(org.apache.oozie.executor.jpa.BulkJPAExecutor) BundleJobInsertJPAExecutor(org.apache.oozie.executor.jpa.BundleJobInsertJPAExecutor)

Example 2 with BulkResponseInfo

use of org.apache.oozie.BulkResponseInfo in project oozie by apache.

the class TestBulkMonitorJPAExecutor method _execQuery.

private BulkResponseInfo _execQuery(String request) throws JPAExecutorException, BundleEngineException {
    BulkJPAExecutor bulkjpa = new BulkJPAExecutor(BundleEngine.parseBulkFilter(request), 1, 10);
    BulkResponseInfo response = jpaService.execute(bulkjpa);
    assertNotNull(response);
    return response;
}
Also used : BulkResponseInfo(org.apache.oozie.BulkResponseInfo)

Example 3 with BulkResponseInfo

use of org.apache.oozie.BulkResponseInfo in project oozie by apache.

the class TestBulkMonitorJPAExecutor method testBundleId.

public void testBundleId() throws Exception {
    String request = "bundle=" + bundleId + ";actionstatus=FAILED;" + "startcreatedtime=2012-07-21T00:00Z;endcreatedtime=2012-07-22T02:00Z";
    BulkResponseInfo response = _execQuery(request);
    List<BulkResponseImpl> brList = response.getResponses();
    // only 1 action satisfies the
    assertEquals(1, brList.size());
    // conditions
    assertEquals(1, response.getTotal());
    BulkResponseImpl br = brList.get(0);
    assertEquals(bundleId, br.getBundle().getId());
    assertEquals("Coord1", br.getCoordinator().getAppName());
    assertEquals(CoordinatorAction.Status.FAILED, br.getAction().getStatus());
    assertEquals(DateUtils.parseDateUTC(CREATE_TIME).toString(), br.getAction().getCreatedTime().toString());
}
Also used : BulkResponseImpl(org.apache.oozie.client.rest.BulkResponseImpl) BulkResponseInfo(org.apache.oozie.BulkResponseInfo)

Example 4 with BulkResponseInfo

use of org.apache.oozie.BulkResponseInfo in project oozie by apache.

the class TestBulkMonitorJPAExecutor method testSingleRecord.

public void testSingleRecord() throws Exception {
    String request = "bundle=" + bundleName + ";actionstatus=FAILED;" + "startcreatedtime=2012-07-21T00:00Z;endcreatedtime=2012-07-22T02:00Z;" + "startscheduledtime=2012-07-20T23:00Z;endscheduledtime=2012-07-22T03:00Z";
    BulkResponseInfo response = _execQuery(request);
    List<BulkResponseImpl> brList = response.getResponses();
    // only 1 action satisfies the
    assertEquals(1, brList.size());
    // conditions
    assertEquals(1, response.getTotal());
    BulkResponseImpl br = brList.get(0);
    assertEquals(bundleName, br.getBundle().getAppName());
    assertEquals("Coord1", br.getCoordinator().getAppName());
    assertEquals(CoordinatorAction.Status.FAILED, br.getAction().getStatus());
    assertEquals(DateUtils.parseDateUTC(CREATE_TIME).toString(), br.getAction().getCreatedTime().toString());
}
Also used : BulkResponseImpl(org.apache.oozie.client.rest.BulkResponseImpl) BulkResponseInfo(org.apache.oozie.BulkResponseInfo)

Example 5 with BulkResponseInfo

use of org.apache.oozie.BulkResponseInfo in project oozie by apache.

the class TestBulkMonitorJPAExecutor method testMultipleCoordinators.

public void testMultipleCoordinators() throws Exception {
    // there are 3 coordinators but giving range as only two of them
    String request = "bundle=" + bundleName + ";coordinators=Coord1,Coord2;actionstatus=KILLED";
    BulkResponseInfo response = _execQuery(request);
    List<BulkResponseImpl> brList = response.getResponses();
    // 2 actions satisfy the conditions
    assertEquals(2, brList.size());
    assertEquals(2, response.getTotal());
    assertEquals(brList.get(0).getAction().getId(), "Coord1@2");
    assertEquals(brList.get(1).getAction().getId(), "Coord2@1");
}
Also used : BulkResponseImpl(org.apache.oozie.client.rest.BulkResponseImpl) BulkResponseInfo(org.apache.oozie.BulkResponseInfo)

Aggregations

BulkResponseInfo (org.apache.oozie.BulkResponseInfo)11 BulkResponseImpl (org.apache.oozie.client.rest.BulkResponseImpl)8 ArrayList (java.util.ArrayList)3 BundleJobBean (org.apache.oozie.BundleJobBean)2 BulkJPAExecutor (org.apache.oozie.executor.jpa.BulkJPAExecutor)2 JPAService (org.apache.oozie.service.JPAService)2 Timestamp (java.sql.Timestamp)1 ParseException (java.text.ParseException)1 HashMap (java.util.HashMap)1 BaseEngineException (org.apache.oozie.BaseEngineException)1 BundleEngine (org.apache.oozie.BundleEngine)1 XException (org.apache.oozie.XException)1 CommandException (org.apache.oozie.command.CommandException)1 BundleJobInsertJPAExecutor (org.apache.oozie.executor.jpa.BundleJobInsertJPAExecutor)1 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)1 BundleEngineService (org.apache.oozie.service.BundleEngineService)1 JSONObject (org.json.simple.JSONObject)1