Skip to content

Commit

Permalink
GRRRRRRRRRR
Browse files Browse the repository at this point in the history
  • Loading branch information
cybertyche committed Jul 7, 2023
1 parent bb5cac9 commit 3263e1e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
18 changes: 9 additions & 9 deletions src/Orleans.Streaming/Common/PooledCache/PooledQueueCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Orleans.Providers.Streams.Common
/// The PooledQueueCache is a cache that is intended to serve as a message cache in an IQueueCache.
/// It is capable of storing large numbers of messages (gigs worth of messages) for extended periods
/// of time (minutes to indefinite), while incurring a minimal performance hit due to garbage collection.
/// This pooled cache allocates memory and never releases it. It keeps freed resources available in pools
/// This pooled cache allocates memory and never releases it. It keeps freed resources available in pools
/// that remain in application use through the life of the service. This means these objects go to gen2,
/// are compacted, and then stay there. This is relatively cheap, as the only cost they now incur is
/// the cost of checking to see if they should be freed in each collection cycle. Since this cache uses
Expand Down Expand Up @@ -82,8 +82,8 @@ public PooledQueueCache(
TimeSpan? cacheMonitorWriteInterval,
TimeSpan? purgeMetadataInterval = null)
{
this.cacheDataAdapter = cacheDataAdapter ?? throw new ArgumentNullException("cacheDataAdapter");
this.logger = logger ?? throw new ArgumentNullException("logger");
this.cacheDataAdapter = cacheDataAdapter ?? throw new ArgumentNullException(nameof(cacheDataAdapter));
this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
this.ItemCount = 0;
pool = new CachedMessagePool(cacheDataAdapter);
messageBlocks = new LinkedList<CachedMessageBlock>();
Expand All @@ -106,7 +106,7 @@ public PooledQueueCache(
public bool IsEmpty => messageBlocks.Count == 0 || (messageBlocks.Count == 1 && messageBlocks.First.Value.IsEmpty);

/// <summary>
/// Acquires a cursor to enumerate through the messages in the cache at the provided sequenceToken,
/// Acquires a cursor to enumerate through the messages in the cache at the provided sequenceToken,
/// filtered on the specified stream.
/// </summary>
/// <param name="streamId">stream identity</param>
Expand Down Expand Up @@ -188,7 +188,7 @@ private void SetCursor(Cursor cursor, StreamSequenceToken sequenceToken)

// If sequenceToken is too new to be in cache, unset token, and wait for more data.
CachedMessage newestMessage = newestBlock.Value.NewestMessage;
if (newestMessage.Compare(sequenceToken) < 0)
if (newestMessage.Compare(sequenceToken) < 0)
{
cursor.State = CursorStates.Unset;
cursor.SequenceToken = sequenceToken;
Expand Down Expand Up @@ -233,7 +233,7 @@ private void SetCursor(Cursor cursor, StreamSequenceToken sequenceToken)
// return cursor from start.
cursor.CurrentBlock = node;
cursor.Index = node.Value.GetIndexOfFirstMessageLessThanOrEqualTo(sequenceToken);
// if cursor has been idle, move to next message after message specified by sequenceToken
// if cursor has been idle, move to next message after message specified by sequenceToken
if(cursor.State == CursorStates.Idle)
{
// if there are more messages in this block, move to next message
Expand Down Expand Up @@ -269,13 +269,13 @@ public bool TryGetNextMessage(object cursorObj, out IBatchContainer message)

if (cursorObj == null)
{
throw new ArgumentNullException("cursorObj");
throw new ArgumentNullException(nameof(cursorObj));
}

var cursor = cursorObj as Cursor;
if (cursor == null)
{
throw new ArgumentOutOfRangeException("cursorObj", "Cursor is bad");
throw new ArgumentOutOfRangeException(nameof(cursorObj), "Cursor is bad");
}

if (cursor.State != CursorStates.Set)
Expand Down Expand Up @@ -337,7 +337,7 @@ public bool TryGetNextMessage(object cursorObj, out IBatchContainer message)
}

/// <summary>
/// Add a list of queue message to the cache
/// Add a list of queue message to the cache
/// </summary>
/// <param name="messages"></param>
/// <param name="dequeueTime"></param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ namespace Orleans.Streams
{
/// <summary>
/// LeaseBasedQueueBalancer. This balancer supports queue balancing in cluster auto-scale scenarios,
/// unexpected server failure scenarios, and tries to support ideal distribution as much as possible.
/// unexpected server failure scenarios, and tries to support ideal distribution as much as possible.
/// </summary>
public class LeaseBasedQueueBalancer : QueueBalancerBase, IStreamQueueBalancer
{
private class AcquiredQueue
private class AcquiredQueue
{
public int LeaseOrder { get; set; }
public QueueId QueueId { get; set; }
Expand Down Expand Up @@ -85,12 +85,12 @@ public override Task Initialize(IStreamQueueMapper queueMapper)
if (base.Cancellation.IsCancellationRequested) throw new InvalidOperationException("Cannot initialize a terminated balancer.");
if (queueMapper == null)
{
throw new ArgumentNullException("queueMapper");
throw new ArgumentNullException(nameof(queueMapper));
}
var allQueues = queueMapper.GetAllQueues().ToList();
this.allQueuesCount = allQueues.Count;

//Selector default to round robin selector now, but we can make a further change to make selector configurable if needed. Selector algorithm could
//Selector default to round robin selector now, but we can make a further change to make selector configurable if needed. Selector algorithm could
//be affecting queue balancing stablization time in cluster initializing and auto-scaling
this.queueSelector = new RoundRobinSelector<QueueId>(allQueues);
return base.Initialize(queueMapper);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ public static async Task<RelationalStorageForTesting> SetupInstance(string invar
{
if (string.IsNullOrWhiteSpace(invariantName))
{
throw new ArgumentException("The name of invariant must contain characters", "invariantName");
throw new ArgumentException("The name of invariant must contain characters", nameof(invariantName));
}

if (string.IsNullOrWhiteSpace(testDatabaseName))
{
throw new ArgumentException("database string must contain characters", "testDatabaseName");
throw new ArgumentException("database string must contain characters", nameof(testDatabaseName));
}

Console.WriteLine("Initializing relational databases...");
Expand Down
4 changes: 2 additions & 2 deletions test/Grains/TestGrains/AdoNet/CustomerGrain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public async Task Set(int customerId, string firstName, string lastName)
public async Task AddDevice(IDeviceGrain device)
{
if (device == null)
throw new ArgumentNullException("device");
throw new ArgumentNullException(nameof(device));

if (null == State.Devices)
State.Devices = new List<IDeviceGrain>();
Expand All @@ -51,7 +51,7 @@ public async Task AddDevice(IDeviceGrain device)
public async Task SetRandomState()
{
int customerId = (int)this.GetPrimaryKeyLong();

var dt = DateTime.UtcNow;
var now = new DateTime(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second, DateTimeKind.Utc);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public string WriteRow(IList<Tuple<string, string>> keys, IDictionary<string, ob
{
var error = string.Format("Wrong number of keys supplied -- Expected count = {0} Received = {1}", numKeyLayers, keys.Count);
Trace.TraceError(error);
throw new ArgumentOutOfRangeException("keys", keys.Count, error);
throw new ArgumentOutOfRangeException(nameof(keys), keys.Count, error);
}

lock (lockable)
Expand All @@ -51,7 +51,7 @@ public IDictionary<string, object> ReadRow(IList<Tuple<string, string>> keys)
{
var error = string.Format("Not enough keys supplied -- Expected count = {0} Received = {1}", numKeyLayers, keys.Count);
Trace.TraceError(error);
throw new ArgumentOutOfRangeException("keys", keys.Count, error);
throw new ArgumentOutOfRangeException(nameof(keys), keys.Count, error);
}

lock (lockable)
Expand All @@ -64,7 +64,7 @@ public IList<IDictionary<string, object>> ReadMultiRow(IList<Tuple<string, strin
{
if (keys.Count > numKeyLayers)
{
throw new ArgumentOutOfRangeException("keys", keys.Count,
throw new ArgumentOutOfRangeException(nameof(keys), keys.Count,
string.Format("Too many key supplied -- Expected count = {0} Received = {1}", numKeyLayers, keys.Count));
}

Expand All @@ -78,7 +78,7 @@ public bool DeleteRow(IList<Tuple<string, string>> keys, string eTag)
{
if (keys.Count > numKeyLayers)
{
throw new ArgumentOutOfRangeException("keys", keys.Count,
throw new ArgumentOutOfRangeException(nameof(keys), keys.Count,
string.Format("Not enough keys supplied -- Expected count = {0} Received = {1}", numKeyLayers, keys.Count));
}

Expand Down

0 comments on commit 3263e1e

Please sign in to comment.