public void refresh() throws Exception {
   this.lock.lock();
   try {
     // 判断状态是否终止
     ManagerFactoryInfo stsInfo =
         this.getScheduleStrategyManager().loadManagerFactoryInfo(this.getUuid());
     if (stsInfo.isStart() == false) {
       stopServer(null); // 停止所有的调度任务
       this.getScheduleStrategyManager().unRregisterManagerFactory(this);
     } else {
       for (String baseTaskType : this.baseTaskList.keySet()) {
         ScheduleTaskType taskType =
             this.getScheduleDataManager().loadTaskTypeBaseInfo(baseTaskType);
         if (ScheduleTaskType.STS_PAUSE.equals(taskType.getSts())) {
           this.pauseServer(baseTaskType);
         } else if (ScheduleTaskType.STS_RESUME.equals(taskType.getSts())) {
           this.resumeServer(baseTaskType);
         }
       }
       List<String> stopList = this.getScheduleStrategyManager().registerManagerFactory(this);
       for (String taskType : stopList) {
         this.stopServer(taskType);
       }
       this.assignScheduleServer();
       this.reRunScheduleServer();
     }
   } finally {
     this.lock.unlock();
   }
 }
  /**
   * 创建调度服务器
   *
   * @param baseTaskType
   * @param dealBeanName
   * @param ownSign
   * @return
   * @throws Exception
   */
  public TBScheduleManager createTBScheduleManager(
      String baseTaskType, String dealBeanName, String ownSign) throws Exception {
    if (scheduleDataManager == null) {
      throw new Exception("没有设置配置中心客户端的接口实现,请在Spring中配置,或者通过程序设置");
    }
    this.lock.lock();
    try {
      int managerPort = MBeanManagerFactory.getHtmlAdaptorPort();
      String jmxUrl = MBeanManagerFactory.getManangerUrl();
      // 清除已经过期1天的TASK,OWN_SIGN的组合。超过一天没有活动server的视为过期
      ScheduleTaskType baseTaskTypeInfo = scheduleDataManager.loadTaskTypeBaseInfo(baseTaskType);

      scheduleDataManager.clearExpireTaskTypeRunningInfo(
          baseTaskType,
          ScheduleUtil.getLocalIP() + "清除过期OWN_SIGN信息",
          baseTaskTypeInfo.getExpireOwnSignInterval());

      if (ScheduleTaskType.STS_PAUSE.equals(baseTaskTypeInfo.getSts()) == true) {
        this.baseTaskList.put(baseTaskType, baseTaskType);
        String taskType = TBScheduleManager.getTaskTypeByBaseAndOwnSign(baseTaskType, ownSign);
        AtomicInteger count = (AtomicInteger) this.pauseTaskType.get(taskType);
        if (count == null) {
          count = new AtomicInteger(1);
        } else {
          count.incrementAndGet();
        }
        this.pauseTaskType.put(taskType, count);
        return null;
      }

      if (dealBeanName == null || dealBeanName.trim().length() == 0) {
        dealBeanName = baseTaskTypeInfo.getDealBeanName();
      }
      Object dealBean = applicationcontext.getBean(dealBeanName);

      if (dealBean == null) {
        throw new Exception("SpringBean " + dealBeanName + " 不存在");
      }
      if (dealBean instanceof IScheduleTaskDeal == false) {
        throw new Exception(
            "SpringBean " + baseTaskTypeInfo.getDealBeanName() + " 没有实现 IScheduleTaskDeal接口");
      }
      TBScheduleManager result =
          new TBScheduleManagerStatic(
              this,
              baseTaskType,
              ownSign,
              managerPort,
              jmxUrl,
              scheduleDataManager,
              (IScheduleTaskDeal<?>) dealBean);
      MBeanManagerFactory.registerMBean(new TBScheduleManagerMBean(result), result.getmBeanName());
      String key =
          TBScheduleManager.getTaskTypeByBaseAndOwnSign(baseTaskType, ownSign)
              + "$"
              + result.hashCode();
      managerMap.put(key, result);
      this.baseTaskList.put(baseTaskType, baseTaskType);
      return result;
    } finally {
      this.lock.unlock();
    }
  }