Permalink
Browse files

Code cleanup.

  • Loading branch information...
1 parent d61a616 commit 98b412ccbcb1c697de13c60fbaf85de80761b2b4 @enyim enyim committed Sep 16, 2010
Showing with 37 additions and 49 deletions.
  1. +3 −3 Northscale.Store/NorthScaleClient.cs
  2. +34 −46 Northscale.Store/VBucketAwareOperationFactory.cs
@@ -161,7 +161,7 @@ private bool ExecuteWithRedirect(IMemcachedNode startNode, ISingleItemOperation
{
if (startNode.Execute(op)) return true;
- var iows = (IOpWithState)op;
+ var iows = (IOperationWithState)op;
#if HAS_FORWARD_MAP
// node responded with invalid vbucket
@@ -183,7 +183,7 @@ private bool ExecuteWithRedirect(IMemcachedNode startNode, ISingleItemOperation
}
#endif
// still invalid vbucket, try all nodes in sequence
- if (iows.State == OpState.InvalidVBucket)
+ if (iows.State == OperationState.InvalidVBucket)
{
var nodes = this.Pool.GetWorkingNodes();
@@ -193,7 +193,7 @@ private bool ExecuteWithRedirect(IMemcachedNode startNode, ISingleItemOperation
return true;
// the node accepted our request so quit
- if (iows.State != OpState.InvalidVBucket)
+ if (iows.State != OperationState.InvalidVBucket)
break;
}
}
@@ -61,27 +61,15 @@ IFlushOperation IOperationFactory.Flush()
return new FlushOperation();
}
- [Serializable]
- public class InvalidVBucketException : Exception
- {
- public InvalidVBucketException() { }
- public InvalidVBucketException(string message) : base(message) { }
- public InvalidVBucketException(string message, Exception inner) : base(message, inner) { }
- protected InvalidVBucketException(
- System.Runtime.Serialization.SerializationInfo info,
- System.Runtime.Serialization.StreamingContext context)
- : base(info, context) { }
- }
-
#region [ Custom operations ]
private const string NotMyVBucket = "I'm not responsible for this vbucket";
- private class VBStore : StoreOperation, IOpWithState
+ private class VBStore : StoreOperation, IOperationWithState
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(VBStore).FullName.Replace('+', '.'));
private VBucketNodeLocator locator;
- private OpState state;
+ private OperationState state;
public VBStore(VBucketNodeLocator locator, StoreMode mode, string key, CacheItem value, uint expires)
: base(mode, key, value, expires)
@@ -102,32 +90,32 @@ protected override BinaryRequest Build()
protected override bool ReadResponse(PooledSocket socket)
{
var r = base.ReadResponse(socket);
- this.state = r ? OpState.Success : OpState.Failure;
+ this.state = r ? OperationState.Success : OperationState.Failure;
if (!r)
{
if (this.CurrentResponse.GetResponseMessage() == NotMyVBucket)
- this.state = OpState.InvalidVBucket;
+ this.state = OperationState.InvalidVBucket;
}
return r;
}
- #region IOpWithState Members
+ #region [ IOperationWithState ]
- OpState IOpWithState.State
+ OperationState IOperationWithState.State
{
get { return this.state; }
}
#endregion
}
- private class VBDelete : DeleteOperation, IOpWithState
+ private class VBDelete : DeleteOperation, IOperationWithState
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(VBDelete).FullName.Replace('+', '.'));
private VBucketNodeLocator locator;
- private OpState state;
+ private OperationState state;
public VBDelete(VBucketNodeLocator locator, string key)
: base(key)
@@ -148,32 +136,32 @@ protected override BinaryRequest Build()
protected override bool ReadResponse(PooledSocket socket)
{
var r = base.ReadResponse(socket);
- this.state = r ? OpState.Success : OpState.Failure;
+ this.state = r ? OperationState.Success : OperationState.Failure;
if (!r)
{
if (this.CurrentResponse.GetResponseMessage() == NotMyVBucket)
- this.state = OpState.InvalidVBucket;
+ this.state = OperationState.InvalidVBucket;
}
return r;
}
- #region IOpWithState Members
+ #region [ IOperationWithState ]
- OpState IOpWithState.State
+ OperationState IOperationWithState.State
{
get { return this.state; }
}
#endregion
}
- private class VBMutator : MutatorOperation, IOpWithState
+ private class VBMutator : MutatorOperation, IOperationWithState
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(VBMutator).FullName.Replace('+', '.'));
private VBucketNodeLocator locator;
- private OpState state;
+ private OperationState state;
public VBMutator(VBucketNodeLocator locator, MutationMode mode, string key, ulong defaultValue, ulong delta, uint expires)
: base(mode, key, defaultValue, delta, expires)
@@ -194,20 +182,20 @@ protected override BinaryRequest Build()
protected override bool ReadResponse(PooledSocket socket)
{
var r = base.ReadResponse(socket);
- this.state = r ? OpState.Success : OpState.Failure;
+ this.state = r ? OperationState.Success : OperationState.Failure;
if (!r)
{
if (this.CurrentResponse.GetResponseMessage() == NotMyVBucket)
- this.state = OpState.InvalidVBucket;
+ this.state = OperationState.InvalidVBucket;
}
return r;
}
- #region IOpWithState Members
+ #region [ IOperationWithState ]
- OpState IOpWithState.State
+ OperationState IOperationWithState.State
{
get { return this.state; }
}
@@ -237,11 +225,11 @@ protected override BinaryRequest Build(string key)
}
}
- private class VBConcat : ConcatOperation, IOpWithState
+ private class VBConcat : ConcatOperation, IOperationWithState
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(VBConcat).FullName.Replace('+', '.'));
private VBucketNodeLocator locator;
- private OpState state;
+ private OperationState state;
public VBConcat(VBucketNodeLocator locator, ConcatenationMode mode, string key, ArraySegment<byte> data)
: base(mode, key, data)
@@ -262,38 +250,38 @@ protected override BinaryRequest Build()
protected override bool ReadResponse(PooledSocket socket)
{
var r = base.ReadResponse(socket);
- this.state = r ? OpState.Success : OpState.Failure;
+ this.state = r ? OperationState.Success : OperationState.Failure;
if (!r)
{
if (this.CurrentResponse.GetResponseMessage() == NotMyVBucket)
- this.state = OpState.InvalidVBucket;
+ this.state = OperationState.InvalidVBucket;
}
return r;
}
- #region IOpWithState Members
+ #region [ IOperationWithState ]
- OpState IOpWithState.State
+ OperationState IOperationWithState.State
{
get { return this.state; }
}
#endregion
}
- private class VBGet : GetOperation, IOpWithState
+ private class VBGet : GetOperation, IOperationWithState
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(VBGet).FullName.Replace('+', '.'));
private VBucketNodeLocator locator;
- private OpState state;
+ private OperationState state;
public VBGet(VBucketNodeLocator locator, string key)
: base(key)
{
this.locator = locator;
- this.state = OpState.Unspecified;
+ this.state = OperationState.Unspecified;
}
protected override BinaryRequest Build()
@@ -309,20 +297,20 @@ protected override BinaryRequest Build()
protected override bool ReadResponse(PooledSocket socket)
{
var r = base.ReadResponse(socket);
- this.state = r ? OpState.Success : OpState.Failure;
+ this.state = r ? OperationState.Success : OperationState.Failure;
if (!r)
{
if (this.CurrentResponse.GetResponseMessage() == NotMyVBucket)
- this.state = OpState.InvalidVBucket;
+ this.state = OperationState.InvalidVBucket;
}
return r;
}
- #region IOpWithState Members
+ #region [ IOperationWithState ]
- OpState IOpWithState.State
+ OperationState IOperationWithState.State
{
get { return this.state; }
}
@@ -333,12 +321,12 @@ OpState IOpWithState.State
#endregion
}
- interface IOpWithState
+ internal interface IOperationWithState
{
- OpState State { get; }
+ OperationState State { get; }
}
- enum OpState { Unspecified, Success, Failure, InvalidVBucket }
+ internal enum OperationState { Unspecified, Success, Failure, InvalidVBucket }
}
#region [ License information ]

0 comments on commit 98b412c

Please sign in to comment.