Add method getCurrentlyAvailableNodes to QueryableGraph and Walkable Graph
It allows all graph implementations to return the list of nodes which are
immediately available to be fetched. NOTE: Not-currently-available here does
not mean the nodes do not exist in the graph. It simply means they are not
ready to be fetched immediately yet.
--
MOS_MIGRATED_REVID=137701432
diff --git a/src/test/java/com/google/devtools/build/skyframe/GraphConcurrencyTest.java b/src/test/java/com/google/devtools/build/skyframe/GraphTest.java
similarity index 96%
rename from src/test/java/com/google/devtools/build/skyframe/GraphConcurrencyTest.java
rename to src/test/java/com/google/devtools/build/skyframe/GraphTest.java
index 6490835..0510523 100644
--- a/src/test/java/com/google/devtools/build/skyframe/GraphConcurrencyTest.java
+++ b/src/test/java/com/google/devtools/build/skyframe/GraphTest.java
@@ -43,8 +43,8 @@
import org.junit.Before;
import org.junit.Test;
-/** Base class for concurrency sanity tests on {@link EvaluableGraph} implementations. */
-public abstract class GraphConcurrencyTest {
+/** Base class for sanity tests on {@link EvaluableGraph} implementations. */
+public abstract class GraphTest {
private static final SkyFunctionName SKY_FUNCTION_NAME = SkyFunctionName.FOR_TESTING;
protected ProcessableGraph graph;
@@ -154,8 +154,9 @@
@Test
public void testAddRemoveRdeps() throws Exception {
SkyKey key = key("foo");
- final NodeEntry entry = Iterables.getOnlyElement(
- graph.createIfAbsentBatch(null, Reason.OTHER, ImmutableList.of(key)).values());
+ final NodeEntry entry =
+ Iterables.getOnlyElement(
+ graph.createIfAbsentBatch(null, Reason.OTHER, ImmutableList.of(key)).values());
// These numbers are arbitrary.
int numThreads = 50;
int numKeys = numThreads;
@@ -459,6 +460,19 @@
}
}
+ @Test
+ public void testGetCurrentlyAvailableNodes() throws Exception {
+ SkyKey foo = key("foo");
+ SkyKey bar = key("bar");
+ SkyKey foobar = key("foobar");
+ graph.createIfAbsentBatch(null, Reason.OTHER, ImmutableList.of(foo, bar));
+
+ Iterable<SkyKey> currentlyAvailable =
+ graph.getCurrentlyAvailableNodes(ImmutableList.of(foo, bar, foobar), Reason.OTHER);
+
+ assertThat(currentlyAvailable).containsExactly(foo, bar);
+ }
+
private static DependencyState startEvaluation(NodeEntry entry) throws InterruptedException {
return entry.addReverseDepAndCheckIfDone(null);
}
diff --git a/src/test/java/com/google/devtools/build/skyframe/InMemoryGraphConcurrencyTest.java b/src/test/java/com/google/devtools/build/skyframe/InMemoryGraphTest.java
similarity index 90%
rename from src/test/java/com/google/devtools/build/skyframe/InMemoryGraphConcurrencyTest.java
rename to src/test/java/com/google/devtools/build/skyframe/InMemoryGraphTest.java
index 18d6875..0180391 100644
--- a/src/test/java/com/google/devtools/build/skyframe/InMemoryGraphConcurrencyTest.java
+++ b/src/test/java/com/google/devtools/build/skyframe/InMemoryGraphTest.java
@@ -14,13 +14,12 @@
package com.google.devtools.build.skyframe;
import com.google.devtools.build.lib.util.Preconditions;
-
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
-/** Concurrency tests for {@link InMemoryGraphImpl}. */
+/** Tests for {@link InMemoryGraphImpl}. */
@RunWith(JUnit4.class)
-public class InMemoryGraphConcurrencyTest extends GraphConcurrencyTest {
+public class InMemoryGraphTest extends GraphTest {
private ProcessableGraph graph;
@Override
diff --git a/src/test/java/com/google/devtools/build/skyframe/NotifyingHelper.java b/src/test/java/com/google/devtools/build/skyframe/NotifyingHelper.java
index 6cde573..559b3cf 100644
--- a/src/test/java/com/google/devtools/build/skyframe/NotifyingHelper.java
+++ b/src/test/java/com/google/devtools/build/skyframe/NotifyingHelper.java
@@ -100,6 +100,11 @@
throws InterruptedException {
return notifyingHelper.wrapEntry(key, delegate.get(requestor, reason, key));
}
+
+ @Override
+ public Iterable<SkyKey> getCurrentlyAvailableNodes(Iterable<SkyKey> keys, Reason reason) {
+ return delegate.getCurrentlyAvailableNodes(keys, reason);
+ }
}
static class NotifyingProcessableGraph