Fix duplicated timeout logic in AbstractRayRuntime.get() (#5338)

This commit is contained in:
Kai Yang
2019-08-06 13:36:49 +08:00
committed by Hao Chen
parent 32f275344b
commit 384cbfb211
11 changed files with 45 additions and 285 deletions
@@ -11,7 +11,7 @@ import org.ray.api.exception.UnreconstructableException;
import org.ray.api.id.UniqueId;
import org.ray.runtime.AbstractRayRuntime;
import org.ray.runtime.RayActorImpl;
import org.ray.runtime.objectstore.ObjectStoreProxy.GetResult;
import org.ray.runtime.objectstore.NativeRayObject;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -100,9 +100,10 @@ public class ActorTest extends BaseTest {
Ray.internal().free(ImmutableList.of(value.getId()), false, false);
// Wait until the object is deleted, because the above free operation is async.
while (true) {
GetResult<Integer> result = ((AbstractRayRuntime)
Ray.internal()).getObjectStoreProxy().get(value.getId(), 0);
if (!result.exists) {
NativeRayObject result = ((AbstractRayRuntime)
Ray.internal()).getObjectStoreProxy().getObjectInterface()
.get(ImmutableList.of(value.getId()), 0).get(0);
if (result == null) {
break;
}
TimeUnit.MILLISECONDS.sleep(100);
@@ -23,8 +23,9 @@ public class PlasmaFreeTest extends BaseTest {
Assert.assertEquals("hello", helloString);
Ray.internal().free(ImmutableList.of(helloId.getId()), true, false);
final boolean result = TestUtils.waitForCondition(() -> !((AbstractRayRuntime) Ray.internal())
.getObjectStoreProxy().get(helloId.getId(), 0).exists, 50);
final boolean result = TestUtils.waitForCondition(() ->
((AbstractRayRuntime) Ray.internal()).getObjectStoreProxy().getObjectInterface()
.get(ImmutableList.of(helloId.getId()), 0).get(0) == null, 50);
Assert.assertTrue(result);
}
@@ -17,9 +17,9 @@ public class PlasmaStoreTest extends BaseTest {
AbstractRayRuntime runtime = (AbstractRayRuntime) Ray.internal();
ObjectStoreProxy objectInterface = runtime.getObjectStoreProxy();
objectInterface.put(objectId, 1);
Assert.assertEquals(objectInterface.<Integer>get(objectId, -1).object, (Integer) 1);
Assert.assertEquals(objectInterface.<Integer>get(objectId), (Integer) 1);
objectInterface.put(objectId, 2);
// Putting 2 objects with duplicate ID should fail but ignored.
Assert.assertEquals(objectInterface.<Integer>get(objectId, -1).object, (Integer) 1);
Assert.assertEquals(objectInterface.<Integer>get(objectId), (Integer) 1);
}
}