/** * Gets the controller. * * @return the controller */ public static Controller getController() { if (controller == null) { controller = new Controller(); } return controller; }
/** * <p>stop</p> * * @return a int. */ public int stop() { return invokeOperation("stop"); }
configureLog4j(); Controller c = new Controller(); System.exit(0); } else if (argv[i].equals("-t")) { c.setHttpRequestReadTimeout(Integer.parseInt(argv[i + 1]) * 1000); i++; } else if (argv[i].equals("-v")) { c.setVerbose(true); } else if (argv[i].equals("-u")) { c.setInvokeUrl(argv[i + 1]); i++; } else if (i != (argv.length - 1)) { c.setAuthenticator(c.createAuthenticatorUsingConfigCredentials()); c.start(); } else if ("stop".equals(command)) { System.exit(c.stop()); } else if ("status".equals(command)) { System.exit(c.status()); } else if ("check".equals(command)) { System.exit(c.check()); } else if ("exit".equals(command)) { System.exit(c.exit()); } else { System.err.println("Invalid command \"" + command + "\".");
Controller c = new Controller(); System.exit(0); } else if (argv[i].equals("-p")) { c.setPid(argv[i + 1]); i++; } else if (argv[i].equals("-t")) { c.setRmiHandshakeTimeout(Integer.parseInt(argv[i + 1]) * 1000); i++; } else if (argv[i].equals("-u")) { c.setJmxRmiUrl(argv[i + 1]); i++; } else if (argv[i].equals("-v")) { c.setVerbose(true); } else if (i != (argv.length - 1)) { System.err.println("Invalid command-line option: \"" + argv[i] + "\". Use \"-h\" option for help."); c.start(); } else if ("stop".equals(command)) { System.exit(c.stop()); } else if ("status".equals(command)) { System.exit(c.status()); } else if ("check".equals(command)) { System.exit(c.check()); } else if ("dumpThreads".equals(command)) { System.exit(c.dumpThreads()); } else if ("exit".equals(command)) { System.exit(c.exit()); } else {
int invokeOperation(String operation) { Authenticator.setDefault(getAuthenticator()); String urlString = getInvokeUrl() + "&operation=" + operation; try { URL invoke = new URL(urlString); HttpURLConnection connection = (HttpURLConnection) invoke.openConnection(); connection.setReadTimeout(getHttpRequestReadTimeout()); InputStream in = connection.getInputStream(); int ch; while ((ch = in.read()) != -1) { System.out.write((char) ch); } in.close(); System.out.println(""); System.out.flush(); } catch (final ConnectException e) { LogUtils.errorf(this, e, "error when attempting to fetch URL \"%s\"", urlString); if (isVerbose()) { System.out.println(e.getMessage() + " when attempting to fetch URL \"" + urlString + "\""); } return 1; } catch (final Throwable t) { LogUtils.errorf(this, t, "error invoking %s operation", operation); System.out.println("error invoking " + operation + " operation"); return 1; } return 0; }
Authenticator.setDefault(getAuthenticator()); statusGetter.setVerbose(isVerbose()); String url = getInvokeUrl() + "&operation=status"; try { statusGetter.setInvokeURL(new URL(url));
/** * Checks if is OpenNMS running. * * @return true, if is OpenNMS running */ protected boolean isOpennmsRunning() { try { return ControllerUtils.getController().status() == 0; } catch (Exception e) { log("Warning: can't retrieve OpeNNMS status (assuming it is not running).\n"); return false; } } }
statusResults = (List<String>)m_controller.doInvokeOperation("status"); } catch (Throwable e) { LOG.debug("Could not fetch status: " + e.getMessage()); if (m_controller.isVerbose()) { running++; if (m_controller.isVerbose()) { System.out.println("OpenNMS." + daemon + spaces.substring(daemon.length()) + ": " + status);
/** * Checks if is OpenNMS running. * * @return true, if is OpenNMS running */ protected boolean isOpennmsRunning() { try { return ControllerUtils.getController().status() == 0; } catch (Exception e) { log("Warning: can't retrieve OpeNNMS status (assuming it is not running).\n"); return false; } }
/** * <p>exit</p> * * @return a int. */ public int exit() { return invokeOperation("doSystemExit"); }
/** * <p>dumpThreads</p> * * @return a int. */ public int dumpThreads() { return invokeOperation("dumpThreads"); }
/** * <p>stop</p> * * @return a int. */ public int stop() { return invokeOperation("stop"); }
/** * <p>exit</p> * * @return a int. */ public int exit() { return invokeOperation("doSystemExit"); }