Skip to content

Commit

Permalink
enable prov and access logs for [--prov-mode]
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorrit Poelen committed Jan 2, 2025
1 parent a000914 commit 9482dc6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,10 @@ protected void stop() {


protected ActivityListener getActivityListener(String namespaceLocal) {
return getEnableProvMode()
? new ProvLogger(getStatementListener())
: new AccessLogger(namespaceLocal, getProvDir());
AccessLogger accessLogger = new AccessLogger(namespaceLocal, getProvDir());
return new ActivityProxy(getEnableProvMode()
? Arrays.asList(new ProvLogger(getStatementListener()), accessLogger)
: Collections.singletonList(accessLogger));
}

protected ActivityListener getActivityListener() {
Expand Down
20 changes: 2 additions & 18 deletions src/main/java/org/globalbioticinteractions/elton/cmd/CmdList.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@
import org.globalbioticinteractions.dataset.DatasetRegistryGitHubArchive;
import org.globalbioticinteractions.dataset.DatasetRegistryProxy;
import org.globalbioticinteractions.dataset.DatasetRegistryZenodo;
import org.globalbioticinteractions.dataset.DatasetWithCache;
import org.globalbioticinteractions.elton.store.AccessLogger;
import org.globalbioticinteractions.elton.store.ActivityListener;
import org.globalbioticinteractions.elton.store.CachePullThroughPrestonStore;
import org.globalbioticinteractions.elton.store.LocalPathToHashIRI;
import org.globalbioticinteractions.elton.store.ActivityProxy;
import org.globalbioticinteractions.elton.store.ProvLoggerWithClock;
import org.globalbioticinteractions.elton.util.DatasetRegistryUtil;
import org.globalbioticinteractions.elton.util.ResourceServiceListening;
import picocli.CommandLine;

import java.io.File;
Expand All @@ -37,7 +34,6 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Supplier;

@CommandLine.Command(
Expand Down Expand Up @@ -147,19 +143,7 @@ public Literal get() {
public InputStream retrieve(URI uri) throws IOException {
IRI activityId = getActivityIdFactory().get();
IRI request = RefNodeFactory.toIRI(uri);
final ActivityListener proxy = new ActivityListener() {
List<ActivityListener> listeners = Arrays.asList(logger, activityListener);

@Override
public void onStarted(IRI parentActivityId, IRI activityId, IRI request) {
listeners.forEach(listener -> listener.onStarted(parentActivityId, activityId, request));
}

@Override
public void onCompleted(IRI parentActivityId, IRI activityId, IRI request, IRI response, URI localPathOfResponseData) {
listeners.forEach(listener -> listener.onCompleted(parentActivityId, activityId, request, response, localPathOfResponseData));
}
};
final ActivityListener proxy = new ActivityProxy(Arrays.asList(logger, activityListener));
proxy.onStarted(getActivityContext().getActivity(), activityId, request);
InputStream retrieve = resourceServiceRemote.retrieve(uri);
IRI put = blobStore.put(retrieve);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;

@CommandLine.Command(
name = "sync",
Expand Down Expand Up @@ -62,9 +64,18 @@ protected void doRun() {
}

DatasetRegistry registryProxy = new DatasetRegistryProxy(registries);

DatasetRegistryAccessLogger accessLogger = new DatasetRegistryAccessLogger(registryProxy, getProvDir());

DatasetRegistryProxy provAndAccessLogger = new DatasetRegistryProxy(
Arrays.asList(
new DatasetRegistryProvLogger(registryProxy, getStatementListener(), getActivityContext()),
accessLogger)
);

DatasetRegistry registryProvenanceLogger = getEnableProvMode()
? new DatasetRegistryProvLogger(registryProxy, getStatementListener(), getActivityContext())
: new DatasetRegistryAccessLogger(registryProxy, getProvDir());
? provAndAccessLogger
: accessLogger;


NamespaceHandler namespaceHandler = namespace -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public ActivityProxy(List<ActivityListener> listeners) {

@Override
public void onStarted(IRI parentActivityId, IRI activityId, IRI request) {
listeners.forEach(l -> l.onStarted(parentActivityId, activityId, request));

}

Expand Down

0 comments on commit 9482dc6

Please sign in to comment.