Nexus:名为 "Storage facet cleanup" 的未知任务

Nexus: Unknown Task called "Storage facet cleanup"

我安装了 Sonatype Nexus OSS 3.6.2-01 尽管我没有配置任何计划任务,但我可以在命令行中看到 Nexus 是 运行 每十分钟调用一次 "Storage facet cleanup" 的任务。

因为找不到关于这个任务的任何信息,所以我终于来到了这里。

2017-12-20 08:40:00,013+0100 INFO  [quartz-3-thread-19]  *SYSTEM org.sonatype.nexus.quartz.internal.task.QuartzTaskInfo - Task 'Storage facet cleanup' [repository.storage-facet-cleanup] state change WAITING -> RUNNING
2017-12-20 08:40:00,051+0100 INFO  [quartz-3-thread-19]  *SYSTEM org.sonatype.nexus.quartz.internal.task.QuartzTaskInfo - Task 'Storage facet cleanup' [repository.storage-facet-cleanup] state change RUNNING -> WAITING (OK)
2017-12-20 08:50:00,014+0100 INFO  [quartz-3-thread-19]  *SYSTEM org.sonatype.nexus.quartz.internal.task.QuartzTaskInfo - Task 'Storage facet cleanup' [repository.storage-facet-cleanup] state change WAITING -> RUNNING
2017-12-20 08:50:00,029+0100 INFO  [quartz-3-thread-19]  *SYSTEM org.sonatype.nexus.quartz.internal.task.QuartzTaskInfo - Task 'Storage facet cleanup' [repository.storage-facet-cleanup] state change RUNNING -> WAITING (OK)
2017-12-20 09:00:00,015+0100 INFO  [quartz-3-thread-19]  *SYSTEM org.sonatype.nexus.quartz.internal.task.QuartzTaskInfo - Task 'Storage facet cleanup' [repository.storage-facet-cleanup] state change WAITING -> RUNNING
2017-12-20 09:00:00,031+0100 INFO  [quartz-3-thread-19]  *SYSTEM org.sonatype.nexus.quartz.internal.task.QuartzTaskInfo - Task 'Storage facet cleanup' [repository.storage-facet-cleanup] state change RUNNING -> WAITING (OK)
2017-12-20 09:10:00,016+0100 INFO  [quartz-3-thread-19]  *SYSTEM org.sonatype.nexus.quartz.internal.task.QuartzTaskInfo - Task 'Storage facet cleanup' [repository.storage-facet-cleanup] state change WAITING -> RUNNING
2017-12-20 09:10:00,032+0100 INFO  [quartz-3-thread-19]  *SYSTEM org.sonatype.nexus.quartz.internal.task.QuartzTaskInfo - Task 'Storage facet cleanup' [repository.storage-facet-cleanup] state change RUNNING -> WAITING (OK)

这个任务是做什么用的?

为什么它在管理面板的 "Tasks" 部分不可见?

有没有办法禁用此任务(或仅在晚上配置它运行)?

这是一项清理任务,需要它才能正确使用 NXRM 运行。未列出,因为它不是 disablable/configurable.

这是 class StorageFacetCleanupTask 中定义的清理任务,其中 运行 performDeletions()storageFacetManager:

 @Override
  protected Void execute() throws Exception {
    thread = Thread.currentThread();
    long count;
    do {
      count = storageFacetManager.performDeletions();
    }
    while (count > 0 && !isCanceled());
    return null;
}

方法 performDeletionsStorageFacetManagerImpl 中定义,它删除所有标有 P_PENDING_DELETION:

的桶
    @Override
      @Guarded(by = STARTED)
      public long performDeletions() {
        List<Bucket> buckets = findBucketsForDeletion();
        return buckets.stream().filter((bucket) -> {
          try {
            log.info("Deleting bucket for repository {}", bucket.getRepositoryName());
            deleteBucket(bucket);
            return true;
          }
          catch (Exception e) {
            log.warn("Unable to delete bucket with repository name {}, will require manual cleanup",
                bucket.getRepositoryName(), e);
            return false;
          }
        }).count();
      }

所有标有P_PENDING_DELETION的桶都被findBucketsForDeletion收集在StorageFacetManagerImpl:

private List<Bucket> findBucketsForDeletion() {
    return inTx(databaseInstanceProvider).call(db -> {
      return StreamSupport
          .stream(bucketEntityAdapter.browse(db).spliterator(), false)
          .filter((bucket) -> bucket.attributes().contains(P_PENDING_DELETION))
          .collect(Collectors.toList());
    });
}