/** * Test for the availability of the web server * @return true if the web server is started, false otherwise */ public boolean isAlive() { return webServer != null && webServer.isStarted(); }
/** * Test for the availability of the web server * @return true if the web server is started, false otherwise */ public boolean isAlive() { return webServer != null && webServer.isStarted(); }
@Override protected void stopServer() { if((server != null) && server.isStarted()) { try { server.stop(); server = null; LOG.info("Thrift HTTP server has been stopped"); } catch (Exception e) { LOG.error("Error stopping HTTP server: ", e); } } }
@Override public void stop() { if (server.isStarted()) { LOGGER.log(Level.FINE, "Stopping JettyTestContainer..."); try { this.server.stop(); } catch (Exception ex) { LOGGER.log(Level.WARNING, "Error Stopping JettyTestContainer...", ex); } } else { LOGGER.log(Level.WARNING, "Ignoring stop request - JettyTestContainer is already stopped."); } } }
public static synchronized void start() throws Exception{ if(!(server.isStarted() || server.isRunning())){ server.start(); } }
public int getPort() { if (!jetty.isStarted()) { throw new IllegalStateException("Jetty server not started"); } return ((ServerConnector) jetty.getConnectors()[0]).getLocalPort(); }
@Override public void run() { if (server.isStarted()) { try { server.stop(); eventHubHandler.close(); } catch (Exception e) { e.printStackTrace(); } } } },"Stop Jetty Hook"));
@Override synchronized public void startIfNotRunning() { if (!server.isStarted() && !server.isStarting()) { log.info("Starting Jetty server... "); try { server.start(); } catch (Exception ex) { log.severe("Couldn't start Jetty server: " + ex); throw new RuntimeException(ex); } } }
public int getSecurePort() { if (!jetty.isStarted()) { throw new IllegalStateException("Jetty server not started"); } return ((ServerConnector) jetty.getConnectors()[1]).getLocalPort(); }
public static boolean isRunning(){ return server.isRunning() || server.isStarted(); }
@Override public void start() { jettyServer = new Server(); //We can use Contexts etc if we have many urls to handle. For one url, //specifying a handler directly is the most efficient. HttpConfiguration httpConfiguration = new HttpConfiguration(); ServerConnector connector = new ServerConnector(jettyServer, new HttpConnectionFactory(httpConfiguration)); connector.setReuseAddress(true); connector.setPort(port); jettyServer.addConnector(connector); jettyServer.setHandler(new HTTPMetricsHandler()); try { jettyServer.start(); while (!jettyServer.isStarted()) { Thread.sleep(500); } } catch (Exception ex) { LOG.error("Error starting Jetty. JSON Metrics may not be available.", ex); } }
@Override public void start() { if (server.isStarted()) { LOGGER.log(Level.WARNING, "Ignoring start request - JettyTestContainer is already started."); } else { LOGGER.log(Level.FINE, "Starting JettyTestContainer..."); try { server.start(); if (baseUri.getPort() == 0) { int port = 0; for (final Connector connector : server.getConnectors()) { if (connector instanceof ServerConnector) { port = ((ServerConnector) connector).getLocalPort(); break; } } baseUri = UriBuilder.fromUri(baseUri).port(port).build(); LOGGER.log(Level.INFO, "Started JettyTestContainer at the base URI " + baseUri); } } catch (Exception e) { throw new TestContainerException(e); } } }
void start() throws Exception { boolean success = false; try { assert armeriaServer != null; server = serverFactory.apply(armeriaServer.config().blockingTaskExecutor()); connector = new ArmeriaConnector(server); server.addConnector(connector); if (!server.isStarted()) { logger.info("Starting an embedded Jetty: {}", server); server.start(); startedServer = true; } else { startedServer = false; } success = true; } finally { if (!success) { server = null; connector = null; } } }
@Override public Status getStatus() { if (ready) { return Status.OPERATIONAL; } if (server.isStarted()) { ready = true; writeTimeToFile("readyAt"); } return ready ? Status.OPERATIONAL : Status.DOWN; }
if (httpSrv != null) { if (httpSrv.isStarted()) ctx.ports().deregisterPorts(getClass());
@Override synchronized public int addConnector(String host, int port) throws IOException { SocketConnector connector = new SocketConnector(); connector.setHost(host); connector.setPort(port); // Open immediately so we can get the assigned local port connector.open(); // Only add if open() succeeded server.addConnector(connector); // stats the connector if the server is started (server starts all connectors when started) if (server.isStarted()) { try { connector.start(); } catch (Exception ex) { log.severe("Couldn't start connector: " + connector + " " + ex); throw new RuntimeException(ex); } } return connector.getLocalPort(); }
if (!httpServer.isStarted()) { logger.info("Attempting to start HTTP service on port ({}) at bind-address ({})...", this.port, this.bindAddress);
httpSrv.start(); if (httpSrv.isStarted()) { for (Connector con : httpSrv.getConnectors()) { int connPort = ((NetworkConnector)con).getPort();
@Override synchronized public void startIfNotRunning() { if (!server.isStarted() && !server.isStarting()) { log.info("Starting Jetty server... "); try { server.start(); } catch (Exception ex) { log.severe("Couldn't start Jetty server: " + ex); throw new RuntimeException(ex); } } }
public static boolean isAlive() { return server.isRunning() || server.isStarted() || server.isStarting(); }