void statisticsTest() { /* Create Statistics in right and wrong manner */ StatisticsFactory factory = StatisticsFactory.GetExistingInstance(); /* Register a type */ TestStatisticsType testType = new TestStatisticsType(); createType(factory, testType); Util.Log("Statistics Type TestStats Registered"); /* Create a statistics */ Statistics testStat1 = factory.CreateStatistics(testType.testStatsType, "TestStatistics"); Assert.IsNotNull(testStat1, "Test Statistics Creation Failed"); /* Tests Find Type , Find Statistics */ Statistics temp = factory.FindFirstStatisticsByType(testType.testStatsType); Assert.IsNotNull(temp, "findFirstStatisticsByType Failed"); Util.Log("Statistics testStat1 Created Successfully."); /* Test Set Functions */ testGetSetIncFunctions(testStat1, testType); Util.Log("Get / Set / Inc Functions Tested "); /* Close Statistics */ testStat1.Close(); Statistics temp2 = factory.FindFirstStatisticsByType(testType.testStatsType); Assert.IsNull(temp2, "Statistics close() Failed"); Util.Log("StatisticsTest Completed"); }
public PerfStat(int threadID) { PerfStatType regStatType = PerfStatType.GetInstance(); statsType = regStatType.GetStatType(); StatisticsFactory factory = StatisticsFactory.GetExistingInstance(); string buf = String.Format("ThreadId-{0}", threadID); testStat = factory.CreateStatistics(statsType, buf); }
public StatisticsType GetStatType() { StatisticsFactory m_factory = StatisticsFactory.GetExistingInstance(); StatisticsType statsType = m_factory.FindType("cacheperf.CachePerfStats"); if (statsType == null) { statDes[0] = m_factory.CreateIntCounter(PerfOps.PERF_PUTS, "Number of puts completed.", "operations", 1); statDes[1] = m_factory.CreateLongCounter(PerfOps.PERF_PUT_TIME, "Total time spent doing puts.", "nanoseconds", 0); statDes[2] = m_factory.CreateIntCounter(PerfOps.PERF_UPDATE_EVENTS, "Number of update events.", "events", 1); statDes[3] = m_factory.CreateLongCounter(PerfOps.PERF_UPDATE_LATENCY, "Latency of update operations.", "nanoseconds", 0); statDes[4] = m_factory.CreateIntCounter(PerfOps.PERF_CREATES, "Number of creates completed.", "operations", 1); statDes[5] = m_factory.CreateLongCounter(PerfOps.PERF_CREATE_TIME, "Total time spent doing creates.", "nanoseconds", 0); statDes[6] = m_factory.CreateIntCounter(PerfOps.PERF_LATENCY_SPIKES, "Number of latency spikes.", "spikes", 0); statDes[7] = m_factory.CreateIntCounter( PerfOps.PERF_NEGATIVE_LATENCIES, "Number of negative latencies (caused by insufficient clock skew correction).", "negatives", 0); statDes[8] = m_factory.CreateIntCounter(PerfOps.PERF_OPS, "Number of operations completed.", "operations", 1); statDes[9] = m_factory.CreateLongCounter(PerfOps.PERF_OP_TIME, "Total time spent doing operations.", "nanoseconds", 0); statDes[10] = m_factory.CreateIntCounter(PerfOps.PERF_CONNECTS, "Number of connects completed.", "operations", 1); statDes[11] = m_factory.CreateLongCounter(PerfOps.PERF_CONNECT_TIME, "Total time spent doing connects.", "nanoseconds", 0); statDes[12] = m_factory.CreateIntCounter(PerfOps.PERF_DISCONNECTS, "Number of disconnects completed.", "operations", 1); statDes[13] = m_factory.CreateLongCounter(PerfOps.PERF_DISCONNECT_TIME, "Total time spent doing disconnects.", "nanoseconds", 0); statDes[14] = m_factory.CreateIntCounter(PerfOps.PERF_GETS, "Number of gets completed.", "operations", 1); statDes[15] = m_factory.CreateLongCounter(PerfOps.PERF_GET_TIME, "Total time spent doing gets.", "nanoseconds", 0); statDes[16] = m_factory.CreateIntCounter(PerfOps.PERF_QUERIES, "Number of queries completed.", "operations", 1); statDes[17] = m_factory.CreateLongCounter(PerfOps.PERF_QUERY_TIME, "Total time spent doing queries.", "nanoseconds", 0); statDes[18] = m_factory.CreateIntCounter(PerfOps.PERF_UPDATES, "Number of updates completed.", "operations", 1); statDes[19] = m_factory.CreateLongCounter(PerfOps.PERF_UPDATES_TIME, "Total time spent doing updates.", "nanoseconds", 0); statsType = m_factory.CreateType("cacheperf.CachePerfStats", "Application statistics.", statDes, 20); } return(statsType); }
public void DoPRSHFixedPartitionResolverTests(string rname) { IRegion <object, object> region = CacheHelper.GetRegion <object, object>(rname); int nonSingleHopCount = 0, metadatarefreshCount = 0; int nonSingleHopCount1 = 0, metadatarefreshCount1 = 0; Assert.IsNotNull(region, "DoPRSHPartitionResolverPuts: null region."); Util.Log("Inside DoPRSHFixedPartitionResolverTests region name is {0} ", region.Name.ToString()); for (int i = 0; i < 2000; i++) { try { int key = i; int val = key /*.GetHashCode()*/; region[key] = val; Util.Log("Put inside DoPRSHFixedPartitionResolverTests successfull {0} {1}", key, val); } catch (CacheServerException ex) { Util.Log("CacheServerException: Put caused networkhop"); Assert.Fail("Got CacheServerException (0}", ex.Message); } catch (CacheWriterException ex) { Util.Log("CacheWriterException: Put caused networkhop"); Assert.Fail("Got CacheWriterException (0}", ex.Message); } catch (Exception ex) { Util.Log("Exception: Put caused networkhop "); Util.Log("Got Exception (0} {1} {2} ", ex.Message, ex.StackTrace, ex.Source); Assert.Fail("Got Exception (0} {1} {2} ", ex.Message, ex.StackTrace, ex.Source); } } StatisticsFactory factory = StatisticsFactory.GetExistingInstance(); StatisticsType type = factory.FindType("RegionStatistics"); if (type != null) { Statistics rStats = factory.FindFirstStatisticsByType(type); if (rStats != null) { nonSingleHopCount = rStats.GetInt((string)"nonSingleHopCount"); metadatarefreshCount = rStats.GetInt((string)"metaDataRefreshCount"); } } Util.Log("DoPRSHFixedPartitionResolverTests Put Task completed nonSingleHopCount = {0} metadatarefreshCount = {1}.", nonSingleHopCount, metadatarefreshCount); Assert.Greater(nonSingleHopCount, 1, "nonSingleHopCount should be Greater than 1"); Assert.Greater(metadatarefreshCount, 1, "metadatarefreshCount should be Greater than 1"); for (int i = 0; i < 1000; i++) { try { int key = i; Object val = region[key]; Util.Log("Get inside DoPRSHFixedPartitionResolverTests successfull {0}", key); } catch (CacheServerException ex) { Util.Log("CPPTEST: Get caused networkhop"); Assert.Fail("Got CacheServerException (0}", ex.Message); } catch (CacheWriterException ex) { Util.Log("CPPTEST: Get caused networkhop"); Assert.Fail("Got CacheWriterException (0}", ex.Message); } catch (Exception ex) { Util.Log("CPPTEST: Get caused networkhop"); Assert.Fail("Got Exception (0}", ex.Message); } try { int key = i; region.Remove(key); //Destroy() -> Remove() Util.Log("Remove inside DoPRSHFixedPartitionResolverTests successfull {0}", key); } catch (CacheServerException ex) { Util.Log("CPPTEST: Put caused networkhop"); Assert.Fail("Got CacheServerException (0}", ex.Message); } catch (CacheWriterException ex) { Util.Log("CPPTEST: Put caused networkhop"); Assert.Fail("Got CacheWriterException (0}", ex.Message); } catch (Exception ex) { Util.Log("CPPTEST: Put caused networkhop"); Assert.Fail("Got Exception (0}", ex.Message); } } if (type != null) { Statistics rStats = factory.FindFirstStatisticsByType(type); if (rStats != null) { nonSingleHopCount1 = rStats.GetInt((string)"nonSingleHopCount"); metadatarefreshCount1 = rStats.GetInt((string)"metaDataRefreshCount"); } } Util.Log("DoPRSHFixedPartitionResolverTests All Task completed "); Util.Log("nonSingleHopCount = {0} metadatarefreshCount = {1} .", nonSingleHopCount, metadatarefreshCount); Util.Log("nonSingleHopCount1 = {0} metadatarefreshCount1 = {1} .", nonSingleHopCount1, metadatarefreshCount1); Assert.AreEqual(nonSingleHopCount, nonSingleHopCount1, "nonSingleHopCount should be equal to {0}", nonSingleHopCount); Assert.AreEqual(metadatarefreshCount, metadatarefreshCount1, "metadatarefreshCount should be equal to {0}", metadatarefreshCount); }
public void DoPRSHTradeResolverTasks(string rname) { Util.Log("DoPRSHTradeResolverTasks rname = {0} ", rname); IRegion <TradeKey, Object> region = CacheHelper.GetRegion <TradeKey, Object>(rname); int nonSingleHopCount = 0, metadatarefreshCount = 0; int nonSingleHopCount1 = 0, metadatarefreshCount1 = 0; Assert.IsNotNull(region, "DoPRSHTradeResolverTasks: null region."); for (int i = 0; i < 1000; i++) { try { region[new TradeKey(i)] = "Value" + i; Util.Log("Put inside DoPRSHTradeResolverTasks successfull "); } catch (CacheServerException ex) { Util.Log("CPPTEST: Put caused networkhop"); Assert.Fail("Got CacheServerException (0}", ex.Message); } catch (CacheWriterException ex) { Util.Log("CPPTEST: Put caused networkhop"); Assert.Fail("Got CacheWriterException (0}", ex.Message); } catch (Exception ex) { Util.Log("CPPTEST: Put caused networkhop"); Assert.Fail("Got Exception (0}", ex.Message); } } StatisticsFactory factory = StatisticsFactory.GetExistingInstance(); StatisticsType type = factory.FindType("RegionStatistics"); if (type != null) { Statistics rStats = factory.FindFirstStatisticsByType(type); if (rStats != null) { nonSingleHopCount = rStats.GetInt((string)"nonSingleHopCount"); metadatarefreshCount = rStats.GetInt((string)"metaDataRefreshCount"); } } Util.Log("nonSingleHopCount = {0} & metadatarefreshCount = {1} ", nonSingleHopCount, metadatarefreshCount); Assert.GreaterOrEqual(nonSingleHopCount, 1, "nonSingleHopCount should be GreaterOrEqual to 1"); Assert.GreaterOrEqual(metadatarefreshCount, 1, "metadatarefreshCount should be equal to 1"); Util.Log("DoPRSHTradeResolverTasks WarmUp Task completed."); for (int i = 1000; i < 2000; i++) { try { region[new TradeKey(i)] = "Value" + i; Util.Log("Put inside DoPRSHTradeResolverTasks successfull"); } catch (CacheServerException ex) { Util.Log("CPPTEST: Put caused networkhop"); Assert.Fail("Got CacheServerException (0}", ex.Message); } catch (CacheWriterException ex) { Util.Log("CPPTEST: Put caused networkhop"); Assert.Fail("Got CacheWriterException (0}", ex.Message); } catch (Exception ex) { Util.Log("CPPTEST: Put caused networkhop"); Assert.Fail("Got Exception (0}", ex.Message); } try { Object val = region[new TradeKey(i)]; Util.Log("Get inside DoPRSHTradeResolverTasks successfull "); } catch (CacheServerException ex) { Util.Log("CPPTEST: Get caused networkhop"); Assert.Fail("Got CacheServerException (0}", ex.Message); } catch (CacheWriterException ex) { Util.Log("CPPTEST: Get caused networkhop"); Assert.Fail("Got CacheWriterException (0}", ex.Message); } catch (Exception ex) { Util.Log("CPPTEST: Get caused networkhop"); Assert.Fail("Got Exception (0}", ex.Message); } try { region.Remove(new TradeKey(i)); //Destroy() replaced by Remove Util.Log("Destroy inside DoPRSHTradeResolverTasks successfull "); } catch (CacheServerException ex) { Util.Log("CPPTEST: Destroy caused networkhop"); Assert.Fail("Got CacheServerException (0}", ex.Message); } catch (CacheWriterException ex) { Util.Log("CPPTEST: Destroy caused networkhop"); Assert.Fail("Got CacheWriterException (0}", ex.Message); } catch (Exception ex) { Util.Log("CPPTEST: Destroy caused networkhop"); Assert.Fail("Got Exception (0}", ex.Message); } } if (type != null) { Statistics rStats = factory.FindFirstStatisticsByType(type); if (rStats != null) { nonSingleHopCount1 = rStats.GetInt((string)"nonSingleHopCount"); metadatarefreshCount1 = rStats.GetInt((string)"metaDataRefreshCount"); Util.Log("nonSingleHopCount1 = {0} & metadatarefreshCount1 = {1} ", nonSingleHopCount1, metadatarefreshCount1); //Assert.AreEqual(nonSingleHopCount1, nonSingleHopCount, "nonSingleHopCount1 should be equal to nonSingleHopCount"); Assert.AreEqual(metadatarefreshCount1, metadatarefreshCount, "metadatarefreshCount1 should be equal to metadatarefreshCount"); } } Util.Log("Executing onRegion FE with custom key and custom partitionResolver"); Apache.Geode.Client.Execution <object> exc = Client.FunctionService <object> .OnRegion <TradeKey, object>(region); Assert.IsTrue(exc != null, "onRegion Returned NULL"); TradeKey[] filter = new TradeKey[901]; int j = 0; for (int i = 100; i < 1001; i++) { filter[j] = new TradeKey(i); j++; } Util.Log("filter count= {0}.", filter.Length); Client.IResultCollector <object> rc = exc.WithFilter <TradeKey>(filter).Execute(FEOnRegionPrSHOP_OptimizeForWrite, 15); Util.Log("FEOnRegionPrSHOP_OptimizeForWrite executed"); ICollection <object> executeFunctionResult = rc.GetResult(); Util.Log("OnRegionPrSHOP for filter executeFunctionResult.Count = {0} ", executeFunctionResult.Count); Assert.AreEqual(3, executeFunctionResult.Count, "executeFunctionResult count check failed"); foreach (Boolean item in executeFunctionResult) { Util.Log("on region:FEOnRegionPrSHOP:= {0}.", item); Assert.AreEqual(true, item, "FEOnRegionPrSHOP item not true"); } Util.Log("FEOnRegionPrSHOP_OptimizeForWrite done"); rc = exc.WithFilter <TradeKey>(filter).Execute(FEOnRegionPrSHOP, 15); Util.Log("FEOnRegionPrSHOP executed"); executeFunctionResult = rc.GetResult(); Util.Log("OnRegionPrSHOP for filter executeFunctionResult.Count = {0} ", executeFunctionResult.Count); Assert.AreEqual(3, executeFunctionResult.Count, "executeFunctionResult count check failed"); foreach (Boolean item in executeFunctionResult) { Util.Log("on region:FEOnRegionPrSHOP:= {0}.", item); Assert.AreEqual(true, item, "FEOnRegionPrSHOP item not true"); } Util.Log("FEOnRegionPrSHOP done"); object args = true; rc = exc.WithFilter <TradeKey>(filter).Execute(getFuncName); executeFunctionResult = rc.GetResult(); Util.Log("ExecuteFunctionOnRegion for filter executeFunctionResult.Count = {0} ", executeFunctionResult.Count); List <object> resultList = new List <object>(); foreach (List <object> item in executeFunctionResult) { foreach (object item2 in item) { resultList.Add(item2); } } Util.Log("on region: result count= {0}.", resultList.Count); Assert.AreEqual(1802, resultList.Count, "result count check failed"); for (int i = 0; i < resultList.Count; i++) { Util.Log("on region:get:= {0}.", resultList[i]); } }
public void DoPRSHPartitionResolverPuts(string rname) { IRegion <object, object> region = CacheHelper.GetRegion <object, object>(rname); int nonSingleHopCount = 0, metadatarefreshCount = 0; int nonSingleHopCount1 = 0, metadatarefreshCount1 = 0; Assert.IsNotNull(region, "DoPRSHPartitionResolverPuts: null region."); if (rname.CompareTo("DistRegionNoAck") == 0) { Util.Log("Inside DoPRSHPartitionResolverPuts region name is {0} ", region.Name.ToString()); for (int i = 0; i < 1000; i++) { try { int key = i; int val = key.GetHashCode(); region[key] = val; Util.Log("Put inside DoPRSHPartitionResolverPuts successfull {0} {1}", key, val); } catch (CacheServerException ex) { Util.Log("CPPTEST: Put caused networkhop"); Assert.Fail("Got CacheServerException (0}", ex.Message); } catch (CacheWriterException ex) { Util.Log("CPPTEST: Put caused networkhop"); Assert.Fail("Got CacheWriterException (0}", ex.Message); } catch (Exception ex) { Util.Log("CPPTEST: Put caused networkhop"); Assert.Fail("Got Exception (0}", ex.Message); } } StatisticsFactory factory = StatisticsFactory.GetExistingInstance(); StatisticsType type = factory.FindType("RegionStatistics"); if (type != null) { Statistics rStats = factory.FindFirstStatisticsByType(type); if (rStats != null) { nonSingleHopCount = rStats.GetInt((string)"nonSingleHopCount"); metadatarefreshCount = rStats.GetInt((string)"metaDataRefreshCount"); } } //Assert.AreEqual(1, nonSingleHopCount, "nonSingleHopCount should be equal to 1"); //Assert.AreEqual(1, metadatarefreshCount, "metadatarefreshCount should be equal to 1"); Util.Log("DoPRSHPartitionResolverPuts WarmUp Task completed."); for (int i = 1000; i < 2000; i++) { try { //CacheableInt32 key = new CacheableInt32(i); int key = i; int val = key.GetHashCode(); region[key] = val; Util.Log("Put inside DoPRSHPartitionResolverPuts successfull {0} {1}", key, val); } catch (CacheServerException ex) { Util.Log("CPPTEST: Put caused networkhop"); Assert.Fail("Got CacheServerException (0}", ex.Message); } catch (CacheWriterException ex) { Util.Log("CPPTEST: Put caused networkhop"); Assert.Fail("Got CacheWriterException (0}", ex.Message); } catch (Exception ex) { Util.Log("CPPTEST: Put caused networkhop"); Assert.Fail("Got Exception (0}", ex.Message); } try { //CacheableInt32 key = new CacheableInt32(i); int key = i; Object val = region[key]; Util.Log("Get inside DoPRSHPartitionResolverPuts successfull {0}", key); } catch (CacheServerException ex) { Util.Log("CPPTEST: Get caused networkhop"); Assert.Fail("Got CacheServerException (0}", ex.Message); } catch (CacheWriterException ex) { Util.Log("CPPTEST: Get caused networkhop"); Assert.Fail("Got CacheWriterException (0}", ex.Message); } catch (Exception ex) { Util.Log("CPPTEST: Get caused networkhop"); Assert.Fail("Got Exception (0}", ex.Message); } try { //CacheableInt32 key = new CacheableInt32(i); int key = i; region.Remove(key); //Destroy() replaced by Remove Util.Log("Destroy inside DoPRSHPartitionResolverPuts successfull {0}", key); } catch (CacheServerException ex) { Util.Log("CPPTEST: Destroy caused networkhop"); Assert.Fail("Got CacheServerException (0}", ex.Message); } catch (CacheWriterException ex) { Util.Log("CPPTEST: Destroy caused networkhop"); Assert.Fail("Got CacheWriterException (0}", ex.Message); } catch (Exception ex) { Util.Log("CPPTEST: Destroy caused networkhop"); Assert.Fail("Got Exception (0}", ex.Message); } } if (type != null) { Statistics rStats = factory.FindFirstStatisticsByType(type); if (rStats != null) { nonSingleHopCount1 = rStats.GetInt((string)"nonSingleHopCount"); metadatarefreshCount1 = rStats.GetInt((string)"metaDataRefreshCount"); Assert.AreEqual(nonSingleHopCount1, nonSingleHopCount, "nonSingleHopCount1 should be equal to nonSingleHopCount"); Assert.AreEqual(metadatarefreshCount1, metadatarefreshCount, "metadatarefreshCount1 should be equal to metadatarefreshCount"); } } } nonSingleHopCount = metadatarefreshCount = 0; if (rname.CompareTo("DistRegionAck") == 0) { Util.Log("Inside DoPRSHPartitionResolverPuts region name is {0} ", region.Name.ToString()); for (int i = 0; i < 1000; i++) { try { int key = i; int val = key.GetHashCode(); region[key] = val; Util.Log("Put inside DoPRSHPartitionResolverPuts successfull {0} {1}", key, val); } catch (CacheServerException ex) { Util.Log("CPPTEST: Put caused networkhop"); Assert.Fail("Got CacheServerException (0}", ex.Message); } catch (CacheWriterException ex) { Util.Log("CPPTEST: Put caused networkhop"); Assert.Fail("Got CacheWriterException (0}", ex.Message); } catch (Exception ex) { Util.Log("CPPTEST: Put caused networkhop"); Assert.Fail("Got Exception (0}", ex.Message); } } StatisticsFactory factory = StatisticsFactory.GetExistingInstance(); StatisticsType type = factory.FindType("RegionStatistics"); if (type != null) { Statistics rStats = factory.FindFirstStatisticsByType(type); if (rStats != null) { nonSingleHopCount = rStats.GetInt((string)"nonSingleHopCount"); metadatarefreshCount = rStats.GetInt((string)"metaDataRefreshCount"); } } //Assert.AreEqual(1, nonSingleHopCount, "nonSingleHopCount should be equal to 1"); //Assert.AreEqual(1, metadatarefreshCount, "metadatarefreshCount should be equal to 1"); Util.Log("DoPRSHPartitionResolverPuts WarmUp Task completed."); Util.Log("Inside DoPRSHPartitionResolverPuts region name is {0} ", region.Name.ToString()); for (int i = 1000; i < 2000; i++) { try { //CacheableInt32 key = new CacheableInt32(i); int key = i; int val = key.GetHashCode(); region[key] = val; Util.Log("Put inside DoPRSHPartitionResolverPuts successfull {0} {1}", key, val); } catch (CacheServerException ex) { Util.Log("CPPTEST: Put caused networkhop"); Assert.Fail("Got CacheServerException (0}", ex.Message); } catch (CacheWriterException ex) { Util.Log("CPPTEST: Put caused networkhop"); Assert.Fail("Got CacheWriterException (0}", ex.Message); } catch (Exception ex) { Util.Log("CPPTEST: Put caused networkhop"); Assert.Fail("Got Exception (0}", ex.Message); } try { //CacheableInt32 key = new CacheableInt32(i); int key = i; Object val = region[key]; Util.Log("Get inside DoPRSHPartitionResolverPuts successfull {0}", key); } catch (CacheServerException ex) { Util.Log("CPPTEST: Get caused networkhop"); Assert.Fail("Got CacheServerException (0}", ex.Message); } catch (CacheWriterException ex) { Util.Log("CPPTEST: Get caused networkhop"); Assert.Fail("Got CacheWriterException (0}", ex.Message); } catch (Exception ex) { Util.Log("CPPTEST: Get caused networkhop"); Assert.Fail("Got Exception (0}", ex.Message); } try { //CacheableInt32 key = new CacheableInt32(i); int key = i; region.Remove(key); //Destroy() -> Remove() Util.Log("Destroy inside DoPRSHPartitionResolverPuts successfull {0}", key); } catch (CacheServerException ex) { Util.Log("CPPTEST: Put caused networkhop"); Assert.Fail("Got CacheServerException (0}", ex.Message); } catch (CacheWriterException ex) { Util.Log("CPPTEST: Put caused networkhop"); Assert.Fail("Got CacheWriterException (0}", ex.Message); } catch (Exception ex) { Util.Log("CPPTEST: Put caused networkhop"); Assert.Fail("Got Exception (0}", ex.Message); } } if (type != null) { Statistics rStats = factory.FindFirstStatisticsByType(type); if (rStats != null) { nonSingleHopCount1 = rStats.GetInt((string)"nonSingleHopCount"); metadatarefreshCount1 = rStats.GetInt((string)"metaDataRefreshCount"); Assert.AreEqual(nonSingleHopCount1, nonSingleHopCount, "nonSingleHopCount1 should be equal to nonSingleHopCount"); Assert.AreEqual(metadatarefreshCount1, metadatarefreshCount, "metadatarefreshCount1 should be equal to metadatarefreshCount"); } } } }