Example #1
0
        /// <summary>
        /// Generate testing environment and return a collection of blocks
        /// on which to run the tests.
        /// </summary>
        /// <param name="bpid">Block pool ID to generate blocks for</param>
        /// <param name="dataSet">Namespace in which to insert blocks</param>
        /// <returns>Contrived blocks for further testing.</returns>
        /// <exception cref="System.IO.IOException"/>
        private ExtendedBlock[] Setup(string bpid, FsDatasetImpl dataSet)
        {
            // setup replicas map
            ExtendedBlock[] blocks = new ExtendedBlock[] { new ExtendedBlock(bpid, 1, 1, 2001
                                                                             ), new ExtendedBlock(bpid, 2, 1, 2002), new ExtendedBlock(bpid, 3, 1, 2003), new
                                                           ExtendedBlock(bpid, 4, 1, 2004), new ExtendedBlock(bpid, 5, 1, 2005), new ExtendedBlock
                                                               (bpid, 6, 1, 2006) };
            ReplicaMap   replicasMap = dataSet.volumeMap;
            FsVolumeImpl vol         = (FsVolumeImpl)dataSet.volumes.GetNextVolume(StorageType.Default
                                                                                   , 0).GetVolume();
            ReplicaInfo replicaInfo = new FinalizedReplica(blocks[Finalized].GetLocalBlock(),
                                                           vol, vol.GetCurrentDir().GetParentFile());

            replicasMap.Add(bpid, replicaInfo);
            replicaInfo.GetBlockFile().CreateNewFile();
            replicaInfo.GetMetaFile().CreateNewFile();
            replicasMap.Add(bpid, new ReplicaInPipeline(blocks[Temporary].GetBlockId(), blocks
                                                        [Temporary].GetGenerationStamp(), vol, vol.CreateTmpFile(bpid, blocks[Temporary]
                                                                                                                 .GetLocalBlock()).GetParentFile(), 0));
            replicaInfo = new ReplicaBeingWritten(blocks[Rbw].GetLocalBlock(), vol, vol.CreateRbwFile
                                                      (bpid, blocks[Rbw].GetLocalBlock()).GetParentFile(), null);
            replicasMap.Add(bpid, replicaInfo);
            replicaInfo.GetBlockFile().CreateNewFile();
            replicaInfo.GetMetaFile().CreateNewFile();
            replicasMap.Add(bpid, new ReplicaWaitingToBeRecovered(blocks[Rwr].GetLocalBlock()
                                                                  , vol, vol.CreateRbwFile(bpid, blocks[Rwr].GetLocalBlock()).GetParentFile()));
            replicasMap.Add(bpid, new ReplicaUnderRecovery(new FinalizedReplica(blocks[Rur].GetLocalBlock
                                                                                    (), vol, vol.GetCurrentDir().GetParentFile()), 2007));
            return(blocks);
        }