Search in sources :

Example 6 with Instrumentation

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

the class TestActionStartXCommand method testActionStartPreCondition3.

/**
 * Test : verify the PreconditionException is thrown when pending = false
 *
 * @throws Exception
 */
public void testActionStartPreCondition3() 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.PREP);
    assertFalse(action.isPending());
    assertNull(inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP));
    ActionStartXCommand startCmd = new ActionStartXCommand(action.getId(), "map-reduce");
    startCmd.call();
    // precondition failed because of pending = false
    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 7 with Instrumentation

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

the class TestActionStartXCommand method testActionStartPreCondition1.

/**
 * Test : verify the PreconditionException is thrown when pending = true and action = PREP and job != RUNNING
 *
 * @throws Exception
 */
public void testActionStartPreCondition1() 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.PREP);
    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 = PREP 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 8 with Instrumentation

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

the class TestCompletedActionXCommand method testEarlyCallbackTimeout.

public void testEarlyCallbackTimeout() throws Exception {
    final Instrumentation inst = Services.get().get(InstrumentationService.class).get();
    WorkflowJobBean job = addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
    WorkflowActionBean action = addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.PREP);
    final CompletedActionXCommand cmd = new CompletedActionXCommand(action.getId(), "SUCCEEDED", null);
    long xexceptionCount;
    try {
        xexceptionCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(cmd.getName() + ".xexceptions").getValue();
    } catch (NullPointerException npe) {
        // counter might be null
        xexceptionCount = 0L;
    }
    assertEquals(0L, xexceptionCount);
    long executionsCount;
    try {
        executionsCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(cmd.getName() + ".executions").getValue();
    } catch (NullPointerException npe) {
        // counter might be null
        executionsCount = 0L;
    }
    assertEquals(0L, executionsCount);
    long executionCount;
    try {
        executionCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(cmd.getName() + ".execution").getValue();
    } catch (NullPointerException npe) {
        // counter might be null
        executionCount = 0L;
    }
    assertEquals(0L, executionCount);
    cmd.call();
    int timeout = 10000 * 5 * 2;
    waitFor(timeout, new Predicate() {

        @Override
        public boolean evaluate() throws Exception {
            long xexceptionCount;
            try {
                xexceptionCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(cmd.getName() + ".xexceptions").getValue();
            } catch (NullPointerException npe) {
                // counter might be null
                xexceptionCount = 0L;
            }
            return (xexceptionCount == 1L);
        }
    });
    executionsCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(cmd.getName() + ".executions").getValue();
    assertEquals(6L, executionsCount);
    try {
        executionCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(cmd.getName() + ".execution").getValue();
    } catch (NullPointerException npe) {
        // counter might be null
        executionCount = 0L;
    }
    assertEquals(0L, executionCount);
    xexceptionCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(cmd.getName() + ".xexceptions").getValue();
    assertEquals(1L, xexceptionCount);
}
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 9 with Instrumentation

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

the class TestCompletedActionXCommand method testEarlyCallbackTransitionToRunning.

public void testEarlyCallbackTransitionToRunning() throws Exception {
    final Instrumentation inst = Services.get().get(InstrumentationService.class).get();
    WorkflowJobBean job = addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
    final WorkflowActionBean action = addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.PREP);
    final CompletedActionXCommand cmd = new CompletedActionXCommand(action.getId(), "SUCCEEDED", null);
    long xexceptionCount;
    try {
        xexceptionCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(cmd.getName() + ".xexceptions").getValue();
    } catch (NullPointerException npe) {
        // counter might be null
        xexceptionCount = 0L;
    }
    assertEquals(0L, xexceptionCount);
    long executionsCount;
    try {
        executionsCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(cmd.getName() + ".executions").getValue();
    } catch (NullPointerException npe) {
        // counter might be null
        executionsCount = 0L;
    }
    assertEquals(0L, executionsCount);
    long checkXCommandExecutionsCount;
    try {
        checkXCommandExecutionsCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get("action.check.executions").getValue();
    } catch (NullPointerException npe) {
        // counter might be null
        checkXCommandExecutionsCount = 0L;
    }
    assertEquals(0L, checkXCommandExecutionsCount);
    cmd.call();
    int timeout = 100000 * 5 * 2;
    waitFor(timeout, new Predicate() {

        @Override
        public boolean evaluate() throws Exception {
            long executionsCount;
            try {
                executionsCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(cmd.getName() + ".executions").getValue();
            } catch (NullPointerException npe) {
                // counter might be null
                executionsCount = 0L;
            }
            if (executionsCount == 3 && !action.getStatus().equals(WorkflowAction.Status.RUNNING)) {
                // Transition the action to RUNNING
                action.setStatus(WorkflowAction.Status.RUNNING);
                WorkflowActionQueryExecutor.getInstance().executeUpdate(WorkflowActionQueryExecutor.WorkflowActionQuery.UPDATE_ACTION, action);
            }
            long checkXCommandExecutionsCount;
            try {
                checkXCommandExecutionsCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get("action.check.executions").getValue();
            } catch (NullPointerException npe) {
                // counter might be null
                checkXCommandExecutionsCount = 0L;
            }
            return (checkXCommandExecutionsCount == 1L);
        }
    });
    executionsCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(cmd.getName() + ".executions").getValue();
    assertTrue("expected a value greater than 3L, but found " + executionsCount, executionsCount >= 3L);
    checkXCommandExecutionsCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get("action.check.executions").getValue();
    assertEquals(1L, checkXCommandExecutionsCount);
    try {
        xexceptionCount = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(cmd.getName() + ".xexceptions").getValue();
    } catch (NullPointerException npe) {
        // counter might be null
        xexceptionCount = 0L;
    }
    assertEquals(0L, xexceptionCount);
}
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 10 with Instrumentation

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

the class InstrumentationService method init.

/**
 * Initialize the instrumentation service.
 *
 * @param services services instance.
 */
@Override
public void init(Services services) throws ServiceException {
    final Instrumentation instr = new Instrumentation();
    int interval = ConfigurationService.getInt(services.getConf(), CONF_LOGGING_INTERVAL);
    initLogging(services, instr, interval);
    instr.addVariable(JVM_INSTRUMENTATION_GROUP, "free.memory", new Instrumentation.Variable<Long>() {

        @Override
        public Long getValue() {
            return Runtime.getRuntime().freeMemory();
        }
    });
    instr.addVariable(JVM_INSTRUMENTATION_GROUP, "max.memory", new Instrumentation.Variable<Long>() {

        @Override
        public Long getValue() {
            return Runtime.getRuntime().maxMemory();
        }
    });
    instr.addVariable(JVM_INSTRUMENTATION_GROUP, "total.memory", new Instrumentation.Variable<Long>() {

        @Override
        public Long getValue() {
            return Runtime.getRuntime().totalMemory();
        }
    });
    instrumentation = instr;
    isEnabled = true;
}
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