Exemple #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();
        }
Exemple #2
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);
        }