/** * Creates the database config service. * * @param configSnapshot is the config snapshot * @param schedulingService is the timer stuff * @param schedulingMgmtService for statement schedule management * @return database config svc */ protected static DatabaseConfigService makeDatabaseRefService( ConfigurationInformation configSnapshot, SchedulingService schedulingService, SchedulingMgmtService schedulingMgmtService) { DatabaseConfigService databaseConfigService; // Add auto-imports try { ScheduleBucket allStatementsBucket = schedulingMgmtService.allocateBucket(); databaseConfigService = new DatabaseConfigServiceImpl( configSnapshot.getDatabaseReferences(), schedulingService, allStatementsBucket); } catch (IllegalArgumentException ex) { throw new ConfigurationException("Error configuring engine: " + ex.getMessage(), ex); } return databaseConfigService; }
public void testIterateStatement() { epService .getEPAdministrator() .createEPL("create context PartitionedByString partition by theString from SupportBean"); String[] fields = "c0,c1".split(","); EPStatement stmt = epService .getEPAdministrator() .createEPL( "@Name('StmtOne') context PartitionedByString select context.key1 as c0, sum(intPrimitive) as c1 from SupportBean.win:length(5)"); epService.getEPRuntime().sendEvent(new SupportBean("E1", 10)); epService.getEPRuntime().sendEvent(new SupportBean("E2", 20)); epService.getEPRuntime().sendEvent(new SupportBean("E2", 21)); Object[][] expectedAll = new Object[][] {{"E1", 10}, {"E2", 41}}; EPAssertionUtil.assertPropsPerRow(stmt.iterator(), stmt.safeIterator(), fields, expectedAll); // test iterator ALL ContextPartitionSelector selector = ContextPartitionSelectorAll.INSTANCE; EPAssertionUtil.assertPropsPerRow( stmt.iterator(selector), stmt.safeIterator(selector), fields, expectedAll); // test iterator by context partition id selector = new SupportSelectorById(new HashSet<Integer>(Arrays.asList(0, 1, 2))); EPAssertionUtil.assertPropsPerRow( stmt.iterator(selector), stmt.safeIterator(selector), fields, expectedAll); selector = new SupportSelectorById(new HashSet<Integer>(Arrays.asList(1))); EPAssertionUtil.assertPropsPerRow( stmt.iterator(selector), stmt.safeIterator(selector), fields, new Object[][] {{"E2", 41}}); assertFalse(stmt.iterator(new SupportSelectorById(Collections.<Integer>emptySet())).hasNext()); assertFalse(stmt.iterator(new SupportSelectorById(null)).hasNext()); try { stmt.iterator(null); fail(); } catch (IllegalArgumentException ex) { assertEquals(ex.getMessage(), "No selector provided"); } try { stmt.safeIterator(null); fail(); } catch (IllegalArgumentException ex) { assertEquals(ex.getMessage(), "No selector provided"); } EPStatement stmtTwo = epService.getEPAdministrator().createEPL("select * from java.lang.Object"); try { stmtTwo.iterator(null); fail(); } catch (UnsupportedOperationException ex) { assertEquals( ex.getMessage(), "Iterator with context selector is only supported for statements under context"); } try { stmtTwo.safeIterator(null); fail(); } catch (UnsupportedOperationException ex) { assertEquals( ex.getMessage(), "Iterator with context selector is only supported for statements under context"); } }