Search in sources :

Example 1 with Builder

use of org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.LocatedBlockProto.Builder in project hadoop by apache.

the class PBHelperClient method convertAclEntry.

public static List<AclEntry> convertAclEntry(List<AclEntryProto> aclSpec) {
    ArrayList<AclEntry> r = Lists.newArrayListWithCapacity(aclSpec.size());
    for (AclEntryProto e : aclSpec) {
        AclEntry.Builder builder = new AclEntry.Builder();
        builder.setType(convert(e.getType()));
        builder.setScope(convert(e.getScope()));
        builder.setPermission(convert(e.getPermissions()));
        if (e.hasName()) {
            builder.setName(e.getName());
        }
        r.add(builder.build());
    }
    return r;
}
Also used : Builder(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.LocatedBlockProto.Builder) DatanodeInfoBuilder(org.apache.hadoop.hdfs.protocol.DatanodeInfo.DatanodeInfoBuilder) AclEntry(org.apache.hadoop.fs.permission.AclEntry) AclEntryProto(org.apache.hadoop.hdfs.protocol.proto.AclProtos.AclEntryProto)

Example 2 with Builder

use of org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.LocatedBlockProto.Builder in project hadoop by apache.

the class PBHelperClient method convertLocatedBlock.

public static LocatedBlockProto convertLocatedBlock(LocatedBlock b) {
    if (b == null)
        return null;
    Builder builder = LocatedBlockProto.newBuilder();
    DatanodeInfo[] locs = b.getLocations();
    List<DatanodeInfo> cachedLocs = Lists.newLinkedList(Arrays.asList(b.getCachedLocations()));
    for (int i = 0; i < locs.length; i++) {
        DatanodeInfo loc = locs[i];
        builder.addLocs(i, PBHelperClient.convert(loc));
        boolean locIsCached = cachedLocs.contains(loc);
        builder.addIsCached(locIsCached);
        if (locIsCached) {
            cachedLocs.remove(loc);
        }
    }
    Preconditions.checkArgument(cachedLocs.size() == 0, "Found additional cached replica locations that are not in the set of" + " storage-backed locations!");
    StorageType[] storageTypes = b.getStorageTypes();
    if (storageTypes != null) {
        for (StorageType storageType : storageTypes) {
            builder.addStorageTypes(convertStorageType(storageType));
        }
    }
    final String[] storageIDs = b.getStorageIDs();
    if (storageIDs != null) {
        builder.addAllStorageIDs(Arrays.asList(storageIDs));
    }
    if (b instanceof LocatedStripedBlock) {
        LocatedStripedBlock sb = (LocatedStripedBlock) b;
        byte[] indices = sb.getBlockIndices();
        builder.setBlockIndices(PBHelperClient.getByteString(indices));
        Token<BlockTokenIdentifier>[] blockTokens = sb.getBlockTokens();
        builder.addAllBlockTokens(convert(blockTokens));
    }
    return builder.setB(PBHelperClient.convert(b.getBlock())).setBlockToken(PBHelperClient.convert(b.getBlockToken())).setCorrupt(b.isCorrupt()).setOffset(b.getStartOffset()).build();
}
Also used : DatanodeInfo(org.apache.hadoop.hdfs.protocol.DatanodeInfo) StorageType(org.apache.hadoop.fs.StorageType) Builder(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.LocatedBlockProto.Builder) DatanodeInfoBuilder(org.apache.hadoop.hdfs.protocol.DatanodeInfo.DatanodeInfoBuilder) Token(org.apache.hadoop.security.token.Token) ByteString(com.google.protobuf.ByteString) LocatedStripedBlock(org.apache.hadoop.hdfs.protocol.LocatedStripedBlock)

Example 3 with Builder

use of org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.LocatedBlockProto.Builder in project hadoop by apache.

the class PBHelperClient method convert.

public static AclStatus convert(GetAclStatusResponseProto e) {
    AclStatusProto r = e.getResult();
    AclStatus.Builder builder = new AclStatus.Builder();
    builder.owner(r.getOwner()).group(r.getGroup()).stickyBit(r.getSticky()).addEntries(convertAclEntry(r.getEntriesList()));
    if (r.hasPermission()) {
        builder.setPermission(convert(r.getPermission()));
    }
    return builder.build();
}
Also used : AclStatus(org.apache.hadoop.fs.permission.AclStatus) Builder(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.LocatedBlockProto.Builder) DatanodeInfoBuilder(org.apache.hadoop.hdfs.protocol.DatanodeInfo.DatanodeInfoBuilder) AclStatusProto(org.apache.hadoop.hdfs.protocol.proto.AclProtos.AclStatusProto)

Example 4 with Builder

use of org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.LocatedBlockProto.Builder in project hadoop by apache.

the class PBHelperClient method convertXAttrs.

public static List<XAttr> convertXAttrs(List<XAttrProto> xAttrSpec) {
    ArrayList<XAttr> xAttrs = Lists.newArrayListWithCapacity(xAttrSpec.size());
    for (XAttrProto a : xAttrSpec) {
        XAttr.Builder builder = new XAttr.Builder();
        builder.setNameSpace(convert(a.getNamespace()));
        if (a.hasName()) {
            builder.setName(a.getName());
        }
        if (a.hasValue()) {
            builder.setValue(a.getValue().toByteArray());
        }
        xAttrs.add(builder.build());
    }
    return xAttrs;
}
Also used : XAttrProto(org.apache.hadoop.hdfs.protocol.proto.XAttrProtos.XAttrProto) Builder(org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.LocatedBlockProto.Builder) DatanodeInfoBuilder(org.apache.hadoop.hdfs.protocol.DatanodeInfo.DatanodeInfoBuilder) XAttr(org.apache.hadoop.fs.XAttr)

Aggregations

DatanodeInfoBuilder (org.apache.hadoop.hdfs.protocol.DatanodeInfo.DatanodeInfoBuilder)4 Builder (org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.LocatedBlockProto.Builder)4 ByteString (com.google.protobuf.ByteString)1 StorageType (org.apache.hadoop.fs.StorageType)1 XAttr (org.apache.hadoop.fs.XAttr)1 AclEntry (org.apache.hadoop.fs.permission.AclEntry)1 AclStatus (org.apache.hadoop.fs.permission.AclStatus)1 DatanodeInfo (org.apache.hadoop.hdfs.protocol.DatanodeInfo)1 LocatedStripedBlock (org.apache.hadoop.hdfs.protocol.LocatedStripedBlock)1 AclEntryProto (org.apache.hadoop.hdfs.protocol.proto.AclProtos.AclEntryProto)1 AclStatusProto (org.apache.hadoop.hdfs.protocol.proto.AclProtos.AclStatusProto)1 XAttrProto (org.apache.hadoop.hdfs.protocol.proto.XAttrProtos.XAttrProto)1 Token (org.apache.hadoop.security.token.Token)1