Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions re-core/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<artifactId>re-core</artifactId>
Expand Down Expand Up @@ -28,17 +30,23 @@
<artifactId>en-diagram</artifactId>
<version>${enigma.version}</version>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>re-cache</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.g2forge.alexandria</groupId>
<artifactId>ax-log</artifactId>
<version>${alexandria.version}</version>
</dependency>

<dependency>
<groupId>com.g2forge.alexandria</groupId>
<artifactId>ax-workqueue</artifactId>
<version>${alexandria.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand All @@ -19,6 +18,9 @@
import com.g2forge.alexandria.java.core.error.HError;
import com.g2forge.alexandria.java.core.error.OrThrowable;
import com.g2forge.alexandria.java.core.helpers.HCollection;
import com.g2forge.alexandria.workqueue.BasicWorkQueueFactory;
import com.g2forge.alexandria.workqueue.IWorkQueueContext;
import com.g2forge.alexandria.workqueue.IWorkQueueHandler;
import com.g2forge.reassert.core.api.IReassertGraphBuilder;
import com.g2forge.reassert.core.api.IReassertGraphBuilder.ICallback;
import com.g2forge.reassert.core.api.ReassertGraphBuilder;
Expand Down Expand Up @@ -152,17 +154,18 @@ public Graph<IVertex, IEdge> createGraph(IOrigins origins) {
}

protected void extendGraph(final Callback<?> callback, final Graph<IVertex, IEdge> graph) {
final ArtifactLoadContext context = new ArtifactLoadContext(graph);
final LinkedList<IReassertGraphBuilder.ICallback<?>> queue = new LinkedList<>();
final ArtifactLoadContext artifactLoadContext = new ArtifactLoadContext(graph);
final Collection<Throwable> failures = new ArrayList<>();
queue.add(callback);
while (!queue.isEmpty()) {
handle(context, queue, queue.remove(), failures);
}
BasicWorkQueueFactory.create().run(new IWorkQueueHandler<IReassertGraphBuilder.ICallback<?>>() {
@Override
public void run(IWorkQueueContext<IReassertGraphBuilder.ICallback<?>> context, IReassertGraphBuilder.ICallback<?> task) {
handle(artifactLoadContext, context, task, failures);
}
}, callback);
if (!failures.isEmpty()) throw HError.withSuppressed(new RuntimeException("Failed to load one or more artifacts!"), failures);
}

protected <Coordinates extends ICoordinates> void handle(final ArtifactLoadContext loadContext, final Collection<IReassertGraphBuilder.ICallback<?>> queue, final ICallback<Coordinates> callback, final Collection<Throwable> failures) {
protected <Coordinates extends ICoordinates> void handle(final ArtifactLoadContext loadContext, final IWorkQueueContext<IReassertGraphBuilder.ICallback<?>> queueContext, final ICallback<Coordinates> callback, final Collection<Throwable> failures) {
final List<IReassertGraphBuilder.ICallback<?>> callbacks = new ArrayList<>();

final Artifact<Coordinates> unloadedArtifact = callback.getArtifact();
Expand Down Expand Up @@ -191,7 +194,7 @@ protected <Coordinates extends ICoordinates> void handle(final ArtifactLoadConte
name = coordinates.toString();
}

log.info(String.format("Starting %1$s with %2$d remaining", name, queue.size()));
log.info(String.format("Starting %1$s with %2$d remaining", name, queueContext.getApproximateQueueSize()));
}

final ReassertGraphBuilder builder = new ReassertGraphBuilder(loadContext.getGraph(), callbacks);
Expand All @@ -211,6 +214,6 @@ protected <Coordinates extends ICoordinates> void handle(final ArtifactLoadConte
}
callback.callback(artifact, builder);

queue.addAll(callbacks);
queueContext.queue(callbacks);
}
}