HDFS-5775. Consolidate the code for serialization in CacheManager. Contributed by Haohui Mai
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1558599 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ca5d73d1ab
commit
a506df8e48
|
@ -481,6 +481,9 @@ Trunk (Unreleased)
|
||||||
HDFS-5768. Consolidate the serialization code in DelegationTokenSecretManager
|
HDFS-5768. Consolidate the serialization code in DelegationTokenSecretManager
|
||||||
(Haohui Mai via brandonli)
|
(Haohui Mai via brandonli)
|
||||||
|
|
||||||
|
HDFS-5775. Consolidate the code for serialization in CacheManager
|
||||||
|
(Haohui Mai via brandonli)
|
||||||
|
|
||||||
Release 2.4.0 - UNRELEASED
|
Release 2.4.0 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -160,6 +160,8 @@ public final class CacheManager {
|
||||||
*/
|
*/
|
||||||
private final ReentrantLock crmLock = new ReentrantLock();
|
private final ReentrantLock crmLock = new ReentrantLock();
|
||||||
|
|
||||||
|
private final SerializerCompat serializerCompat = new SerializerCompat();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The CacheReplicationMonitor.
|
* The CacheReplicationMonitor.
|
||||||
*/
|
*/
|
||||||
|
@ -926,11 +928,9 @@ public final class CacheManager {
|
||||||
* @param sdPath path of the storage directory
|
* @param sdPath path of the storage directory
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public void saveState(DataOutputStream out, String sdPath)
|
public void saveStateCompat(DataOutputStream out, String sdPath)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
out.writeLong(nextDirectiveId);
|
serializerCompat.save(out, sdPath);
|
||||||
savePools(out, sdPath);
|
|
||||||
saveDirectives(out, sdPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -939,7 +939,18 @@ public final class CacheManager {
|
||||||
* @param in DataInput from which to restore state
|
* @param in DataInput from which to restore state
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public void loadState(DataInput in) throws IOException {
|
public void loadStateCompat(DataInput in) throws IOException {
|
||||||
|
serializerCompat.load(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final class SerializerCompat {
|
||||||
|
private void save(DataOutputStream out, String sdPath) throws IOException {
|
||||||
|
out.writeLong(nextDirectiveId);
|
||||||
|
savePools(out, sdPath);
|
||||||
|
saveDirectives(out, sdPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void load(DataInput in) throws IOException {
|
||||||
nextDirectiveId = in.readLong();
|
nextDirectiveId = in.readLong();
|
||||||
// pools need to be loaded first since directives point to their parent pool
|
// pools need to be loaded first since directives point to their parent pool
|
||||||
loadPools(in);
|
loadPools(in);
|
||||||
|
@ -1039,6 +1050,7 @@ public final class CacheManager {
|
||||||
}
|
}
|
||||||
prog.endStep(Phase.LOADING_FSIMAGE, step);
|
prog.endStep(Phase.LOADING_FSIMAGE, step);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void waitForRescanIfNeeded() {
|
public void waitForRescanIfNeeded() {
|
||||||
crmLock.lock();
|
crmLock.lock();
|
||||||
|
|
|
@ -878,7 +878,7 @@ public class FSImageFormat {
|
||||||
if (!LayoutVersion.supports(Feature.CACHING, imgVersion)) {
|
if (!LayoutVersion.supports(Feature.CACHING, imgVersion)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
namesystem.getCacheManager().loadState(in);
|
namesystem.getCacheManager().loadStateCompat(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getLayoutVersion() {
|
private int getLayoutVersion() {
|
||||||
|
@ -1034,7 +1034,7 @@ public class FSImageFormat {
|
||||||
context.checkCancelled();
|
context.checkCancelled();
|
||||||
sourceNamesystem.saveSecretManagerStateCompat(out, sdPath);
|
sourceNamesystem.saveSecretManagerStateCompat(out, sdPath);
|
||||||
context.checkCancelled();
|
context.checkCancelled();
|
||||||
sourceNamesystem.getCacheManager().saveState(out, sdPath);
|
sourceNamesystem.getCacheManager().saveStateCompat(out, sdPath);
|
||||||
context.checkCancelled();
|
context.checkCancelled();
|
||||||
out.flush();
|
out.flush();
|
||||||
context.checkCancelled();
|
context.checkCancelled();
|
||||||
|
|
Loading…
Reference in New Issue