Exemple #1
0
  public void testVariantTwoWildcard() throws InterruptedException {
    String stmtText =
        "insert into event1 select * from " + SupportBean.class.getName() + ".win:length(100)";
    String otherText = "select * from default.event1.win:length(10)";

    // Attach listener to feed
    EPStatement stmtOne = epService.getEPAdministrator().createEPL(stmtText, "stmt1");
    assertEquals(
        StatementType.INSERT_INTO,
        ((EPStatementSPI) stmtOne).getStatementMetadata().getStatementType());
    SupportUpdateListener listenerOne = new SupportUpdateListener();
    stmtOne.addListener(listenerOne);
    EPStatement stmtTwo = epService.getEPAdministrator().createEPL(otherText, "stmt2");
    SupportUpdateListener listenerTwo = new SupportUpdateListener();
    stmtTwo.addListener(listenerTwo);

    SupportBean theEvent = sendEvent(10, 11);
    assertTrue(listenerOne.getAndClearIsInvoked());
    assertEquals(1, listenerOne.getLastNewData().length);
    assertEquals(10, listenerOne.getLastNewData()[0].get("intPrimitive"));
    assertEquals(11, listenerOne.getLastNewData()[0].get("intBoxed"));
    assertEquals(20, listenerOne.getLastNewData()[0].getEventType().getPropertyNames().length);
    assertSame(theEvent, listenerOne.getLastNewData()[0].getUnderlying());

    assertTrue(listenerTwo.getAndClearIsInvoked());
    assertEquals(1, listenerTwo.getLastNewData().length);
    assertEquals(10, listenerTwo.getLastNewData()[0].get("intPrimitive"));
    assertEquals(11, listenerTwo.getLastNewData()[0].get("intBoxed"));
    assertEquals(20, listenerTwo.getLastNewData()[0].getEventType().getPropertyNames().length);
    assertSame(theEvent, listenerTwo.getLastNewData()[0].getUnderlying());

    // assert statement-type reference
    EPServiceProviderSPI spi = (EPServiceProviderSPI) epService;
    assertTrue(spi.getStatementEventTypeRef().isInUse("event1"));
    Set<String> stmtNames = spi.getStatementEventTypeRef().getStatementNamesForType("event1");
    EPAssertionUtil.assertEqualsAnyOrder(stmtNames.toArray(), new String[] {"stmt1", "stmt2"});
    assertTrue(spi.getStatementEventTypeRef().isInUse(SupportBean.class.getName()));
    stmtNames =
        spi.getStatementEventTypeRef().getStatementNamesForType(SupportBean.class.getName());
    EPAssertionUtil.assertEqualsAnyOrder(stmtNames.toArray(), new String[] {"stmt1"});

    stmtOne.destroy();
    assertTrue(spi.getStatementEventTypeRef().isInUse("event1"));
    stmtNames = spi.getStatementEventTypeRef().getStatementNamesForType("event1");
    EPAssertionUtil.assertEqualsAnyOrder(new String[] {"stmt2"}, stmtNames.toArray());
    assertFalse(spi.getStatementEventTypeRef().isInUse(SupportBean.class.getName()));

    stmtTwo.destroy();
    assertFalse(spi.getStatementEventTypeRef().isInUse("event1"));
  }
  public void testLateStartIndex() {
    // prepare
    preloadData(false);

    // test join
    String eplJoin =
        "select * from SupportBean_S0 as s0 unidirectional, AWindow(p00='x') as aw where aw.id = s0.id";
    epService.getEPAdministrator().createEPL(eplJoin).addListener(listener);
    assertEquals(2, MyCountAccessEvent.getAndResetCountGetterCalled());

    epService.getEPRuntime().sendEvent(new SupportBean_S0(-1, "x"));
    assertTrue(listener.getAndClearIsInvoked());

    // test subquery no-index-share
    String eplSubqueryNoIndexShare =
        "select (select id from AWindow(p00='x') as aw where aw.id = s0.id) "
            + "from SupportBean_S0 as s0 unidirectional";
    epService.getEPAdministrator().createEPL(eplSubqueryNoIndexShare).addListener(listener);
    assertEquals(2, MyCountAccessEvent.getAndResetCountGetterCalled());

    epService.getEPRuntime().sendEvent(new SupportBean_S0(-1, "x"));

    // test subquery with index share
    epService.getEPAdministrator().destroyAllStatements();
    preloadData(true);

    String eplSubqueryWithIndexShare =
        "select (select id from AWindow(p00='x') as aw where aw.id = s0.id) "
            + "from SupportBean_S0 as s0 unidirectional";
    epService.getEPAdministrator().createEPL(eplSubqueryWithIndexShare).addListener(listener);
    assertEquals(2, MyCountAccessEvent.getAndResetCountGetterCalled());

    epService.getEPRuntime().sendEvent(new SupportBean_S0(-1, "x"));
    assertTrue(listener.isInvoked());
  }
  public void testEnabledDisableRuntime() {
    EPStatement[] statements = new EPStatement[5];
    Configuration config = getConfig(10000, 10000, true);
    epService = EPServiceProviderManager.getProvider("MyURI", config);
    epService.initialize();

    sendTimer(1000);

    statements[0] =
        epService
            .getEPAdministrator()
            .createEPL("select * from " + StatementMetric.class.getName(), "stmtmetric");
    statements[0].addListener(listenerStmtMetric);

    statements[1] =
        epService
            .getEPAdministrator()
            .createEPL("select * from " + EngineMetric.class.getName(), "enginemetric");
    statements[1].addListener(listenerEngineMetric);

    statements[2] =
        epService
            .getEPAdministrator()
            .createEPL(
                "select * from SupportBean(intPrimitive=1).win:keepall() where MyMetricFunctions.takeCPUTime(longPrimitive)");
    sendEvent("E1", 1, cpuGoalOneNano);

    sendTimer(11000);
    assertTrue(listenerStmtMetric.getAndClearIsInvoked());
    assertTrue(listenerEngineMetric.getAndClearIsInvoked());

    epService.getEPAdministrator().getConfiguration().setMetricsReportingDisabled();
    sendEvent("E2", 2, cpuGoalOneNano);
    sendTimer(21000);
    assertFalse(listenerStmtMetric.getAndClearIsInvoked());
    assertFalse(listenerEngineMetric.getAndClearIsInvoked());

    sendTimer(31000);
    sendEvent("E3", 3, cpuGoalOneNano);
    assertFalse(listenerStmtMetric.getAndClearIsInvoked());
    assertFalse(listenerEngineMetric.getAndClearIsInvoked());

    epService.getEPAdministrator().getConfiguration().setMetricsReportingEnabled();
    sendEvent("E4", 4, cpuGoalOneNano);
    sendTimer(41000);
    assertTrue(listenerStmtMetric.getAndClearIsInvoked());
    assertTrue(listenerEngineMetric.getAndClearIsInvoked());

    statements[2].destroy();
    sendTimer(51000);
    assertTrue(listenerStmtMetric.isInvoked()); // metrics statements reported themselves
    assertTrue(listenerEngineMetric.isInvoked());
  }
Exemple #4
0
  public void testVariantTwoJoinWildcard() {
    String textOne =
        "insert into event2 select * "
            + "from "
            + SupportBean.class.getName()
            + ".win:length(100) as s0, "
            + SupportBean_A.class.getName()
            + ".win:length(5) as s1 "
            + "where s0.theString = s1.id";
    String textTwo = "select * from event2.win:length(10)";

    // Attach listener to feed
    EPStatement stmtOne = epService.getEPAdministrator().createEPL(textOne);
    SupportUpdateListener listenerOne = new SupportUpdateListener();
    stmtOne.addListener(listenerOne);
    EPStatement stmtTwo = epService.getEPAdministrator().createEPL(textTwo);
    SupportUpdateListener listenerTwo = new SupportUpdateListener();
    stmtTwo.addListener(listenerTwo);

    // send event for joins to match on
    SupportBean_A eventA = new SupportBean_A("myId");
    epService.getEPRuntime().sendEvent(eventA);

    SupportBean eventOne = sendEvent(10, 11);
    assertTrue(listenerOne.getAndClearIsInvoked());
    assertEquals(1, listenerOne.getLastNewData().length);
    assertEquals(2, listenerOne.getLastNewData()[0].getEventType().getPropertyNames().length);
    assertTrue(listenerOne.getLastNewData()[0].getEventType().isProperty("s0"));
    assertTrue(listenerOne.getLastNewData()[0].getEventType().isProperty("s1"));
    assertSame(eventOne, listenerOne.getLastNewData()[0].get("s0"));
    assertSame(eventA, listenerOne.getLastNewData()[0].get("s1"));

    assertTrue(listenerTwo.getAndClearIsInvoked());
    assertEquals(1, listenerTwo.getLastNewData().length);
    assertEquals(2, listenerTwo.getLastNewData()[0].getEventType().getPropertyNames().length);
    assertTrue(listenerTwo.getLastNewData()[0].getEventType().isProperty("s0"));
    assertTrue(listenerTwo.getLastNewData()[0].getEventType().isProperty("s1"));
    assertSame(eventOne, listenerOne.getLastNewData()[0].get("s0"));
    assertSame(eventA, listenerOne.getLastNewData()[0].get("s1"));
  }
  public void testFilterBehavior() {
    epService.getEPAdministrator().createEPL("create table varagg (total count(*))");
    epService
        .getEPAdministrator()
        .createEPL("into table varagg select count(*) as total from SupportBean_S0");
    epService
        .getEPAdministrator()
        .createEPL("select * from SupportBean(varagg.total = intPrimitive)")
        .addListener(listener);

    epService.getEPRuntime().sendEvent(new SupportBean_S0(0));

    epService.getEPRuntime().sendEvent(new SupportBean("E1", 1));
    assertTrue(listener.getAndClearIsInvoked());

    epService.getEPRuntime().sendEvent(new SupportBean_S0(0));

    epService.getEPRuntime().sendEvent(new SupportBean("E1", 2));
    assertTrue(listener.getAndClearIsInvoked());

    epService.getEPRuntime().sendEvent(new SupportBean("E1", 3));
    epService.getEPRuntime().sendEvent(new SupportBean("E1", 1));
    assertFalse(listener.getAndClearIsInvoked());
  }
Exemple #6
0
 private void assertSimple(
     SupportUpdateListener listener,
     String myString,
     int myInt,
     String additionalString,
     int additionalInt) {
   assertTrue(listener.getAndClearIsInvoked());
   EventBean eventBean = listener.getLastNewData()[0];
   assertEquals(myString, eventBean.get("myString"));
   assertEquals(myInt, eventBean.get("myInt"));
   if (additionalString != null) {
     assertEquals(additionalString, eventBean.get("concat"));
     assertEquals(additionalInt, eventBean.get("summed"));
   }
 }