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