use of io.vertx.core.http.HttpServer in project vertx-micrometer-metrics by vert-x3.
the class MetricsExamples method createPartialSnapshot.
public void createPartialSnapshot() {
HttpServer server = vertx.createHttpServer();
MetricsService metricsService = MetricsService.create(server);
JsonObject metrics = metricsService.getMetricsSnapshot();
System.out.println(metrics);
}
use of io.vertx.core.http.HttpServer in project strimzi by strimzi.
the class Session method stop.
/**
* Stop the controller.
*/
@Override
public void stop(Future<Void> stopFuture) throws Exception {
this.stopped = true;
vertx.executeBlocking(blockingResult -> {
long t0 = System.currentTimeMillis();
long timeout = 120_000L;
LOGGER.info("Stopping");
LOGGER.debug("Stopping kube watch");
topicCmWatch.close();
LOGGER.debug("Stopping zk watches");
topicsWatcher.stop();
while (controller.isWorkInflight()) {
if (System.currentTimeMillis() - t0 > timeout) {
LOGGER.error("Timeout waiting for inflight work to finish");
break;
}
LOGGER.debug("Waiting for inflight work to finish");
try {
Thread.sleep(1_000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
LOGGER.debug("Stopping kafka {}", kafka);
kafka.stop();
try {
LOGGER.debug("Disconnecting from zookeeper {}", zk);
zk.disconnect();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
LOGGER.debug("Closing AdminClient {}", adminClient);
adminClient.close(timeout - (System.currentTimeMillis() - t0), TimeUnit.MILLISECONDS);
HttpServer healthServer = this.healthServer;
if (healthServer != null) {
healthServer.close();
}
LOGGER.info("Stopped");
blockingResult.complete();
}, stopFuture);
}
use of io.vertx.core.http.HttpServer in project vertx-sync by vert-x3.
the class TestVerticle method testFiberHandler.
@Suspendable
protected void testFiberHandler() {
HttpServer server = vertx.createHttpServer(new HttpServerOptions().setPort(8080));
server.requestHandler(fiberHandler(req -> {
String res = awaitResult(h -> ai.methodWithParamsAndHandlerNoReturn("oranges", 23, h));
assertEquals("oranges23", res);
req.response().end();
}));
server.listen(res -> {
assertTrue(res.succeeded());
HttpClient client = vertx.createHttpClient(new HttpClientOptions().setDefaultPort(8080));
client.getNow("/somepath", resp -> {
assertTrue(resp.statusCode() == 200);
client.close();
server.close(res2 -> {
complete();
});
});
});
}
use of io.vertx.core.http.HttpServer in project vertx-zero by silentbalanceyh.
the class ZeroSockAgent method start.
@Override
public void start() {
// Server Listen
ZeroAtomic.SOCK_OPTS.forEach((port, option) -> {
/**
* Create Server *
*/
final HttpServer server = this.vertx.createHttpServer(option);
final Router router = Router.router(this.vertx);
/**
* Handler *
*/
server.requestHandler(router::accept).listen();
});
}
use of io.vertx.core.http.HttpServer in project vertx-zero by silentbalanceyh.
the class ZeroHttpAgent method start.
@Override
public void start() {
/**
* 1.Call router hub to mount commont *
*/
final Axis<Router> routerAxiser = Fn.poolThread(Pool.ROUTERS, () -> Instance.instance(RouterAxis.class));
/**
* 2.Call route hub to mount defined *
*/
final Axis<Router> axiser = Fn.poolThread(Pool.EVENTS, () -> Instance.instance(EventAxis.class));
/**
* 3.Call route hub to mount walls *
*/
final Axis<Router> wallAxiser = Fn.poolThread(Pool.WALLS, () -> Instance.instance(WallAxis.class, this.vertx));
/**
* 4.Call route hub to mount filters *
*/
final Axis<Router> filterAxiser = Fn.poolThread(Pool.FILTERS, () -> Instance.instance(FilterAxis.class));
/**
* 5.Get the default HttpServer Options *
*/
ZeroAtomic.HTTP_OPTS.forEach((port, option) -> {
/**
* 5.1.Single server processing *
*/
final HttpServer server = this.vertx.createHttpServer(option);
/**
* 5.2. Build router with current option *
*/
final Router router = Router.router(this.vertx);
/**
* 5.3. Mount data to router *
*/
// Router
routerAxiser.mount(router);
// Wall
wallAxiser.mount(router);
// Event
axiser.mount(router);
// Filter
filterAxiser.mount(router);
/**
* 5.4.Listen for router on the server *
*/
server.requestHandler(router::accept).listen();
{
// 5.5. Log output
this.registryServer(option, router);
}
});
}
Aggregations