Search in sources :

Example 1 with SparkHttpServiceHandler

use of io.cdap.cdap.api.spark.service.SparkHttpServiceHandler in project cdap by caskdata.

the class SparkHttpServiceServer method createDelegatorContexts.

@Override
protected List<SparkHandlerDelegatorContext> createDelegatorContexts() throws Exception {
    List<SparkHandlerDelegatorContext> contexts = new ArrayList<>();
    InstantiatorFactory instantiatorFactory = new InstantiatorFactory(false);
    for (SparkHttpServiceHandlerSpecification spec : context.getSpecification().getHandlers()) {
        Class<?> handlerClass = getProgram().getClassLoader().loadClass(spec.getClassName());
        @SuppressWarnings("unchecked") TypeToken<SparkHttpServiceHandler> type = TypeToken.of((Class<SparkHttpServiceHandler>) handlerClass);
        MetricsContext handlerMetricsContext = runtimeContext.getProgramMetrics().childContext(Constants.Metrics.Tag.HANDLER, handlerClass.getSimpleName());
        contexts.add(new SparkHandlerDelegatorContext(type, instantiatorFactory, spec, runtimeContext.getProgramMetrics(), handlerMetricsContext));
    }
    return contexts;
}
Also used : InstantiatorFactory(io.cdap.cdap.common.lang.InstantiatorFactory) SparkHttpServiceHandler(io.cdap.cdap.api.spark.service.SparkHttpServiceHandler) MetricsContext(io.cdap.cdap.api.metrics.MetricsContext) ArrayList(java.util.ArrayList) SparkHttpServiceHandlerSpecification(io.cdap.cdap.api.spark.SparkHttpServiceHandlerSpecification)

Aggregations

MetricsContext (io.cdap.cdap.api.metrics.MetricsContext)1 SparkHttpServiceHandlerSpecification (io.cdap.cdap.api.spark.SparkHttpServiceHandlerSpecification)1 SparkHttpServiceHandler (io.cdap.cdap.api.spark.service.SparkHttpServiceHandler)1 InstantiatorFactory (io.cdap.cdap.common.lang.InstantiatorFactory)1 ArrayList (java.util.ArrayList)1