示例#1
0
        public void StartTasks()
        {
            try
            {
                Thread[]        threads    = new Thread[_threadCount];
                CacheInitParams parameters = new CacheInitParams();

                _cache = Factory.InitializeCache(_cacheId, parameters);
                _cache.ExceptionsEnabled = true;

                string pid = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();

                for (int threadIndex = 0; threadIndex < _threadCount; threadIndex++)
                {
                    StressThreadTask threadTask = new StressThreadTask(_cache, _totalLoopCount, _testCaseIterations, _testCaseIterationDelay, _getsPerIteration, _updatesPerIteration, _dataSize, _expiration, _threadCount, _reportingInterval, threadIndex, _outputProvider, _adapter);
                    _tasks.Add(threadTask);
                    threadTask.Start();
                }
                _adapter.Listen();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
示例#2
0
        /// <summary>
        /// Main test starting point. This method instantiate multiple threads and keeps track of
        /// all of them.
        /// </summary>
        public void Test()
        {
            try
            {
                Thread[] threads = new Thread[_threadCount];

                Cache cache = Factory.InitializeCache(_cacheId);
                cache.ExceptionsEnabled = true;

                string pid = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();

                for (int threadIndex = 0; threadIndex < _threadCount; threadIndex++)
                {
                    ThreadContainer tc             = new ThreadContainer(cache, _totalLoopCount, _testCaseIterations, _testCaseIterationDelay, _getsPerIteration, _updatesPerIteration, _dataSize, _expiration, _threadCount, _reportingInterval, threadIndex);
                    ThreadStart     threadDelegate = new ThreadStart(tc.DoTest);
                    threads[threadIndex]      = new Thread(threadDelegate);
                    threads[threadIndex].Name = "ThreadIndex: " + threadIndex;
                    threads[threadIndex].Start();
                }

                //--- wait on threads to complete their work before finishing
                for (int threadIndex = 0; threadIndex < threads.Length; threadIndex++)
                {
                    threads[threadIndex].Join();
                }

                cache.Dispose();
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Error :- " + e.Message);
                Console.Error.WriteLine();
                Console.Error.WriteLine(e.ToString());
            }
        }
示例#3
0
 public NCache(string cacheId, string clientCacheId)
 {
     Guard.ArgumentNotNullOrEmpty(cacheId, "cacheId");
     Guard.ArgumentNotNullOrEmpty(clientCacheId, "clientCacheId");
     _cacheId       = cacheId;
     _clientCacheId = clientCacheId;
     _cache         = ANCache.InitializeCache(cacheId, clientCacheId);
 }
示例#4
0
            public static void Run(string[] args)
            {
                try
                {
                    object param = new DumpCacheParam();
                    CommandLineArgumentParser.CommandLineParser(ref param, args);
                    cParam = (DumpCacheParam)param;

                    if (cParam.IsUsage)
                    {
                        AssemblyUsage.PrintLogo(cParam.IsLogo);
                        AssemblyUsage.PrintUsage();
                        return;
                    }
                    if (!ValidateParameters())
                    {
                        return;
                    }

                    Cache cache = Factory.InitializeCache(cParam.CacheId);
                    cache.ExceptionsEnabled = true;

                    System.Console.WriteLine("Cache count: {0}.", cache.Count);
                    IDictionaryEnumerator keys = (IDictionaryEnumerator)cache.GetEnumerator();

                    if (keys != null)
                    {
                        long index       = 0;
                        bool checkFilter = (cParam.KeyFilter != "");
                        cParam.KeyFilter = cParam.KeyFilter.Trim();
                        while (keys.MoveNext())
                        {
                            if ((cParam.KeyCount > 0) && (index >= cParam.KeyCount))
                            {
                                break;
                            }

                            if (checkFilter == true)
                            {
                                string tmpKey = (string)keys.Key;

                                if (tmpKey.Contains(cParam.KeyFilter) == true)
                                {
                                    System.Console.WriteLine(tmpKey);
                                }
                            }
                            else
                            {
                                System.Console.WriteLine(keys.Key);
                            }
                            index++;
                        } //end while
                    }     //end if
                    cache.Dispose();
                }         //end try block
                catch (Exception e)
                {
                    Console.Error.WriteLine("Error: " + e.Message);
                    Console.Error.WriteLine();
                    Console.Error.WriteLine(e.ToString());
                }
            }