[java] Fix the logic of generating TaskID (#2747)

## What do these changes do?
Because the logic of generating `TaskID` in java is different from python's, there are many tests fail when we change the `Ray Core` code.
In this change,  I rewrote the logic of generating `TaskID` in java which is the same as the python's.

In java, we call the native method `_generateTaskId()` to generate a `TaskID` which is also used in python. We change `computePutId()`'s logic too.

## Related issue number
[#2608](https://github.com/ray-project/ray/issues/2608)
This commit is contained in:
Wang Qing
2018-08-28 04:11:33 +08:00
committed by Robert Nishihara
parent f37c260bdb
commit b4cba9a49f
17 changed files with 255 additions and 299 deletions
@@ -7,7 +7,7 @@ import java.util.Random;
import javax.xml.bind.DatatypeConverter;
/**
* Unique ID for task, worker, function...
* Unique ID for task, worker, function.
*/
public class UniqueID implements Serializable {
@@ -42,7 +42,8 @@ public class UniqueID implements Serializable {
public UniqueID(byte[] id) {
if (id.length != LENGTH) {
throw new IllegalArgumentException("Illegal argument: " + id.toString());
throw new IllegalArgumentException("Illegal argument for UniqueID, expect " + LENGTH
+ " bytes, but got " + id.length + " bytes.");
}
this.id = id;
@@ -86,11 +87,6 @@ public class UniqueID implements Serializable {
}
public boolean isNil() {
for (byte b : id) {
if (b != (byte) 0xFF) {
return false;
}
}
return true;
return this.equals(NIL);
}
}