/// <summary>Create a block that is currently being constructed.</summary> public BlockInfoContiguousUnderConstruction(Block blk, short replication, HdfsServerConstants.BlockUCState state, DatanodeStorageInfo[] targets) : base(blk, replication) { System.Diagnostics.Debug.Assert(GetBlockUCState() != HdfsServerConstants.BlockUCState .Complete, "BlockInfoUnderConstruction cannot be in COMPLETE state"); this.blockUCState = state; SetExpectedLocations(targets); }
/// <summary>Commit block's length and generation stamp as reported by the client.</summary> /// <remarks> /// Commit block's length and generation stamp as reported by the client. /// Set block state to /// <see cref="Org.Apache.Hadoop.Hdfs.Server.Common.HdfsServerConstants.BlockUCState.Committed /// "/> /// . /// </remarks> /// <param name="block">- contains client reported block length and generation</param> /// <exception cref="System.IO.IOException">if block ids are inconsistent.</exception> internal virtual void CommitBlock(Block block) { if (GetBlockId() != block.GetBlockId()) { throw new IOException("Trying to commit inconsistent block: id = " + block.GetBlockId () + ", expected id = " + GetBlockId()); } blockUCState = HdfsServerConstants.BlockUCState.Committed; this.SetNumBytes(block.GetNumBytes()); // Sort out invalid replicas. SetGenerationStampAndVerifyReplicas(block.GetGenerationStamp()); }
/// <summary>Convert a complete block to an under construction block.</summary> /// <returns>BlockInfoUnderConstruction - an under construction block.</returns> public virtual BlockInfoContiguousUnderConstruction ConvertToBlockUnderConstruction (HdfsServerConstants.BlockUCState s, DatanodeStorageInfo[] targets) { if (IsComplete()) { BlockInfoContiguousUnderConstruction ucBlock = new BlockInfoContiguousUnderConstruction (this, GetBlockCollection().GetBlockReplication(), s, targets); ucBlock.SetBlockCollection(GetBlockCollection()); return(ucBlock); } // the block is already under construction BlockInfoContiguousUnderConstruction ucBlock_1 = (BlockInfoContiguousUnderConstruction )this; ucBlock_1.SetBlockUCState(s); ucBlock_1.SetExpectedLocations(targets); ucBlock_1.SetBlockCollection(GetBlockCollection()); return(ucBlock_1); }
internal virtual void SetBlockUCState(HdfsServerConstants.BlockUCState s) { blockUCState = s; }