public override void DoTask(int iters, object data) { if (m_keys != null && m_keys.Length > 0) { int numKeys = m_keys.Length; int offset = Util.Rand(numKeys); int count = offset; int idx; PaceMeter pm = new PaceMeter(m_opsSec); while (Running && (iters-- != 0)) { idx = count % numKeys; try { m_region[m_keys[idx]] = m_values[idx]; } catch (Exception ex) { Util.Log(Util.LogLevel.Error, "Exception while putting key[{0}] for region {1} in iteration " + "{2}: {3}", idx, m_region.Name, (count - offset), ex); throw; } count++; pm.CheckPace(); } Interlocked.Add(ref m_iters, count - offset); } }
public override void DoTask(int iters, object data) { if (m_keys != null && m_keys.Length > 0) { TKey key = m_keys[0]; TVal buffer = m_values[0]; //TVal[] buffer = value; int count = 0; PaceMeter pm = new PaceMeter(m_opsSec); while (Running && (iters-- != 0)) { /* * if (buffer.Length >= (int)(sizeof(int) + sizeof(long))) * { * BitConverter.GetBytes(LatMark).CopyTo(buffer, 0); * BitConverter.GetBytes(DateTime.Now.Ticks).CopyTo(buffer, (int)(sizeof(int))); * } */ try { m_region[key] = buffer; } catch (Exception ex) { Util.Log(Util.LogLevel.Error, "Exception while putting key[{0}] for region {1} in iteration " + "{2}: {3}", 0, m_region.Name, count, ex); throw; } count++; pm.CheckPace(); } Interlocked.Add(ref m_iters, count); } }
public override void DoTask(int iters, object data) { if (m_keys != null && m_keys.Length > 0) { Int32 localcnt = m_cnt; Interlocked.Increment(ref m_cnt); int numKeys = m_keys.Length; int offset = Util.Rand(numKeys); int count = offset; long startTime; int idx; PaceMeter pm = new PaceMeter(m_opsSec); while (Running && (iters-- != 0)) { idx = count % numKeys; try { TVal obj = ObjectHelper <TKey, TVal> .CreateObject(m_objectType, m_size, m_encodeKey, m_encodeTimestamp, 0, 0, 0); startTime = InitPerfStat.perfstat[localcnt].StartPut(); m_region[m_keys[idx]] = obj;//.Put(m_keys[idx], obj); InitPerfStat.perfstat[localcnt].EndPut(startTime, m_isMainWorkLoad); pm.CheckPace(); } catch (Exception ex) { Util.Log(Util.LogLevel.Error, "Exception while putting key[{0}] for region {1} in iteration " + "{2}: {3}", idx, m_region.Name, (count - offset), ex); throw; } count++; } Interlocked.Add(ref m_iters, count - offset); } }
public void DoEntryOperationsMU() { FwkInfo("DoEntryOperations called."); int opsSec = GetUIntValue(OpsSecond); opsSec = (opsSec < 1) ? 0 : opsSec; int entryCount = GetUIntValue(EntryCount); entryCount = (entryCount < 1) ? 10000 : entryCount; int secondsToRun = GetTimeValue(WorkTime); secondsToRun = (secondsToRun < 1) ? 30 : secondsToRun; int valSize = GetUIntValue(ValueSizes); valSize = ((valSize < 0) ? 32 : valSize); DateTime now = DateTime.Now; DateTime end = now + TimeSpan.FromSeconds(secondsToRun); byte[] valBuf = Encoding.ASCII.GetBytes(new string('A', valSize)); string opcode = null; int creates = 0, puts = 0, gets = 0, dests = 0, invals = 0, queries = 0; Region region = GetRegion(); if (region == null) { FwkSevere("Security.DoEntryOperations: No region to perform operations on."); now = end; // Do not do the loop } FwkInfo("DoEntryOperations will work for {0} secs using {1} byte values.", secondsToRun, valSize); CacheableKey key; IGFSerializable value; IGFSerializable tmpValue; PaceMeter meter = new PaceMeter(opsSec); string objectType = GetStringValue(ObjectType); while (now < end) { try { opcode = GetStringValue(EntryOps); if (opcode == null || opcode.Length == 0) { opcode = "no-op"; } if (opcode == "add") { key = GetKey(entryCount); if (objectType != null && objectType.Length > 0) { tmpValue = GetUserObject(objectType); } else { tmpValue = CacheableBytes.Create(valBuf); } region.Create(key, tmpValue); creates++; } else { key = GetKey(entryCount); if (opcode == "update") { if (objectType != null && objectType.Length > 0) { tmpValue = GetUserObject(objectType); } else { int keyVal = int.Parse(key.ToString()); int val = BitConverter.ToInt32(valBuf, 0); val = (val == keyVal) ? keyVal + 1 : keyVal; // alternate the value so that it can be validated later. BitConverter.GetBytes(val).CopyTo(valBuf, 0); BitConverter.GetBytes(DateTime.Now.Ticks).CopyTo(valBuf, 4); tmpValue = CacheableBytes.Create(valBuf); } region.Put(key, tmpValue); puts++; } else if (opcode == "invalidate") { region.Invalidate(key); invals++; } else if (opcode == "destroy") { region.Destroy(key); dests++; } else if (opcode == "read") { value = region.Get(key); gets++; } else if (opcode == "read+localdestroy") { value = region.Get(key); gets++; region.LocalDestroy(key); dests++; } else if (opcode == "query") { RunQuery(ref queries); } else { FwkSevere("Invalid operation specified: {0}", opcode); } } } catch (TimeoutException ex) { FwkSevere("Security: Caught unexpected timeout exception during entry " + "{0} operation; continuing with the test: {1}", opcode, ex); } catch (EntryExistsException) { } catch (EntryNotFoundException) { } catch (EntryDestroyedException) { } catch (Exception ex) { end = DateTime.Now; FwkException("Security: Caught unexpected exception during entry " + "{0} operation; exiting task: {1}", opcode, ex); } meter.CheckPace(); now = DateTime.Now; } FwkInfo("DoEntryOperations did {0} creates, {1} puts, {2} gets, " + "{3} invalidates, {4} destroys, {5} queries.", creates, puts, gets, invals, dests, queries); }