List of usage examples for org.apache.hadoop.hdfs.protocol ExtendedBlock getBlockId
public long getBlockId()
From source file:backup.store.BackupUtil.java
License:Apache License
public static org.apache.hadoop.hdfs.protocol.ExtendedBlock toHadoop(ExtendedBlock block) { if (block == null) { return null; }//ww w .j a v a 2s. co m return new org.apache.hadoop.hdfs.protocol.ExtendedBlock(block.getPoolId(), block.getBlockId(), block.getLength(), block.getGenerationStamp()); }
From source file:backup.store.BackupUtil.java
License:Apache License
public static ExtendedBlock fromHadoop(org.apache.hadoop.hdfs.protocol.ExtendedBlock block) { if (block == null) { return null; }//from w w w.j a va 2 s .c om return new ExtendedBlock(block.getBlockPoolId(), block.getBlockId(), block.getNumBytes(), block.getGenerationStamp()); }
From source file:com.bigstep.datalake.JsonUtil.java
License:Apache License
/** Convert an ExtendedBlock to a Json map. */ private static Map<String, Object> toJsonMap(final ExtendedBlock extendedblock) { if (extendedblock == null) { return null; }//from ww w. j av a 2 s . com final Map<String, Object> m = new TreeMap<String, Object>(); m.put("blockPoolId", extendedblock.getBlockPoolId()); m.put("blockId", extendedblock.getBlockId()); m.put("numBytes", extendedblock.getNumBytes()); m.put("generationStamp", extendedblock.getGenerationStamp()); return m; }
From source file:com.mellanox.r4h.DataXceiverBase.java
License:Apache License
private boolean checkAccess(final boolean reply, final ExtendedBlock blk, final Token<BlockTokenIdentifier> t, final Op op, final BlockTokenSecretManager.AccessMode mode, final Msg msg) throws IOException { if (dnBridge.isBlockTokenEnabled()) { if (LOG.isDebugEnabled()) { LOG.debug("Checking block access token for block '" + blk.getBlockId() + "' with mode '" + mode + "'"); }/*www . j a va2 s . c o m*/ try { dnBridge.getBlockPoolTokenSecretManager().checkAccess(t, null, blk, mode); } catch (InvalidToken e) { if (reply) { final OutputStream replyOut = new ByteBufferOutputStream(msg.getOut()); BlockOpResponseProto.Builder resp = BlockOpResponseProto.newBuilder() .setStatus(ERROR_ACCESS_TOKEN); if (mode == BlockTokenSecretManager.AccessMode.WRITE) { DatanodeRegistration dnR = dnBridge.getDNRegistrationForBP(blk.getBlockPoolId()); // NB: Unconditionally using the xfer addr w/o hostname resp.setFirstBadLink(dnR.getXferAddr()); } resp.build().writeDelimitedTo(replyOut); replyOut.flush(); spw.queueAsyncReply(DataXceiverBase.this, msg, onFlightMsgs, true); } LOG.error("Block token verification failed: op=" + op + ", serverSession=" + serverSession + ", message=" + e.getLocalizedMessage()); return false;// FAILED } } return true; // SUCCESS }
From source file:com.mellanox.r4h.MiniDFSCluster.java
License:Apache License
/** * Get file correpsonding to a block//from www. j a v a 2 s. c o m * * @param storageDir * storage directory * @param blk * the block * @return data file corresponding to the block */ public static File getBlockFile(File storageDir, ExtendedBlock blk) { return new File( DatanodeUtil.idToBlockDir(getFinalizedDir(storageDir, blk.getBlockPoolId()), blk.getBlockId()), blk.getBlockName()); }
From source file:com.mellanox.r4h.MiniDFSCluster.java
License:Apache License
/** * Get the latest metadata file correpsonding to a block * //from w ww . j a va2 s . co m * @param storageDir * storage directory * @param blk * the block * @return metadata file corresponding to the block */ public static File getBlockMetadataFile(File storageDir, ExtendedBlock blk) { return new File( DatanodeUtil.idToBlockDir(getFinalizedDir(storageDir, blk.getBlockPoolId()), blk.getBlockId()), blk.getBlockName() + "_" + blk.getGenerationStamp() + Block.METADATA_EXTENSION); }