Example usage for org.apache.hadoop.hdfs.server.namenode INode getId

List of usage examples for org.apache.hadoop.hdfs.server.namenode INode getId

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs.server.namenode INode getId.

Prototype

public abstract long getId();

Source Link

Document

Get inode id

Usage

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

License:Apache License

@Override
protected void acquire(TransactionLocks locks) throws IOException {
    //[S] consider src = /a/b/c and dst = /d
    //during the acquire lock of src write locks will be acquired on parent of c and c
    //during the acquire lock of dst write lock on the root will be acquired but the snapshot 
    //layer will not let the request go to the db as it has already cached the root inode
    //one simple solution is that to acquire lock on the short path first
    //setPartitioningKey(PathMemcache.getInstance().getPartitionKey(locks.getInodeParam()[0]));
    String src = paths[0];/* w ww .  j  a  v  a2  s. co  m*/
    String dst = paths[1];
    Arrays.sort(paths, PATH_COMPARTOR);
    acquireINodeLocks();

    if (legacyRename) // In deprecated rename, it allows to move a dir to an existing destination.
    {
        List<INode> dstINodes = getPathINodes(dst);
        String[] dstComponents = INode.getPathNames(dst);
        String[] srcComponents = INode.getPathNames(src);
        INode lastComp = dstINodes.get(dstINodes.size() - 1);

        if (dstINodes.size() == dstComponents.length && lastComp.isDirectory()) {
            //the dst exist and is a directory.
            find(srcComponents[srcComponents.length - 1], lastComp.getId());
        }
    }

    acquireINodeAttributes();
}

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

License:Apache License

@Override
protected void acquire(TransactionLocks locks) throws IOException {
    BaseINodeLock inodeLock = (BaseINodeLock) locks.getLock(Type.INode);
    for (INode inode : inodeLock.getTargetINodes()) {

        if (attrs == null || attrs.isEmpty()) {
            //read all xattrs
            //Skip if the inode doesn't have any xattrs
            if (inode.getNumXAttrs() == 0) {
                EntityManager.snapshotMaintenance(HdfsTransactionContextMaintenanceCmds.NoXAttrsAttached,
                        inode.getId());
                continue;
            }/*from w w w  .java  2  s.  co  m*/
            acquireLockList(DEFAULT_LOCK_TYPE, StoredXAttr.Finder.ByInodeId, inode.getId());
        } else {
            acquireLockList(DEFAULT_LOCK_TYPE, StoredXAttr.Finder.ByPrimaryKeyBatch,
                    XAttrFeature.getPrimaryKeys(inode.getId(), attrs));
        }
    }
}