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); }
@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.src = st.getValue("SRC"); this.dst = st.getValue("DST"); this.timestamp = Long.parseLong(st.getValue("TIMESTAMP")); String opts = st.getValue("OPTIONS"); String o[] = opts.split("\\|"); this.options = new Rename[o.length]; for (int i = 0; i < o.length; i++) { if (o[i].equals("")) continue; try { this.options[i] = Rename.valueOf(o[i]); } finally { if (this.options[i] == null) { System.err.println("error parsing Rename value: \"" + o[i] + "\""); } } } readRpcIdsFromXml(st); }
public static DelegationTokenIdentifier delegationTokenFromXml(Stanza st) throws InvalidXmlException { String kind = st.getValue("KIND"); if (!kind.equals(DelegationTokenIdentifier. HDFS_DELEGATION_KIND.toString())) { throw new InvalidXmlException("can't understand " + "DelegationTokenIdentifier KIND " + kind); } int seqNum = Integer.parseInt(st.getValue("SEQUENCE_NUMBER")); String owner = st.getValue("OWNER"); String renewer = st.getValue("RENEWER"); String realuser = st.getValue("REALUSER"); long issueDate = Long.parseLong(st.getValue("ISSUE_DATE")); long maxDate = Long.parseLong(st.getValue("MAX_DATE")); int masterKeyId = Integer.parseInt(st.getValue("MASTER_KEY_ID")); DelegationTokenIdentifier token = new DelegationTokenIdentifier(new Text(owner), new Text(renewer), new Text(realuser)); token.setSequenceNumber(seqNum); token.setIssueDate(issueDate); token.setMaxDate(maxDate); token.setMasterKeyId(masterKeyId); return token; }
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; }
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; }
void readRpcIdsFromXml(Stanza st) { this.rpcClientId = st.hasChildren("RPC_CLIENTID") ? ClientId.toBytes(st.getValue("RPC_CLIENTID")) : RpcConstants.DUMMY_CLIENT_ID; this.rpcCallId = st.hasChildren("RPC_CALLID") ? Integer.parseInt(st.getValue("RPC_CALLID")) : RpcConstants.INVALID_CALL_ID; }
@Override void fromXml(Stanza st) throws InvalidXmlException { this.path = st.getValue("PATH"); this.clientName = st.getValue("CLIENT_NAME"); this.clientMachine = st.getValue("CLIENT_MACHINE"); this.newBlock = Boolean.parseBoolean(st.getValue("NEWBLOCK")); readRpcIdsFromXml(st); }
@Override void fromXml(Stanza st) throws InvalidXmlException { this.path = st.getValue("PATH"); List<Stanza> blocks = st.getChildren("BLOCK"); int size = blocks.size(); Preconditions.checkState(size == 1 || size == 2); this.penultimateBlock = size == 2 ? FSEditLogOp.blockFromXml(blocks.get(0)) : null; this.lastBlock = FSEditLogOp.blockFromXml(blocks.get(size - 1)); readRpcIdsFromXml(st); }
@Override void fromXml(Stanza st) throws InvalidXmlException { this.path = st.getValue("PATH"); 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)); } readRpcIdsFromXml(st); }
@Override void fromXml(Stanza st) throws InvalidXmlException { this.length = Integer.parseInt(st.getValue("LENGTH")); this.src = st.getValue("SRC"); this.dst = st.getValue("DST"); this.timestamp = Long.parseLong(st.getValue("TIMESTAMP")); readRpcIdsFromXml(st); }
@Override void fromXml(Stanza st) throws InvalidXmlException { this.length = Integer.parseInt(st.getValue("LENGTH")); this.path = st.getValue("PATH"); this.timestamp = Long.parseLong(st.getValue("TIMESTAMP")); readRpcIdsFromXml(st); }
@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.timestamp = Long.parseLong(st.getValue("TIMESTAMP")); this.permissions = permissionStatusFromXml(st); aclEntries = readAclEntriesFromXml(st); xAttrs = readXAttrsFromXml(st); }
@Override void fromXml(Stanza st) throws InvalidXmlException { this.src = st.getValue("SRC"); this.username = (st.hasChildren("USERNAME")) ? st.getValue("USERNAME") : null; this.groupname = (st.hasChildren("GROUPNAME")) ? st.getValue("GROUPNAME") : null; }
@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.value = st.getValue("VALUE"); this.mtime = Long.parseLong(st.getValue("MTIME")); this.atime = Long.parseLong(st.getValue("ATIME")); this.permissionStatus = permissionStatusFromXml(st); readRpcIdsFromXml(st); }
@Override void fromXml(Stanza st) throws InvalidXmlException { this.src = st.getValue("SRC"); this.clientName = st.getValue("CLIENTNAME"); this.clientMachine = st.getValue("CLIENTMACHINE"); this.newLength = Long.parseLong(st.getValue("NEWLENGTH")); this.timestamp = Long.parseLong(st.getValue("TIMESTAMP")); if (st.hasChildren("BLOCK")) this.truncateBlock = FSEditLogOp.blockFromXml(st); }
@Override void fromXml(Stanza st) throws InvalidXmlException { snapshotRoot = st.getValue("SNAPSHOTROOT"); snapshotName = st.getValue("SNAPSHOTNAME"); readRpcIdsFromXml(st); }
@Override void fromXml(Stanza st) throws InvalidXmlException { snapshotRoot = st.getValue("SNAPSHOTROOT"); snapshotOldName = st.getValue("SNAPSHOTOLDNAME"); snapshotNewName = st.getValue("SNAPSHOTNEWNAME"); readRpcIdsFromXml(st); }
@Override void fromXml(Stanza st) throws InvalidXmlException { src = st.getValue("SRC"); aclEntries = readAclEntriesFromXml(st); if (aclEntries == null) { aclEntries = Lists.newArrayList(); } }
public static Block blockFromXml(Stanza st) throws InvalidXmlException { long blockId = Long.parseLong(st.getValue("BLOCK_ID")); long numBytes = Long.parseLong(st.getValue("NUM_BYTES")); long generationStamp = Long.parseLong(st.getValue("GENSTAMP")); return new Block(blockId, numBytes, generationStamp); }
public static PermissionStatus permissionStatusFromXml(Stanza st) throws InvalidXmlException { Stanza status = st.getChildren("PERMISSION_STATUS").get(0); String username = status.getValue("USERNAME"); String groupname = status.getValue("GROUPNAME"); FsPermission mode = fsPermissionFromXml(status); return new PermissionStatus(username, groupname, mode); }