@Override
 public void writeLine(String line) throws IOException {
   if (outputEnabled) {
     double rate;
     if (maxEventRateChecker.updateAndCheckRate()
         && (rate = maxEventRateChecker.getRate()) > maxLogsRate) {
       outputEnabled = false;
       final String message =
           String.format(
               "[WARNING] Application '%s' has exceeded output rate of %.2f messages / second. Application output has been disabled.",
               project.startsWith("/") ? project.substring(1) : project, rate);
       eventService.publish(
           RunnerEvent.messageLoggedEvent(
               processId,
               workspace,
               project,
               new RunnerEvent.LoggedMessage(message, lineCounter.getAndIncrement())));
       return;
     }
     if (line != null) {
       eventService.publish(
           RunnerEvent.messageLoggedEvent(
               processId,
               workspace,
               project,
               new RunnerEvent.LoggedMessage(line, lineCounter.getAndIncrement())));
     }
   }
   super.writeLine(line);
 }
示例#2
0
  @Test
  public void shouldPublishStackPersistedEventAfterStackIsPersisted() throws Exception {
    final boolean[] isNotified = new boolean[] {false};
    eventService.subscribe(event -> isNotified[0] = true, StackPersistedEvent.class);

    stackDao.create(createStack("test", "test"));

    assertTrue(isNotified[0], "Event subscriber notified");
  }
 @PreDestroy
 void stop() {
   eventService.unsubscribe(projectCreatedEventSubscriber);
 }
 @PostConstruct
 void start() {
   eventService.subscribe(projectCreatedEventSubscriber);
 }
示例#5
0
 @PreDestroy
 public void unsubscribe() {
   eventService.unsubscribe(this, BeforeUserRemovedEvent.class);
 }
示例#6
0
 @PostConstruct
 public void subscribe() {
   eventService.subscribe(this, BeforeUserRemovedEvent.class);
 }
示例#7
0
 @PreRemove
 private void preRemove(RecipeImpl recipe) {
   eventService.publish(new BeforeRecipeRemovedEvent(recipe));
 }