Search in sources :

Example 1 with PentahoCacheManagerImpl

use of org.pentaho.caching.impl.PentahoCacheManagerImpl in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceRealTest method testServiceTransKeepsRunningWhenDataServiceIsNotUserDefined.

@Test
public void testServiceTransKeepsRunningWhenDataServiceIsNotUserDefined() throws Exception {
    TransMeta transMeta = new TransMeta(getClass().getResource("/GenerateOneMillion.ktr").getPath());
    DataServiceMeta dataServiceMeta = new DataServiceMeta(transMeta);
    dataServiceMeta.setName("table");
    dataServiceMeta.setStepname("Delay Row");
    dataServiceMeta.setUserDefined(false);
    PentahoCacheSystemConfiguration systemConfiguration = new PentahoCacheSystemConfiguration();
    systemConfiguration.setData(new HashMap<>());
    PentahoCacheManagerImpl pentahoCacheManager = new PentahoCacheManagerImpl(systemConfiguration, new HeapCacheProvidingService());
    ServiceCacheFactory cacheFactory = new ServiceCacheFactory(pentahoCacheManager, Executors.newSingleThreadExecutor());
    DataServiceContext dataServiceContext = new DataServiceContext(singletonList(cacheFactory), emptyList(), pentahoCacheManager, new UIFactory(), new LogChannel(""));
    SQL countSql = new SQL("select count(*) from table");
    DataServiceExecutor countExecutor = new DataServiceExecutor.Builder(countSql, dataServiceMeta, dataServiceContext).build();
    countExecutor.executeQuery();
    SQL limitSql = new SQL("select field1,field2 from table limit 5");
    DataServiceExecutor limitExecutor = new DataServiceExecutor.Builder(limitSql, dataServiceMeta, dataServiceContext).build();
    limitExecutor.executeQuery();
    limitExecutor.waitUntilFinished();
    assertTrue(countExecutor.getGenTrans().isRunning());
    assertTrue(countExecutor.getServiceTrans().isRunning());
    countExecutor.getServiceTrans().stopAll();
}
Also used : HeapCacheProvidingService(org.pentaho.caching.ri.HeapCacheProvidingService) UIFactory(org.pentaho.di.trans.dataservice.ui.UIFactory) DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta) DataServiceExecutor(org.pentaho.di.trans.dataservice.DataServiceExecutor) TransMeta(org.pentaho.di.trans.TransMeta) LogChannel(org.pentaho.di.core.logging.LogChannel) ServiceCacheFactory(org.pentaho.di.trans.dataservice.optimization.cache.ServiceCacheFactory) SQL(org.pentaho.di.core.sql.SQL) DataServiceContext(org.pentaho.di.trans.dataservice.DataServiceContext) PentahoCacheManagerImpl(org.pentaho.caching.impl.PentahoCacheManagerImpl) PentahoCacheSystemConfiguration(org.pentaho.caching.api.PentahoCacheSystemConfiguration) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 PentahoCacheSystemConfiguration (org.pentaho.caching.api.PentahoCacheSystemConfiguration)1 PentahoCacheManagerImpl (org.pentaho.caching.impl.PentahoCacheManagerImpl)1 HeapCacheProvidingService (org.pentaho.caching.ri.HeapCacheProvidingService)1 LogChannel (org.pentaho.di.core.logging.LogChannel)1 SQL (org.pentaho.di.core.sql.SQL)1 TransMeta (org.pentaho.di.trans.TransMeta)1 DataServiceContext (org.pentaho.di.trans.dataservice.DataServiceContext)1 DataServiceExecutor (org.pentaho.di.trans.dataservice.DataServiceExecutor)1 DataServiceMeta (org.pentaho.di.trans.dataservice.DataServiceMeta)1 ServiceCacheFactory (org.pentaho.di.trans.dataservice.optimization.cache.ServiceCacheFactory)1 UIFactory (org.pentaho.di.trans.dataservice.ui.UIFactory)1