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