@SuppressWarnings("unchecked")
  @Override
  public void afterPropertiesSet() throws Exception {

    TaskTrackerProperties properties = null;
    if (locations == null || locations.length == 0) {
      properties = new TaskTrackerProperties();
      properties.setClusterName(clusterName);
      properties.setDataPath(dataPath);
      properties.setNodeGroup(nodeGroup);
      properties.setRegistryAddress(registryAddress);
      properties.setBindIp(bindIp);
      properties.setIdentity(identity);
      properties.setWorkThreads(workThreads);
      properties.setConfigs(CollectionUtils.toMap(configs));
      properties.setBizLoggerLevel(bizLoggerLevel);
    } else {
      properties =
          PropertiesConfigurationFactory.createPropertiesConfiguration(
              TaskTrackerProperties.class, locations);
    }

    taskTracker = TaskTrackerBuilder.buildByProperties(properties);

    registerRunnerBeanDefinition();

    // 设置config
    for (Map.Entry<Object, Object> entry : configs.entrySet()) {
      taskTracker.addConfig(entry.getKey().toString(), entry.getValue().toString());
    }

    taskTracker.setRunnerFactory(
        new RunnerFactory() {
          @Override
          public JobRunner newRunner() {
            return (JobRunner) applicationContext.getBean(jobRunnerBeanName);
          }
        });

    if (masterChangeListeners != null) {
      for (MasterChangeListener masterChangeListener : masterChangeListeners) {
        taskTracker.addMasterChangeListener(masterChangeListener);
      }
    }
  }
 @Override
 public void destroy() throws Exception {
   taskTracker.stop();
 }
 /** 可以自己得到TaskTracker对象后调用,也可以直接使用spring配置中的init属性指定该方法 */
 public void start() {
   if (!started) {
     taskTracker.start();
     started = true;
   }
 }