示例#1
0
        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);
        }
示例#2
0
    void DoNotificationWithDefaultCloning()
    {
      string cKey = m_keys[0];
      DeltaTestImpl val = new DeltaTestImpl();
      IRegion<object, object> reg = CacheHelper.GetRegion<object, object>("DistRegionAck");
      reg[cKey] = val;
      val.SetIntVar(2);
      val.SetDelta(true);
      reg[cKey] = val;

      javaobject.PdxDelta pd = new javaobject.PdxDelta(1001);
      for (int i = 0; i < 10; i++)
      {
        reg["pdxdelta"] = pd;
      }
    }
示例#3
0
        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);
        }