Package org.apache.oozie.util

Examples of org.apache.oozie.util.Instrumentation$Element


        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();
            }
View Full Code Here


    }

    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(instr instanceof MetricsInstrumentation);
    }
View Full Code Here

     *
     * @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();
            }
        });
View Full Code Here

            SERVICES = null;
            throw ex;
        }
        InstrumentationService instrService = get(InstrumentationService.class);
        if (instrService != null) {
            Instrumentation instr = instrService.get();
            for (Service service : services.values()) {
                if (service instanceof Instrumentable) {
                    ((Instrumentable) service).instrument(instr);
                }
            }
            instr.addVariable("oozie", "version", new Instrumentation.Variable<String>() {
                @Override
                public String getValue() {
                    return BuildInfo.getBuildInfo().getProperty(BuildInfo.BUILD_VERSION);
                }
            });
            instr.addVariable("oozie", "mode", new Instrumentation.Variable<String>() {
                @Override
                public String getValue() {
                    return getSystemMode().toString();
                }
            });
View Full Code Here

        }
    }

    public void testInstrumentation() throws Exception {
        JobsConcurrencyService jcs = new JobsConcurrencyService();
        Instrumentation instr = new Instrumentation();
        try {
            jcs.init(Services.get());
            jcs.instrument(instr);
            String servers = ConfigurationService.get("oozie.instance.id") + "=" + ConfigUtils.getOozieEffectiveUrl();
            assertEquals(servers, instr.getVariables().get("oozie").get("servers").getValue());
        } finally {
            jcs.destroy();
        }
    }
View Full Code Here

    }

    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();
        assertFalse(instr instanceof MetricsInstrumentation);
    }
View Full Code Here

     * 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);
    }
View Full Code Here

     * 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);
    }
View Full Code Here

     * 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);
    }
View Full Code Here

     * 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);
    }
View Full Code Here

TOP

Related Classes of org.apache.oozie.util.Instrumentation$Element

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.