Example usage for org.apache.hadoop.hdfs.server.blockmanagement BlockInfo getBlockId

List of usage examples for org.apache.hadoop.hdfs.server.blockmanagement BlockInfo getBlockId

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs.server.blockmanagement BlockInfo getBlockId.

Prototype

public long getBlockId() 

Source Link

Usage

From source file:io.hops.metadata.blockmanagement.ExcessReplicasMap.java

License:Apache License

public boolean put(String dn, BlockInfo excessBlk) throws StorageException, TransactionContextException {
    ExcessReplica er = getExcessReplica(datanodeManager.getDatanode(dn).getSId(), excessBlk);
    if (er == null) {
        addExcessReplicaToDB(new ExcessReplica(datanodeManager.getDatanode(dn).getSId(), excessBlk.getBlockId(),
                excessBlk.getInodeId()));
        return true;
    }//  w  w w . jav  a 2s  .com
    return false;
}

From source file:io.hops.metadata.blockmanagement.ExcessReplicasMap.java

License:Apache License

public boolean contains(String dn, BlockInfo blk) throws StorageException, TransactionContextException {
    Collection<ExcessReplica> ers = getExcessReplicas(blk);
    if (ers == null) {
        return false;
    }/*  w  ww .j  ava2  s  .  c  o  m*/
    return ers.contains(
            new ExcessReplica(datanodeManager.getDatanode(dn).getSId(), blk.getBlockId(), blk.getInodeId()));
}

From source file:io.hops.metadata.blockmanagement.ExcessReplicasMap.java

License:Apache License

private Collection<ExcessReplica> getExcessReplicas(BlockInfo blk)
        throws StorageException, TransactionContextException {
    return EntityManager.findList(ExcessReplica.Finder.ByBlockIdAndINodeId, blk.getBlockId(), blk.getInodeId());
}

From source file:io.hops.metadata.blockmanagement.ExcessReplicasMap.java

License:Apache License

private ExcessReplica getExcessReplica(int dn, BlockInfo block)
        throws StorageException, TransactionContextException {
    return EntityManager.find(ExcessReplica.Finder.ByBlockIdStorageIdAndINodeId, block.getBlockId(), dn,
            block.getInodeId());//from w ww .j  ava 2  s  . co  m
}

From source file:io.hops.transaction.context.BlockInfoContext.java

License:Apache License

@Override
public void update(BlockInfo blockInfo) throws TransactionContextException {
    super.update(blockInfo);
    //only called in update not add
    updateInodeBlocks(blockInfo);//from   w  w  w . j  ava 2  s .c  om
    log("updated-blockinfo", "bid", blockInfo.getBlockId(), "inodeId", blockInfo.getInodeId(), "blk index",
            blockInfo.getBlockIndex());

}

From source file:io.hops.transaction.context.BlockInfoContext.java

License:Apache License

@Override
public void remove(BlockInfo blockInfo) throws TransactionContextException {
    super.remove(blockInfo);
    removeBlockFromInodeBlocks(blockInfo);
    log("removed-blockinfo", "bid", blockInfo.getBlockId());
}

From source file:io.hops.transaction.context.BlockInfoContext.java

License:Apache License

@Override
Long getKey(BlockInfo blockInfo) {
    return blockInfo.getBlockId();
}

From source file:io.hops.transaction.context.BlockInfoContext.java

License:Apache License

private List<BlockInfo> syncBlockInfoInstances(List<BlockInfo> newBlocks, boolean syncInodeBlocks) {
    List<BlockInfo> finalList = new ArrayList<BlockInfo>();

    for (BlockInfo blockInfo : newBlocks) {
        if (isRemoved(blockInfo.getBlockId())) {
            continue;
        }/*  www. j  a va2 s  .c  o m*/

        gotFromDB(blockInfo);
        finalList.add(blockInfo);

        if (syncInodeBlocks) {
            List<BlockInfo> blockList = inodeBlocks.get(blockInfo.getInodeId());
            if (blockList == null) {
                blockList = new ArrayList<BlockInfo>();
                inodeBlocks.put(blockInfo.getInodeId(), blockList);
            }
            blockList.add(blockInfo);
        }
    }

    return finalList;
}

From source file:io.hops.transaction.context.BlockInfoContext.java

License:Apache License

private void deleteBlocksForConcat(INodeCandidatePrimaryKey trg_param,
        List<INodeCandidatePrimaryKey> deleteINodes, List<BlockInfo> oldBlks /* blks with old pk*/)
        throws TransactionContextException {

    if (!getRemoved().isEmpty()) {//in case of concat new block_infos rows are added by
        // the concat fn
        throw new IllegalStateException(
                "Concat file(s) whose blocks are changed. During rename and move no block blocks should have been changed.");
    }//from www  .  j a  v a2s. c o  m

    for (BlockInfo bInfo : oldBlks) {
        INodeCandidatePrimaryKey pk = new INodeCandidatePrimaryKey(bInfo.getInodeId());
        if (deleteINodes.contains(pk)) {
            //remove the block
            concatRemovedBlks.add(bInfo);
            log("snapshot-maintenance-removed-blockinfo", "bid", bInfo.getBlockId(), "inodeId",
                    bInfo.getInodeId());
        }
    }
}

From source file:io.hops.transaction.lock.BlockLock.java

License:Apache License

private boolean contains(Iterable<BlockInfo> blks, long blockId) {
    for (BlockInfo blk : blks) {
        if (blockId == blk.getBlockId()) {
            return true;
        }//from  ww w .j a  v  a 2 s  . c  o  m
    }
    return false;
}