Package org.apache.oozie.util

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


     * Return safemode state, instrumentation, configuration, osEnv or javaSysProps
     */
    @SuppressWarnings("unchecked")
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String resource = getResourceName(request);
        Instrumentation instr = Services.get().get(InstrumentationService.class).get();

        if (resource.equals(RestConstants.ADMIN_STATUS_RESOURCE)) {
            JSONObject json = new JSONObject();
            populateOozieMode(json);
            //json.put(JsonTags.SYSTEM_SAFE_MODE, getOozeMode());
            sendJsonResponse(response, HttpServletResponse.SC_OK, json);
        }
        else if (resource.equals(RestConstants.ADMIN_OS_ENV_RESOURCE)) {
                JSONObject json = new JSONObject();
                json.putAll(instr.getOSEnv());
                sendJsonResponse(response, HttpServletResponse.SC_OK, json);
            }
            else if (resource.equals(RestConstants.ADMIN_JAVA_SYS_PROPS_RESOURCE)) {
                JSONObject json = new JSONObject();
                json.putAll(instr.getJavaSystemProperties());
                sendJsonResponse(response, HttpServletResponse.SC_OK, json);
            }
            else if (resource.equals(RestConstants.ADMIN_CONFIG_RESOURCE)) {
                JSONObject json = new JSONObject();
                json.putAll(instr.getConfiguration());
                sendJsonResponse(response, HttpServletResponse.SC_OK, json);
            }
            else if (resource.equals(RestConstants.ADMIN_INSTRUMENTATION_RESOURCE)) {
                sendJsonResponse(response, HttpServletResponse.SC_OK, instrToJson(instr));
            }
View Full Code Here


    /**
     * The created datasource instruments the active DB connections.
     */
    public InstrumentedBasicDataSource() {
        Instrumentation instr = Services.get().get(InstrumentationService.class).get();
        instr.addSampler(INSTR_GROUP, INSTR_NAME, 60, 1, new Instrumentation.Variable<Long>() {
            public Long getValue() {
                return (long) getNumActive();
            }
        });
    }
View Full Code Here

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

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

        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 =
        // START_RETRY and job != RUNNING
        Long counterVal = inst.getCounters().get(XCommand.INSTRUMENTATION_GROUP).get(
                startCmd.getName() + ".preconditionfailed").getValue();
        assertEquals(new Long(1), new Long(counterVal));
    }
View Full Code Here

     * 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.getPending());

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

     * The created datasource instruments the active DB connections.
     */
    public InstrumentedBasicDataSource() {
        InstrumentationService instrumentationService = Services.get().get(InstrumentationService.class);
        if (instrumentationService != null) {
            Instrumentation instr = instrumentationService.get();
            instr.addSampler(INSTR_GROUP, INSTR_NAME, 60, 1, new Instrumentation.Variable<Long>() {
                public Long getValue() {
                    return (long) getNumActive();
                }
            });
        }
View Full Code Here

     */
    @Override
    @SuppressWarnings("unchecked")
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String resource = getResourceName(request);
        Instrumentation instr = Services.get().get(InstrumentationService.class).get();

        if (resource.equals(RestConstants.ADMIN_STATUS_RESOURCE)) {
            JSONObject json = new JSONObject();
            populateOozieMode(json);
            // json.put(JsonTags.SYSTEM_SAFE_MODE, getOozeMode());
            sendJsonResponse(response, HttpServletResponse.SC_OK, json);
        }
        else if (resource.equals(RestConstants.ADMIN_OS_ENV_RESOURCE)) {
            JSONObject json = new JSONObject();
            json.putAll(instr.getOSEnv());
            sendJsonResponse(response, HttpServletResponse.SC_OK, json);
        }
        else if (resource.equals(RestConstants.ADMIN_JAVA_SYS_PROPS_RESOURCE)) {
            JSONObject json = new JSONObject();
            json.putAll(instr.getJavaSystemProperties());
            sendJsonResponse(response, HttpServletResponse.SC_OK, json);
        }
        else if (resource.equals(RestConstants.ADMIN_CONFIG_RESOURCE)) {
            JSONObject json = new JSONObject();
            json.putAll(instr.getConfiguration());
            sendJsonResponse(response, HttpServletResponse.SC_OK, json);
        }
        else if (resource.equals(RestConstants.ADMIN_INSTRUMENTATION_RESOURCE)) {
            sendJsonResponse(response, HttpServletResponse.SC_OK, instrToJson(instr));
        }
View Full Code Here

        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

TOP

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

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.