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;
}
Aggregations