private int ReplicateBidirectional(ITestableReplicationProviderInside providerA,
                                           ITestableReplicationProviderInside providerB, Type clazz)
        {
            int replicatedObjects = 0;
            IReplicationSession replicationSession = Replication.Begin(providerA, providerB,
                                                                       null, _fixtures.reflector);
            IObjectSet changedInA = clazz == null?providerA.ObjectsChangedSinceLastReplication
                                        () : providerA.ObjectsChangedSinceLastReplication(clazz);

            foreach (object obj in changedInA)
            {
                replicatedObjects++;
                replicationSession.Replicate(obj);
            }
            IObjectSet changedInB = clazz == null?providerB.ObjectsChangedSinceLastReplication
                                        () : providerB.ObjectsChangedSinceLastReplication(clazz);

            foreach (object obj in changedInB)
            {
                replicatedObjects++;
                replicationSession.Replicate(obj);
            }
            replicationSession.Commit();
            return(replicatedObjects);
        }
Example #2
0
        public virtual void Test()
        {
            ITestableReplicationProviderInside providerA = A().Provider();
            ITestableReplicationProviderInside providerB = B().Provider();

            providerA.StoreNew(new Pilot());
            providerA.Commit();
            IReplicationSession replication = Replication.Begin(providerA, providerB, null, _fixtures
                                                                .reflector);
            TimeStamps initialTimeStampsB = AssertTimeStampsForFirstReplication(providerB);
            IObjectSet modifiedObjects    = providerA.ObjectsChangedSinceLastReplication();

            while (modifiedObjects.HasNext())
            {
                replication.Replicate(modifiedObjects.Next());
            }
            replication.Commit();
            Pilot replicatedPilot = (Pilot)providerB.GetStoredObjects(typeof(Pilot)).Next();
            long  version         = providerB.ObjectVersion(replicatedPilot);

            Assert.AreEqual(initialTimeStampsB.Commit(), version);
            replication = Replication.Begin(providerA, providerB, null, _fixtures.reflector);
            TimeStamps timestampsBAfterReplication = AssertTimeStampsForSecondReplication(initialTimeStampsB
                                                                                          , providerB);

            replication.Commit();
            Pilot pilotStoredAfterReplication = new Pilot();

            providerB.StoreNew(pilotStoredAfterReplication);
            providerB.Commit();
            providerB.WaitForPreviousCommits();
            version = providerB.ObjectVersion(pilotStoredAfterReplication);
            Assert.IsGreater(timestampsBAfterReplication.Commit(), version);
        }
Example #3
0
        protected virtual void ReplicateAll(ITestableReplicationProviderInside from, ITestableReplicationProviderInside
                                            to, IReplicationEventListener listener)
        {
            IReplicationSession replication = Replication.Begin(from, to, listener, _fixtures
                                                                .reflector);

            ReplicateAll(replication, from.ObjectsChangedSinceLastReplication().GetEnumerator
                             ());
        }
Example #4
0
        protected virtual void ReplicateClass(ITestableReplicationProviderInside providerA
                                              , ITestableReplicationProviderInside providerB, Type clazz)
        {
            IReplicationSession replication = Replication.Begin(providerA, providerB, null, _fixtures
                                                                .reflector);
            IEnumerator allObjects = providerA.ObjectsChangedSinceLastReplication(clazz).GetEnumerator
                                         ();

            ReplicateAll(replication, allObjects);
        }
Example #5
0
        protected virtual void ReplicateAll(ITestableReplicationProviderInside providerFrom
                                            , ITestableReplicationProviderInside providerTo)
        {
            IReplicationSession replication = Replication.Begin(providerFrom, providerTo, _fixtures
                                                                .reflector);
            IObjectSet changedSet = providerFrom.ObjectsChangedSinceLastReplication();

            if (changedSet.Count == 0)
            {
                throw new Exception("Can't find any objects to replicate");
            }
            ReplicateAll(replication, changedSet.GetEnumerator());
        }
		private int ReplicateBidirectional(ITestableReplicationProviderInside providerA, 
			ITestableReplicationProviderInside providerB, Type clazz)
		{
			int replicatedObjects = 0;
			IReplicationSession replicationSession = Replication.Begin(providerA, providerB, 
				null, _fixtures.reflector);
			IObjectSet changedInA = clazz == null ? providerA.ObjectsChangedSinceLastReplication
				() : providerA.ObjectsChangedSinceLastReplication(clazz);
			foreach (object obj in changedInA)
			{
				replicatedObjects++;
				replicationSession.Replicate(obj);
			}
			IObjectSet changedInB = clazz == null ? providerB.ObjectsChangedSinceLastReplication
				() : providerB.ObjectsChangedSinceLastReplication(clazz);
			foreach (object obj in changedInB)
			{
				replicatedObjects++;
				replicationSession.Replicate(obj);
			}
			replicationSession.Commit();
			return replicatedObjects;
		}
Example #7
0
        protected override void ReplicateClass(ITestableReplicationProviderInside providerA
                                               , ITestableReplicationProviderInside providerB, Type clazz)
        {
            IReplicationSession replication = Replication.Begin(providerA, providerB, _fixtures
                                                                .reflector);
            IEnumerator allObjects = providerA.ObjectsChangedSinceLastReplication(clazz).GetEnumerator
                                         ();

            while (allObjects.MoveNext())
            {
                object obj = allObjects.Current;
                //System.out.println("obj = " + obj);
                replication.Replicate(obj);
            }
            replication.Commit();
        }
Example #8
0
        private int ReplicateAll(ITestableReplicationProviderInside peerA, ITestableReplicationProviderInside
                                 peerB, bool modifiedOnly)
        {
            IReplicationSession replication = Replication.Begin(peerA, peerB, null, _fixtures
                                                                .reflector);
            IEnumerator it = modifiedOnly ? peerA.ObjectsChangedSinceLastReplication(typeof(R0
                                                                                            )).GetEnumerator() : peerA.GetStoredObjects(typeof(R0)).GetEnumerator();
            int replicated = 0;

            while (it.MoveNext())
            {
                R0 r0 = (R0)it.Current;
                replication.Replicate(r0);
                replicated++;
            }
            replication.Commit();
            EnsureCount(peerA, Linkers);
            EnsureCount(peerB, Linkers);
            return(replicated);
        }
Example #9
0
		private int ReplicateAll(ITestableReplicationProviderInside peerA, ITestableReplicationProviderInside
			 peerB, bool modifiedOnly)
		{
			IReplicationSession replication = Replication.Begin(peerA, peerB, null, _fixtures
				.reflector);
			IEnumerator it = modifiedOnly ? peerA.ObjectsChangedSinceLastReplication(typeof(R0
				)).GetEnumerator() : peerA.GetStoredObjects(typeof(R0)).GetEnumerator();
			int replicated = 0;
			while (it.MoveNext())
			{
				R0 r0 = (R0)it.Current;
				replication.Replicate(r0);
				replicated++;
			}
			replication.Commit();
			EnsureCount(peerA, Linkers);
			EnsureCount(peerB, Linkers);
			return replicated;
		}
Example #10
0
		protected override void ReplicateClass(ITestableReplicationProviderInside providerA
			, ITestableReplicationProviderInside providerB, Type clazz)
		{
			IReplicationSession replication = Replication.Begin(providerA, providerB, _fixtures
				.reflector);
			IEnumerator allObjects = providerA.ObjectsChangedSinceLastReplication(clazz).GetEnumerator
				();
			while (allObjects.MoveNext())
			{
				object obj = allObjects.Current;
				//System.out.println("obj = " + obj);
				replication.Replicate(obj);
			}
			replication.Commit();
		}
Example #11
0
		protected virtual void ReplicateClass(ITestableReplicationProviderInside providerA
			, ITestableReplicationProviderInside providerB, Type clazz)
		{
			IReplicationSession replication = Replication.Begin(providerA, providerB, null, _fixtures
				.reflector);
			IEnumerator allObjects = providerA.ObjectsChangedSinceLastReplication(clazz).GetEnumerator
				();
			ReplicateAll(replication, allObjects);
		}
Example #12
0
		protected virtual void ReplicateAll(ITestableReplicationProviderInside from, ITestableReplicationProviderInside
			 to, IReplicationEventListener listener)
		{
			IReplicationSession replication = Replication.Begin(from, to, listener, _fixtures
				.reflector);
			ReplicateAll(replication, from.ObjectsChangedSinceLastReplication().GetEnumerator
				());
		}
Example #13
0
		protected virtual void ReplicateAll(ITestableReplicationProviderInside providerFrom
			, ITestableReplicationProviderInside providerTo)
		{
			IReplicationSession replication = Replication.Begin(providerFrom, providerTo, _fixtures
				.reflector);
			IObjectSet changedSet = providerFrom.ObjectsChangedSinceLastReplication();
			if (changedSet.Count == 0)
			{
				throw new Exception("Can't find any objects to replicate");
			}
			ReplicateAll(replication, changedSet.GetEnumerator());
		}