Search in sources :

Example 1 with Instrumentation

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

the class BaseAdminServlet method doGet.

/**
 * Return safemode state, instrumentation, configuration, osEnv or
 * javaSysProps
 */
@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)) {
        authorizeForSystemInfo(request);
        JSONObject json = new JSONObject();
        json.putAll(instr.getOSEnv());
        sendJsonResponse(response, HttpServletResponse.SC_OK, json);
    } else if (resource.equals(RestConstants.ADMIN_JAVA_SYS_PROPS_RESOURCE)) {
        authorizeForSystemInfo(request);
        JSONObject json = new JSONObject();
        json.putAll(instr.getJavaSystemProperties());
        sendJsonResponse(response, HttpServletResponse.SC_OK, json);
    } else if (resource.equals(RestConstants.ADMIN_CONFIG_RESOURCE)) {
        authorizeForSystemInfo(request);
        JSONObject json = new JSONObject();
        json.putAll(instr.getConfiguration());
        sendJsonResponse(response, HttpServletResponse.SC_OK, json);
    } else if (resource.equals(RestConstants.ADMIN_INSTRUMENTATION_RESOURCE)) {
        sendInstrumentationResponse(response, instr);
    } else if (resource.equals(RestConstants.ADMIN_BUILD_VERSION_RESOURCE)) {
        JSONObject json = new JSONObject();
        json.put(JsonTags.BUILD_VERSION, BuildInfo.getBuildInfo().getProperty(BuildInfo.BUILD_VERSION));
        json.put(JsonTags.BUILD_INFO, BuildInfo.getBuildInfo());
        sendJsonResponse(response, HttpServletResponse.SC_OK, json);
    } else if (resource.equals(RestConstants.ADMIN_QUEUE_DUMP_RESOURCE)) {
        JSONObject json = new JSONObject();
        getQueueDump(json);
        sendJsonResponse(response, HttpServletResponse.SC_OK, json);
    } else if (resource.equals(RestConstants.ADMIN_TIME_ZONES_RESOURCE)) {
        JSONObject json = new JSONObject();
        json.put(JsonTags.AVAILABLE_TIME_ZONES, availableTimeZonesToJsonArray());
        sendJsonResponse(response, HttpServletResponse.SC_OK, json);
    } else if (resource.equals(RestConstants.ADMIN_JMS_INFO)) {
        String timeZoneId = request.getParameter(RestConstants.TIME_ZONE_PARAM) == null ? "GMT" : request.getParameter(RestConstants.TIME_ZONE_PARAM);
        JsonBean jmsBean = getJMSConnectionInfo(request, response);
        sendJsonResponse(response, HttpServletResponse.SC_OK, jmsBean, timeZoneId);
    } else if (resource.equals(RestConstants.ADMIN_AVAILABLE_OOZIE_SERVERS_RESOURCE)) {
        JSONObject json = new JSONObject();
        json.putAll(getOozieURLs());
        sendJsonResponse(response, HttpServletResponse.SC_OK, json);
    } else if (resource.equals(RestConstants.ADMIN_UPDATE_SHARELIB)) {
        authorizeRequest(request);
        updateShareLib(request, response);
    } else if (resource.equals(RestConstants.ADMIN_LIST_SHARELIB)) {
        String sharelibKey = request.getParameter(RestConstants.SHARE_LIB_REQUEST_KEY);
        sendJsonResponse(response, HttpServletResponse.SC_OK, getShareLib(sharelibKey));
    } else if (resource.equals(RestConstants.ADMIN_METRICS_RESOURCE)) {
        sendMetricsResponse(response);
    }
}
Also used : JsonBean(org.apache.oozie.client.rest.JsonBean) JSONObject(org.json.simple.JSONObject) Instrumentation(org.apache.oozie.util.Instrumentation) InstrumentationService(org.apache.oozie.service.InstrumentationService)

Example 2 with Instrumentation

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

the class Services method init.

/**
 * Initialize all services define in the {@link #CONF_SERVICE_CLASSES} configuration property.
 *
 * @throws ServiceException thrown if any of the services could not initialize.
 */
public void init() throws ServiceException {
    XLog log = new XLog(LogFactory.getLog(getClass()));
    log.trace("Initializing");
    SERVICES = this;
    try {
        loadServices();
    } catch (RuntimeException rex) {
        XLog.getLog(getClass()).fatal(rex.getMessage(), rex);
        throw rex;
    } catch (ServiceException ex) {
        XLog.getLog(getClass()).fatal(ex.getMessage(), ex);
        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();
            }
        });
    }
    log.info("Initialized");
    log.info("Running with JARs for Hadoop version [{0}]", VersionInfo.getVersion());
    log.info("Oozie System ID [{0}] started!", getSystemId());
}
Also used : XLog(org.apache.oozie.util.XLog) Instrumentation(org.apache.oozie.util.Instrumentation) Instrumentable(org.apache.oozie.util.Instrumentable)

Example 3 with Instrumentation

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

the class MemoryLocksService method instrument.

/**
 * Instruments the memory locks service.
 *
 * @param instr instance to instrument the memory locks service to.
 */
public void instrument(Instrumentation instr) {
    final MemoryLocks finalLocks = this.locks;
    instr.addVariable(INSTRUMENTATION_GROUP, "locks", new Instrumentation.Variable<Long>() {

        public Long getValue() {
            return (long) finalLocks.size();
        }
    });
}
Also used : Instrumentation(org.apache.oozie.util.Instrumentation) MemoryLocks(org.apache.oozie.lock.MemoryLocks)

Example 4 with Instrumentation

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

the class TestJobsConcurrencyService method testInstrumentation.

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(ZKUtils.OOZIE_INSTANCE_ID) + "=" + ConfigUtils.getOozieEffectiveUrl();
        assertEquals(servers, instr.getVariables().get("oozie").get("servers").getValue());
    } finally {
        jcs.destroy();
    }
}
Also used : Instrumentation(org.apache.oozie.util.Instrumentation)

Example 5 with Instrumentation

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

the class TestMetricsInstrumentationService method testInstrumentation.

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);
}
Also used : MetricsInstrumentation(org.apache.oozie.util.MetricsInstrumentation) Instrumentation(org.apache.oozie.util.Instrumentation) MetricsInstrumentation(org.apache.oozie.util.MetricsInstrumentation)

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