use of org.apache.hadoop.hdfs.server.namenode.FsImageProto.CacheManagerSection in project hadoop by apache.
the class PBImageXmlWriter method dumpCacheManagerSection.
private void dumpCacheManagerSection(InputStream is) throws IOException {
out.print("<" + CACHE_MANAGER_SECTION_NAME + ">");
CacheManagerSection s = CacheManagerSection.parseDelimitedFrom(is);
o(CACHE_MANAGER_SECTION_NEXT_DIRECTIVE_ID, s.getNextDirectiveId());
o(CACHE_MANAGER_SECTION_NUM_DIRECTIVES, s.getNumDirectives());
o(CACHE_MANAGER_SECTION_NUM_POOLS, s.getNumPools());
for (int i = 0; i < s.getNumPools(); ++i) {
CachePoolInfoProto p = CachePoolInfoProto.parseDelimitedFrom(is);
out.print("<" + CACHE_MANAGER_SECTION_POOL + ">");
o(CACHE_MANAGER_SECTION_POOL_NAME, p.getPoolName()).o(CACHE_MANAGER_SECTION_OWNER_NAME, p.getOwnerName()).o(CACHE_MANAGER_SECTION_GROUP_NAME, p.getGroupName()).o(CACHE_MANAGER_SECTION_MODE, p.getMode()).o(CACHE_MANAGER_SECTION_LIMIT, p.getLimit()).o(CACHE_MANAGER_SECTION_MAX_RELATIVE_EXPIRY, p.getMaxRelativeExpiry());
out.print("</" + CACHE_MANAGER_SECTION_POOL + ">\n");
}
for (int i = 0; i < s.getNumDirectives(); ++i) {
CacheDirectiveInfoProto p = CacheDirectiveInfoProto.parseDelimitedFrom(is);
out.print("<" + CACHE_MANAGER_SECTION_DIRECTIVE + ">");
o(SECTION_ID, p.getId()).o(SECTION_PATH, p.getPath()).o(SECTION_REPLICATION, p.getReplication()).o(CACHE_MANAGER_SECTION_POOL, p.getPool());
out.print("<" + CACHE_MANAGER_SECTION_EXPIRATION + ">");
CacheDirectiveInfoExpirationProto e = p.getExpiration();
o(CACHE_MANAGER_SECTION_MILLIS, e.getMillis()).o(CACHE_MANAGER_SECTION_RELATIVE, e.getIsRelative());
out.print("</" + CACHE_MANAGER_SECTION_EXPIRATION + ">\n");
out.print("</" + CACHE_MANAGER_SECTION_DIRECTIVE + ">\n");
}
out.print("</" + CACHE_MANAGER_SECTION_NAME + ">\n");
}
use of org.apache.hadoop.hdfs.server.namenode.FsImageProto.CacheManagerSection in project hadoop by apache.
the class CacheManager method saveState.
public PersistState saveState() throws IOException {
ArrayList<CachePoolInfoProto> pools = Lists.newArrayListWithCapacity(cachePools.size());
ArrayList<CacheDirectiveInfoProto> directives = Lists.newArrayListWithCapacity(directivesById.size());
for (CachePool pool : cachePools.values()) {
CachePoolInfo p = pool.getInfo(true);
CachePoolInfoProto.Builder b = CachePoolInfoProto.newBuilder().setPoolName(p.getPoolName());
if (p.getOwnerName() != null)
b.setOwnerName(p.getOwnerName());
if (p.getGroupName() != null)
b.setGroupName(p.getGroupName());
if (p.getMode() != null)
b.setMode(p.getMode().toShort());
if (p.getLimit() != null)
b.setLimit(p.getLimit());
pools.add(b.build());
}
for (CacheDirective directive : directivesById.values()) {
CacheDirectiveInfo info = directive.toInfo();
CacheDirectiveInfoProto.Builder b = CacheDirectiveInfoProto.newBuilder().setId(info.getId());
if (info.getPath() != null) {
b.setPath(info.getPath().toUri().getPath());
}
if (info.getReplication() != null) {
b.setReplication(info.getReplication());
}
if (info.getPool() != null) {
b.setPool(info.getPool());
}
Expiration expiry = info.getExpiration();
if (expiry != null) {
assert (!expiry.isRelative());
b.setExpiration(PBHelperClient.convert(expiry));
}
directives.add(b.build());
}
CacheManagerSection s = CacheManagerSection.newBuilder().setNextDirectiveId(nextDirectiveId).setNumPools(pools.size()).setNumDirectives(directives.size()).build();
return new PersistState(s, pools, directives);
}
Aggregations