Search in sources :

Example 1 with SYSTEM_MODE

use of org.apache.oozie.client.OozieClient.SYSTEM_MODE in project oozie by apache.

the class OozieCLI method adminCommand.

private void adminCommand(CommandLine commandLine) throws OozieCLIException {
    XOozieClient wc = createXOozieClient(commandLine);
    List<String> options = new ArrayList<String>();
    for (Option option : commandLine.getOptions()) {
        options.add(option.getOpt());
    }
    try {
        SYSTEM_MODE status = SYSTEM_MODE.NORMAL;
        if (options.contains(VERSION_OPTION)) {
            System.out.println("Oozie server build version: " + wc.getServerBuildVersion());
        } else if (options.contains(SYSTEM_MODE_OPTION)) {
            String systemModeOption = commandLine.getOptionValue(SYSTEM_MODE_OPTION).toUpperCase();
            try {
                status = SYSTEM_MODE.valueOf(systemModeOption);
            } catch (Exception e) {
                throw new OozieCLIException("Invalid input provided for option: " + SYSTEM_MODE_OPTION + " value given :" + systemModeOption + " Expected values are: NORMAL/NOWEBSERVICE/SAFEMODE ");
            }
            wc.setSystemMode(status);
            System.out.println("System mode: " + status);
        } else if (options.contains(STATUS_OPTION)) {
            status = wc.getSystemMode();
            System.out.println("System mode: " + status);
        } else if (options.contains(UPDATE_SHARELIB_OPTION)) {
            System.out.println(wc.updateShareLib());
        } else if (options.contains(LIST_SHARELIB_LIB_OPTION)) {
            String sharelibKey = null;
            if (commandLine.getArgList().size() > 0) {
                sharelibKey = (String) commandLine.getArgList().get(0);
            }
            System.out.println(wc.listShareLib(sharelibKey));
        } else if (options.contains(QUEUE_DUMP_OPTION)) {
            List<String> list = wc.getQueueDump();
            if (list != null && list.size() != 0) {
                for (String str : list) {
                    System.out.println(str);
                }
            } else {
                System.out.println("QueueDump is null!");
            }
        } else if (options.contains(AVAILABLE_SERVERS_OPTION)) {
            Map<String, String> availableOozieServers = new TreeMap<String, String>(wc.getAvailableOozieServers());
            for (Map.Entry<String, String> ent : availableOozieServers.entrySet()) {
                System.out.println(ent.getKey() + " : " + ent.getValue());
            }
        } else if (options.contains(SERVER_CONFIGURATION_OPTION)) {
            Map<String, String> serverConfig = new TreeMap<String, String>(wc.getServerConfiguration());
            for (Map.Entry<String, String> ent : serverConfig.entrySet()) {
                System.out.println(ent.getKey() + " : " + ent.getValue());
            }
        } else if (options.contains(SERVER_OS_ENV_OPTION)) {
            Map<String, String> osEnv = new TreeMap<String, String>(wc.getOSEnv());
            for (Map.Entry<String, String> ent : osEnv.entrySet()) {
                System.out.println(ent.getKey() + " : " + ent.getValue());
            }
        } else if (options.contains(SERVER_JAVA_SYSTEM_PROPERTIES_OPTION)) {
            Map<String, String> javaSysProps = new TreeMap<String, String>(wc.getJavaSystemProperties());
            for (Map.Entry<String, String> ent : javaSysProps.entrySet()) {
                System.out.println(ent.getKey() + " : " + ent.getValue());
            }
        } else if (options.contains(METRICS_OPTION)) {
            OozieClient.Metrics metrics = wc.getMetrics();
            if (metrics == null) {
                System.out.println("Metrics are unavailable.  Try Instrumentation (-" + INSTRUMENTATION_OPTION + ") instead");
            } else {
                printMetrics(metrics);
            }
        } else if (options.contains(INSTRUMENTATION_OPTION)) {
            OozieClient.Instrumentation instrumentation = wc.getInstrumentation();
            if (instrumentation == null) {
                System.out.println("Instrumentation is unavailable.  Try Metrics (-" + METRICS_OPTION + ") instead");
            } else {
                printInstrumentation(instrumentation);
            }
        } else if (options.contains(PURGE_OPTION)) {
            String purgeOptions = commandLine.getOptionValue(PURGE_OPTION);
            System.out.println(wc.purgeCommand(purgeOptions));
        }
    } catch (OozieClientException ex) {
        throw new OozieCLIException(ex.toString(), ex);
    }
}
Also used : SYSTEM_MODE(org.apache.oozie.client.OozieClient.SYSTEM_MODE) OozieClientException(org.apache.oozie.client.OozieClientException) XOozieClient(org.apache.oozie.client.XOozieClient) ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap) ParseException(org.apache.commons.cli.ParseException) SAXException(org.xml.sax.SAXException) DOMException(org.w3c.dom.DOMException) OozieClientException(org.apache.oozie.client.OozieClientException) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) OozieClient(org.apache.oozie.client.OozieClient) AuthOozieClient(org.apache.oozie.client.AuthOozieClient) XOozieClient(org.apache.oozie.client.XOozieClient) Option(org.apache.commons.cli.Option) List(java.util.List) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 2 with SYSTEM_MODE

use of org.apache.oozie.client.OozieClient.SYSTEM_MODE in project oozie by apache.

the class V1AdminServlet method setOozieMode.

/*
     * (non-Javadoc)
     *
     * @see
     * org.apache.oozie.servlet.BaseAdminServlet#setOozieMode(javax.servlet.
     * http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
     * java.lang.String)
     */
@Override
protected void setOozieMode(HttpServletRequest request, HttpServletResponse response, String resourceName) throws XServletException {
    SYSTEM_MODE sysMode = SYSTEM_MODE.valueOf(request.getParameter(modeTag));
    Services.get().setSystemMode(sysMode);
    response.setStatus(HttpServletResponse.SC_OK);
}
Also used : SYSTEM_MODE(org.apache.oozie.client.OozieClient.SYSTEM_MODE)

Example 3 with SYSTEM_MODE

use of org.apache.oozie.client.OozieClient.SYSTEM_MODE in project oozie by apache.

the class V0AdminServlet method setOozieMode.

/*
     * (non-Javadoc)
     *
     * @see
     * org.apache.oozie.servlet.BaseAdminServlet#setOozieMode(javax.servlet.
     * http.HttpServletRequest, javax.servlet.http.HttpServletResponse,
     * java.lang.String)
     */
@Override
protected void setOozieMode(HttpServletRequest request, HttpServletResponse response, String resourceName) throws XServletException {
    boolean safeMode = Boolean.parseBoolean(request.getParameter(modeTag));
    SYSTEM_MODE sysMode = safeMode ? SYSTEM_MODE.NOWEBSERVICE : SYSTEM_MODE.NORMAL;
    Services.get().setSystemMode(sysMode);
    response.setStatus(HttpServletResponse.SC_OK);
}
Also used : SYSTEM_MODE(org.apache.oozie.client.OozieClient.SYSTEM_MODE)

Aggregations

SYSTEM_MODE (org.apache.oozie.client.OozieClient.SYSTEM_MODE)3 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 Option (org.apache.commons.cli.Option)1 ParseException (org.apache.commons.cli.ParseException)1 AuthOozieClient (org.apache.oozie.client.AuthOozieClient)1 OozieClient (org.apache.oozie.client.OozieClient)1 OozieClientException (org.apache.oozie.client.OozieClientException)1 XOozieClient (org.apache.oozie.client.XOozieClient)1 DOMException (org.w3c.dom.DOMException)1 NodeList (org.w3c.dom.NodeList)1 SAXException (org.xml.sax.SAXException)1