public void updateLocationOfStatefulTrigger(String triggerName, TDataNodeLocation newLocation)
      throws IOException {
    try {
      acquireLock();
      TriggerInformation triggerInformation = triggerTable.getTriggerInformation(triggerName);
      if (triggerInformation == null || !triggerInformation.isStateful()) {
        return;
      }
      triggerInformation.setDataNodeLocation(newLocation);
      triggerTable.addTriggerInformation(triggerName, triggerInformation);
      if (newLocation.getDataNodeId() != DATA_NODE_ID) {
        // The instance of stateful trigger is created on another DataNode. We need to drop the
        // instance if it exists on this DataNode
        TriggerExecutor triggerExecutor = executorMap.remove(triggerName);
        if (triggerExecutor != null) {
          triggerExecutor.onDrop();
        }
      } else {
        TriggerExecutor triggerExecutor = executorMap.get(triggerName);
        if (triggerExecutor != null) {
          return;
        }
        // newLocation of stateful trigger is this DataNode, we need to create its instance if it
        // does not exist.
        try (TriggerClassLoader currentActiveClassLoader =
            TriggerClassLoaderManager.getInstance().updateAndGetActiveClassLoader()) {
          TriggerExecutor newExecutor =
              new TriggerExecutor(
                  triggerInformation,
                  constructTriggerInstance(
                      triggerInformation.getClassName(), currentActiveClassLoader),
                  true);
          executorMap.put(triggerName, newExecutor);
        }
      }
    } finally {
      releaseLock();
    }
  }
Maintain a PatternTree: PathPattern -> List<String> triggerNames Return the triggerNames of
triggers whose PathPatterns match the given one.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/trigger/service/TriggerManagementService.java