示例#1
0
        public VarLenServer(string folderName, string address = "127.0.0.1", int port = 33278)
        {
            this.folderName = folderName;
            GetSettings(folderName, out var logSettings, out var checkpointSettings, out var indexSize);

            store = new FasterKV <SpanByte, SpanByte>(indexSize, logSettings, checkpointSettings);

            // Create session provider for VarLen
            provider = new SpanByteFasterKVProvider(store);

            server = new FasterServer(address, port);
            server.Register(WireFormat.DefaultVarLenKV, provider);
            server.Start();
        }
示例#2
0
        public FixedLenServer(string folderName, Func <Value, Value, Value> merger, string address = "127.0.0.1", int port = 33278)
        {
            this.folderName = folderName;
            GetSettings(folderName, out var logSettings, out var checkpointSettings, out var indexSize);

            // We use blittable structs Key and Value to construct a costomized server for fixed-length types
            store = new FasterKV <Key, Value>(indexSize, logSettings, checkpointSettings);

            // Create session provider for FixedLen
            var provider = new FasterKVProvider <Key, Value, Value, Value, FixedLenServerFunctions <Key, Value>, FixedLenSerializer <Key, Value, Value, Value> >(store, e => new FixedLenServerFunctions <Key, Value>(merger));

            server = new FasterServer(address, port);
            server.Register(WireFormat.DefaultFixedLenKV, provider);
            server.Start();
        }
示例#3
0
        static void FixedLenServer(string[] args)
        {
            Console.WriteLine("FASTER fixed-length (binary) KV server");

            ParserResult <Options> result = Parser.Default.ParseArguments <Options>(args);

            if (result.Tag == ParserResultType.NotParsed)
            {
                return;
            }
            var opts = result.MapResult(o => o, xs => new Options());

            opts.GetSettings(out var logSettings, out var checkpointSettings, out var indexSize);

            // We use blittable structs Key and Value to construct a customized server for fixed-length types
            var store = new FasterKV <Key, Value>(indexSize, logSettings, checkpointSettings);

            if (opts.Recover)
            {
                store.Recover();
            }

            // This fixed-length session provider can be used with compatible clients such as FixedLenClient and FASTER.benchmark
            // Uses FixedLenSerializer as our in-built serializer for blittable (fixed length) types
            var provider = new FasterKVProvider <Key, Value, Input, Output, Functions, FixedLenSerializer <Key, Value, Input, Output> >(store, e => new Functions());

            // Create server
            var server = new FasterServer(opts.Address, opts.Port);

            // Register session provider for WireFormat.DefaultFixedLenKV
            // You can register multiple session providers with the same server, with different wire protocol specifications
            server.Register(WireFormat.DefaultFixedLenKV, provider);

            // Start server
            server.Start();
            Console.WriteLine("Started server");

            Thread.Sleep(Timeout.Infinite);
        }
示例#4
0
        static void VarLenServer(string[] args)
        {
            Console.WriteLine("FASTER variable-length KV server");

            ParserResult <Options> result = Parser.Default.ParseArguments <Options>(args);

            if (result.Tag == ParserResultType.NotParsed)
            {
                return;
            }
            var opts = result.MapResult(o => o, xs => new Options());

            opts.GetSettings(out var logSettings, out var checkpointSettings, out var indexSize);

            // Create a new instance of the FasterKV, customized for variable-length blittable data (represented by SpanByte)
            // With SpanByte, keys and values are stored inline in the FASTER log as [ 4 byte length | payload ]
            var store = new FasterKV <SpanByte, SpanByte>(indexSize, logSettings, checkpointSettings);

            if (opts.Recover)
            {
                store.Recover();
            }

            // This variable-length session provider can be used with compatible clients such as VarLenClient
            var provider = new SpanByteFasterKVProvider(store);

            // Create server
            var server = new FasterServer(opts.Address, opts.Port);

            // Register provider as backend provider for WireFormat.DefaultFixedLenKV
            // You can register multiple providers with the same server, with different wire protocol specifications
            server.Register(WireFormat.DefaultVarLenKV, provider);

            // Start server
            server.Start();
            Console.WriteLine("Started server");

            Thread.Sleep(Timeout.Infinite);
        }