String systemModeOption = commandLine.getOptionValue(SYSTEM_MODE_OPTION).toUpperCase(); try { status = SYSTEM_MODE.valueOf(systemModeOption);
public Void call() throws Exception { URL url = createURL(RestConstants.ADMIN_STATUS_RESOURCE, Collections.EMPTY_MAP); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); assertEquals(HttpServletResponse.SC_OK, conn.getResponseCode()); assertTrue(conn.getHeaderField("content-type").startsWith(RestConstants.JSON_CONTENT_TYPE)); JSONObject json = (JSONObject) JSONValue.parse(new InputStreamReader(conn.getInputStream())); assertEquals(SYSTEM_MODE.NORMAL.toString(), json.get(JsonTags.OOZIE_SYSTEM_MODE)); return null; } });
String systemModeOption = commandLine.getOptionValue(SYSTEM_MODE_OPTION).toUpperCase(); try { status = SYSTEM_MODE.valueOf(systemModeOption);
JSONObject json = (JSONObject) JSONValue.parse(new InputStreamReader(conn.getInputStream())); assertTrue(json.containsKey(JsonTags.OOZIE_SYSTEM_MODE)); assertEquals(SYSTEM_MODE.NORMAL.toString(), json.get(JsonTags.OOZIE_SYSTEM_MODE)); params.put(RestConstants.ADMIN_SYSTEM_MODE_PARAM, SYSTEM_MODE.SAFEMODE.toString()); url = createURL("/v1/admin/*", RestConstants.ADMIN_STATUS_RESOURCE, params); conn = (HttpURLConnection) url.openConnection(); json = (JSONObject) JSONValue.parse(new InputStreamReader(conn.getInputStream())); assertTrue(json.containsKey(JsonTags.OOZIE_SYSTEM_MODE)); assertEquals(SYSTEM_MODE.SAFEMODE.toString(), json.get(JsonTags.OOZIE_SYSTEM_MODE)); params.put(RestConstants.ADMIN_SYSTEM_MODE_PARAM, SYSTEM_MODE.NORMAL.toString()); url = createURL("/v1/admin/*", RestConstants.ADMIN_STATUS_RESOURCE, params); conn = (HttpURLConnection) url.openConnection(); json = (JSONObject) JSONValue.parse(new InputStreamReader(conn.getInputStream())); assertTrue(json.containsKey(JsonTags.OOZIE_SYSTEM_MODE)); assertEquals(SYSTEM_MODE.NORMAL.toString(), json.get(JsonTags.OOZIE_SYSTEM_MODE));
String systemModeOption = commandLine.getOptionValue(SYSTEM_MODE_OPTION).toUpperCase(); try { status = SYSTEM_MODE.valueOf(systemModeOption);
String systemModeOption = commandLine.getOptionValue(SYSTEM_MODE_OPTION).toUpperCase(); try { status = SYSTEM_MODE.valueOf(systemModeOption);
/** * Create a services. <p> The built in services are initialized. * * @throws ServiceException thrown if any of the built in services could not initialize. */ public Services() throws ServiceException { setOozieHome(); if (SERVICES != null) { XLog log = XLog.getLog(getClass()); log.warn(XLog.OPS, "Previous services singleton active, destroying it"); SERVICES.destroy(); SERVICES = null; } setServiceInternal(XLogService.class, false); setServiceInternal(ConfigurationService.class, true); conf = get(ConfigurationService.class).getConf(); DateUtils.setConf(conf); if (!DateUtils.getOozieProcessingTimeZone().equals(DateUtils.UTC)) { XLog.getLog(getClass()).warn("Oozie configured to work in a timezone other than UTC: {0}", DateUtils.getOozieProcessingTimeZone().getID()); } systemId = ConfigurationService.get(conf, CONF_SYSTEM_ID); if (systemId.length() > MAX_SYSTEM_ID_LEN) { systemId = systemId.substring(0, MAX_SYSTEM_ID_LEN); XLog.getLog(getClass()).warn("System ID [{0}] exceeds maximum length [{1}], trimming", systemId, MAX_SYSTEM_ID_LEN); } setSystemMode(SYSTEM_MODE.valueOf(ConfigurationService.get(conf, CONF_SYSTEM_MODE))); runtimeDir = createRuntimeDir(); }
/** * Create a services. <p> The built in services are initialized. * * @throws ServiceException thrown if any of the built in services could not initialize. */ public Services() throws ServiceException { setOozieHome(); if (SERVICES != null) { XLog log = XLog.getLog(getClass()); log.warn(XLog.OPS, "Previous services singleton active, destroying it"); SERVICES.destroy(); SERVICES = null; } setServiceInternal(XLogService.class, false); setServiceInternal(ConfigurationService.class, true); conf = get(ConfigurationService.class).getConf(); DateUtils.setConf(conf); if (!DateUtils.getOozieProcessingTimeZone().equals(DateUtils.UTC)) { XLog.getLog(getClass()).warn("Oozie configured to work in a timezone other than UTC: {0}", DateUtils.getOozieProcessingTimeZone().getID()); } systemId = ConfigurationService.get(conf, CONF_SYSTEM_ID); if (systemId.length() > MAX_SYSTEM_ID_LEN) { systemId = systemId.substring(0, MAX_SYSTEM_ID_LEN); XLog.getLog(getClass()).warn("System ID [{0}] exceeds maximum length [{1}], trimming", systemId, MAX_SYSTEM_ID_LEN); } setSystemMode(SYSTEM_MODE.valueOf(ConfigurationService.get(conf, CONF_SYSTEM_MODE))); runtimeDir = createRuntimeDir(); }
@Override protected SYSTEM_MODE call(HttpURLConnection conn) throws IOException, OozieClientException { if ((conn.getResponseCode() == HttpURLConnection.HTTP_OK)) { Reader reader = new InputStreamReader(conn.getInputStream(), Charsets.UTF_8); JSONObject json = (JSONObject) JSONValue.parse(reader); return SYSTEM_MODE.valueOf((String) json.get(JsonTags.OOZIE_SYSTEM_MODE)); } else { handleError(conn); } return SYSTEM_MODE.NORMAL; } }
@Override protected SYSTEM_MODE call(HttpURLConnection conn) throws IOException, OozieClientException { if ((conn.getResponseCode() == HttpURLConnection.HTTP_OK)) { Reader reader = new InputStreamReader(conn.getInputStream()); JSONObject json = (JSONObject) JSONValue.parse(reader); return SYSTEM_MODE.valueOf((String) json.get(JsonTags.OOZIE_SYSTEM_MODE)); } else { handleError(conn); } return SYSTEM_MODE.NORMAL; } }
@Override protected SYSTEM_MODE call(HttpURLConnection conn) throws IOException, OozieClientException { if ((conn.getResponseCode() == HttpURLConnection.HTTP_OK)) { Reader reader = new InputStreamReader(conn.getInputStream(), Charsets.UTF_8); JSONObject json = (JSONObject) JSONValue.parse(reader); return SYSTEM_MODE.valueOf((String) json.get(JsonTags.OOZIE_SYSTEM_MODE)); } else { handleError(conn); } return SYSTEM_MODE.NORMAL; } }
@Override protected SYSTEM_MODE call(HttpURLConnection conn) throws IOException, OozieClientException { if ((conn.getResponseCode() == HttpURLConnection.HTTP_OK)) { Reader reader = new InputStreamReader(conn.getInputStream()); JSONObject json = (JSONObject) JSONValue.parse(reader); return SYSTEM_MODE.valueOf((String) json.get(JsonTags.OOZIE_SYSTEM_MODE)); } else { handleError(conn); } return SYSTEM_MODE.NORMAL; } }
@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); }
@SuppressWarnings("unchecked") @Override protected void populateOozieMode(JSONObject json) { json.put(JsonTags.OOZIE_SYSTEM_MODE, Services.get().getSystemMode().toString()); }
@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); }
@SuppressWarnings("unchecked") @Override protected void populateOozieMode(JSONObject json) { json.put(JsonTags.OOZIE_SYSTEM_MODE, Services.get().getSystemMode().toString()); }