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));
}
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));
}
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);
}
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);
}
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;
}
Aggregations