コード例 #1
0
 internal ReportedBlockInfo(DatanodeStorageInfo storageInfo, Block block, HdfsServerConstants.ReplicaState
                            reportedState)
 {
     this.storageInfo   = storageInfo;
     this.block         = block;
     this.reportedState = reportedState;
 }
コード例 #2
0
        internal virtual void AddReplicaIfNotPresent(DatanodeStorageInfo storage, Block block
                                                     , HdfsServerConstants.ReplicaState rState)
        {
            IEnumerator <BlockInfoContiguousUnderConstruction.ReplicaUnderConstruction> it = replicas
                                                                                             .GetEnumerator();

            while (it.HasNext())
            {
                BlockInfoContiguousUnderConstruction.ReplicaUnderConstruction r = it.Next();
                DatanodeStorageInfo expectedLocation = r.GetExpectedStorageLocation();
                if (expectedLocation == storage)
                {
                    // Record the gen stamp from the report
                    r.SetGenerationStamp(block.GetGenerationStamp());
                    return;
                }
                else
                {
                    if (expectedLocation != null && expectedLocation.GetDatanodeDescriptor() == storage
                        .GetDatanodeDescriptor())
                    {
                        // The Datanode reported that the block is on a different storage
                        // than the one chosen by BlockPlacementPolicy. This can occur as
                        // we allow Datanodes to choose the target storage. Update our
                        // state by removing the stale entry and adding a new one.
                        it.Remove();
                        break;
                    }
                }
            }
            replicas.AddItem(new BlockInfoContiguousUnderConstruction.ReplicaUnderConstruction
                                 (block, storage, rState));
        }
コード例 #3
0
 internal virtual void EnqueueReportedBlock(DatanodeStorageInfo storageInfo, Block
                                            block, HdfsServerConstants.ReplicaState reportedState)
 {
     block = new Block(block);
     GetBlockQueue(block).AddItem(new PendingDataNodeMessages.ReportedBlockInfo(storageInfo
                                                                                , block, reportedState));
     count++;
 }
コード例 #4
0
 internal ReplicaUnderConstruction(Block block, DatanodeStorageInfo target, HdfsServerConstants.ReplicaState
                                   state)
     : base(block)
 {
     this.expectedLocation = target;
     this.state            = state;
     this.chosenAsPrimary  = false;
 }
コード例 #5
0
 public BlockReportReplica(Block block)
     : base(block)
 {
     if (block is BlockListAsLongs.BlockReportReplica)
     {
         this.state = ((BlockListAsLongs.BlockReportReplica)block).GetState();
     }
     else
     {
         this.state = HdfsServerConstants.ReplicaState.Finalized;
     }
 }
コード例 #6
0
        /// <exception cref="System.Exception"/>
        private static ReplicaInPipeline GetReplica(DataNode datanode, string bpid, HdfsServerConstants.ReplicaState
                                                    expectedState)
        {
            ICollection <ReplicaInfo> replicas = FsDatasetTestUtil.GetReplicas(datanode.GetFSDataset
                                                                                   (), bpid);

            for (int i = 0; i < 5 && replicas.Count == 0; i++)
            {
                Log.Info("wait since replicas.size() == 0; i=" + i);
                Sharpen.Thread.Sleep(1000);
            }
            NUnit.Framework.Assert.AreEqual(1, replicas.Count);
            ReplicaInfo r = replicas.GetEnumerator().Next();

            NUnit.Framework.Assert.AreEqual(expectedState, r.GetState());
            return((ReplicaInPipeline)r);
        }
コード例 #7
0
 public virtual void Add(Replica replica)
 {
     try
     {
         // zig-zag to reduce size of legacy blocks
         cos.WriteSInt64NoTag(replica.GetBlockId());
         cos.WriteRawVarint64(replica.GetBytesOnDisk());
         cos.WriteRawVarint64(replica.GetGenerationStamp());
         HdfsServerConstants.ReplicaState state = replica.GetState();
         // although state is not a 64-bit value, using a long varint to
         // allow for future use of the upper bits
         cos.WriteRawVarint64(state.GetValue());
         if (state == HdfsServerConstants.ReplicaState.Finalized)
         {
             numFinalized++;
         }
         numBlocks++;
     }
     catch (IOException ioe)
     {
         // shouldn't happen, ByteString.Output doesn't throw IOE
         throw new InvalidOperationException(ioe);
     }
 }
コード例 #8
0
 public UnexpectedReplicaStateException(ExtendedBlock b, HdfsServerConstants.ReplicaState
                                        expectedState)
     : base("Replica " + b + " is not in expected state " + expectedState)
 {
 }
コード例 #9
0
 public virtual void SetState(HdfsServerConstants.ReplicaState state)
 {
     this.state = state;
 }
コード例 #10
0
ファイル: FsDatasetSpi.cs プロジェクト: orf53975/hadoop.net
 /// <summary>Check if a block is valid.</summary>
 /// <param name="b">The block to check.</param>
 /// <param name="minLength">The minimum length that the block must have.  May be 0.</param>
 /// <param name="state">
 /// If this is null, it is ignored.  If it is non-null, we
 /// will check that the replica has this state.
 /// </param>
 /// <exception cref="Org.Apache.Hadoop.Hdfs.Server.Datanode.ReplicaNotFoundException"
 ///     >If the replica is not found</exception>
 /// <exception cref="Org.Apache.Hadoop.Hdfs.Server.Datanode.UnexpectedReplicaStateException
 ///     ">
 /// If the replica is not in the
 /// expected state.
 /// </exception>
 /// <exception cref="System.IO.FileNotFoundException">
 /// If the block file is not found or there
 /// was an error locating it.
 /// </exception>
 /// <exception cref="System.IO.EOFException">If the replica length is too short.</exception>
 /// <exception cref="System.IO.IOException">May be thrown from the methods called.</exception>
 public abstract void CheckBlock(ExtendedBlock b, long minLength, HdfsServerConstants.ReplicaState
                                 state);
コード例 #11
0
 public ReplicaRecoveryInfo(long blockId, long diskLen, long gs, HdfsServerConstants.ReplicaState
                            rState)
 {
     Set(blockId, diskLen, gs);
     originalState = rState;
 }
コード例 #12
0
 /// <summary>Set replica state.</summary>
 internal virtual void SetState(HdfsServerConstants.ReplicaState s)
 {
     state = s;
 }
コード例 #13
0
 /// <exception cref="Org.Apache.Hadoop.Hdfs.Server.Datanode.ReplicaNotFoundException"
 ///     />
 /// <exception cref="Org.Apache.Hadoop.Hdfs.Server.Datanode.UnexpectedReplicaStateException
 ///     "/>
 /// <exception cref="System.IO.FileNotFoundException"/>
 /// <exception cref="System.IO.EOFException"/>
 /// <exception cref="System.IO.IOException"/>
 public override void CheckBlock(ExtendedBlock b, long minLength, HdfsServerConstants.ReplicaState
                                 state)
 {
 }
コード例 #14
0
        /// <exception cref="System.IO.IOException"/>
        private void WaitForTempReplica(Block bl, int DnN1)
        {
            bool tooLongWait = false;
            int  Timeout     = 40000;

            if (Log.IsDebugEnabled())
            {
                Log.Debug("Wait for datanode " + DnN1 + " to appear");
            }
            while (cluster.GetDataNodes().Count <= DnN1)
            {
                WaitTil(20);
            }
            if (Log.IsDebugEnabled())
            {
                Log.Debug("Total number of DNs " + cluster.GetDataNodes().Count);
            }
            cluster.WaitActive();
            // Look about specified DN for the replica of the block from 1st DN
            DataNode dn1   = cluster.GetDataNodes()[DnN1];
            string   bpid  = cluster.GetNamesystem().GetBlockPoolId();
            Replica  r     = DataNodeTestUtils.FetchReplicaInfo(dn1, bpid, bl.GetBlockId());
            long     start = Time.MonotonicNow();
            int      count = 0;

            while (r == null)
            {
                WaitTil(5);
                r = DataNodeTestUtils.FetchReplicaInfo(dn1, bpid, bl.GetBlockId());
                long waiting_period = Time.MonotonicNow() - start;
                if (count++ % 100 == 0)
                {
                    if (Log.IsDebugEnabled())
                    {
                        Log.Debug("Has been waiting for " + waiting_period + " ms.");
                    }
                }
                if (waiting_period > Timeout)
                {
                    NUnit.Framework.Assert.IsTrue("Was waiting too long to get ReplicaInfo from a datanode"
                                                  , tooLongWait);
                }
            }
            HdfsServerConstants.ReplicaState state = r.GetState();
            if (Log.IsDebugEnabled())
            {
                Log.Debug("Replica state before the loop " + state.GetValue());
            }
            start = Time.MonotonicNow();
            while (state != HdfsServerConstants.ReplicaState.Temporary)
            {
                WaitTil(5);
                state = r.GetState();
                if (Log.IsDebugEnabled())
                {
                    Log.Debug("Keep waiting for " + bl.GetBlockName() + " is in state " + state.GetValue
                                  ());
                }
                if (Time.MonotonicNow() - start > Timeout)
                {
                    NUnit.Framework.Assert.IsTrue("Was waiting too long for a replica to become TEMPORARY"
                                                  , tooLongWait);
                }
            }
            if (Log.IsDebugEnabled())
            {
                Log.Debug("Replica state after the loop " + state.GetValue());
            }
        }