@Override void fromXml(Stanza st) throws InvalidXmlException { this.length = Integer.parseInt(st.getValue("LENGTH")); this.inodeId = Long.parseLong(st.getValue("INODEID")); this.path = st.getValue("PATH"); this.replication = Short.parseShort(st.getValue("REPLICATION")); this.mtime = Long.parseLong(st.getValue("MTIME")); this.atime = Long.parseLong(st.getValue("ATIME")); this.blockSize = Long.parseLong(st.getValue("BLOCKSIZE")); this.clientName = st.getValue("CLIENT_NAME"); this.clientMachine = st.getValue("CLIENT_MACHINE"); this.overwrite = Boolean.parseBoolean(st.getValueOrNull("OVERWRITE")); if (st.hasChildren("BLOCK")) { List<Stanza> blocks = st.getChildren("BLOCK"); this.blocks = new Block[blocks.size()]; for (int i = 0; i < blocks.size(); i++) { this.blocks[i] = FSEditLogOp.blockFromXml(blocks.get(i)); } } else { this.blocks = new Block[0]; } this.permissions = permissionStatusFromXml(st); aclEntries = readAclEntriesFromXml(st); if (st.hasChildren("ERASURE_CODING_POLICY_ID")) { this.erasureCodingPolicyId = Byte.parseByte(st.getValue( "ERASURE_CODING_POLICY_ID")); } readRpcIdsFromXml(st); } }
/** * Convert a stanza to a human-readable string. */ @Override public String toString() { StringBuilder bld = new StringBuilder(); bld.append("{"); if (!value.equals("")) { bld.append("\"").append(value).append("\""); } String prefix = ""; for (Map.Entry<String, LinkedList <Stanza > > entry : subtrees.entrySet()) { String key = entry.getKey(); LinkedList <Stanza > ll = entry.getValue(); for (Stanza child : ll) { bld.append(prefix); bld.append("<").append(key).append(">"); bld.append(child.toString()); prefix = ", "; } } bld.append("}"); return bld.toString(); } }
/** * Convert a stanza to a human-readable string. */ @Override public String toString() { StringBuilder bld = new StringBuilder(); bld.append("{"); if (!value.equals("")) { bld.append("\"").append(value).append("\""); } String prefix = ""; for (Map.Entry<String, LinkedList <Stanza > > entry : subtrees.entrySet()) { String key = entry.getKey(); LinkedList <Stanza > ll = entry.getValue(); for (Stanza child : ll) { bld.append(prefix); bld.append("<").append(key).append(">"); bld.append(child.toString()); prefix = ", "; } } bld.append("}"); return bld.toString(); } }
@Override void fromXml(Stanza st) throws InvalidXmlException { this.length = Integer.parseInt(st.getValue("LENGTH")); this.inodeId = Long.parseLong(st.getValue("INODEID")); this.path = st.getValue("PATH"); this.replication = Short.valueOf(st.getValue("REPLICATION")); this.mtime = Long.parseLong(st.getValue("MTIME")); this.atime = Long.parseLong(st.getValue("ATIME")); this.blockSize = Long.parseLong(st.getValue("BLOCKSIZE")); this.clientName = st.getValue("CLIENT_NAME"); this.clientMachine = st.getValue("CLIENT_MACHINE"); this.overwrite = Boolean.parseBoolean(st.getValueOrNull("OVERWRITE")); if (st.hasChildren("BLOCK")) { List<Stanza> blocks = st.getChildren("BLOCK"); this.blocks = new Block[blocks.size()]; for (int i = 0; i < blocks.size(); i++) { this.blocks[i] = FSEditLogOp.blockFromXml(blocks.get(i)); } } else { this.blocks = new Block[0]; } this.permissions = permissionStatusFromXml(st); aclEntries = readAclEntriesFromXml(st); readRpcIdsFromXml(st); } }
public static CacheDirectiveInfo readCacheDirectiveInfo(Stanza st) throws InvalidXmlException { CacheDirectiveInfo.Builder builder = new CacheDirectiveInfo.Builder(); builder.setId(Long.parseLong(st.getValue("ID"))); String path = st.getValueOrNull("PATH"); if (path != null) { builder.setPath(new Path(path)); } String replicationString = st.getValueOrNull("REPLICATION"); if (replicationString != null) { builder.setReplication(Short.parseShort(replicationString)); } String pool = st.getValueOrNull("POOL"); if (pool != null) { builder.setPool(pool); } String expiryTime = st.getValueOrNull("EXPIRATION"); if (expiryTime != null) { builder.setExpiration(CacheDirectiveInfo.Expiration.newAbsolute( Long.parseLong(expiryTime))); } return builder.build(); }
public static CachePoolInfo readCachePoolInfo(Stanza st) throws InvalidXmlException { String poolName = st.getValue("POOLNAME"); CachePoolInfo info = new CachePoolInfo(poolName); if (st.hasChildren("OWNERNAME")) { info.setOwnerName(st.getValue("OWNERNAME")); } if (st.hasChildren("GROUPNAME")) { info.setGroupName(st.getValue("GROUPNAME")); } if (st.hasChildren("MODE")) { info.setMode(FSEditLogOp.fsPermissionFromXml(st)); } if (st.hasChildren("LIMIT")) { info.setLimit(Long.parseLong(st.getValue("LIMIT"))); } if (st.hasChildren("MAXRELATIVEEXPIRY")) { info.setMaxRelativeExpiryMs( Long.parseLong(st.getValue("MAXRELATIVEEXPIRY"))); } return info; }
@Override void fromXml(Stanza st) throws InvalidXmlException { this.length = Integer.parseInt(st.getValue("LENGTH")); this.inodeId = Long.parseLong(st.getValue("INODEID")); this.path = st.getValue("PATH"); this.replication = Short.valueOf(st.getValue("REPLICATION")); this.mtime = Long.parseLong(st.getValue("MTIME")); this.atime = Long.parseLong(st.getValue("ATIME")); this.blockSize = Long.parseLong(st.getValue("BLOCKSIZE")); this.clientName = st.getValue("CLIENT_NAME"); this.clientMachine = st.getValue("CLIENT_MACHINE"); this.overwrite = Boolean.parseBoolean(st.getValueOrNull("OVERWRITE")); if (st.hasChildren("BLOCK")) { List<Stanza> blocks = st.getChildren("BLOCK"); this.blocks = new Block[blocks.size()]; for (int i = 0; i < blocks.size(); i++) { this.blocks[i] = FSEditLogOp.blockFromXml(blocks.get(i)); } } else { this.blocks = new Block[0]; } this.permissions = permissionStatusFromXml(st); aclEntries = readAclEntriesFromXml(st); readRpcIdsFromXml(st); } }
private static List<XAttr> readXAttrsFromXml(Stanza st) throws InvalidXmlException { if (!st.hasChildren("XATTR")) { return null; } List<Stanza> stanzas = st.getChildren("XATTR"); List<XAttr> xattrs = Lists.newArrayListWithCapacity(stanzas.size()); for (Stanza a: stanzas) { XAttr.Builder builder = new XAttr.Builder(); builder.setNameSpace(XAttr.NameSpace.valueOf(a.getValue("NAMESPACE"))). setName(a.getValue("NAME")); String v = a.getValueOrNull("VALUE"); if (v != null) { try { builder.setValue(XAttrCodec.decodeValue(v)); } catch (IOException e) { throw new InvalidXmlException(e.toString()); } } xattrs.add(builder.build()); } return xattrs; } }
public static CacheDirectiveInfo readCacheDirectiveInfo(Stanza st) throws InvalidXmlException { CacheDirectiveInfo.Builder builder = new CacheDirectiveInfo.Builder(); builder.setId(Long.parseLong(st.getValue("ID"))); String path = st.getValueOrNull("PATH"); if (path != null) { builder.setPath(new Path(path)); } String replicationString = st.getValueOrNull("REPLICATION"); if (replicationString != null) { builder.setReplication(Short.parseShort(replicationString)); } String pool = st.getValueOrNull("POOL"); if (pool != null) { builder.setPool(pool); } String expiryTime = st.getValueOrNull("EXPIRATION"); if (expiryTime != null) { builder.setExpiration(CacheDirectiveInfo.Expiration.newAbsolute( Long.parseLong(expiryTime))); } return builder.build(); }
public static CachePoolInfo readCachePoolInfo(Stanza st) throws InvalidXmlException { String poolName = st.getValue("POOLNAME"); CachePoolInfo info = new CachePoolInfo(poolName); if (st.hasChildren("OWNERNAME")) { info.setOwnerName(st.getValue("OWNERNAME")); } if (st.hasChildren("GROUPNAME")) { info.setGroupName(st.getValue("GROUPNAME")); } if (st.hasChildren("MODE")) { info.setMode(FSEditLogOp.fsPermissionFromXml(st)); } if (st.hasChildren("LIMIT")) { info.setLimit(Long.parseLong(st.getValue("LIMIT"))); } if (st.hasChildren("MAXRELATIVEEXPIRY")) { info.setMaxRelativeExpiryMs( Long.parseLong(st.getValue("MAXRELATIVEEXPIRY"))); } return info; }
private static List<XAttr> readXAttrsFromXml(Stanza st) throws InvalidXmlException { if (!st.hasChildren("XATTR")) { return null; } List<Stanza> stanzas = st.getChildren("XATTR"); List<XAttr> xattrs = Lists.newArrayListWithCapacity(stanzas.size()); for (Stanza a: stanzas) { XAttr.Builder builder = new XAttr.Builder(); builder.setNameSpace(XAttr.NameSpace.valueOf(a.getValue("NAMESPACE"))). setName(a.getValue("NAME")); String v = a.getValueOrNull("VALUE"); if (v != null) { try { builder.setValue(XAttrCodec.decodeValue(v)); } catch (IOException e) { throw new InvalidXmlException(e.toString()); } } xattrs.add(builder.build()); } return xattrs; } }
@Override void fromXml(Stanza st) throws InvalidXmlException { this.length = Integer.parseInt(st.getValue("LENGTH")); this.trg = st.getValue("TRG"); this.timestamp = Long.parseLong(st.getValue("TIMESTAMP")); List<Stanza> sources = st.getChildren("SOURCES"); int i = 0; while (true) { if (!sources.get(0).hasChildren("SOURCE" + (i + 1))) break; i++; } srcs = new String[i]; for (i = 0; i < srcs.length; i++) { srcs[i] = sources.get(0).getValue("SOURCE" + (i + 1)); } readRpcIdsFromXml(st); } }
@Override void fromXml(Stanza st) throws InvalidXmlException { this.length = Integer.parseInt(st.getValue("LENGTH")); this.trg = st.getValue("TRG"); this.timestamp = Long.parseLong(st.getValue("TIMESTAMP")); List<Stanza> sources = st.getChildren("SOURCES"); int i = 0; while (true) { if (!sources.get(0).hasChildren("SOURCE" + (i + 1))) break; i++; } srcs = new String[i]; for (i = 0; i < srcs.length; i++) { srcs[i] = sources.get(0).getValue("SOURCE" + (i + 1)); } readRpcIdsFromXml(st); } }
private static List<AclEntry> readAclEntriesFromXml(Stanza st) { List<AclEntry> aclEntries = Lists.newArrayList(); if (!st.hasChildren("ENTRY")) return null; List<Stanza> stanzas = st.getChildren("ENTRY"); for (Stanza s : stanzas) { AclEntry e = new AclEntry.Builder() .setScope(AclEntryScope.valueOf(s.getValue("SCOPE"))) .setType(AclEntryType.valueOf(s.getValue("TYPE"))) .setName(s.getValueOrNull("NAME")) .setPermission(fsActionFromXml(s)).build(); aclEntries.add(e); } return aclEntries; }