private void CheckSerialization(object obj) { var blob = serializer.ToBinary(obj); var reference = serializer.FromBinary(blob, serializer.Manifest(obj)); reference.Should().Be(obj); }
public LmdbDurableStore(Config config) { _config = config.GetConfig("lmdb"); if (_config.IsNullOrEmpty()) { throw ConfigurationException.NullOrEmptyConfig <LmdbDurableStore>("akka.cluster.distributed-data.durable.lmdb"); } _log = Context.GetLogger(); _serialization = Context.System.Serialization; _serializer = (SerializerWithStringManifest)_serialization.FindSerializerForType(typeof(DurableDataEnvelope)); _manifest = _serializer.Manifest(new DurableDataEnvelope(GCounter.Empty)); var useWriteBehind = _config.GetString("write-behind-interval", "").ToLowerInvariant(); _writeBehindInterval = useWriteBehind == "off" || useWriteBehind == "false" || useWriteBehind == "no" ? TimeSpan.Zero : _config.GetTimeSpan("write-behind-interval"); _mapSize = _config.GetByteSize("map-size") ?? 100 * 1024 * 1024; var path = _config.GetString("dir"); _dir = path.EndsWith(DatabaseName) ? Path.GetFullPath($"{path}-{Context.System.Name}-{Self.Path.Parent.Name}-{Cluster.Cluster.Get(Context.System).SelfAddress.Port}") : Path.GetFullPath(path); if (!Directory.Exists(_dir)) { Directory.CreateDirectory(_dir); } _log.Info($"Using durable data in LMDB directory [{_dir}]"); Init(); }