public async Task <HttpResponseMessage> Post()
        {
            /*Read Current Counter Value for CounterStorageName - Need ReaderWriter Lock
             * If values are ABS larger
             *      Write delta
             * Store last ETag for servers we've successfully rpelicated to
             */
            ReplicationMessage replicationMessage;

            Storage.MetricsCounters.IncomingReplications.Mark();

            try
            {
                replicationMessage = await ReadJsonObjectAsync <ReplicationMessage>();
            }
            catch (Exception e)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, e.Message));
            }

            long lastEtag     = 0;
            bool wroteCounter = false;

            using (var writer = Storage.CreateWriter())
            {
                foreach (var counter in replicationMessage.Counters)
                {
                    lastEtag = Math.Max(counter.Etag, lastEtag);
                    var currentCounter = writer.GetCounter(counter.CounterName);
                    foreach (var serverValue in counter.ServerValues)
                    {
                        Counter.PerServerValue currentServerValue;
                        if (currentCounter != null)
                        {
                            currentServerValue = currentCounter.ServerValues
                                                 .FirstOrDefault(x => x.SourceId == writer.SourceIdFor(serverValue.ServerName)) ??
                                                 new Counter.PerServerValue
                            {
                                Negative = 0,
                                Positive = 0,
                            };

                            // old update, have updates after it already
                            if (serverValue.Positive <= currentServerValue.Positive &&
                                serverValue.Negative <= currentServerValue.Negative)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            currentServerValue = new Counter.PerServerValue
                            {
                                Negative = 0,
                                Positive = 0
                            };
                        }

                        wroteCounter = true;
                        writer.Store(serverValue.ServerName,
                                     counter.CounterName,
                                     Math.Max(serverValue.Positive, currentServerValue.Positive),
                                     Math.Max(serverValue.Negative, currentServerValue.Negative)
                                     );
                    }
                }

                var sendingServerName = replicationMessage.SendingServerName;
                if (wroteCounter || writer.GetLastEtagFor(sendingServerName) < lastEtag)
                {
                    writer.RecordLastEtagFor(sendingServerName, lastEtag);
                    writer.Commit();
                }

                return(new HttpResponseMessage(HttpStatusCode.OK));
            }
        }
        public async Task<HttpResponseMessage> Post()
        {
            /*Read Current Counter Value for CounterStorageName - Need ReaderWriter Lock
             *If values are ABS larger
             *      Write delta
             *Store last ETag for servers we've successfully rpelicated to
             */
            ReplicationMessage replicationMessage;
            Storage.MetricsCounters.IncomingReplications.Mark();

            try
            {
                replicationMessage = await ReadJsonObjectAsync<ReplicationMessage>();
            }
            catch (Exception e)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest, e.Message);
            }

            long lastEtag = 0;
            bool wroteCounter = false;
            using (var writer = Storage.CreateWriter())
            {
                foreach (var counter in replicationMessage.Counters)
                {
                    lastEtag = Math.Max(counter.Etag, lastEtag);
                    var currentCounter = writer.GetCounter(counter.CounterName);
                    foreach (var serverValue in counter.ServerValues)
                    {
                        Counter.PerServerValue currentServerValue;
                        if (currentCounter != null)
                        {
                            currentServerValue = currentCounter.ServerValues
                                .FirstOrDefault(x => x.SourceId == writer.SourceIdFor(serverValue.ServerName)) ??
                                                    new Counter.PerServerValue
                                                    {
                                                        Negative = 0,
                                                        Positive = 0,
                                                    };

                            // old update, have updates after it already
                            if (serverValue.Positive <= currentServerValue.Positive &&
                                serverValue.Negative <= currentServerValue.Negative)
                                continue;
                        }
                        else
                        {
                            currentServerValue = new Counter.PerServerValue
                            {
                                Negative = 0,
                                Positive = 0
                            };
                        }

                        wroteCounter = true;
                        writer.Store(serverValue.ServerName,
                            counter.CounterName,
                            Math.Max(serverValue.Positive, currentServerValue.Positive),
                            Math.Max(serverValue.Negative, currentServerValue.Negative)
                        );
                    }
                }

                var sendingServerName = replicationMessage.SendingServerName;
                if (wroteCounter || writer.GetLastEtagFor(sendingServerName) < lastEtag)
                {
                    writer.RecordLastEtagFor(sendingServerName, lastEtag);
                    writer.Commit(); 
                }

                return new HttpResponseMessage(HttpStatusCode.OK);
            }
        }