use of org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceExecutorTest method testWaitInterruptedException.
@Test(expected = RuntimeException.class)
public void testWaitInterruptedException() throws Exception {
SQL sql = new SQL("SELECT * FROM " + DATA_SERVICE_NAME);
when(serviceTrans.getTransMeta().listParameters()).thenReturn(new String[0]);
when(sqlTransGenerator.getSql()).thenReturn(sql);
PushDownOptimizationMeta optimization = mock(PushDownOptimizationMeta.class);
when(optimization.isEnabled()).thenReturn(true);
dataService.getPushDownOptimizationMeta().add(optimization);
dataService.setStreaming(true);
IMetaStore metastore = mock(IMetaStore.class);
DataServiceExecutor executor = new DataServiceExecutor.Builder(sql, dataService, context).serviceTrans(serviceTrans).sqlTransGenerator(sqlTransGenerator).genTrans(genTrans).metastore(metastore).windowMode(IDataServiceClientService.StreamingMode.ROW_BASED).windowSize(1).windowEvery(0).windowLimit(0).build();
doThrow(InterruptedException.class).when(genTrans).isFinishedOrStopped();
executor.waitUntilFinished();
}
use of org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceExecutorTest method testExecuteStreamQuery.
@Test
public void testExecuteStreamQuery() throws Exception {
when(genTrans.isFinishedOrStopped()).thenReturn(true);
SQL sql = new SQL("SELECT * FROM " + DATA_SERVICE_NAME);
when(serviceTrans.getTransMeta().listParameters()).thenReturn(new String[0]);
when(sqlTransGenerator.getSql()).thenReturn(sql);
PushDownOptimizationMeta optimization = mock(PushDownOptimizationMeta.class);
when(optimization.isEnabled()).thenReturn(true);
dataService.getPushDownOptimizationMeta().add(optimization);
dataService.setStreaming(true);
IMetaStore metastore = mock(IMetaStore.class);
DataServiceExecutor executor = new DataServiceExecutor.Builder(sql, dataService, context).serviceTrans(serviceTrans).sqlTransGenerator(sqlTransGenerator).genTrans(genTrans).metastore(metastore).windowMode(IDataServiceClientService.StreamingMode.ROW_BASED).windowSize(1).windowEvery(0).windowLimit(0).build();
ArgumentCaptor<String> objectIds = ArgumentCaptor.forClass(String.class);
verify(serviceTrans).setContainerObjectId(objectIds.capture());
when(serviceTrans.getContainerObjectId()).thenReturn(objectIds.getValue());
verify(genTrans).setContainerObjectId(objectIds.capture());
when(genTrans.getContainerObjectId()).thenReturn(objectIds.getValue());
verify(serviceTrans).setMetaStore(metastore);
verify(genTrans).setMetaStore(metastore);
RowProducer sqlTransRowProducer = mock(RowProducer.class);
when(genTrans.addRowProducer(INJECTOR_STEP_NAME, 0)).thenReturn(sqlTransRowProducer);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
// Start Execution
executor.executeQuery(new DataOutputStream(outputStream));
// Check header was written
assertThat(outputStream.size(), greaterThan(0));
outputStream.reset();
executor.waitUntilFinished();
verify(serviceTrans, times(0)).waitUntilFinished();
verify(genTrans).waitUntilFinished();
}
use of org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceExecutorTest method testWaitUntilFinished.
@Test
public void testWaitUntilFinished() throws Exception {
SQL sql = new SQL("SELECT * FROM " + DATA_SERVICE_NAME);
when(serviceTrans.getTransMeta().listParameters()).thenReturn(new String[0]);
PushDownOptimizationMeta optimization = mock(PushDownOptimizationMeta.class);
when(optimization.isEnabled()).thenReturn(true);
dataService.getPushDownOptimizationMeta().add(optimization);
IMetaStore metastore = mock(IMetaStore.class);
DataServiceExecutor executor = new DataServiceExecutor.Builder(sql, dataService, context).serviceTrans(serviceTrans).sqlTransGenerator(sqlTransGenerator).genTrans(genTrans).metastore(metastore).build();
executor.waitUntilFinished();
verify(genTrans, times(0)).isFinishedOrStopped();
verify(serviceTrans, times(1)).waitUntilFinished();
}
use of org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceModel method getDataService.
public DataServiceMeta getDataService() {
DataServiceMeta dataService = new DataServiceMeta(transMeta);
dataService.setName(getServiceName());
dataService.setPushDownOptimizationMeta(getPushDownOptimizations());
dataService.setStepname(getServiceStep());
dataService.setStreaming(isStreaming());
dataService.setRowLimit(serviceMaxRows);
dataService.setTimeLimit(serviceMaxTime);
for (PushDownOptimizationMeta pushDownOptimization : pushDownOptimizations) {
pushDownOptimization.getType().init(transMeta, dataService, pushDownOptimization);
}
return dataService;
}
use of org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta in project pdi-dataservice-server-plugin by pentaho.
the class ServiceCacheControllerTest method testBindingsAux.
private void testBindingsAux() throws Exception {
// Override Controller to inject our mocks
controller = new ServiceCacheController(factory) {
@Override
protected PushDownOptimizationMeta locateServiceCacheMeta(DataServiceModel model) {
assertThat(model, sameInstance(ServiceCacheControllerTest.this.model));
return meta;
}
@Override
protected LogChannelInterface getLogChannel() {
return log;
}
};
controller.setXulDomContainer(xulDomContainer);
controller.setBindingFactory(bindingFactory);
meta = new PushDownOptimizationMeta();
meta.setType(serviceCache = mock(ServiceCache.class));
meta.setEnabled(true);
when(serviceCache.getConfiguredTimeToLive()).thenReturn("1200");
}
Aggregations