Search in sources :

Example 1 with TransformService

use of com.thinkbiganalytics.spark.service.TransformService in project kylo by Teradata.

the class KyloShellConfig method transformService.

/**
 * Gets the transform service.
 *
 * @param transformScriptClass      the transform script class
 * @param engine                    the Spark script engine
 * @param sparkContextService       the Spark context service
 * @param tracker                   the transform job tracker
 * @param datasourceProviderFactory the data source provider factory
 * @param profiler                  the profiler
 * @return the transform service
 */
@Bean
public TransformService transformService(final Class<? extends TransformScript> transformScriptClass, final SparkScriptEngine engine, final SparkContextService sparkContextService, final JobTrackerService tracker, final DatasourceProviderFactory datasourceProviderFactory, final Profiler profiler, final DataValidator validator, final FileSystem fileSystem, final DataSetConverterService converterService, final KyloCatalogClientBuilder kyloCatalogClientBuilder, final CatalogDataSetProviderFactory catalogDataSetProviderFactory) {
    final TransformService service = new TransformService(transformScriptClass, engine, sparkContextService, tracker, converterService, kyloCatalogClientBuilder);
    service.setDatasourceProviderFactory(datasourceProviderFactory);
    service.setFileSystem(fileSystem);
    service.setProfiler(profiler);
    service.setValidator(validator);
    service.setCatalogDataSetProviderFactory(catalogDataSetProviderFactory);
    return service;
}
Also used : TransformService(com.thinkbiganalytics.spark.service.TransformService) Bean(org.springframework.context.annotation.Bean)

Example 2 with TransformService

use of com.thinkbiganalytics.spark.service.TransformService in project kylo by Teradata.

the class KyloShellConfig method jerseyConfig.

/**
 * Gets the resource configuration for setting up Jersey.
 *
 * @return the Jersey configuration
 */
@Bean
public ResourceConfig jerseyConfig(final TransformService transformService, final FileSystem fileSystem, final SparkLocatorService sparkLocatorService, final SparkUtilityService sparkUtilityService) {
    Validate.notNull(fileSystem);
    Validate.notNull(transformService);
    Validate.notNull(sparkLocatorService);
    Validate.notNull(sparkUtilityService);
    final ResourceConfig config = new ResourceConfig(ApiListingResource.class, SwaggerSerializers.class);
    config.packages("com.thinkbiganalytics.spark.rest");
    config.register(new AbstractBinder() {

        @Override
        protected void configure() {
            bind(fileSystem).to(FileSystem.class);
            bind(transformService).to(TransformService.class);
            bind(sparkLocatorService).to(SparkLocatorService.class);
            bind(sparkUtilityService).to(SparkUtilityService.class);
        }
    });
    return config;
}
Also used : AbstractBinder(org.glassfish.hk2.utilities.binding.AbstractBinder) FileSystem(org.apache.hadoop.fs.FileSystem) SparkUtilityService(com.thinkbiganalytics.spark.service.SparkUtilityService) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) TransformService(com.thinkbiganalytics.spark.service.TransformService) SparkLocatorService(com.thinkbiganalytics.spark.service.SparkLocatorService) Bean(org.springframework.context.annotation.Bean)

Example 3 with TransformService

use of com.thinkbiganalytics.spark.service.TransformService in project kylo by Teradata.

the class SparkShellTransformControllerTest method createWithScriptException.

/**
 * Verify response if a script exception is thrown.
 */
@Test
public void createWithScriptException() throws Exception {
    // Create transform objects
    TransformRequest request = new TransformRequest();
    request.setScript("sqlContext.sql(\"SELECT * FROM invalid\")");
    TransformService transformService = Mockito.mock(TransformService.class);
    Mockito.when(transformService.execute(request)).thenThrow(new ScriptException("Invalid script"));
    // Test script exception
    SparkShellTransformController controller = new SparkShellTransformController();
    controller.transformService = transformService;
    Response response = controller.create(request);
    Assert.assertEquals(Response.Status.INTERNAL_SERVER_ERROR, response.getStatusInfo());
    TransformResponse entity = (TransformResponse) response.getEntity();
    Assert.assertEquals("Invalid script", entity.getMessage());
    Assert.assertEquals(TransformResponse.Status.ERROR, entity.getStatus());
}
Also used : TransformResponse(com.thinkbiganalytics.spark.rest.model.TransformResponse) Response(javax.ws.rs.core.Response) ScriptException(javax.script.ScriptException) TransformResponse(com.thinkbiganalytics.spark.rest.model.TransformResponse) TransformService(com.thinkbiganalytics.spark.service.TransformService) TransformRequest(com.thinkbiganalytics.spark.rest.model.TransformRequest) Test(org.junit.Test)

Example 4 with TransformService

use of com.thinkbiganalytics.spark.service.TransformService in project kylo by Teradata.

the class SparkShellApp method jerseyConfig.

/**
 * Gets the resource configuration for setting up Jersey.
 *
 * @return the Jersey configuration
 */
@Bean
public ResourceConfig jerseyConfig(final TransformService transformService, final FileSystem fileSystem, final SparkLocatorService sparkLocatorService) {
    final ResourceConfig config = new ResourceConfig(ApiListingResource.class, SwaggerSerializers.class);
    config.packages("com.thinkbiganalytics.spark.rest");
    config.register(new AbstractBinder() {

        @Override
        protected void configure() {
            bind(fileSystem).to(FileSystem.class);
            bind(transformService).to(TransformService.class);
            bind(sparkLocatorService).to(SparkLocatorService.class);
        }
    });
    return config;
}
Also used : AbstractBinder(org.glassfish.hk2.utilities.binding.AbstractBinder) FileSystem(org.apache.hadoop.fs.FileSystem) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) TransformService(com.thinkbiganalytics.spark.service.TransformService) SparkLocatorService(com.thinkbiganalytics.spark.service.SparkLocatorService) Bean(org.springframework.context.annotation.Bean)

Example 5 with TransformService

use of com.thinkbiganalytics.spark.service.TransformService in project kylo by Teradata.

the class SparkShellApp method transformService.

/**
 * Gets the transform service.
 *
 * @param transformScriptClass      the transform script class
 * @param engine                    the Spark script engine
 * @param sparkContextService       the Spark context service
 * @param tracker                   the transform job tracker
 * @param datasourceProviderFactory the data source provider factory
 * @param profiler                  the profiler
 * @return the transform service
 */
@Bean
public TransformService transformService(final Class<? extends TransformScript> transformScriptClass, final SparkScriptEngine engine, final SparkContextService sparkContextService, final JobTrackerService tracker, final DatasourceProviderFactory datasourceProviderFactory, final Profiler profiler, final DataValidator validator, final FileSystem fileSystem) {
    final TransformService service = new TransformService(transformScriptClass, engine, sparkContextService, tracker);
    service.setDatasourceProviderFactory(datasourceProviderFactory);
    service.setFileSystem(fileSystem);
    service.setProfiler(profiler);
    service.setValidator(validator);
    return service;
}
Also used : TransformService(com.thinkbiganalytics.spark.service.TransformService) Bean(org.springframework.context.annotation.Bean)

Aggregations

TransformService (com.thinkbiganalytics.spark.service.TransformService)8 Bean (org.springframework.context.annotation.Bean)5 TransformResponse (com.thinkbiganalytics.spark.rest.model.TransformResponse)3 Response (javax.ws.rs.core.Response)3 Test (org.junit.Test)3 TransformRequest (com.thinkbiganalytics.spark.rest.model.TransformRequest)2 SparkLocatorService (com.thinkbiganalytics.spark.service.SparkLocatorService)2 FileSystem (org.apache.hadoop.fs.FileSystem)2 AbstractBinder (org.glassfish.hk2.utilities.binding.AbstractBinder)2 ResourceConfig (org.glassfish.jersey.server.ResourceConfig)2 TransformJob (com.thinkbiganalytics.spark.metadata.TransformJob)1 SparkUtilityService (com.thinkbiganalytics.spark.service.SparkUtilityService)1 ScriptException (javax.script.ScriptException)1