mirror of
https://github.com/wassname/ray.git
synced 2026-06-27 20:22:39 +08:00
Revert "Revert "Increase the number of unique bits for actors to avoi… (#12990)
This commit is contained in:
@@ -7,7 +7,7 @@ import java.util.Random;
|
||||
|
||||
public class ActorId extends BaseId implements Serializable {
|
||||
|
||||
private static final int UNIQUE_BYTES_LENGTH = 4;
|
||||
private static final int UNIQUE_BYTES_LENGTH = 12;
|
||||
|
||||
public static final int LENGTH = JobId.LENGTH + UNIQUE_BYTES_LENGTH;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.Random;
|
||||
*/
|
||||
public class ObjectId extends BaseId implements Serializable {
|
||||
|
||||
public static final int LENGTH = 20;
|
||||
public static final int LENGTH = 28;
|
||||
|
||||
/**
|
||||
* Create an ObjectId from a ByteBuffer.
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.Random;
|
||||
*/
|
||||
public class UniqueId extends BaseId implements Serializable {
|
||||
|
||||
public static final int LENGTH = 20;
|
||||
public static final int LENGTH = 28;
|
||||
public static final UniqueId NIL = genNil();
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,12 +12,12 @@ public class UniqueIdTest {
|
||||
@Test
|
||||
public void testConstructUniqueId() {
|
||||
// Test `fromHexString()`
|
||||
UniqueId id1 = UniqueId.fromHexString("00000000123456789ABCDEF123456789ABCDEF00");
|
||||
Assert.assertEquals("00000000123456789abcdef123456789abcdef00", id1.toString());
|
||||
UniqueId id1 = UniqueId.fromHexString("00000000123456789ABCDEF123456789ABCDEF0123456789ABCDEF00");
|
||||
Assert.assertEquals("00000000123456789abcdef123456789abcdef0123456789abcdef00", id1.toString());
|
||||
Assert.assertFalse(id1.isNil());
|
||||
|
||||
try {
|
||||
UniqueId id2 = UniqueId.fromHexString("000000123456789ABCDEF123456789ABCDEF00");
|
||||
UniqueId id2 = UniqueId.fromHexString("000000123456789ABCDEF123456789ABCDEF0123456789ABCDEF00");
|
||||
// This shouldn't be happened.
|
||||
Assert.assertTrue(false);
|
||||
} catch (IllegalArgumentException e) {
|
||||
@@ -33,16 +33,16 @@ public class UniqueIdTest {
|
||||
}
|
||||
|
||||
// Test `fromByteBuffer()`
|
||||
byte[] bytes = DatatypeConverter.parseHexBinary("0123456789ABCDEF0123456789ABCDEF01234567");
|
||||
ByteBuffer byteBuffer = ByteBuffer.wrap(bytes, 0, 20);
|
||||
byte[] bytes = DatatypeConverter.parseHexBinary("0123456789ABCDEF0123456789ABCDEF012345670123456789ABCDEF");
|
||||
ByteBuffer byteBuffer = ByteBuffer.wrap(bytes, 0, 28);
|
||||
UniqueId id4 = UniqueId.fromByteBuffer(byteBuffer);
|
||||
Assert.assertTrue(Arrays.equals(bytes, id4.getBytes()));
|
||||
Assert.assertEquals("0123456789abcdef0123456789abcdef01234567", id4.toString());
|
||||
Assert.assertEquals("0123456789abcdef0123456789abcdef012345670123456789abcdef", id4.toString());
|
||||
|
||||
|
||||
// Test `genNil()`
|
||||
UniqueId id6 = UniqueId.NIL;
|
||||
Assert.assertEquals("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF".toLowerCase(), id6.toString());
|
||||
Assert.assertEquals("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF".toLowerCase(), id6.toString());
|
||||
Assert.assertTrue(id6.isNil());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user