HADOOP-11122. Fix findbugs in ZK DelegationTokenSecretManagers. (Arun Suresh via kasha)

This commit is contained in:
Karthik Kambatla 2014-10-22 14:26:27 -07:00
parent 7b0f9bb258
commit 70719e5c62
3 changed files with 16 additions and 15 deletions

View File

@ -994,6 +994,9 @@ Release 2.6.0 - UNRELEASED
HADOOP-11175. Fix several issues of hadoop security configuration in user HADOOP-11175. Fix several issues of hadoop security configuration in user
doc. (Yi Liu via cnauroth) doc. (Yi Liu via cnauroth)
HADOOP-11122. Fix findbugs in ZK DelegationTokenSecretManagers.
(Arun Suresh via kasha)
Release 2.5.1 - 2014-09-05 Release 2.5.1 - 2014-09-05
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -163,11 +163,6 @@ extends AbstractDelegationTokenIdentifier>
return; return;
} }
// for ZK based secretManager
protected void updateMasterKey(DelegationKey key) throws IOException{
return;
}
// RM // RM
protected void removeStoredMasterKey(DelegationKey key) { protected void removeStoredMasterKey(DelegationKey key) {
return; return;
@ -191,7 +186,7 @@ extends AbstractDelegationTokenIdentifier>
* For subclasses externalizing the storage, for example Zookeeper * For subclasses externalizing the storage, for example Zookeeper
* based implementations * based implementations
*/ */
protected int getDelegationTokenSeqNum() { protected synchronized int getDelegationTokenSeqNum() {
return delegationTokenSequenceNumber; return delegationTokenSequenceNumber;
} }
@ -199,7 +194,7 @@ extends AbstractDelegationTokenIdentifier>
* For subclasses externalizing the storage, for example Zookeeper * For subclasses externalizing the storage, for example Zookeeper
* based implementations * based implementations
*/ */
protected int incrementDelegationTokenSeqNum() { protected synchronized int incrementDelegationTokenSeqNum() {
return ++delegationTokenSequenceNumber; return ++delegationTokenSequenceNumber;
} }
@ -207,7 +202,7 @@ extends AbstractDelegationTokenIdentifier>
* For subclasses externalizing the storage, for example Zookeeper * For subclasses externalizing the storage, for example Zookeeper
* based implementations * based implementations
*/ */
protected void setDelegationTokenSeqNum(int seqNum) { protected synchronized void setDelegationTokenSeqNum(int seqNum) {
delegationTokenSequenceNumber = seqNum; delegationTokenSequenceNumber = seqNum;
} }
@ -234,7 +229,6 @@ extends AbstractDelegationTokenIdentifier>
*/ */
protected void updateDelegationKey(DelegationKey key) throws IOException { protected void updateDelegationKey(DelegationKey key) throws IOException {
allKeys.put(key.getKeyId(), key); allKeys.put(key.getKeyId(), key);
updateMasterKey(key);
} }
/** /**

View File

@ -276,7 +276,7 @@ public abstract class ZKDelegationTokenSecretManager<TokenIdent extends Abstract
} }
@Override @Override
public void startThreads() throws IOException { public synchronized void startThreads() throws IOException {
if (!isExternalClient) { if (!isExternalClient) {
try { try {
zkClient.start(); zkClient.start();
@ -402,7 +402,7 @@ public abstract class ZKDelegationTokenSecretManager<TokenIdent extends Abstract
} }
@Override @Override
public void stopThreads() { public synchronized void stopThreads() {
try { try {
if (!isExternalClient && (zkClient != null)) { if (!isExternalClient && (zkClient != null)) {
zkClient.close(); zkClient.close();
@ -434,12 +434,12 @@ public abstract class ZKDelegationTokenSecretManager<TokenIdent extends Abstract
} }
@Override @Override
protected int getDelegationTokenSeqNum() { protected synchronized int getDelegationTokenSeqNum() {
return seqCounter.getCount(); return seqCounter.getCount();
} }
@Override @Override
protected int incrementDelegationTokenSeqNum() { protected synchronized int incrementDelegationTokenSeqNum() {
try { try {
while (!seqCounter.trySetCount(seqCounter.getCount() + 1)) { while (!seqCounter.trySetCount(seqCounter.getCount() + 1)) {
} }
@ -450,8 +450,12 @@ public abstract class ZKDelegationTokenSecretManager<TokenIdent extends Abstract
} }
@Override @Override
protected void setDelegationTokenSeqNum(int seqNum) { protected synchronized void setDelegationTokenSeqNum(int seqNum) {
delegationTokenSequenceNumber = seqNum; try {
seqCounter.setCount(seqNum);
} catch (Exception e) {
throw new RuntimeException("Could not set shared counter !!", e);
}
} }
@Override @Override