List of usage examples for org.apache.hadoop.hdfs.server.namenode INode getLocalName
public final String getLocalName()
From source file:io.hops.common.INodeUtil.java
License:Apache License
public static INodeIdentifier resolveINodeFromBlockID(final long bid) throws StorageException { INodeIdentifier inodeIdentifier;//from ww w.j a v a 2 s . c om LightWeightRequestHandler handler = new LightWeightRequestHandler( HDFSOperationType.RESOLVE_INODE_FROM_BLOCKID) { @Override public Object performTask() throws IOException { BlockLookUpDataAccess<BlockLookUp> da = (BlockLookUpDataAccess) HdfsStorageFactory .getDataAccess(BlockLookUpDataAccess.class); BlockLookUp blu = da.findByBlockId(bid); if (blu == null) { return null; } INodeIdentifier inodeIdent = new INodeIdentifier(blu.getInodeId()); INodeDALAdaptor ida = (INodeDALAdaptor) HdfsStorageFactory.getDataAccess(INodeDataAccess.class); INode inode = ida.indexScanfindInodeById(blu.getInodeId()); if (inode != null) { inodeIdent.setName(inode.getLocalName()); inodeIdent.setPid(inode.getParentId()); } return inodeIdent; } }; try { inodeIdentifier = (INodeIdentifier) handler.handle(); } catch (IOException ex) { throw new StorageException(ex.getMessage()); } return inodeIdentifier; }
From source file:io.hops.common.INodeUtil.java
License:Apache License
public static INodeIdentifier resolveINodeFromBlock(final Block b) throws StorageException { if (b instanceof BlockInfo || b instanceof BlockInfoUnderConstruction) { INodeIdentifier inodeIden = new INodeIdentifier(((BlockInfo) b).getInodeId()); INodeDALAdaptor ida = (INodeDALAdaptor) HdfsStorageFactory.getDataAccess(INodeDataAccess.class); INode inode = ida.indexScanfindInodeById(((BlockInfo) b).getInodeId()); if (inode != null) { inodeIden.setName(inode.getLocalName()); inodeIden.setPid(inode.getParentId()); }/*from w w w . ja v a2s . c om*/ return inodeIden; } else { return resolveINodeFromBlockID(b.getBlockId()); } }
From source file:io.hops.common.INodeUtil.java
License:Apache License
public static INodeIdentifier resolveINodeFromId(final int id) throws StorageException { INodeIdentifier inodeIdentifier;/* w w w. ja va2 s .c o m*/ LightWeightRequestHandler handler = new LightWeightRequestHandler(HDFSOperationType.RESOLVE_INODE_FROM_ID) { @Override public Object performTask() throws StorageException, IOException { INodeDALAdaptor ida = (INodeDALAdaptor) HdfsStorageFactory.getDataAccess(INodeDataAccess.class); INode inode = ida.indexScanfindInodeById(id); INodeIdentifier inodeIdent = new INodeIdentifier(id); if (inode != null) { inodeIdent.setName(inode.getLocalName()); inodeIdent.setPid(inode.getParentId()); } return inodeIdent; } }; try { inodeIdentifier = (INodeIdentifier) handler.handle(); } catch (IOException ex) { throw new StorageException(ex.getMessage()); } return inodeIdentifier; }
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 {//w w w. j av a 2s .c o m builder.append(node.getLocalName()); } } return builder.toString(); }
From source file:io.hops.transaction.context.INodeContext.java
License:Apache License
@Override public void remove(INode iNode) throws TransactionContextException { super.remove(iNode); inodesNameParentIndex.remove(iNode.nameParentKey()); log("removed-inode", "id", iNode.getId(), "name", iNode.getLocalName()); }
From source file:io.hops.transaction.context.INodeContext.java
License:Apache License
@Override public void update(INode iNode) throws TransactionContextException { super.update(iNode); inodesNameParentIndex.put(iNode.nameParentKey(), iNode); log("updated-inode", "id", iNode.getId(), "name", iNode.getLocalName()); }
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 ww w . j ava 2 s .co 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
private boolean containsRemoved(final Integer parentId, final String name) { return contains(new Predicate<ContextEntity>() { @Override//from w ww.ja v a 2 s . c o m public boolean apply(ContextEntity input) { INode iNode = input.getEntity(); return input.getState() == State.REMOVED && iNode.getParentId() == parentId && iNode.getLocalName().equals(name); } }); }
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; }/*w w w .j a v a 2 s.c om*/ } verified = noChangeInInodes; } } return verified; }
From source file:io.hops.transaction.lock.INodeLock.java
License:Apache License
private void checkSubtreeLock(INode iNode) throws SubtreeLockedException { if (SubtreeLockHelper.isSubtreeLocked(iNode.isSubtreeLocked(), iNode.getSubtreeLockOwner(), activeNamenodes)) {/* w w w. j ava 2s.c om*/ if (!ignoreLocalSubtreeLocks && namenodeId != iNode.getSubtreeLockOwner()) { throw new SubtreeLockedException(iNode.getLocalName(), activeNamenodes); } } }