List of usage examples for org.apache.hadoop.hdfs.server.namenode INode getFullPathName
public String getFullPathName()
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()); }//from w w w. j a v a 2 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:org.apache.ranger.services.hdfs.RangerHdfsAuthorizerTest.java
License:Apache License
private static INode createNode(String[] pathSegments, int i, String owner, String group, boolean file) { String fullPath = StringUtils.join(pathSegments, '/', 0, i + 1); String name = pathSegments[i]; INode mock = Mockito.mock(INode.class); try {// w w w . j av a 2 s. c o m when(mock.getLocalNameBytes()).thenReturn(name.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } when(mock.getUserName()).thenReturn(owner); when(mock.getGroupName()).thenReturn(group); when(mock.getFullPathName()).thenReturn(fullPath); when(mock.isFile()).thenReturn(file); when(mock.isDirectory()).thenReturn(!file); when(mock.toString()).thenReturn(name); return mock; }