Ejemplo n.º 1
0
        private ReplicationMessage GetTimeSeriesDataSinceEtag(long etag, out long lastEtagSent)
        {
            var message = new ReplicationMessage {
                ServerId = storage.ServerId, SendingServerName = storage.TimeSeriesUrl
            };

            using (var reader = storage.CreateReader())
            {
                message.Logs = reader.GetLogsSinceEtag(etag + 1).Take(1024).ToList();
                lastEtagSent = message.Logs.LastOrDefault()?.Etag ?? etag; // change this once changed this function do a reall paging
            }

            return(message);
        }
Ejemplo n.º 2
0
        private ReplicationMessage GetTimeSeriesDataSinceEtag(long etag, out long lastEtagSent)
        {
            var message = new ReplicationMessage {
                ServerId = storage.ServerId, SendingServerName = storage.TimeSeriesUrl
            };

            using (var reader = storage.CreateReader())
            {
                message.Logs = reader.GetLogsSinceEtag(etag + 1).Take(1024).ToList();
                throw new NotImplementedException();
                //lastEtagSent = message.LoMaxEtagIsTheLatset.Count > 0 ? message.Counters.Max(x => x.Etag) : etag; // change this once changed this function do a reall paging
            }

            return(message);
        }
Ejemplo n.º 3
0
        private bool TryPerformReplicationToServer(RavenConnectionStringOptions connectionStringOptions, string timeSeriesUrl, ReplicationMessage message, out string lastError)
        {
            try
            {
                var url = string.Format("{0}/replication", timeSeriesUrl);
                lastError = string.Empty;
                var request = httpRavenRequestFactory.Create(url, HttpMethods.Post, connectionStringOptions);
                request.Write(RavenJObject.FromObject(message));
                request.ExecuteRequest();

                return(true);
            }
            catch (WebException e)
            {
                lastError = HandleReplicationDistributionWebException(e, timeSeriesUrl);
                return(false);
            }
            catch (Exception e)
            {
                Log.ErrorException("Error occured replicating to: " + timeSeriesUrl, e);
                lastError = e.Message;
                return(false);
            }
        }
Ejemplo n.º 4
0
        private bool PerformReplicationToServer(RavenConnectionStringOptions connectionStringOptions, string timeSeriesUrl, ReplicationMessage message, out string lastError)
        {
            var destinationUrl = connectionStringOptions.Url;

            if (!TryPerformReplicationToServer(connectionStringOptions, timeSeriesUrl, message, out lastError))
            {
                if (IsFirstFailure(destinationUrl))
                {
                    return(TryPerformReplicationToServer(connectionStringOptions, timeSeriesUrl, message, out lastError));
                }
                return(false);
            }

            return(true);
        }