use of io.strimzi.kafka.bridge.AdminClientEndpoint in project strimzi-kafka-bridge by strimzi.
the class HttpBridge method start.
@Override
public void start(Promise<Void> startPromise) {
RouterBuilder.create(vertx, "openapi.json", ar -> {
if (ar.succeeded()) {
RouterBuilder routerBuilder = ar.result();
routerBuilder.operation(this.SEND.getOperationId().toString()).handler(this.SEND);
routerBuilder.operation(this.SEND_TO_PARTITION.getOperationId().toString()).handler(this.SEND_TO_PARTITION);
routerBuilder.operation(this.CREATE_CONSUMER.getOperationId().toString()).handler(this.CREATE_CONSUMER);
routerBuilder.operation(this.DELETE_CONSUMER.getOperationId().toString()).handler(this.DELETE_CONSUMER);
routerBuilder.operation(this.SUBSCRIBE.getOperationId().toString()).handler(this.SUBSCRIBE);
routerBuilder.operation(this.UNSUBSCRIBE.getOperationId().toString()).handler(this.UNSUBSCRIBE);
routerBuilder.operation(this.LIST_SUBSCRIPTIONS.getOperationId().toString()).handler(this.LIST_SUBSCRIPTIONS);
routerBuilder.operation(this.ASSIGN.getOperationId().toString()).handler(this.ASSIGN);
routerBuilder.operation(this.POLL.getOperationId().toString()).handler(this.POLL);
routerBuilder.operation(this.COMMIT.getOperationId().toString()).handler(this.COMMIT);
routerBuilder.operation(this.SEEK.getOperationId().toString()).handler(this.SEEK);
routerBuilder.operation(this.SEEK_TO_BEGINNING.getOperationId().toString()).handler(this.SEEK_TO_BEGINNING);
routerBuilder.operation(this.SEEK_TO_END.getOperationId().toString()).handler(this.SEEK_TO_END);
routerBuilder.operation(this.LIST_TOPICS.getOperationId().toString()).handler(this.LIST_TOPICS);
routerBuilder.operation(this.GET_TOPIC.getOperationId().toString()).handler(this.GET_TOPIC);
routerBuilder.operation(this.LIST_PARTITIONS.getOperationId().toString()).handler(this.LIST_PARTITIONS);
routerBuilder.operation(this.GET_PARTITION.getOperationId().toString()).handler(this.GET_PARTITION);
routerBuilder.operation(this.GET_OFFSETS.getOperationId().toString()).handler(this.GET_OFFSETS);
routerBuilder.operation(this.HEALTHY.getOperationId().toString()).handler(this.HEALTHY);
routerBuilder.operation(this.READY.getOperationId().toString()).handler(this.READY);
routerBuilder.operation(this.OPENAPI.getOperationId().toString()).handler(this.OPENAPI);
routerBuilder.operation(this.INFO.getOperationId().toString()).handler(this.INFO);
if (this.bridgeConfig.getHttpConfig().isCorsEnabled()) {
routerBuilder.rootHandler(getCorsHandler());
}
this.router = routerBuilder.createRouter();
// handling validation errors and not existing endpoints
this.router.errorHandler(HttpResponseStatus.BAD_REQUEST.code(), this::errorHandler);
this.router.errorHandler(HttpResponseStatus.NOT_FOUND.code(), this::errorHandler);
this.router.route("/metrics").handler(this::metricsHandler);
log.info("Starting HTTP-Kafka bridge verticle...");
this.httpBridgeContext = new HttpBridgeContext<>();
AdminClientEndpoint adminClientEndpoint = new HttpAdminClientEndpoint(this.vertx, this.bridgeConfig, this.httpBridgeContext);
this.httpBridgeContext.setAdminClientEndpoint(adminClientEndpoint);
adminClientEndpoint.open();
this.bindHttpServer(startPromise);
} else {
log.error("Failed to create OpenAPI router factory");
startPromise.fail(ar.cause());
}
});
}
use of io.strimzi.kafka.bridge.AdminClientEndpoint in project strimzi-kafka-bridge by strimzi.
the class HttpBridge method processAdminClient.
private void processAdminClient(RoutingContext routingContext) {
AdminClientEndpoint adminClientEndpoint = this.httpBridgeContext.getAdminClientEndpoint();
if (adminClientEndpoint != null) {
adminClientEndpoint.handle(new HttpEndpoint(routingContext));
} else {
HttpBridgeError error = new HttpBridgeError(HttpResponseStatus.INTERNAL_SERVER_ERROR.code(), "The AdminClient was not found.");
HttpUtils.sendResponse(routingContext, HttpResponseStatus.INTERNAL_SERVER_ERROR.code(), BridgeContentType.KAFKA_JSON, error.toJson().toBuffer());
}
}
Aggregations