public TSStatus createTraining(TCreateTrainingReq req) {
    TSStatus status = confirmLeader();
    if (nodeManager.getRegisteredAINodes().isEmpty()) {
      return new TSStatus(TSStatusCode.NO_REGISTERED_AI_NODE_ERROR.getStatusCode())
          .setMessage("There is no available AINode! Try to start one.");
    }

    TTrainingReq trainingReq = new TTrainingReq();
    trainingReq.setModelId(req.getModelId());
    trainingReq.setModelType("timer_xl");
    if (req.existingModelId != null) {
      trainingReq.setExistingModelId(req.getExistingModelId());
    }
    if (!req.parameters.isEmpty()) {
      trainingReq.setParameters(req.getParameters());
    }

    try {
      status = getConsensusManager().write(new CreateModelPlan(req.getModelId()));
      if (status.code != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
        throw new MetadataException("Can't init model " + req.getModelId());
      }

      List<IDataSchema> dataSchema;
      if (req.isTableModel) {
        dataSchema = fetchSchemaForTableModel(req);
        trainingReq.setDbType("iotdb.table");
      } else {
        dataSchema = fetchSchemaForTreeModel(req);
        trainingReq.setDbType("iotdb.tree");
      }
      updateModelInfo(new TUpdateModelInfoReq(req.modelId, ModelStatus.TRAINING.ordinal()));
      trainingReq.setTargetDataSchema(dataSchema);

      try (AINodeClient client =
          AINodeClientManager.getInstance().borrowClient(AINodeInfo.endPoint)) {
        status = client.createTrainingTask(trainingReq);
        if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
          throw new IllegalArgumentException(status.message);
        }
      }
    } catch (final Exception e) {
      status.setCode(TSStatusCode.CAN_NOT_CONNECT_CONFIGNODE.getStatusCode());
      status.setMessage(e.getMessage());
      try {
        updateModelInfo(new TUpdateModelInfoReq(req.modelId, ModelStatus.UNAVAILABLE.ordinal()));
      } catch (Exception e2) {
        LOGGER.error(e2.getMessage());
      }
    }
    return status;
  }
Get all related dataRegion which may contains the data of specific timeseries matched by given
patternTree
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java