Exemplo n.º 1
0
  @Override
  public void update(
      EventBean[] newEvents,
      EventBean[] oldEvents,
      EPStatement epStatement,
      EPServiceProvider serviceProvider) {
    DebugListener.logger.debug("");
    DebugListener.logger.debug("-------------------------------");
    DebugListener.logger.debug("Update received for statement:");
    DebugListener.logger.debug("\tname: " + epStatement.getName());
    DebugListener.logger.debug("\ttext: " + epStatement.getText());

    if (newEvents != null) {
      DebugListener.logger.debug("new events:");
      DebugListener.logger.debug("\tsize: " + newEvents.length);

      for (int i = 0; i < newEvents.length; i++) {
        DebugListener.logger.debug("\tnumber " + i);
        DebugListener.logger.debug("\t\tbean:  " + newEvents[i]);

        try {
          Object obj = newEvents[i].get("value");
          DebugListener.logger.debug("\t\tvalue: " + obj);
        } catch (Throwable t) {
          /*empty*/
        }
      }
    } else {
      DebugListener.logger.debug("new events are null");
    }

    if (oldEvents != null) {
      DebugListener.logger.debug("old events:");
      DebugListener.logger.debug("\tsize: " + oldEvents.length);

      for (int i = 0; i < oldEvents.length; i++) {
        DebugListener.logger.debug("\tnumber " + i);
        DebugListener.logger.debug("\t\tbean: " + oldEvents[i]);
      }
    } else {
      DebugListener.logger.debug("old events are null");
    }

    DebugListener.logger.debug("service provider: ");
    DebugListener.logger.debug("\t" + serviceProvider);

    DebugListener.logger.debug("-------------------------------");
  }
 /**
  * Check that esper metrics are enabled (esper statement inserted). Check that listener will call
  * Spring Boot gauge service.
  *
  * @throws ConfigurationException
  * @throws EventTypeNotFoundException
  */
 @Test
 public void checkMetrics() throws ConfigurationException, EventTypeNotFoundException {
   esperEventProcessor.setConfiguration(getBasicConf());
   EventBean[] mockBeans = {mockMetricsBean};
   // Check that metric statement is inserted !
   for (EPStatement epStatement : esperEventProcessor.getEPStatements()) {
     if (epStatement.getName().equals("STATEMENT_METRIC")) {
       // Mock Esper metric event
       assertTrue(epStatement.getUpdateListeners().hasNext());
       epStatement.getUpdateListeners().next().update(mockBeans, null);
       // Check Gauge service is notified one for each metric
       verify(gaugeService, times(4)).submit(anyString(), anyDouble());
       return;
     }
   }
   fail("metric statement not found");
 }