-
Notifications
You must be signed in to change notification settings - Fork 7k
[Java] Support calling Ray APIs from multiple threads #3646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| int arg = random.nextInt(); | ||
| RayObject<Integer> obj = Ray.put(arg); | ||
| Assert.assertEquals(arg, (int) Ray.get(obj.getId())); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also add a test case of calling Ray.wait here.
83ae2b2 to
9fc839a
Compare
|
Test PASSed. |
| currentClassLoader = null; | ||
| currentTask = createDummyTask(workerMode, driverId); | ||
| mainThreadId = Thread.currentThread().getId(); | ||
| multiThreadingWarned = new AtomicBoolean(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, set default value to false
raulchen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM except one small comment.
|
Test FAILed. |
|
Test FAILed. |
|
Test FAILed. |
| workerId = workerMode == WorkerMode.DRIVER ? driverId : UniqueId.randomId(); | ||
| currentTaskPutCount = 0; | ||
| currentTaskCallCount = 0; | ||
| currentTaskPutCount = new AtomicInteger(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these also be reset to 0 in setCurrentTask?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, @jovan-wong can you fix this?
| public void setCurrentTask(TaskSpec currentTask) { | ||
| this.currentTask = currentTask; | ||
| currentTaskCallCount.set(0); | ||
| currentTaskCallCount.set(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currentTaskPutCount?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
Test FAILed. |
|
Test FAILed. |
What do these changes do?
We do these things for supporting this:
currentTaskPutCountandcurrentTaskCallCountas atomic variables.objectStoreas thread local.currentThreadTaskIds in different threads.Btw, the implementation of
getCurrentThreadTaskId()is quoted from @kfstorm, thanks.Related issue number
N/A