HADOOP-9770. Make RetryCache#state non volatile. Contributed by Suresh Srinivas.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1507414 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
07b076917e
commit
b3d7442b2b
@ -496,6 +496,8 @@ Release 2.1.0-beta - 2013-07-02
|
|||||||
HADOOP-9756. Remove the deprecated getServer(..) methods from RPC.
|
HADOOP-9756. Remove the deprecated getServer(..) methods from RPC.
|
||||||
(Junping Du via szetszwo)
|
(Junping Du via szetszwo)
|
||||||
|
|
||||||
|
HADOOP-9770. Make RetryCache#state non volatile. (suresh)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
HADOOP-9150. Avoid unnecessary DNS resolution attempts for logical URIs
|
HADOOP-9150. Avoid unnecessary DNS resolution attempts for logical URIs
|
||||||
|
@ -52,7 +52,7 @@ public static class CacheEntry implements LightWeightCache.Entry {
|
|||||||
private static byte SUCCESS = 1;
|
private static byte SUCCESS = 1;
|
||||||
private static byte FAILED = 2;
|
private static byte FAILED = 2;
|
||||||
|
|
||||||
private volatile byte state = INPROGRESS;
|
private byte state = INPROGRESS;
|
||||||
|
|
||||||
// Store uuid as two long for better memory utilization
|
// Store uuid as two long for better memory utilization
|
||||||
private final long clientIdMsb; // Most signficant bytes
|
private final long clientIdMsb; // Most signficant bytes
|
||||||
@ -63,8 +63,10 @@ public static class CacheEntry implements LightWeightCache.Entry {
|
|||||||
private LightWeightGSet.LinkedElement next;
|
private LightWeightGSet.LinkedElement next;
|
||||||
|
|
||||||
CacheEntry(byte[] clientId, int callId, long expirationTime) {
|
CacheEntry(byte[] clientId, int callId, long expirationTime) {
|
||||||
Preconditions.checkArgument(clientId.length == 16, "Invalid clientId");
|
// ClientId must be a UUID - that is 16 octets.
|
||||||
// Conver UUID bytes to two longs
|
Preconditions.checkArgument(clientId.length == 16,
|
||||||
|
"Invalid clientId - must be UUID of size 16 octets");
|
||||||
|
// Convert UUID bytes to two longs
|
||||||
long tmp = 0;
|
long tmp = 0;
|
||||||
for (int i=0; i<8; i++) {
|
for (int i=0; i<8; i++) {
|
||||||
tmp = (tmp << 8) | (clientId[i] & 0xff);
|
tmp = (tmp << 8) | (clientId[i] & 0xff);
|
||||||
@ -116,7 +118,7 @@ synchronized void completed(boolean success) {
|
|||||||
this.notifyAll();
|
this.notifyAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSuccess() {
|
public synchronized boolean isSuccess() {
|
||||||
return state == SUCCESS;
|
return state == SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,13 +243,13 @@ private CacheEntry waitForCompletion(CacheEntry newEntry) {
|
|||||||
|
|
||||||
private static CacheEntry newEntry(long expirationTime) {
|
private static CacheEntry newEntry(long expirationTime) {
|
||||||
return new CacheEntry(Server.getClientId(), Server.getCallId(),
|
return new CacheEntry(Server.getClientId(), Server.getCallId(),
|
||||||
expirationTime);
|
System.nanoTime() + expirationTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CacheEntryWithPayload newEntry(Object payload,
|
private static CacheEntryWithPayload newEntry(Object payload,
|
||||||
long expirationTime) {
|
long expirationTime) {
|
||||||
return new CacheEntryWithPayload(Server.getClientId(), Server.getCallId(),
|
return new CacheEntryWithPayload(Server.getClientId(), Server.getCallId(),
|
||||||
payload, expirationTime);
|
payload, System.nanoTime() + expirationTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Static method that provides null check for retryCache */
|
/** Static method that provides null check for retryCache */
|
||||||
|
Loading…
Reference in New Issue
Block a user