Ejemplo n.º 1
0
        public virtual void Publish(IRevision revision)
        {
            lock (padlock)
            {
                EnsureOpen();

                if (currentRevision != null)
                {
                    int compare = revision.CompareTo(currentRevision.Revision);
                    if (compare == 0)
                    {
                        // same revision published again, ignore but release it
                        revision.Release();
                        return;
                    }

                    if (compare < 0)
                    {
                        revision.Release();
                        throw new ArgumentException(string.Format("Cannot publish an older revision: rev={0} current={1}", revision, currentRevision), "revision");
                    }
                }

                RefCountedRevision oldRevision = currentRevision;
                currentRevision = new RefCountedRevision(revision);
                if (oldRevision != null)
                {
                    oldRevision.DecRef();
                }

                CheckExpiredSessions();
            }
        }
Ejemplo n.º 2
0
        public void TestUpdateToLatest()
        {
            replicator.Publish(CreateRevision(1));
            IRevision rev = CreateRevision(2);

            replicator.Publish(rev);
            SessionToken res = replicator.CheckForUpdate(null);

            assertNotNull(res);
            assertEquals(0, rev.CompareTo(res.Version));
        }