Search in sources :

Example 16 with Instrumentation

use of org.apache.oozie.util.Instrumentation in project oozie by apache.

the class TestActionStartXCommand method testActionStartPreCondition2.

/**
 * Test : verify the PreconditionException is thrown when pending = true and action = START_RETRY and job != RUNNING
 *
 * @throws Exception
 */
public void testActionStartPreCondition2() throws Exception {
    Instrumentation inst = Services.get().get(InstrumentationService.class).get();
    WorkflowJobBean job = this.addRecordToWfJobTable(WorkflowJob.Status.FAILED, WorkflowInstance.Status.FAILED);
    WorkflowActionBean action = this.addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.START_RETRY);
    assertNull(inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP));
    ActionStartXCommand startCmd = new ActionStartXCommand(action.getId(), "map-reduce");
    startCmd.call();
    // precondition failed because of pending = true and action =
    // START_RETRY and job != RUNNING
    Long counterVal = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(startCmd.getName() + ".preconditionfailed").getValue();
    assertEquals(new Long(1), new Long(counterVal));
}
Also used : Instrumentation(org.apache.oozie.util.Instrumentation) InstrumentationService(org.apache.oozie.service.InstrumentationService) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 17 with Instrumentation

use of org.apache.oozie.util.Instrumentation in project oozie by apache.

the class TestInstrumentationService method testInstrumentation.

public void testInstrumentation() throws Exception {
    assertNotNull(Services.get().get(InstrumentationService.class));
    assertNotNull(Services.get().get(InstrumentationService.class).get());
    Instrumentation instr = Services.get().get(InstrumentationService.class).get();
    assertTrue("Metrics is enabled by default since 5.0.0", instr instanceof MetricsInstrumentation);
}
Also used : MetricsInstrumentation(org.apache.oozie.util.MetricsInstrumentation) Instrumentation(org.apache.oozie.util.Instrumentation) MetricsInstrumentation(org.apache.oozie.util.MetricsInstrumentation)

Example 18 with Instrumentation

use of org.apache.oozie.util.Instrumentation in project oozie by apache.

the class TestZKJobsConcurrencyService method testInstrumentation.

public void testInstrumentation() throws Exception {
    ZKJobsConcurrencyService zkjcs = new ZKJobsConcurrencyService();
    // We'll use some DummyZKXOozies here to pretend to be other Oozie servers that will influence the instrumentation
    // once they are running in that the there will be other Oozie "servers"
    DummyZKOozie dummyOozie = null;
    DummyZKOozie dummyOozie2 = null;
    Instrumentation instr = new Instrumentation();
    try {
        zkjcs.init(Services.get());
        zkjcs.instrument(instr);
        String servers = ZK_ID + "=" + ConfigUtils.getOozieURL(false);
        assertEquals(servers, instr.getVariables().get("oozie").get("servers").getValue());
        dummyOozie = new DummyZKOozie("0000", "http://blah1");
        servers = ZK_ID + "=" + ConfigUtils.getOozieURL(false) + ",0000=http://blah1";
        assertEquals(servers, instr.getVariables().get("oozie").get("servers").getValue());
        dummyOozie2 = new DummyZKOozie("z", "http://blah2");
        servers = ZK_ID + "=" + ConfigUtils.getOozieURL(false) + ",0000=http://blah1" + ",z=http://blah2";
        assertEquals(servers, instr.getVariables().get("oozie").get("servers").getValue());
        dummyOozie.teardown();
        servers = ZK_ID + "=" + ConfigUtils.getOozieURL(false) + ",z=http://blah2";
        assertEquals(servers, instr.getVariables().get("oozie").get("servers").getValue());
        dummyOozie2.teardown();
        servers = ZK_ID + "=" + ConfigUtils.getOozieURL(false);
        assertEquals(servers, instr.getVariables().get("oozie").get("servers").getValue());
    } finally {
        zkjcs.destroy();
        if (dummyOozie != null) {
            dummyOozie.teardown();
        }
        if (dummyOozie2 != null) {
            dummyOozie2.teardown();
        }
    }
}
Also used : Instrumentation(org.apache.oozie.util.Instrumentation)

Aggregations

Instrumentation (org.apache.oozie.util.Instrumentation)18 InstrumentationService (org.apache.oozie.service.InstrumentationService)10 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)9 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)9 MetricsInstrumentation (org.apache.oozie.util.MetricsInstrumentation)2 BasicDataSource (org.apache.commons.dbcp.BasicDataSource)1 JsonBean (org.apache.oozie.client.rest.JsonBean)1 MemoryLocks (org.apache.oozie.lock.MemoryLocks)1 Instrumentable (org.apache.oozie.util.Instrumentable)1 XLog (org.apache.oozie.util.XLog)1 JSONObject (org.json.simple.JSONObject)1