@Override
  public void onAlertPublishSpecChange(PublishSpec pubSpec, Map<String, StreamDefinition> sds) {
    if (pubSpec == null) {
      return;
    }

    List<Publishment> newPublishments = pubSpec.getPublishments();
    if (newPublishments == null) {
      LOG.info("no publishments with PublishSpec {} for this topology", pubSpec);
      return;
    }

    Map<String, Publishment> newPublishmentsMap = new HashMap<>();
    newPublishments.forEach(p -> newPublishmentsMap.put(p.getName(), p));
    MapComparator<String, Publishment> comparator =
        new MapComparator<>(newPublishmentsMap, cachedPublishments);
    comparator.compare();

    List<Publishment> beforeModified = new ArrayList<>();
    comparator.getModified().forEach(p -> beforeModified.add(cachedPublishments.get(p.getName())));
    alertPublisher.onPublishChange(
        comparator.getAdded(), comparator.getRemoved(), comparator.getModified(), beforeModified);

    // switch
    cachedPublishments = newPublishmentsMap;
    specVersion = pubSpec.getVersion();
  }
 @Override
 public void execute(Tuple input) {
   try {
     streamContext.counter().scope("receive_count");
     alertPublisher.nextEvent((AlertStreamEvent) input.getValueByField(AlertConstants.FIELD_1));
     this.collector.ack(input);
     streamContext.counter().scope("ack_count");
   } catch (Exception ex) {
     streamContext.counter().scope("fail_count");
     LOG.error(ex.getMessage(), ex);
     collector.reportError(ex);
   }
 }
 @Override
 public void cleanup() {
   alertPublisher.close();
   super.cleanup();
 }