Search in sources :

Example 1 with StreamingServiceTransExecutor

use of org.pentaho.di.trans.dataservice.streaming.execution.StreamingServiceTransExecutor in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceExecutorTest method testTimeLimitAux.

private StreamingServiceTransExecutor testTimeLimitAux(long userLimit, long metaLimit, String kettleLimit) 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);
    System.setProperty(DataServiceConstants.TIME_LIMIT_PROPERTY, kettleLimit);
    dataService.setStreaming(true);
    dataService.setTimeLimit(metaLimit);
    IMetaStore metastore = mock(IMetaStore.class);
    DataServiceExecutor executor = new DataServiceExecutor.Builder(sql, dataService, context).serviceTrans(serviceTrans).sqlTransGenerator(sqlTransGenerator).genTrans(genTrans).metastore(metastore).timeLimit(userLimit).windowMode(IDataServiceClientService.StreamingMode.ROW_BASED).windowSize(1).windowEvery(0).windowLimit(0).build();
    StreamingServiceTransExecutor exec = context.getServiceTransExecutor(dataService.getName());
    context.removeServiceTransExecutor(dataService.getName());
    return exec;
}
Also used : IMetaStore(org.pentaho.metastore.api.IMetaStore) StreamingServiceTransExecutor(org.pentaho.di.trans.dataservice.streaming.execution.StreamingServiceTransExecutor) SQL(org.pentaho.di.core.sql.SQL)

Example 2 with StreamingServiceTransExecutor

use of org.pentaho.di.trans.dataservice.streaming.execution.StreamingServiceTransExecutor in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceExecutorTest method testExecuteStreamQueryTimeLimit.

@Test
public void testExecuteStreamQueryTimeLimit() throws Exception {
    StreamingServiceTransExecutor exec = testTimeLimitAux(0, 0, "0");
    assertNotNull(exec);
    assertEquals(exec.getWindowMaxTimeLimit(), DataServiceConstants.TIME_LIMIT_DEFAULT);
    exec = testTimeLimitAux(0, 0, "NotNumber");
    assertNotNull(exec);
    assertEquals(exec.getWindowMaxTimeLimit(), DataServiceConstants.TIME_LIMIT_DEFAULT);
    exec = testTimeLimitAux(0, 0, String.valueOf(SYSTEM_TIME_LIMIT));
    assertNotNull(exec);
    assertEquals(exec.getWindowMaxTimeLimit(), SYSTEM_TIME_LIMIT);
    exec = testTimeLimitAux(0, SYSTEM_TIME_LIMIT, "0");
    assertNotNull(exec);
    assertEquals(exec.getWindowMaxTimeLimit(), SYSTEM_TIME_LIMIT);
    exec = testTimeLimitAux(SYSTEM_TIME_LIMIT, 0, "0");
    assertNotNull(exec);
    assertEquals(exec.getWindowMaxTimeLimit(), SYSTEM_TIME_LIMIT);
    exec = testTimeLimitAux(SYSTEM_TIME_LIMIT + 1, 0, String.valueOf(SYSTEM_TIME_LIMIT));
    assertNotNull(exec);
    assertEquals(exec.getWindowMaxTimeLimit(), SYSTEM_TIME_LIMIT);
    exec = testTimeLimitAux(SYSTEM_TIME_LIMIT, 0, String.valueOf(SYSTEM_TIME_LIMIT + 1));
    assertNotNull(exec);
    assertEquals(exec.getWindowMaxTimeLimit(), SYSTEM_TIME_LIMIT);
    exec = testTimeLimitAux(0, SYSTEM_TIME_LIMIT + 1, String.valueOf(SYSTEM_TIME_LIMIT));
    assertNotNull(exec);
    assertEquals(exec.getWindowMaxTimeLimit(), SYSTEM_TIME_LIMIT);
    exec = testTimeLimitAux(0, SYSTEM_TIME_LIMIT, String.valueOf(SYSTEM_TIME_LIMIT + 1));
    assertNotNull(exec);
    assertEquals(exec.getWindowMaxTimeLimit(), SYSTEM_TIME_LIMIT);
    exec = testTimeLimitAux(SYSTEM_TIME_LIMIT + 1, SYSTEM_TIME_LIMIT, "0");
    assertNotNull(exec);
    assertEquals(exec.getWindowMaxTimeLimit(), SYSTEM_TIME_LIMIT);
    exec = testTimeLimitAux(SYSTEM_TIME_LIMIT, SYSTEM_TIME_LIMIT + 1, "0");
    assertNotNull(exec);
    assertEquals(exec.getWindowMaxTimeLimit(), SYSTEM_TIME_LIMIT);
    exec = testTimeLimitAux(SYSTEM_TIME_LIMIT + 2, SYSTEM_TIME_LIMIT + 1, String.valueOf(SYSTEM_TIME_LIMIT));
    assertNotNull(exec);
    assertEquals(exec.getWindowMaxTimeLimit(), SYSTEM_TIME_LIMIT);
    exec = testTimeLimitAux(SYSTEM_TIME_LIMIT + 2, SYSTEM_TIME_LIMIT, String.valueOf(SYSTEM_TIME_LIMIT + 1));
    assertNotNull(exec);
    assertEquals(exec.getWindowMaxTimeLimit(), SYSTEM_TIME_LIMIT);
    exec = testTimeLimitAux(SYSTEM_TIME_LIMIT, SYSTEM_TIME_LIMIT + 2, String.valueOf(SYSTEM_TIME_LIMIT + 1));
    assertNotNull(exec);
    assertEquals(exec.getWindowMaxTimeLimit(), SYSTEM_TIME_LIMIT);
}
Also used : StreamingServiceTransExecutor(org.pentaho.di.trans.dataservice.streaming.execution.StreamingServiceTransExecutor) Test(org.junit.Test)

Example 3 with StreamingServiceTransExecutor

use of org.pentaho.di.trans.dataservice.streaming.execution.StreamingServiceTransExecutor in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceTestController method cleanupCurrentExec.

private void cleanupCurrentExec() {
    if (completionPollTimer != null) {
        completionPollTimer.cancel();
    }
    if (dataServiceExec != null) {
        stopDataService(dataServiceExec);
        String streamingServiceName = dataService.getName();
        StreamingServiceTransExecutor streamingServiceCache = context.getServiceTransExecutor(streamingServiceName);
        if (streamingServiceCache != null) {
            streamingServiceCache.clearCache();
            context.removeServiceTransExecutor(streamingServiceName);
        }
    }
    model.setExecuting(false);
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) StreamingServiceTransExecutor(org.pentaho.di.trans.dataservice.streaming.execution.StreamingServiceTransExecutor)

Example 4 with StreamingServiceTransExecutor

use of org.pentaho.di.trans.dataservice.streaming.execution.StreamingServiceTransExecutor in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceExecutorTest method testExecuteStreamQueryRowLimit.

@Test
public void testExecuteStreamQueryRowLimit() throws Exception {
    StreamingServiceTransExecutor exec = testRowLimitAux(0, 0, "0");
    assertNotNull(exec);
    assertEquals(exec.getWindowMaxRowLimit(), DataServiceConstants.ROW_LIMIT_DEFAULT);
    exec = testRowLimitAux(0, 0, "NotNumber");
    assertNotNull(exec);
    assertEquals(exec.getWindowMaxRowLimit(), DataServiceConstants.ROW_LIMIT_DEFAULT);
    exec = testRowLimitAux(0, 0, String.valueOf(SYSTEM_ROW_LIMIT));
    assertNotNull(exec);
    assertEquals(exec.getWindowMaxRowLimit(), SYSTEM_ROW_LIMIT);
    exec = testRowLimitAux(0, SYSTEM_ROW_LIMIT, "0");
    assertNotNull(exec);
    assertEquals(exec.getWindowMaxRowLimit(), SYSTEM_ROW_LIMIT);
    exec = testRowLimitAux(SYSTEM_ROW_LIMIT, 0, "0");
    assertNotNull(exec);
    assertEquals(exec.getWindowMaxRowLimit(), SYSTEM_ROW_LIMIT);
    exec = testRowLimitAux(SYSTEM_ROW_LIMIT + 1, 0, String.valueOf(SYSTEM_ROW_LIMIT));
    assertNotNull(exec);
    assertEquals(exec.getWindowMaxRowLimit(), SYSTEM_ROW_LIMIT);
    exec = testRowLimitAux(SYSTEM_ROW_LIMIT, 0, String.valueOf(SYSTEM_ROW_LIMIT + 1));
    assertNotNull(exec);
    assertEquals(exec.getWindowMaxRowLimit(), SYSTEM_ROW_LIMIT);
    exec = testRowLimitAux(0, SYSTEM_ROW_LIMIT + 1, String.valueOf(SYSTEM_ROW_LIMIT));
    assertNotNull(exec);
    assertEquals(exec.getWindowMaxRowLimit(), SYSTEM_ROW_LIMIT);
    exec = testRowLimitAux(0, SYSTEM_ROW_LIMIT, String.valueOf(SYSTEM_ROW_LIMIT + 1));
    assertNotNull(exec);
    assertEquals(exec.getWindowMaxRowLimit(), SYSTEM_ROW_LIMIT);
    exec = testRowLimitAux(SYSTEM_ROW_LIMIT + 1, SYSTEM_ROW_LIMIT, "0");
    assertNotNull(exec);
    assertEquals(exec.getWindowMaxRowLimit(), SYSTEM_ROW_LIMIT);
    exec = testRowLimitAux(SYSTEM_ROW_LIMIT, SYSTEM_ROW_LIMIT + 1, "0");
    assertNotNull(exec);
    assertEquals(exec.getWindowMaxRowLimit(), SYSTEM_ROW_LIMIT);
    exec = testRowLimitAux(SYSTEM_ROW_LIMIT + 2, SYSTEM_ROW_LIMIT + 1, String.valueOf(SYSTEM_ROW_LIMIT));
    assertNotNull(exec);
    assertEquals(exec.getWindowMaxRowLimit(), SYSTEM_ROW_LIMIT);
    exec = testRowLimitAux(SYSTEM_ROW_LIMIT + 2, SYSTEM_ROW_LIMIT, String.valueOf(SYSTEM_ROW_LIMIT + 1));
    assertNotNull(exec);
    assertEquals(exec.getWindowMaxRowLimit(), SYSTEM_ROW_LIMIT);
    exec = testRowLimitAux(SYSTEM_ROW_LIMIT, SYSTEM_ROW_LIMIT + 2, String.valueOf(SYSTEM_ROW_LIMIT + 1));
    assertNotNull(exec);
    assertEquals(exec.getWindowMaxRowLimit(), SYSTEM_ROW_LIMIT);
}
Also used : StreamingServiceTransExecutor(org.pentaho.di.trans.dataservice.streaming.execution.StreamingServiceTransExecutor) Test(org.junit.Test)

Example 5 with StreamingServiceTransExecutor

use of org.pentaho.di.trans.dataservice.streaming.execution.StreamingServiceTransExecutor in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceExecutorTest method testRowLimitAux.

private StreamingServiceTransExecutor testRowLimitAux(int userLimit, int metaLimit, String kettleLimit) 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);
    System.setProperty(DataServiceConstants.ROW_LIMIT_PROPERTY, kettleLimit);
    dataService.setStreaming(true);
    dataService.setRowLimit(metaLimit);
    IMetaStore metastore = mock(IMetaStore.class);
    DataServiceExecutor executor = new DataServiceExecutor.Builder(sql, dataService, context).serviceTrans(serviceTrans).sqlTransGenerator(sqlTransGenerator).genTrans(genTrans).metastore(metastore).rowLimit(userLimit).windowMode(IDataServiceClientService.StreamingMode.ROW_BASED).windowSize(1).windowEvery(0).windowLimit(0).build();
    StreamingServiceTransExecutor exec = context.getServiceTransExecutor(dataService.getName());
    context.removeServiceTransExecutor(dataService.getName());
    return exec;
}
Also used : IMetaStore(org.pentaho.metastore.api.IMetaStore) StreamingServiceTransExecutor(org.pentaho.di.trans.dataservice.streaming.execution.StreamingServiceTransExecutor) SQL(org.pentaho.di.core.sql.SQL)

Aggregations

StreamingServiceTransExecutor (org.pentaho.di.trans.dataservice.streaming.execution.StreamingServiceTransExecutor)5 Test (org.junit.Test)2 SQL (org.pentaho.di.core.sql.SQL)2 IMetaStore (org.pentaho.metastore.api.IMetaStore)2 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)1