List of usage examples for org.apache.hadoop.hdfs.server.namenode INode isDirectory
public boolean isDirectory()
From source file:io.hops.common.INodeUtil.java
License:Apache License
public static String constructPath(List<INode> pathINodes) { StringBuilder builder = new StringBuilder(); for (INode node : pathINodes) { if (node.isDirectory()) { builder.append(node.getLocalName() + "/"); } else {/*from ww w . j a v a 2 s. co m*/ builder.append(node.getLocalName()); } } return builder.toString(); }
From source file:io.hops.resolvingcache.OptimalMemcache.java
License:Apache License
@Override protected void setInternal(MemcachedClient mc, String path, List<INode> inodes) { if (INode.getPathNames(path).length != inodes.size()) return;/*from w w w. jav a2s. com*/ int lastIndex = path.lastIndexOf(Path.SEPARATOR); if (lastIndex <= 0) return; INode file = inodes.get(inodes.size() - 1); if (file.isDirectory()) { super.setInternal(mc, path, inodes); return; } String parentPath = path.substring(0, lastIndex); super.setInternal(mc, parentPath, inodes.subList(0, inodes.size() - 1)); setInternal(mc, file); }
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];/*from w ww . ja va 2 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: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 a v a 2s . c om 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; }