Skip to content

Commit

Permalink
Make provider extensible. (#575)
Browse files Browse the repository at this point in the history
  • Loading branch information
badrishc authored Oct 15, 2021
1 parent 59b316e commit b9f4fbe
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 11 deletions.
1 change: 1 addition & 0 deletions cs/remote/samples/FixedLenClient/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Program
{
static void Main(string[] args)
{
Environment.SetEnvironmentVariable("DOTNET_SYSTEM_NET_SOCKETS_INLINE_COMPLETIONS", "1");
string ip = "127.0.0.1";
int port = 3278;

Expand Down
1 change: 1 addition & 0 deletions cs/remote/samples/FixedLenServer/FixedLenServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Platforms>AnyCPU;x64</Platforms>
<LangVersion>latest</LangVersion>
<ServerGarbageCollection>true</ServerGarbageCollection>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
Expand Down
1 change: 1 addition & 0 deletions cs/remote/samples/FixedLenServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Program
{
static void Main(string[] args)
{
Environment.SetEnvironmentVariable("DOTNET_SYSTEM_NET_SOCKETS_INLINE_COMPLETIONS", "1");
Trace.Listeners.Add(new ConsoleTraceListener());

Console.WriteLine("FASTER fixed-length (binary) KV server");
Expand Down
1 change: 1 addition & 0 deletions cs/remote/samples/VarLenClient/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Program
{
static void Main(string[] args)
{
Environment.SetEnvironmentVariable("DOTNET_SYSTEM_NET_SOCKETS_INLINE_COMPLETIONS", "1");
string ip = "127.0.0.1";
int port = 3278;

Expand Down
39 changes: 29 additions & 10 deletions cs/remote/src/FASTER.server/Providers/SpanByteFasterKVProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,45 @@ namespace FASTER.server
/// Session provider for FasterKV store based on
/// [K, V, I, O, C] = [SpanByte, SpanByte, SpanByte, SpanByteAndMemory, long]
/// </summary>
public sealed class SpanByteFasterKVProvider : ISessionProvider
public class SpanByteFasterKVProvider : ISessionProvider
{
readonly FasterKV<SpanByte, SpanByte> store;
readonly SpanByteServerSerializer serializer;
readonly SubscribeKVBroker<SpanByte, SpanByte, SpanByte, IKeyInputSerializer<SpanByte, SpanByte>> kvBroker;
readonly SubscribeBroker<SpanByte, SpanByte, IKeySerializer<SpanByte>> broker;
readonly MaxSizeSettings maxSizeSettings;
/// <summary>
/// Store
/// </summary>
protected readonly FasterKV<SpanByte, SpanByte> store;

/// <summary>
/// Serializer
/// </summary>
protected readonly SpanByteServerSerializer serializer;

/// <summary>
/// KV broker
/// </summary>
protected readonly SubscribeKVBroker<SpanByte, SpanByte, SpanByte, IKeyInputSerializer<SpanByte, SpanByte>> kvBroker;

/// <summary>
/// Broker
/// </summary>
protected readonly SubscribeBroker<SpanByte, SpanByte, IKeySerializer<SpanByte>> broker;

/// <summary>
/// Size settings
/// </summary>
protected readonly MaxSizeSettings maxSizeSettings;

/// <summary>
/// Create SpanByte FasterKV backend
/// </summary>
/// <param name="store"></param>
/// <param name="kvBroker"></param>
/// <param name="broker"></param>
/// <param name="serverOptions"></param>
/// <param name="recoverStore"></param>
/// <param name="maxSizeSettings"></param>
public SpanByteFasterKVProvider(FasterKV<SpanByte, SpanByte> store, SubscribeKVBroker<SpanByte, SpanByte, SpanByte, IKeyInputSerializer<SpanByte, SpanByte>> kvBroker = null, SubscribeBroker<SpanByte, SpanByte, IKeySerializer<SpanByte>> broker = null, ServerOptions serverOptions = null, MaxSizeSettings maxSizeSettings = default)
public SpanByteFasterKVProvider(FasterKV<SpanByte, SpanByte> store, SubscribeKVBroker<SpanByte, SpanByte, SpanByte, IKeyInputSerializer<SpanByte, SpanByte>> kvBroker = null, SubscribeBroker<SpanByte, SpanByte, IKeySerializer<SpanByte>> broker = null, bool recoverStore = false, MaxSizeSettings maxSizeSettings = default)
{
this.store = store;
if ((serverOptions ?? new ServerOptions()).Recover)
if (recoverStore)
{
try
{
Expand All @@ -43,7 +62,7 @@ public SpanByteFasterKVProvider(FasterKV<SpanByte, SpanByte> store, SubscribeKVB
}

/// <inheritdoc />
public IServerSession GetSession(WireFormat wireFormat, Socket socket)
public virtual IServerSession GetSession(WireFormat wireFormat, Socket socket)
{
switch (wireFormat)
{
Expand Down
2 changes: 1 addition & 1 deletion cs/remote/src/FASTER.server/Servers/VarLenServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public VarLenServer(ServerOptions opts)
}

// Create session provider for VarLen
provider = new SpanByteFasterKVProvider(store, kvBroker, broker, opts);
provider = new SpanByteFasterKVProvider(store, kvBroker, broker, opts.Recover);

server = new FasterServer(opts.Address, opts.Port);
server.Register(WireFormat.DefaultVarLenKV, provider);
Expand Down

0 comments on commit b9f4fbe

Please sign in to comment.