HDFS-15283. Cache pool MAXTTL is not persisted and restored on cluster restart. Contributed by Stephen O'Donnell.
Signed-off-by: Wei-Chiu Chuang <weichiu@apache.org> (cherry picked from commit 3481895f8a9ea9f6e217a0ba158c48da89b3faf2) (cherry picked from commit aaad947c740c91c36139f3f0569ae78b53bca682) (cherry picked from commit 041c93a26cd0ff705bea9d6283951702cf2cf1c2) (cherry picked from commit 0ea8f3a19cd0b841dda6ba5c4e19887d9fc9cbb4)
This commit is contained in:
parent
8f60971138
commit
9ec141c77f
@ -1041,6 +1041,10 @@ public PersistState saveState() throws IOException {
|
|||||||
if (p.getLimit() != null)
|
if (p.getLimit() != null)
|
||||||
b.setLimit(p.getLimit());
|
b.setLimit(p.getLimit());
|
||||||
|
|
||||||
|
if (p.getMaxRelativeExpiryMs() != null) {
|
||||||
|
b.setMaxRelativeExpiry(p.getMaxRelativeExpiryMs());
|
||||||
|
}
|
||||||
|
|
||||||
pools.add(b.build());
|
pools.add(b.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1106,6 +1110,10 @@ public void loadState(PersistState s) throws IOException {
|
|||||||
if (p.hasLimit())
|
if (p.hasLimit())
|
||||||
info.setLimit(p.getLimit());
|
info.setLimit(p.getLimit());
|
||||||
|
|
||||||
|
if (p.hasMaxRelativeExpiry()) {
|
||||||
|
info.setMaxRelativeExpiryMs(p.getMaxRelativeExpiry());
|
||||||
|
}
|
||||||
|
|
||||||
addCachePool(info);
|
addCachePool(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -568,10 +568,12 @@ public void testCacheManagerRestart() throws Exception {
|
|||||||
String groupName = "partygroup";
|
String groupName = "partygroup";
|
||||||
FsPermission mode = new FsPermission((short)0777);
|
FsPermission mode = new FsPermission((short)0777);
|
||||||
long limit = 747;
|
long limit = 747;
|
||||||
|
long maxExpiry = 1234567890;
|
||||||
dfs.addCachePool(new CachePoolInfo(pool)
|
dfs.addCachePool(new CachePoolInfo(pool)
|
||||||
.setGroupName(groupName)
|
.setGroupName(groupName)
|
||||||
.setMode(mode)
|
.setMode(mode)
|
||||||
.setLimit(limit));
|
.setLimit(limit)
|
||||||
|
.setMaxRelativeExpiryMs(maxExpiry));
|
||||||
RemoteIterator<CachePoolEntry> pit = dfs.listCachePools();
|
RemoteIterator<CachePoolEntry> pit = dfs.listCachePools();
|
||||||
assertTrue("No cache pools found", pit.hasNext());
|
assertTrue("No cache pools found", pit.hasNext());
|
||||||
CachePoolInfo info = pit.next().getInfo();
|
CachePoolInfo info = pit.next().getInfo();
|
||||||
@ -579,6 +581,7 @@ public void testCacheManagerRestart() throws Exception {
|
|||||||
assertEquals(groupName, info.getGroupName());
|
assertEquals(groupName, info.getGroupName());
|
||||||
assertEquals(mode, info.getMode());
|
assertEquals(mode, info.getMode());
|
||||||
assertEquals(limit, (long)info.getLimit());
|
assertEquals(limit, (long)info.getLimit());
|
||||||
|
assertEquals(maxExpiry, (long)info.getMaxRelativeExpiryMs());
|
||||||
assertFalse("Unexpected # of cache pools found", pit.hasNext());
|
assertFalse("Unexpected # of cache pools found", pit.hasNext());
|
||||||
|
|
||||||
// Create some cache entries
|
// Create some cache entries
|
||||||
@ -639,6 +642,7 @@ public void testCacheManagerRestart() throws Exception {
|
|||||||
assertEquals(groupName, info.getGroupName());
|
assertEquals(groupName, info.getGroupName());
|
||||||
assertEquals(mode, info.getMode());
|
assertEquals(mode, info.getMode());
|
||||||
assertEquals(limit, (long)info.getLimit());
|
assertEquals(limit, (long)info.getLimit());
|
||||||
|
assertEquals(maxExpiry, (long)info.getMaxRelativeExpiryMs());
|
||||||
assertFalse("Unexpected # of cache pools found", pit.hasNext());
|
assertFalse("Unexpected # of cache pools found", pit.hasNext());
|
||||||
|
|
||||||
dit = dfs.listCacheDirectives(null);
|
dit = dfs.listCacheDirectives(null);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user