@Override
  public void contextInitialized(ServletContextEvent servletContextEvent) {
    PropertyConfigurator.configure(
        new File("D:\\server\\" + "TomcatNRG4Cast\\conf\\nrg4castApp\\log4j.properties")
            .toString()); // uncoment for .war deployment
    this.context = servletContextEvent.getServletContext();

    this.context.setAttribute("instances", instance);
    this.context.setAttribute("predBuffer", predBuffer);

    // add engine instances
    instance.put(nrg4castEngineName, new EsperNrg4Cast(this.context));
    log.info(nrg4castEngineName + " engine started");
    //	instance.put(nrg4castHistEngineName, new EsperNrg4CastHist(this.context));
    //	log.info(nrg4castHistEngineName + " engine started");

    for (String s : EPServiceProviderManager.getProviderURIs()) {
      System.out.println("known provider uri: " + s);
    }
    // add modules to the corresponding instance
    try {

      String engineModulesList =
          servletContextEvent.getServletContext().getInitParameter("eplEngineModules");

      String[] split = engineModulesList.split(",");
      for (int i = 0; i < split.length; i++) {
        String engineName = split[i].trim().replace("Modules", "");
        String modulesList =
            servletContextEvent.getServletContext().getInitParameter(split[i].trim());
        if (Arrays.asList(EPServiceProviderManager.getProviderURIs()).contains(engineName)) {
          addModules(
              EPServiceProviderManager.getProvider(engineName), modulesList, servletContextEvent);
        } else {
          addModules(
              EPServiceProviderManager.getDefaultProvider(), modulesList, servletContextEvent);
        }
      }

    } catch (Exception ex) {
      ex.printStackTrace();
    }

    // add listeners for each engine instance
    for (String engine : instance.keySet()) {
      EsperInstance ei = instance.get(engine);
      ei.addListeners();
    }
  }
  public void runExample() {
    // Allocate default provider in default configuration
    provider = EPServiceProviderManager.getDefaultProvider();

    // Add an event type
    Map<String, Object> typeDefinition = new HashMap<String, Object>();
    typeDefinition.put("propertyOne", "string");
    typeDefinition.put("propertyTwo", "int");
    provider.getEPAdministrator().getConfiguration().addEventType("MyEvent", typeDefinition);

    // Configure and test variables
    configureVariables();

    // Configure and test a variant stream
    configureVariantStream();

    // Configure and test an import
    configureImport();

    // Add a single-row function
    configureSingleRowFunction();

    // Add a custom aggregation function
    configureCustomAggregationFunction();

    // Use a revision event type
    configureRevisionType();
  }
Exemple #3
0
  public static void main(String[] args) {
    EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider();
    EPAdministrator admin = epService.getEPAdministrator();

    // Apple定义
    Map<String, Object> apple = new HashMap<String, Object>();
    apple.put("id", int.class);
    apple.put("price", int.class);

    // 注册Apple到Esper
    admin.getConfiguration().addEventType("Apple", apple);

    String epl = "select avg(price) from Apple.win:length_batch(3)";

    EPStatement state = admin.createEPL(epl);
    state.addListener(new AppleListener());

    EPRuntime runtime = epService.getEPRuntime();

    Map<String, Object> apple1 = new HashMap<String, Object>();
    apple1.put("id", 1);
    apple1.put("price", 5);
    runtime.sendEvent(apple1, "Apple");

    Map<String, Object> apple2 = new HashMap<String, Object>();
    apple2.put("id", 2);
    apple2.put("price", 2);
    runtime.sendEvent(apple2, "Apple");

    Map<String, Object> apple3 = new HashMap<String, Object>();
    apple3.put("id", 3);
    apple3.put("price", 5);
    runtime.sendEvent(apple3, "Apple");
  }
  public void testSchemaXMLWSchemaWithRestriction() throws Exception {
    Configuration config = SupportConfigFactory.getConfiguration();
    ConfigurationEventTypeXMLDOM eventTypeMeta = new ConfigurationEventTypeXMLDOM();
    eventTypeMeta.setRootElementName("order");
    InputStream schemaStream =
        TestSchemaXMLEvent.class
            .getClassLoader()
            .getResourceAsStream(CLASSLOADER_SCHEMA_WITH_RESTRICTION_URI);
    assertNotNull(schemaStream);
    String schemaText = ParserTool.linesToText(ParserTool.readFile(schemaStream));
    eventTypeMeta.setSchemaText(schemaText);
    config.addEventType("OrderEvent", eventTypeMeta);

    epService = EPServiceProviderManager.getProvider("TestSchemaXML", config);
    epService.initialize();
    updateListener = new SupportUpdateListener();

    String text = "select order_amount from OrderEvent";
    EPStatement stmt = epService.getEPAdministrator().createEPL(text);
    stmt.addListener(updateListener);

    SupportXML.sendEvent(
        epService.getEPRuntime(),
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
            + "<order>\n"
            + "<order_amount>202.1</order_amount>"
            + "</order>");
    EventBean theEvent = updateListener.getLastNewData()[0];
    assertEquals(Double.class, theEvent.get("order_amount").getClass());
    assertEquals(202.1d, theEvent.get("order_amount"));
    updateListener.reset();
  }
Exemple #5
0
  public static void main(String[] args) throws InterruptedException {
    EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider();

    EPAdministrator admin = epService.getEPAdministrator();

    //        String epl1 = "select (select sum(price), sum(size) from " + Apple.class.getName() +
    // ".std:lastevent()) from " + Fruit.class.getName();
    /*
     * 当然,对不同的属性使用不同的聚合函数也是可以的
     */
    // String epl1 = "select (select sum(price), avg(size) from " + Apple.class.getName() +
    // ".std:lastevent()) from " + Fruit.class.getName();

    /*
     * 注意:size没有使用聚合函数,会导致创建epl失败。文档中注明了“The properties of the subselect stream must all be within aggregation functions”.
     * 即子查询中的select子句使用聚合函数时,所查询的属性都要使用聚合函数
     */
    String epl1 =
        "select (select sum(price), size from "
            + Apple.class.getName()
            + ".std:lastevent()) from "
            + Fruit.class.getName();

    admin.createEPL(epl1);
    System.out.println("Create epl successfully!");
  }
  public void testContextContents() throws Exception {
    Configuration configuration = getConfiguration();
    configuration.addPlugInEventRepresentation(
        new URI("type://test/support"), SupportEventRepresentation.class.getName(), "abc");
    epService = EPServiceProviderManager.getDefaultProvider(configuration);
    epService.initialize();

    PlugInEventRepresentationContext initContext = SupportEventRepresentation.getInitContext();
    assertEquals(new URI("type://test/support"), initContext.getEventRepresentationRootURI());
    assertEquals("abc", initContext.getRepresentationInitializer());
    assertNotNull(initContext.getEventAdapterService());

    ConfigurationOperations runtimeConfig = epService.getEPAdministrator().getConfiguration();
    runtimeConfig.addPlugInEventType(
        "TestTypeOne", new URI[] {new URI("type://test/support?a=b&c=d")}, "t1");

    PlugInEventTypeHandlerContext context = SupportEventRepresentation.getAcceptTypeContext();
    assertEquals(new URI("type://test/support?a=b&c=d"), context.getEventTypeResolutionURI());
    assertEquals("t1", context.getTypeInitializer());
    assertEquals("TestTypeOne", context.getEventTypeName());

    context = SupportEventRepresentation.getEventTypeContext();
    assertEquals(new URI("type://test/support?a=b&c=d"), context.getEventTypeResolutionURI());
    assertEquals("t1", context.getTypeInitializer());
    assertEquals("TestTypeOne", context.getEventTypeName());

    epService.getEPRuntime().getEventSender(new URI[] {new URI("type://test/support?a=b")});
    PlugInEventBeanReflectorContext contextBean = SupportEventRepresentation.getEventBeanContext();
    assertEquals("type://test/support?a=b", contextBean.getResolutionURI().toString());
  }
  public void testAfterNextRow() {
    Configuration config = SupportConfigFactory.getConfiguration();
    config.addEventType("MyEvent", SupportRecogBean.class);
    EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(config);
    epService.initialize();

    String[] fields = "a,b0,b1".split(",");
    String text =
        "select * from MyEvent.win:keepall() "
            + "match_recognize ("
            + "  measures A.theString as a, B[0].theString as b0, B[1].theString as b1"
            + "  AFTER MATCH SKIP TO NEXT ROW "
            + "  pattern (A B*) "
            + "  define "
            + "    A as A.theString like 'A%',"
            + "    B as B.theString like 'B%'"
            + ")";

    EPStatement stmt = epService.getEPAdministrator().createEPL(text);
    SupportUpdateListener listener = new SupportUpdateListener();
    stmt.addListener(listener);

    epService.getEPRuntime().sendEvent(new SupportRecogBean("A1", 1));
    EPAssertionUtil.assertPropsPerRow(
        listener.getAndResetLastNewData(), fields, new Object[][] {{"A1", null, null}});
    EPAssertionUtil.assertPropsPerRow(stmt.iterator(), fields, new Object[][] {{"A1", null, null}});

    // since the first match skipped past A, we do not match again
    epService.getEPRuntime().sendEvent(new SupportRecogBean("B1", 2));
    assertFalse(listener.isInvoked()); // incremental skips to next
    EPAssertionUtil.assertPropsPerRow(stmt.iterator(), fields, new Object[][] {{"A1", "B1", null}});
  }
  public void testAfterCurrentRow() throws Exception {
    Configuration config = SupportConfigFactory.getConfiguration();
    config.addEventType("MyEvent", SupportRecogBean.class);
    EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(config);
    epService.initialize();

    String text =
        "select * from MyEvent.win:keepall() "
            + "match_recognize ("
            + " measures A.theString as a, B[0].theString as b0, B[1].theString as b1"
            + " after match skip to current row"
            + " pattern (A B*)"
            + " define"
            + " A as A.theString like \"A%\","
            + " B as B.theString like \"B%\""
            + ")";

    EPStatement stmt = epService.getEPAdministrator().createEPL(text);
    SupportUpdateListener listener = new SupportUpdateListener();
    stmt.addListener(listener);

    runAssertion(epService, listener, stmt);

    stmt.destroy();
    EPStatementObjectModel model = epService.getEPAdministrator().compileEPL(text);
    SerializableObjectCopier.copy(model);
    assertEquals(text, model.toEPL());
    stmt = epService.getEPAdministrator().create(model);
    stmt.addListener(listener);
    assertEquals(text, stmt.getText());

    runAssertion(epService, listener, stmt);
  }
  public void testEngineMetrics() {
    epService = EPServiceProviderManager.getProvider("MyURI", getConfig(10000, -1, true));
    epService.initialize();

    String[] engineFields =
        "engineURI,timestamp,inputCount,inputCountDelta,scheduleDepth".split(",");
    sendTimer(1000);

    String text = "select * from " + EngineMetric.class.getName();
    EPStatement stmt = epService.getEPAdministrator().createEPL(text);
    stmt.addListener(listener);

    epService.getEPRuntime().sendEvent(new SupportBean());

    sendTimer(10999);
    assertFalse(listener.isInvoked());

    epService.getEPAdministrator().createEPL("select * from pattern[timer:interval(5 sec)]");

    sendTimer(11000);
    EventBean event = listener.assertOneGetNewAndReset();
    ArrayAssertionUtil.assertProps(event, engineFields, new Object[] {"MyURI", 11000L, 1L, 1L, 1L});

    epService.getEPRuntime().sendEvent(new SupportBean());
    epService.getEPRuntime().sendEvent(new SupportBean());

    sendTimer(20000);
    sendTimer(21000);
    event = listener.assertOneGetNewAndReset();
    ArrayAssertionUtil.assertProps(event, engineFields, new Object[] {"MyURI", 21000L, 4L, 3L, 0L});
  }
 public void setUp() {
   Configuration config = SupportConfigFactory.getConfiguration();
   epService = (EPServiceProviderSPI) EPServiceProviderManager.getDefaultProvider(config);
   epService.initialize();
   epService.getEPAdministrator().getConfiguration().addEventType(SupportBean_S0.class);
   epService.getEPAdministrator().getConfiguration().addEventType(MyCountAccessEvent.class);
   listener = new SupportUpdateListener();
 }
Exemple #11
0
  @Before
  public void setup() {
    Configuration config = new Configuration();
    config.addEventType("StockTick", StockTick.class);
    epService = EPServiceProviderManager.getProvider("EPLTest", config);

    esperRunner = new EsperRunner(epService);
  }
Exemple #12
0
 public void setUp() {
   epService =
       EPServiceProviderManager.getDefaultProvider(SupportConfigFactory.getConfiguration());
   epService.initialize();
   feedListener = new SupportUpdateListener();
   resultListenerDelta = new SupportUpdateListener();
   resultListenerProduct = new SupportUpdateListener();
 }
  protected void setUp() {
    Configuration config = SupportConfigFactory.getConfiguration();
    config.addEventType("SupportBean", SupportBean.class);

    epService = EPServiceProviderManager.getDefaultProvider(config);
    epService.initialize();
    mergeListener = new SupportUpdateListener();
  }
  public void setUp() {

    Configuration config = SupportConfigFactory.getConfiguration();
    config.addEventType("Bean", SupportBean_ST0_Container.class);
    config.addEventType("SupportCollection", SupportCollection.class);
    epService = EPServiceProviderManager.getDefaultProvider(config);
    epService.initialize();
    listener = new SupportUpdateListener();
  }
 public void setUp() {
   epService =
       EPServiceProviderManager.getDefaultProvider(SupportConfigFactory.getConfiguration());
   epService.initialize();
   if (InstrumentationHelper.ENABLED) {
     InstrumentationHelper.startTest(epService, this.getClass(), getName());
   }
   updateListener = new SupportUpdateListener();
 }
  public void testStaticConfigDynamicTypeResolution() throws Exception {
    URI[] uriList = new URI[] {new URI("type://properties/test2/myresolver")};
    Configuration configuration = getConfiguration();
    configuration.setPlugInEventTypeResolutionURIs(uriList);
    epService = EPServiceProviderManager.getDefaultProvider(configuration);
    epService.initialize();

    runAssertionCaseDynamic(epService);
  }
 public void setUp() {
   Configuration configuration = SupportConfigFactory.getConfiguration();
   configuration.addEventType("SupportBean", SupportBean.class);
   configuration.addEventType("SupportBean_S0", SupportBean_S0.class);
   configuration.addEventType("SupportBean_S1", SupportBean_S1.class);
   configuration.getEngineDefaults().getLogging().setEnableExecutionDebug(true);
   epService = EPServiceProviderManager.getDefaultProvider(configuration);
   epService.initialize();
 }
  public void testSkipToNextRow() {
    Configuration config = SupportConfigFactory.getConfiguration();
    config.addEventType("MyEvent", SupportRecogBean.class);
    EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(config);
    epService.initialize();

    String[] fields = "a_string,b_string".split(",");
    String text =
        "select * from MyEvent.win:keepall() "
            + "match_recognize ("
            + "  measures A.theString as a_string, B.theString as b_string "
            + "  all matches "
            + "  after match skip to next row "
            + "  pattern (A B) "
            + "  define B as B.value > A.value"
            + ") "
            + "order by a_string, b_string";

    EPStatement stmt = epService.getEPAdministrator().createEPL(text);
    SupportUpdateListener listener = new SupportUpdateListener();
    stmt.addListener(listener);

    epService.getEPRuntime().sendEvent(new SupportRecogBean("E1", 5));
    epService.getEPRuntime().sendEvent(new SupportRecogBean("E2", 3));
    assertFalse(listener.isInvoked());
    assertFalse(stmt.iterator().hasNext());

    epService.getEPRuntime().sendEvent(new SupportRecogBean("E3", 6));
    EPAssertionUtil.assertPropsPerRow(
        listener.getAndResetLastNewData(), fields, new Object[][] {{"E2", "E3"}});
    EPAssertionUtil.assertPropsPerRow(stmt.iterator(), fields, new Object[][] {{"E2", "E3"}});

    epService.getEPRuntime().sendEvent(new SupportRecogBean("E4", 4));
    assertFalse(listener.isInvoked());
    EPAssertionUtil.assertPropsPerRow(stmt.iterator(), fields, new Object[][] {{"E2", "E3"}});

    epService.getEPRuntime().sendEvent(new SupportRecogBean("E5", 6));
    EPAssertionUtil.assertPropsPerRow(
        listener.getAndResetLastNewData(), fields, new Object[][] {{"E4", "E5"}});
    EPAssertionUtil.assertPropsPerRow(
        stmt.iterator(), fields, new Object[][] {{"E2", "E3"}, {"E4", "E5"}});

    epService.getEPRuntime().sendEvent(new SupportRecogBean("E6", 10));
    EPAssertionUtil.assertPropsPerRow(
        listener.getAndResetLastNewData(), fields, new Object[][] {{"E5", "E6"}});
    EPAssertionUtil.assertPropsPerRow(
        stmt.iterator(), fields, new Object[][] {{"E2", "E3"}, {"E4", "E5"}, {"E5", "E6"}});

    epService.getEPRuntime().sendEvent(new SupportRecogBean("E7", 9));
    epService.getEPRuntime().sendEvent(new SupportRecogBean("E8", 4));
    assertFalse(listener.isInvoked());
    EPAssertionUtil.assertPropsPerRow(
        stmt.iterator(), fields, new Object[][] {{"E2", "E3"}, {"E4", "E5"}, {"E5", "E6"}});

    stmt.stop();
  }
 public void setUp() {
   Configuration config = SupportConfigFactory.getConfiguration();
   epService = EPServiceProviderManager.getDefaultProvider(config);
   epService.initialize();
   epService
       .getEPAdministrator()
       .getConfiguration()
       .addEventType("SupportBean", SupportBean.class);
   epService.getEPAdministrator().getConfiguration().addEventType("ABean", SupportBean_S0.class);
 }
 public void setUp() {
   epService =
       EPServiceProviderManager.getDefaultProvider(SupportConfigFactory.getConfiguration());
   epService.initialize();
   epService
       .getEPAdministrator()
       .getConfiguration()
       .addImport(DefaultSupportCaptureOp.class.getName());
   MyExceptionHandler.getContexts().clear();
 }
  public void testSchemaXMLWSchemaWithAll() throws Exception {
    Configuration config = SupportConfigFactory.getConfiguration();
    ConfigurationEventTypeXMLDOM eventTypeMeta = new ConfigurationEventTypeXMLDOM();
    eventTypeMeta.setRootElementName("event-page-visit");
    String schemaUri =
        TestSchemaXMLEvent.class
            .getClassLoader()
            .getResource(CLASSLOADER_SCHEMA_WITH_ALL_URI)
            .toString();
    eventTypeMeta.setSchemaResource(schemaUri);
    eventTypeMeta.addNamespacePrefix("ss", "samples:schemas:simpleSchemaWithAll");
    eventTypeMeta.addXPathProperty("url", "/ss:event-page-visit/ss:url", XPathConstants.STRING);
    config.addEventType("PageVisitEvent", eventTypeMeta);

    epService = EPServiceProviderManager.getProvider("TestSchemaXML", config);
    epService.initialize();
    updateListener = new SupportUpdateListener();

    // url='page4'
    String text = "select a.url as sesja from pattern [ every a=PageVisitEvent(url='page1') ]";
    EPStatement stmt = epService.getEPAdministrator().createEPL(text);
    stmt.addListener(updateListener);

    SupportXML.sendEvent(
        epService.getEPRuntime(),
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
            + "<event-page-visit xmlns=\"samples:schemas:simpleSchemaWithAll\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"samples:schemas:simpleSchemaWithAll simpleSchemaWithAll.xsd\">\n"
            + "<url>page1</url>"
            + "</event-page-visit>");
    EventBean theEvent = updateListener.getLastNewData()[0];
    assertEquals("page1", theEvent.get("sesja"));
    updateListener.reset();

    SupportXML.sendEvent(
        epService.getEPRuntime(),
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
            + "<event-page-visit xmlns=\"samples:schemas:simpleSchemaWithAll\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"samples:schemas:simpleSchemaWithAll simpleSchemaWithAll.xsd\">\n"
            + "<url>page2</url>"
            + "</event-page-visit>");
    assertFalse(updateListener.isInvoked());

    EventType type =
        epService.getEPAdministrator().createEPL("select * from PageVisitEvent").getEventType();
    EPAssertionUtil.assertEqualsAnyOrder(
        new Object[] {
          new EventPropertyDescriptor(
              "sessionId", Node.class, null, false, false, false, false, true),
          new EventPropertyDescriptor(
              "customerId", Node.class, null, false, false, false, false, true),
          new EventPropertyDescriptor("url", String.class, null, false, false, false, false, false),
          new EventPropertyDescriptor("method", Node.class, null, false, false, false, false, true),
        },
        type.getPropertyDescriptors());
  }
  private EPServiceProvider getEngineInitialized(
      String name, String[] propertyNames, Object[] propertyTypes) {
    Configuration configuration = SupportConfigFactory.getConfiguration();
    if (name != null) {
      configuration.addEventType(name, propertyNames, propertyTypes);
    }

    EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(configuration);
    epService.initialize();
    return epService;
  }
  public void setUp() {
    listener = new SupportUpdateListener();
    priceLast3StatsListener = new SupportUpdateListener();
    priceAllStatsListener = new SupportUpdateListener();
    volumeLast3StatsListener = new SupportUpdateListener();
    volumeAllStatsListener = new SupportUpdateListener();

    epService =
        EPServiceProviderManager.getDefaultProvider(SupportConfigFactory.getConfiguration());
    epService.initialize();
  }
Exemple #24
0
  public static void main(String[] args)
      throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException {
    DOMConfigurator.configure("logger.xml");

    Configuration conf = new Configuration();
    conf.configure(new File("configuation.xml"));
    conf.getEngineDefaults().getThreading().setListenerDispatchPreserveOrder(false);

    conf.addEventTypeAutoName(Main.class.getPackage().getName());

    init(conf);

    EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(conf);
    String statement = "CREATE WINDOW trainSet.win:length(1000) as select * from InputTuple";
    epService.getEPAdministrator().createEPL(statement);

    statement = "INSERT INTO trainSet SELECT * FROM InputTuple";
    epService.getEPAdministrator().createEPL(statement);

    ////////// TASK 1. Performing Naive Bayes Classification over a data stream

    StreamClassifier classifier = new StreamClassifier(conf);
    classifier.verticalizeTuples(_fieldNames);
    EPStatement stmt = classifier.run(_fieldNames.length + 1);

    /////////// TASK 2. Periodically check quality of the classifier

    PeriodicChecker checker = new PeriodicChecker(conf, stmt);
    checker.run(
        "2 seconds", 100, 0.9); // every two seconds test last 100 tuples to satisfy threshold 0.7

    //////////

    _log.info("started");

    // emulate a continuous input
    AdapterInputSource adapterInputSource = new AdapterInputSource(new File("simulation.csv"));

    CSVInputAdapterSpec spec = new CSVInputAdapterSpec(adapterInputSource, "InputTuple");
    spec.setEventsPerSec(400);
    spec.setLooping(true);
    spec.setUsingEngineThread(true);

    (new CSVInputAdapter(epService, spec)).start();

    try {
      Thread.sleep(10000);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }

    _log.info("stopped");
  }
 public void setUp() {
   Configuration config = SupportConfigFactory.getConfiguration();
   config.addEventType("S0", SupportBean_S0.class);
   config.addEventType("S1", SupportBean_S1.class);
   config.addEventType("S2", SupportBean_S2.class);
   config.addEventType("S3", SupportBean_S3.class);
   config.addEventType("S4", SupportBean_S4.class);
   config.addEventType("S5", SupportBean_S5.class);
   epService = EPServiceProviderManager.getDefaultProvider(config);
   epService.initialize();
   listener = new SupportUpdateListener();
 }
Exemple #26
0
  public void setUp() {

    Configuration config = SupportConfigFactory.getConfiguration();
    config.addEventType("Bean", SupportBean_Container.class);
    config.addEventType("SupportCollection", SupportCollection.class);
    epService = EPServiceProviderManager.getDefaultProvider(config);
    epService.initialize();
    if (InstrumentationHelper.ENABLED) {
      InstrumentationHelper.startTest(epService, this.getClass(), getName());
    }
    listener = new SupportUpdateListener();
  }
  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());
  }
 public void setUp() {
   epService =
       EPServiceProviderManager.getDefaultProvider(SupportConfigFactory.getConfiguration());
   epService.initialize();
   if (InstrumentationHelper.ENABLED) {
     InstrumentationHelper.startTest(epService, this.getClass(), getName());
   }
   epService
       .getEPAdministrator()
       .getConfiguration()
       .addImport(DefaultSupportCaptureOp.class.getName());
 }
  public void setUp() {
    listener = new SupportUpdateListener();

    Configuration configuration = SupportConfigFactory.getConfiguration();
    configuration.addPlugInSingleRowFunction(
        "power3", MySingleRowFunction.class.getName(), "computePower3");
    configuration.addPlugInSingleRowFunction(
        "chainTop", MySingleRowFunction.class.getName(), "getChainTop");
    configuration.addPlugInSingleRowFunction(
        "surroundx", MySingleRowFunction.class.getName(), "surroundx");
    epService = EPServiceProviderManager.getDefaultProvider(configuration);
    epService.initialize();
  }
 public void setUp() {
   epService =
       EPServiceProviderManager.getDefaultProvider(SupportConfigFactory.getConfiguration());
   epService.initialize();
   for (Class clazz :
       new Class[] {SupportBean.class, SupportBean_S0.class, SupportBean_S1.class}) {
     epService.getEPAdministrator().getConfiguration().addEventType(clazz);
   }
   listener = new SupportUpdateListener();
   if (InstrumentationHelper.ENABLED) {
     InstrumentationHelper.startTest(epService, this.getClass(), getName());
   }
 }