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.context.INodeContext.java

License:Apache License

@Override
public void snapshotMaintenance(TransactionContextMaintenanceCmds cmds, Object... params)
        throws TransactionContextException {
    HdfsTransactionContextMaintenanceCmds hopCmds = (HdfsTransactionContextMaintenanceCmds) cmds;
    switch (hopCmds) {
    case INodePKChanged:
        //delete the previous row from db
        INode inodeBeforeChange = (INode) params[0];
        INode inodeAfterChange = (INode) params[1];
        super.remove(inodeBeforeChange);
        renamedInodes.add(inodeAfterChange);
        log("snapshot-maintenance-inode-pk-change", "Before inodeId", inodeBeforeChange.getId(), "name",
                inodeBeforeChange.getLocalName(), "pid", inodeBeforeChange.getParentId(), "After inodeId",
                inodeAfterChange.getId(), "name", inodeAfterChange.getLocalName(), "pid",
                inodeAfterChange.getParentId());
        log("snapshot-maintenance-removed-inode", "name", inodeBeforeChange.getLocalName(), "inodeId",
                inodeBeforeChange.getId(), "pid", inodeBeforeChange.getParentId());
        break;/*from w  w  w. j  av  a  2 s .c o  m*/
    case Concat:
        // do nothing
        // why? files y and z are merged into file x.
        // all the blocks will be added to file x and the inodes y and z will be deleted.
        // Inode deletion is handled by the concat function
        break;
    }
}

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

License:Apache License

@Override
Integer getKey(INode iNode) {
    return iNode.getId();
}

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

License:Apache License

private List<INode> syncInodeInstances(List<INode> newInodes) {
    List<INode> finalList = new ArrayList<INode>(newInodes.size());

    for (INode inode : newInodes) {
        if (isRemoved(inode.getId())) {
            continue;
        }//from   ww w. j a  va2 s .c o  m

        gotFromDB(inode);
        finalList.add(inode);

        String key = inode.nameParentKey();
        if (inodesNameParentIndex.containsKey(key)) {
            if (inodesNameParentIndex.get(key) == null) {
                inodesNameParentIndex.put(key, inode);
            }
        } else {
            inodesNameParentIndex.put(key, inode);
        }
    }
    Collections.sort(finalList, INode.Order.ByName);
    return finalList;
}

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

License:Apache License

@Override
protected void acquire(TransactionLocks locks) throws IOException {
    BaseINodeLock inodeLock = (BaseINodeLock) locks.getLock(Type.INode);
    for (INode inode : inodeLock.getAllResolvedINodes()) {
        if (inode.getNumAces() > 0) {
            //Retrieve aces for inode
            int[] indices = new int[inode.getNumAces()];
            for (int i = 0; i < inode.getNumAces(); i++) {
                indices[i] = i;// www.  j  a  va  2 s.co  m
            }
            acquireLockList(TransactionLockTypes.LockType.WRITE, Ace.Finder.ByInodeIdAndIndices, inode.getId(),
                    indices);
        }
    }
}

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

License:Apache License

protected void acquireINodeAttributes() throws StorageException, TransactionContextException {
    List<INodeCandidatePrimaryKey> pks = new ArrayList<INodeCandidatePrimaryKey>();
    for (INode inode : getAllResolvedINodes()) {
        if (inode instanceof INodeDirectoryWithQuota) {
            INodeCandidatePrimaryKey pk = new INodeCandidatePrimaryKey(inode.getId());
            pks.add(pk);/*  ww  w .  j a v  a2 s.  c  om*/
        }
    }
    acquireLockList(DEFAULT_LOCK_TYPE, INodeAttributes.Finder.ByINodeIds, pks);
}

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

License:Apache License

private boolean verifyINodes(final List<INode> inodes, final String[] names, final int[] parentIds,
        final int[] inodeIds) throws IOException {
    boolean verified = false;
    if (names.length == parentIds.length) {
        if (inodes.size() == names.length) {
            boolean noChangeInInodes = true;
            for (int i = 0; i < inodes.size(); i++) {
                INode inode = inodes.get(i);
                noChangeInInodes = inode != null && inode.getLocalName().equals(names[i])
                        && inode.getParentId() == parentIds[i] && inode.getId() == inodeIds[i];
                if (!noChangeInInodes) {
                    break;
                }/*from   w  w w .  j  av a2 s  . com*/
            }
            verified = noChangeInInodes;
        }
    }
    return verified;
}

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

License:Apache License

@Override
protected void acquire(TransactionLocks locks) throws IOException {
    INodeLock iNodeLock = (INodeLock) locks.getLock(Type.INode);
    INode iNode = iNodeLock.getTargetINode(target);
    BlockChecksumDataAccess.KeyTuple key = new BlockChecksumDataAccess.KeyTuple(iNode.getId(), blockIndex);
    acquireLock(DEFAULT_LOCK_TYPE, BlockChecksum.Finder.ByKeyTuple, key);
}

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

License:Apache License

@Override
protected void acquire(TransactionLocks locks) throws IOException {
    BaseINodeLock inodeLock = (BaseINodeLock) locks.getLock(Type.INode);
    Iterable blks = Collections.EMPTY_LIST;
    for (INode inode : inodeLock.getAllResolvedINodes()) {
        if (inode instanceof INodeFile) {
            Collection<BlockInfo> inodeBlocks = acquireLockList(DEFAULT_LOCK_TYPE, BlockInfo.Finder.ByINodeId,
                    inode.getId());
            blks = Iterables.concat(blks, inodeBlocks);
            files.add((INodeFile) inode);
        }/*  w ww  . j a  v a2  s. c  om*/
    }
    //FIXME we need to bring null to the cache instead
    fixTheCache(locks, blks);
}

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

License:Apache License

@Override
protected void acquire(TransactionLocks locks) throws IOException {
    INodeLock iNodeLock = (INodeLock) locks.getLock(Type.INode);
    LeasePathLock leasePathLock = (LeasePathLock) locks.getLock(Type.LeasePath);
    if (path != null) {
        Collection<LeasePath> lps = leasePathLock.getLeasePaths();
        for (LeasePath lp : lps) {
            if (lp.getPath().equals(path)) {
                INode targetInode = iNodeLock.getTargetINode(path);
                readBlock(lp.getLastBlockId(), targetInode.getId());
                readBlock(lp.getPenultimateBlockId(), targetInode.getId());

                if (getBlocks() == null || getBlocks().isEmpty()) {
                    announceEmptyFile(targetInode.getId());
                }// w w  w  . j  a va2  s . co m

                break;
            }
        }
    } else {
        Collection<LeasePath> lps = leasePathLock.getLeasePaths();
        INode targetInode = INodeUtil.getNode(fileId, true);
        String p = targetInode.getFullPathName();
        for (LeasePath lp : lps) {
            if (lp.getPath().equals(p)) {
                readBlock(lp.getLastBlockId(), fileId);
                readBlock(lp.getPenultimateBlockId(), fileId);

                if (getBlocks() == null || getBlocks().isEmpty()) {
                    announceEmptyFile(targetInode.getId());
                }

                break;
            }
        }
    }
}

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

License:Apache License

private void acquireQuotaUpdate(INode iNode) throws StorageException, TransactionContextException {
    acquireLockList(DEFAULT_LOCK_TYPE, QuotaUpdate.Finder.ByINodeId, iNode.getId());
}