void VerifyCloning() { Thread.Sleep(1000); string cKey = m_keys[0]; IRegion <object, object> reg = CacheHelper.GetRegion <object, object>("DistRegionAck"); DeltaTestImpl val = reg[cKey] as DeltaTestImpl; if (val.GetIntVar() != 2) { Assert.Fail("Int value after cloning should be 2, is " + val.GetIntVar()); } if (DeltaTestImpl.GetFromDataCount() != 2) { Assert.Fail("After cloning, fromDataCount should have been 2, is " + DeltaTestImpl.GetFromDataCount()); } if (DeltaTestImpl.GetToDataCount() != 1) { Assert.Fail("After cloning, toDataCount should have been 1, is " + DeltaTestImpl.GetToDataCount()); } System.Threading.Thread.Sleep(5000); //Assert.Greater(javaobject.PdxDelta.GotDelta, 7, "this should have recieve delta"); javaobject.PdxDelta pd = (javaobject.PdxDelta)(reg.GetLocalView()["pdxdelta"]); Assert.Greater(pd.Delta, 7, "this should have recieve delta"); }
DeltaTestImpl getLatestDelta(TKey key, Int32 localcnt, bool isCreate) { DeltaTestImpl oldValue = (m_maps[localcnt])[key] as DeltaTestImpl; if (oldValue == null) { FwkTest <TKey, TVal> .CurrentTest.FwkInfo("oldDelta cannot be null"); } DeltaTestImpl obj = new DeltaTestImpl(oldValue.GetIntVar() + 1, "delta"); if (!isCreate) { obj.SetIntVar(oldValue.GetIntVar() + 1); } return(obj); }
public override void AfterCreate(EntryEvent <TKey, TVal> ev) { m_numAfterCreate++; TKey key = (TKey)ev.Key; DeltaTestImpl value = ev.NewValue as DeltaTestImpl; if (value == null) { FwkTest <TKey, TVal> .CurrentTest.FwkException(" Value in afterCreate cannot be null : key = {0} ", key.ToString()); return; } if (value.GetIntVar() != 0 && value.GetFromDeltaCounter() != 0) { ValidateIncreamentByOne(key, value); } Int32 mapValue = value.GetIntVar(); Int64 deltaValue = value.GetFromDeltaCounter(); m_latestValues[key] = mapValue; m_ValidateMap[key] = deltaValue; }
public override void AfterDestroy(EntryEvent <TKey, TVal> ev) { m_numAfterDestroy++; TKey key = ev.Key; DeltaTestImpl oldValue = ev.OldValue as DeltaTestImpl; if (oldValue != null) { Int32 mapValue = oldValue.GetIntVar(); m_latestValues.Remove(key); //m_ValidateMap.Remove(key); } }
public override void AfterUpdate(EntryEvent <TKey, TVal> ev) { m_numAfterUpdate++; TKey key = ev.Key; DeltaTestImpl oldValue = ev.OldValue as DeltaTestImpl; DeltaTestImpl newValue = ev.NewValue as DeltaTestImpl; if (newValue == null) { FwkTest <TKey, TVal> .CurrentTest.FwkException(" newValue in afterUpdate cannot be null : key = {0} ", key.ToString()); return; } if (oldValue == null) { ValidateIncreamentByOne(key, newValue); } else { Int32 mapValue1; m_latestValues.TryGetValue(key, out mapValue1); Int32 mapValue2 = mapValue1; // CacheableInt32 mapValue2 = m_latestValues[key] as CacheableInt32; Int32 diff = newValue.GetIntVar() - mapValue2; if (diff != 1) { FwkTest <TKey, TVal> .CurrentTest.FwkException("difference expected in newValue and oldValue is 1 , but it was not" + " for key {0} & newVal = {1} oldValue = {2} map count = {3} : {4}", key.ToString(), newValue.GetIntVar(), mapValue2, m_latestValues.Count, m_latestValues.ToString()); return; } } Int32 mapValue = newValue.GetIntVar(); Int64 deltaValue = newValue.GetFromDeltaCounter(); m_latestValues[key] = mapValue; m_ValidateMap[key] = deltaValue; }
public override void DoTask(int iters, object data) { FwkTest <TKey, TVal> .CurrentTest.FwkInfo("PutTask::DoTask:"); Int32 localcnt = m_cnt; Interlocked.Increment(ref m_cnt); int offset = Util.Rand(m_MaxKeys); int count = offset; while (Running && (iters-- != 0)) { int idx = count % m_MaxKeys; TKey key = default(TKey); try { key = (TKey)(object)("AAAAAA" + localcnt + idx.ToString("D10")); DeltaTestImpl oldVal = (m_maps[localcnt])[key] as DeltaTestImpl; if (oldVal == null) { Util.Log(Util.LogLevel.Error, "oldDelta Cannot be null"); } DeltaTestImpl obj = new DeltaTestImpl(oldVal); obj.SetIntVar(oldVal.GetIntVar() + 1); m_region[key] = (TVal)(object)obj; Interlocked.Increment(ref m_update); Util.BBSet("ToDeltaBB", key.ToString(), oldVal.GetToDeltaCounter()); bool removeKey = (m_maps[localcnt]).Remove(key); if (removeKey) { (m_maps[localcnt]).Add(key, (TVal)(object)obj); } } catch (Exception ex) { Util.Log(Util.LogLevel.Error, "Exception while putting key[{0}] for region {1} in iteration " + "{2}: {3}", key, m_region.Name, (count - offset), ex); throw; } count++; //if ((count % 1000) == 0) //{ // Util.Log("PutsTask::DoTask: Intermediate: Ran for 1000 iterations."); //} } //Util.Log("PutsTask::DoTask: Ran for {0} iterations.", count); Interlocked.Add(ref m_iters, count - offset); }
public void ValidateIncreamentByOne(TKey key, DeltaTestImpl newValue) { Int32 oldValue = m_latestValues[key]; if (oldValue == 0) { FwkTest <TKey, TVal> .CurrentTest.FwkException("oldValue in latestValues cannot be null: key = {0} & newVal = {1} ", key, newValue.ToString()); } Int32 diff = newValue.GetIntVar() - oldValue; if (diff != 1) { FwkTest <TKey, TVal> .CurrentTest.FwkException("defference expected in newValue and oldValue is 1 , but it was {0}" + " for key {1} & newVal = {2}", diff, key, newValue.ToString()); } }
public override void AfterInvalidate(EntryEvent <TKey, TVal> ev) { m_numAfterInvalidate++; TKey key = ev.Key; DeltaTestImpl oldValue = ev.OldValue as DeltaTestImpl; if (oldValue == null) { FwkTest <TKey, TVal> .CurrentTest.FwkException("oldValue cannot be null key = {0}", key.ToString()); return; } Int32 mapValue = oldValue.GetIntVar(); m_latestValues[key] = 0; }
public void OnEvent(CqEvent<TKey, TResult> aCqEvent) { byte[] deltaValue = aCqEvent.getDeltaValue(); DeltaTestImpl newValue = new DeltaTestImpl(); DataInput input = CacheHelper.DCache.CreateDataInput(deltaValue); newValue.FromDelta(input); if (newValue.GetIntVar() == 5) { m_deltaCount++; } DeltaTestImpl fullObject = (DeltaTestImpl)(object)aCqEvent.getNewValue(); if (fullObject.GetIntVar() == 5) { m_valueCount++; } }
public override void DoTask(int iters, object data) { Int32 localcnt = m_cnt; Interlocked.Increment(ref m_cnt); IDictionary <TKey, TVal> hmoc = new Dictionary <TKey, TVal>(); lock (m_maps) { m_maps.Add(hmoc); } int offset = Util.Rand(m_MaxKeys); int count = offset; TKey key = default(TKey); Util.Log("EntryTask::DoTask: starting {0} iterations.", iters); while (Running && (iters-- != 0)) { int idx = count % m_MaxKeys; key = (TKey)(object)("AAAAAA" + localcnt + idx.ToString("D10")); string opcode = FwkTest <TKey, TVal> .CurrentTest.GetStringValue("entryOps"); if (opcode == null) { opcode = "no-opcode"; } if (opcode == "put") { lock (CLASS_LOCK) { DeltaTestImpl newValue = null; if (m_region.ContainsKey(key)) { DeltaTestImpl oldValue = m_region[key] as DeltaTestImpl; if (oldValue == null) { newValue = getLatestDelta(key, localcnt, false); m_region[key] = (TVal)(object)newValue; } else { newValue = new DeltaTestImpl(oldValue); newValue.SetIntVar(oldValue.GetIntVar() + 1); m_region[key] = (TVal)(object)newValue; } Interlocked.Increment(ref m_update); //Util.BBSet("ToDeltaBB", key.ToString(), newValue.GetToDeltaCounter()); } else { newValue = getLatestDelta(key, localcnt, true); m_region.Add(key, (TVal)(object)newValue); Interlocked.Increment(ref m_create); } //(m_maps[localcnt]).Add(key, newValue); m_maps[localcnt][key] = (TVal)(object)newValue; } } else if (opcode == "destroy") { DeltaTestImpl oldValue = null; if (m_region.ContainsKey(key)) { if ((oldValue = m_region[key] as DeltaTestImpl) == null) { if (m_isDestroy) { m_region.Remove(key); (m_maps[localcnt]).Remove(key); } } else { m_maps[localcnt][key] = (TVal)(object)oldValue; m_region.Remove(key); //(m_maps[localcnt]).Remove(key); } Interlocked.Increment(ref m_destroy); } } else if (opcode == "invalidate") { DeltaTestImpl oldValue = null; if (m_region.ContainsKey(key)) { if ((oldValue = m_region[key] as DeltaTestImpl) != null) { m_maps[localcnt].Add(key, (TVal)(object)oldValue); m_region.Invalidate(key); Interlocked.Increment(ref m_invalidate); m_maps[localcnt].Add(key, default(TVal)); } } } } Interlocked.Add(ref m_iters, count - offset); }