private void startScheduleDeleteJobs() {
    final Map<String /* deleteWhen */, JobInfo> jobs =
        new HashMap<String, MessageStoreManager.JobInfo>();
    // 启动quartz job
    for (final String topic : this.getAllTopics()) {
      final TopicConfig topicConfig = this.metaConfig.getTopicConfig(topic);
      final String deleteWhen =
          topicConfig != null ? topicConfig.getDeleteWhen() : this.metaConfig.getDeleteWhen();
      JobInfo jobInfo = jobs.get(deleteWhen);
      if (jobInfo == null) {
        final JobDetail job = newJob(DeleteJob.class).build();
        job.getJobDataMap().put(DeleteJob.TOPICS, new HashSet<String>());
        job.getJobDataMap().put(DeleteJob.STORE_MGR, this);
        final Trigger trigger =
            newTrigger().withSchedule(cronSchedule(deleteWhen)).forJob(job).build();
        jobInfo = new JobInfo(job, trigger);
        jobs.put(deleteWhen, jobInfo);
      }
      // 添加本topic
      ((Set<String>) jobInfo.job.getJobDataMap().get(DeleteJob.TOPICS)).add(topic);
    }

    for (final JobInfo jobInfo : jobs.values()) {
      try {
        this.scheduler.scheduleJob(jobInfo.job, jobInfo.trigger);
      } catch (final SchedulerException e) {
        throw new ServiceStartupException("Schedule delete job failed", e);
      }
    }
    try {
      this.scheduler.start();
    } catch (final SchedulerException e) {
      throw new ServiceStartupException("Start scheduler failed", e);
    }
  }
 DeletePolicySelector(final MetaConfig metaConfig) {
   for (final String topic : metaConfig.getTopics()) {
     final TopicConfig topicConfig = metaConfig.getTopicConfig(topic);
     final String deletePolicy =
         topicConfig != null ? topicConfig.getDeletePolicy() : metaConfig.getDeletePolicy();
     this.deletePolicyMap.put(topic, DeletePolicyFactory.getDeletePolicy(deletePolicy));
   }
 }
 private Set<File> getDataDirSet(final MetaConfig metaConfig) throws IOException {
   final Set<String> paths = new HashSet<String>();
   // public data path
   paths.add(metaConfig.getDataPath());
   // topic data path
   for (final String topic : metaConfig.getTopics()) {
     final TopicConfig topicConfig = metaConfig.getTopicConfig(topic);
     if (topicConfig != null) {
       paths.add(topicConfig.getDataPath());
     }
   }
   final Set<File> fileSet = new HashSet<File>();
   for (final String path : paths) {
     fileSet.add(this.getDataDir(path));
   }
   return fileSet;
 }
 public int getNumPartitions(final String topic) {
   final TopicConfig topicConfig = this.metaConfig.getTopicConfig(topic);
   return topicConfig != null
       ? topicConfig.getNumPartitions()
       : this.metaConfig.getNumPartitions();
 }