public void doRegister(TriggerInformation triggerInformation, boolean isRestoring)
      throws IOException {
    try (TriggerClassLoader currentActiveClassLoader =
        TriggerClassLoaderManager.getInstance().updateAndGetActiveClassLoader()) {
      String triggerName = triggerInformation.getTriggerName();
      // register in trigger-table
      triggerTable.addTriggerInformation(triggerName, triggerInformation);
      // update PatternTreeMap
      patternTreeMap.append(triggerInformation.getPathPattern(), triggerName);
      // if it is a stateful trigger, we only maintain its instance on specified DataNode
      if (!triggerInformation.isStateful()
          || triggerInformation.getDataNodeLocation().getDataNodeId() == DATA_NODE_ID) {
        // get trigger instance
        Trigger trigger =
            constructTriggerInstance(triggerInformation.getClassName(), currentActiveClassLoader);
        // construct and save TriggerExecutor after successfully creating trigger instance
        TriggerExecutor triggerExecutor =
            new TriggerExecutor(triggerInformation, trigger, isRestoring);
        executorMap.put(triggerName, triggerExecutor);
      }
    } catch (Exception e) {
      String errorMessage =
          String.format(
              "Failed to register trigger %s with className: %s. The cause is: %s",
              triggerInformation.getTriggerName(), triggerInformation.getClassName(), e);
      LOGGER.warn(errorMessage);
      throw e;
    }
  }
Only call this method directly for registering new data node, otherwise you need to call
register().
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/trigger/service/TriggerManagementService.java