Hi Torgeir,
the following code contains more less all we do, from the creation of the
repository, the garbage collector and its execution. We actually run the
two gc methods into separated scheduled processes.

public void executeGarbageCollection() throws Exception {
  File storageRoot = new File("/tmp/oakrepo");

  OakFileDataStore fileDataStore = new OakFileDataStore();
  fileDataStore.init(storageRoot.getAbsolutePath());
  DataStoreBlobStore dataStoreBlobStore = new
DataStoreBlobStore(fileDataStore);
  FileStore fileStore =
FileStoreBuilder.fileStoreBuilder(storageRoot).withBlobStore(dataStoreBlobStore).build();
  SegmentNodeStore segmentStore =
SegmentNodeStoreBuilders.builder(fileStore).build();
  Oak oak = new Oak(segmentStore);
  Whiteboard whiteboard = oak.getWhiteboard();
  Jcr jcr = new Jcr(oak).with(new InitialContent()).with(whiteboard);
  JackrabbitRepository repository = (JackrabbitRepository)
jcr.createRepository();

  WhiteboardExecutor whiteboardExecutor = new WhiteboardExecutor();
  whiteboardExecutor.start(whiteboard);
  String clusterId = ClusterRepositoryInfo.getOrCreateId(segmentStore);
  ScheduledExecutorService statisticsProcess =
Executors.newSingleThreadScheduledExecutor();
  StatisticsProvider statisticsProvider = new
DefaultStatisticsProvider(statisticsProcess);
  MarkSweepGarbageCollector blobGarbageCollector = new
MarkSweepGarbageCollector(
          new SegmentBlobReferenceRetriever(fileStore),
          (GarbageCollectableBlobStore) fileStore.getBlobStore(),
          whiteboardExecutor,
          MarkSweepGarbageCollector.TEMP_DIR,
          MarkSweepGarbageCollector.DEFAULT_BATCH_COUNT,
          GarbageCollectorSettings.BLOB_MAX_AGE_IN_SEC,
          false,
          false,
          clusterId,
          whiteboard,
          statisticsProvider);

  fileStore.fullGC();
  blobGarbageCollector.collectGarbage(false);

  whiteboardExecutor.stop();
  statisticsProcess.shutdown();

  fileStore.close();
  repository.shutdown();
}

Marco.

On Fri, Oct 23, 2020 at 11:11 AM Torgeir Veimo <torgeir.ve...@gmail.com>
wrote:

> Can you show some code? There's a real lack of code showing how to do
> GC without using the default osgi configuration.
>
> On Fri, 23 Oct 2020 at 19:08, Marco Piovesana <pioves...@esteco.com>
> wrote:
> >
> > We use Oak alone so we handle the garbage collection, we used a specific
> > contractor for the *MarkSweepGarbageCollector *object that does not exist
> > anymore (now it has different parameters, no really big deal).
> >
> > Marco.
> >
> > On Fri, Oct 23, 2020 at 10:58 AM Julian Reschke <julian.resc...@gmx.de>
> > wrote:
> >
> > > Am 23.10.2020 um 10:22 schrieb Marco Piovesana:
> > > > Right, didn't think of jira for that, thanks Julian. Would that work
> also
> > > > for breaking changes? Do you guys have a convention for the jira
> issues
> > > to
> > > > highlight it?
> > > > I'm updating from the 1.14 to the latest stable 1.32, and there was
> just
> > > > one very easy breaking change.
> > > > ...
> > >
> > > It would include all changes; "breaking" changes do not have special
> > > treatment in Jira.
> > >
> > > That said: I wasn't aware of a breaking change. Can you elaborate?
> > >
> > > Best regards, Julian
> > >
>
>
>
> --
> -Tor
>

Reply via email to