Search in sources :

Example 11 with Instrumentation

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

the class JPAService method instrument.

@Override
public void instrument(final Instrumentation instr) {
    this.instr = instr;
    final BasicDataSource dataSource = getBasicDataSource();
    if (dataSource != null) {
        instr.addSampler("jdbc", "connections.active", 60, 1, new Instrumentation.Variable<Long>() {

            @Override
            public Long getValue() {
                return (long) dataSource.getNumActive();
            }
        });
        instr.addSampler("jdbc", "connections.idle", 60, 1, new Instrumentation.Variable<Long>() {

            @Override
            public Long getValue() {
                return (long) dataSource.getNumIdle();
            }
        });
    }
}
Also used : Instrumentation(org.apache.oozie.util.Instrumentation) BasicDataSource(org.apache.commons.dbcp.BasicDataSource)

Example 12 with Instrumentation

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

the class TestActionCheckXCommand method testActionCheckPreCondition2.

/**
 * Test : verify the PreconditionException is thrown when pending = false
 *
 * @throws Exception
 */
public void testActionCheckPreCondition2() throws Exception {
    Instrumentation inst = Services.get().get(InstrumentationService.class).get();
    WorkflowJobBean job = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
    WorkflowActionBean action = super.addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.RUNNING);
    ActionCheckXCommand checkCmd = new ActionCheckXCommand(action.getId());
    long counterVal;
    try {
        counterVal = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(checkCmd.getName() + ".preconditionfailed").getValue();
    } catch (NullPointerException e) {
        // counter might be null
        counterVal = 0L;
    }
    assertEquals(0L, counterVal);
    checkCmd.call();
    // precondition failed because of pending = false
    counterVal = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(checkCmd.getName() + ".preconditionfailed").getValue();
    assertEquals(1L, 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 13 with Instrumentation

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

the class TestActionCheckXCommand method testActionCheckPreCondition1.

/**
 * Test : verify the PreconditionException is thrown when actionCheckDelay > 0
 *
 * @throws Exception
 */
public void testActionCheckPreCondition1() throws Exception {
    Instrumentation inst = Services.get().get(InstrumentationService.class).get();
    WorkflowJobBean job = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
    WorkflowActionBean action = this.addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.PREP);
    ActionCheckXCommand checkCmd = new ActionCheckXCommand(action.getId(), 10);
    long counterVal;
    try {
        counterVal = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(checkCmd.getName() + ".preconditionfailed").getValue();
    } catch (NullPointerException e) {
        // counter might be null
        counterVal = 0L;
    }
    assertEquals(0L, counterVal);
    checkCmd.call();
    // precondition failed because of actionCheckDelay > 0
    counterVal = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(checkCmd.getName() + ".preconditionfailed").getValue();
    assertEquals(1L, 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 14 with Instrumentation

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

the class TestActionCheckXCommand method testActionCheckPreCondition4.

/**
 * Test : verify the PreconditionException is thrown when job != RUNNING && job != SUSPENDED
 *
 * @throws Exception
 */
public void testActionCheckPreCondition4() 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.RUNNING);
    ActionCheckXCommand checkCmd = new ActionCheckXCommand(action.getId());
    long counterVal;
    try {
        counterVal = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(checkCmd.getName() + ".preconditionfailed").getValue();
    } catch (NullPointerException e) {
        // counter might be null
        counterVal = 0L;
    }
    assertEquals(0L, counterVal);
    checkCmd.call();
    // precondition failed because of job != RUNNING && job != SUSPENDED
    counterVal = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(checkCmd.getName() + ".preconditionfailed").getValue();
    assertEquals(1L, counterVal);
    job = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
    action = this.addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.RUNNING);
    checkCmd = new ActionCheckXCommand(action.getId());
    checkCmd.call();
    // precondition passed because job == RUNNING so counter shouldn't have incremented
    counterVal = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(checkCmd.getName() + ".preconditionfailed").getValue();
    assertEquals(1L, counterVal);
    job = this.addRecordToWfJobTable(WorkflowJob.Status.SUSPENDED, WorkflowInstance.Status.SUSPENDED);
    action = this.addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.RUNNING);
    checkCmd = new ActionCheckXCommand(action.getId());
    checkCmd.call();
    // precondition passed because job == SUSPENDED so counter shouldn't have incremented
    counterVal = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(checkCmd.getName() + ".preconditionfailed").getValue();
    assertEquals(1L, counterVal);
    job = this.addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
    action = this.addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.RUNNING);
    checkCmd = new ActionCheckXCommand(action.getId());
    checkCmd.call();
    // precondition failed because of job != RUNNING && job != SUSPENDED
    counterVal = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(checkCmd.getName() + ".preconditionfailed").getValue();
    assertEquals(2L, counterVal);
    job = this.addRecordToWfJobTable(WorkflowJob.Status.KILLED, WorkflowInstance.Status.KILLED);
    action = this.addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.RUNNING);
    checkCmd = new ActionCheckXCommand(action.getId());
    checkCmd.call();
    // precondition failed because of job != RUNNING && job != SUSPENDED
    counterVal = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(checkCmd.getName() + ".preconditionfailed").getValue();
    assertEquals(3L, 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 15 with Instrumentation

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

the class TestActionCheckXCommand method testActionCheckPreCondition3.

/**
 * Test : verify the PreconditionException is thrown when action != RUNNING
 *
 * @throws Exception
 */
public void testActionCheckPreCondition3() throws Exception {
    Instrumentation inst = Services.get().get(InstrumentationService.class).get();
    WorkflowJobBean job = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
    WorkflowActionBean action = this.addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.PREP);
    ActionCheckXCommand checkCmd = new ActionCheckXCommand(action.getId());
    long counterVal;
    try {
        counterVal = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(checkCmd.getName() + ".preconditionfailed").getValue();
    } catch (NullPointerException e) {
        // counter might be null
        counterVal = 0L;
    }
    assertEquals(0L, counterVal);
    checkCmd.call();
    // precondition failed because of action != RUNNING
    counterVal = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(checkCmd.getName() + ".preconditionfailed").getValue();
    assertEquals(1L, 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)

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