Ejemplo n.º 1
0
        public void DistributedCacheConstructorTest1()
        {
            string diskCacheDirectoryRoot    = string.Empty; // TODO: Initialize to an appropriate value
            DistributedCache_Accessor target = new DistributedCache_Accessor(diskCacheDirectoryRoot);

            Assert.Inconclusive("TODO: Implement code to verify target");
        }
Ejemplo n.º 2
0
        public void GetSHA1HashTest()
        {
            string cacheKey = string.Empty; // TODO: Initialize to an appropriate value
            SHA1   sha1     = null;         // TODO: Initialize to an appropriate value

            byte[] expected = null;         // TODO: Initialize to an appropriate value
            byte[] actual;
            actual = DistributedCache_Accessor.GetSHA1Hash(cacheKey, sha1);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Ejemplo n.º 3
0
        public void WriteTest()
        {
            PrivateObject             param0 = null;                                  // TODO: Initialize to an appropriate value
            DistributedCache_Accessor target = new DistributedCache_Accessor(param0); // TODO: Initialize to an appropriate value
            string cacheKey    = string.Empty;                                        // TODO: Initialize to an appropriate value
            object cacheObject = null;                                                // TODO: Initialize to an appropriate value
            SHA1   sha1        = null;                                                // TODO: Initialize to an appropriate value

            target.Write(cacheKey, cacheObject, sha1, true);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
Ejemplo n.º 4
0
        public void WriteCacheItemsWhenReadFromCachePeersTest()
        {
            PrivateObject             param0 = null;                                  // TODO: Initialize to an appropriate value
            DistributedCache_Accessor target = new DistributedCache_Accessor(param0); // TODO: Initialize to an appropriate value
            bool expected = false;                                                    // TODO: Initialize to an appropriate value
            bool actual;

            target.WriteCacheItemsWhenReadFromCachePeers = expected;
            actual = target.WriteCacheItemsWhenReadFromCachePeers;
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Ejemplo n.º 5
0
        public void UseSlidingWindowCacheTest()
        {
            PrivateObject             param0 = null;                                  // TODO: Initialize to an appropriate value
            DistributedCache_Accessor target = new DistributedCache_Accessor(param0); // TODO: Initialize to an appropriate value
            bool expected = false;                                                    // TODO: Initialize to an appropriate value
            bool actual;

            target.UseSlidingWindowCache = expected;
            actual = target.UseSlidingWindowCache;
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Ejemplo n.º 6
0
        public void ReadTest()
        {
            PrivateObject             param0 = null;                                  // TODO: Initialize to an appropriate value
            DistributedCache_Accessor target = new DistributedCache_Accessor(param0); // TODO: Initialize to an appropriate value
            string cacheKey = string.Empty;                                           // TODO: Initialize to an appropriate value
            SHA1   sha1     = null;                                                   // TODO: Initialize to an appropriate value
            object expected = null;                                                   // TODO: Initialize to an appropriate value
            object actual;

            actual = target.Read(cacheKey, sha1);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Ejemplo n.º 7
0
        public void ReadObjectFromCachePeerDiskTest()
        {
            PrivateObject             param0 = null;                                  // TODO: Initialize to an appropriate value
            DistributedCache_Accessor target = new DistributedCache_Accessor(param0); // TODO: Initialize to an appropriate value
            string cacheKey = string.Empty;                                           // TODO: Initialize to an appropriate value

            byte[] sha1Hash = null;                                                   // TODO: Initialize to an appropriate value
            string fileName = string.Empty;                                           // TODO: Initialize to an appropriate value
            object expected = null;                                                   // TODO: Initialize to an appropriate value
            object actual;

            actual = target.ReadObjectFromCachePeerDisk(cacheKey, sha1Hash, fileName);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Ejemplo n.º 8
0
        public void TestFullTextDistributedCacheStorageBasic()
        {
            string diskCacheDirectoryRoot    = "C:\\DeleteMe"; // TODO: Initialize to an appropriate value
            DistributedCache_Accessor target = new DistributedCache_Accessor(diskCacheDirectoryRoot);

            SHA1 sha1 = SHA1.Create();

            target.Write("the", "some document:1", sha1, true);
            target.Write("quick", "some document:1", sha1, true);
            target.Write("brown", "some document:1", sha1, true);
            target.Write("fox", "some document:1", sha1, true);
            target.Write("jumped", "some document:1", sha1, true);
            target.Write("over", "some document:1", sha1, true);
            target.Write("the", "some document:1", sha1, true);
            target.Write("lazy", "some document:1", sha1, true);
            target.Write("dog", "some document:1", sha1, true);
        }
Ejemplo n.º 9
0
        public void GetFileNameTest()
        {
            PrivateObject             param0 = null;                                  // TODO: Initialize to an appropriate value
            DistributedCache_Accessor target = new DistributedCache_Accessor(param0); // TODO: Initialize to an appropriate value
            string cacheDirectoryRoot        = string.Empty;                          // TODO: Initialize to an appropriate value
            string cacheKey = string.Empty;                                           // TODO: Initialize to an appropriate value

            byte[] sha1Hash        = null;                                            // TODO: Initialize to an appropriate value
            bool   createKey       = false;                                           // TODO: Initialize to an appropriate value
            bool   createDirectory = false;                                           // TODO: Initialize to an appropriate value
            string expected        = string.Empty;                                    // TODO: Initialize to an appropriate value
            string actual;

            actual = target.GetFileName(cacheDirectoryRoot, cacheKey, sha1Hash, createKey, createDirectory);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Ejemplo n.º 10
0
        public void TestFullTextDistributedCacheStorageStress()
        {
            string directoryRoot1 = "c:\\DeleteMe\\WordsPerAbsoluteUri";
            string directoryRoot2 = "c:\\DeleteMe\\InvertedIndexPerWord";

            try
            {
                //Directories.DeleteFilesInDirectory(directoryRoot1 + "\\arachnode.cache");
                //Directories.DeleteFilesInDirectory(directoryRoot2 + "\\arachnode.cache");
            }
            catch (Exception)
            {
                throw;
            }

            DistributedCache_Accessor wordsPerAbsoluteUriDistributedCache = new DistributedCache_Accessor(directoryRoot1);

            wordsPerAbsoluteUriDistributedCache.UseSlidingWindowCache = false;

            DistributedCache_Accessor invertedIndexPerWordDistributedCache = new DistributedCache_Accessor(directoryRoot2);

            invertedIndexPerWordDistributedCache.UseSlidingWindowCache      = true;
            invertedIndexPerWordDistributedCache.CacheItemPriority          = CacheItemPriority.Normal;
            invertedIndexPerWordDistributedCache.CacheItemSlidingExpiration = TimeSpan.FromSeconds(10);

            Stopwatch perDocumentStopwatch = new Stopwatch();
            Stopwatch corpusStopwatch      = new Stopwatch();
            SHA1      sha1 = SHA1.Create();

            int iterations       = 10;
            int numberOfWebPages = 10000;

            double totalNumberOfWebPages = 0;

            WebClient webClient = new WebClient();

            corpusStopwatch.Reset();
            corpusStopwatch.Start();

            for (int j = 1; j <= iterations; j++)
            {
                for (int i = 1; i <= numberOfWebPages; i++)
                {
                    totalNumberOfWebPages++;

                    string absoluteUri = "http://localhost:56830/Test/" + i + ".htm";

                    string downloadedString = webClient.DownloadString(absoluteUri);

                    IEnumerator enumerator = UserDefinedFunctions.ExtractWords(downloadedString, true, true).GetEnumerator();

                    perDocumentStopwatch.Reset();
                    perDocumentStopwatch.Start();

                    HashSet <string> wordsPerAbsoluteUri = new HashSet <string>();

                    bool writeWordsPerAbsoluteUri = false;

                    object o2 = wordsPerAbsoluteUriDistributedCache.Read("WORDS_" + absoluteUri + "_" + j, sha1);

                    if (true || o2 == null)
                    {
                        while (enumerator.MoveNext())
                        {
                            wordsPerAbsoluteUri.Add(enumerator.Current.ToString());

                            /**/

                            string directory = invertedIndexPerWordDistributedCache.GenerateFullTextUniqueDirectory(enumerator.Current.ToString(), false, sha1);

                            string directory2 = directory + "\\" + invertedIndexPerWordDistributedCache.GetFileNameWithoutDirectory(absoluteUri + "_" + j, sha1);

                            if (!Directory.Exists(directory2))
                            {
                                Directory.CreateDirectory(directory2);
                            }

                            //HashSet<string> invertedIndexPerWord;

                            //object o = invertedIndexPerWordDistributedCache.Read(enumerator.Current.ToString(), sha1);

                            //if (o == null)
                            //{
                            //    invertedIndexPerWord = new HashSet<string>();

                            //    invertedIndexPerWordDistributedCache.Write(enumerator.Current.ToString(), invertedIndexPerWord, sha1, false);
                            //}
                            //else
                            //{
                            //    invertedIndexPerWord = (HashSet<string>) o;
                            //}

                            //if (!invertedIndexPerWord.Contains(absoluteUri + "_" + j))
                            //{
                            //    invertedIndexPerWord.Add(absoluteUri + "_" + j);

                            //    writeWordsPerAbsoluteUri = true;
                            //}
                            //Debug.Print(invertedIndexPerWord.Count.ToString());
                        }

                        if (true || writeWordsPerAbsoluteUri)
                        {
                            wordsPerAbsoluteUriDistributedCache.Write("WORDS_" + absoluteUri + "_" + j, wordsPerAbsoluteUri, sha1, true);

                            invertedIndexPerWordDistributedCache.CacheItemSlidingExpiration = TimeSpan.FromSeconds(perDocumentStopwatch.Elapsed.TotalSeconds + 2);
                        }
                    }

                    perDocumentStopwatch.Stop();

                    Debug.Print((((j - 1) * numberOfWebPages) + i).ToString());
                    Debug.Print(perDocumentStopwatch.Elapsed.ToString());
                    Debug.Print((corpusStopwatch.Elapsed.TotalSeconds / totalNumberOfWebPages).ToString());
                }

                Debug.Print(j.ToString());
                Debug.Print(corpusStopwatch.Elapsed.ToString());
                Debug.Print((corpusStopwatch.Elapsed.TotalSeconds / totalNumberOfWebPages).ToString());
            }

            corpusStopwatch.Stop();
            Debug.Print(corpusStopwatch.Elapsed.ToString());
            Debug.Print((corpusStopwatch.Elapsed.TotalSeconds / totalNumberOfWebPages).ToString());
        }