List of usage examples for org.apache.hadoop.hdfs DFSUtil string2Bytes
public static byte[] string2Bytes(String str)
From source file:com.bigstep.datalake.JsonUtil.java
License:Apache License
/** * Convert a Json map to a HdfsFileStatus object. * @param json//from w w w .j ava 2s. co m * @param includesType * @return sau nu */ public static HdfsFileStatus toFileStatus(final Map<?, ?> json, boolean includesType) { if (json == null) { return null; } final Map<?, ?> m = includesType ? (Map<?, ?>) json.get(FileStatus.class.getSimpleName()) : json; final String localName = (String) m.get("pathSuffix"); final PathType type = PathType.valueOf((String) m.get("type")); final byte[] symlink = type != PathType.SYMLINK ? null : DFSUtil.string2Bytes((String) m.get("symlink")); final long len = ((Number) m.get("length")).longValue(); final String owner = (String) m.get("owner"); final String group = (String) m.get("group"); final FsPermission permission = toFsPermission((String) m.get("permission"), (Boolean) m.get("aclBit"), (Boolean) m.get("encBit")); final long aTime = ((Number) m.get("accessTime")).longValue(); final long mTime = ((Number) m.get("modificationTime")).longValue(); final long blockSize = ((Number) m.get("blockSize")).longValue(); final short replication = ((Number) m.get("replication")).shortValue(); final long fileId = m.containsKey("fileId") ? ((Number) m.get("fileId")).longValue() : INodeId.GRANDFATHER_INODE_ID; final int childrenNum = getInt(m, "childrenNum", -1); final byte storagePolicy = m.containsKey("storagePolicy") ? (byte) ((Number) m.get("storagePolicy")).longValue() : BlockStoragePolicySuite.ID_UNSPECIFIED; return new HdfsFileStatus(len, type == PathType.DIRECTORY, replication, blockSize, mTime, aTime, permission, owner, group, symlink, DFSUtil.string2Bytes(localName), fileId, childrenNum, null, storagePolicy); }
From source file:com.wandisco.s3hdfs.rewrite.redirect.ObjectInfoRedirect.java
License:Apache License
private S3HdfsFileStatus parseHdfsFileStatus(JsonNode element) { return new S3HdfsFileStatus(element.get("length").getLongValue(), element.get("type").getTextValue().equalsIgnoreCase("DIRECTORY"), element.get("replication").getIntValue(), element.get("blockSize").getLongValue(), element.get("modificationTime").getLongValue(), element.get("accessTime").getLongValue(), FsPermission.createImmutable((short) element.get("permission").getIntValue()), element.get("owner").getTextValue(), element.get("group").getTextValue(), (element.get("symlink") == null) ? null : DFSUtil.string2Bytes(element.get("symlink").getTextValue()), DFSUtil.string2Bytes(element.get("pathSuffix").getTextValue()), element.get("fileId").getLongValue(), element.get("childrenNum").getIntValue()); }