@Test public void rebuildIsCancelable() throws Exception { Component component = mock(Component.class); Asset asset = mock(Asset.class); doReturn(infiniteContinuation(component)).when(components).browse(anyInt(), anyString()); doReturn(infiniteContinuation(asset)).when(assets).browse(anyInt(), anyString()); final AtomicBoolean canceled = new AtomicBoolean(false); final List<Throwable> uncaught = new ArrayList<>(); Thread taskThread = new Thread(() -> { CancelableHelper.set(canceled); new DatastoreMetadataRebuilder(10, 20).rebuild(repository, true, false, "group", "artifact", "version"); }); taskThread.setUncaughtExceptionHandler((t, e) -> { if (e instanceof TaskInterruptedException) { return; } uncaught.add(e); }); taskThread.start(); sleep((long) (Math.random() * 1000)); canceled.set(true); taskThread.join(5000); if (taskThread.isAlive()) { fail("Task did not cancel"); } if (uncaught.size() > 0) { throw new MultipleFailureException(uncaught); } }
@Transactional @Override public boolean rebuild( final Repository repository, final boolean update, final boolean rebuildChecksums, @Nullable final String groupId, @Nullable final String artifactId, @Nullable final String baseVersion) { checkNotNull(repository); return rebuildInTransaction(repository, update, rebuildChecksums, groupId, artifactId, baseVersion); }
DatastoreMetadataRebuilder extends AbstractMetadataRebuilder { @Transactional @Override public boolean rebuild( final Repository repository, final boolean update, final boolean rebuildChecksums, @Nullable final String groupId, @Nullable final String artifactId, @Nullable final String baseVersion) { checkNotNull(repository); return rebuildInTransaction(repository, update, rebuildChecksums, groupId, artifactId, baseVersion); } }
DatastoreMetadataRebuilder extends AbstractMetadataRebuilder { @Transactional @Override public boolean rebuild( final Repository repository, final boolean update, final boolean rebuildChecksums, @Nullable final String groupId, @Nullable final String artifactId, @Nullable final String baseVersion) { checkNotNull(repository); return rebuildInTransaction(repository, update, rebuildChecksums, groupId, artifactId, baseVersion); } @Inject  DatastoreMetadataRebuilder(
      @Named("${nexus.maven.metadata.rebuild.bufferSize:-1000}") final int bufferSize,
      @Named("${nexus.maven.metadata.rebuild.timeoutSeconds:-60}") final int timeoutSeconds); }
DatastoreMetadataRebuilder extends AbstractMetadataRebuilder { @Transactional @Override public boolean rebuild( final Repository repository, final boolean update, final boolean rebuildChecksums, @Nullable final String groupId, @Nullable final String artifactId, @Nullable final String baseVersion) { checkNotNull(repository); return rebuildInTransaction(repository, update, rebuildChecksums, groupId, artifactId, baseVersion); } @Inject  DatastoreMetadataRebuilder(
      @Named("${nexus.maven.metadata.rebuild.bufferSize:-1000}") final int bufferSize,
      @Named("${nexus.maven.metadata.rebuild.timeoutSeconds:-60}") final int timeoutSeconds); @Transactional @Override boolean rebuild(
      final Repository repository,
      final boolean update,
      final boolean rebuildChecksums,
      @Nullable final String groupId,
      @Nullable final String artifactId,
      @Nullable final String baseVersion); @Override boolean rebuildInTransaction(
      final Repository repository,
      final boolean update,
      final boolean rebuildChecksums,
      @Nullable final String groupId,
      @Nullable final String artifactId,
      @Nullable final String baseVersion); @Override boolean exists(final Repository repository, final MavenPath mavenPath); @Override void deleteMetadata(final Repository repository, final List<String[]> gavs); }
DatastoreMetadataRebuilder extends AbstractMetadataRebuilder { @Transactional @Override public boolean rebuild( final Repository repository, final boolean update, final boolean rebuildChecksums, @Nullable final String groupId, @Nullable final String artifactId, @Nullable final String baseVersion) { checkNotNull(repository); return rebuildInTransaction(repository, update, rebuildChecksums, groupId, artifactId, baseVersion); } @Inject  DatastoreMetadataRebuilder(
      @Named("${nexus.maven.metadata.rebuild.bufferSize:-1000}") final int bufferSize,
      @Named("${nexus.maven.metadata.rebuild.timeoutSeconds:-60}") final int timeoutSeconds); @Transactional @Override boolean rebuild(
      final Repository repository,
      final boolean update,
      final boolean rebuildChecksums,
      @Nullable final String groupId,
      @Nullable final String artifactId,
      @Nullable final String baseVersion); @Override boolean rebuildInTransaction(
      final Repository repository,
      final boolean update,
      final boolean rebuildChecksums,
      @Nullable final String groupId,
      @Nullable final String artifactId,
      @Nullable final String baseVersion); @Override boolean exists(final Repository repository, final MavenPath mavenPath); @Override void deleteMetadata(final Repository repository, final List<String[]> gavs);  }