HDFS-10516. Fix bug when warming up EDEK cache of more than one encryption zone. Contributed by Xiao Chen.

This commit is contained in:
Andrew Wang 2016-06-13 11:50:19 -07:00
parent 0accc3306d
commit 709a814fe0
3 changed files with 10 additions and 2 deletions

View File

@ -416,7 +416,7 @@ String[] getKeyNames() {
int index = 0;
for (Map.Entry<Long, EncryptionZoneInt> entry : encryptionZones
.entrySet()) {
ret[index] = entry.getValue().getKeyName();
ret[index++] = entry.getValue().getKeyName();
}
return ret;
}

View File

@ -370,6 +370,9 @@ public void run() {
} else {
NameNode.LOG.debug("Failed to warm up EDEKs.", ioe);
}
} catch (Exception e) {
NameNode.LOG.error("Cannot warm up EDEKs.", e);
throw e;
}
try {
Thread.sleep(retryInterval);

View File

@ -100,9 +100,14 @@ public void testDelegationToken() throws Exception {
@Test(timeout = 120000)
public void testWarmupEDEKCacheOnStartup() throws Exception {
final Path zonePath = new Path("/TestEncryptionZone");
Path zonePath = new Path("/TestEncryptionZone");
fsWrapper.mkdir(zonePath, FsPermission.getDirDefault(), false);
dfsAdmin.createEncryptionZone(zonePath, TEST_KEY, NO_TRASH);
final String anotherKey = "k2";
zonePath = new Path("/TestEncryptionZone2");
DFSTestUtil.createKey(anotherKey, cluster, conf);
fsWrapper.mkdir(zonePath, FsPermission.getDirDefault(), false);
dfsAdmin.createEncryptionZone(zonePath, anotherKey, NO_TRASH);
@SuppressWarnings("unchecked")
KMSClientProvider spy = (KMSClientProvider) Whitebox