コード例 #1
0
 public T Read <T>(JsonOperationContext context)
     where T : class
 {
     try
     {
         using (_disposerLock.EnsureNotDisposed())
             using (
                 var json = context.ParseToMemory(_stream, "rachis-item",
                                                  BlittableJsonDocumentBuilder.UsageMode.None, _buffer))
             {
                 json.BlittableValidation();
                 ValidateMessage(typeof(T).Name, json);
                 return(JsonDeserializationRachis <T> .Deserialize(json));
             }
     }
     catch (IOException e)
     {
         if (_log.IsInfoEnabled)
         {
             _log.Info(
                 $"Failed to read from connection. If this error happens during state change of a node, it is expected. (source : [{_src}] -> destination : [{_destTag}])",
                 e);
         }
         throw new IOException("Failed to read " + typeof(T).Name, e);
     }
 }
コード例 #2
0
        public RachisEntry ReadRachisEntry(JsonOperationContext context)
        {
            // we explicitly not disposing this here, because we need to access the entry
            var json = context.ParseToMemory(_stream, "rachis-entry",
                                             BlittableJsonDocumentBuilder.UsageMode.None, _buffer);

            json.BlittableValidation();
            ValidateMessage(nameof(RachisEntry), json);
            return(JsonDeserializationRachis <RachisEntry> .Deserialize(json));
        }
コード例 #3
0
        public InstallSnapshot ReadInstallSnapshot(JsonOperationContext context)
        {
            // we explicitly not disposing this here, because we need to access the topology
            var json = context.ParseToMemory(_stream, "rachis-snapshot",
                                             BlittableJsonDocumentBuilder.UsageMode.None, _buffer);

            json.BlittableValidation();
            ValidateMessage(nameof(InstallSnapshot), json);
            return(JsonDeserializationRachis <InstallSnapshot> .Deserialize(json));
        }
コード例 #4
0
 public T Read <T>(JsonOperationContext context)
     where T : class
 {
     using (_disposerLock.EnsureNotDisposed())
         using (
             var json = context.ParseToMemory(_stream, "rachis-item",
                                              BlittableJsonDocumentBuilder.UsageMode.None, _buffer))
         {
             json.BlittableValidation();
             ValidateMessage(typeof(T).Name, json);
             return(JsonDeserializationRachis <T> .Deserialize(json));
         }
 }
コード例 #5
0
        public RachisHello InitFollower(JsonOperationContext context)
        {
            using (
                var json = context.ParseToMemory(_stream, "rachis-initial-msg",
                                                 BlittableJsonDocumentBuilder.UsageMode.None, _buffer))
            {
                json.BlittableValidation();
                ValidateMessage(nameof(RachisHello), json);
                var rachisHello = JsonDeserializationRachis <RachisHello> .Deserialize(json);

                _src     = rachisHello.DebugSourceIdentifier ?? "unknown";
                _destTag = rachisHello.DebugDestinationIdentifier ?? _destTag;
                _log     = LoggingSource.Instance.GetLogger <RemoteConnection>($"{_src} > {_destTag}");
                return(rachisHello);
            }
        }
コード例 #6
0
        public RachisEntry ReadRachisEntry(JsonOperationContext context)
        {
            // we explicitly not disposing this here, because we need to access the entry
            BlittableJsonReaderObject json = null;

            try
            {
                using (_disposerLock.EnsureNotDisposed())
                {
                    json = context.ParseToMemory(_stream, "rachis-entry",
                                                 BlittableJsonDocumentBuilder.UsageMode.None, _buffer);
                    json.BlittableValidation();
                    ValidateMessage(nameof(RachisEntry), json);
                    return(JsonDeserializationRachis <RachisEntry> .Deserialize(json));
                }
            }
            catch
            {
                json?.Dispose();
                throw;
            }
        }