Ejemplo n.º 1
0
        public static ClusterTopologyResponse TryLoad(string topologyHash, JsonOperationContext context)
        {
            try
            {
                var path = GetPath(topologyHash);
                if (File.Exists(path) == false)
                {
                    return(null);
                }

                using (var stream = SafeFileStream.Create(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    using (var blittableJsonReaderObject = context.Read(stream, "raven-cluster-topology"))
                    {
                        return(JsonDeserializationClient.ClusterTopology(blittableJsonReaderObject));
                    }
            }
            catch (Exception e)
            {
                if (_logger.IsInfoEnabled)
                {
                    _logger.Info("Could not understand the persisted cluster topology", e);
                }
                return(null);
            }
        }
        public static async Task <ClusterTopologyResponse> TryLoadAsync(string topologyHash, DocumentConventions conventions, JsonOperationContext context)
        {
            try
            {
                if (conventions.DisableTopologyCache)
                {
                    return(null);
                }

                var path = GetPath(topologyHash, conventions);
                if (File.Exists(path) == false)
                {
                    return(null);
                }

                using (var stream = SafeFileStream.Create(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    using (var json = await context.ReadForMemoryAsync(stream, "raven-cluster-topology").ConfigureAwait(false))
                    {
                        return(JsonDeserializationClient.ClusterTopology(json));
                    }
            }
            catch (Exception e)
            {
                if (_logger.IsInfoEnabled)
                {
                    _logger.Info("Could not understand the persisted cluster topology", e);
                }
                return(null);
            }
        }
Ejemplo n.º 3
0
        public override void SetResponse(BlittableJsonReaderObject response, bool fromCache)
        {
            if (response == null)
            {
                return;
            }

            Result = JsonDeserializationClient.ClusterTopology(response);
        }
Ejemplo n.º 4
0
        public static Topology TryLoadTopologyFromLocalCache(string serverHash, JsonOperationContext context)
        {
            try
            {
                var path = GetTopologyPath(serverHash);
                if (File.Exists(path) == false)
                {
                    return(null);
                }

                using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                    using (var blittableJsonReaderObject = context.Read(stream, "raven-topology"))
                    {
                        return(JsonDeserializationClient.ClusterTopology(blittableJsonReaderObject));
                    }
                }
            }
            catch (Exception e)
            {
                Log.ErrorException("Could not understand the persisted replication information", e);
                return(null);
            }
        }
Ejemplo n.º 5
0
 public override void SetResponse(BlittableJsonReaderObject response)
 {
     Result = JsonDeserializationClient.ClusterTopology(response);
 }