List of usage examples for org.apache.hadoop.hdfs.server.namenode INodeFile getId
long getId();
From source file:io.hops.transaction.lock.BlockRelatedLock.java
License:Apache License
@Override protected void acquire(TransactionLocks locks) throws IOException { // FIXME handle null block Lock lock = locks.getLock(Type.Block); if (lock instanceof BaseIndividualBlockLock) { BaseIndividualBlockLock individualBlockLock = (BaseIndividualBlockLock) lock; //get by blocksId for (BlockInfo blk : individualBlockLock.getBlocks()) { if (isList()) { acquireLockList(DEFAULT_LOCK_TYPE, getFinderType(true), blk.getBlockId(), blk.getInodeId()); } else { acquireLock(DEFAULT_LOCK_TYPE, getFinderType(true), blk.getBlockId(), blk.getInodeId()); }//from w w w .ja va2 s . com } if (lock instanceof BlockLock) { //get by inodeId BlockLock blockLock = (BlockLock) lock; for (INodeFile file : blockLock.getFiles()) { acquireLockList(DEFAULT_LOCK_TYPE, getFinderType(false), file.getId()); } } } else { throw new TransactionLocks.LockNotAddedException("Block Lock wasn't added"); } }
From source file:io.hops.transaction.lock.LastBlockReplicasHashBucketLock.java
License:Apache License
@Override protected void acquire(TransactionLocks locks) throws IOException { BlockLock blockLock = (BlockLock) locks.getLock(Type.Block); for (INodeFile iNodeFile : blockLock.getFiles()) { Block lastBlock = iNodeFile.getLastBlock(); if (iNodeFile.getLastBlock() != null) { List<Replica> replicas = (List<Replica>) EntityManager.findList(Replica.Finder.ByBlockIdAndINodeId, lastBlock.getBlockId(), iNodeFile.getId()); if (replicas != null) { Collections.sort(replicas, new Comparator<Replica>() { @Override/*from w w w . j a va 2s. c o m*/ public int compare(Replica o1, Replica o2) { return new Integer(o1.getBucketId()).compareTo(o2.getBucketId()); } }); //FIXME-BR why lock buckets for all the replicas. Only the last // replica should be locked. Am I missing something for (Replica replica : replicas) { EntityManager.find(HashBucket.Finder.ByStorageIdAndBucketId, replica.getStorageId(), replica.getBucketId()); } } } } }