public TSStatus activeCQ(ActiveCQPlan plan) {
    TSStatus res = new TSStatus();
    String cqId = plan.getCqId();
    String md5 = plan.getMd5();
    lock.writeLock().lock();
    try {
      CQEntry cqEntry = cqMap.get(cqId);
      if (cqEntry == null) {
        res.code = TSStatusCode.NO_SUCH_CQ.getStatusCode();
        res.message = String.format(CQ_NOT_EXIST_FORMAT, cqId);
      } else if (!md5.equals(cqEntry.md5)) {
        res.code = TSStatusCode.NO_SUCH_CQ.getStatusCode();
        res.message = String.format(MD5_NOT_MATCH_FORMAT, cqId);
      } else if (cqEntry.state == CQState.ACTIVE) {
        res.code = TSStatusCode.CQ_ALREADY_ACTIVE.getStatusCode();
        res.message = String.format("CQ %s has already been active", cqId);
      } else {
        cqEntry.state = CQState.ACTIVE;
        res.code = TSStatusCode.SUCCESS_STATUS.getStatusCode();
      }
      return res;
    } finally {
      lock.writeLock().unlock();
    }
  }
Change the state of cq to ACTIVE.

@return Optional.empty() if there is no such cq, otherwise previous state of this cq.
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/cq/CQInfo.java