DataServiceExecutor { public int getServiceRowLimit() { return sqlTransGenerator.getServiceRowLimit(); } private  DataServiceExecutor( Builder builder ); static void writeMetadata( DataOutputStream dos, String... metadatas ); DataServiceExecutor executeQuery( final DataOutputStream dos ); DataServiceExecutor executeQuery( Observer<RowMetaAndData> consumer ); DataServiceExecutor executeStreamingQuery( final Observer<List<RowMetaAndData>> streamingConsumer, boolean pollingMode ); String getStreamingGenTransCacheKey(); DataServiceExecutor executeDefaultQuery( final Observer<RowMetaAndData> consumer ); DataServiceExecutor executeQuery(); void executeListeners( ExecutionPoint... stages ); RowProducer addRowProducer(); void waitUntilFinished(); TransMeta getServiceTransMeta(); TransMeta getGenTransMeta(); DataServiceMeta getService(); Trans getServiceTrans(); Trans getGenTrans(); String getServiceName(); Map<String, String> getParameters(); String getId(); Boolean hasErrors(); static String calculateTransname( SQL sql, boolean isService ); void stop( boolean stopTrans ); boolean isStopped(); SQL getSql(); String getResultStepName(); int getRowLimit(); int getServiceRowLimit(); ListMultimap<ExecutionPoint, Runnable> getListenerMap();  }
@Test public void testDynamicLimit() throws Exception { final String limitProp = "dataservice.dynamic.limit"; boolean userDef = dataService.isUserDefined(); try { System.setProperty( limitProp, "2" ); dataService.setUserDefined( false ); DataServiceExecutor executor = new DataServiceExecutor.Builder( new SQL( "SELECT * FROM " + DATA_SERVICE_NAME ), dataService, context ) .serviceTrans( serviceTrans ) .genTrans( genTrans ) .build(); assertEquals( 2, executor.getServiceRowLimit() ); dataService.setUserDefined( true ); System.setProperty( limitProp, "2" ); executor = new DataServiceExecutor.Builder( new SQL( "SELECT * FROM " + DATA_SERVICE_NAME ), dataService, context ) .serviceTrans( serviceTrans ) .genTrans( genTrans ) .build(); assertEquals( 0, executor.getServiceRowLimit() ); int serviceRowLimit = 1000; dataService.setRowLimit( serviceRowLimit ); executor = new DataServiceExecutor.Builder( new SQL( "SELECT * FROM " + DATA_SERVICE_NAME ), dataService, context ) .serviceTrans( serviceTrans ) .genTrans( genTrans ) .build(); assertEquals( serviceRowLimit, executor.getServiceRowLimit() ); serviceRowLimit = -3; dataService.setRowLimit( serviceRowLimit ); executor = new DataServiceExecutor.Builder( new SQL( "SELECT * FROM " + DATA_SERVICE_NAME ), dataService, context ) .serviceTrans( serviceTrans ) .genTrans( genTrans ) .build(); assertEquals( 0, executor.getServiceRowLimit() ); } finally { dataService.setUserDefined( userDef ); dataService.setRowLimit( 0 ); System.getProperties().remove( limitProp ); } }
@Test public void testDynamicLimitDefault() throws Exception { final int defaultLimit = 50000; boolean userDef = dataService.isUserDefined(); try { System.getProperties().remove( DataServiceConstants.ROW_LIMIT_PROPERTY ); System.getProperties().remove( DataServiceConstants.LEGACY_LIMIT_PROPERTY ); dataService.setUserDefined( false ); DataServiceExecutor executor = new DataServiceExecutor.Builder( new SQL( "SELECT * FROM " + DATA_SERVICE_NAME ), dataService, context ) .serviceTrans( serviceTrans ) .genTrans( genTrans ) .build(); assertEquals( defaultLimit, executor.getServiceRowLimit() ); System.setProperty( DataServiceConstants.ROW_LIMIT_PROPERTY, "baah" ); executor = new DataServiceExecutor.Builder( new SQL( "SELECT * FROM " + DATA_SERVICE_NAME ), dataService, context ) .serviceTrans( serviceTrans ) .genTrans( genTrans ) .build(); assertEquals( defaultLimit, executor.getServiceRowLimit() ); verify( logChannel ).logError( anyString() ); } finally { dataService.setUserDefined( userDef ); System.getProperties().remove( DataServiceConstants.ROW_LIMIT_PROPERTY ); } }